From af1722ee7ded25e74e5f2afaf212ab856c942d77 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 27 十一月 2025 09:51:02 +0800
Subject: [PATCH] 解决冲突

---
 rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java |   71 +++++++++++++++++++++--------------
 1 files changed, 42 insertions(+), 29 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 36f6740..19c1476 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
@@ -309,6 +309,9 @@
         waitPakins.forEach(pakin -> {
             BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
                     .eq(BasContainer::getCode, pakin.getBarcode()));
+            if (Objects.isNull(container)) {
+                throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
+            }
             /**鑾峰彇搴撲綅*/
             String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
             if (Cools.isEmpty(targetLoc)) {
@@ -683,10 +686,9 @@
         if (Objects.isNull(loc)) {
             throw new CoolException("搴撳瓨涓嶅瓨鍦紒锛�");
         }
-        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
-            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
-        }
-
+//        if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
+//            throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
+//        }
         loc.setUseStatus(LocStsType.LOC_STS_TYPE_F.type)
                 .setBarcode(task.getBarcode())
                 .setUpdateBy(loginUserId).setUpdateTime(new Date());
@@ -705,10 +707,11 @@
             LocItem locItem = new LocItem();
             LocItemWorking locWorking = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>()
                     .eq(LocItemWorking::getTaskId, taskItem.getTaskId())
-                    .eq(StringUtils.isNotBlank(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
+                    .eq(LocItemWorking::getFieldsIndex, taskItem.getFieldsIndex())
+                    .eq(StringUtils.isNotEmpty(taskItem.getBatch()), LocItemWorking::getBatch, taskItem.getBatch())
                     .eq(LocItemWorking::getMatnrId, taskItem.getMatnrId()));
             if (Objects.isNull(locWorking)) {
-                throw new CoolException("鏁版嵁閿欒锛屼綔涓氫腑搴撳瓨鏁版嵁涓㈠け锛侊紒");
+               continue;
             }
             if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
                 locWorking.setAnfme(taskItem.getAnfme());
@@ -1016,12 +1019,12 @@
 
         tempLocs.forEach(working -> {
             taskItems.forEach(taskItem -> {
-                if (taskItem.getMatnrId().equals(working.getMatnrId())) {
+                if (taskItem.getFieldsIndex().equals(working.getFieldsIndex())) {
                     Double minQty = taskItem.getAnfme();
                     if (!task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)) {
-                        minQty = Math.round((working.getAnfme() - taskItem.getAnfme()) * 100) / 100.0;
+                        minQty = Math.round((working.getAnfme() - taskItem.getQty()) * 100) / 100.0;
                     }
-                    if (minQty.compareTo(0.0) > 0) {
+                    if (minQty.compareTo(0.0) >= 0) {
                         taskItem.setAnfme(minQty);
                         if (!taskItemService.updateById(taskItem)) {
                             throw new CoolException("浠诲姟鏄庣粏淇敼澶辫触锛侊紒");
@@ -1047,6 +1050,7 @@
                     .setMatnrCode(working.getMatnrCode())
                     .setSpec(working.getSpec())
                     .setAnfme(working.getAnfme())
+                    .setQty(0.0)
                     .setBatch(working.getBatch())
                     .setFieldsIndex(working.getFieldsIndex())
                     .setUnit(working.getUnit())
@@ -1071,6 +1075,7 @@
                 LocItemWorking itemWorking = new LocItemWorking();
                 BeanUtils.copyProperties(taskItem, itemWorking);
                 itemWorking.setTaskId(task.getId())
+                        .setQty(0.0)
                         .setLocId(loc1.getId())
                         .setLocCode(loc1.getCode());
                 workings.add(itemWorking);
@@ -1205,28 +1210,36 @@
             throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
         }
 
-        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
-            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("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
-            }
-        } else {
-            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("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
-            }
-            //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
-            if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
-                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.WAVE_SEED.id))) {
+            throw new CoolException("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
         }
 
+//        if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) {
+//            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("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+//            }
+//        } else {
+//            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("搴撳瓨鐘舵�佹洿鏂板け璐ワ紒锛�");
+//            }
+////            //鍏ㄦ澘鍑哄簱锛屽垹闄や复鏃跺簱瀛�
+////            if (!locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId()))) {
+////                throw new CoolException("涓存椂搴撳瓨娓呴櫎澶辫触锛侊紒");
+////            }
+//        }
+
     }
 
     /**

--
Gitblit v1.9.1