From 2450c236d78bc1c16c207904289e3ad5506a5581 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期六, 07 九月 2024 15:29:09 +0800
Subject: [PATCH] #

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java
index 295462d..faa4b8d 100644
--- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java
+++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java
@@ -370,6 +370,7 @@
 
                 TaskDetl taskDetl = new TaskDetl();
                 taskDetl.sync(locDetl);
+                taskDetl.setId(null);
                 taskDetl.setTaskId(task.getId());
                 taskDetl.setAnfme(dto.getAnfme());
                 taskDetl.setStock(locDetl.getAnfme());
@@ -384,6 +385,7 @@
                 for (LocDetlField locDetlField : locDetlFields) {
                     TaskDetlField taskDetlField = new TaskDetlField();
                     taskDetlField.sync(locDetlField);
+                    taskDetlField.setId(null);
                     taskDetlField.setDetlId(taskDetl.getId());
                     boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
                     if(!taskDetlFieldSave){
@@ -588,6 +590,7 @@
 
             List<OrderDetl> orderDetlList = detlMap.get(matUniqueKey);
             for (OrderDetl orderDetl : orderDetlList) {
+                orderDetl = orderDetlService.getById(orderDetl);
                 double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty() - orderDetl.getWorkQty()).orElse(0.0D);
                 if (issued <= 0D) {
                     continue;
@@ -597,19 +600,18 @@
                 orderOutMergeDto.sync(param);
                 orderOutMergeDto.setOrderDetlId(orderDetl.getId());
 
-                Double anfme = orderDetl.getAnfme();
                 Double updateWorkQty = null;
 
-                double diffAnfme = requireAnfme - anfme;
-                if (diffAnfme >= 0) {
-                    orderOutMergeDto.setAnfme(anfme);
-                    updateWorkQty = anfme;
-                    requireAnfme -= anfme;
+                if (requireAnfme > issued) {
+                    orderOutMergeDto.setAnfme(issued);
+                    updateWorkQty = issued;
+                    requireAnfme -= issued;
                 }else {
                     orderOutMergeDto.setAnfme(requireAnfme);
                     updateWorkQty = requireAnfme;
                     requireAnfme -= requireAnfme;
                 }
+
                 orderOutMergeDtos.add(orderOutMergeDto);
 
                 orderUtils.updateWorkQty(orderDetl.getId(), updateWorkQty);
@@ -680,6 +682,7 @@
 
                 TaskDetl taskDetl = new TaskDetl();
                 taskDetl.sync(locDetl);
+                taskDetl.setId(null);
                 taskDetl.setTaskId(task.getId());
                 taskDetl.setAnfme(merge.getAnfme());
                 taskDetl.setStock(locDetl.getAnfme());
@@ -694,6 +697,7 @@
                 for (LocDetlField locDetlField : locDetlFields) {
                     TaskDetlField taskDetlField = new TaskDetlField();
                     taskDetlField.sync(locDetlField);
+                    taskDetlField.setId(null);
                     taskDetlField.setDetlId(taskDetl.getId());
                     boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
                     if(!taskDetlFieldSave){

--
Gitblit v1.9.1