|
@@ -217,6 +217,23 @@ public class WODispatchDatabaseDBServiceImpl implements WODispatchDatabaseDBServ
|
|
|
woDispatchDatabaseMapper.updateWiths(datas, andWheres, null, "");
|
|
|
//TODO 先修改完方案库,再添加/处置建议
|
|
|
if(!CollectionUtils.isEmpty(dispoalList)) {
|
|
|
+ Map<String, Object> dispoalQueryMap = new HashMap<>();
|
|
|
+ dispoalQueryMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY, andWheres.get(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY));
|
|
|
+ List<Map<String, Object>> dispoalListMap = woDispatchDatabaseDisposalMapper.batchQueryWiths("", "",
|
|
|
+ dispoalQueryMap, new HashMap<>(), "", "");//原数据库的数据
|
|
|
+
|
|
|
+ //TODO 先对比集合,不存在的就删除
|
|
|
+ for (Map<String,Object> map:dispoalListMap){
|
|
|
+ boolean exists = dispoalList.stream()
|
|
|
+ .anyMatch(dispoal -> map.get("key").equals(dispoal.getKey()));
|
|
|
+ if(!exists){
|
|
|
+ Map<String,Object> delWhere = new HashMap<>();
|
|
|
+ delWhere.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY,andWheres.get(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY));
|
|
|
+ delWhere.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY_TWO,map.get("key"));
|
|
|
+ woDispatchDatabaseDisposalMapper.deleteWiths(delWhere,new HashMap<>(),"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for (JPDispatchCmdBatchDispoal dispoal : dispoalList) {
|
|
|
Map<String, Object> entityMap = FastJsonUtil.obj2Map(dispoal, true);
|
|
|
entityMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY, andWheres.get(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY));
|
|
@@ -227,24 +244,33 @@ public class WODispatchDatabaseDBServiceImpl implements WODispatchDatabaseDBServ
|
|
|
woDispatchDatabaseDisposalMapper.inserts(entityMap);
|
|
|
} else {
|
|
|
//TODO 查询是否存在, 如果不存在则以传递值为值然后新增
|
|
|
- Map<String, Object> dispoalQueryMap = new HashMap<>();
|
|
|
- dispoalQueryMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY, andWheres.get(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY));
|
|
|
- dispoalQueryMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY_TWO, dispoal.getKey());
|
|
|
- List<Map<String, Object>> dispoalListMap = woDispatchDatabaseDisposalMapper.batchQueryWiths("", "",
|
|
|
- dispoalQueryMap, new HashMap<>(), "", "");
|
|
|
- if (CollectionUtils.isEmpty(dispoalListMap)) {
|
|
|
- //TODO 说明不存在
|
|
|
+ if (dispoalListMap!=null) {
|
|
|
+ boolean exists = dispoalListMap.stream()
|
|
|
+ .anyMatch(map -> map.get("key").equals(dispoal.getKey()));
|
|
|
+ if(!exists) {
|
|
|
+ //TODO 说明不存在
|
|
|
+ entityMap.put("key", dispoal.getKey());
|
|
|
+ entityMap.put("create_time", TimeTool.getCurMsUTC());
|
|
|
+ entityMap.put("usage", 0);
|
|
|
+ woDispatchDatabaseDisposalMapper.inserts(entityMap);
|
|
|
+ }else{
|
|
|
+ //TODO 说明存在 ,则修改
|
|
|
+ //TODO 说明不存在
|
|
|
+ entityMap.put("update_time", TimeTool.getCurMsUTC());
|
|
|
+
|
|
|
+ Map<String, Object> dispoalUpMap = new HashMap<>();
|
|
|
+ dispoalUpMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY, andWheres.get(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY));
|
|
|
+ dispoalUpMap.put(WODispatchDatabaseDisposalTable.W_INFO.PRIMARY_KEY_TWO, entityMap.get("key"));
|
|
|
+ entityMap.remove("key");
|
|
|
+ entityMap.remove("database_id");
|
|
|
+ woDispatchDatabaseDisposalMapper.updateWiths(entityMap, dispoalUpMap, new HashMap<>(), "");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ //TODO 说明原数据库不存在
|
|
|
entityMap.put("key", dispoal.getKey());
|
|
|
entityMap.put("create_time", TimeTool.getCurMsUTC());
|
|
|
entityMap.put("usage", 0);
|
|
|
woDispatchDatabaseDisposalMapper.inserts(entityMap);
|
|
|
- } else {
|
|
|
- //TODO 说明存在 ,则修改
|
|
|
- //TODO 说明不存在
|
|
|
- entityMap.put("key", dispoal.getKey());
|
|
|
- entityMap.put("update_time", TimeTool.getCurMsUTC());
|
|
|
- entityMap.put("usage", 0);
|
|
|
- woDispatchDatabaseDisposalMapper.updateWiths(entityMap, dispoalQueryMap, new HashMap<>(), "");
|
|
|
}
|
|
|
}
|
|
|
}
|