From 6e18b1e086f202512eeb9aa988a8b9026cfccec3 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期六, 28 三月 2026 20:28:27 +0800
Subject: [PATCH] 修复

---
 src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java |   67 ++++++++++++++++++++++-----------
 1 files changed, 45 insertions(+), 22 deletions(-)

diff --git a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
index 5a84f79..805b2db 100644
--- a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
@@ -207,23 +207,25 @@
                         wrkMastService.updateById(wrkMast);
                         //鍑哄簱涓烘満鍙板伐浣嶆椂锛屽喕缁撶浉瀵规湁鐨勫簱浣�,鍙婄浉閭诲簱浣�
                         String s = Utils.convertLocFormat(params.getLocNo());
-                        LocAroundBind bind = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>()
-                                .eq("b_loc_no", s));
-                        if (!Objects.isNull(bind)) {
-                            bind.setFreeze(1);
-                            locAroundBindService.updateById(bind);
-                            //鍐荤粨鐩搁偦搴撲綅
-                            Integer[] aroundIds = freezeLocAround(bind.getOrderNo());
-                            if (aroundIds != null) {
-                                for (Integer id : aroundIds) {
-                                    if (id != null && id > 0) {
-                                        LocAroundBind aroundBind = locAroundBindService.selectOne(
-                                                new EntityWrapper<LocAroundBind>()
-                                                        .eq("dev_id", bind.getDevId())
-                                                        .eq("order_no", id));
-                                        if (aroundBind != null) {
-                                            aroundBind.setFreeze(1);
-                                            locAroundBindService.updateById(aroundBind);
+                        if(Cools.isEmpty(wrkMast.getLocNo())){
+                            LocAroundBind bind = locAroundBindService.selectOne(new EntityWrapper<LocAroundBind>()
+                                    .eq("b_loc_no", s));
+                            if (!Objects.isNull(bind)) {
+                                bind.setFreeze(1);
+                                locAroundBindService.updateById(bind);
+                                //鍐荤粨鐩搁偦搴撲綅
+                                Integer[] aroundIds = freezeLocAround(bind.getOrderNo());
+                                if (aroundIds != null) {
+                                    for (Integer id : aroundIds) {
+                                        if (id != null && id > 0) {
+                                            LocAroundBind aroundBind = locAroundBindService.selectOne(
+                                                    new EntityWrapper<LocAroundBind>()
+                                                            .eq("dev_id", bind.getDevId())
+                                                            .eq("order_no", id));
+                                            if (aroundBind != null) {
+                                                aroundBind.setFreeze(1);
+                                                locAroundBindService.updateById(aroundBind);
+                                            }
                                         }
                                     }
                                 }
@@ -322,10 +324,25 @@
                         LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>()
                                 .eq("zpallet", mast.getBarcode())
                                 .eq("loc_no", mast.getSourceLocNo()));
-                        if (Objects.isNull(locDetl)) {
+                        WrkDetl mainWrkDetl = null;
+                        if (Objects.isNull(locDetl) && !Cools.isEmpty(mast.getWrkCode())) {
+                            mainWrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>()
+                                    .eq("wrk_no", mast.getWrkCode())
+                                    .eq("zpallet", mast.getBarcode()));
+                            if (Objects.isNull(mainWrkDetl)) {
+                                mainWrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>()
+                                        .eq("wrk_no", mast.getWrkCode()));
+                            }
+                            if (!Objects.isNull(mainWrkDetl)) {
+                                log.info("locDetl涓虹┖锛屽洖閫�鏌ヨ涓讳换鍔℃槑缁嗭紝wrkNo={}, mainWrkNo={}, barcode={}",
+                                        mast.getWrkNo(), mast.getWrkCode(), mast.getBarcode());
+                            }
+                        }
+                        if (Objects.isNull(locDetl) && Objects.isNull(mainWrkDetl)) {
                             throw new CoolException("鏄庣粏鏁版嵁涓嶅瓨鍦紒锛�");
                         }
-                        Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", locDetl.getMatnr()));
+                        String matnrNo = Objects.isNull(locDetl) ? mainWrkDetl.getMatnr() : locDetl.getMatnr();
+                        Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnrNo));
                         if (Objects.isNull(matnr)) {
                             throw new CoolException("鐗╂枡鍩虹淇℃伅涓嶅瓨鍦紒锛�");
                         }
@@ -333,9 +350,15 @@
                             Double val = Math.round((weight - matnr.getSafeQty()) * 10000) / 10000.0;
                             if (val.compareTo(0.0) > 0) {
                                 WrkDetl wrkDetl = new WrkDetl();
-                                BeanUtils.copyProperties(locDetl, wrkDetl);
+                                if (Objects.isNull(locDetl)) {
+                                    BeanUtils.copyProperties(mainWrkDetl, wrkDetl);
+                                    wrkDetl.setStockQty(Cools.isEmpty(mainWrkDetl.getStockQty()) ? mainWrkDetl.getAnfme() : mainWrkDetl.getStockQty());
+                                    wrkDetl.setZpallet(mast.getBarcode());
+                                } else {
+                                    BeanUtils.copyProperties(locDetl, wrkDetl);
+                                    wrkDetl.setStockQty(locDetl.getAnfme());
+                                }
                                 wrkDetl.setWrkNo(mast.getWrkNo());
-                                wrkDetl.setStockQty(locDetl.getAnfme());
                                 wrkDetl.setIoTime(new Date());
                                 wrkDetl.setWeight(weight);
                                 wrkDetl.setIoTime(mast.getIoTime());
@@ -401,7 +424,7 @@
                         }
                         Double realQty = Math.round((wrkDetl.getStockQty() - wrkDetl.getAnfme()) * 10000) / 10000.0;
                         if (!Cools.isEmpty(weight)) {
-                            Double val = Math.round((weight - 3) * 10000) / 10000.0;
+                            Double val = Math.round((weight - 2.5) * 10000) / 10000.0;
                             //绉伴噸鍚庯紝璁$畻鍑虹湡瀹為暱搴�
                             realQty = val * matnr.getVolume();
                             if (realQty<matnr.getSafeQty()){

--
Gitblit v1.9.1