From 757a5a1373c96d216be9eb5d6b5cd6374ce95deb Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 04 二月 2026 14:19:06 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/devlop-phyz' into devlop-phyz

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |  527 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 417 insertions(+), 110 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
index a40d434..ceb9243 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -125,7 +125,7 @@
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public synchronized R generateAGVTasks(WaitPakin pakins, String locCode, String orgSta, Long loginUserId) {
+    public synchronized R generateAGVTasks(WaitPakin pakins, String locCode, String orgSta,String targSite, Long loginUserId) {
         if (Cools.isEmpty(pakins) || Cools.isEmpty(locCode)) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
         }
@@ -150,10 +150,11 @@
             }
             Task task = new Task();
             task.setTaskCode(ruleCode)
-                    .setTaskStatus(TaskStsType.GENERATE_IN.id)
+                    .setTaskStatus(TaskStsType.MISSION_INITIAL.id)
                     .setTaskType(TaskType.TASK_TYPE_IN.type)
                     .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)
                     .setTargLoc(targetLoc)
+                    //.setTargSite(targSite)//鍏ュ簱娌℃湁鐩爣绔欑偣
                     .setOrgSite(orgSta)
                     .setBarcode(pakin.getBarcode())
                     .setCreateBy(loginUserId)
@@ -182,6 +183,14 @@
                         .setUpdateBy(loginUserId)
                         .setExtendFields(item.getExtendFields())
                         .setOrderId(item.getAsnId())
+                        .setBatch(item.getBatch())
+                        .setSplrBatch(item.getBatch())
+                        .setPlatWorkCode(item.getPlatWorkCode())
+                        .setPlatItemId(item.getPlatItemId())
+                        .setOrderId(item.getAsnId())
+                        .setSplrBatch(item.getBatch())
+                        .setPlatWorkCode(item.getPlatWorkCode())
+                        .setPlatItemId(item.getPlatItemId())
                         .setOrderItemId(item.getAsnItemId());
                 taskItems.add(taskItem);
             });
@@ -270,6 +279,9 @@
                         .setUpdateBy(loginUserId)
                         .setExtendFields(item.getExtendFields())
                         .setOrderId(item.getAsnId())
+                        .setSplrBatch(item.getBatch())
+                        .setPlatWorkCode(item.getPlatWorkCode())
+                        .setPlatItemId(item.getPlatItemId())
                         .setOrderItemId(item.getAsnItemId());
                 taskItems.add(taskItem);
             });
@@ -340,7 +352,7 @@
 //            }
 
             //楠岃瘉鍩虹淇℃伅
-            BasStation basStation = checkStaStatus(pakin.getBarcode(), deviceSite.getSite());
+            checkStaStatus(pakin.getBarcode(), deviceSite.getSite(),warehouseArea.getId().toString());
             /**鑾峰彇搴撲綅*/
             String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null);
             if (Cools.isEmpty(targetLoc)) {
@@ -423,6 +435,9 @@
                         .setUpdateBy(loginUserId)
                         .setExtendFields(item.getExtendFields())
                         .setOrderId(item.getAsnId())
+                        .setSplrBatch(item.getBatch())
+                        .setPlatWorkCode(item.getPlatWorkCode())
+                        .setPlatItemId(item.getPlatItemId())
                         .setOrderItemId(item.getAsnItemId());
                 taskItems.add(taskItem);
             });
@@ -448,6 +463,76 @@
         return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
     }
 
