From c65a357fc8b907af755e1ef6a2c201e31eb71e94 Mon Sep 17 00:00:00 2001
From: vincentlu <t1341870251@gmail.com>
Date: 星期六, 07 二月 2026 13:50:38 +0800
Subject: [PATCH] #

---
 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java |  113 +++++++++++++++++++++++++++++++-------------------------
 1 files changed, 62 insertions(+), 51 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 2d38703..82c2626 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
@@ -104,11 +104,12 @@
     @Transactional
     public Bus generateBusAndTask(OpenBusSubmitParam busSubmitParam, String memo) {
         String errorMsg = busService.checkoutValid(busSubmitParam);
+        Boolean maintainLocSts = configService.getVal("maintainLocSts", Boolean.class);
         if (!Cools.isEmpty(errorMsg)) {
             throw new BusinessException(errorMsg);
         }
-        String batch = busSubmitParam.getBatchNo();
-        List<TaskDto> taskDtoList = busSubmitParam.getTaskList();
+        String batchNo = busSubmitParam.getBatchNo();
+        List<TaskDto> taskDtoList = busSubmitParam.getTasks();
         if (Cools.isEmpty(taskDtoList)) {
             throw new BusinessException("taskList can't be empty!");
         }
@@ -123,7 +124,7 @@
         Date now = new Date();
         Bus bus = new Bus();
         bus.setUuid(String.valueOf(snowflakeIdWorker.nextId()).substring(3));
-        bus.setBusNo(batch);
+        bus.setBusNo(batchNo);
         bus.setStartTime(now);
         bus.setBusSts(BusStsType.RECEIVE.val());
         bus.setMemo(memo);
@@ -147,35 +148,39 @@
             Sta destSta = null;
             switch (TaskTypeType.get(task.getTaskTypeEl())) {
                 case LOC_TO_LOC:
-                    oriLoc = locService.getById(task.getOriLoc());
-                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
-                        throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
-                    }
-                    oriLoc.setLocSts(LocStsType.PAKOUT.val());
-                    oriLoc.setUpdateTime(now);
-                    if (!locService.updateById(oriLoc)) {
-                        throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
-                    }
+                    if (maintainLocSts) {
+                        oriLoc = locService.getById(task.getOriLoc());
+                        if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+                            throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
+                        }
+                        oriLoc.setLocSts(LocStsType.PAKOUT.val());
+                        oriLoc.setUpdateTime(now);
+                        if (!locService.updateById(oriLoc)) {
+                            throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+                        }
 
-                    destLoc = locService.getById(task.getDestLoc());
-                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
-                        throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
-                    }
-                    destLoc.setLocSts(LocStsType.PAKIN.val());
-                    destLoc.setUpdateTime(now);
-                    if (!locService.updateById(destLoc)) {
-                        throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+                        destLoc = locService.getById(task.getDestLoc());
+                        if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+                            throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
+                        }
+                        destLoc.setLocSts(LocStsType.PAKIN.val());
+                        destLoc.setUpdateTime(now);
+                        if (!locService.updateById(destLoc)) {
+                            throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+                        }
                     }
                     break;
                 case LOC_TO_STA:
-                    oriLoc = locService.getById(task.getOriLoc());
-                    if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
-                        throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
-                    }
-                    oriLoc.setLocSts(LocStsType.PAKOUT.val());
-                    oriLoc.setUpdateTime(now);
-                    if (!locService.updateById(oriLoc)) {
-                        throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+                    if (maintainLocSts) {
+                        oriLoc = locService.getById(task.getOriLoc());
+                        if (!oriLoc.getLocSts().equals(LocStsType.STOCK.val())) {
+                            throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " is not in STOCK status");
+                        }
+                        oriLoc.setLocSts(LocStsType.PAKOUT.val());
+                        oriLoc.setUpdateTime(now);
+                        if (!locService.updateById(oriLoc)) {
+                            throw new BusinessException("oriLoc锛�" + task.getOriLoc$() + " failed to update");
+                        }
                     }
 
                     destSta = staService.getById(task.getDestSta());
@@ -189,14 +194,16 @@
                         throw new BusinessException("oriSta锛�" + task.getOriSta$() + " failed to reserve");
                     }
 
