From e046dba174365eb8934ee1e4206f09821145e876 Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 21 八月 2025 13:23:22 +0800
Subject: [PATCH] no message

---
 zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 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 e5d13a7..c1aacdc 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
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.mysql.cj.util.StringUtils;
 import com.zy.asrs.wms.asrs.entity.param.StockOutParam;
 import com.zy.asrs.framework.exception.CoolException;
@@ -532,6 +533,12 @@
         return mergePreviewDtos;
     }
 
+    /**
+     * 娉㈡鍑哄簱棰勮
+     *
+     * @param param
+     * @return
+     */
     @Transactional(rollbackFor = Exception.class)
     public List<MergePreviewResultDto> orderOutMergeLocPreview(List<MergePreviewDto> param) {
         if (param == null) {
@@ -567,7 +574,7 @@
             //鏌ヨ骞冲簱涓鍚堟潯浠剁殑搴撳瓨
             List<LocDetl> locs = locDetlService.queryFlatStock(pars.getMatnr(), pars.getBatch(), pars.getFieldParams());
             if (!locs.isEmpty()) {
-                double anfme = pars.getAnfme() - pars.getWorkQty();
+                Double anfme = pars.getAnfme() - pars.getWorkQty();
                 for (LocDetl detl : locs) {
                     Loc loc = locService.getById(detl.getLocId());
                     if (loc == null) {
@@ -582,7 +589,7 @@
                     locDto.setLocNo(detl.getLocNo());
                     locDto.setTypeId(LocAreaTypeSts.LOC_AREA_TYPE_FLAT.id);
                     locDto.setLocDetlId(detl.getId());
-                    locDto.setAnfme(detl.getAnfme());
+                    locDto.setAnfme(detl.getAnfme() - detl.getWorkQty());
                     locDto.setWorkQty(detl.getWorkQty());
                     locDtos.add(locDto);
                     //搴撲綅瀹為檯鍙敤鏁伴噺
@@ -591,8 +598,8 @@
                         continue;
                     }
                     //娉㈡鏁伴噺鍑忓幓搴撲綅鍙敤鏁伴噺鍚庯紝鐩堜綑鏁伴噺
-                    anfme = anfme - surplusQty;
-                    if (anfme > 0) {
+                    anfme = Math.round((anfme - surplusQty) * 10000) / 10000.0;
+                    if (anfme.compareTo(0.0) > 0) {
                         //褰撳墠鍙娇鐢ㄦ暟閲�
                         resultDto.setFetchQty(surplusQty);
                         //浣欎笅闇�姹傛暟閲�
@@ -1021,9 +1028,10 @@
      * 鏍规嵁涓嶅悓搴撲綅绫诲瀷鐢熸垚鍑哄簱鎷h揣鍗曟垨CTU浠诲姟妗�
      *
      * @param dto
-     * @param wave
+     * @param
      */
-    private void outStockByArea(OrderOutMergeParamDto dto, Wave wave) {
+    @Transactional(rollbackFor = Exception.class)
+    public void outStockByArea(OrderOutMergeParamDto dto, Wave wave) {
         List<OrderOutMergeParam> params = dto.getList();
         if (params.isEmpty()) {
             throw new CoolException("鍙傛暟涓嶈兘涓虹┖");
@@ -1103,6 +1111,11 @@
                 throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
             }
 
+            wave.setSite(operationPort.getFlag());
+            if (!waveService.updateById(wave)) {
+                throw new CoolException("娉㈡绔欏彛鐘舵�佹洿鏂板け璐ワ紒锛�");
+            }
+
             for (OrderOutMergeDto merge : list) {
                 LocDetl locDetl = locDetlService.getById(merge.getLocDetlId());
                 if (locDetl == null) {
@@ -1137,9 +1150,12 @@
                 }
 
                 String matUniqueKey = Utils.getMatUniqueKey(taskDetl.getMatnr(), taskDetl.getBatch(), taskDetl.getUniqueField());
-                WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getStockIndex, matUniqueKey).eq(WaveDetl::getWaveId, wave.getId()));
+                logger.error("Matnr------>{}", taskDetl.getMatnr());
+                WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>()
+                        .eq(WaveDetl::getStockIndex, matUniqueKey)
+                        .eq(WaveDetl::getWaveId, wave.getId()));
                 if (waveDetl == null) {
-                    throw new CoolException("娉㈡鏁版嵁涓嶅瓨鍦�");
+                    throw new CoolException("waveId:" + wave.getId() + "鐗╂枡锛�" + taskDetl.getMatnr() + "娉㈡鏁版嵁涓嶅瓨鍦�");
                 }
                 waveDetl.setWorkQty(waveDetl.getWorkQty() + taskDetl.getAnfme());
                 waveDetl.setUpdateTime(new Date());
@@ -1152,6 +1168,7 @@
             if (orders.isEmpty()) {
                 throw new CoolException("褰撳墠娉㈡璁㈠崟涓嶅瓨鍦紒锛�");
             }
+
 
 //            List<CacheSite> cacheSites = cacheSiteService.list(new LambdaQueryWrapper<CacheSite>()
 //                    .eq(CacheSite::getSiteStatus, CacheSiteStatusType.O.id).eq(CacheSite::getChannel, task.getTargetSite()));
@@ -1262,6 +1279,12 @@
                 if (!locDetlService.updateById(locDetl)) {
                     throw new CoolException("搴撳瓨鍔犻攣澶辫触锛侊紒");
                 }
+
+                orderDetlService.update(new LambdaUpdateWrapper<OrderDetl>()
+                                .set(OrderDetl::getWareType, 2)
+                        .eq(OrderDetl::getMatId, mat.getId())
+                        .eq(StringUtils.isNullOrEmpty(outOder.getBatch()), OrderDetl::getBatch, outOder.getBatch())
+                        .in(OrderDetl::getOrderId, outOder.getOrderIds()));
             });
 
             curLoc.setLocStsId(LocStsType.R.val());
@@ -1629,7 +1652,10 @@
 
         for (LocDetl locDetl : param.getLocDetls()) {
             List<OrderOutMergeParam> orders = new ArrayList<>();
-            LocDetl detl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locDetl.getLocNo()));
+            LocDetl detl = locDetlService.getOne(new LambdaQueryWrapper<LocDetl>()
+                    .eq(LocDetl::getMatId, locDetl.getMatId())
+                    .eq(LocDetl::getBatch, locDetl.getBatch())
+                    .eq(LocDetl::getLocNo, locDetl.getLocNo()));
             if (Objects.isNull(detl)) {
                 continue;
             }

--
Gitblit v1.9.1