From ee536f9aedaf642d64ba2681778fd4e74731d00c Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期五, 16 一月 2026 16:47:28 +0800
Subject: [PATCH] lsh#空板流程

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/LocItemServiceImpl.java |  120 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 94 insertions(+), 26 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 a3bd489..a8de2f5 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
@@ -55,6 +55,74 @@
 
     /**
      * 搴撳瓨鍑哄簱鐢熸垚鍑哄簱浠诲姟
+     * type: 绌烘澘鍑哄簱
+     *
+     * @param resouce
+     * @param map
+     * @param loginUserId
+     * @return
+     */
+    @Override
+    @Synchronized
+    @Transactional(rollbackFor = Exception.class)
+    public synchronized void generateTaskEmpty(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
+        if (Objects.isNull(map.getSiteNo())) {
+            throw new CoolException("鐩爣绔欑偣涓嶈兘涓虹┖锛�");
+        }
+        if (Objects.isNull(map.getOrgLoc())) {
+            throw new CoolException("婧愬簱浣嶄笉鑳戒负绌猴紒");
+        }
+        String siteNo = map.getSiteNo();
+        Task task = new Task();
+        Loc loc = locService.getById(Long.decode(map.getOrgLoc()));
+        logger.info("搴撲綅锛�>{}", loc.getCode());
+        if (Objects.isNull(loc)) {
+            throw new CoolException("鏁版嵁閿欒锛氭墍閫夊簱瀛樹俊鎭笉瀛樺湪锛侊紒");
+        }
+        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_D.type)) {
+            throw new CoolException("搴撲綅:" + loc.getCode() + ",涓嶅浜嶥.绌烘澘鐘舵�侊紝涓嶅彲鎵цR.鍑哄簱棰勭害鎿嶄綔锛侊紒");
+        }
+
+        loc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+
+        if (!locService.updateById(loc)) {
+            throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐ワ紒锛�");
+        }
+        String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
+        task.setOrgLoc(loc.getCode())
+                .setTaskCode(ruleCode)
+                .setResource(resouce)
+                .setTargSite(siteNo)
+                .setSort(Constants.TASK_SORT_DEFAULT_VALUE)
+                .setUpdateBy(loginUserId)
+                .setCreateBy(loginUserId)
+                .setCreateTime(new Date())
+                .setUpdateTime(new Date())
+                .setTaskStatus(TaskStsType.GENERATE_OUT.id)
+                .setBarcode(loc.getBarcode())
+                .setMemo(map.getMemo());
+
+        if (map.getType().equals(Constants.TASK_TYPE_OUT_STOCK_EMPTY)) {
+                //绌哄鍣ㄥ嚭搴�
+                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_EMPITY_OUT.type));
+                if (Objects.isNull(deviceSite)) {
+                    throw new CoolException("绔欑偣涓嶆敮鎸佺┖瀹瑰櫒鍑哄簱锛侊紒");
+                }
+                task.setTaskType(TaskType.TASK_TYPE_EMPITY_OUT.type).setWarehType(deviceSite.getDevice());
+        } else {
+            throw new CoolException("绌哄鍣ㄥ嚭搴擄紒锛佸叾浠栫被鍨嬫棤鏁堬紝杩涘叆绫诲瀷锛�"+map.getType());
+        }
+
+        if (!taskService.save(task)) {
+            throw new CoolException("浠诲姟鍒涘缓澶辫触锛侊紒");
+        }
+    }
+
+
+    /**
+     * 搴撳瓨鍑哄簱鐢熸垚鍑哄簱浠诲姟
      * type: check 鐩樼偣, stock: 搴撳瓨鍑哄簱
      *
      * @param resouce
@@ -65,7 +133,7 @@
     @Override
     @Synchronized
     @Transactional(rollbackFor = Exception.class)
-    public void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
+    public synchronized void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception {
         if (Objects.isNull(map.getSiteNo())) {
             throw new CoolException("绔欑偣涓嶈兘涓虹┖锛�");
         }
@@ -137,7 +205,7 @@
                     //鎷f枡鍑哄簱 -- 鐩樼偣鍑哄簱
                     DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                             .eq(DeviceSite::getSite, siteNo)
-                            .eq(DeviceSite::getChannel, loc.getChannel())
+                            .eq(!Objects.isNull(loc.getChannel()),DeviceSite::getChannel, loc.getChannel())
                             .eq(DeviceSite::getType, TaskType.TASK_TYPE_PICK_AGAIN_OUT.type));
                     if (Objects.isNull(deviceSite)) {
                         throw new CoolException("绔欑偣涓嶆敮鎸佹嫞鏂欏嚭搴擄紒锛�");
@@ -146,7 +214,7 @@
                 } else {
                     //鍏ㄦ澘鍑哄簱
                     DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
-                            .eq(DeviceSite::getChannel, loc.getChannel())
+                            .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                             .eq(DeviceSite::getSite, siteNo).eq(DeviceSite::getType, TaskType.TASK_TYPE_OUT.type));
                     if (Objects.isNull(deviceSite)) {
                         throw new CoolException("绔欑偣涓嶆敮鎸佸叏鏉垮嚭搴擄紒锛�");
@@ -157,7 +225,7 @@
             } else if (map.getType().equals(Constants.TASK_TYPE_OUT_CHECK)) {
                 //鐩樼偣鍑哄簱
                 DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
-                        .eq(DeviceSite::getChannel, loc.getChannel())
+                        .eq(!Objects.isNull(loc.getChannel()), DeviceSite::getChannel, loc.getChannel())
                         .eq(DeviceSite::getSite, siteNo)
                         .eq(DeviceSite::getType, TaskType.TASK_TYPE_CHECK_OUT.type));
                 if (Objects.isNull(deviceSite)) {
@@ -170,27 +238,27 @@
                 throw new CoolException("浠诲姟鍒涘缓澶辫触锛侊紒");
             }
 
-            if (!LocUtils.isShallowLoc(loc.getCode())) {
-                //鑾峰彇娣卞簱浣嶅搴旀祬搴撲綅
-                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
-                Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
-                if (Objects.isNull(one)) {
-                    throw new CoolException("瀵瑰簲搴撲綅涓嶅瓨鍦紒锛�");
-                }
-                Task workTask = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, one.getBarcode()));
-                if (Objects.isNull(workTask)) {
-                    map.setOrgLoc(one.getCode());
-                    //浼樺厛鐢熸垚绉诲簱浠诲姟
-                    if (one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
-                        moveTask = genMoveTask(map, loginUserId);
-                    }
-                } else {
-                    workTask.setSort(task.getSort() + 1).setParentId(task.getId());
-                    if (!taskService.updateById(workTask)) {
-                        throw new CoolException("浼樺厛绾т慨鏀瑰け璐ワ紒锛�");
-                    }
-                }
-            }
+//            if (!LocUtils.isShallowLoc(loc.getCode())) {
+//                //鑾峰彇娣卞簱浣嶅搴旀祬搴撲綅
+//                String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
+//                Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
+//                if (Objects.isNull(one)) {
+//                    throw new CoolException("瀵瑰簲搴撲綅涓嶅瓨鍦紒锛�");
+//                }
+//                Task workTask = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, one.getBarcode()));
+//                if (Objects.isNull(workTask)) {
+//                    map.setOrgLoc(one.getCode());
+//                    //浼樺厛鐢熸垚绉诲簱浠诲姟
+//                    if (one.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+//                        moveTask = genMoveTask(map, loginUserId);
+//                    }
+//                } else {
+//                    workTask.setSort(task.getSort() + 1).setParentId(task.getId());
+//                    if (!taskService.updateById(workTask)) {
+//                        throw new CoolException("浼樺厛绾т慨鏀瑰け璐ワ紒锛�");
+//                    }
+//                }
+//            }
 
             if (!Objects.isNull(moveTask.getId())) {
                 moveTask.setParentId(task.getId()).setSort(moveTask.getSort() + 1);
@@ -294,7 +362,7 @@
             //鐩爣搴撲綅涓虹┖锛岃嚜鍔ㄨ幏鍙栨柊搴撲綅
             DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>()
                     .eq(DeviceSite::getType, TaskType.TASK_TYPE_LOC_MOVE.type)
-                    .eq(DeviceSite::getChannel, orgLoc.getChannel()), false);
+                    .eq(!Objects.isNull(orgLoc.getChannel()), DeviceSite::getChannel, orgLoc.getChannel()), false);
             if (Objects.isNull(deviceSite)) {
                 throw new CoolException("绔欑偣淇℃伅涓嶅瓨鍦紒锛�");
             }

--
Gitblit v1.9.1