From 79ce234f181a8fa5e3e02938520395243c82a5da Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期五, 06 三月 2026 08:15:39 +0800
Subject: [PATCH] 拣货过程中的出库库存匹配+空板

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |  258 +++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 228 insertions(+), 30 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 4e4640d..7ebc3ce 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
@@ -467,16 +467,18 @@
         if (success.compareAndSet(false, true)) {
             Long loginUserId = SystemAuthUtils.getLoginUserId();
             for (Task task : tasks) {
-                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
-                    //1.鍏ュ簱
+                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)) {
+                    //1.鍏ュ簱銆�54.骞舵澘鍐嶅叆搴�
                     complateInstock(task, loginUserId);
                 } else if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
-                    //53.鎷f枡鍐嶅叆搴�
-                    //57.鐩樼偣鍐嶅叆搴�
+                    //53.鎷f枡鍐嶅叆搴撱��57.鐩樼偣鍐嶅叆搴�
                     pickComplateInStock(task, loginUserId);
                 } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                    //绉诲簱
+                    //11.搴撴牸绉昏浇
                     moveInStock(task, loginUserId);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+                    //10.绌烘澘鍏ュ簱锛氫笌鏅�氬叆搴撳叡鐢ㄤ竴涓畬鎴愰�昏緫锛堣嫢鏈夌粍鎵樺垯鏇存柊缁勬墭/搴撲綅骞朵笂鎶ヤ簯浠擄級
+                    complateInstock(task, loginUserId);
                 }
             }
         }
@@ -812,7 +814,11 @@
                 .set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
             throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
         }
-
+        // 9.1 鍏�/鍑哄簱缁撴灉涓婃姤锛氬簱鏍肩Щ杞藉畬鎴愬悗閫氱煡浜戜粨锛堜笌瀹氭椂浠诲姟闂幆涓�鑷达級
+        List<TaskItem> moveTaskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+        if (!moveTaskItems.isEmpty()) {
+            reportInOutResultToCloud(task, loc, moveTaskItems, null, true);
+        }
     }
 
 
@@ -911,7 +917,8 @@
         if (!taskService.updateById(task)) {
             throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
         }
