From 4696a0be1e0235e4a9e5077c3f42e038da8c6809 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 14 八月 2025 16:30:37 +0800
Subject: [PATCH] 1

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
index afc92d9..451bc83 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -132,6 +132,8 @@
         if (!busService.save(bus)) {
             throw new BusinessException("Internal Server Error!");
         }
+        Boolean locStaStatusCheck = configService.getVal("LOC_STA_STATUS_CHECK", Boolean.class, true);
+
 
         // 淇濆瓨浠诲姟
         for (Task task : taskList) {
@@ -149,7 +151,7 @@
             switch (TaskTypeType.get(task.getTaskTypeEl())) {
                 case LOC_TO_LOC:
                     oriLoc = locService.getById(task.getOriLoc());
-                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+                    if (locStaStatusCheck && !oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                         throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
                     }
                     oriLoc.setLocSts(LocStsType.PAKOUT.val());
@@ -159,7 +161,7 @@
                     }
 
                     destLoc = locService.getById(task.getDestLoc());
-                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+                    if (locStaStatusCheck && !destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                         throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
                     }
                     destLoc.setLocSts(LocStsType.PAKIN.val());
@@ -170,7 +172,7 @@
                     break;
                 case LOC_TO_STA:
                     oriLoc = locService.getById(task.getOriLoc());
-                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+                    if (locStaStatusCheck && !oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
                         throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
                     }
                     oriLoc.setLocSts(LocStsType.PAKOUT.val());
@@ -180,7 +182,7 @@
                     }
 
                     destSta = staService.getById(task.getDestSta());
-                    if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) {
+                    if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                         throw new BusinessException("destSta锛�" + task.getDestSta$() + " is not in IDLE status");
                     }
                     destSta.setStaSts(StaStsType.READY_RELEASE.val());
@@ -191,7 +193,7 @@
                     break;
                 case STA_TO_LOC:
                     oriSta = staService.getById(task.getOriSta());
-                    if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
+                    if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
                         throw new BusinessException("oriSta锛�" + task.getOriSta$() + " is not in STOCK status");
                     }
                     oriSta.setStaSts(StaStsType.READY_TAKE.val());
@@ -201,7 +203,7 @@
                     }
 
                     destLoc = locService.getById(task.getDestLoc());
-                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+                    if (locStaStatusCheck && !destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
                         throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
                     }
                     destLoc.setLocSts(LocStsType.PAKIN.val());
@@ -212,7 +214,7 @@
                     break;
                 case STA_TO_STA:
                     oriSta = staService.getById(task.getOriSta());
-                    if (!oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
+                    if (locStaStatusCheck && !oriSta.getStaSts().equals(StaStsType.STOCK.val())) {
                         throw new BusinessException("oriSta锛�" + task.getOriSta$() + " is not in STOCK status");
                     }
                     oriSta.setStaSts(StaStsType.READY_TAKE.val());
@@ -222,7 +224,7 @@
                     }
 
                     destSta = staService.getById(task.getDestSta());
-                    if (!destSta.getStaSts().equals(StaStsType.IDLE.val())) {
+                    if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) {
                         throw new BusinessException("destSta锛�" + task.getDestSta$() + " is not in IDLE status");
                     }
                     destSta.setStaSts(StaStsType.READY_RELEASE.val());
@@ -277,7 +279,7 @@
                 if (!taskService.updateById(task)) {
                     throw new BusinessException("seqNum: " + task.getSeqNum() + " failed to update");
                 }
-                report(task, TaskReportStsType.START);
+                report(task,null, TaskReportStsType.START);
             }
         } catch (Exception e) {
             log.error("mainService.infuseAgvForTask", e);
@@ -1466,7 +1468,7 @@
                 List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                 for (Long taskId : taskIds) {
                     Task task = taskService.getById(taskId);
-                    report(task, TaskReportStsType.END);
+                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
                 }
             }
 
@@ -1504,7 +1506,7 @@
                 List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                 for (Long taskId : taskIds) {
                     Task task = taskService.getById(taskId);
-                    report(task, TaskReportStsType.OTBIN);
+                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
                 }
 
             }
@@ -1514,7 +1516,7 @@
                 List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                 for (Long taskId : taskIds) {
                     Task task = taskService.getById(taskId);
-                    report(task, TaskReportStsType.OTBIN);
+                    report(task, agv_11_up.getQrCode(), TaskReportStsType.OTBIN);
                 }
             }
             //寰�杈撻�佺嚎鏀捐揣瀹屾垚
@@ -1523,7 +1525,7 @@
                 List<Long> taskIds = actionService.selectTaskIdsByGroupId(serialNo);
                 for (Long taskId : taskIds) {
                     Task task = taskService.getById(taskId);
-                    report(task, TaskReportStsType.END);
+                    report(task, agv_11_up.getQrCode(), TaskReportStsType.END);
                 }
             }
 
@@ -1639,12 +1641,21 @@
     /**
      * 涓婃姤缁欎笂娓哥郴缁燂紝灏辨槸鎻掑叆涓�鏉℃暟鎹埌涓婃姤琛�
      */
-    private void report(Task task, TaskReportStsType taskReportStsType) {
+    private void report(Task task, String qrCode, TaskReportStsType taskReportStsType) {
         // TODO 鎻掑叆涓�鏉′笂鎶ヨ褰�
+        if (task.getBusId() == null) {
+            return;
+        }
+        List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getSeqNum, task.getSeqNum()).eq(TaskReport::getBusNo, task.getBusId$()).eq(TaskReport::getTaskSts, taskReportStsType.status));
+        if (!Cools.isEmpty(list)) {
+            log.info("TaskReport [{}] 宸查噸澶嶏紝涓嶅啀鎻掑叆 ==========>> ", JSON.toJSONString(task));
+            return;
+        }
         TaskReport taskReport = new TaskReport();
         taskReport.setAgvId(task.getAgvId());
         taskReport.setBusNo(task.getBusId$());
         taskReport.setCreateTime(new Date());
+        taskReport.setQrCode(qrCode);
         taskReport.setReportTimes(0);
         taskReport.setTaskSts(taskReportStsType.status);
         taskReport.setSeqNum(task.getSeqNum());

--
Gitblit v1.9.1