Browse Source

巡检定时成成

guarantee-lsq 2 years ago
parent
commit
5d05c23477

+ 4 - 0
platform-dao/src/main/java/com/platform/dao/dto/fill/FillGatherTaskDTO.java

@@ -154,5 +154,9 @@ public class FillGatherTaskDTO extends BaseDTO implements Serializable {
      * 任务等级 A级  B级 C级
      */
     private String taskLevel;
+    /**
+     * 被复制次数
+     */
+    private Integer generateNum;
 
 }

+ 5 - 0
platform-dao/src/main/java/com/platform/dao/entity/fill/FillGatherTask.java

@@ -114,6 +114,11 @@ public class FillGatherTask implements Serializable {
      */
     private String taskLevel;
 
+    /**
+     * 被复制次数
+     */
+    private Integer generateNum;
+
     /**
      * 数据权限
      */

+ 12 - 3
platform-rest/src/main/java/com/platform/rest/task/FillGatherTaskTask.java

@@ -3,6 +3,7 @@ package com.platform.rest.task;
 import com.platform.common.cache.ConfigCache;
 import com.platform.common.constant.RedisKeyConstants;
 import com.platform.common.util.*;
+import com.platform.dao.dto.fill.FillGatherTaskDTO;
 import com.platform.dao.entity.fill.FillGatherInfo;
 import com.platform.dao.entity.fill.FillGatherTask;
 import com.platform.dao.entity.fill.FillGatherTaskDetail;
@@ -53,9 +54,11 @@ public class FillGatherTaskTask {
     public void generateFillTask () {
         String nowDateStr = DateUtils.dateToString(LocalDateTime.now(),DateUtils.PATTERN_YMD);
         // 获取所有点检任务集合
-        List<FillGatherTask> taskList = fillGatherTaskService.selectAll();
+        FillGatherTaskDTO queryDTO = new FillGatherTaskDTO();
+        queryDTO.setGenerateNum(0);
+        List<FillGatherTask> taskList = fillGatherTaskService.getModelListByDTO(queryDTO);
         // 判断是否需要生成新的巡检任务
-        List<FillGatherTask> handleList = validateList(taskList,nowDateStr);
+        List<FillGatherTask> handleList = validateList(taskList);
         // 生成巡检任务
         for(FillGatherTask task : handleList){
             FillGatherTask newTask = BeanConverterUtil.copyObjectProperties(task,FillGatherTask.class);
@@ -66,6 +69,11 @@ public class FillGatherTaskTask {
             newTask.setName(task.getName() + "_" + nowDateStr);
             newTask.setLateHistoryHours(0);
             fillGatherTaskService.saveModelNoId(newTask);
+            // 老旧巡检任务,修改为已生成
+            FillGatherTask updTask = new FillGatherTask();
+            updTask.setGenerateNum(task.getGenerateNum() + 1);
+            updTask.setId(task.getId());
+            fillGatherTaskService.modModelByPrimaryKey(updTask);
             // 1、获取巡检内容
             String content = getContentByGatherId(task.getGatherId());
             // 2、根据设备IDs,生成内容列表并保存
@@ -119,7 +127,7 @@ public class FillGatherTaskTask {
         return JsonUtils.objectToJson(contents);
     }
 
-    private List<FillGatherTask> validateList(List<FillGatherTask> list,String nowDateStr){
+    private List<FillGatherTask> validateList(List<FillGatherTask> list){
         List<FillGatherTask> retList = new ArrayList<>();
         // 当前时间
         LocalDateTime now = LocalDateTime.now();
@@ -131,6 +139,7 @@ public class FillGatherTaskTask {
             if(nowDateStr.equals(targetCreatedTimeStr)){
                 retList.add(task);
             }*/
+
             if(targetTime.isAfter(now)){
                 // 超过当前频次周期的生成任务
                 retList.add(task);

+ 1 - 0
platform-service/src/main/java/com/platform/service/fill/impl/FillGatherTaskServiceImpl.java

@@ -102,6 +102,7 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
         task.setCreatedTime(LocalDateTime.now());
         task.setCreatedUserId(SecurityUtils.getUserInfo().getUserId());
         task.setCreatedUserName(SecurityUtils.getUserInfo().getUsername());
+        task.setGenerateNum(0);
         mapper.insert(task);
         // 1、获取巡检内容
         String content = getContentByGatherId(model.getGatherId());