From ab0193f955b64f5ab8636c46b5d1f0f86fde8806 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期四, 07 八月 2025 13:41:12 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/task/TaskLogScheduler.java | 11 ++++++++++- src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java | 19 +++++++++++++++++++ src/main/resources/mapper/ApiLogMapper.xml | 3 +-- src/main/java/com/zy/asrs/service/CommandInfoService.java | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/CommandInfoService.java b/src/main/java/com/zy/asrs/service/CommandInfoService.java index eaed3cb..218d3f2 100644 --- a/src/main/java/com/zy/asrs/service/CommandInfoService.java +++ b/src/main/java/com/zy/asrs/service/CommandInfoService.java @@ -19,4 +19,5 @@ List<CommandInfo> selectCompleteManualCommand();//鏌ヨ宸插畬鎴愮殑鎵嬪姩鍛戒护 + void clearCommandInfo(); } diff --git a/src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java index 15f2a53..f0fa940 100644 --- a/src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/CommandInfoServiceImpl.java @@ -1,12 +1,15 @@ package com.zy.asrs.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.zy.asrs.entity.CommandInfoLog; +import com.zy.asrs.entity.TaskWrk; import com.zy.asrs.mapper.CommandInfoMapper; import com.zy.asrs.entity.CommandInfo; import com.zy.asrs.service.CommandInfoLogService; import com.zy.asrs.service.CommandInfoService; import com.baomidou.mybatisplus.service.impl.ServiceImpl; +import com.zy.asrs.service.TaskWrkService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -17,6 +20,10 @@ @Autowired private CommandInfoLogService commandInfoLogService; + @Autowired + private TaskWrkService taskWrkService; + @Autowired + private CommandInfoService commandInfoService; @Override public List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo) { @@ -65,4 +72,16 @@ public List<CommandInfo> selectCompleteManualCommand() { return this.baseMapper.selectCompleteManualCommand(); } + + @Override + public void clearCommandInfo() { + int count = taskWrkService.selectCount(new EntityWrapper<TaskWrk>()); + if (count != 0){ + return; + } + int count1 = commandInfoService.selectCount(new EntityWrapper<CommandInfo>()); + if (count1 != 0){ + commandInfoService.delete(new EntityWrapper<>()); + } + } } diff --git a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java index eccf1ac..b629447 100644 --- a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java +++ b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java @@ -244,7 +244,16 @@ try { apiLogService.clearWeekBefore(); } catch (Exception e) { - log.error("绗笁鏂规帴鍙f棩蹇楄嚜鍔ㄦ竻闄ゅけ璐ワ紙鑼冨洿锛氫竴鍛ㄤ箣鍓�", e); + log.error("绗笁鏂规帴鍙f棩蹇楄嚜鍔ㄦ竻闄ゅけ璐ワ紙鑼冨洿锛氫竴鏈堜箣鍓�)", e); + } + } + + @Scheduled(cron = "0 0/10 * * * ? ") + public void clearCommandInfo(){ + try { + commandInfoService.clearCommandInfo(); + } catch (Exception e) { + log.error("寮傚父鎸囦护鑷姩娓呴櫎澶辫触锛堣寖鍥达細浠诲姟琛ㄤ负绌烘椂娓呯悊", e); } } diff --git a/src/main/resources/mapper/ApiLogMapper.xml b/src/main/resources/mapper/ApiLogMapper.xml index e68e93a..8f85c82 100644 --- a/src/main/resources/mapper/ApiLogMapper.xml +++ b/src/main/resources/mapper/ApiLogMapper.xml @@ -24,8 +24,7 @@ <delete id="clearWeekBefore"> delete from man_api_log where 1=1 - and datediff(week,create_time,getdate()) >= 1 - and result != 1 + and datediff(month,create_time,getdate()) >= 1 </delete> </mapper> -- Gitblit v1.9.1