From cbd83560cffd9e9d055108717e4f9dec0aa6b58f Mon Sep 17 00:00:00 2001
From: 刘小明 <liuxm_a@163.com>
Date: 星期四, 11 七月 2024 11:25:33 +0800
Subject: [PATCH] 检查组装计划的定时任务
---
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/PmsProductApplication.java | 8 ----
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanTask.java | 42 +++++++++++++++++++++
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/AppStartupRunner.java | 18 +++++++++
3 files changed, 60 insertions(+), 8 deletions(-)
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/PmsProductApplication.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/PmsProductApplication.java
index eccb1c4..a9a91c5 100644
--- a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/PmsProductApplication.java
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/PmsProductApplication.java
@@ -1,7 +1,5 @@
package com.dy.pmsProduct;
-import com.dy.common.schedulerTask.SchedulerTaskSupport;
-import com.dy.common.schedulerTask.Test;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -16,12 +14,6 @@
public static void main(String[] args) {
SpringApplication.run(PmsProductApplication.class, args);
- try {
- SchedulerTaskSupport.addSecondlyJob("test", "testGroup", Test.class, null,
- 10, 1, -1) ;
- } catch (Exception e) {
- e.printStackTrace();
- }
}
}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/AppStartupRunner.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/AppStartupRunner.java
new file mode 100644
index 0000000..4715311
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/config/AppStartupRunner.java
@@ -0,0 +1,18 @@
+package com.dy.pmsProduct.config;
+
+import com.dy.common.schedulerTask.SchedulerTaskSupport;
+import com.dy.pmsProduct.taskPlan.AssemblyPlanTask;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AppStartupRunner implements CommandLineRunner {
+
+ @Override
+ public void run(String... args) throws Exception {
+// SchedulerTaskSupport.addDailyJob("assemblyPlanTask", "taskPlan", AssemblyPlanTask.class,
+// null, 11, 2);
+ SchedulerTaskSupport.addMinutelyJob("assemblyPlanTask", "taskPlan", AssemblyPlanTask.class,
+ null, 20, 5,-1);
+ }
+}
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanTask.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanTask.java
new file mode 100644
index 0000000..0be004a
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/taskPlan/AssemblyPlanTask.java
@@ -0,0 +1,42 @@
+package com.dy.pmsProduct.taskPlan;
+
+import cn.hutool.core.date.DateUnit;
+import cn.hutool.core.date.DateUtil;
+import com.dy.common.schedulerTask.TaskJob;
+import com.dy.common.springUtil.SpringContextUtil;
+import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
+import com.dy.pmsGlobal.daoPr.PrDeviceMapper;
+import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
+import com.dy.pmsGlobal.util.DeviceStatus;
+import lombok.extern.slf4j.Slf4j;
+import org.quartz.JobExecutionContext;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+@Slf4j
+@Component
+public class AssemblyPlanTask extends TaskJob {
+
+ @Override
+ public void execute(JobExecutionContext ctx) {
+ log.info("寮�濮嬫墽琛� 缁勮璁″垝浠诲姟瀹氭椂妫�鏌�");
+ PrAssemblyPlanMapper assemblyDao = SpringContextUtil.getBean(PrAssemblyPlanMapper.class);
+ PrDeviceMapper deviceDao = SpringContextUtil.getBean(PrDeviceMapper.class);
+ Map<String,Object> planParams = new HashMap<>();
+ planParams.put("status",PlanStatusEnum.NORMAL.getCode());
+ List<PrAssemblyPlan> list = assemblyDao.selectSome(planParams);
+ for (PrAssemblyPlan plan : list) {
+ HashMap<String, Object> deviceParams = new HashMap<>();
+ deviceParams.put("batchId", plan.getBatchId());
+ deviceParams.put("status", DeviceStatus.COMPLETED.getCode());
+ Long count = deviceDao.selectSomeCount(deviceParams);
+ if(count>plan.number && DateUtil.between(DateUtil.parse(plan.endDate), DateUtil.date(), DateUnit.DAY)>3){
+ plan.setStatus(PlanStatusEnum.END.getCode());
+ assemblyDao.updateByPrimaryKeySelective(plan);
+ }
+ }
+ log.info("瀹屾垚 缁勮璁″垝浠诲姟瀹氭椂妫�鏌�");
+ }
+}
--
Gitblit v1.8.0