From fee18a4910fe117f5f75780550fe3bd7c9d50fa1 Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 10 十二月 2025 14:34:03 +0800
Subject: [PATCH] #出库单

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java       |    4 
 src/main/webapp/static/js/order/order.js                          |    1 
 src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java     |  230 +++++++++++++++++++++++++++++++++++++-
 src/main/java/com/zy/asrs/entity/BasStationDetl.java              |    3 
 src/main/java/com/zy/asrs/controller/MobileController.java        |   12 ++
 src/main/java/com/zy/asrs/entity/param/CollectionPakinParams.java |   52 ++++++++
 src/main/java/com/zy/asrs/service/MobileService.java              |    4 
 7 files changed, 297 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/asrs/controller/MobileController.java b/src/main/java/com/zy/asrs/controller/MobileController.java
index a36dc7f..e3a2df6 100644
--- a/src/main/java/com/zy/asrs/controller/MobileController.java
+++ b/src/main/java/com/zy/asrs/controller/MobileController.java
@@ -60,6 +60,18 @@
     @Resource
     private StaDescService staDescService;
 
+    @PostMapping("/agv/collectionPakin/view")
+    @ManagerAuth
+    public R pdaAgvCollectionPakinView(@RequestBody CollectionPakinParams params){
+        return mobileService.collectionPakinView(params);
+    }
+
+    @PostMapping("/agv/collectionPakin/auth")
+    @ManagerAuth
+    public R pdaAgvCollectionPakin(@RequestBody CollectionPakinParams params){
+        return mobileService.collectionPakin(params, getUserId());
+    }
+
 
     @PostMapping("/agv/callEmptyCar")
     @ManagerAuth
diff --git a/src/main/java/com/zy/asrs/entity/BasStationDetl.java b/src/main/java/com/zy/asrs/entity/BasStationDetl.java
index b8be23d..d9a76b5 100644
--- a/src/main/java/com/zy/asrs/entity/BasStationDetl.java
+++ b/src/main/java/com/zy/asrs/entity/BasStationDetl.java
@@ -8,6 +8,8 @@
 import com.zy.system.entity.User;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+
+import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 import com.core.common.SpringUtils;
 import com.zy.system.service.UserService;
@@ -22,6 +24,7 @@
 
 @Data
 @TableName("agv_bas_station_detl")
+@Accessors(chain = true)
 public class BasStationDetl implements Serializable {
 
     private static final long serialVersionUID = 1L;
diff --git a/src/main/java/com/zy/asrs/entity/param/CollectionPakinParams.java b/src/main/java/com/zy/asrs/entity/param/CollectionPakinParams.java
new file mode 100644
index 0000000..0afddd6
--- /dev/null
+++ b/src/main/java/com/zy/asrs/entity/param/CollectionPakinParams.java
@@ -0,0 +1,52 @@
+package com.zy.asrs.entity.param;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class CollectionPakinParams {
+
+    private String orgBarcode;
+
+    private String tarBarcode;
+
+    private String devNo;
+
+    private List<CombMat> combMats;
+
+    @Data
+    public static class CombMat {
+
+        private String orderNo;
+
+        // 鐗╂枡缂栧彿
+        private String matnr = "";
+
+        // 搴忓垪鐮�
+        private String batch = "";
+        private String brand = "";
+        private String standby1 = "";
+        private String standby2 = "";
+        private String standby3 = "";
+
+        private String boxType1 = "1";
+        private String boxType2 = "1";
+        private String boxType3 = "1";
+
+        // 鐗╂枡鏁伴噺
+        private BigDecimal anfme;
+
+        // 鐗╂枡鏁伴噺
+        private BigDecimal workQty;
+
+        // 鍟嗗搧鍚嶇О
+        private String maktx;
+
+        // 瑙勬牸
+        private String specs;
+
+        private String threeCode;
+    }
+}
diff --git a/src/main/java/com/zy/asrs/service/MobileService.java b/src/main/java/com/zy/asrs/service/MobileService.java
index 47dccfe..bfb42a1 100644
--- a/src/main/java/com/zy/asrs/service/MobileService.java
+++ b/src/main/java/com/zy/asrs/service/MobileService.java
@@ -148,4 +148,8 @@
      * @date 2025/12/9 15:04
      */
     void combInPub(CompleteParam combParam, Long userId);
+
+    R collectionPakin(CollectionPakinParams params, Long userId);
+
+    R collectionPakinView(CollectionPakinParams params);
 }
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 0aac059..92b3351 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -1347,28 +1347,125 @@
     }
 
     @Override
