Parcourir la source

数据迁移 查询删除日志条件调整为QueryCriteria

lvxianyun il y a 2 ans
Parent
commit
0764952762

+ 27 - 18
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/controller/DataMigrationController.java

@@ -130,17 +130,7 @@ public class DataMigrationController {
             e.printStackTrace();
             return AdmResponse.failure(MigrationConstant.ERROR +":"+ e.getMessage());
         }
-
         dataMigrationHandler.handleAndSaveLog(context, migrationInfo);
-
-        AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
-        admQueryCriteria.addFilters("targetId = 'error'");
-        admQueryCriteria.addFilters("projectId = '" + context.getProjectId() + "'");
-        admQueryCriteria.setOnlyCount(true);
-        AdmResponse response = queryMigrateForLog(admQueryCriteria);
-        if(response.getMessage().equals(DmpResult.SUCCESS) && response.getCount() > 5){
-            return AdmResponse.failure("出现错误次数:"+ response.getCount()+"次,请使用导出检查数据是否迁移成功");
-        }
         return AdmResponse.success();
     }
 
@@ -195,18 +185,26 @@ public class DataMigrationController {
     /**
      * 获取迁移数据日志
      *
-     * @AdmQueryCriteria
+     * @param request
      * {
-     *     "order": "lastUpdate asc, objId asc",
-     *     "pageNumber": 1,
-     *     "pageSize": 15,
-     *     "filters": "projectId='Pj9909990004';sign=2;type='create';objectType='building'"
+     *     "onlyCount": false,
+     *     "withoutCount": false,
+     *     "criteria": {
+     *         "sign": 2,
+     *         "type": "create",
+     *         "tableName": "dt_relation",
+     *         "creationTime":{
+     *             "$gte":20220120121146,
+     *             "$lte":20220123121146
+     *         },
+     *         "valid": 1
+     *     }
      * }
      *
      *  return AdmResponse
      */
     @PostMapping("/log")
-    public AdmResponse queryMigrateForLog(@RequestBody AdmQueryCriteria request) {
+    public AdmResponse queryMigrateForLog(@RequestBody QueryCriteria request) {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return logService.queryMigrationLog(context, request);
     }
@@ -215,12 +213,23 @@ public class DataMigrationController {
      * 根据条件 删除操作日志 物理删除
      * @param request
      * {
-     *     "filters": "projectId='Pj9909990004';sign=2;type='create';tableName='dt_relation';creationTime='20220125121146'"
+     *     "onlyCount": false,
+     *     "withoutCount": false,
+     *     "criteria": {
+     *         "sign": 2,
+     *         "type": "create",
+     *         "tableName": "dt_relation",
+     *         "creationTime":{
+     *             "$gte":20220120121146,
+     *             "$lte":20220123121146
+     *         },
+     *         "valid": 1
+     *     }
      * }
      * @return
      */
     @PostMapping("/deleteLog")
-    public AdmResponse deleteMigrateForLog(@RequestBody AdmQueryCriteria request) {
+    public AdmResponse deleteMigrateForLog(@RequestBody QueryCriteria request) {
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return logService.deleteMigrationLog(context, request);
     }

+ 2 - 2
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/IMigrationLogService.java

@@ -14,6 +14,6 @@ import com.persagy.proxy.common.entity.InstanceUrlParam;
  */
 public interface IMigrationLogService {
 
-    AdmResponse queryMigrationLog(InstanceUrlParam context, AdmQueryCriteria request);
-    AdmResponse deleteMigrationLog(InstanceUrlParam context, AdmQueryCriteria request);
+    AdmResponse queryMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria);
+    AdmResponse deleteMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria);
 }

+ 5 - 7
adm-business/adm-middleware/src/main/java/com/persagy/proxy/migration/service/Impl/MigrationLogServiceImpl.java

@@ -37,8 +37,7 @@ import java.util.stream.Collectors;
 @Slf4j
 public class MigrationLogServiceImpl implements IMigrationLogService {
     @Override
-    public AdmResponse queryMigrationLog(InstanceUrlParam context, AdmQueryCriteria request) {
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
+    public AdmResponse queryMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria) {
         String groupCode = context.getGroupCode();
         String projectId = context.getProjectId();
         CommonResult<List<SyncData>> result = DigitalMigrateLogFacade.query(groupCode, projectId, context.getAppId(), context.getUserId(),queryCriteria);
@@ -51,14 +50,14 @@ public class MigrationLogServiceImpl implements IMigrationLogService {
             processSynDatas(groupCode, projectId, syncDatas);
             AdmResponse response = AdmResponse.success(syncDatas);
             Long total = result.getCount() == null ? null : result.getCount().longValue();
-            if(request.isOnlyCount()){
+            if(queryCriteria.isOnlyCount()){
                 response.setTotal(null);
                 response.setCount(total);
             }else {
                 response.setTotal(total);
             }
-            response.setPageNumber(request.getPageNumber());
-            response.setPageSize(request.getPageSize());
+            response.setPageNumber(queryCriteria.getPage() == null ? 0 : queryCriteria.getPage().intValue());
+            response.setPageSize(queryCriteria.getSize() == null ? 50 : queryCriteria.getSize().intValue());
             return response;
         } else {
             return AdmResponse.failure(result.getMessage());
@@ -66,8 +65,7 @@ public class MigrationLogServiceImpl implements IMigrationLogService {
     }
 
     @Override
-    public AdmResponse deleteMigrationLog(InstanceUrlParam context, AdmQueryCriteria request) {
-        QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
+    public AdmResponse deleteMigrationLog(InstanceUrlParam context, QueryCriteria queryCriteria) {
         String groupCode = context.getGroupCode();
         String projectId = context.getProjectId();
         CommonResult result = DigitalMigrateLogFacade.deleteAllLog(groupCode, projectId, context.getAppId(), context.getUserId(),queryCriteria);