+    private BasStation checkStaStatus(String barcode, String sta,String area) {
+        if (Cools.isEmpty(barcode)) {
+            throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
+        }
+        if (Cools.isEmpty(sta)) {
+            throw new CoolException("鎺ラ┏浣嶆潯鐮佷笉鑳戒负绌�");
+        }
+        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
+                .eq(WaitPakin::getBarcode, barcode)
+                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
+        );
+        if (Cools.isEmpty(waitPakin)) {
+            throw new CoolException("瀹瑰櫒鐮佹湭鎵惧埌缁勬墭淇℃伅,璇锋鏌ョ粍鎵樼姸鎬�");
+        }
+        BasStation isBarcodeSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+                        .eq(BasStation::getBarcode, barcode)
+                , false
+        );
+        if (!Cools.isEmpty(isBarcodeSta)) {
+            throw new CoolException("璇ユ潯鐮佸凡琚�" + isBarcodeSta.getStationName() + "绔欑粦瀹�");
+        }
+        BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+                .eq(BasStation::getStationName, sta)
+        );
+        if (Cools.isEmpty(basStation)) {
+            throw new CoolException("鏈壘鍒扮珯鐐逛俊鎭�");
+        }
+        if (!basStation.getUseStatus().equals("O")) {
+            throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
+        }
+
+        List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
+        if (!areaList.contains(area)) {
+            throw new CoolException("褰撳墠绔欑偣涓嶆敮鎸佺洰鏍囧簱鍖�");
+        }
+        if (!Cools.isEmpty(basStation.getContainerType())) {
+            List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
+            List<BasContainer> containers = basContainerService.list(
+                    new LambdaQueryWrapper<BasContainer>()
+                            .in(BasContainer::getContainerType, longs1)
+            );
+            boolean matches = false;
+            boolean matches2 = true;
+            for (BasContainer container : containers) {
+                String codeType = container.getCodeType();  // 鑾峰彇姝e垯琛ㄨ揪寮�
+                if (barcode.matches(codeType)) {  // 鍒ゆ柇鏉$爜鏄惁绗﹀悎杩欎釜姝e垯
+                    List<Integer> areaList2 = container.getAreasIds();
+                    if (!areaList2.contains(Integer.parseInt(area))) {
+                        matches2 = false;
+                        continue;
+                    }
+                    matches = true;
+                    break;  // 鎵惧埌鍖归厤鐨勫氨閫�鍑哄惊鐜�
+                }
+            }
+//            boolean matches = containers.stream()
+//                    .map(BasContainer::getCodeType)
+//                    .anyMatch(codeType -> barcode.matches(codeType));
+            if (!matches2) {
+                throw new CoolException("鏌ヨ鍒扮殑瀹瑰櫒涓嶆敮鎸佺洰鏍囧簱鍖�");
+            }
+            if (!matches) {
+                throw new CoolException("鏉$爜涓庣珯鐐逛笉鍖归厤");
+            }
+        } else {
+            throw new CoolException("鏁版嵁寮傚父锛氶獙璇佸熀纭�淇℃伅");
+        }
+
+        return basStation;
+    }
 
     private BasStation checkStaStatus(String barcode, String sta) {
         if (Cools.isEmpty(barcode)) {
@@ -492,6 +577,8 @@
             if (!matches) {
                 throw new CoolException("鏉$爜涓庣珯鐐逛笉鍖归厤");
             }
+        } else {
+            throw new CoolException("鏁版嵁寮傚父锛氶獙璇佸熀纭�淇℃伅");
         }
 
         return basStation;
@@ -509,112 +596,144 @@
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
         }
 
-        DeviceSite deviceSite = deviceSiteService.getById(waitPakin.getSiteId());
-        if (Objects.isNull(deviceSite)) {
+        BasStation basStation = basStationService.getById(waitPakin.getSiteId());
+        if (Objects.isNull(basStation)) {
             throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
         }
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(deviceSite.getSite()));
-        if (Cools.isEmpty(deviceBind)) {
-            throw new CoolException("搴撲綅瑙勫垯鏈煡");
+        List<WarehouseAreas> warehouseAreasList = new ArrayList<>();
+        if (basStation.getIsWcs() == 1){
+            DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(basStation.getStationName()));
+            if (Cools.isEmpty(deviceBind)) {
+                throw new CoolException("搴撲綅瑙勫垯鏈煡");
+            }
+            WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
+            if (Cools.isEmpty(warehouseArea)) {
+                throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+            }
+            warehouseAreasList.add(warehouseArea);
+        } else {
+            List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
+            if (areaList.isEmpty()) {
+                throw new CoolException("褰撳墠绔欑偣搴撳尯鏈厤缃�");
+            }
+            warehouseAreasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().in(WarehouseAreas::getId,areaList));
         }
