zs 8 maanden geleden
bovenliggende
commit
4167729d6c
1 gewijzigde bestanden met toevoegingen van 4 en 6 verwijderingen
  1. 4 6
      src/main/java/com/free/schedule/ClearTransferApply.java

+ 4 - 6
src/main/java/com/free/schedule/ClearTransferApply.java

@@ -29,8 +29,8 @@ public class ClearTransferApply {
   /** 自动关闭时间: 10分钟 */
   private Long limit = 10L;
 
-  // 每2分整执行一次
-  @Scheduled(cron = "0 0/2 * * * ? ")
+  // 每2分整执行一次
+  @Scheduled(cron = "0 0/1 * * * ? ")
   public void schedule() {
     DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
     LocalDateTime nowTime = LocalDateTime.now();
@@ -53,13 +53,12 @@ public class ClearTransferApply {
       if (null != chatRecord) {
         // 有聊天记录,就根据最后一次发言时间判断
         LocalDateTime chat_time = chatRecord.getTime();
-        chat_time.plusMinutes(limit);
+        chat_time = chat_time.plusMinutes(limit);
         isBefore = nowTime.isBefore(chat_time);
-        
       } else {
         // 没有聊天记录,用申请时间判断,10分钟不说话就给关了
         LocalDateTime apply_time = i.getApply_time();
-        apply_time.plusMinutes(limit);
+        apply_time = apply_time.plusMinutes(limit);
         isBefore = nowTime.isBefore(apply_time);
       }
       // 判断, 最后的发言时间 + 自动关闭时间的10分钟 是否在当前时间之前:
@@ -71,7 +70,6 @@ public class ClearTransferApply {
         closeData.setIs_close(TransferApplyController.TransferApplyClose);
         transferApplyService.updateById(closeData);
       }
-
     }
   }
 }