ICSCyclecountAPIService.java
5.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.huaheng.pc.u8.service;
import com.alibaba.fastjson.JSON;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.warehouse.domain.Warehouse;
import com.huaheng.pc.config.warehouse.service.WarehouseService;
import com.huaheng.pc.inventory.adjustDetail.domain.AdjustDetail;
import com.huaheng.pc.inventory.adjustDetail.service.AdjustDetailService;
import com.huaheng.pc.inventory.adjustHeader.domain.AdjustHeader;
import com.huaheng.pc.inventory.adjustHeader.service.AdjustHeaderService;
import com.huaheng.pc.inventory.cycleCountHeader.service.CycleCountHeaderService;
import com.huaheng.pc.u8.domain.ICSCyclecountAdjustDetail;
import com.huaheng.pc.u8.domain.ICSCyclecountAdjustHeader;
import com.huaheng.pc.u8.domain.ICSCyclecountModel;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
@Service
public class ICSCyclecountAPIService {
@Resource
private AdjustHeaderService adjustHeaderService;
@Resource
private AdjustDetailService adjustDetailService;
@Resource
private WarehouseService warehouseService;
@Resource
private MaterialService materialService;
public AjaxResult confirm(String code , String sourceCode,String warehouseCode) {
//查找状态为10的盘点差异主单
AdjustHeader adjustHeader=new AdjustHeader();
adjustHeader.setProcessStamp(String.valueOf(10));
adjustHeader.setCode(code);
adjustHeader.setReferCode(sourceCode);
adjustHeader.setWarehouseCode(warehouseCode);
List<AdjustHeader> adjustlist=adjustHeaderService.getByDoamin(adjustHeader);
if(adjustlist==null||adjustlist.size()==0){
return AjaxResult.error("没有盘点差异上传");
}
adjustHeader=adjustlist.get(0);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
//替换成icsCyclecountAdjustHeader
ICSCyclecountAdjustHeader icsCyclecountAdjustHeader=new ICSCyclecountAdjustHeader();
icsCyclecountAdjustHeader.setCCode(adjustHeader.getCode());
icsCyclecountAdjustHeader.setCId(adjustHeader.getId());
icsCyclecountAdjustHeader.setDDate(simpleDateFormat.format(adjustHeader.getCreated()));
icsCyclecountAdjustHeader.setDDate2(simpleDateFormat.format(adjustHeader.getLastUpdated()));
icsCyclecountAdjustHeader.setDOperator(adjustHeader.getCreatedBy());
icsCyclecountAdjustHeader.setDVerifyer(adjustHeader.getLastUpdatedBy());
icsCyclecountAdjustHeader.setCompanyCode(adjustHeader.getCompanyCode());
//通过主单id找到子单
AdjustDetail adjustDetail=new AdjustDetail();
adjustDetail.setAdjustCode(adjustHeader.getCode());
List<AdjustDetail> adjustDetails=adjustDetailService.getByDoamin(adjustDetail);
// Material material=new Material();
// 查询仓库名
String warehouseName=warehouseService.getWarehouseNameByCode(adjustHeader.getWarehouseCode());
List<ICSCyclecountAdjustDetail> icsCyclecountAdjustDetails=new ArrayList<>();
//替换成icsCyclecountAdjustDetail
for (AdjustDetail item :adjustDetails){
ICSCyclecountAdjustDetail icsCyclecountAdjustDetail = new ICSCyclecountAdjustDetail();
icsCyclecountAdjustDetail.setCDID(item.getId());
icsCyclecountAdjustDetail.setCCode(adjustHeader.getCode());
icsCyclecountAdjustDetail.setCId(adjustHeader.getId());
icsCyclecountAdjustDetail.setCWhCode(adjustHeader.getWarehouseCode());
icsCyclecountAdjustDetail.setCWhName(warehouseName);
icsCyclecountAdjustDetail.setCWarecell(item.getLocationCode());
icsCyclecountAdjustDetail.setCContainer(item.getContainerCode());
icsCyclecountAdjustDetail.setCItemName(item.getProjectNo());
icsCyclecountAdjustDetail.setCInvCode(item.getMaterialCode());
Material material=materialService.getMaterialByCode(item.getMaterialCode());
if(material!=null){
icsCyclecountAdjustDetail.setCInvName(material.getName());
icsCyclecountAdjustDetail.setCComUnitName(material.getUnit());
}
icsCyclecountAdjustDetail.setCInvStd(item.getMaterialSpec());
icsCyclecountAdjustDetail.setIQuantity(item.getFromQty());
icsCyclecountAdjustDetail.setDQuantity(item.getToQty());
icsCyclecountAdjustDetail.setCAttribute(item.getFromInventorySts());
icsCyclecountAdjustDetail.setAQuantiy(item.getGapQty());
icsCyclecountAdjustDetail.setCRegister(item.getCreatedBy());
icsCyclecountAdjustDetail.setCRegisterDate(simpleDateFormat.format(item.getCreated()));
icsCyclecountAdjustDetail.setCompanyCode(item.getCompanyCode());
icsCyclecountAdjustDetails.add(icsCyclecountAdjustDetail);
}
//把主单和子单整合到一起
ICSCyclecountModel icsCyclecountModel=new ICSCyclecountModel();
icsCyclecountModel.setIcsCyclecountAdjustHeader(icsCyclecountAdjustHeader);
icsCyclecountModel.setIcsCyclecountAdjustDetails(icsCyclecountAdjustDetails);
String JsonParam = JSON.toJSONString(icsCyclecountModel);
String url="http://58.240.189.134:8099/api/"; //对端地址
String result = HttpUtils.bodypost(url, JsonParam,adjustHeader.getWarehouseCode());
AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);
if(!ajaxResult.hasErr()) {
adjustHeader.setProcessStamp(String.valueOf(20));
adjustHeaderService.updateById(adjustHeader);
}
return ajaxResult;
}
}