MaterialAPIService.java
3.09 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
package com.huaheng.api.U8.Service;
import com.huaheng.api.U8.domain.ICSMaterialModel;
import com.huaheng.api.general.service.BasicDataApiService;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.domain.WarehouseCompany;
import com.huaheng.pc.general.company.mapper.WarehouseCompanyMapperAuto;
import com.huaheng.pc.general.material.domain.Material;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class MaterialAPIService {
@Autowired
BasicDataApiService basicDataApiService;;
@Resource
private WarehouseCompanyMapperAuto warehouseCompanyMapperAuto;
@Transactional
public AjaxResult ICSInventory(ICSMaterialModel iCSInventory) {
WarehouseCompany warehouseCompany = new WarehouseCompany();
warehouseCompany.setCompanyCode(iCSInventory.getCompanyCode());
List<WarehouseCompany> list = warehouseCompanyMapperAuto.selectListEntityByEqual(warehouseCompany);
if (list == null || list.size() == 0){
return AjaxResult.error("系统中没有该货主:"+warehouseCompany.toString()+" 信息,请先录入货主信息!");
}
//先查询货主对应的仓库,有几个仓库,就循环几次来添加。
AjaxResult ajaxResult=new AjaxResult();
for (WarehouseCompany item :list ) {
// DictData dictData = new DictData();
// dictData.setDictType("materialType");
// dictData.setWarehouseCode(item.getWarehouseCode());
// dictData.setDictValue(iCSInventory.getcInvCCode());
// dictData.setDictLabel(iCSInventory.getcInvCName());
// dictData.setEnable(true);
Material material = new Material();
material.setCode(iCSInventory.getcInvCode());
material.setBarcode(iCSInventory.getcInvAddCode());
material.setName(iCSInventory.getcInvName());
material.setUserDef1(iCSInventory.getcInvAddCode());
material.setSpecification(iCSInventory.getcInvStd());
material.setMasterUnit(iCSInventory.getcComUnitName());
material.setAssistUnit(iCSInventory.getcAssComUnitCode());
material.setConvertRate(iCSInventory.getfConvertRate());
material.setType(iCSInventory.getcInvCCode());
material.setDictLabel(iCSInventory.getcInvName());
material.setCompanyId(item.getCompanyId());
material.setCompanyCode(item.getCompanyCode());
material.setWarehouseId(item.getWarehouseId());
material.setWarehouseCode(item.getWarehouseCode());
material.setLastUpdatedBy(ShiroUtils.getLoginName());
material.setCreatedBy(ShiroUtils.getLoginName());
material.setLastUpdated(new Date());
ajaxResult = basicDataApiService.material(material);
}
return ajaxResult;
}
}