From 96838eab6a7da7b12f4623aa6e86f16f26bcdde4 Mon Sep 17 00:00:00 2001 From: tqs <56479841@qq.com> Date: 星期一, 09 一月 2023 14:27:53 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 359 ++++++++++++++++++++--------------------------------------- 1 files changed, 121 insertions(+), 238 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 b609a62..baaa901 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -104,15 +104,6 @@ if (barcodeThread == null) { continue; } - String barcode = barcodeThread.getBarcode(); - if (!Cools.isEmpty(barcode)) { - log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); - if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) { - continue; - } - } else { - continue; - } // 鑾峰彇鍏ュ簱绔欎俊鎭� SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); @@ -123,11 +114,13 @@ staProtocol = staProtocol.clone(); } + //LED + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); // 鍏ュ嚭搴撴ā寮忓垽鏂� // if ( inSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } - if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { - continue; - } +// if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { +// continue; +// } // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (staProtocol.isAutoing() && staProtocol.isLoading() @@ -135,63 +128,60 @@ && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) { -// if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { -// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); -// //鏉$爜涓虹┖鎴栬�呬笉绗﹀悎锛岄��搴撳埌172绔欑偣 -// staProtocol.setWorkNo((short)9999); -// staProtocol.setStaNo((short)172); -// devpThread.setPakMk(staProtocol.getSiteId(), false); -// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); -// if (!result) { -// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); -// } -// continue; -// } + String barcode = barcodeThread.getBarcode(); + if(!Cools.isEmpty(barcode)) { + log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + staProtocol.setWorkNo((short) 9999); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - // 鍒ゆ柇閲嶅宸ヤ綔妗� - WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); - WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode); - if (wrkMast1 !=null){ - if (wrkMast1.getIoType()==103 || wrkMast1.getIoType()==107 || wrkMast1.getIoType()==104){ + log.info("鎵爜澶辫触1 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); + } continue; } - } - if (wrkMast != null) { - log.error("宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo()); - if (inSta.getStaNo()==101 || inSta.getStaNo()==109 || inSta.getStaNo()==117){ - staProtocol.setWorkNo((short)9999); - staProtocol.setStaNo((short)100); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } - }else if (inSta.getStaNo()==201 || inSta.getStaNo()==207 || inSta.getStaNo()==213){ - staProtocol.setWorkNo((short)9999); - if (inSta.getStaNo()==201){ - staProtocol.setStaNo((short)200); - }else if (inSta.getStaNo()==207){ - staProtocol.setStaNo((short)206); - }else if (inSta.getStaNo()==213){ - staProtocol.setStaNo((short)212); - } - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } + } else { + staProtocol.setWorkNo((short) 9999); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + + log.info("鎵爜澶辫触2 ===>> {}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{},绔欑偣:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); } continue; } -// // 鑾峰彇鍏ュ簱閫氱煡妗� -// List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N")); -// if (waitPakins.isEmpty()) { -// log.error("鏃犳鍏ュ簱鏉$爜鏁版嵁銆傛潯鐮佸彿={}", barcode); -// continue; -// } + + // 鍒ゆ柇閲嶅宸ヤ綔妗� + WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); + + if (wrkMast != null) { + log.error("宸ヤ綔妗d腑宸插瓨鍦ㄨ绔欑姸鎬佷负锛� 2.璁惧涓婅蛋 锛夌殑鏁版嵁,宸ヤ綔鍙�={}", wrkMast.getWrkNo()); + staProtocol.setWorkNo((short)9999); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = "宸ヤ綔妗e凡瀛樺湪璇ユ潯鐮佸彿===>>" + barcode; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); + } + continue; + } try { - LocTypeDto locTypeDto = new LocTypeDto(staProtocol); SearchLocParam param = new SearchLocParam(); @@ -217,90 +207,37 @@ if (!result) { throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } + + // led 鍏ュ簱淇℃伅鏄剧ず + 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, inSta.getLed(), new Task(3, commands)); + } } else { log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); - if (inSta.getStaNo()==101 || inSta.getStaNo()==109 || inSta.getStaNo()==117){ - staProtocol.setWorkNo((short)9999); - staProtocol.setStaNo((short)100); - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } - }else if (inSta.getStaNo()==201 || inSta.getStaNo()==207 || inSta.getStaNo()==213){ - staProtocol.setWorkNo((short)9999); - if (inSta.getStaNo()==201){ - staProtocol.setStaNo((short)200); - }else if (inSta.getStaNo()==207){ - staProtocol.setStaNo((short)206); - }else if (inSta.getStaNo()==213){ - staProtocol.setStaNo((short)212); - } - devpThread.setPakMk(staProtocol.getSiteId(), false); - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - if (!result) { - throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); - } + staProtocol.setWorkNo((short)9999); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = jsonObject.getString("msg"); + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); } } - - -// // 妫�绱㈠簱浣� -// LocTypeDto locTypeDto = new LocTypeDto(staProtocol); -// List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); -// StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos, locTypeDto, 0); -// // 宸ヤ綔鍙� -// int workNo = startupDto.getWorkNo(); -// // 鎻掑叆宸ヤ綔鏄庣粏妗� -// wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); -// -// // 鎻掑叆宸ヤ綔涓绘。 -// wrkMast = new WrkMast(); -// wrkMast.setWrkNo(workNo); -// wrkMast.setIoTime(new Date()); -// wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 -// wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱 -// wrkMast.setIoPri(10D); // 浼樺厛绾э細10 -// wrkMast.setCrnNo(startupDto.getCrnNo()); -// wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); -// wrkMast.setStaNo(startupDto.getStaNo()); -// wrkMast.setLocNo(startupDto.getLocNo()); -// wrkMast.setBarcode(barcode); // 鎵樼洏鐮� -// wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 -// wrkMast.setPicking("N"); // 鎷f枡 -// wrkMast.setExitMk("N"); // 閫�鍑� -// wrkMast.setEmptyMk("N"); // 绌烘澘 -// wrkMast.setLinkMis("N"); -// // 鎿嶄綔浜哄憳鏁版嵁 -// wrkMast.setAppeTime(new Date()); -// wrkMast.setModiTime(new Date()); -// Integer insert = wrkMastMapper.insert(wrkMast); -// if (insert == 0) { -// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); -// } -// // 鏇存柊鐩爣搴撲綅鐘舵�� -// LocMast locMast = locMastService.selectById(startupDto.getLocNo()); -// locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 -// locMast.setModiTime(new Date()); -// if (!locMastService.updateById(locMast)){ -// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); -// } -// // 灏嗗叆搴撻�氱煡妗d慨鏀逛负宸插惎鍔� -// if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { -// throw new CoolException("淇敼鍏ュ簱閫氱煡妗g姸鎬佷负宸插惎鍔ㄥけ璐�"); -// } -// -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 -// barcodeThread.setBarcode(""); -// staProtocol.setWorkNo((short) workNo); -// staProtocol.setStaNo(startupDto.getStaNo().shortValue()); -// devpThread.setPakMk(staProtocol.getSiteId(), false); -// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); -// if (!result) { -// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); -// } } catch (Exception e) { e.printStackTrace(); @@ -308,7 +245,6 @@ } } - } } @@ -1303,9 +1239,18 @@ staProtocol = staProtocol.clone(); } + LedThread ledThread = null; + if (!Cools.isEmpty(emptyInSta.getLed())) { + ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); + } + // 绔欑偣鏉′欢鍒ゆ柇 - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() - && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) && staProtocol.isPakMk()) { + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.isEmptyMk() + && (staProtocol.getWorkNo() > 9990 && staProtocol.getWorkNo() <= 9999) + && staProtocol.isPakMk()) { try { LocTypeDto locTypeDto = new LocTypeDto(staProtocol); @@ -1332,7 +1277,36 @@ if (!result) { 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)9999); + staProtocol.setStaNo(emptyInSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + if (!result) { + throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); + } + + if (ledThread != null) { + String errorMsg = jsonObject.getString("msg"); + if (!Cools.isEmpty(errorMsg)) { + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg)); + } + } log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } } catch (Exception e) { @@ -1340,62 +1314,7 @@ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - -// // 妫�绱㈠簱浣� -// LocTypeDto locTypeDto = new LocTypeDto(staProtocol); -// StartupDto startupDto = commonService.getLocNo(1, 10, emptyInSta.getStaNo(), null, locTypeDto, 0); -// // 宸ヤ綔鍙� -// int workNo = startupDto.getWorkNo(); -// -// try { -// // 鎻掑叆宸ヤ綔涓绘。 -// WrkMast wrkMast = new WrkMast(); -// wrkMast.setWrkNo(workNo); -// wrkMast.setIoTime(new Date()); -// wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 -// wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱 -// wrkMast.setIoPri(10D); // 浼樺厛绾э細10 -// wrkMast.setCrnNo(startupDto.getCrnNo()); -// wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); -// wrkMast.setStaNo(startupDto.getStaNo()); -// wrkMast.setLocNo(startupDto.getLocNo()); -// wrkMast.setFullPlt("N"); // 婊℃澘 -// wrkMast.setPicking("N"); // 鎷f枡 -// wrkMast.setExitMk("N"); // 閫�鍑� -// wrkMast.setEmptyMk("Y"); // 绌烘澘 -// wrkMast.setLinkMis("N"); -//// wrkMast.setCtnType(sourceStaNo.getCtnType()); // 瀹瑰櫒绫诲瀷 -// // 鎿嶄綔浜哄憳鏁版嵁 -// wrkMast.setAppeTime(new Date()); -// wrkMast.setModiTime(new Date()); -// Integer insert = wrkMastMapper.insert(wrkMast); -// if (insert == 0) { -// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); -// } -// // 鏇存柊鐩爣搴撲綅鐘舵�� -// LocMast locMast = locMastService.selectById(startupDto.getLocNo()); -// locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 -// locMast.setModiTime(new Date()); -// if (!locMastService.updateById(locMast)){ -// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); -// } -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 -// staProtocol.setWorkNo((short) workNo); -// staProtocol.setStaNo(startupDto.getStaNo().shortValue()); -// devpThread.setPakMk(staProtocol.getSiteId(), false); -// boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); -// if (!result) { -// throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// } - } - } } @@ -1521,33 +1440,6 @@ * 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅 */ public synchronized void ledReset() { -// for (LedSlave led : slaveProperties.getLed()) { -// // 鑾峰彇杈撻�佺嚎plc绾跨▼ -// DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); -// // 鍛戒护闆嗗悎 -// boolean reset = true; -// for (Integer staNo : led.getStaArr()) { -// // 鑾峰彇鍙夎溅绔欑偣 -// StaProtocol staProtocol = devpThread.getStation().get(staNo); -// if (staProtocol == null) { -// continue; -// } else { -// staProtocol = staProtocol.clone(); -// } -// if (staProtocol.getWorkNo() != 0) { -// reset = false; -// break; -// } -// } -// // 鑾峰彇led绾跨▼ -// LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); -// // led鏄剧ず榛樿鍐呭 -// if (reset) { -// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { -// log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); -// } -// } -// } for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1568,20 +1460,11 @@ LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); // led鏄剧ず榛樿鍐呭 if (reset && !ledThread.isLedMk()) { - if (led.getId() == 7) { - ledThread.setLedMk(true); - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { - log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); - } else { - - } + ledThread.setLedMk(true); + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); } else { - ledThread.setLedMk(true); - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { - log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); - } else { - } } } } -- Gitblit v1.9.1