From ed170766d35e68256f60ab48e3fd7071326455a9 Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期一, 09 二月 2026 09:32:24 +0800
Subject: [PATCH] pda确认流程优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   66 +++++++++++++++++++++++++++------
 1 files changed, 54 insertions(+), 12 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 cdfc073..1cfd1e6 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
@@ -1399,16 +1399,36 @@
         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 (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
+            // 濡傛灉搴撲綅鏄庣粏涓虹┖锛岃鏄庡凡缁忓鐞嗚繃浜嗭紝鐩存帴鏇存柊浠诲姟鐘舵�佷负199
+            if (locItems.isEmpty()) {
+                logger.warn("浠诲姟{}鐨勫簱浣峽}鐘舵�佷负{}锛屼絾搴撲綅鏄庣粏涓虹┖锛屽彲鑳藉凡缁忓鐞嗚繃锛岀洿鎺ユ洿鏂颁换鍔$姸鎬佷负199", 
+                        task.getId(), loc.getCode(), loc.getUseStatus());
+                if (!this.update(new LambdaUpdateWrapper<Task>()
+                        .eq(Task::getId, task.getId())
+                        .set(Task::getUpdateBy, loginUserId)
+                        .set(Task::getUpdateTime, new Date())
+                        .set(Task::getTaskStatus, TaskStsType.WAVE_SEED.id))) {
+                    throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
+                }
+                return; // 璺宠繃鍚庣画澶勭悊
+            } else {
+                // 搴撲綅鏄庣粏涓嶄负绌轰絾鐘舵�佷笉鏄疪锛岃褰曢敊璇絾涓嶆姏鍑哄紓甯革紝璁╁畾鏃朵换鍔$户缁鐞嗗叾浠栦换鍔�
+                logger.error("浠诲姟{}鐨勫簱浣峽}鐘舵�佷负{}锛屼笉鏄疪.鍑哄簱棰勭害鐘舵�侊紝浣嗗簱浣嶆槑缁嗕笉涓虹┖锛岃烦杩囧鐞嗐�備换鍔$紪鐮侊細{}锛屽簱浣嶇紪鐮侊細{}", 
+                        task.getId(), loc.getCode(), loc.getUseStatus(), task.getTaskCode(), loc.getCode());
+                return; // 璺宠繃澶勭悊锛岄伩鍏嶅紓甯镐腑鏂畾鏃朵换鍔�
+            }
+        }
+        
         // 濡傛灉搴撲綅鏄庣粏涓虹┖锛屽彲鑳芥槸宸茬粡琚鐞嗚繃浜嗭紝鍏佽缁х画鎵ц
         if (!locItems.isEmpty()) {
             List<LocItemWorking> workings = new ArrayList<>();
@@ -1430,8 +1450,8 @@
             try {
                 // 鏍规嵁浠诲姟绫诲瀷鏇存柊搴撲綅鏄庣粏
                 if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
-                    // 鍏ㄧ増鍑哄簱锛氬垹闄ゆ墍鏈夊簱浣嶆槑缁�
-                    subtractLocItem(loc);
+                    // 鍏ㄧ増鍑哄簱锛氫笉鍒犻櫎搴撲綅鏄庣粏锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶅垹闄�
+                    // subtractLocItem(loc); // 宸茬Щ闄わ紝鏀逛负鍦╟ompleteFullOutStock涓垹闄�
                 } else {
                     // 閮ㄥ垎鍑哄簱锛堝鎷f枡鍑哄簱锛夛細鏍规嵁TaskItem鏁伴噺鎵e噺搴撲綅鏄庣粏
                     subtractLocItemByTaskItems(loc, taskItems, loginUserId);
@@ -1493,6 +1513,8 @@
                 throw new CoolException(e.getMessage());
             }
         }
+        
+        // 鏍规嵁浠诲姟绫诲瀷鏇存柊搴撲綅鐘舵��
         if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
             /**淇敼涓哄簱浣嶇姸鎬佷负S.棰勭害鍏ュ簱锛屼繚鐣欏師鏈夊簱浣�*/
             if (!locService.update(new LambdaUpdateWrapper<Loc>()
@@ -1503,6 +1525,9 @@
                     .eq(Loc::getId, loc.getId()))) {
                 throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
             }
