From 4661519afdd8c30ffeafa38ba95358e97c1ba65d Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 05 十二月 2024 12:02:44 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java                |  155 ++++++++++++++++++++++++++++-----------------------
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java             |   16 ----
 zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java |    6 +
 3 files changed, 91 insertions(+), 86 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 45bdd19..aa06289 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
@@ -1250,77 +1250,8 @@
                         .orderByAsc(Segment::getSerial)
                 );
 
-                // task
-                for (Segment segment : segmentList) {
-                    boolean taskComplete = false;
-
-                    Task task = taskService.getById(segment.getTaskId());   assert null != task;
-                    TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());     assert null != typeType;
-
-                    TaskPosDto.PosType posType = TaskPosDto.queryPosType(segment.getPosType());
-                    switch (Objects.requireNonNull(posType)) {
-                        case ORI_STA:
-                        case ORI_LOC:
-                            break;
-                        case DEST_STA:
-                        case DEST_LOC:
-                        case TO_CHARGE:
-                        case TO_STANDBY:
-                            if (segment.getEndNode().equals(task.getDestCode())) {
-                                taskComplete = true;
-                            }
-                            break;
-                        case MOVE:
-                            if (segment.getEndNode().equals(task.getDestCode())) {
-                                if (typeType.equals(TaskTypeType.MOVE)) {
-                                    taskComplete = true;
-                                }
-                            }
-                            break;
-                        default:
-                            break;
-                    }
-
-                    if (taskComplete) {
-                        locService.taskCallBack(task);
-
-                        task.setTaskSts(TaskStsType.COMPLETE.val());
-                        task.setEndTime(now);
-                        task.setUpdateTime(now);
-                        if (!taskService.updateById(task)) {
-                            log.error("Task [{}] 鏇存柊澶辫触 锛侊紒锛�", task.getSeqNum());
-                        } else {
-                            log.info("Task [{}] 浣滀笟瀹屾瘯 ==========>> ", task.getSeqNum());
-                        }
-
-                    }
-                }
-
-                // action
-                List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>()
-                        .eq(Action::getGroupId, serialNo)
-                        .eq(Action::getActionSts, ActionStsType.ISSUED.val())
-                );
-                for (Action action : actionList) {
-                    action.setActionSts(ActionStsType.FINISH.val());
-                    action.setEndTime(now);
-                    action.setUpdateTime(now);
-                    if (!actionService.updateById(action)) {
-                        log.error("Action [{}] 鏇存柊澶辫触 锛侊紒锛�", action.getPriority() + " - " + action.getName());
-                    }
-                }
-
-                // segment
-                for (Segment segment : segmentList) {
-                    segment.setState(SegmentStateType.FINISH.toString());
-                    segment.setUpdateTime(now);
-                    if (!segmentService.updateById(segment)) {
-                        log.error("Segment [{}] 鏇存柊澶辫触 锛侊紒锛�", segment.getGroupId() + " - " + segment.getSerial());
-                    }
-                }
-
-                // segment call back
-                segmentService.processNext(segmentList);
+                // settlement
+                this.settleSegmentList(segmentList, serialNo);
 
                 log.info("Agv [{}] {}浣滀笟瀹屾瘯 ==========>> ", protocol.getAgvNo(), serialNo);
 
@@ -1335,4 +1266,86 @@
         }
     }
 