-//    @Transactional(rollbackFor = Exception.class)
+    @Transactional(rollbackFor = Exception.class)
     public R collectionInCall(AgvCallParams params, Long userId) {
         if (Objects.isNull(params.getOrgSite())) {
             throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
-        }
-        List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", params.getBarcode()));
-        if (!tasks.isEmpty()) {
-            throw new CoolException("鎵樼洏鐮佸凡鐢熸垚浠诲姟");
         }
 
         BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
 
         List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
-                .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_D.type)
+                .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
                 .eq("area_id", basAreas.getId()));
         if (locCaches.isEmpty()) {
             throw new CoolException("褰撳墠鏆傛棤绌哄簱浣嶏紒锛�");
         }
 
-        generateAgvTask("agv", locCaches.get(0), params.getOrgSite(), params.getBarcode(), userId);
+        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getOrgSite()));
+        if (Objects.isNull(station)) {
+            throw new CoolException("婧愮珯鐐规湭妫�绱㈠埌鏁版嵁锛侊紒");
+        }
+
+        generateSOEOInTask("agv", locCaches.get(0), params.getOrgSite(), station.getBarcode(), userId);
 
         return R.ok();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void generateSOEOInTask(String type, LocCache loc, String orgSite, String barcode, Long userId) {
+        List<BasStationDetl> basStationDetls = basStationDetlService.selectList(new EntityWrapper<BasStationDetl>().eq("dev_no", orgSite));
+        if (Objects.isNull(basStationDetls) || basStationDetls.isEmpty()) {
+            throw new CoolException("绔欑偣淇℃伅涓嶅瓨鍦紒锛�");
+        }
+
+
+
+        List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", barcode));
+        if (!tasks.isEmpty()) {
+            throw new CoolException("鎵樼洏宸插湪浠诲姟鎵ц涓�..");
+        }
+        // 鑾峰彇宸ヤ綔鍙�
+        int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+        // 淇濆瓨宸ヤ綔妗�
+        Task task = new Task();
+        task.setWrkNo(workNo)
+                .setIoTime(new Date())
+                .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+                .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+                .setTaskType("agv")
+                .setIoPri(10D)
+                .setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
+                .setFullPlt("Y") // 婊℃澘锛歒
+                .setPicking("N") // 鎷f枡
+                .setExitMk("N")// 閫�鍑�
+                .setSourceStaNo(orgSite)
+                .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+                .setBarcode(barcode)// 鎵樼洏鐮�
+                .setLinkMis("N")
+                .setAppeUser(userId)
+                .setAppeTime(new Date())
+                .setModiUser(userId)
+                .setModiTime(new Date());
+        if (!taskService.insert(task)) {
+            throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+        }
+
+        for (BasStationDetl basStationDetl : basStationDetls) {
+            TaskDetl wrkDetl = new TaskDetl();
+            BeanUtils.copyProperties(basStationDetl, wrkDetl);
+            wrkDetl.setWrkNo(workNo)
+                    .setIoTime(new Date())
+                    .setOrderNo(basStationDetl.getOrderNo())
+                    .setAnfme(basStationDetl.getAnfme())
+                    .setZpallet(basStationDetl.getBarcode())
+                    .setBatch(basStationDetl.getBatch())
+                    .setMatnr(basStationDetl.getMatnr())
+                    .setMaktx(basStationDetl.getMaktx())
+                    .setStandby1(basStationDetl.getStandby1())
+                    .setAppeUser(userId)
+                    .setUnit(basStationDetl.getUnit())
+                    .setModel(basStationDetl.getModel())
+                    .setAppeTime(new Date())
+                    .setModiUser(userId);
+
+            //淇濆瓨宸ヤ綔妗f槑缁�
+            if (!taskDetlService.insert(wrkDetl)) {
+                throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+            }
+        }
+
+
+
+        // 淇敼鐩爣搴撲綅鐘舵��
+        if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+            loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
+            loc.setModiTime(new Date());
+            loc.setModiUser(userId);
+            if (!locCacheService.updateById(loc)) {
+                throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+            }
+        } else {
+            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
+        }
+
+        // 淇敼鐩爣绔欑偣淇℃伅
+        BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
+        if (Objects.isNull(station)) {
+            throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+        }
+
+        if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+            station.setLocSts("R"); // S.鍏ュ簱棰勭害
+            station.setBarcode(barcode);
+            station.setModiTime(new Date());
+            station.setModiUser(userId);
+            if (!basStationService.updateById(station)) {
+                throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+            }
+        } else {
+            throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+        }
     }
 
     /**
@@ -1581,6 +1678,125 @@
         generateCrnInTask(waitPakins, station, param.getLocType1(), userId);
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public R collectionPakin(CollectionPakinParams params, Long userId) {
+        List<BasStation> basStations = basStationService.selectList(new EntityWrapper<BasStation>().eq("barcode", params.getTarBarcode()));
+        if (basStations.isEmpty() && Cools.isEmpty(params.getDevNo())) {
+            throw new CoolException("璇疯緭鍏ョ珯鐐瑰彿");
+        }
+        BasStation basStation = null;
+        if (!basStations.isEmpty()) {
+            basStation =  basStations.get(0);
+        }else {
+            basStation = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", params.getDevNo()));
+        }
+        if (Cools.isEmpty(basStation)){
+            throw new CoolException("璇疯緭鍏ユ纭殑绔欑偣鍙�");
+        }
+        for (CollectionPakinParams.CombMat combMat : params.getCombMats()) {
+            if (combMat.getWorkQty().compareTo(BigDecimal.ZERO) == 0) {
+                continue;
+            }
+
+            OrderPakin orderPakin = orderPakinService.selectByNo(combMat.getOrderNo());
+            if (Cools.isEmpty(orderPakin)) {
+                throw new CoolException("鏈壘鍒板璐у叆搴撳崟");
+            }
+
+            UpdateDetailsOfPakin(orderPakin,combMat);
+
+            BasStationDetl basStationDetl = basStationDetlService.selectOne(new EntityWrapper<BasStationDetl>()
+                    .eq("dev_no", basStation.getDevNo())
+                    .eq("matnr", combMat.getMatnr())
+                    .eq("batch", combMat.getBatch())
+                    .eq("standby1", combMat.getStandby1())
+            );
+            if (Cools.isEmpty(basStationDetl)) {
+                basStationDetl = new BasStationDetl();
+                Mat mat = matService.selectByMatnr(combMat.getMatnr());
+                BeanUtils.copyProperties(mat,basStationDetl);
+                basStationDetl
+                        .setOrderNo(orderPakin.getOrderNo())
+                        .setDevNo(basStation.getDevNo())
+                        .setBarcode(params.getTarBarcode())
+                        .setBatch(combMat.getBatch())
+                        .setStandby1(combMat.getStandby1())
+                        .setAnfme(combMat.getWorkQty().doubleValue())
+                ;
+                if (!basStationDetlService.insert(basStationDetl)){
+                    throw new CoolException("鎻掑叆鏄庣粏澶辫触");
+                }
+                
+
+            }else {
+                BigDecimal anfme = new BigDecimal(basStationDetl.getAnfme().toString()).add(combMat.getWorkQty());
+                basStationDetl.setAnfme(anfme.doubleValue());
+                if (!basStationDetlService.updateById(basStationDetl)){
+                    throw new CoolException("鏇存柊鏄庣粏鏁版嵁澶辫触");
+                }
+
+            }
+        }
+        if (basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_D.type) || basStation.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+            basStation.setBarcode(params.getTarBarcode());
+            basStation.setLocSts(LocStsType.LOC_STS_TYPE_F.type);
+            basStationService.updateById(basStation);
+        }
+
+        return R.ok();
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public void UpdateDetailsOfPakin(OrderPakin orderPakin,CollectionPakinParams.CombMat combMat){
+        OrderDetlPakin orderDetlPakin = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>()
+                .eq("order_id", orderPakin.getId())
+                .eq("matnr", combMat.getMatnr())
+                .eq("batch", combMat.getBatch())
+                .eq("standby1", combMat.getStandby1())
+        );
+        if (Cools.isEmpty(orderDetlPakin)) {
+            throw new CoolException("妫�绱㈠崟鎹槑缁嗘暟鎹け璐�");
+        }
+        if (orderDetlPakin.getWorkQty() >= orderDetlPakin.getAnfme()) {
+            throw new CoolException("璇峰嬁瓒呭嚭璁㈠崟鏄庣粏鏁伴噺");
+        }
+        BigDecimal workQty = new BigDecimal(orderDetlPakin.getWorkQty().toString()).add(combMat.getWorkQty());
+        orderDetlPakin.setWorkQty(workQty.doubleValue());
+        if (!orderDetlPakinService.updateById(orderDetlPakin)){
+            throw new CoolException("鏇存柊鍗曟嵁鏄庣粏鏁版嵁澶辫触");
+        }
+        if (!orderPakin.getSettle().equals(2L)){
+            orderPakin.setSettle(2L);
+            if (!orderPakinService.updateById(orderPakin)){
+                throw new CoolException("鏇存柊鍗曟嵁鐘舵�佸け璐�");
+            }
+        }
+
+
+    }
+
+    @Override
+    public R collectionPakinView(CollectionPakinParams params) {
+
+        WrkMast wrkMast = wrkMastService.selectByBarcode(params.getOrgBarcode());
+        if (Cools.isEmpty(wrkMast)) {
+            throw new CoolException("鏈壘鍒颁换鍔�");
+        }
+
+        if (wrkMast.getIoType().equals(TaskIOType.ALL_OUT.type) && wrkMast.getIoType().equals(TaskIOType.PICK_OUT.type)){
+            throw new CoolException("浜虹墿绫诲瀷閿欒");
+        }
+
+        List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo());
+        if (Cools.isEmpty(wrkDetls)) {
+            throw new CoolException("鏈壘鍒颁换鍔℃槑缁�");
+        }
+
+
+        return R.ok(wrkDetls);
+    }
+
     /**
      * 鐢熸垚鍫嗗灈鏈哄叆搴撲换鍔�
      *
diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
index 4659d70..ca9d398 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -410,8 +410,8 @@
         // 鍒ゆ柇鏄惁鏄洏鐐瑰崟
         String orderNo = taskDto.getLocDtos().get(0).getOrderNo();
 //        OrderPakout orderPakout = orderPakOutService.selectByNo(orderNo);
-        CheckOrder checkOrder = checkOrderService.selectOne(new EntityWrapper<CheckOrder>().eq("order_no", orderNo));
-        int ioType = checkOrder.getDocType() == 8 ? 107 : (taskDto.isAll() ? 101 : 103);
+
+        int ioType =  (taskDto.isAll() ? 101 : 103);
         if(ioType == 101){
             boolean DiffQty = taskDto.getLocDtos().stream().allMatch(locDto ->
                     locDetlService.selectOne(new EntityWrapper<LocDetl>()
diff --git a/src/main/webapp/static/js/order/order.js b/src/main/webapp/static/js/order/order.js
index 940bfa4..0d083ce 100644
--- a/src/main/webapp/static/js/order/order.js
+++ b/src/main/webapp/static/js/order/order.js
@@ -228,6 +228,7 @@
                         {type: 'numbers', title: '#'},
                         {field: 'matnr', title: '鍟嗗搧缂栫爜', width: 160},
                         {field: 'maktx', title: '鍟嗗搧鍚嶇О', width: 200},
+                        {field: 'standby1', title: '渚涘簲鍟嗕唬鐮�', edit: true},
                         {field: 'batch', title: '鎵瑰彿', edit: true},
                         {field: 'specs', title: '瑙勬牸'},
                         {field: 'anfme', title: '鏁伴噺(淇敼)', style: 'color: blue;font-weight: bold', edit: true, minWidth: 110, width: 110},

--
Gitblit v1.9.1