-                    destLoc = locService.getById(task.getDestLoc());
-                    if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
-                        throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
-                    }
-                    destLoc.setLocSts(LocStsType.PAKIN.val());
-                    destLoc.setUpdateTime(now);
-                    if (!locService.updateById(destLoc)) {
-                        throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+                    if (maintainLocSts) {
+                        destLoc = locService.getById(task.getDestLoc());
+                        if (!destLoc.getLocSts().equals(LocStsType.IDLE.val())) {
+                            throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " is not in IDLE status");
+                        }
+                        destLoc.setLocSts(LocStsType.PAKIN.val());
+                        destLoc.setUpdateTime(now);
+                        if (!locService.updateById(destLoc)) {
+                            throw new BusinessException("destLoc锛�" + task.getDestLoc$() + " failed to update");
+                        }
                     }
                     break;
                 case STA_TO_STA:
@@ -376,7 +383,7 @@
                             int idx = -1;
                             for (int i = 0; i < destPosList.size(); i++) {
                                 if (Objects.equals(destPosList.get(i).getTaskId(), newDto.getTaskId())
-                                 && Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())) {
+                                        && Objects.equals(destPosList.get(i).getCodeId(), newDto.getCodeId())) {
                                     idx = i;
                                     break;
                                 }
@@ -1148,7 +1155,7 @@
                 }
 
                 // 浣滀笟鐐瑰姩浣�
