|
|
@@ -1,5 +1,6 @@
|
|
1
|
1
|
package com.chinaitop.depot.intelligent.basicdata.service.impl;
|
|
2
|
2
|
|
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
3
|
4
|
import com.chinaitop.depot.intelligent.basicdata.mapper.TWarningThresholdListMapper;
|
|
4
|
5
|
import com.chinaitop.depot.intelligent.basicdata.mapper.TWarningThresholdMapper;
|
|
5
|
6
|
import com.chinaitop.depot.intelligent.basicdata.model.TWarningThreshold;
|
|
|
@@ -72,42 +73,50 @@ public class WarningThresholdServiceImpl implements WarningThresholdService {
|
|
72
|
73
|
* @param thresholdList
|
|
73
|
74
|
*/
|
|
74
|
75
|
@Override
|
|
75
|
|
- public void saveAndUpdate(List<TWarningThreshold> thresholdList) {
|
|
|
76
|
+ public void saveAndUpdate(List<TWarningThreshold> thresholdList, String[] splitBehindCode) {
|
|
|
77
|
+ // 使用时间作为组条件
|
|
|
78
|
+ Date date = new Date();
|
|
76
|
79
|
for (TWarningThreshold tWarningThreshold : thresholdList) {
|
|
|
80
|
+ // 保存,修改共用set数据
|
|
|
81
|
+ tWarningThreshold.setwUpdateTime(date);
|
|
77
|
82
|
// 保存详情
|
|
78
|
83
|
if (StringUtils.isBlank(tWarningThreshold.getId())) {
|
|
79
|
84
|
tWarningThreshold.setId(uUidUtils.getCodeId(tWarningThreshold.getOrgId(), "t_warning_threshold"));
|
|
80
|
|
- tWarningThreshold.setwUpdateTime(new Date());
|
|
81
|
85
|
tWarningThreshold.setDelFlag(1); //未删除
|
|
82
|
86
|
tWarningThresholdMapper.insert(tWarningThreshold);
|
|
83
|
87
|
} else {
|
|
84
|
88
|
// 更新详情
|
|
85
|
|
- tWarningThreshold.setwUpdateTime(new Date());
|
|
86
|
89
|
tWarningThresholdMapper.updateByPrimaryKeySelective(tWarningThreshold);
|
|
87
|
90
|
}
|
|
88
|
91
|
}
|
|
89
|
92
|
// 保存,修改列表
|
|
90
|
93
|
TWarningThreshold tWarningThreshold = thresholdList.get(0);
|
|
91
|
|
- List<TWarningThresholdList> list = this.getList(tWarningThreshold.getvCfCode(),tWarningThreshold.getOrgId());
|
|
92
|
|
- TWarningThresholdList tWarningThresholdList = new TWarningThresholdList();
|
|
93
|
|
- if (list.size() == 0) {
|
|
94
|
|
- // 保存
|
|
95
|
|
- tWarningThresholdList.setId(uUidUtils.getCodeId(tWarningThreshold.getOrgId(), "t_warning_threshold"));
|
|
96
|
|
- tWarningThresholdList.setOrgId(tWarningThreshold.getOrgId());
|
|
97
|
|
- tWarningThresholdList.setvCfCode(tWarningThreshold.getvCfCode());
|
|
|
94
|
+ // 根据仓房编码多次修改列表
|
|
|
95
|
+ for (int i = 0; i < splitBehindCode.length; i++) {
|
|
|
96
|
+ // 获取每一个仓房编码
|
|
|
97
|
+ String storCode = splitBehindCode[i];
|
|
|
98
|
+ List<TWarningThresholdList> list = this.getList(storCode, tWarningThreshold.getOrgId());
|
|
|
99
|
+ TWarningThresholdList tWarningThresholdList = new TWarningThresholdList();
|
|
|
100
|
+ // 保存,修改共用set数据
|
|
|
101
|
+ tWarningThresholdList.setUpdateTime(date);
|
|
98
|
102
|
tWarningThresholdList.setUpdatePerson(tWarningThreshold.getwUpdatePerson());
|
|
99
|
|
- tWarningThresholdList.setUpdateTime(new Date());
|
|
100
|
|
- tWarningThresholdList.setDelFlag(1); //未删除
|
|
101
|
|
- tWarningThresholdListMapper.insert(tWarningThresholdList);
|
|
102
|
|
- } else {
|
|
103
|
|
- // 更新
|
|
104
|
|
- TWarningThresholdListExample example = new TWarningThresholdListExample();
|
|
105
|
|
- TWarningThresholdListExample.Criteria criteria = example.createCriteria();
|
|
106
|
|
- if (StringUtils.isNotBlank(tWarningThreshold.getvCfCode()))
|
|
107
|
|
- criteria.andVCfCodeEqualTo(tWarningThreshold.getvCfCode());
|
|
108
|
|
- tWarningThresholdList.setUpdatePerson(tWarningThreshold.getwUpdatePerson());
|
|
109
|
|
- tWarningThresholdList.setUpdateTime(new Date());
|
|
110
|
|
- tWarningThresholdListMapper.updateByExampleSelective(tWarningThresholdList, example);
|
|
|
103
|
+ if (list.size() == 0) {
|
|
|
104
|
+ // 保存
|
|
|
105
|
+ tWarningThresholdList.setId(uUidUtils.getCodeId(tWarningThreshold.getOrgId(), "t_warning_threshold"));
|
|
|
106
|
+ tWarningThresholdList.setOrgId(tWarningThreshold.getOrgId());
|
|
|
107
|
+ tWarningThresholdList.setvCfCode(storCode);
|
|
|
108
|
+ tWarningThresholdList.setUpdatePerson(tWarningThreshold.getwUpdatePerson());
|
|
|
109
|
+ tWarningThresholdList.setDelFlag(1); //未删除
|
|
|
110
|
+ tWarningThresholdListMapper.insert(tWarningThresholdList);
|
|
|
111
|
+ } else {
|
|
|
112
|
+ // 更新
|
|
|
113
|
+ TWarningThresholdListExample example = new TWarningThresholdListExample();
|
|
|
114
|
+ TWarningThresholdListExample.Criteria criteria = example.createCriteria();
|
|
|
115
|
+ if (StringUtils.isNotBlank(storCode))
|
|
|
116
|
+ criteria.andVCfCodeEqualTo(storCode);
|
|
|
117
|
+ tWarningThresholdList.setUpdatePerson(tWarningThreshold.getwUpdatePerson());
|
|
|
118
|
+ tWarningThresholdListMapper.updateByExampleSelective(tWarningThresholdList, example);
|
|
|
119
|
+ }
|
|
111
|
120
|
}
|
|
112
|
121
|
}
|
|
113
|
122
|
|
|
|
@@ -275,4 +284,50 @@ public class WarningThresholdServiceImpl implements WarningThresholdService {
|
|
275
|
284
|
return mapObj;
|
|
276
|
285
|
}
|
|
277
|
286
|
|
|
|
287
|
+ /**
|
|
|
288
|
+ * 根据时间和组织编码查询多仓房编码,组织编码拦截器获取
|
|
|
289
|
+ *
|
|
|
290
|
+ * @param updateTime
|
|
|
291
|
+ * @return
|
|
|
292
|
+ */
|
|
|
293
|
+ @Override
|
|
|
294
|
+ public String getCfCodeByTime(String updateTime) {
|
|
|
295
|
+ return tWarningThresholdListMapper.getCfCodeByTime(updateTime);
|
|
|
296
|
+ }
|
|
|
297
|
+
|
|
|
298
|
+ // 改变list数组,多仓房编码拆分成多个list
|
|
|
299
|
+ public List<TWarningThreshold> storeListData(String thresholdListJson, String[] splitBehindCode) {
|
|
|
300
|
+ // 缓存空间
|
|
|
301
|
+ List<TWarningThreshold> newThresholdList = new ArrayList<>();
|
|
|
302
|
+ // 截取仓房编码
|
|
|
303
|
+ for (int i = 0; i < splitBehindCode.length; i++) {
|
|
|
304
|
+ // 数据倍增,防止list数据"$ref": "$[0]" 重复引用对象地址
|
|
|
305
|
+ List<TWarningThreshold> tWarningThresholds = JSON.parseArray(thresholdListJson, TWarningThreshold.class);
|
|
|
306
|
+ for (int y = 0; y < tWarningThresholds.size(); y++) {
|
|
|
307
|
+ TWarningThreshold tWarningThreshold = tWarningThresholds.get(y);
|
|
|
308
|
+ tWarningThreshold.setvCfCode(splitBehindCode[i]);
|
|
|
309
|
+ newThresholdList.add(tWarningThreshold);
|
|
|
310
|
+ }
|
|
|
311
|
+ }
|
|
|
312
|
+ return newThresholdList;
|
|
|
313
|
+ }
|
|
|
314
|
+
|
|
|
315
|
+ @Override
|
|
|
316
|
+ public void deleteByStoreCodeAndOrgId(String[] splitBehindCode, String orgId) {
|
|
|
317
|
+ for (int i = 0; i < splitBehindCode.length; i++) {
|
|
|
318
|
+ // 删除列表数据
|
|
|
319
|
+ TWarningThresholdListExample example = new TWarningThresholdListExample();
|
|
|
320
|
+ TWarningThresholdListExample.Criteria criteria = example.createCriteria();
|
|
|
321
|
+ criteria.andVCfCodeEqualTo(splitBehindCode[i]);
|
|
|
322
|
+ criteria.andOrgIdEqualTo(orgId);
|
|
|
323
|
+ tWarningThresholdListMapper.deleteByExample(example);
|
|
|
324
|
+ // 删除详情数据
|
|
|
325
|
+ TWarningThresholdExample example1 = new TWarningThresholdExample();
|
|
|
326
|
+ TWarningThresholdExample.Criteria criteria1 = example1.createCriteria();
|
|
|
327
|
+ criteria1.andVCfCodeEqualTo(splitBehindCode[i]);
|
|
|
328
|
+ criteria1.andOrgIdEqualTo(orgId);
|
|
|
329
|
+ tWarningThresholdMapper.deleteByExample(example1);
|
|
|
330
|
+ }
|
|
|
331
|
+ }
|
|
|
332
|
+
|
|
278
|
333
|
}
|