From cbeff29a3261cb13ed3c5aada8bbd9cc4c1fee72 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 22 七月 2025 09:57:48 +0800 Subject: [PATCH] #空托盘程序 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 251 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 225 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index 848ec37..3ca6779 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.Cools; import com.core.common.DateUtils; +import com.core.common.R; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.BasCrnErrorMapper; @@ -1634,13 +1635,43 @@ continue; } + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); + if (barcodeThread == null) { + continue; + } + // 绔欑偣鏉′欢鍒ゆ柇 if (staProtocol.isAutoing() && staProtocol.isInEnable() && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) - && staProtocol.isPakMk()) { + && staProtocol.isPakMk() + && staProtocol.getEmptyInType() == 1 + ) { News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�"); + + String barcode = barcodeThread.getBarcode(); + if(!Cools.isEmpty(barcode)) { + News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + News.info(""+mark+" - 2"+" - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } + } else { + News.info(""+mark+" - 3"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } try { LocTypeDto locTypeDto = new LocTypeDto(staProtocol); @@ -1649,6 +1680,7 @@ param.setIoType(10); param.setSourceStaNo(emptyInSta.getStaNo()); param.setLocType1(locTypeDto.getLocType1()); + param.setBarcode(barcode); String response = new HttpHandler.Builder() .setUri(wmsUrl) .setPath("/rpc/pakin/loc/v1") @@ -1668,31 +1700,7 @@ News.errorNoLog(""+mark+" - 1"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触"); throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } - - if (ledThread != null) { - // 鍛戒护闆嗗悎 - List<LedCommand> commands = new ArrayList<>(); - // 缁勮鍛戒护 - LedCommand ledCommand = new LedCommand(); - ledCommand.setWorkNo(dto.getWorkNo()); - ledCommand.setIoType(1); - ledCommand.setTitle("鍏ㄦ澘鍏ュ簱"); - ledCommand.setLocNo(dto.getLocNo()); - ledCommand.setStaNo(dto.getStaNo()); - commands.add(ledCommand); - MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands)); -// ledThread.errorReset(); - } } else { - staProtocol.setWorkNo((short)9992); - staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - News.errorNoLog(""+mark+" - 2"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触"); - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } - if (ledThread != null) { String errorMsg = jsonObject.getString("msg"); if (!Cools.isEmpty(errorMsg)) { @@ -1703,9 +1711,115 @@ } } catch (Exception e) { e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } else { + News.errorNoLog(""+mark+" - 4"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() + +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() + +"銆侀攣瀹氭爣璁�"+ staProtocol.isPakMk()); + } + } + } + News.infoNoLog(""+mark+" - 0"+" - 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐ф墽琛屽畬鎴�"); + } + + /** + * 绌烘墭鐩樺叆搴�-浜х嚎 + */ + public synchronized void storeEmptyPltLine(Integer mark) { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻绌烘澘鍏ュ簱鍙� + for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { + // 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + LedThread ledThread = null; + if (!Cools.isEmpty(emptyInSta.getLed())) { + ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); + } + + if (!staProtocol.isLoading()){ + continue; + } + + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); + if (barcodeThread == null) { + continue; + } + + // 绔欑偣鏉′欢鍒ゆ柇 + if (staProtocol.isAutoing() + && staProtocol.isInEnable() + && staProtocol.isEmptyMk() + && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) + && staProtocol.isPakMk() + && staProtocol.getEmptyInType() == 2 + ) { + News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛岋細绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐�"); + + String barcode = barcodeThread.getBarcode(); + if(!Cools.isEmpty(barcode)) { + News.info(""+mark+" - 1"+" - {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + News.info(""+mark+" - 2"+" - 鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; + } + } else { + News.info(""+mark+" - 3"+" - 鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", emptyInSta.getBarcode(), barcode, emptyInSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + continue; } + WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() + .eq("barcode", barcode) + ); + if(wrkMast != null) { + continue; + } + + int workNo = commonService.getWorkNo(3); + // 鐢熸垚宸ヤ綔妗� + WrkMast wrkMast1 = new WrkMast(); + wrkMast1.setWrkNo(workNo); + wrkMast1.setIoTime(new Date()); + wrkMast1.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細璁惧涓婅蛋 + wrkMast1.setIoType(3); // 鍏ュ嚭搴撶姸鎬侊細3.绔欏埌绔� + wrkMast1.setIoPri(13D); // 浼樺厛绾� + wrkMast1.setSourceStaNo(emptyInSta.getStaNo()); + wrkMast1.setStaNo(1007); + wrkMast1.setBarcode(barcode); + // 鎿嶄綔浜哄憳鏁版嵁 + wrkMast1.setAppeTime(new Date()); + wrkMast1.setModiTime(new Date()); + boolean res = wrkMastService.insert(wrkMast1); + if (!res) { + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); + } + + // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 + staProtocol.setWorkNo((short) workNo); + staProtocol.setStaNo((short) 2003); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + News.errorNoLog(""+mark+" - 1"+" - 鏇存柊plc绔欑偣淇℃伅澶辫触"); + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } } else { News.errorNoLog(""+mark+" - 4"+" - 绔欑偣淇℃伅涓嶇鍚堝叆搴撴潯浠讹紒锛侊紒"+" 鑷姩淇″彿锛�"+staProtocol.isAutoing()+"銆佸彲鍏ヤ俊鍙凤細" + staProtocol.isInEnable() +"銆佺┖鏉夸俊鍙凤細"+ staProtocol.isEmptyMk()+"銆佸伐浣滃彿锛�" + staProtocol.getWorkNo() @@ -2429,6 +2543,11 @@ continue; } + if (wrkMast.getIoType() == 3) { + //绔欏埌绔欒蛋鍙﹀涓�涓柟娉� + continue; + } + Integer devpId = null; Integer devpStaNo = null; String locNo = null; @@ -2478,6 +2597,86 @@ News.infoNoLog(""+mark+" - 0"+" - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); } + // RGV ===>> 鎵ц瀵筊GV宸ヤ綔妗g殑瀹屾垚鎿嶄綔 绔欏埌绔� + public synchronized void rgvFinished2(Integer mark) { + for (RgvSlave rgvSlave : slaveProperties.getRgv()) { + // 鑾峰彇RGV淇℃伅 + RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, rgvSlave.getId()); + if (rgvThread == null) { + continue; + } + + RgvProtocol rgvProtocol = rgvThread.getRgvProtocol(); + if (rgvProtocol == null) { + continue; + } + + // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 + if (rgvProtocol.statusType1 == RgvStatusType.WAITING && rgvProtocol.getTaskNo1() != 0) { + News.warnNoLog(""+mark+" - 0"+" - 寮�濮嬫墽琛屽RGV宸ヤ綔妗g殑瀹屾垚鎿嶄綔"); + // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectPakInStep3(rgvProtocol.getTaskNo1().intValue()); + if (wrkMast == null) { + News.error(""+mark+" - 1"+" - RGV澶勪簬绛夊緟纭涓斾换鍔″畬鎴愮姸鎬侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�俁GV鍙�={}锛屽伐浣滃彿={}", rgvSlave.getId(), rgvProtocol.getTaskNo1()); + continue; + } + + if (wrkMast.getWrkSts() != 201) { + continue; + } + + if (wrkMast.getIoType() != 3) { + //涓嶆槸绔欏埌绔� + continue; + } + + Integer devpId = 2; + Integer devpStaNo = 2002; + + // 鑾峰彇鍏ュ簱绔欎俊鎭� + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devpId); + StaProtocol staProtocol = devpThread.getStation().get(devpStaNo); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.getWorkNo() == 0 + ) { + + short locType2 = 1; + String barcode = wrkMast.getBarcode(); + if (barcode.startsWith("11")) { + locType2 = 1; + } else if (barcode.startsWith("13")) { + locType2 = 2; + } else if (barcode.startsWith("16")) { + locType2 = 3; + } else { + continue; + } + + staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); + staProtocol.setPalletSize(locType2); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + rgvThread.setResetFlag1(true); + + wrkMastService.delete(new EntityWrapper<WrkMast>() + .eq("wrk_no", wrkMast.getWrkNo())); + } + } + } + News.infoNoLog(""+mark+" - 0"+" - 瀵瑰伐浣滄。鐨勫畬鎴愭搷浣滄墽琛屽畬鎴�"); + } + // /** // * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁� // */ -- Gitblit v1.9.1