-                AgvDirectionType agvDirectionType;
+                ActuatorDirectionType actuatorDirectionType;
                 Double staWorkDirection;
                 AgvBackpackType backpackType = AgvBackpackType.query(segment.getBackpack());
                 switch (Objects.requireNonNull(TaskPosDto.queryPosType(segment.getPosType()))) {
@@ -1161,7 +1168,8 @@
                         // 璐ф灦鍙栬揣
                         Loc oriLoc = locService.getById(task.getOriLoc());
                         // 璁$畻宸﹀彸鏂瑰悜
-                        agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode);
+                        actuatorDirectionType = ActuatorDirectionType.fromVal(oriLoc.getCompDirect());
+//                        actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(oriLoc, lastCode);
                         actionList.add(new Action(
                                 null,    // 缂栧彿
                                 task.getBusId(),    // 鎬荤嚎
@@ -1169,7 +1177,7 @@
                                 null,    // 鍔ㄤ綔鍙�
                                 null,    // 浼樺厛绾�
                                 ActionTypeType.ReadyTakeFromShelvesLoc.desc,    // 鍚嶇О
-                                (double) agvDirectionType.val,    // 灞炴�у��
+                                (double) actuatorDirectionType.val,    // 灞炴�у��
                                 lastCode.getData(),    // 鍦伴潰鐮�
                                 JSON.toJSONString(new HeightDepthDto(oriLoc.getOffset())),   // 鍔ㄤ綔鍙傛暟
                                 ActionTypeType.ReadyTakeFromShelvesLoc.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1224,15 +1232,16 @@
                         // 璐ф灦鏀捐揣
                         Loc destLoc = locService.getById(task.getDestLoc());
                         // 璁$畻宸﹀彸鏂瑰悜
-                        agvDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode);
+                        actuatorDirectionType = ActuatorDirectionType.fromVal(destLoc.getCompDirect());
+//                        actuatorDirectionType = mapService.calculateAgvWorkDirectionByShelf(destLoc, lastCode);
                         actionList.add(new Action(
                                 null,    // 缂栧彿
                                 task.getBusId(),    // 鎬荤嚎
                                 task.getId(),    // 浠诲姟
                                 null,    // 鍔ㄤ綔鍙�
-                                 null,    // 浼樺厛绾�
+                                null,    // 浼樺厛绾�
                                 ActionTypeType.ReadyReleaseToShelvesLoc.desc,    // 鍚嶇О
-                                (double) agvDirectionType.val,    // 灞炴�у��
+                                (double) actuatorDirectionType.val,    // 灞炴�у��
                                 lastCode.getData(),    // 鍦伴潰鐮�
                                 JSON.toJSONString(new HeightDepthDto(destLoc.getOffset())),   // 鍔ㄤ綔鍙傛暟
                                 ActionTypeType.ReadyReleaseToShelvesLoc.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1244,7 +1253,7 @@
                     case ORI_STA:
                         // 绔欑偣鍙栬揣
                         Sta oriSta = staService.getById(task.getOriSta());
-                        Double oriStaWorkDirection = mapService.getStaAngle(oriSta, workDirection);
+                        Double oriStaWorkDirection = mapService.getStaAngle(oriSta);
                         // 妫�楠屾柟鍚�
                         if (!lastDirection.equals(oriStaWorkDirection)) {
                             if (!lastCode.getCornerBool()) {
@@ -1269,7 +1278,8 @@
                             lastDirection = oriStaWorkDirection;
                         }
                         // 璁$畻璐у弶宸ヤ綔鏂瑰悜
-                        staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection);
+                        actuatorDirectionType = ActuatorDirectionType.fromVal(oriSta.getActDir());
+//                        staWorkDirection = mapService.calculateAgvWorkDirectionByStation(oriStaWorkDirection, lastDirection);
                         actionList.add(new Action(
                                 null,    // 缂栧彿
                                 task.getBusId(),    // 鎬荤嚎
@@ -1277,7 +1287,7 @@
                                 null,    // 鍔ㄤ綔鍙�
                                 null,    // 浼樺厛绾�
                                 ActionTypeType.ReadyTakeFromConveyorSta.desc,    // 鍚嶇О
-                                staWorkDirection,    // 灞炴�у��
+                                (double) actuatorDirectionType.val,    // 灞炴�у��
                                 lastCode.getData(),    // 鍦伴潰鐮�
                                 JSON.toJSONString(new HeightDepthDto(oriSta.getHeight(), Optional.ofNullable(oriSta.getDepth()).orElse((double) 0))),   // 鍔ㄤ綔鍙傛暟
                                 ActionTypeType.ReadyTakeFromConveyorSta.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1308,7 +1318,7 @@
                     case DEST_STA:
                         // 绔欑偣鏀捐揣
                         Sta destSta = staService.getById(task.getDestSta());
-                        Double destStaWorkDirection = mapService.getStaAngle(destSta, workDirection);
+                        Double destStaWorkDirection = mapService.getStaAngle(destSta);
                         // 妫�楠屾柟鍚�
                         if (!lastDirection.equals(destStaWorkDirection)) {
                             if (!lastCode.getCornerBool()) {
@@ -1352,7 +1362,8 @@
                             ));
                         }
                         // 璁$畻璐у弶宸ヤ綔鏂瑰悜
-                        staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
+//                        staWorkDirection = mapService.calculateAgvWorkDirectionByStation(destStaWorkDirection, lastDirection);
+                        actuatorDirectionType = ActuatorDirectionType.fromVal(destSta.getActDir());
                         actionList.add(new Action(
                                 null,    // 缂栧彿
                                 task.getBusId(),    // 鎬荤嚎
@@ -1360,7 +1371,7 @@
                                 null,    // 鍔ㄤ綔鍙�
                                 null,    // 浼樺厛绾�
                                 ActionTypeType.ReadyReleaseToConveyorSta.desc,    // 鍚嶇О
-                                staWorkDirection,    // 灞炴�у��
+                                (double) actuatorDirectionType.val,    // 灞炴�у��
                                 lastCode.getData(),    // 鍦伴潰鐮�
                                 JSON.toJSONString(new HeightDepthDto(destSta.getHeight(), Optional.ofNullable(destSta.getDepth()).orElse((double) 0))),   // 鍔ㄤ綔鍙傛暟
                                 ActionTypeType.ReadyReleaseToConveyorSta.val(),    // 鍔ㄤ綔绫诲瀷
@@ -1822,9 +1833,9 @@
 
                 // segment list
                 List<Segment> segmentList = segmentService.list(new LambdaQueryWrapper<Segment>()
-                        .eq(Segment::getGroupId, serialNo)
+                                .eq(Segment::getGroupId, serialNo)
 //                        .eq(Segment::getState, SegmentStateType.RUNNING.toString())
-                        .orderByAsc(Segment::getSerial)
+                                .orderByAsc(Segment::getSerial)
                 );
 
                 // settlement

--
Gitblit v1.9.1