From 2a7fd275313003968fc186ee4617aec4eca90266 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期六, 10 五月 2025 16:55:41 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/task/AgvTaskLogScheduler.java | 77 ++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/asrs/task/AgvTaskLogScheduler.java b/src/main/java/com/zy/asrs/task/AgvTaskLogScheduler.java
new file mode 100644
index 0000000..060cdc8
--- /dev/null
+++ b/src/main/java/com/zy/asrs/task/AgvTaskLogScheduler.java
@@ -0,0 +1,77 @@
+package com.zy.asrs.task;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.core.exception.CoolException;
+import com.zy.asrs.domain.enums.TaskStatusType;
+import com.zy.asrs.entity.LocMast;
+import com.zy.asrs.entity.TaskWrk;
+import com.zy.asrs.entity.TaskWrkLog;
+import com.zy.asrs.service.LocMastService;
+import com.zy.asrs.service.TaskWrkLogService;
+import com.zy.asrs.service.TaskWrkService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+@Slf4j
+@Component
+public class AgvTaskLogScheduler {
+
+ @Autowired
+ private TaskWrkService taskWrkService;
+ @Autowired
+ private TaskWrkLogService taskWrkLogService;
+ @Autowired
+ private LocMastService locMastService;
+
+ /**
+ * AGV浠诲姟杞巻鍙�
+ */
+ @Scheduled(cron = "0/3 * * * * ? ")
+ public void execute() {
+ List<TaskWrk> taskWrkList = taskWrkService.selectList(new EntityWrapper<TaskWrk>()
+ .eq("status", TaskStatusType.COMPLETE.id));
+ for (TaskWrk taskWrk : taskWrkList) {
+ Date now = new Date();
+ String originPoint = taskWrk.getStartPoint();
+ String targetPoint = taskWrk.getTargetPoint();
+ LocMast startLocMast = locMastService.selectByLocNo(originPoint);
+ if(startLocMast == null){
+ throw new CoolException("鍙栬揣鐐瑰簱浣嶄笉瀛樺湪");
+ }
+
+ if (!startLocMast.getLocSts().equals("R")) {
+ throw new CoolException("鍙栬揣鐐逛笉澶勪簬鍑哄簱棰勭害");
+ }
+
+ LocMast targetLocMast = locMastService.selectByLocNo(targetPoint);
+ if(targetLocMast == null){
+ throw new CoolException("鏀捐揣鐐瑰簱浣嶄笉瀛樺湪");
+ }
+
+ if (!targetLocMast.getLocSts().equals("S")) {
+ throw new CoolException("鏀捐揣鐐逛笉澶勪簬鍏ュ簱棰勭害");
+ }
+
+ startLocMast.setLocSts("O");
+ startLocMast.setModiTime(now);
+ locMastService.updateById(startLocMast);
+
+ targetLocMast.setLocSts("F");
+ targetLocMast.setModiTime(now);
+ locMastService.updateById(targetLocMast);
+
+ TaskWrkLog taskWrkLog = new TaskWrkLog(taskWrk);
+ if (!taskWrkLogService.insert(taskWrkLog)) {
+ throw new CoolException("杞巻鍙叉。澶辫触" + taskWrkLog);
+ }
+ if (!taskWrkService.deleteById(taskWrk)) {
+ throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrkLog);
+ }
+ }
+ }
+}
--
Gitblit v1.9.1