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 |   44 ++++++++++++++++++++++++++++++++------------
 1 files changed, 32 insertions(+), 12 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 15505a1..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
@@ -51,6 +51,8 @@
     private WaveService waveService;
     @Autowired
     private BasStationService basStationService;
+    @Autowired
+    private LocItemWorkingService locItemWorkingService;
 
 
     /**
@@ -106,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("绔欑偣涓嶆敮鎸佺┖瀹瑰櫒鍑哄簱锛侊紒");
                 }
@@ -134,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("鏄庣粏涓嶈兘涓虹┖锛�");
         }
@@ -211,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("绔欑偣涓嶆敮鎸佹嫞鏂欏嚭搴擄紒锛�");
                     }
@@ -220,8 +222,8 @@
                     if (resouce.equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val)){
                         //鍏ㄦ澘鍑哄簱
                         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(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_CROSS_DOCKING_OUT.type)
+                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                         if (Objects.isNull(deviceSite)) {
                             throw new CoolException("绔欑偣涓嶆敮鎸佽秺搴擄紒锛�");
                         }
@@ -229,8 +231,8 @@
                     } else {
                         //鍏ㄦ澘鍑哄簱
                         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(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type)
+                                .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel()).last("limit 1"));
                         if (Objects.isNull(deviceSite)) {
                             throw new CoolException("绔欑偣涓嶆敮鎸佸叏鏉垮嚭搴擄紒锛�");
                         }
@@ -243,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("褰撳墠绔欑偣涓嶆敮鎸佺洏鐐瑰嚭搴擄紒锛�");
                 }
@@ -286,7 +288,6 @@
                     throw new CoolException("涓讳换鍔″叧鑱斿け璐ワ紒锛�");
                 }
             }
-
             List<TaskItem> taskItems = new ArrayList<>();
             listMap.get(key).forEach(item -> {
                 TaskItem taskItem = new TaskItem();
@@ -340,7 +341,26 @@
                 if (!locItemService.updateById(item)) {
                     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("浠诲姟鏄庣粏鐢熸垚澶辫触锛侊紒");
@@ -381,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