Browse Source

巡检默认填报

guarantee-lsq 2 years ago
parent
commit
926a9619d3

+ 21 - 14
platform-rest/src/main/java/com/platform/rest/task/FillGatherTaskTask.java

@@ -24,6 +24,7 @@ import com.platform.service.fill.FillGatherTaskService;
 import com.platform.service.util.SendMessageUtils;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.velocity.app.event.implement.EscapeXmlReference;
 import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
@@ -59,6 +60,7 @@ public class FillGatherTaskTask {
         // 判断是否需要生成新的巡检任务
         List<FillGatherTask> handleList = validateList(taskList);
         // 生成巡检任务
+        LocalDateTime now = LocalDateTime.now();
         for(FillGatherTask task : handleList){
             FillGatherTask newTask = BeanConverterUtil.copyObjectProperties(task,FillGatherTask.class);
             newTask.setId(IdGeneratorUtils.getObjectId());
@@ -75,27 +77,29 @@ public class FillGatherTaskTask {
             if(period <= 12){
                 // 12小时周期的,21点之后到次日的8点,任务开始时间T+1 早上八点
                 if(currentHour >= 0 && currentHour <= 8){ // 当日八点
-                    startTime = LocalDateTime.now().withHour(8);
+                    startTime = now.withHour(8);
                     diffHour = 8-currentHour;
                 }else if(currentHour > 21){
-                    startTime = LocalDateTime.now().plusDays(1).withHour(8);
+                    startTime = now.plusDays(1).withHour(8);
                     diffHour = 24-currentHour + 8;
                 }else{
-                    startTime = LocalDateTime.now();
+                    startTime = now;
                 }
             }else{
                 // 24小时制的,晚上六点之后到第二天八点,统一到明日八点
                 if(currentHour >= 0 && currentHour <= 8){
-                    startTime = LocalDateTime.now().withHour(8);
+                    startTime = now.withHour(8);
                     diffHour = 8-currentHour;
                 }else if(currentHour > 17){
-                    startTime = LocalDateTime.now().plusDays(1).withHour(8);
+                    startTime = now.plusDays(1).withHour(8);
                     diffHour = 24-currentHour + 8;
                 }else{
-                    startTime = LocalDateTime.now();
+                    startTime = now;
                 }
             }
-            newTask.setCreatedTime(startTime.withSecond(0)); // 巡检开始时间
+            String dateStr = DateUtils.dateToString(startTime,DateUtils.PATTERN_YMD_HMS);
+            String startDate = dateStr.substring(0,17) + "00";
+            newTask.setCreatedTime(DateUtils.strToLocalDateTime(startDate,DateUtils.PATTERN_YMD_HMS)); // 巡检开始时间
             fillGatherTaskService.saveModelNoId(newTask);
             // 老旧巡检任务,修改为已生成
             FillGatherTask updTask = new FillGatherTask();
@@ -116,13 +120,16 @@ public class FillGatherTaskTask {
         }
     }
 
-    public static void main(String[] args) {
-        LocalDateTime now = LocalDateTime.now();
-        LocalDateTime end = now.withSecond(0);
-        //LocalDateTime end = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),now.getHour(),now.getMinute(),00,123);
-
-        System.out.println(now);
-        System.out.println(end);
+    public static void main(String[] args) throws Exception {
+        for(int i=0;i<2;i++){
+            //LocalDateTime now = LocalDateTime.now();
+            //LocalDateTime end = now.withSecond(0);
+            //LocalDateTime end = LocalDateTime.of(now.getYear(),now.getMonthValue(),now.getDayOfMonth(),now.getHour(),now.getMinute(),00,123);
+            LocalDateTime end = DateUtils.strToLocalDateTime("2023-03-06 08:00:00",DateUtils.PATTERN_YMD_HMS);
+            String dateStr = DateUtils.dateToString(end,DateUtils.PATTERN_YMD_HMS);
+            System.out.println(dateStr.substring(0,17));
+            System.out.println(end);
+        }
     }
 
     private void saveDetails(String content,String newTaskId,String taskId){

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

@@ -411,7 +411,11 @@ public class FillGatherTaskServiceImpl extends BaseServiceImpl<FillGatherTaskMap
             if(item.getType() == 1){
                 item.setFillValue("0");
             }else{
-                item.setFillValue("停机(正常)");
+                if(item.getSelectValue().contains("停机(正常)")){
+                    item.setFillValue("停机(正常)");
+                }else{
+                    item.setFillValue("停机");
+                }
             }
         });
         updDetail.setContent(JsonUtils.objectToJson(contents));