Przeglądaj źródła

2023-3-28 定时器定时处理90天以前的所有控制记录。

chaiyunlong 2 lat temu
rodzic
commit
15079b9d92

+ 6 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/RemoteLaboratoryService.java

@@ -452,6 +452,12 @@ public interface RemoteLaboratoryService {
     public AjaxResult timedExhaustTask();
 
     /**
+     * 定时器定时每天 00:30 开始执行,定时清理90天以前的所有控制记录数据
+     */
+    @GetMapping("/control/timingClearMsg")
+    public AjaxResult timingClearMsg();
+
+    /**
      * 一体机logo修改通知
      */
     @ApiOperation(value = "一体机logo修改通知")

+ 5 - 0
zd-api/zd-laboratory-api/src/main/java/com/zd/laboratory/api/feign/fallback/RemoteLaboratoryFallbackFactory.java

@@ -417,6 +417,11 @@ public class RemoteLaboratoryFallbackFactory implements FallbackFactory<RemoteLa
             }
 
             @Override
+            public AjaxResult timingClearMsg() {
+                throw new RuntimeException("定时清理消息失败:" + cause.getMessage());
+            }
+
+            @Override
             public void logoNotice() {
                 throw new RuntimeException("logo通知失败" + cause.getMessage());
             }

+ 8 - 0
zd-modules/zd-base/src/main/java/com/zd/base/job/task/LabTask.java

@@ -70,4 +70,12 @@ public class LabTask {
     public void timedExhaustTask() {
         remoteLaboratoryService.timedExhaustTask();
     }
+
+
+    /**
+     * 定时器定时每天 00:30 开始执行,定时清理90天以前的所有控制记录数据
+     */
+    public void timingClearMsg() {
+        remoteLaboratoryService.timingClearMsg();
+    }
 }

+ 2 - 9
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabControlController.java

@@ -11,14 +11,7 @@ import com.zd.laboratory.domain.vo.LabBigViewGroupVO;
 import com.zd.laboratory.domain.vo.LabControlVO;
 import com.zd.laboratory.domain.vo.LabRiskPlanListVO;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.zd.common.core.annotation.Log;
 import com.zd.common.core.log.BusinessType;
 import com.zd.common.core.annotation.PreAuthorize;
@@ -137,7 +130,7 @@ public class LabControlController extends BaseController {
        return ResultData.fail("获取控制记录信息失败!");
     }
 
-    @GetMapping(value = "/timingClearMsg")
+    @RequestMapping(value = "/timingClearMsg")
     public void timingClearMsg(){
         labControlService.timingClearMsg();
     }

+ 1 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/controller/LabTimedExhaustController.java

@@ -175,7 +175,7 @@ public class LabTimedExhaustController  extends BaseController {
         Calendar calendar = Calendar.getInstance();
         int monthInt = calendar.get(Calendar.MONTH)+1;
         int dateInt = calendar.get(Calendar.DATE);
-        if(monthInt==3 && dateInt==28){
+        if(monthInt==12 && dateInt==1){
             //这里需要查询定时排风下的所有实验室和关联的责任人
             new Thread(()->sendMassage()).start();
         }

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabControlMapper.java

@@ -85,4 +85,11 @@ public interface LabControlMapper {
      * @return 控制记录
      */
     public LabControl selectLabControlNewMegById(Long id);
+
+
+    /**
+     * 定时清理90天以前的所有控制记录数据
+     *
+     */
+    public int timingClearMsg();
 }

+ 5 - 1
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabControlServiceImpl.java

@@ -236,8 +236,12 @@ public class LabControlServiceImpl implements ILabControlService {
         return labControlMapper.selectLabControlNewMegById(id);
     }
 
+    /**
+     * 定时清理90天以前的所有控制记录数据
+     *
+     */
     @Override
     public void timingClearMsg() {
-
+        labControlMapper.timingClearMsg();
     }
 }

+ 5 - 0
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabControlMapper.xml

@@ -269,4 +269,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where hardware_id = #{id}
         order by create_time desc limit 1
     </select>
+
+
+    <delete id="timingClearMsg">
+        delete from lab_control where create_time &lt;= DATE_SUB(CURDATE(),INTERVAL 90 day)
+    </delete>
 </mapper>