From caa7a2327123cc070ae16ad802983c04e296ff11 Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期三, 04 二月 2026 13:46:00 +0800
Subject: [PATCH] #1。档案同步2,任务状态上报,3设备状态读取,4心跳,5wms手动完成取消任务

---
 src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java |  190 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 159 insertions(+), 31 deletions(-)

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 2cfd50a..983ae44 100644
--- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -98,6 +98,13 @@
     @Resource
     private OrderPakoutService orderPakOutService;
 
+    @Resource
+    private BasAgvLocDetlService basAgvLocDetlService;
+
+    @Resource
+    private BasAgvWrkDetlService basAgvWrkDetlService;
+    private OpenService openService;
+
     @Override
     @Transactional
     public String startupFullPutStore(FullStoreParam param, Long userId) {
@@ -113,7 +120,12 @@
 //        List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList());
 //        List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList());
         FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(param.getList().get(0));
-        StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto);
+        StartupDto dto = null;
+        try{
+            dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto);
+        } catch (Exception e){
+            throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆�"+e.getMessage());
+        }
         if (Cools.isEmpty(dto)){
             throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆媠tartupFullPutStore ==銆� commonService.getLocNo");
         }
@@ -311,14 +323,7 @@
                 dtos.add(new OutLocDto(locNo, locDetlDto));
             }
         }
-        Config config = configService.selectConfigByCode("AutoMPArea");
-
-        List<LocMast> list = locMastMapper.selectList(
-                new EntityWrapper<LocMast>()
-                        .eq("whs_type", 5)
-                        .eq("loc_sts", "O")
-        );
-        LocMast locMastRgv = list.isEmpty() ? null : list.get(0);
+        Config configAutoMPArea = configService.selectConfigByCode("AutoMPArea");
 
         Integer ioType = null;
         // 鐢熸垚宸ヤ綔妗�
@@ -364,10 +369,26 @@
             wrkMast.setEmptyMk("N"); // 绌烘澘
             wrkMast.setLinkMis("N");
             wrkMast.setBarcode(locMast.getBarcode());
-            if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) {  //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙�
-                wrkMast.setLocNo(locMastRgv.getLocNo());
-                wrkMast.setTakeNone("0");  //0rgv鏈彇锛�1rgv宸插彇璐�
-            }
+            wrkMast.setTakeNone("0");  //0闈炶嚜鍔�
+
+            List<BasAgvWrkDetl> basAgvWrkDetls = null;
+            List<BasAgvLocDetl> basAgvLocDetls = null;
+            try{
+                if (Boolean.parseBoolean(configAutoMPArea.getValue())){
+                    if (wrkMast.getStaNoAgvSign()){
+                        if (ioType==101){
+                            // 鍏ㄦ澘鍑哄簱
+                            basAgvLocDetls = new ArrayList<>();
+                        } else {
+                            // 鎷f枡鍑哄簱
+                            basAgvWrkDetls = new ArrayList<>();
+                        }
+                        wrkMast.setTakeNone("1"); //绛夊緟涓嬪彂
+                    } else {
+                        wrkMast.setTakeNone("3");  //鏃犻渶AGV鎼繍
+                    }
+                }
+            } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
             wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁
             wrkMast.setAppeTime(now);
             wrkMast.setModiUser(userId);
@@ -375,6 +396,7 @@
             if (!wrkMastService.insert(wrkMast)) {
                 throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+dto.getLocNo());
             }
+
             // 鐢熸垚宸ヤ綔妗f槑缁�
             for (LocDetlDto detlDto : dto.getLocDetlDtos()) {
                 if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;}
@@ -389,25 +411,48 @@
                 wrkDetl.setAppeUser(userId);
                 wrkDetl.setModiTime(now);
                 wrkDetl.setModiUser(userId);
+
+                try{
+                    if (basAgvWrkDetls != null){
+                        BasAgvWrkDetl basAgvWrkDetl = new BasAgvWrkDetl();
+                        basAgvWrkDetl.sync(wrkDetl);
+                        basAgvWrkDetls.add(basAgvWrkDetl);
+                    }
+                } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
+
                 if (!wrkDetlService.insert(wrkDetl)) {
                     throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
                 }
             }
