ICSCyclecountAPIService.java
6.16 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
package com.huaheng.api.U8.Service;
import com.alibaba.fastjson.JSON;
import com.huaheng.api.U8.domain.ICSCyclecountAdjustDetail;
import com.huaheng.api.U8.domain.ICSCyclecountAdjustHeader;
import com.huaheng.api.U8.domain.ICSCyclecountModel;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
import com.huaheng.pc.general.warehouse.domain.Warehouse;
import com.huaheng.pc.general.warehouse.service.IWarehouseService;
import com.huaheng.pc.inventory.cyclecountAdjust.domain.CyclecountAdjust;
import com.huaheng.pc.inventory.cyclecountAdjust.mapper.CyclecountAdjustMapperAuto;
import com.huaheng.pc.inventory.cyclecountAdjust.service.ICycleconutAdjustService;
import com.huaheng.pc.inventory.cyclecountAdjustDetail.domain.CyclecountAdjustDetail;
import com.huaheng.pc.inventory.cyclecountAdjustDetail.service.ICyclecountAdjustDetailService;
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 CyclecountAdjustMapperAuto cyclecountAdjustMapperAuto;
@Resource
private ICycleconutAdjustService cycleconutAdjustService;
@Resource
private ICyclecountAdjustDetailService cyclecountAdjustDetailService;
@Resource
private IWarehouseService warehouseService;
@Resource
private IMaterialService materialService;
public AjaxResult confirm(String code , String sourceCode) {
//查找状态为10的盘点差异主单
CyclecountAdjust cyclecountAdjust=new CyclecountAdjust();
cyclecountAdjust.setStatus(10);
cyclecountAdjust.setCode(code);
cyclecountAdjust.setSourceCode(sourceCode);
cyclecountAdjust=cyclecountAdjustMapperAuto.selectFirstEntity(cyclecountAdjust);
if(cyclecountAdjust==null){
return AjaxResult.error("没有盘点差异上传");
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
//替换成icsCyclecountAdjustHeader
ICSCyclecountAdjustHeader icsCyclecountAdjustHeader=new ICSCyclecountAdjustHeader();
icsCyclecountAdjustHeader.setcCode(cyclecountAdjust.getCode());
icsCyclecountAdjustHeader.setcId(cyclecountAdjust.getId());
icsCyclecountAdjustHeader.setdDate(simpleDateFormat.format(cyclecountAdjust.getCreated()));
icsCyclecountAdjustHeader.setdDate2(simpleDateFormat.format(cyclecountAdjust.getLastUpdated()));
icsCyclecountAdjustHeader.setdOperator(cyclecountAdjust.getCreatedBy());
icsCyclecountAdjustHeader.setdVerifyer(cyclecountAdjust.getLastUpdatedBy());
icsCyclecountAdjustHeader.setCompanyCode(cyclecountAdjust.getCompanyCode());
//通过主单id找到子单
CyclecountAdjustDetail cyclecountAdjustDetail=new CyclecountAdjustDetail();
cyclecountAdjustDetail.setCyclecountAdjustCode(cyclecountAdjust.getCode());
List<CyclecountAdjustDetail> cyclecountAdjustDetails=cyclecountAdjustDetailService.selectListEntityByEqual(cyclecountAdjustDetail);
Material material=new Material();
Warehouse warehouse=new Warehouse();
warehouse.setCode(cyclecountAdjust.getWarehouseCode());
String warehouseName=warehouseService.selectFirstEntity(warehouse).getName();
List<ICSCyclecountAdjustDetail> icsCyclecountAdjustDetails=new ArrayList<>();
//替换成icsCyclecountAdjustDetail
for (CyclecountAdjustDetail item :cyclecountAdjustDetails){
ICSCyclecountAdjustDetail icsCyclecountAdjustDetail = new ICSCyclecountAdjustDetail();
icsCyclecountAdjustDetail.setcDID(item.getId());
icsCyclecountAdjustDetail.setcCode(cyclecountAdjust.getCode());
icsCyclecountAdjustDetail.setcId(cyclecountAdjust.getId());
icsCyclecountAdjustDetail.setcWhCode(cyclecountAdjust.getWarehouseCode());
icsCyclecountAdjustDetail.setcWhName(warehouseName);
icsCyclecountAdjustDetail.setcWarecell(item.getLocationCode());
icsCyclecountAdjustDetail.setcContainer(item.getContainerCode());
icsCyclecountAdjustDetail.setcItemName(item.getProject());
icsCyclecountAdjustDetail.setcInvCode(item.getMaterialCode());
material.setCode(item.getMaterialCode());
String materialName=materialService.selectFirstEntity(material).getName();
String ComUnitName=materialService.selectFirstEntity(material).getMasterUnit();
icsCyclecountAdjustDetail.setcInvName(materialName);
icsCyclecountAdjustDetail.setcInvStd(item.getMaterialSpecification());
icsCyclecountAdjustDetail.setiQuantity(item.getSystemQty());
icsCyclecountAdjustDetail.setcComUnitName(ComUnitName);
icsCyclecountAdjustDetail.setdQuantity(item.getCountedQty());
icsCyclecountAdjustDetail.setcAttribute(item.getInventoryStatus());
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);
AjaxResult ajaxResult = JSON.parseObject(result, AjaxResult.class);
if(!ajaxResult.hasErr()) {
cyclecountAdjust.setStatus(20);
cycleconutAdjustService.updateByModel(cyclecountAdjust);
}
return ajaxResult;
}
}