+    @Transactional
+    public void settleSegmentList(List<Segment> segmentList, String serialNo) {
+        if (Cools.isEmpty(segmentList)) {
+            return;
+        }
+        Date now = new Date();
+
+        // task
+        for (Segment segment : segmentList) {
+            boolean taskComplete = false;
+
+            Task task = taskService.getById(segment.getTaskId());   assert null != task;
+            TaskTypeType typeType = TaskTypeType.get(task.getTaskTypeEl());     assert null != typeType;
+
+            TaskPosDto.PosType posType = TaskPosDto.queryPosType(segment.getPosType());
+            switch (Objects.requireNonNull(posType)) {
+                case ORI_STA:
+                case ORI_LOC:
+                    break;
+                case DEST_STA:
+                case DEST_LOC:
+                case TO_CHARGE:
+                case TO_STANDBY:
+                    if (segment.getEndNode().equals(task.getDestCode())) {
+                        taskComplete = true;
+                    }
+                    break;
+                case MOVE:
+                    if (segment.getEndNode().equals(task.getDestCode())) {
+                        if (typeType.equals(TaskTypeType.MOVE)) {
+                            taskComplete = true;
+                        }
+                    }
+                    break;
+                default:
+                    break;
+            }
+
+            if (taskComplete) {
+                locService.taskCallBack(task);
+
+                task.setTaskSts(TaskStsType.COMPLETE.val());
+                task.setEndTime(now);
+                task.setUpdateTime(now);
+                if (!taskService.updateById(task)) {
+                    log.error("Task [{}] 鏇存柊澶辫触 锛侊紒锛�", task.getSeqNum());
+                } else {
+                    log.info("Task [{}] 浣滀笟瀹屾瘯 ==========>> ", task.getSeqNum());
+                }
+
+            }
+        }
+
+        // action, follow by groupId
+        if (!Cools.isEmpty(serialNo)) {
+            List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>()
+                    .eq(Action::getGroupId, serialNo)
+                    .eq(Action::getActionSts, ActionStsType.ISSUED.val())
+            );
+            for (Action action : actionList) {
+                action.setActionSts(ActionStsType.FINISH.val());
+                action.setEndTime(now);
+                action.setUpdateTime(now);
+                if (!actionService.updateById(action)) {
+                    log.error("Action [{}] 鏇存柊澶辫触 锛侊紒锛�", action.getPriority() + " - " + action.getName());
+                }
+            }
+        }
+
+        // segment
+        for (Segment segment : segmentList) {
+            segment.setState(SegmentStateType.FINISH.toString());
+            segment.setUpdateTime(now);
+            if (!segmentService.updateById(segment)) {
+                log.error("Segment [{}] 鏇存柊澶辫触 锛侊紒锛�", segment.getGroupId() + " - " + segment.getSerial());
+            }
+        }
+
+        // segment call back
+        segmentService.processNext(segmentList);
+    }
+
 }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
index b1afab4..20eb1e0 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/TrafficService.java
@@ -110,9 +110,8 @@
 
             // deprecate jam
             if (this.isJamBeDeprecatedByAvo(segment.getId())) {
-                if (this.skipCurrSegment(segment)) {
-                    return;
-                }
+                mainService.settleSegmentList(Utils.singletonList(segment), null);
+                return;
             }
 
             // execute -----------------------------------------------
@@ -632,17 +631,6 @@
                 .eq(Jam::getAvoSeg, avoSeg)
                 .eq(Jam::getState, JamStateType.DEPRECATED.toString())
         );
-    }
-
-    private boolean skipCurrSegment(Segment currSegment) {
-        currSegment.setState(SegmentStateType.FINISH.toString());
-        currSegment.setUpdateTime(new Date());
-        if (!segmentService.updateById(currSegment)) {
-            log.error("Segment [{}] failed to update 锛侊紒锛�", currSegment.getTravelId() + " - " + currSegment.getSerial());
-            return false;
-        }
-        segmentService.processNext(Utils.singletonList(currSegment));
-        return true;
     }
 
 }
diff --git a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
index 3d97b80..e9307d8 100644
--- a/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
+++ b/zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/FuncStaServiceImpl.java
@@ -110,7 +110,11 @@
                 if (null == agv) {
                     // if there is a running task whose destination is this funSta, then that means this funSta is occupied
                     if (0 < taskService.count(new LambdaQueryWrapper<Task>()
-                            .in(Task::getTaskType, TaskTypeType.TO_STANDBY.val(), TaskTypeType.TO_CHARGE.val())
+                            .in(Task::getTaskType
+                                    , TaskTypeType.TO_STANDBY.val()
+                                    , TaskTypeType.TO_CHARGE.val()
+                                    , TaskTypeType.MOVE.val()
+                            )
                             .in(Task::getTaskSts, TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())
                             .eq(Task::getDestCode, code)
                     )) {

--
Gitblit v1.9.1