-            //淇敼agv澶囨枡鍖虹姸鎬�
-            if(locMastRgv.getLocSts().equals("O")){
-                locMastRgv.setLocSts("S");
-                locMastRgv.setModiUser(userId);
-                locMastRgv.setModiTime(now);
-                if (!locMastService.updateById(locMastRgv)) {
-                    throw new CoolException("棰勭害agv澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+locMastRgv.getLocNo());
-                }
-            }else{
-                throw new CoolException(locMastRgv.getLocNo() + "澶囨枡鍖轰笉鏄┖搴撲綅鐘舵��");
+//            if(locMastRgv !=null){
+//                if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null && ioType != 107) {  //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙�
+//                    //淇敼agv澶囨枡鍖虹姸鎬�
+//                    if(locMastRgv.getLocSts().equals("O") && ioType != 107){
+//                        locMastRgv.setLocSts("S");
+//                        locMastRgv.setModiUser(userId);
+//                        locMastRgv.setModiTime(now);
+//                        if (!locMastService.updateById(locMastRgv)) {
+//                            throw new CoolException("棰勭害agv澶囨枡鍖哄簱浣嶇姸鎬佸け璐ワ紝搴撲綅鍙凤細"+locMastRgv.getLocNo());
+//                        }
+//                    }
+//                }
+//            }
 
-            }
             // 淇敼搴撲綅鐘舵��:   F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
             locMast = locMastService.selectById(dto.getLocNo());
             if (locMast.getLocSts().equals("F")) {
+
+                try{
+                    if (basAgvLocDetls != null){
+                        List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
+                        for (LocDetl locDetl : locDetlList) {
+                            BasAgvLocDetl basAgvLocDetl = new BasAgvLocDetl();
+                            basAgvLocDetl.sync(locDetl);
+                            basAgvLocDetls.add(basAgvLocDetl);
+                        }
+                    }
+                } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
+
                 locMast.setLocSts(ioType==101?"R":"P");
                 locMast.setModiUser(userId);
                 locMast.setModiTime(now);
@@ -417,6 +462,21 @@
             } else {
                 throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
             }
+
+            try{
+                // 澧炲姞AGV搴撳瓨涓浆鏁伴噺
+                if (basAgvLocDetls != null){
+                    for (BasAgvLocDetl basAgvLocDetl : basAgvLocDetls) {
+                        basAgvLocDetlService.insert(basAgvLocDetl);
+                    }
+                }
+                if (basAgvWrkDetls != null){
+                    for (BasAgvWrkDetl basAgvWrkDetl : basAgvWrkDetls) {
+                        basAgvWrkDetlService.insert(basAgvWrkDetl);
+                    }
+                }
+
+            }catch (Exception e){}
         }
     }
 
@@ -430,7 +490,7 @@
                 throw new CoolException("璁㈠崟鍑哄簱寮傚父锛岃鑱旂郴绠$悊鍛�");
             }
         }
-        Config config = configService.selectConfigByCode("AutoMPArea");
+        Config configAutoMPArea = configService.selectConfigByCode("AutoMPArea");
 
         // 鑾峰彇搴撲綅
         LocMast locMast = locMastService.selectById(taskDto.getLocNo());
@@ -462,10 +522,27 @@
         wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
         wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
         wrkMast.setSourceLocNo(taskDto.getLocNo()); // 婧愬簱浣�
-        if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) {  //鑻ユ湁绌哄簱浣嶄笖閰嶇疆鍏佽鍒欑粦瀹氬叾澶囨枡搴撲綅鍙�
-            wrkMast.setLocNo(locMastRgv.getLocNo());
-            wrkMast.setTakeNone("0");  //0rgv鏈彇锛�1rgv宸插彇璐�
-        }
+        wrkMast.setTakeNone("0");  //0闈炶嚜鍔�
+
+        List<BasAgvWrkDetl> basAgvWrkDetls = null;
+        List<BasAgvLocDetl> basAgvLocDetls = null;
+        try{
+            if (Boolean.parseBoolean(configAutoMPArea.getValue())){
+                if (wrkMast.getStaNoAgvSign()){
+                    if (ioType==101){
+                        // 鍏ㄦ澘鍑哄簱
+                        basAgvLocDetls = new ArrayList<>();
+                    } else {
+                        // 鎷f枡鍑哄簱
+                        basAgvWrkDetls = new ArrayList<>();
+                    }
+                    wrkMast.setTakeNone("1"); //绛夊緟涓嬪彂
+                } else {
+                    wrkMast.setTakeNone("3");  //鏃犻渶AGV鎼繍
+                }
+            }
+        } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
+
         wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
         wrkMast.setPicking("N"); // 鎷f枡
         wrkMast.setExitMk("N"); // 閫�鍑�
@@ -502,6 +579,15 @@
             wrkDetl.setAppeUser(userId);
             wrkDetl.setModiTime(now);
             wrkDetl.setModiUser(userId);
+
+            try{
+                if (basAgvWrkDetls != null){
+                    BasAgvWrkDetl basAgvWrkDetl = new BasAgvWrkDetl();
+                    basAgvWrkDetl.sync(wrkDetl);
+                    basAgvWrkDetls.add(basAgvWrkDetl);
+                }
+            } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
+
             if (!wrkDetlService.insert(wrkDetl)) {
                 throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
             }
@@ -531,6 +617,17 @@
         // 淇敼搴撲綅鐘舵��:   F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
         locMast = locMastService.selectById(taskDto.getLocNo());
         if (locMast.getLocSts().equals("F")) {
+            try{
+                if (basAgvLocDetls != null){
+                    List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
+                    for (LocDetl locDetl : locDetlList) {
+                        BasAgvLocDetl basAgvLocDetl = new BasAgvLocDetl();
+                        basAgvLocDetl.sync(locDetl);
+                        basAgvLocDetls.add(basAgvLocDetl);
+                    }
+                }
+            } catch (Exception e) {}  //閰嶇疆椤逛笉瀛樺湪锛屼笉鍋氬鐞�
+
             locMast.setLocSts(ioType==101?"R":"P");
             locMast.setModiUser(userId);
             locMast.setModiTime(now);
@@ -540,6 +637,23 @@
         } else {
             throw new CoolException(taskDto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
         }
+
+
+
+        try{
+            // 澧炲姞AGV搴撳瓨涓浆鏁伴噺
+            if (basAgvLocDetls != null){
+                for (BasAgvLocDetl basAgvLocDetl : basAgvLocDetls) {
+                    basAgvLocDetlService.insert(basAgvLocDetl);
+                }
+            }
+            if (basAgvWrkDetls != null){
+                for (BasAgvWrkDetl basAgvWrkDetl : basAgvWrkDetls) {
+                    basAgvWrkDetlService.insert(basAgvWrkDetl);
+                }
+            }
+
+        }catch (Exception e){}
     }
 
     @Override
@@ -550,8 +664,15 @@
         // 妫�绱㈠簱浣�
         LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
         FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo();
-
-        StartupDto dto = commonService.getLocNo( 10, devpNo, findLocNoAttributeVo, locTypeDto);
+        StartupDto dto = null;
+        try{
+            dto = commonService.getLocNo( 10, devpNo, findLocNoAttributeVo, locTypeDto);
+        } catch (Exception e){
+            throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆�"+e.getMessage());
+        }
+        if (Cools.isEmpty(dto)){
+            throw new CoolException("鏌ヨ搴撲綅澶辫触锛侊紒==銆媠tartupFullPutStore ==銆� commonService.getLocNo");
+        }
         int workNo = dto.getWorkNo();
         Date now = new Date();
         // 鐢熸垚宸ヤ綔妗�
@@ -871,6 +992,7 @@
     @Transactional
     public void completeWrkMast(String workNo, Long userId) {
         WrkMast wrkMast = wrkMastService.selectById(workNo);
+        Integer ioType = 0;
         if (Cools.isEmpty(wrkMast)){
             throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪");
         }
@@ -880,9 +1002,15 @@
         // 鍏ュ簱 + 搴撲綅杞Щ
         if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) {
             wrkMast.setWrkSts(4L);
+            if(wrkMast.getIoType() == 11){
+                ioType = 2;
+            }else{
+                ioType = 3;
+            }
         // 鍑哄簱
         } else if (wrkMast.getWrkSts() > 10) {
             wrkMast.setWrkSts(14L);
+            ioType = 1;
         }
         Date now = new Date();
         wrkMast.setCrnStrTime(DateUtils.calculate(now, 1L, TimeUnit.SECONDS, true));

--
Gitblit v1.9.1