Sfoglia il codice sorgente

交班逻辑校验添加

qiangxuan 2 settimane fa
parent
commit
4745ad05e0

+ 92 - 12
zgztBus/jeecg-module-sbm/src/main/java/org/jeecg/modules/billet/billetHotsendChangeShift/controller/BilletHotsendChangeShiftController.java

@@ -311,25 +311,105 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	}
 
 
-	// 每天 08:00:00 执行的定时任务
-//	@Scheduled(cron = "0 0 8 * * ?")
+	// 每天 08:10:00 执行的定时任务
+	@Scheduled(cron = "0 10 8 * * ?")
 	public void executeDayShiftTask() {
-		log.info("自动化定时交班——白班:08:00:00开始执行!");
+		log.info("自动化定时交班——白班:08:10:00开始执行!");
 		performShiftChange("白班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("5");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.fiveChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
 	}
 
-	// 每天 16:00:00 执行的定时任务
-//	@Scheduled(cron = "0 0 16 * * ?")
+	// 每天 16:10:00 执行的定时任务
+	@Scheduled(cron = "0 10 16 * * ?")
 	public void executeMiddleShiftTask() {
-		log.info("自动定时交班——中班:16:00:00开始执行!");
+		log.info("自动定时交班——中班:16:10:00开始执行!");
 		performShiftChange("中班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("5");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.fiveChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
 	}
 
-	// 每天 00:00:00 执行的定时任务
-//	@Scheduled(cron = "0 0 0 * * ?")
+	// 每天 00:10:00 执行的定时任务
+	@Scheduled(cron = "0 10 0 * * ?")
 	public void executeNeightShiftTask() {
-		log.info("自动化定时交班——白班:00:00:00开始执行!");
+		log.info("自动化定时交班——白班:00:10:00开始执行!");
+		performShiftChange("夜班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("5");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.fiveChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
+	}
+
+	// 每天 08:10:00 执行的定时任务
+	@Scheduled(cron = "0 0 8 * * ?")
+	public void executeDayShiftTaskSix() {
+		log.info("自动化定时交班——白班:08:10:00开始执行!");
+		performShiftChange("白班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("6");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.sixChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
+	}
+
+	// 每天 16:10:00 执行的定时任务
+	@Scheduled(cron = "0 10 16 * * ?")
+	public void executeMiddleShiftTaskSix() {
+		log.info("自动定时交班——中班:16:10:00开始执行!");
+		performShiftChange("中班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("6");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.sixChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
+	}
+
+	// 每天 00:10:00 执行的定时任务
+	@Scheduled(cron = "0 10 0 * * ?")
+	public void executeNeightShiftTaskSix() {
+		log.info("自动化定时交班——白班:00:10:00开始执行!");
 		performShiftChange("夜班");
+		BilletHotsendChangeShift billetHotsendChangeShiftVo = new BilletHotsendChangeShift();
+		billetHotsendChangeShiftVo.setCcmNo("6");
+		boolean exit = findShift(billetHotsendChangeShiftVo.getCcmNo());
+		if (exit){
+			billetHotsendChangeShiftService.sixChangeShiftHandle(billetHotsendChangeShiftVo);
+		}
+	}
+
+	/**
+	 * 校验当前时间后退20分钟内是否有交班数据
+	 * @param ccmNo
+	 * @return
+	 */
+	private boolean findShift(String ccmNo){
+		LambdaQueryWrapper<BilletHotsendChangeShift> queryWrapper = new LambdaQueryWrapper<>();
+		LocalDateTime now = LocalDateTime.now(); // 当前时间
+		LocalDateTime startTime = now.minusMinutes(20); // 当前时间向前推20分钟
+		queryWrapper.eq(BilletHotsendChangeShift::getCcmNo, ccmNo) // 指定ccm_no
+				.ge(BilletHotsendChangeShift::getCreateTime, startTime) // 创建时间 >= 当前时间-20分钟
+				.le(BilletHotsendChangeShift::getCreateTime, now) // 创建时间 <= 当前时间
+				.orderByAsc(BilletHotsendChangeShift::getCreateTime); // 按创建时间升序排列
+		List<BilletHotsendChangeShift> shiftRecords = billetHotsendChangeShiftService.list(queryWrapper);
+		if (oConvertUtils.listIsNotEmpty(shiftRecords)){
+			log.info("{}{}", "已有交班记录,无需重复交班!", ccmNo);
+			return false;
+		}else {
+			log.info("{}{}", "b端补偿交班!", ccmNo);
+			return true;
+		}
 	}
 
 	@ApiOperation(value="自动化交班测试", notes="自动化交班测试")
@@ -449,7 +529,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 	}
 
 
-	@Scheduled(cron = "0 5 0 * * ?")
+	@Scheduled(cron = "0 15 0 * * ?")
 	public void runAtMidnight() {
 		// 每天	00:00:05 执行的任务逻辑
 
@@ -471,7 +551,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		executeShiftTask88();
 	}
 
-	@Scheduled(cron = "0 5 8 * * ?")
+	@Scheduled(cron = "0 15 8 * * ?")
 	public void runAtEight() {
 		// 08:05:00 执行的任务逻辑
 
@@ -493,7 +573,7 @@ public class BilletHotsendChangeShiftController extends JeecgController<BilletHo
 		executeShiftTask88();
 	}
 
-	@Scheduled(cron = "0 5 16 * * ?")
+	@Scheduled(cron = "0 15 16 * * ?")
 	public void runAtFourPm() {
 		// 16:00:05 执行的任务逻辑