ソースを参照

对象校验后结果放到object对象的mark中,供数据迁移使用

lvxianyun 3 年 前
コミット
398305da30

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

@@ -92,10 +92,15 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
 
     @Override
     public List<ObjectDigital> insert(List<ObjectDigital> voList) {
-        validateOnSave(voList, false);
-        if(CollUtil.isEmpty(voList)) {
+        //验证失败的数据
+        List<ObjectDigital> errorList = validateOnSave(voList, false);
+
+        if(CollUtil.isEmpty(voList) && CollUtil.isEmpty(errorList)) {
             return null;
         }
+        if(CollUtil.isEmpty(voList) && !CollUtil.isEmpty(errorList)) {
+            return errorList;
+        }
         //获取对象类型
         Map<String, String> typeMap = typeService.queryObjTypeMap();
         voList.forEach(vo -> {
@@ -115,6 +120,8 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
             // 新增后消息
             messageSender.sendMessage(DigitalMessageConstant.OPERATE_AFTER_INSERT, null, vo, false);
         });
+        //返回总体数据
+        voList.addAll(errorList);
         return voList;
     }
 
@@ -679,18 +686,20 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
      * @param voList
      * @param isUpdate
      */
-    private void validateOnSave(List<ObjectDigital> voList, boolean isUpdate) {
-        validateInfoCode(voList);
+    private List<ObjectDigital> validateOnSave(List<ObjectDigital> voList, boolean isUpdate) {
+        return validateInfoCode(voList);
     }
 
     /**
      * 信息点值校验
      * @param voList
+     * @return 对象类型不存在的需要返回
      */
-    private void validateInfoCode(List<ObjectDigital> voList) {
+    private List<ObjectDigital> validateInfoCode(List<ObjectDigital> voList) {
         if(CollUtil.isEmpty(voList)) {
-            return;
+            return Collections.emptyList();
         }
+        List<ObjectDigital> errorList = new ArrayList<>();
         // 保存时,项目ID一定有,而且都是操作这个项目的数据。这是前提,若后续放开全集团保存,则应按项目分组后查询信息点
         String projectId = AppContext.getContext().getProjectId();
         //获取该信息点当前classCode
@@ -704,6 +713,8 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
             Map<String, ObjectInfoDefine> infoMap = typeInfoMap == null ? null : typeInfoMap.get(vo.getClassCode());
             if(MapUtil.isEmpty(infoMap)) {
                 log.error(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
+                vo.setMark(StrUtil.format("没有对象类型【{}】的信息点定义信息!", vo.getClassCode()));
+                errorList.add(vo);
                 continue;
             }
             // 只保留有对象类型的
@@ -727,7 +738,8 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
                     InfoDataFactory.parse(infoMap.get(infoCode), infos.get(infoCode));
                 } catch (BusinessException e) {
                     // 校验不通过的移除
-                    infoKeys.remove();;
+                    infoKeys.remove();
+
                     continue;
                 }
             }
@@ -737,6 +749,7 @@ public class ObjectDigitalServiceImpl extends ServiceImpl<ObjectDigitalMapper, O
         if(CollUtil.isNotEmpty(restList)) {
             voList.addAll(restList);
         }
+        return errorList;
     }
 
     /**

+ 3 - 1
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/digital/entity/ObjectDigital.java

@@ -14,7 +14,6 @@ import lombok.NoArgsConstructor;
 import org.hibernate.validator.constraints.Length;
 
 import javax.validation.constraints.NotNull;
-import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Set;
 
@@ -120,4 +119,7 @@ public class ObjectDigital extends AuditableEntity {
     /** 该对象的对象分类所拥有的classCode集合 */
     @TableField(exist = false,typeHandler = JacksonTypeHandler.class,value = "objTypeClassCodes")
     private Set<String> objTypeClassCodes;
+    /** 单条数据验证信息存储 **/
+    @TableField(exist = false)
+    private String mark;
 }