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/MobileServiceImpl.java |  230 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 223 insertions(+), 7 deletions(-)

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);
+    }
+
     /**
      * 鐢熸垚鍫嗗灈鏈哄叆搴撲换鍔�
      *

--
Gitblit v1.9.1