From ce641129b3d43df13f322319ac4b39fa29fd3840 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期三, 25 三月 2026 16:39:22 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java |  352 ++++++++++++++++++++++++++-------------------------------
 1 files changed, 161 insertions(+), 191 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 4d46033..e8e1658 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
@@ -1585,216 +1585,186 @@
     @Transactional
     public void publishAction(String actionGroupId) {
         try {
-            List<Action> actionList = listPrepareActions(actionGroupId);
+            // action
+            List<Action> actionList = actionService.list(new LambdaQueryWrapper<Action>()
+                    .eq(Action::getGroupId, actionGroupId)
+                    .eq(Action::getActionSts, ActionStsType.PREPARE.val())
+                    .orderByDesc(Action::getPriority));
             if (Cools.isEmpty(actionList)) {
                 return;
             }
 
             Long agvId = actionList.get(0).getAgvId();
-            AgvModel agvModel = agvModelService.getByAgvId(agvId);
-            if (hikOrderPublishService.support(agvModel)) {
-                publishActionForHik(actionGroupId);
-                return;
-            }
-
-            Date now = new Date();
-            String agvNo = agvService.getAgvNo(agvId);
             if (!agvService.judgeOnline(agvId)) {
                 return;
             }
 
-            markActionAndTaskIssued(actionGroupId, actionList, now);
-
-            AgvAction agvAction = new AgvAction(agvNo, actionGroupId);
+            Date now = new Date();
+            long actionIssuedSts = ActionStsType.ISSUED.val();
             for (Action action : actionList) {
-                switch (Objects.requireNonNull(ActionTypeType.get(action.getActionTypeEl()))) {
-                    case TurnCorner:
-                        agvAction.add(new AgvActionItem<>(TurnCornerAction.class)
-                                .setQrCode(action.getCode())
-                                .setVal(Optional.ofNullable(action.getVal()).orElse(0D).intValue())
-                                .bodySync(body -> body.setAngle((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case StraightBackUnturnable:
-                        break;
-                    case StraightBackTurnable:
-                        agvAction.add(new AgvActionItem<>(StraightBackTurnableAction.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync(body -> body.setDistance((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case StraightAheadUnturnable:
-                        break;
-                    case StraightAheadTurnable:
-                        agvAction.add(new AgvActionItem<>(StraightAheadTurnableAction.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync(body -> body.setDistance((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case ReadyTakeFromShelvesLoc:
-                        agvAction.add(new AgvActionItem<>(ReadyTakeFromShelvesLoc.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync((body) -> {
-                                    HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
-                                    body.setHeight(heightDepthDto.getHeight());
-                                    body.setDepth(heightDepthDto.getDepth());
-                                })
-                        );
-                        break;
-                    case ReadyTakeFromConveyorSta:
-                        agvAction.add(new AgvActionItem<>(ReadyTakeFromConveyorSta.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync((body) -> {
-                                    HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
-                                    body.setHeight(heightDepthDto.getHeight());
-                                    body.setDepth(heightDepthDto.getDepth());
-                                })
-                        );
-                        break;
-                    case ReadyTakeFromAgvSite:
-                        agvAction.add(new AgvActionItem<>(ReadyTakeFromAgvSite.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync(body -> body.setDepth((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case ReadyReleaseToShelvesLoc:
-                        agvAction.add(new AgvActionItem<>(ReadyReleaseToShelvesLoc.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync((body) -> {
-                                    HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
-                                    body.setHeight(heightDepthDto.getHeight());
-                                    body.setDepth(heightDepthDto.getDepth());
-                                })
-                        );
-                        break;
-                    case ReadyReleaseToConveyorSta:
-                        agvAction.add(new AgvActionItem<>(ReadyReleaseToConveyorSta.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync((body) -> {
-                                    HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
-                                    body.setHeight(heightDepthDto.getHeight());
-                                    body.setDepth(heightDepthDto.getDepth());
-                                })
-                        );
-                        break;
-                    case ReadyReleaseToAgvSite:
-                        agvAction.add(new AgvActionItem<>(ReadyReleaseToAgvSite.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync(body -> body.setDepth((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case LoadPlatformLift:
-                        agvAction.add(new AgvActionItem<>(LoadPlatformLift.class)
-                                .setVal(action.getVal().intValue())
-                                .setQrCode(action.getCode())
-                                .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
-                        );
-                        break;
-                    case FinishPath:
-                        agvAction.add(new AgvActionItem<>(FinishPathAction.class)
-                                .setQrCode(action.getCode())
-                        );
-                        break;
-                    case DockingCharge:
-                        agvAction.add(new AgvActionItem<>(DockingChargeAction.class)
-                                .setQrCode(action.getCode())
-                        );
-                        break;
-                    case UndockingCharge:
-                        agvAction.add(new AgvActionItem<>(UndockingChargeAction.class)
-                                .setQrCode(action.getCode())
-                        );
-                        break;
-                    default:
-                        break;
+                action.setActionSts(actionIssuedSts);
+                action.setStartTime(now);
+                action.setIoTime(now);
+                action.setUpdateTime(now);
+            }
+            if (!actionService.updateBatchById(actionList)) {
+                throw new BusinessException("failed to update action batch !!!");
+            }
+
+            // task
+            List<Long> taskIds = actionService.selectTaskIdsByGroupId(actionGroupId);
+            long taskAssignSts = TaskStsType.ASSIGN.val();
+            long taskProgressSts = TaskStsType.PROGRESS.val();
+            for (Long taskId : taskIds) {
+                Task task = taskService.getById(taskId);
+                if (task.getTaskSts().equals(taskAssignSts)) {
+                    task.setTaskSts(taskProgressSts);
+                    task.setUpdateTime(now);
+                    if (!taskService.updateById(task)) {
+                        throw new BusinessException(task.getSeqNum() + "浠诲姟鏇存柊澶辫触");
+                    }
+                }
+            }
+
+            String agvNo = agvService.getAgvNo(agvId);
+            AgvModel agvModel = agvModelService.getByAgvId(agvId);
+
+            // hik robot
+            if (hikOrderPublishService.support(agvModel)) {
+
+                hikOrderPublishService.publish(actionGroupId, agvNo, agvModel, actionList);
+                News.info("娴峰悍浠诲姟缁� [{}] order 宸蹭笅鍙� ===>> 鎸囦护鏁伴噺锛歿}", actionGroupId, actionList.size());
+
+            // zoneyung robot
+            } else {
+                AgvAction agvAction = new AgvAction(agvNo, actionGroupId);
+                for (Action action : actionList) {
+                    switch (Objects.requireNonNull(ActionTypeType.get(action.getActionTypeEl()))) {
+                        case TurnCorner:
+                            agvAction.add(new AgvActionItem<>(TurnCornerAction.class)
+                                    .setQrCode(action.getCode())
+                                    .setVal(Optional.ofNullable(action.getVal()).orElse(0D).intValue())
+                                    .bodySync(body -> body.setAngle((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case StraightBackUnturnable:
+                            break;
+                        case StraightBackTurnable:
+                            agvAction.add(new AgvActionItem<>(StraightBackTurnableAction.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync(body -> body.setDistance((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case StraightAheadUnturnable:
+                            break;
+                        case StraightAheadTurnable:
+                            agvAction.add(new AgvActionItem<>(StraightAheadTurnableAction.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync(body -> body.setDistance((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case ReadyTakeFromShelvesLoc:
+                            agvAction.add(new AgvActionItem<>(ReadyTakeFromShelvesLoc.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync((body) -> {
+                                        HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+                                        body.setHeight(heightDepthDto.getHeight());
+                                        body.setDepth(heightDepthDto.getDepth());
+                                    })
+                            );
+                            break;
+                        case ReadyTakeFromConveyorSta:
+                            agvAction.add(new AgvActionItem<>(ReadyTakeFromConveyorSta.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync((body) -> {
+                                        HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+                                        body.setHeight(heightDepthDto.getHeight());
+                                        body.setDepth(heightDepthDto.getDepth());
+                                    })
+                            );
+                            break;
+                        case ReadyTakeFromAgvSite:
+                            agvAction.add(new AgvActionItem<>(ReadyTakeFromAgvSite.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync(body -> body.setDepth((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case ReadyReleaseToShelvesLoc:
+                            agvAction.add(new AgvActionItem<>(ReadyReleaseToShelvesLoc.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync((body) -> {
+                                        HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+                                        body.setHeight(heightDepthDto.getHeight());
+                                        body.setDepth(heightDepthDto.getDepth());
+                                    })
+                            );
+                            break;
+                        case ReadyReleaseToConveyorSta:
+                            agvAction.add(new AgvActionItem<>(ReadyReleaseToConveyorSta.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync((body) -> {
+                                        HeightDepthDto heightDepthDto = JSON.parseObject(action.getParams(), HeightDepthDto.class);
+                                        body.setHeight(heightDepthDto.getHeight());
+                                        body.setDepth(heightDepthDto.getDepth());
+                                    })
+                            );
+                            break;
+                        case ReadyReleaseToAgvSite:
+                            agvAction.add(new AgvActionItem<>(ReadyReleaseToAgvSite.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync(body -> body.setDepth((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case LoadPlatformLift:
+                            agvAction.add(new AgvActionItem<>(LoadPlatformLift.class)
+                                    .setVal(action.getVal().intValue())
+                                    .setQrCode(action.getCode())
+                                    .bodySync(body -> body.setHeight((short) Double.parseDouble(action.getParams())))
+                            );
+                            break;
+                        case FinishPath:
+                            agvAction.add(new AgvActionItem<>(FinishPathAction.class)
+                                    .setQrCode(action.getCode())
+                            );
+                            break;
+                        case DockingCharge:
+                            agvAction.add(new AgvActionItem<>(DockingChargeAction.class)
+                                    .setQrCode(action.getCode())
+                            );
+                            break;
+                        case UndockingCharge:
+                            agvAction.add(new AgvActionItem<>(UndockingChargeAction.class)
+                                    .setQrCode(action.getCode())
+                            );
+                            break;
+                        default:
+                            break;
+                    }
+
                 }
 
+                BaseResult<?> result = agvCmdService.executeAgvActionCmd(agvAction);
+                if (result.success()) {
+                    News.info("浠诲姟缁� [{}] 鍔ㄤ綔鎸囦护宸蹭笅鍙� ===>> 鎸囦护鏁伴噺锛歿}", actionGroupId, actionList.size());
+                } else {
+                    News.error("浠诲姟缁� [{}] 鍔ㄤ綔鎸囦护涓嬪彂澶辫触 锛侊紒锛�", actionGroupId);
+                    throw new CoolException("浠诲姟缁� [{" + actionGroupId + "}] 鍔ㄤ綔鎸囦护涓嬪彂澶辫触 锛侊紒锛�");
+                }
             }
 
-            BaseResult<?> result = agvCmdService.executeAgvActionCmd(agvAction);
-            if (result.success()) {
-                News.info("浠诲姟缁� [{}] 鍔ㄤ綔鎸囦护宸蹭笅鍙� ===>> 鎸囦护鏁伴噺锛歿}", actionGroupId, actionList.size());
-            } else {
-                News.error("浠诲姟缁� [{}] 鍔ㄤ綔鎸囦护涓嬪彂澶辫触 锛侊紒锛�", actionGroupId);
-                throw new CoolException("浠诲姟缁� [{" + actionGroupId + "}] 鍔ㄤ綔鎸囦护涓嬪彂澶辫触 锛侊紒锛�");
-            }
         } catch (Exception e) {
             News.error("mainService.publishAction", e);
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
         }
 
-    }
-
-    @Transactional
-    public void publishActionForHik(String actionGroupId) {
-        try {
-            List<Action> actionList = listPrepareActions(actionGroupId);
-            if (Cools.isEmpty(actionList)) {
-                return;
-            }
-
-            Long agvId = actionList.get(0).getAgvId();
-            String agvNo = agvService.getAgvNo(agvId);
-            if (!agvService.judgeOnline(agvId)) {
-                return;
-            }
-
-            AgvModel agvModel = agvModelService.getByAgvId(agvId);
-            if (!hikOrderPublishService.support(agvModel)) {
-                throw new CoolException("agv [" + agvNo + "] protocol is not hik");
-            }
-
-            Date now = new Date();
-            markActionAndTaskIssued(actionGroupId, actionList, now);
-
-            hikOrderPublishService.publish(actionGroupId, agvNo, agvModel, actionList);
-            News.info("娴峰悍浠诲姟缁� [{}] order 宸蹭笅鍙� ===>> 鎸囦护鏁伴噺锛歿}", actionGroupId, actionList.size());
-        } catch (Exception e) {
-            News.error("mainService.publishActionForHik", e);
-            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-        }
-    }
-
-    private List<Action> listPrepareActions(String actionGroupId) {
-        return actionService.list(new LambdaQueryWrapper<Action>()
-                .eq(Action::getGroupId, actionGroupId)
-                .eq(Action::getActionSts, ActionStsType.PREPARE.val())
-                .orderByDesc(Action::getPriority));
-    }
-
-    private void markActionAndTaskIssued(String actionGroupId, List<Action> actionList, Date now) {
-        long actionIssuedSts = ActionStsType.ISSUED.val();
-        for (Action action : actionList) {
-            action.setActionSts(actionIssuedSts);
-            action.setStartTime(now);
-            action.setIoTime(now);
-            action.setUpdateTime(now);
-        }
-        if (!actionService.updateBatchById(actionList)) {
-            throw new BusinessException("failed to update action batch !!!");
-        }
-
-        List<Long> taskIds = actionService.selectTaskIdsByGroupId(actionGroupId);
-        long taskAssignSts = TaskStsType.ASSIGN.val();
-        long taskProgressSts = TaskStsType.PROGRESS.val();
-        for (Long taskId : taskIds) {
-            Task task = taskService.getById(taskId);
-            if (task != null && task.getTaskSts().equals(taskAssignSts)) {
-                task.setTaskSts(taskProgressSts);
-                task.setUpdateTime(now);
-                if (!taskService.updateById(task)) {
-                    throw new BusinessException(task.getSeqNum() + "浠诲姟鏇存柊澶辫触");
-                }
-            }
-        }
     }
 
     @Transactional

--
Gitblit v1.9.1