|
|
@@ -4,12 +4,15 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
4
|
4
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
5
|
5
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
6
|
6
|
import com.shinsoft.sto.mapper.ware.ProdMasterMapper;
|
|
|
7
|
+import com.shinsoft.sto.mapper.ware.ChangeRecordMapper;
|
|
7
|
8
|
import com.shinsoft.sto.model.system.ResponseCodeMsg;
|
|
|
9
|
+import com.shinsoft.sto.model.ware.ChangeRecord;
|
|
8
|
10
|
import com.shinsoft.sto.model.ware.ProdMaster;
|
|
9
|
11
|
import com.shinsoft.sto.service.ware.ProdMasterService;
|
|
10
|
|
-import com.shinsoft.tools.JSONTools;
|
|
11
|
12
|
import com.shinsoft.sto.model.system.ResultJSON;
|
|
12
|
13
|
import org.springframework.stereotype.Service;
|
|
|
14
|
+import org.springframework.beans.BeanUtils;
|
|
|
15
|
+import org.springframework.transaction.annotation.Transactional;
|
|
13
|
16
|
|
|
14
|
17
|
import java.util.Map;
|
|
15
|
18
|
|
|
|
@@ -25,6 +28,11 @@ import java.util.Map;
|
|
25
|
28
|
public class ProdMasterServiceImpl extends ServiceImpl<ProdMasterMapper, ProdMaster> implements ProdMasterService {
|
|
26
|
29
|
|
|
27
|
30
|
ResultJSON resultJSON;
|
|
|
31
|
+ private final ChangeRecordMapper changeRecordMapper;
|
|
|
32
|
+
|
|
|
33
|
+ public ProdMasterServiceImpl(ChangeRecordMapper changeRecordMapper) {
|
|
|
34
|
+ this.changeRecordMapper = changeRecordMapper;
|
|
|
35
|
+ }
|
|
28
|
36
|
|
|
29
|
37
|
@Override
|
|
30
|
38
|
public ResultJSON query(int page, int rows, Map<String, Object> map) {
|
|
|
@@ -37,5 +45,64 @@ public class ProdMasterServiceImpl extends ServiceImpl<ProdMasterMapper, ProdMas
|
|
37
|
45
|
return ResultJSON.error(ResponseCodeMsg.CODE_EX, ex.getMessage());
|
|
38
|
46
|
}
|
|
39
|
47
|
}
|
|
|
48
|
+
|
|
|
49
|
+ @Override
|
|
|
50
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
51
|
+ public ResultJSON edit(ProdMaster prodMaster) {
|
|
|
52
|
+ try {
|
|
|
53
|
+ if (prodMaster == null || prodMaster.getId() == null || prodMaster.getId().trim().isEmpty()) {
|
|
|
54
|
+ return ResultJSON.error("材料ID不能为空");
|
|
|
55
|
+ }
|
|
|
56
|
+
|
|
|
57
|
+ ProdMaster dbData = baseMapper.selectById(prodMaster.getId());
|
|
|
58
|
+ if (dbData == null) {
|
|
|
59
|
+ return ResultJSON.error("未找到对应的材料信息");
|
|
|
60
|
+ }
|
|
|
61
|
+
|
|
|
62
|
+ // 记录旧数据到变更表
|
|
|
63
|
+ ChangeRecord record = new ChangeRecord();
|
|
|
64
|
+ BeanUtils.copyProperties(dbData, record);
|
|
|
65
|
+ record.setId(null);
|
|
|
66
|
+ changeRecordMapper.insert(record);
|
|
|
67
|
+
|
|
|
68
|
+ // 按需更新字段
|
|
|
69
|
+ if (prodMaster.getQuantity() != null) {
|
|
|
70
|
+ dbData.setQuantity(prodMaster.getQuantity());
|
|
|
71
|
+ }
|
|
|
72
|
+ if (prodMaster.getWeight() != null) {
|
|
|
73
|
+ dbData.setWeight(prodMaster.getWeight());
|
|
|
74
|
+ }
|
|
|
75
|
+ if (prodMaster.getAttrib01() != null) {
|
|
|
76
|
+ dbData.setAttrib01(prodMaster.getAttrib01());
|
|
|
77
|
+ }
|
|
|
78
|
+ if (prodMaster.getAttrib02() != null) {
|
|
|
79
|
+ dbData.setAttrib02(prodMaster.getAttrib02());
|
|
|
80
|
+ }
|
|
|
81
|
+ if (prodMaster.getAttrib04() != null) {
|
|
|
82
|
+ dbData.setAttrib04(prodMaster.getAttrib04());
|
|
|
83
|
+ }
|
|
|
84
|
+ if (prodMaster.getAttrib05() != null) {
|
|
|
85
|
+ dbData.setAttrib05(prodMaster.getAttrib05());
|
|
|
86
|
+ }
|
|
|
87
|
+ if (prodMaster.getOwnerCompany() != null) {
|
|
|
88
|
+ dbData.setOwnerCompany(prodMaster.getOwnerCompany());
|
|
|
89
|
+ }
|
|
|
90
|
+ if (prodMaster.getCustomerCompany() != null) {
|
|
|
91
|
+ dbData.setCustomerCompany(prodMaster.getCustomerCompany());
|
|
|
92
|
+ }
|
|
|
93
|
+ if (prodMaster.getDeliveryAddress() != null) {
|
|
|
94
|
+ dbData.setDeliveryAddress(prodMaster.getDeliveryAddress());
|
|
|
95
|
+ }
|
|
|
96
|
+ if (prodMaster.getRemark1() != null) {
|
|
|
97
|
+ dbData.setRemark1(prodMaster.getRemark1());
|
|
|
98
|
+ }
|
|
|
99
|
+
|
|
|
100
|
+ baseMapper.updateById(dbData);
|
|
|
101
|
+ return ResultJSON.success(dbData);
|
|
|
102
|
+ } catch (Exception ex) {
|
|
|
103
|
+ ex.printStackTrace();
|
|
|
104
|
+ return ResultJSON.error(ResponseCodeMsg.CODE_EX, ex.getMessage());
|
|
|
105
|
+ }
|
|
|
106
|
+ }
|
|
40
|
107
|
}
|
|
41
|
108
|
|