From 6c3cc6842009f3897c3fb18bef8a6634fe653818 Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 04 三月 2026 19:59:11 +0800
Subject: [PATCH] lsh#

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java |   52 +++++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
index 6d30467..9486159 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java
@@ -108,7 +108,7 @@
                 //绌哄鍣ㄥ嚭搴�
                 DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                         .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
-                        .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPTY_OUT.type));
+                        .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_EMPTY_OUT.type).last("limit 1"));
                 if (Objects.isNull(deviceSite)) {
                     throw new CoolException("绔欑偣涓嶆敮鎸佺┖瀹瑰櫒鍑哄簱锛侊紒");
                 }
@@ -136,9 +136,9 @@
     @Synchronized
     @Transactional(rollbackFor = Exception.class)
     public synchronized void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
-        if (Objects.isNull(map.getSiteNo())) {
-            throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�");
-        }
+//        if (Objects.isNull(map.getSiteNo())) {
+//            throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�");
+//        }
         if (Objects.isNull(map.getItems()) || map.getItems().isEmpty()) {
             throw new CoolException("鏄庣粏涓嶈兘涓虹┖锛�");
         }
@@ -213,7 +213,7 @@
                     DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                             .eq(DeviceSite::getSite, siteNo)
                             .eq(!Objects.isNull(loc.getChannel()),DeviceSite::getChannel, loc.getChannel())
-                            .eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type));
+                            .eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type).last("limit 1"),false);
                     if (Objects.isNull(deviceSite)) {
                         throw new CoolException("绔欑偣涓嶆敮鎸佹嫞鏂欏嚭搴擄紒锛�");
                     }
@@ -223,7 +223,7 @@
                         //鍏ㄦ澘鍑哄簱
                         DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                                 .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)
-                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()));
+                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                         if (Objects.isNull(deviceSite)) {
                             throw new CoolException("绔欑偣涓嶆敮鎸佽秺搴擄紒锛�");
                         }
@@ -232,7 +232,7 @@
                         //鍏ㄦ澘鍑哄簱
                         DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                                 .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type)
-                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()));
+                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                         if (Objects.isNull(deviceSite)) {
                             throw new CoolException("绔欑偣涓嶆敮鎸佸叏鏉垮嚭搴擄紒锛�");
                         }
@@ -245,7 +245,7 @@
                 DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                         .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                         .eq(DeviceSite::getSite, siteNo)
-                        .eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type));
+                        .eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type).last("limit 1"));
                 if (Objects.isNull(deviceSite)) {
                     throw new CoolException("褰撳墠绔欑偣涓嶆敮鎸佺洏鐐瑰嚭搴擄紒锛�");
                 }
@@ -288,8 +288,6 @@
                     throw new CoolException("涓讳换鍔″叧鑱斿け璐ワ紒锛�");
                 }
             }
-            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
-
             List<TaskItem> taskItems = new ArrayList<>();
             listMap.get(key).forEach(item -> {
                 TaskItem taskItem = new TaskItem();
@@ -344,21 +342,25 @@
                     throw new CoolException("搴撳瓨淇℃伅淇敼澶辫触锛侊紒");
                 }
 
-                if (taskItem.getAnfme() > 0) {
-                    LocItemWorking itemWorking = new LocItemWorking();
-                    BeanUtils.copyProperties(taskItem, itemWorking);
-                    itemWorking.setTaskId(task.getId())
-                            .setQty(0.0)
-                            .setLocId(loc.getId())
-                            .setLocItemId(locItem.getId())
-                            .setType("out")
-                            .setLocCode(loc.getCode());
-
-                    if (!locItemWorkingService.save(itemWorking)) {
-                        throw new CoolException("涓存椂搴撳瓨鏇存柊澶辫触锛侊紒");
-                    }
-                }
             });
+
+            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
+
+            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);
+            }
+
+            if (!locItemWorkingService.saveBatch(workings)) {
+                throw new CoolException("涓存椂搴撳瓨鏇存柊澶辫触锛侊紒");
+            }
 
             if (!taskItemService.saveBatch(taskItems)) {
                 throw new CoolException("浠诲姟鏄庣粏鐢熸垚澶辫触锛侊紒");
@@ -399,7 +401,7 @@
             //鐩爣搴撲綅涓虹┖锛岃嚜鍔ㄨ幏鍙栨柊搴撲綅
             DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                     .eq(DeviceSite::getType, TaskType.TASK_TYPE_LOC_MOVE.type)
-                    .eq(!Objects.isNull(orgLoc.getChannel()), DeviceSite::getChannel, orgLoc.getChannel()), false);
+                    .eq(!Objects.isNull(orgLoc.getChannel()), DeviceSite::getChannel, orgLoc.getChannel()).last("limit 1"), false);
             if (Objects.isNull(deviceSite)) {
                 throw new CoolException("绔欑偣淇℃伅涓嶅瓨鍦紒锛�");
             }

--
Gitblit v1.9.1