3
1

2 Incheckningar 8e9fbe7480 ... b32b0f5deb

Upphovsman SHA1 Meddelande Datum
  lvxianyun b32b0f5deb 数据迁移 兼容时间查询 2 år sedan
  lvxianyun 2899c0793f 数据迁移 增加删除日志接口 2 år sedan

+ 46 - 0
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/migrate/controller/DigitalMigrateLogController.java

@@ -1,15 +1,19 @@
 package com.persagy.dmp.rwd.migrate.controller;
 
+import cn.hutool.core.collection.CollUtil;
 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.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
 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.entity.AuditableEntity;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ParamCheckUtil;
 import com.persagy.dmp.common.utils.ResultHelper;
@@ -53,6 +57,7 @@ public class DigitalMigrateLogController {
         // 添加所属项目条件
         ConditionUtil.ensureProjectCriteriaDirectly(wrapper);
         // 转换查询条件
+        processCreateTime(criteria, wrapper);
         QueryCriteriaHelper.toWrapper(wrapper, criteria, SyncData.class);
         Page page = QueryCriteriaHelper.toPage(criteria);
         if(criteria.isOnlyCount()) {
@@ -79,6 +84,18 @@ public class DigitalMigrateLogController {
         return ResultHelper.multi(voList);
     }
 
+    @PostMapping("/deleteAllLog")
+    public CommonResult deleteAllLog(@RequestBody QueryCriteria criteria) {
+        ParamCheckUtil.checkParam(CommonConstant.QUERY_GROUPCODE,CommonConstant.QUERY_PROJECTID);
+        QueryWrapper<SyncData> wrapper = new QueryWrapper<>();
+        // 添加所属项目条件
+        ConditionUtil.ensureProjectCriteriaDirectly(wrapper);
+        // 转换查询条件
+        processCreateTime(criteria, wrapper);
+        QueryCriteriaHelper.toWrapper(wrapper, criteria, SyncData.class);
+        service.remove(wrapper);
+        return ResultHelper.success();
+    }
     /**
      * 补充默认值
      * @param voList
@@ -96,4 +113,33 @@ public class DigitalMigrateLogController {
             }
         }
     }
+
+    /**
+     * 兼容
+     * {
+     *     "order": "lastUpdate asc, objId asc",
+     *     "pageNumber": 1,
+     *     "pageSize": 15,
+     *     "filters": "projectId='Pj9909990004';sign=2;type='create';tableName='dt_relation';creationTime in ['20220120121146','20220123121146']"
+     * }
+     * 特殊处理creation_time in ['20220120121146', '20220122121146'] 转化为时间段查询 -> creation_time >= '20220120121146' AND creation_time <= '20220122121146'
+     * @param criteria
+     * @param wrapper
+     */
+    private void processCreateTime(QueryCriteria criteria, QueryWrapper<SyncData> wrapper){
+        if(criteria == null){
+            return;
+        }
+        ObjectNode objectNode = criteria.getCriteria();
+        if(objectNode.get(AuditableEntity.DO_PROP_CREATIONTIME).isArray()){
+            ArrayNode arrayNode = (ArrayNode) objectNode.get(AuditableEntity.DO_PROP_CREATIONTIME);
+            if(arrayNode.size() != 2 || CollUtil.isEmpty(arrayNode)){
+                return;
+            }
+            wrapper.ge(AuditableEntity.PROP_CREATIONTIME,arrayNode.get(0).textValue())
+                    .le(AuditableEntity.PROP_CREATIONTIME,arrayNode.get(1).textValue());
+            objectNode.remove(AuditableEntity.DO_PROP_CREATIONTIME);
+            criteria.setCriteria(objectNode);
+        }
+    }
 }

+ 20 - 4
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/migrate/client/DigitalMigrateLogClient.java

@@ -48,8 +48,24 @@ public interface DigitalMigrateLogClient {
      */
     @PostMapping("create")
     CommonResult<List<SyncData>> create(@RequestParam("groupCode") String groupCode,
-                                             @RequestParam("projectId") String projectId,
-                                             @RequestParam("appId") String appId,
-                                             @RequestParam("userId") String userId,
-                                             @RequestBody List<SyncData> nodes);
+                                        @RequestParam("projectId") String projectId,
+                                        @RequestParam("appId") String appId,
+                                        @RequestParam("userId") String userId,
+                                        @RequestBody List<SyncData> nodes);
+
+    /**
+     * 新增数据迁移日志-根据条件删除
+     * @param groupCode: 集团编码
+     * @param projectId: 项目ID
+     * @param appId: 应用ID
+     * @param userId: 用户ID
+     * @param criteria: 条件
+     * @return
+     */
+    @PostMapping("/deleteAllLog")
+    CommonResult deleteAllLog(@RequestParam("groupCode") String groupCode,
+                              @RequestParam("projectId") String projectId,
+                              @RequestParam("appId") String appId,
+                              @RequestParam("userId") String userId,
+                              @RequestBody QueryCriteria criteria) ;
 }

+ 21 - 2
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/migrate/client/DigitalMigrateLogFacade.java

@@ -5,6 +5,8 @@ import com.persagy.dmp.basic.model.QueryCriteria;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.common.utils.ResultHelper;
 import com.persagy.dmp.rwd.migrate.entity.SyncData;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
 
@@ -29,7 +31,7 @@ public class DigitalMigrateLogFacade {
      * @return 对象数组
      */
     public static CommonResult<List<SyncData>> query(String groupCode, String projectId, String appId,
-                                       String userId, QueryCriteria criteria) {
+                                                     String userId, QueryCriteria criteria) {
         CommonResult<List<SyncData>> result = client.query(groupCode, projectId, appId, userId, criteria);
         return result;
     }
@@ -45,8 +47,25 @@ public class DigitalMigrateLogFacade {
      * @return 对象数组
      */
     public static List<SyncData> create(String groupCode, String projectId, String appId,
-                                             String userId, List<SyncData> syncDataList) {
+                                        String userId, List<SyncData> syncDataList) {
         CommonResult<List<SyncData>> result = client.create(groupCode, projectId, appId, userId, syncDataList);
         return ResultHelper.getContent(result);
     }
+
+    /**
+     * 新增数据迁移日志-根据条件删除
+     * @param groupCode: 集团编码
+     * @param projectId: 项目ID
+     * @param appId: 应用ID
+     * @param userId: 用户ID
+     * @param criteria: 条件
+     * @return
+     */
+    public static CommonResult deleteAllLog(@RequestParam("groupCode") String groupCode,
+                                            @RequestParam("projectId") String projectId,
+                                            @RequestParam("appId") String appId,
+                                            @RequestParam("userId") String userId,
+                                            @RequestBody QueryCriteria criteria) {
+        return client.deleteAllLog(groupCode,projectId,appId,userId,criteria);
+    }
 }