From a412fb692f1ff4a5b18e64ac1bdb5788fd55d4d0 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期四, 15 一月 2026 15:05:59 +0800
Subject: [PATCH] no message

---
 src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java |   54 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 20 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 50e3947..7bbff68 100644
--- a/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
+++ b/src/main/java/com/zy/api/service/impl/WcsApiServiceImpl.java
@@ -8,10 +8,10 @@
 import com.zy.api.controller.params.ReceviceTaskParams;
 import com.zy.api.controller.params.WorkTaskParams;
 import com.zy.api.service.WcsApiService;
-import com.zy.asrs.entity.BasDevice;
-import com.zy.asrs.entity.LocAroundBind;
-import com.zy.asrs.entity.WrkMast;
+import com.zy.asrs.entity.*;
 import com.zy.asrs.service.*;
+import com.zy.asrs.service.impl.MatServiceImpl;
+import com.zy.asrs.service.impl.WrkDetlServiceImpl;
 import com.zy.common.constant.MesConstant;
 import com.zy.common.utils.HttpHandler;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +37,10 @@
     private WrkMastService wrkMastService;
     @Autowired
     private WorkService workService;
+    @Autowired
+    private WrkDetlService wrkDetlService;
+    @Autowired
+    private MatService matService;
 
     /**
      * 閫氱煡WCS閿佸畾搴撲綅锛屽強绂佹褰撳墠搴撲綅鐨勪竴鍒囨搷浣�
@@ -187,20 +191,17 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R receviceTaskFromWcs(ReceviceTaskParams params) {
-        if (Objects.isNull(params.getDevice())) {
-            throw new CoolException("璁惧鍙蜂笉鑳戒负绌猴紒锛�");
-        }
         if (Objects.isNull(params.getWrkNo())) {
             throw new CoolException("WMS浠诲姟鍙蜂笉鑳戒负绌猴紒锛�");
         }
-        if (Objects.isNull(params.getMsgType())) {
+        if (Objects.isNull(params.getNotifyType())) {
             throw new CoolException("鍔ㄤ綔绫诲瀷涓嶈兘涓虹┖锛侊紒");
         }
         WrkMast mast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", params.getWrkNo()));
         if (Objects.isNull(mast)) {
             throw new CoolException("浠诲姟妗d笉瀛樺湪锛侊紒");
         }
-        if (!Objects.isNull(params.getMsgType()) && params.getMsgType().equals("task")) {
+        if ( params.getNotifyType().equals("task")) {
             //浠诲姟
             if (params.getMsgType().equals("task_complete")) {
                 mast.setWrkSts(4L);
@@ -210,20 +211,33 @@
             } else if (params.getMsgType().equals("task_cancel")){
 
             }
-        } else if (Objects.isNull(params.getMsgType()) && params.getMsgType().equals("weight")) {
+        } else if (params.getNotifyType().equals("weight")) {
             //绉伴噸
-
-
+            if (mast.getWrkSts() == 2) {
+                WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", mast.getWrkNo()));
+                if (Objects.isNull(wrkDetl)) {
+                    throw new CoolException("鏁版嵁閿欒锛屼换鍔℃槑缁嗕笉瀛樺湪锛侊紒");
+                }
+                Mat matnr = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", wrkDetl.getMatnr()));
+                if (Objects.isNull(matnr)) {
+                    throw new CoolException("鐗╂枡鍩虹淇℃伅涓嶅瓨鍦紒锛�");
+                }
+                Double val = Math.round((params.getWeight() - matnr.getSafeQty()) * 10000) / 10000.0;
+                if (val.compareTo(0.0) > 0) {
+                    //浣欐枡闀垮害
+                    wrkDetl.setRealQty(val * matnr.getVolume());
+                } else {
+                    //绌烘澘
+                    wrkDetl.setRealQty(0.0);
+                }
+                wrkDetl.setWeight(params.getWeight());
+                if (!wrkDetlService.update(wrkDetl, new EntityWrapper<WrkDetl>().eq("wrk_no", mast.getWrkNo()).eq("matnr", wrkDetl.getMatnr()).eq("barcode", wrkDetl.getBarcode()))) {
+                    throw new CoolException("浠诲姟妗f槑缁嗕慨鏀瑰け璐ワ紒锛�");
+                }
+            } else {
+                throw new CoolException("鏁版嵁閿欒锛屽綋鍓嶄换鍔$姸鎬佹湁璇� 锛�");
+            }
         }
-
-
-
-
-
-//       if (!wrkMastService.updateById(mast)) {
-//           throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
-//       }
-
         return R.ok();
     }
 }

--
Gitblit v1.9.1