Browse Source

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 years ago
parent
commit
6abcaddb77

+ 6 - 2
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/define/controller/ObjectInfoController.java

@@ -190,8 +190,12 @@ public class ObjectInfoController {
             projectId = CommonConstant.DEFAULT_ID;
         }
         for (ObjectInfoDefine vo : voList) {
-            vo.setGroupCode(groupCode);
-            vo.setProjectId(projectId);
+            if(StrUtil.isEmpty(vo.getProjectId())){
+                vo.setProjectId(projectId);
+            }
+            if(StrUtil.isEmpty(vo.getGroupCode())){
+                vo.setGroupCode(groupCode);
+            }
         }
     }
 }

+ 7 - 2
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/define/controller/ObjectTypeController.java

@@ -1,6 +1,7 @@
 package com.persagy.dmp.rwd.define.controller;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -134,8 +135,12 @@ public class ObjectTypeController {
             projectId = CommonConstant.DEFAULT_ID;
         }
         for (ObjectTypeDefine vo : voList) {
-            vo.setGroupCode(groupCode);
-            vo.setProjectId(projectId);
+            if(StrUtil.isEmpty(vo.getProjectId())){
+                vo.setProjectId(projectId);
+            }
+            if(StrUtil.isEmpty(vo.getGroupCode())){
+                vo.setGroupCode(groupCode);
+            }
         }
     }
 }

+ 5 - 4
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/define/service/impl/ObjectInfoServiceImpl.java

@@ -109,7 +109,8 @@ public class ObjectInfoServiceImpl implements IObjectInfoService {
 
     /**
      * 保存校验
-     * 编码全局唯一
+     * 仅仅验证单次提交的数据中,projectId-code-classCode组合后的编码不能重复,整体编码是否重复,使用数据库中的唯一索引控制
+     *
      * @param voList
      * @param isUpdate
      */
@@ -118,11 +119,11 @@ public class ObjectInfoServiceImpl implements IObjectInfoService {
         List<String> idList = new ArrayList<>();
         for(ObjectInfoDefine vo:voList) {
             // 编码重复
-            if(!codeSet.add(vo.getCode())) {
-                throw new BusinessException(StrFormatter.format("存在重复编码{},不允许保存!", vo.getCode()));
+            if(!codeSet.add(String.join(StrUtil.UNDERLINE,vo.getProjectId(),vo.getCode(),vo.getClassCode()))) {
+                throw new BusinessException(StrFormatter.format("存在重复编码{}-{}-{},不允许保存!", vo.getProjectId(),vo.getCode(),vo.getClassCode()));
             }
             // 校验器校验
-            InfoDataFactory.parse(vo, null);
+           InfoDataFactory.parse(vo, null);
             // 修改时,收集待排除的主键
             if(isUpdate) {
                 idList.add(vo.getId());

+ 4 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/migrate/service/impl/SyncDataServiceImpl.java

@@ -37,7 +37,10 @@ public class SyncDataServiceImpl extends ServiceImpl<SyncDataMapper, SyncData> i
     @Override
     public List<SyncData> save(List<SyncData> voList) throws Exception {
         //修改采集信息点
-        syncDataMapper.save(voList);
+        //syncDataMapper.save(voList);
+        voList.forEach(vo -> {
+            syncDataMapper.insert(vo);
+        });
         return voList;
     }
 

+ 1 - 2
dmp-business/dmp-rwd/src/main/resources/db/init/schema.sql

@@ -325,6 +325,5 @@ CREATE TABLE IF NOT EXISTS `dt_sync_data` (
    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
    `valid` tinyint NULL DEFAULT 1 COMMENT '合法标识',
    `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '乐观锁',
-   PRIMARY KEY (`id`),
-   UNIQUE KEY `idx_1`(`project_id`,`table_name`,`target_id`,`type`) USING BTREE
+   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC COMMENT='adm交付数据同步到项目现场';

+ 2 - 2
dmp-business/dmp-rwd/src/main/resources/mapper/SyncDatMapper.xml

@@ -32,7 +32,7 @@
     modifier, modified_time, `valid`, ts
   </sql>
 
-  <insert id="save">
+  <!--<insert id="save">
     insert into dt_sync_data
      (id,table_name,target_id, object_type, `type`,
       project_id, sign, ops, 
@@ -57,6 +57,6 @@
     class_code = VALUES(class_code), local_name = VALUES(local_name), local_id = VALUES(local_id),
     `name` = VALUES(name),code = VALUES(code),
     modifier = VALUES(modifier), modified_time = VALUES(modified_time)
-  </insert>
+  </insert>-->
 
 </mapper>