-        WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
-        if (Cools.isEmpty(warehouseArea)) {
+
+        if (Cools.isEmpty(warehouseAreasList) || warehouseAreasList.size() == 0) {
             throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
         }
-
-        /**鑾峰彇缁勬嫋*/
-        List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
-        List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
-                .in(WaitPakin::getId, ids)
-                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
-        if (waitPakins.isEmpty()) {
-            throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
-        }
-        waitPakins.forEach(pakin -> {
-
-
-            //楠岃瘉鍩虹淇℃伅
-            BasStation basStation = checkStaStatus(pakin.getBarcode(), deviceSite.getSite());
-
+        final String[] errMsg = {""};
+        for (WarehouseAreas warehouseArea : warehouseAreasList) {
+            /**鑾峰彇缁勬嫋*/
+            List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
+            List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
+                    .in(WaitPakin::getId, ids)
+                    .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
+            if (waitPakins.isEmpty()) {
+                throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
+            }
+            boolean sign = true;
+            for (WaitPakin pakin : waitPakins) {//楠岃瘉鍩虹淇℃伅
+                try {
+                    checkStaStatus(pakin.getBarcode(), basStation.getStationName(), warehouseArea.getId().toString());
+                } catch (Exception e) {
+                    errMsg[0] = errMsg[0] + e.getMessage();
+                    sign = false;
+                    break;
+                }
 //            BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
 //                    .eq(BasContainer::getCode, pakin.getBarcode()));
 //            if (Objects.isNull(container)) {
 //                throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
 //            }
-            /**鑾峰彇搴撲綅*/
-            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(),null,rowList);
-            if (Cools.isEmpty(targetLoc)) {
-                throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
-            }
-
-            List<TaskItem> taskItems = new ArrayList<>();
-            String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
-            if (StringUtils.isBlank(ruleCode)) {
-                throw new CoolException("缂栫爜閿欒锛氳纭缂栫爜銆孲YS_TASK_CODE銆嶆槸鍚﹀凡鐢熸垚!!");
-            }
-            Task task = new Task();
-            task.setTaskCode(ruleCode)
-                    .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
-                    .setTaskType(TaskType.TASK_TYPE_IN.type)
-                    .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
-                    .setTargLoc(targetLoc)
-                    .setBarcode(pakin.getBarcode())
-                    .setOrgSite(deviceSite.getSite())
-                    .setTargSite(deviceSite.getDeviceSite())
-                    .setCreateBy(loginUserId)
-                    .setUpdateBy(loginUserId);
-
-            if (!this.save(task)) {
-                throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
-            }
-
-            if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
-                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
-                throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
-            }
-            /**鑾峰彇缁勬嫋鏄庣粏**/
-            List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
-            if (waitPakinItems.isEmpty()) {
-                throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨槑缁嗕笉瀛樺湪");
-            }
-            waitPakinItems.forEach(item -> {
-                TaskItem taskItem = new TaskItem();
-                BeanUtils.copyProperties(item, taskItem);
-                taskItem.setTaskId(task.getId())
-                        .setOrderType(OrderType.ORDER_IN.type)
-                        .setSource(item.getId())
-                        .setTrackCode(item.getTrackCode())
-                        .setPlatItemId(item.getPlatItemId())
-                        .setPlatOrderCode(item.getPlatOrderCode())
-                        .setPlatWorkCode(item.getPlatWorkCode())
-                        .setProjectCode(item.getProjectCode())
-                        .setCreateBy(loginUserId)
-                        .setUpdateBy(loginUserId)
-                        .setExtendFields(item.getExtendFields())
-                        .setOrderId(item.getAsnId())
-                        .setOrderItemId(item.getAsnItemId());
-                taskItems.add(taskItem);
-            });
-            if (!taskItemService.saveBatch(taskItems)) {
-                throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
-            }
-            waitPakinItems.forEach(item -> {
-                if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
-                        .set(WaitPakinItem::getWorkQty, item.getAnfme())
-                        .eq(WaitPakinItem::getId, item.getId()))) {
-                    throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
+                /**鑾峰彇搴撲綅*/
+                String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null, rowList);
+                if (Cools.isEmpty(targetLoc)) {
+                    throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
                 }
-            });
-        });
 
