From 7a717a0bbc0eac8e494cd84207482e983ef56a3c Mon Sep 17 00:00:00 2001
From: chen.lin <1442464845@qq.com>
Date: 星期日, 08 二月 2026 17:42:55 +0800
Subject: [PATCH] RCS入库流程优化

---
 rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java |   37 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
index 4fc12ff..73d859c 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
@@ -28,6 +28,7 @@
 import com.vincent.rsf.server.system.service.impl.FieldsItemServiceImpl;
 import com.vincent.rsf.server.system.service.impl.FieldsServiceImpl;
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
+import com.vincent.rsf.server.common.constant.Constants;
 import com.vincent.rsf.server.system.utils.SystemAuthUtils;
 import lombok.Synchronized;
 import org.apache.commons.lang3.StringUtils;
@@ -43,6 +44,7 @@
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.Date;
 
 @Service
 public class PdaOutStockServiceImpl implements PdaOutStockService {
@@ -356,6 +358,34 @@
                 if (!taskItemService.updateById(item)) {
                     throw new CoolException("鐘舵�佸畬鎴愬け璐ワ紒锛�");
                 }
+                
+                // 鎵e噺搴撲綅鏄庣粏搴撳瓨锛堜笌鍑哄簱瀹屾垚閫昏緫淇濇寔涓�鑷达級
+                if (StringUtils.isNotBlank(task.getOrgLoc())) {
+                    LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>()
+                            .eq(LocItem::getLocCode, task.getOrgLoc())
+                            .eq(LocItem::getMatnrId, item.getMatnrId())
+                            .eq(StringUtils.isNotBlank(item.getBatch()), LocItem::getBatch, item.getBatch())
+                            .eq(StringUtils.isNotBlank(item.getFieldsIndex()), LocItem::getFieldsIndex, item.getFieldsIndex()));
+                    
+                    if (Objects.nonNull(locItem)) {
+                        // 浣跨敤瀹為檯鎷h揣鏁伴噺锛坱askItem.getAnfme()锛夋墸鍑忓簱浣嶆槑缁�
+                        Double newAnfme = Math.round((locItem.getAnfme() - taskItem.getAnfme()) * 1000000) / 1000000.0;
+                        
+                        if (newAnfme.compareTo(0.0) <= 0) {
+                            // 鏁伴噺灏忎簬绛変簬0锛屽垹闄ゅ簱浣嶆槑缁�
+                            locItemService.removeById(locItem.getId());
+                        } else {
+                            // 鏇存柊搴撲綅鏄庣粏鏁伴噺
+                            locItem.setAnfme(newAnfme)
+                                    .setUpdateBy(SystemAuthUtils.getLoginUserId())
+                                    .setUpdateTime(new Date());
+                            if (!locItemService.updateById(locItem)) {
+                                throw new CoolException("搴撲綅鏄庣粏鏁伴噺鎵e噺澶辫触锛侊紒");
+                            }
+                        }
+                    }
+                }
+                
                 StockItem stockItem = new StockItem();
                 BeanUtils.copyProperties(item, stockItem);
                 //taskItem涓轰笂鎶ユ暟鎹�
@@ -515,9 +545,14 @@
 
 
         try {
-            if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+            if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
+                // 鎷f枡鍑哄簱锛氬垱寤烘嫞鏂欏叆搴撲换鍔�
                 taskService.pickOrCheckTask(task.getId(), "");
+            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+                // 鐩樼偣鍑哄簱锛氬垱寤虹洏鐐瑰叆搴撲换鍔�
+                taskService.pickOrCheckTask(task.getId(), Constants.TASK_TYPE_OUT_CHECK);
             } else {
+                // 鍏朵粬鍑哄簱绫诲瀷锛氱洿鎺ユ洿鏂颁负200
                 task.setTaskStatus(TaskStsType.UPDATED_OUT.id);
                 if (!taskService.updateById(task)) {
                     throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐�");

--
Gitblit v1.9.1