Browse Source

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

lijie 3 years ago
parent
commit
37a23a875e

+ 20 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/migrate/controller/DigitalMigrateLogController.java

@@ -1,11 +1,14 @@
 package com.persagy.dmp.rwd.migrate.controller;
 
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.basic.utils.QueryCriteriaHelper;
 import com.persagy.dmp.common.constant.CommonConstant;
 import com.persagy.dmp.common.constant.ResponseCode;
+import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.exception.BusinessException;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ParamCheckUtil;
@@ -65,7 +68,8 @@ public class DigitalMigrateLogController {
     public CommonResult<List<SyncData>> createBatch(@Valid @RequestBody List<SyncData> voList){
         //基础参数校验
         ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
-        //创建默认条件
+        String projectId = AppContext.getContext().getProjectId();
+        ensureDefaultValue(voList,projectId);
         try {
             service.save(voList);
         } catch (Exception e) {
@@ -74,4 +78,19 @@ public class DigitalMigrateLogController {
         //批量新增迁移日志
         return ResultHelper.multi(voList);
     }
+
+    /**
+     * 补充默认值
+     * @param voList
+     */
+    private void ensureDefaultValue(List<SyncData> voList,String projectId) {
+        for (SyncData vo : voList) {;
+            if(StrUtil.isBlank(vo.getId())) {
+                vo.setId(IdUtil.fastSimpleUUID());
+            }
+            if(StrUtil.isBlank(vo.getProjectId())) {
+                vo.setProjectId(projectId);
+            }
+        }
+    }
 }

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

@@ -305,7 +305,7 @@ CREATE TABLE IF NOT EXISTS `dt_sync_data` (
    `id` varchar(200) NOT NULL COMMENT '消息id',
    `table_name` varchar(32) NOT NULL COMMENT '同步表名称',
    `target_id` varchar(100) DEFAULT NULL COMMENT '对象id,关系id,类型id,信息点id',
-   `obj_type` varchar(200) DEFAULT NULL COMMENT '对象类型',
+   `object_type` varchar(200) DEFAULT NULL COMMENT '对象类型',
    `type` varchar(200) DEFAULT NULL COMMENT '操作类型',
    `project_id` varchar(200) DEFAULT NULL COMMENT '项目id',
    `sign` int DEFAULT NULL COMMENT '标记',
@@ -324,7 +324,7 @@ CREATE TABLE IF NOT EXISTS `dt_sync_data` (
    `creation_time` char(14) NULL DEFAULT NULL COMMENT '创建时间',
    `modifier` varchar(32) NULL DEFAULT NULL COMMENT '最后修改人',
    `modified_time` char(14) NULL DEFAULT NULL COMMENT '最后修改时间',
-   `valid` tinyint 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

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

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.persagy.dmp.rwd.migrate.SyncDataMapper">
+<mapper namespace="com.persagy.dmp.rwd.migrate.dao.SyncDataMapper">
   <resultMap id="BaseResultMap" type="com.persagy.dmp.rwd.migrate.entity.SyncData">
     <id column="id" jdbcType="VARCHAR" property="id" />
     <id column="table_name" jdbcType="VARCHAR" property="tableName" />
     <result column="target_id" jdbcType="VARCHAR" property="targetId" />
-    <result column="obj_type" jdbcType="VARCHAR" property="objType" />
+    <result column="object_type" jdbcType="VARCHAR" property="objectType" />
     <result column="type" jdbcType="VARCHAR" property="type" />
     <result column="project_id" jdbcType="VARCHAR" property="projectId" />
     <result column="sign" jdbcType="INTEGER" property="sign" />
@@ -28,32 +28,38 @@
     <result column="ts" jdbcType="TIMESTAMP" property="ts" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, table_name, target_id, obj_type, `type`, project_id, sign, ops, ops_name, from_id, to_id,
+    id, table_name, target_id, object_type, `type`, project_id, sign, ops, ops_name, from_id, to_id,
     error, class_code, local_name, local_id, `name`, code, obj_name, creator, creation_time,
     modifier, modified_time, `valid`, ts
   </sql>
 
   <insert id="save">
-    insert into dt_sync_data (id,table_name,target_id, obj_type, `type`,
+    <selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
+      select uuid()
+    </selectKey>
+    insert into dt_sync_data
+     (id,table_name,target_id, object_type, `type`,
       project_id, sign, ops, 
       ops_name, from_id, to_id, 
       error, class_code, local_name, 
       local_id, `name`, code,
       obj_name, creator, creation_time, 
-      modifier, modified_time, `valid`, 
-      ts)
+      modifier, modified_time)
+    VALUES
     <foreach collection="vos" item="vo" open="(" close=")" separator="),(">
-      #{vo.id},#{vo.tableName},#{vo.targetId},#{vo.objType},#{vo.type},#{vo.projectId},
-      #{vo.sign},#{vo.ops},#{vo.opsName},#{vo.fromId},#{vo.toId},
+      #{vo.id},#{vo.tableName},#{vo.targetId},#{vo.objectType},#{vo.type},
+      #{vo.projectId},#{vo.sign},#{vo.ops},
+      #{vo.opsName},#{vo.fromId},#{vo.toId},
       #{vo.error},#{vo.classCode},#{vo.localName},
       #{vo.localId},#{vo.name},#{vo.code},
-      #{vo.creator},#{vo.creationTime},#{vo.modifier},#{vo.modifiedTime},#{vo.valid}
+      #{vo.objName},#{vo.creator},#{vo.creationTime},
+      #{vo.modifier},#{vo.modifiedTime}
     </foreach>
     ON DUPLICATE KEY UPDATE
-    type = VALUES(type), ops = VALUES(ops), opsName = VALUES(opsName),
+    type = VALUES(type), ops = VALUES(ops), ops_name = VALUES(ops_name),
     from_id = VALUES(from_id), to_id = VALUES(to_id), error = VALUES(error),
     class_code = VALUES(class_code), local_name = VALUES(local_name), local_id = VALUES(local_id),
-    `name` = VALUES(name), code_name = VALUES(local_name), obj_name = VALUES(obj_name),code = VALUES(code),
+    `name` = VALUES(name), obj_name = VALUES(obj_name),code = VALUES(code),
     modifier = VALUES(modifier), modified_time = VALUES(modified_time)
   </insert>
 

+ 3 - 2
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/rwd/migrate/entity/SyncData.java

@@ -25,6 +25,7 @@ public class SyncData extends AuditableEntity {
     /**
      * 消息id
      */
+
     private String id;
     /**
      * 同步表名称
@@ -39,7 +40,7 @@ public class SyncData extends AuditableEntity {
     /**
      * 对象类型
      */
-    private String objType;
+    private String objectType;
 
     /**
      * 操作类型
@@ -54,7 +55,7 @@ public class SyncData extends AuditableEntity {
     /**
      * 标记
      */
-    private Integer sign;
+    private Integer sign = 2;
 
     /**
      * 操作符