From 05b6ccedbd294ad536fe86b49e10d6825284fb65 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期四, 12 九月 2024 11:14:47 +0800
Subject: [PATCH] #

---
 zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java |   86 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
index d512408..057e514 100644
--- a/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
+++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/wms/service/impl/MobileServiceImpl.java
@@ -99,6 +99,8 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setFullPlt(param.getFullPlt());
+                waitPakin.setOwner(param.getOwner());
                 if (!waitPakinService.save(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
@@ -155,6 +157,7 @@
                 waitPakin.setAppeTime(now);
                 waitPakin.setModiUser(userId);
                 waitPakin.setModiTime(now);
+                waitPakin.setOwner(param.getOwner());
                 if (!waitPakinService.save(waitPakin)) {
                     throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
                 }
@@ -245,7 +248,7 @@
     @Transactional
     public R WarehouseIn(String locNo, String barcode,Long hostId) {
         //鍒ゆ柇搴撲綅鐘舵��
-        LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, locNo).eq(LocMast::getHostId,hostId));
+        LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, locNo).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,1L));
         if (Cools.isEmpty(locMast)){
             return R.error("璇ュ簱浣嶄笉瀛樺湪");
         }
@@ -314,7 +317,7 @@
     @Transactional
     public R WarehouseOut(CombParam combParam, Long hostId) {
         //鍒ゆ柇搴撲綅鐘舵��
-        LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId));
+        LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,1L));
         if (Cools.isEmpty(locMast)){
             return R.error("璇ュ簱浣嶄笉瀛樺湪");
         }
@@ -389,4 +392,83 @@
 
         return R.ok();
     }
+
+    @Override
+    @Transactional
+    public R WarehouseOutV1(CombParam combParam, Long hostId) {
+        //鍒ゆ柇搴撲綅鐘舵��
+        LocMast locMast = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId,hostId).eq(LocMast::getWhsType,0L));
+        if (Cools.isEmpty(locMast)){
+            return R.error("璇ュ簱浣嶄笉瀛樺湪");
+        }
+        if (!locMast.getLocSts().equals("P")){
+            return R.error("璇ュ簱浣嶇姸鎬佷负锛�"+locMast.getLocSts()+",涓嶆弧瓒冲苟鏉块�斾腑鎷i�夋潯浠讹紒锛侊紒");
+        }
+        //鏌ヨ搴撳瓨鏁版嵁
+        for (CombParam.CombMat combMat :combParam.getCombMats()){
+            List<LocDetl> locDetlList = locDetlService.list(new LambdaQueryWrapper<LocDetl>()
+                    .eq(LocDetl::getLocNo, combParam.getLocno())
+                    .eq(LocDetl::getHostId, hostId)
+//                    .eq(LocDetl::getZpallet, combMat.getZpallet())
+                    .eq(LocDetl::getMatnr, combMat.getMatnr())
+//                    .eq(LocDetl::getBatch, combMat.getBatch())
+            );
+            if (locDetlList.isEmpty()){
+                return R.error("鏈煡璇㈠埌搴撳瓨鏁版嵁");
+            }
+            if (locDetlList.size()>1){
+                return R.error("搴撳瓨鏁版嵁澶т簬1鏉★紝涓轰繚璇佹暟鎹噯纭�э紝璇风敤姝e父娴佺▼鍑哄簱锛侊紒锛�");
+            }
+            LocDetl locDetl = locDetlList.get(0);
+            if (combMat.getAnfme() > locDetl.getAnfme()){
+                return R.error("鎷i�夋暟閲忛敊璇紝瓒呭嚭搴撳瓨鏁伴噺");
+            }
+            if (!Cools.isEmpty(combParam.getOrderNo())){
+                Order order = orderService.selectByNo(combParam.getOrderNo(), hostId);
+                if (Cools.isEmpty(order)){
+                    continue;
+                }
+                if (order.getSettle() == 1){
+                    orderService.updateSettle(order.getId(), 2L, 9527L, hostId);
+                }
+                OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(),hostId);
+                if (Cools.isEmpty(orderDetl)){
+                    continue;
+                }
+                if (orderDetl.getAnfme() < (orderDetl.getWorkQty()+combMat.getAnfme())){
+                    throw new CoolException("鎷i�夋暟閲忓嚭閿�,璁㈠崟鍓╀綑鍑哄簱鏁伴噺灏忎簬宸插嚭搴撴暟閲忎笌灏嗘嫞閫夋暟閲忎箣鍜岋紒锛侊紒");
+                }
+                // 淇敼璁㈠崟鏄庣粏浣滀笟鏁伴噺
+                if (!orderDetlService.increaseWorkQtyByOrderNo(combParam.getOrderNo(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), hostId)) {
+                    throw new CoolException("淇敼鍗曟嵁鏄庣粏宸ヤ綔鏁伴噺澶辫触");
+                }
+                // 淇敼璁㈠崟鏄庣粏瀹屾垚鏁伴噺
+                if (!orderDetlService.increase(order.getId(), hostId, combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) {
+                    throw new CoolException("淇敼鍗曟嵁鏄庣粏瀹屾垚鏁伴噺澶辫触");
+                }
+                // 淇敼璁㈠崟鐘舵�� 浣滀笟涓� ===>> 宸插畬鎴�
+                orderService.checkComplete(combParam.getOrderNo(), hostId);
+            }
+            try {
+                //澶勭悊搴撳瓨淇℃伅
+                if (combMat.getAnfme().equals(locDetl.getAnfme())){
+                    //搴撳瓨鐩哥瓑鍒犻櫎鏁版嵁
+                    locDetlService.removeById(locDetl);
+                    int count = locDetlService.count(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo,combParam.getLocno()).eq(LocDetl::getHostId, hostId));
+                    if (count == 0){
+                        LocMast locMast1 = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, combParam.getLocno()).eq(LocMast::getHostId, hostId));
+                        locMast1.setLocSts("O");
+                        locMastService.updateById(locMast1);
+                    }
+                } else {
+                    BigDecimal subtract = BigDecimal.valueOf(locDetl.getAnfme()).subtract(BigDecimal.valueOf(combMat.getAnfme()));
+                    locDetl.setAnfme(subtract.doubleValue());
+                    locDetlService.updateById(locDetl);
+                }
+            }catch (Exception e){
+                throw new CoolException("鏇存柊搴撳瓨鏁版嵁鍑洪敊"+e.getMessage());
+            }
+        }
+        return R.ok();
+    }
 }

--
Gitblit v1.9.1