-
+        // 9.1 鍏�/鍑哄簱缁撴灉涓婃姤锛氭嫞鏂欏啀鍏ュ簱/鐩樼偣鍐嶅叆搴撳畬鎴愬悗閫氱煡浜戜粨锛堜笌瀹氭椂浠诲姟闂幆涓�鑷达級
+        reportInOutResultToCloud(task, loc, taskItems, null, true);
     }
 
     /**
@@ -1376,6 +1383,15 @@
             });
             log.debug("[鎷f枡鍏ュ簱] 鍗冲皢鎵e噺搴撲綅 locId={}, locCode={}", loc.getId(), loc.getCode());
             subtractLocItemByTaskItems(loc, taskItems, SystemAuthUtils.getLoginUserId());
+            // 鏂欑宸插叏閮ㄧ敤瀹屽垯涓嶇敓鎴愭嫞璐у叆搴撳崟锛屼粎瀹岀粨鍑哄簱
+            double totalRemaining = taskItems.stream().mapToDouble(ti -> ti.getAnfme() != null && ti.getAnfme().compareTo(0.0) > 0 ? ti.getAnfme() : 0.0).sum();
+            if (totalRemaining <= 0.0) {
+                task.setTaskType(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type);
+                task.setTaskStatus(TaskStsType.UPDATED_OUT.id);
+                this.updateById(task);
+                locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()));
+                return task;
+            }
         }
 
         tempLocs.forEach(working -> {
@@ -1471,6 +1487,137 @@
     }
 
     /**
+     * 鍚岀鐮佷笅澶氭潯 200 鎷f枡鍑哄簱涓�娆℃�у鐞嗭細鎸夌浉鍚岀墿鏂欏悎璁℃墸鍑忓簱浣嶃�佹洿鏂板嚭搴撳崟/搴撳瓨鏄庣粏銆佺敓鎴愪竴寮犳嫞鏂欏叆搴撳崟锛堟湁浣欓噺鏃讹級銆佹洿鏂板簱浣嶇姸鎬�
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void processPickOutBarcodeAll200(List<Task> all200Tasks) {
+        if (all200Tasks == null || all200Tasks.isEmpty()) {
+            return;
+        }
+        Task first = all200Tasks.get(0);
+        if (!TaskType.TASK_TYPE_PICK_AGAIN_OUT.type.equals(first.getTaskType()) || !TaskStsType.UPDATED_OUT.id.equals(first.getTaskStatus())) {
+            throw new CoolException("闈炴嫞鏂欏嚭搴�200浠诲姟锛屼笉鍙壒閲忓鐞�");
+        }
+        List<Long> taskIds = all200Tasks.stream().map(Task::getId).collect(Collectors.toList());
+        List<TaskItem> allItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, taskIds));
+        if (allItems.isEmpty()) {
+            throw new CoolException("浠诲姟鏄庣粏涓虹┖");
+        }
+        Long loginUserId = SystemAuthUtils.getLoginUserId();
+        if (loginUserId == null) {
+            loginUserId = 1L;
+        }
+        String orgLoc = first.getOrgLoc();
+        Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, orgLoc));
+        if (loc == null) {
+            throw new CoolException("搴撲綅涓嶅瓨鍦細" + orgLoc);
+        }
+        // 鎸夌墿鏂�+鎵规+绁ㄥ彿姹囨�诲凡鎷f暟閲�
+        Map<String, List<TaskItem>> byKey = allItems.stream().collect(Collectors.groupingBy(ti ->
+                (ti.getMatnrId() != null ? ti.getMatnrId() : "") + "_" + (ti.getBatch() != null ? ti.getBatch() : "") + "_" + (ti.getFieldsIndex() != null ? ti.getFieldsIndex() : "")));
+        List<TaskItem> aggregatedForDeduct = new ArrayList<>();
+        Map<String, Double> remainderByKey = new LinkedHashMap<>();
+        for (Map.Entry<String, List<TaskItem>> e : byKey.entrySet()) {
+            List<TaskItem> group = e.getValue();
+            double totalQty = group.stream().mapToDouble(ti -> ti.getQty() != null && ti.getQty() > 0 ? ti.getQty() : (ti.getAnfme() != null ? ti.getAnfme() : 0)).sum();
+            TaskItem rep = group.get(0);
+            TaskItem forDeduct = new TaskItem();
+            forDeduct.setMatnrId(rep.getMatnrId()).setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setQty(totalQty);
+            aggregatedForDeduct.add(forDeduct);
+            LambdaQueryWrapper<LocItem> qw = new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId()).eq(LocItem::getMatnrId, rep.getMatnrId());
+            if (StringUtils.isNotBlank(rep.getBatch())) qw.eq(LocItem::getBatch, rep.getBatch());
+            else qw.and(w -> w.isNull(LocItem::getBatch).or().eq(LocItem::getBatch, ""));
+            if (StringUtils.isNotBlank(rep.getFieldsIndex())) qw.eq(LocItem::getFieldsIndex, rep.getFieldsIndex());
+            else qw.and(w -> w.isNull(LocItem::getFieldsIndex).or().eq(LocItem::getFieldsIndex, ""));
+            LocItem li = locItemService.getOne(qw);
+            double remainder = (li != null && li.getAnfme() != null ? li.getAnfme() : 0) - totalQty;
+            if (remainder > 0) {
+                remainderByKey.put(e.getKey(), remainder);
+            }
+        }
+        subtractLocItemByTaskItems(loc, aggregatedForDeduct, loginUserId);
+        // 鎸� source 鍒嗙粍鏇存柊鍑哄簱鍗曞苟鍐欏簱瀛樻祦姘�
+        Map<Long, List<TaskItem>> bySource = allItems.stream().collect(Collectors.groupingBy(TaskItem::getSource));
+        for (Map.Entry<Long, List<TaskItem>> e : bySource.entrySet()) {
+            Long key = e.getKey();
+            List<TaskItem> items = e.getValue();
+            if (first.getResource() != null && first.getResource().equals(TaskResouceType.TASK_RESOUCE_WAVE_TYPE.val)) {
+                WaveItem waveItem = waveItemService.getById(key);
+                if (waveItem != null) {
+                    try {
+                        saveOutStockItem(items, null, waveItem, null, loginUserId);
+                    } catch (Exception ex) {
+                        throw new CoolException(ex.getMessage());
+                    }
+                }
+            } else if (first.getResource() != null && first.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
+                WkOrderItem orderItem = asnOrderItemService.getById(key);
+                if (orderItem != null) {
+                    try {
+                        saveOutStockItem(items, orderItem, null, null, loginUserId);
+                    } catch (Exception ex) {
+                        throw new CoolException(ex.getMessage());
+                    }
+                }
+            }
+        }
+        // 鏈変綑閲忓垯鐢熸垚涓�寮犳嫞鏂欏叆搴撳崟
+        if (!remainderByKey.isEmpty()) {
+            Task pickInTask = new Task();
+            pickInTask.setTaskCode(SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, first));
+            pickInTask.setTaskType(TaskType.TASK_TYPE_PICK_IN.type);
+            pickInTask.setTaskStatus(TaskStsType.GENERATE_IN.id);
+            pickInTask.setBarcode(first.getBarcode());
+            pickInTask.setOrgLoc(orgLoc);
+            pickInTask.setTargLoc(orgLoc);
+            pickInTask.setOrgSite(first.getTargSite());
+            pickInTask.setTargSite(first.getTargSite());
+            pickInTask.setResource(first.getResource());
+            if (!this.save(pickInTask)) {
+                throw new CoolException("鎷f枡鍏ュ簱浠诲姟鍒涘缓澶辫触");
+            }
+            List<LocItemWorking> workings = new ArrayList<>();
+            for (Map.Entry<String, Double> re : remainderByKey.entrySet()) {
+                String k = re.getKey();
+                Double rem = re.getValue();
+                if (rem == null || rem <= 0) continue;
+                List<TaskItem> group = byKey.get(k);
+                if (group == null || group.isEmpty()) continue;
+                TaskItem rep = group.get(0);
+                TaskItem ti = new TaskItem();
+                ti.setTaskId(pickInTask.getId());
+                ti.setMatnrId(rep.getMatnrId()).setMaktx(rep.getMaktx()).setMatnrCode(rep.getMatnrCode());
+                ti.setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setUnit(rep.getUnit()).setSpec(rep.getSpec()).setModel(rep.getModel());
+                ti.setAnfme(rem).setQty(0.0);
+                taskItemService.save(ti);
+                LocItemWorking w = new LocItemWorking();
+                w.setTaskId(pickInTask.getId());
+                w.setLocId(loc.getId());
+                w.setLocCode(loc.getCode());
+                w.setMatnrId(rep.getMatnrId()).setMaktx(rep.getMaktx()).setMatnrCode(rep.getMatnrCode());
+                w.setBatch(rep.getBatch()).setFieldsIndex(rep.getFieldsIndex()).setUnit(rep.getUnit());
+                w.setAnfme(rem);
+                workings.add(w);
+            }
+            if (!workings.isEmpty()) {
+                locItemWorkingService.saveBatch(workings);
+            }
+            loc.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+            locService.updateById(loc);
+        } else {
+            loc.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
+            loc.setBarcode(null);
+            loc.setUpdateBy(loginUserId);
+            loc.setUpdateTime(new Date());
+            locService.updateById(loc);
+        }
+        for (Long tid : taskIds) {
+            locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, tid));
+        }
+    }
+
+    /**
      * @author Ryan
      * @date 2025/5/20
      * @description: 瀹屾垚鍑哄簱浠诲姟锛屾洿鏂板嚭搴撳簱瀛樹俊鎭�
@@ -1486,7 +1633,35 @@
         if (Objects.isNull(loc)) {
             throw new CoolException("搴撲綅涓嶅瓨鍦紒锛�");
         }
-        
+
+        // 绌烘澘鍑哄簱锛氭棤浠诲姟鏄庣粏锛屼笉闇�瑕� PDA 鎷h揣纭锛孯CS 鍥炶皟鍚庣洿鎺ュ畬鎴愬簱浣嶆洿鏂板苟缃负 UPDATED_OUT
+        if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)) {
+            List<TaskItem> emptyItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
+            if (emptyItems.isEmpty()) {
+                if (!LocStsType.LOC_STS_TYPE_R.type.equals(loc.getUseStatus())) {
+                    log.warn("绌烘澘鍑哄簱浠诲姟{}鐨勫簱浣峽}鐘舵�佷笉鏄疪.鍑哄簱棰勭害锛岃烦杩�", task.getId(), loc.getCode());
+                    return;
+                }
+                if (!locService.update(new LambdaUpdateWrapper<Loc>()
+                        .eq(Loc::getId, loc.getId())
+                        .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type)
+                        .set(Loc::getBarcode, null)
+                        .set(Loc::getUpdateBy, loginUserId)
+                        .set(Loc::getUpdateTime, new Date()))) {
+                    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("绌烘澘鍑哄簱浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
+                }
+                log.info("[绌烘澘鍑哄簱] 浠诲姟{} RCS鍥炶皟鍚庡凡鐩存帴瀹屾垚搴撲綅鏇存柊锛屾棤闇�PDA纭", task.getTaskCode());
+                return;
+            }
+        }
+
         List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
         if (taskItems.isEmpty()) {
             throw new CoolException("浠诲姟鏄庣粏涓嶅瓨鍦紒锛�");
@@ -1564,11 +1739,11 @@
                     if (Objects.isNull(waveItem)) {
                         throw new CoolException("娉㈡鏄庣粏涓嶅瓨鍦紒锛�");
                     }
-//                    try {
-//                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
-//                    } catch (Exception e) {
-//                        throw new CoolException(e.getMessage());
-//                    }
+                    try {
+                        saveOutStockItem(maps.get(key), null, waveItem, null, loginUserId);
+                    } catch (Exception e) {
+                        throw new CoolException(e.getMessage());
+                    }
                 } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
                     WkOrderItem orderItem = asnOrderItemService.getById(key);
                     if (Objects.isNull(orderItem)) {
@@ -1603,15 +1778,8 @@
         
         // 鏍规嵁浠诲姟绫诲瀷鏇存柊搴撲綅鐘舵��
         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>()
-                    .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type)
-                    .set(Loc::getBarcode, null)
-                    .set(Loc::getUpdateBy, loginUserId)
-                    .set(Loc::getUpdateTime, new Date())
-                    .eq(Loc::getId, loc.getId()))) {
-                throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
-            }
+            // 鎷f枡鍑哄簱/鐩樼偣鍑哄簱锛氬湪鏈敓鎴愭嫞鏂欏叆搴撳崟涔嬪墠淇濇寔 R.棰勭害鍑哄簱锛屽惁鍒欎笅鍙戜换鍔℃椂鏌ヤ笉鍒拌搴撲綅锛堝彧鏌� F+R锛夊鑷粹�滃簱瀛樹笉瓒斥��
+            // 绛� PDA 纭骞剁敓鎴愭嫞鏂欏叆搴撲换鍔℃椂锛屽啀鍦� pickOrCheckTask 涓皢鐩爣搴撲綅鏀逛负 S.棰勭害鍏ュ簱
         } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)) {
             // 鍏ㄧ増鍑哄簱锛氫笉鏇存柊搴撲綅鐘舵�佷负O锛岀瓑寰匬DA蹇�熸嫞璐х‘璁ゆ椂鍐嶆洿鏂�
             // 搴撲綅鐘舵�佷繚鎸佸師鏍凤紙R.鍑哄簱棰勭害鐘舵�侊級
@@ -1696,8 +1864,35 @@
                 .setUpdateTime(new Date())
                 .setAnfme(sum);
         if (!Objects.isNull(waveItem)) {
-            //TODO 鐢熸垚娉㈡鏃堕渶瑕佸皢娉㈡鍙峰啓鍏ュ崟鎹紝閫氳繃鐗╂枡锛屾壒娆★紝鍔ㄦ�佸瓧娈电瓑鍞竴鍊煎弽鏌ュ崟鎹俊鎭�
+            // 娉㈡鍑哄簱锛氭洿鏂板嚭搴撳崟瀹屾垚鏁伴噺鍙婂嚭搴撳崟鏄庣粏鎵ц鏁伴噺
             stock.setSourceId(waveItem.getId()).setType(OrderType.ORDER_OUT.type);
+            Long orderId = waveItem.getOrderId();
+            if (orderId != null) {
+                WkOrder wkOrder = asnOrderService.getById(orderId);
+                if (wkOrder != null) {
+                    Double curQty = wkOrder.getQty() != null ? wkOrder.getQty() : 0.0;
+                    Double newQty = QuantityUtils.roundToScale(curQty + sum);
+                    wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val).setQty(newQty);
+                    if (!asnOrderService.updateById(wkOrder)) {
+                        throw new CoolException("鍑哄簱鍗曞畬鎴愭暟閲忔洿鏂板け璐ワ紒锛�");
+                    }
+                }
+                // 鎸夊嚭搴撳崟鏄庣粏姹囨�绘湰娆′换鍔℃暟閲忥紝鏇存柊鍚勬槑缁� workQty
+                Map<Long, Double> sumByOrderItemId = taskItems.stream()
+                        .filter(ti -> ti.getOrderItemId() != null)
+                        .collect(Collectors.groupingBy(TaskItem::getOrderItemId,
+                                Collectors.summingDouble(ti -> ti.getAnfme() != null ? ti.getAnfme() : 0.0)));
+                for (Map.Entry<Long, Double> e : sumByOrderItemId.entrySet()) {
+                    WkOrderItem oi = outStockItemService.getById(e.getKey());
+                    if (oi != null) {
+                        Double wq = oi.getWorkQty() != null ? oi.getWorkQty() : 0.0;
+                        oi.setWorkQty(QuantityUtils.roundToScale(wq + e.getValue()));
+                        if (!outStockItemService.updateById(oi)) {
+                            throw new CoolException("鍑哄簱鍗曟槑缁嗘墽琛屾暟閲忔洿鏂板け璐ワ紒锛�");
+                        }
+                    }
+                }
+            }
         } else if (!Objects.isNull(orderItem) && StringUtils.isNotBlank(orderItem.getId() + "")) {
             WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId());
             Double qty = Math.round((wkOrder.getQty() + sum) * 1000000) / 1000000.0;
@@ -2222,7 +2417,7 @@
             List<TaskItem> items = orderMap.get(key);
             //淇濆瓨鍏ュ嚭搴撴槑缁�
             saveStockItems(items, task, pakinItem.getId(), pakinItem.getAsnCode(), pakinItem.getWkType(), pakinItem.getType(), loginUserId);
-            //绉诲嚭鏀惰揣鍖哄簱瀛橈紝 淇敼缁勬墭鐘舵�侊紙鍙湁褰搒ource涓嶄负null鏃舵墠闇�瑕佺Щ闄ゆ敹璐у尯搴撳瓨锛�
+            // DirectWaitPakin 鍚敤鏃剁粍鎵樻潵鑷敹璐у尯锛屽叆搴撳畬鎴愬悗绉诲嚭鏀惰揣鍖哄簱瀛橈紱鏈惎鐢ㄦ椂 source 涓� null 涓嶆墽琛�
             if (Objects.nonNull(pakinItem.getSource())) {
                 removeReceiptStock(pakinItem, loginUserId);
             }
@@ -2322,12 +2517,12 @@
                 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, ""));
-            }
+            // 绁ㄥ彿鏆備笉浣跨敤锛屼笉鎸夌エ鍙峰尮閰嶏紝鍙煡绁ㄥ彿涓� null 鎴栫┖鐨勫簱浣嶆槑缁�
+            // 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)) {
@@ -2452,6 +2647,9 @@
             Date now = new Date();
             for (TaskItem item : taskItems) {
                 String orderNo = isInbound ? sourceToOrderNo.get(item.getSource()) : (item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode());
+                if (orderNo == null && isInbound) {
+                    orderNo = item.getPlatOrderCode() != null ? item.getPlatOrderCode() : item.getPlatWorkCode();
+                }
                 if (orderNo == null || item.getMatnrCode() == null) {
                     continue;
                 }

--
Gitblit v1.9.1