+        } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
+            // 鍏ㄧ増鍑哄簱锛氫笉鏇存柊搴撲綅鐘舵�佷负O锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶆洿鏂�
+            // 搴撲綅鐘舵�佷繚鎸佸師鏍凤紙R.鍑哄簱棰勭害鐘舵�侊級
         } else {
             /**淇敼涓哄簱浣嶇姸鎬佷负O.绌哄簱*/
             if (!locService.update(new LambdaUpdateWrapper<Loc>()
@@ -1761,7 +1786,10 @@
                     // 涓烘瘡涓笉鍚岀殑搴撲綅鍒涘缓涓�涓猅askItemParam
                     for (String locCode : locCodes) {
                         TaskItemParam outItemParam = new TaskItemParam();
-                        outItemParam.setTaskNo(task.getTaskCode());
+                        String taskNo = locCodes.size() > 1
+                                ? task.getTaskCode() + "_" + locCode 
+                                : task.getTaskCode();
+                        outItemParam.setTaskNo(taskNo);
                         outItemParam.setPriority(1);
                         outItemParam.setOriLoc(locCode);
                         outItemParam.setDestSta(task.getTargSite());
@@ -2161,12 +2189,26 @@
                 throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
             }
             LocItem item = new LocItem();
-            LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
+            // 鏋勫缓鏌ヨ鏉′欢锛氶渶瑕佸悓鏃跺尮閰嶇墿鏂橧D銆佸簱浣岻D銆佹壒娆″拰绁ㄥ彿
+            LambdaQueryWrapper<LocItem> locItemWrapper = new LambdaQueryWrapper<LocItem>()
                     .eq(LocItem::getMatnrId, taskItem.getMatnrId())
-                    .eq(LocItem::getLocId, loc.getId())
-                    .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItem::getBatch, taskItem.getBatch())
-                    .eq(StringUtils.isNotBlank(taskItem.getFieldsIndex()), LocItem::getFieldsIndex, taskItem.getFieldsIndex())
-            );
+                    .eq(LocItem::getLocId, loc.getId());
+            
+            // 鎵规鍖归厤锛氬鏋渢askItem鏈夋壒娆★紝鍒欏繀椤诲尮閰嶏紱濡傛灉taskItem娌℃湁鎵规锛屽垯鏌ヨ鎵规涓簄ull鎴栫┖瀛楃涓茬殑璁板綍
+            if (StringUtils.isNotBlank(taskItem.getBatch())) {
+                locItemWrapper.eq(LocItem::getBatch, taskItem.getBatch());
+            } else {
+                locItemWrapper.and(wrapper -> wrapper.isNull(LocItem::getBatch).or().eq(LocItem::getBatch, ""));
+            }
+            
+            // 绁ㄥ彿鍖归厤锛氬鏋渢askItem鏈夌エ鍙凤紝鍒欏繀椤诲尮閰嶏紱濡傛灉taskItem娌℃湁绁ㄥ彿锛屽垯鏌ヨ绁ㄥ彿涓簄ull鎴栫┖瀛楃涓茬殑璁板綍
+            if (StringUtils.isNotBlank(taskItem.getFieldsIndex())) {
+                locItemWrapper.eq(LocItem::getFieldsIndex, taskItem.getFieldsIndex());
+            } else {
+                locItemWrapper.and(wrapper -> wrapper.isNull(LocItem::getFieldsIndex).or().eq(LocItem::getFieldsIndex, ""));
+            }
+            
+            LocItem locItem = locItemService.getOne(locItemWrapper);
             if (Objects.isNull(locItem)) {
                 // 搴撲綅鏄庣粏涓嶅瓨鍦紝鍒涘缓鏂扮殑搴撲綅鏄庣粏
                 BeanUtils.copyProperties(taskItem, item);

--
Gitblit v1.9.1