-        if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
-                .in(WaitPakin::getId, ids)
-                .set(WaitPakin::getUpdateBy, loginUserId)
-                .set(WaitPakin::getCreateBy, loginUserId)
-                .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
-            throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+                List<TaskItem> taskItems = new ArrayList<>();
+                String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
+                if (StringUtils.isBlank(ruleCode)) {
+                    throw new CoolException("缂栫爜閿欒锛氳纭缂栫爜銆孲YS_TASK_CODE銆嶆槸鍚﹀凡鐢熸垚!!");
+                }
+
+                String staNoEnd = basStation.getStationName();
+                if (basStation.getIsWcs() != 0) {
+                    staNoEnd = "B102";
+                }
+                Task task = new Task();
+                task.setTaskCode(ruleCode)
+                        .setTaskStatus(TaskStsType.MISSION_INITIAL.id)
+                        .setTaskType(TaskType.TASK_TYPE_IN.type)
+                        .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
+                        .setTargLoc(targetLoc)
+                        .setBarcode(pakin.getBarcode())
+                        .setOrgSite(basStation.getStationName())
+                        .setTargSite(staNoEnd)
+                        .setCreateBy(loginUserId)
+                        .setUpdateBy(loginUserId);
+
+                if (!this.save(task)) {
+                    throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
+                }
+
+                if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
+                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
+                    throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
+                }
+                /**鑾峰彇缁勬嫋鏄庣粏**/
+                List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
+                if (waitPakinItems.isEmpty()) {
+                    throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨槑缁嗕笉瀛樺湪");
+                }
+                waitPakinItems.forEach(item -> {
+                    TaskItem taskItem = new TaskItem();
+                    BeanUtils.copyProperties(item, taskItem);
+                    taskItem.setTaskId(task.getId())
+                            .setOrderType(OrderType.ORDER_IN.type)
+                            .setSource(item.getId())
+                            .setTrackCode(item.getTrackCode())
+                            .setPlatItemId(item.getPlatItemId())
+                            .setPlatOrderCode(item.getPlatOrderCode())
+                            .setPlatWorkCode(item.getPlatWorkCode())
+                            .setProjectCode(item.getProjectCode())
+                            .setCreateBy(loginUserId)
+                            .setUpdateBy(loginUserId)
+                            .setExtendFields(item.getExtendFields())
+                            .setOrderId(item.getAsnId())
+                            .setSplrBatch(item.getBatch())
+                            .setPlatWorkCode(item.getPlatWorkCode())
+                            .setPlatItemId(item.getPlatItemId())
+                            .setOrderItemId(item.getAsnItemId());
+                    taskItems.add(taskItem);
+                });
+                if (!taskItemService.saveBatch(taskItems)) {
+                    throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
+                }
+                waitPakinItems.forEach(item -> {
+                    if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
+                            .set(WaitPakinItem::getWorkQty, item.getAnfme())
+                            .eq(WaitPakinItem::getId, item.getId()))) {
+                        throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
+                    }
+                });
+            }
+            if (!sign){
+                continue;
+            }
+
+            if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
+                    .in(WaitPakin::getId, ids)
+                    .set(WaitPakin::getUpdateBy, loginUserId)
+                    .set(WaitPakin::getCreateBy, loginUserId)
+                    .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
+                throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+            }
+            return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
         }
