From adb83050b74c2d7fa1845f18e016ef3b18496543 Mon Sep 17 00:00:00 2001
From: zc <zyzc>
Date: 星期三, 22 十月 2025 17:15:43 +0800
Subject: [PATCH] pda波次揀貨優化 放貨成功上報優化 出入庫站點功能優化

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   81 +++++++++++++++++++++++++++-------------
 1 files changed, 55 insertions(+), 26 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 79bde62..82a7389 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
@@ -3,7 +3,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.vincent.rsf.framework.common.Cools;
-import com.vincent.rsf.server.api.controller.params.TaskInParam;
+import com.vincent.rsf.server.api.controller.erp.params.TaskInParam;
 import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto;
 import com.vincent.rsf.server.api.service.WcsService;
 import com.vincent.rsf.server.common.constant.Constants;
@@ -23,6 +23,7 @@
 import com.vincent.rsf.server.system.utils.SerialRuleUtils;
 import com.vincent.rsf.server.system.utils.SystemAuthUtils;
 import lombok.Synchronized;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,8 +34,8 @@
 
 import java.util.*;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
+@Slf4j
 @Service("taskService")
 public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
 
@@ -92,6 +93,8 @@
     private CheckDiffService checkDiffService;
     @Autowired
     private CheckDiffItemService checkDiffItemService;
+    @Autowired
+    private BasContainerService basContainerService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -286,7 +289,7 @@
         if (Objects.isNull(deviceSite)) {
             throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
         }
-        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(Integer.valueOf(deviceSite.getSite())));
+        DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(deviceSite.getSite()));
         if (Cools.isEmpty(deviceBind)) {
             throw new CoolException("搴撲綅瑙勫垯鏈煡");
         }
@@ -304,8 +307,10 @@
             throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
         }
         waitPakins.forEach(pakin -> {
+            BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
+                    .eq(BasContainer::getCode, pakin.getBarcode()));
             /**鑾峰彇搴撲綅*/
-            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId());
+            String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
             if (Cools.isEmpty(targetLoc)) {
                 throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
             }
@@ -346,6 +351,18 @@
             if (!this.save(task)) {
                 throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
             }
+            BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+                    .eq(BasStation::getStationName, deviceSite.getSite()));
+            if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+                throw new CoolException("绔欑偣涓嶅瓨鍦ㄦ垨绔欑偣涓嶅浜庣┖搴撶姸鎬侊紒锛�");
+            }
+            station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+
+            if (!basStationService.updateById(station)) {
+                 throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+             }
+
+
             if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
                     .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
                 throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
@@ -407,22 +424,24 @@
      */
     @Synchronized
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void complateInTask(List<Task> tasks) throws Exception {
         Long loginUserId = SystemAuthUtils.getLoginUserId();
         for (Task task : tasks) {
-            if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
-                //1.鍏ュ簱
-                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.鐩樼偣鍐嶅叆搴�
-                pickComplateInStock(task, loginUserId);
-            } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
-                //绉诲簱
-                moveInStock(task, loginUserId);
+            try {
+                if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
+                    //1.鍏ュ簱
+                    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.鐩樼偣鍐嶅叆搴�
+                    pickComplateInStock(task, loginUserId);
+                } else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+                    //绉诲簱
+                    moveInStock(task, loginUserId);
+                }
+            } catch (Exception ex) {
+                log.error(ex.getMessage(), ex);
             }
-
         }
     }
 
@@ -591,7 +610,7 @@
                 //鏇存柊搴撲綅鏄庣粏
                 saveLocItem(taskItems, task.getId(), loginUserId);
             } catch (Exception e) {
-                throw new CoolException("搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
+                throw new CoolException("浠诲姟鍙凤細" + task.getTaskCode() +  "搴撲綅鏄庣粏鏇存柊澶辫触锛侊紒");
             }
 
             if (!locItemService.remove(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocCode, task.getOrgLoc()))) {
@@ -636,7 +655,6 @@
      */
     @Synchronized
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public void completeTask(List<Task> tasks) {
         Long loginUserId = SystemAuthUtils.getLoginUserId();
         for (Task task : tasks) {
@@ -644,7 +662,8 @@
             try {
                 complateOutStock(task, loginUserId);
             } catch (Exception e) {
-                throw new CoolException(e.getMessage());
+                log.error(e.getMessage(), e);
+//                throw new CoolException(e.getMessage());
             }
         }
     }
@@ -971,7 +990,7 @@
                 .setTaskStatus(TaskStsType.GENERATE_IN.id);
 
         TaskInParam param = new TaskInParam();
-        param.setSourceStaNo(Integer.parseInt(task.getTargSite()))
+        param.setSourceStaNo(task.getTargSite())
                 .setIoType(type)
                 .setLocType1(Integer.parseInt(loc.getType()));
         //鑾峰彇鏂板簱浣�
@@ -980,7 +999,8 @@
         if (Objects.isNull(locInfo)) {
             throw new CoolException("鑾峰彇搴撲綅澶辫触锛侊紒");
         }
-        task.setTargLoc(locInfo.getLocNo());
+        task.setTargLoc(locInfo.getLocNo())
+                .setOrgSite(task.getTargSite());
 
         if (!this.updateById(task)) {
             throw new CoolException("浠诲姟鐘舵�佹洿鏂板け璐ワ紒锛�");
@@ -1144,14 +1164,23 @@
                     } catch (Exception e) {
                         throw new CoolException(e.getMessage());
                     }
-                } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)
-                        || task.getResource().equals(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val)) {
+                } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_ORDER_TYPE.val)) {
                     WkOrderItem orderItem = asnOrderItemService.getById(key);
                     if (Objects.isNull(orderItem)) {
                         throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
                     }
                     try {
-                        saveOutStockItem(maps.get(key), orderItem, null, null, loginUserId);
+                        saveOutStockItem(maps.get(key), orderItem,  loginUserId);
+                    } catch (Exception e) {
+                        throw new CoolException(e.getMessage());
+                    }
+                } else if (task.getResource().equals(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val)) {
+                    WkOrderItem orderItem = asnOrderItemService.getById(key);
+                    if (Objects.isNull(orderItem)) {
+                        throw new CoolException("鍗曟嵁鏄庣粏涓嶅瓨鍦紒锛�");
+                    }
+                    try {
+                        saveOutStockItem(maps.get(key), null, null, orderItem, loginUserId);
                     } catch (Exception e) {
                         throw new CoolException(e.getMessage());
                     }
@@ -1208,7 +1237,7 @@
      * @version 1.0
      */
     @Transactional(rollbackFor = Exception.class)
-    public void saveOutStockItem(List<TaskItem> taskItems, CheckDiffItem diffItem, Long loginUserId) {
+    public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem diffItem, Long loginUserId) {
         try {
             saveOutStockItem(taskItems, null, null, diffItem, loginUserId);
         } catch (Exception e) {
@@ -1223,7 +1252,7 @@
      * @version 1.0
      */
     @Transactional(rollbackFor = Exception.class)
-    public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, CheckDiffItem diffItem, Long loginUserId) throws Exception {
+    public void saveOutStockItem(List<TaskItem> taskItems, WkOrderItem orderItem, WaveItem waveItem, WkOrderItem diffItem, Long loginUserId) throws Exception {
         Stock stock = new Stock();
         String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_STOCK_CODE, null);
         if (StringUtils.isBlank(ruleCode)) {

--
Gitblit v1.9.1