GeneralService.java
5.25 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
package com.huaheng.api.U8.service;
import com.huaheng.api.U8.domain.ICSInventoryModel;
import com.huaheng.api.U8.domain.ICSWarehouseModel;
import com.huaheng.common.exception.service.ServiceException;
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 com.huaheng.pc.general.material.service.IMaterialService;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.dict.domain.DictType;
import com.huaheng.pc.system.dict.service.IDictDataService;
import com.huaheng.pc.system.dict.service.IDictTypeService;
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 GeneralService {
@Autowired
IDictTypeService dictTypeService;
@Autowired
IDictDataService dictDataService;
@Autowired
IMaterialService materialService;
@Resource
private WarehouseCompanyMapperAuto warehouseCompanyMapperAuto;
@Transactional
public AjaxResult ICSInventory(ICSInventoryModel iCSInventory) {
//先查询货主对应的仓库,有几个仓库,就循环几次来添加。
WarehouseCompany warehouseCompany = new WarehouseCompany();
warehouseCompany.setCompanyCode(iCSInventory.getCompanyCode());
List<WarehouseCompany> list = warehouseCompanyMapperAuto.selectListEntityByEqual(warehouseCompany);
for (WarehouseCompany item :list ) {
int result = 0;
//检查字典表是否存在物料类型编码,如果没有就添加
DictData dictData = new DictData();
dictData.setDictType("materialType");
dictData.setWarehouseCode(item.getWarehouseCode());
dictData.setDictValue(iCSInventory.getcInvStd());
List<DictData> dictDatas = dictDataService.selectDictDataList(dictData);
if (dictDatas.size() < 1) {
//找出字典头表的id
DictType dictType = new DictType();
dictType.setWarehouseCode(item.getWarehouseCode());
dictType.setDictType("materialType");
List<DictType> dictList = dictTypeService.selectDictTypeList(dictType);
if (dictList.size() < 1) {
throw new ServiceException("字典表头没有 物料类型!");
}
//增新一条字典明细表的记录
dictData.setHeaderId(dictList.get(0).getId());
dictData.setWarehouseId(item.getWarehouseId());
dictData.setDictLabel(iCSInventory.getcInvCName());
dictData.setEnable(true);
result = dictDataService.insertDictData(dictData);
if (result < 1) {
throw new ServiceException("新增物料类型失败!");
}
}
// 检查是否存在物料,如果存在就修改,不存在就新增
Material material = new Material();
material.setCode(iCSInventory.getcInvCode());
material.setWarehouseCode(item.getWarehouseCode());
material = materialService.selectFirstEntity(material);
if (material == null) {
material = new Material();
}
material.setCode(iCSInventory.getcInvCode());
material.setBarcode(iCSInventory.getcInvCode());
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.setCompanyId(item.getCompanyId());
material.setCompanyCode(item.getCompanyCode());
material.setWarehouseId(item.getWarehouseId());
material.setWarehouseCode(item.getWarehouseCode());
material.setLastUpdatedBy(ShiroUtils.getLoginName());
material.setLastUpdated(new Date());
if (material.getId() == null) {
material.setCreatedBy(ShiroUtils.getLoginName());
material.setCreated(new Date());
result = materialService.insert(material);
if (result < 1) {
throw new ServiceException("新增物料类型失败!");
}
}
else {
result = materialService.updateByModel(material);
if (result < 1) {
throw new ServiceException("编辑物料类型失败!");
}
}
}
return AjaxResult.success("成功!");
}
public AjaxResult ICSWarehouse(ICSWarehouseModel iCSWarehouse) {
return AjaxResult.success("成功!");
}
}