-        return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
+        String msg = "鏈壘搴撲綅" + Arrays.toString(errMsg);
+        throw new CoolException(msg);
     }
 
     /**
@@ -639,9 +758,12 @@
                 } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
                     //绉诲簱
                     moveInStock(task, loginUserId);
-                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) {
                     //绉诲簱
                     complateInstockE(task, loginUserId);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) {
+                    //瓒婂簱
+                    complateInstockDocking(task, loginUserId);
                 }
             }
         }
@@ -695,7 +817,7 @@
 //        if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
 //            task.setTaskStatus(TaskStsType.COMPLETE_OUT.id);
 //        } else {
-        task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : TaskStsType.AWAIT.id);
+        task.setTaskStatus(task.getTaskType() < 100 ? TaskStsType.COMPLETE_IN.id : task.getTaskType()==101? TaskStsType.COMPLETE_OUT.id:TaskStsType.AWAIT.id);
 //        }
         if (!this.updateById(task)) {
             throw new CoolException("瀹屾垚浠诲姟澶辫触");
@@ -711,7 +833,7 @@
      */
     private Task modiftyTaskSort(Task task, Long loginUserId) {
         String curLoc;
-        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+        if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) {
             curLoc = task.getTargLoc();
         } else {
             curLoc = task.getOrgLoc();
@@ -862,7 +984,15 @@
         for (Task task : tasks) {
             //鍑哄簱浠诲姟
             try {
-                complateOutStock(task, loginUserId);
+                if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) {
+                    //110.绌烘澘鍑哄簱
+                    complateOutStockEmpty(task, loginUserId);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)) {
+                    //110.绌烘澘鍑哄簱
+                    complateOutStockDocking(task, loginUserId);
+                } else {
+                    complateOutStock(task, loginUserId);
+                }
             } catch (Exception e) {
                 log.error(e.getMessage(), e);
 //                throw new CoolException(e.getMessage());
@@ -938,6 +1068,50 @@
     }
 
     /**
+     * 瓒婂簱鍥炲簱
+     *
+     * @param task
+     * @param loginUserId
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public void complateInstockDocking(Task task, Long loginUserId) {
+        if (Objects.isNull(task)) {
+            return;
+        }
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()));
+        if (Objects.isNull(loc)) {
+            throw new CoolException("搴撳瓨涓嶅瓨鍦紒锛�");
+        }
+//        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
+//            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
+//        }
+        loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
+                .setBarcode(task.getBarcode())
+                .setUpdateBy(loginUserId).setUpdateTime(new Date());
+
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅淇℃伅鏇存柊澶辫触锛侊紒");
+        }
+
+        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+        if (taskItems.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+        }
+
+        TaskItem taskItem = taskItems.stream().findFirst().get();
+        //淇濆瓨鍏ュ嚭搴撴祦姘�
+        saveStockItems(taskItems, task, null, null, taskItem.getWkType(), OrderType.ORDER_IN.type, loginUserId);
+
+        locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
+
+        task.setTaskStatus(TaskStsType.UPDATED_IN.id).setUpdateTime(new Date()).setUpdateBy(loginUserId);
+        if (!taskService.updateById(task)) {
+            throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+        }
+
+    }
+
+    /**
      * 浠诲姟鍙栨秷
      *
      * @param ids
@@ -949,8 +1123,8 @@
     public R removeTask(Long[] ids, Long loginUserId) {
         List<Integer> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id);
         List<Integer> list = Arrays.asList(TaskType.TASK_TYPE_IN.type, TaskType.TASK_TYPE_OUT.type, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type,
-                TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_EMPITY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type,
-                TaskType.TASK_TYPE_EMPITY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type);
+                TaskType.TASK_TYPE_CHECK_OUT.type, TaskType.TASK_TYPE_EMPTY_IN.type, TaskType.TASK_TYPE_LOC_MOVE.type,
+                TaskType.TASK_TYPE_EMPTY_OUT.type, TaskType.TASK_TYPE_MERGE_OUT.type);
         List<Task> tasks = this.list(new LambdaQueryWrapper<Task>()
                 .in(Task::getTaskType, list)
                 .in(Task::getId, ids)
@@ -1024,7 +1198,7 @@
 
             if (!Objects.isNull(task.getWarehType()) && task.getWarehType().equals(WarehType.WAREHOUSE_TYPE_AGV.val)) {
                 BasStation basStation = null;
-                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) {
                     basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                             .eq(BasStation::getStationName, task.getOrgSite())
                             .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type));
@@ -1032,7 +1206,7 @@
                         || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
                         || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
                         || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
-                        || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) {
+                        || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)) {
                     basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
                             .eq(BasStation::getStationName, task.getTargLoc())
                             .eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_R.type));
@@ -1412,7 +1586,7 @@
                 .eq(Task::getId, task.getId())
                 .set(Task::getUpdateBy, loginUserId)
                 .set(Task::getUpdateTime, new Date())
-                .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+                .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
             throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
         }
 
@@ -1438,6 +1612,139 @@
 ////            }
 //        }
 
+    }
+
+    /**
+     * @author Ryan
+     * @date 2025/5/20
+     * @description: 瀹屾垚鍑哄簱浠诲姟锛屾洿鏂板嚭搴撳簱瀛樹俊鎭�
+     * @version 1.0
+     */
+    @Synchronized
+    @Transactional(rollbackFor = Exception.class)
+    public void complateOutStockDocking(Task task, Long loginUserId) throws Exception {
+
+        if (Objects.isNull(task)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
+        if (Objects.isNull(loc)) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+        }
+        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勭悊浜嶳.鍑哄簱棰勭害锛侊紒");
+        }
+
+        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+        if (taskItems.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
+        }
+
+        List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()));
+        if (locItems.isEmpty()) {
+            throw new CoolException("搴撲綅鏄庣粏涓嶅瓨鍦紒锛�");
+        }
+
+        List<LocItemWorking> workings = new ArrayList<>();
+        for (LocItem item : locItems) {
+            LocItemWorking working = new LocItemWorking();
+            BeanUtils.copyProperties(item, working);
+            working.setId(null)
+                    .setTaskId(task.getId())
+                    .setLocItemId(item.getId())
+                    .setUpdateBy(loginUserId)
+                    .setUpdateTime(new Date());
+            workings.add(working);
+        }
+
+
+        //娣诲姞鍑哄叆搴撹褰曚俊鎭�
+        Map<Short, List<TaskItem>> listMap = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getWkType));
+        /***鑾峰彇搴撳瓨鍑哄簱鍊硷紝濡傛灉涓虹┖琛ㄧず姝e父鍗曟嵁鍑哄簱锛岄潪绌鸿〃鏄庢槸搴撳瓨鍑哄簱
+         * 1. 搴撳瓨鍑哄簱娌℃湁鍗曟嵁淇℃伅锛屽崟鎹俊鎭粯璁や负绌�
+         * 2. 鍗曟嵁搴撳瓨闇�閫氳繃娉㈡鏌ヨ鍘熷鍗曟嵁淇℃伅锛屽皢鍗曟嵁淇℃伅濉叆stock涓�
+         * */
+        List<TaskItem> list = listMap.get(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_OUT.type));
+        if (Objects.isNull(list) || list.isEmpty()) {
+            Map<Long, List<TaskItem>> maps = taskItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
+            maps.keySet().forEach(key -> {
+                if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)) {
+                    WkOrderItem orderItem = asnOrderItemService.getById(key);
+                    if (Objects.isNull(orderItem)) {
+                        throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+                    }
+                    try {
+                        saveOutStockItem(taskItems, orderItem, null, null, loginUserId);
+                    } catch (Exception e) {
+                        throw new CoolException(e.getMessage());
+                    }
+                }
+            });
+        } else {
+            try {
+                saveOutStockItem(taskItems, null, null, null, loginUserId);
+            } catch (Exception e) {
+                throw new CoolException(e.getMessage());
+            }
+        }
+
+        /**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
+        if (!locService.update(new LambdaUpdateWrapper<Loc>()
+                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
+                .set(Loc::getBarcode, loc.getBarcode())
+                .set(Loc::getUpdateBy, loginUserId)
+                .set(Loc::getUpdateTime, new Date())
+                .eq(Loc::getId, loc.getId()))) {
+            throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+        }
+
+        if (!this.update(new LambdaUpdateWrapper<Task>()
+                .eq(Task::getId, task.getId())
+                .set(Task::getUpdateBy, loginUserId)
+                .set(Task::getUpdateTime, new Date())
+                .set(Task::getTargLoc, task.getOrgLoc())
+                .set(Task::getTaskStatus, TaskStsType.COMPLETE_IN.id))) {
+            throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+        }
+    }
+
+    /**
+     * @author Ryan
+     * @date 2025/5/20
+     * @description: 瀹屾垚鍑哄簱浠诲姟锛屾洿鏂板嚭搴撳簱瀛樹俊鎭�
+     * @version 1.0
+     */
+    @Synchronized
+    @Transactional(rollbackFor = Exception.class)
+    public void complateOutStockEmpty(Task task, Long loginUserId) throws Exception {
+        if (Objects.isNull(task)) {
+            throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+        }
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getOrgLoc()));
+        if (Objects.isNull(loc)) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
+        }
+        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
+            throw new CoolException("搴撲綅鐘舵�佷笉澶勭悊浜嶳.鍑哄簱棰勭害锛侊紒");
+        }
+
+        /**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
+        if (!locService.update(new LambdaUpdateWrapper<Loc>()
+                .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+                .set(Loc::getBarcode, null)
+                .set(Loc::getUpdateBy, loginUserId)
+                .set(Loc::getUpdateTime, new Date())
+                .eq(Loc::getId, loc.getId()))) {
+            throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+        }
+
+        if (!this.update(new LambdaUpdateWrapper<Task>()
+                .eq(Task::getId, task.getId())
+                .set(Task::getUpdateBy, loginUserId)
+                .set(Task::getUpdateTime, new Date())
+                .set(Task::getTaskStatus, TaskStsType.UPDATED_OUT.id))) {
+            throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+        }
     }
 
     /**
@@ -1596,7 +1903,7 @@
                 itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
             } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
                     || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)) {
                 /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
                 itemParam.setDestLoc(task.getTargLoc())
                         .setOriSta(task.getOrgSite());
@@ -1606,7 +1913,7 @@
                         .setOriSta(task.getTargSite());
             } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
                     || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
-                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+                    || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)
                     || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
                     || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
                 /**鍑哄簱鍙傛暟*/
@@ -1658,7 +1965,7 @@
                         if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
 
@@ -1684,7 +1991,7 @@
                         } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
-                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+                                || task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_OUT.type)
                                 || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
                             BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
                             if (Objects.isNull(curSta)) {
@@ -1925,7 +2232,7 @@
         if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) ||
                 task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type) ||
                 task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type) ||
-                task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type) ||
+                task.getTaskType().equals(TaskType.TASK_TYPE_EMPTY_IN.type) ||
                 task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
             stock.setLocCode(task.getTargLoc());
         } else {

--
Gitblit v1.9.1