Kaynağa Gözat

优化:优化对象更新逻辑

lijie 2 yıl önce
ebeveyn
işleme
f3046d9c6e

+ 12 - 3
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/ObjectDigitalServiceImpl.java

@@ -138,19 +138,28 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
         if(CollUtil.isEmpty(voList)) {
             return null;
         }
+        List<ObjectDigital> updateList = CollUtil.newArrayList();
+        Map<String,ObjectDigital> oldMap = MapUtil.newHashMap();
         voList.forEach(vo -> {
             ObjectDigital dbVO = MapUtil.get(dbMap, vo.getId(), ObjectDigital.class);
             // 容错处理
             if(dbVO == null) {
                 return;
             }
+            oldMap.put(dbVO.getId(),dbVO);
             // 更新数据的属性合并和删除
             ensureUpdateInfos(vo, dbVO, removeMap.get(vo.getId()));
             // 修改
-            dao.updateById(vo);
-            // 修改后消息
-            messageSender.sendMessage(DigitalMessageConstant.OPERATE_AFTER_UPDATE, dbVO, vo, false);
+            updateList.add(vo);
+            // dao.updateById(vo);60
         });
+        if (CollUtil.isNotEmpty(updateList)){
+            this.updateBatchById(updateList);
+            for (ObjectDigital vo : updateList) {
+                // 修改后消息
+                messageSender.sendMessage(DigitalMessageConstant.OPERATE_AFTER_UPDATE, oldMap.get(vo.getId()), vo, false);
+            }
+        }
         return voList;
     }