From e26ec12fc616abfb24c1ce5bd48ede15b21fc327 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期日, 29 一月 2023 13:21:58 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 438 +++++++++++++++++++++++++----------------------------- 1 files changed, 203 insertions(+), 235 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 5516330..da10301 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -41,7 +41,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; @@ -95,7 +94,7 @@ * 缁勬墭 * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 2 */ - public void generateStoreWrkFile() { + public synchronized void generateStoreWrkFile() { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鍏ュ簱鍙� @@ -103,15 +102,6 @@ // 鑾峰彇鏉$爜鎵弿浠俊鎭� BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); 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; } @@ -124,46 +114,84 @@ 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() && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) - && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) { + && staProtocol.isPakMk() && staProtocol.getStamp()>=2) {// && !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; -// } +// try { +// Thread.sleep(300); +// }catch (Exception e){} + + 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)); + + 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; + } + } 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; + } // 鍒ゆ柇閲嶅宸ヤ綔妗� 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){ + continue; + } + } 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; } -// // 鑾峰彇鍏ュ簱閫氱煡妗� -// List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N")); -// if (waitPakins.isEmpty()) { -// log.error("鏃犳鍏ュ簱鏉$爜鏁版嵁銆傛潯鐮佸彿={}", barcode); -// continue; -// } try { - LocTypeDto locTypeDto = new LocTypeDto(staProtocol); SearchLocParam param = new SearchLocParam(); @@ -189,67 +217,38 @@ 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)); +// ledThread.errorReset(); + } } else { log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + 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(); @@ -257,7 +256,6 @@ } } - } } @@ -268,7 +266,7 @@ * wms鍏ュ簱 * 鍏ュ簱绔欙紝鏍规嵁鏉$爜鎵弿鐢熸垚鍏ュ簱宸ヤ綔妗o紝宸ヤ綔鐘舵�� 1 ==>> 2 */ - public void generateStoreWrkFile0() { + public synchronized void generateStoreWrkFile0() { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鍏ュ簱鍙� @@ -330,20 +328,20 @@ for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻鎷f枡鍏ュ簱鍙� for (DevpSlave.Sta pickSta : devp.getPickSta()) { -// // 鑾峰彇鏉$爜鎵弿浠俊鎭� -// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); -// if (barcodeThread == null) { -// continue; -// } -// String barcode = barcodeThread.getBarcode(); -// if(!Cools.isEmpty(barcode)) { -// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); -// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { -// continue; -// } -// } else { -// continue; -// } + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if(!Cools.isEmpty(barcode)) { + log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + continue; + } + } else { + continue; + } // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); @@ -358,8 +356,8 @@ // if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()) { -// WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); - WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); + WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); +// WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); if (wrkMast == null) { // 鏃犳嫞鏂欐暟鎹� continue; @@ -448,8 +446,7 @@ /** * 鍫嗗灈鏈虹珯鍑哄簱鍒板嚭搴撶珯 */ - @Async - public void crnStnToOutStn() { + public synchronized void crnStnToOutStn() { for (CrnSlave crnSlave : slaveProperties.getCrn()) { // 閬嶅巻鍫嗗灈鏈哄嚭搴撶珯 for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) { @@ -621,7 +618,7 @@ /** * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� */ - public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) { + public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) { for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) { boolean flag = false; // 鑾峰彇鍫嗗灈鏈哄叆搴撶珯淇℃伅 @@ -714,7 +711,7 @@ CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� - crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� +// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 crnCommand.setSourcePosX(crnStn.getRow().shortValue()); // 婧愬簱浣嶆帓 crnCommand.setSourcePosY(crnStn.getBay().shortValue()); // 婧愬簱浣嶅垪 @@ -754,7 +751,7 @@ * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� * 2022-06-09 TQS淇敼锛屾煡璇㈠伐浣滄。LIST锛岄亶鍘嗕笅鍙戯紝闃叉绗竴涓换鍔″牭濉炲嚭搴� */ - public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { + public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) { for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗� // WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); @@ -845,7 +842,7 @@ log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛佹祬搴撲綅鍙�:{}", wrkMast.getWrkNo(), shallowLocNo); continue; } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) { - WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); + WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo); if (null != waitWrkMast && waitWrkMast.getWrkSts() == 4) { continue; } @@ -862,7 +859,7 @@ CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� - crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� +// crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 @@ -1008,7 +1005,7 @@ /** * 搴撲綅绉昏浆 */ - public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) { + public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) { // 鑾峰彇宸ヤ綔妗d俊鎭� WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); if (null == wrkMast) { @@ -1076,8 +1073,7 @@ /** * 鎵ц瀵瑰伐浣滄。鐨勫畬鎴愭搷浣� */ - @Async - public void storeFinished() { + public synchronized void storeFinished() { for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); @@ -1120,8 +1116,7 @@ /** * 鍫嗗灈鏈哄紓甯镐俊鎭褰� */ - @Async - public void recCrnErr() { + public synchronized void recCrnErr() { Date now = new Date(); for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� @@ -1242,8 +1237,7 @@ /** * 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐� */ - @Async - public void storeEmptyPlt() { + public synchronized void storeEmptyPlt() { for (DevpSlave devp : slaveProperties.getDevp()) { // 閬嶅巻绌烘澘鍏ュ簱鍙� for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { @@ -1256,15 +1250,18 @@ staProtocol = staProtocol.clone(); } -// // 鍏ュ嚭搴撴ā寮忓垽鏂� -// if ( emptyInSta.getStaNo()==203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) { continue; } - if (emptyInSta.getStaNo() == 203 && devpThread.ioModeOf2F == IoModeType.PAKOUT_MODE) { - continue; + 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); @@ -1291,7 +1288,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) { @@ -1299,62 +1325,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(); -// } - } - } } @@ -1363,8 +1334,7 @@ /** * 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣� */ - @Async - public void ledExecute() { + public synchronized void ledExecute() { for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1480,35 +1450,7 @@ /** * 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅 */ - @Async - public 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()); -// } -// } -// } + public synchronized void ledReset() { for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1529,20 +1471,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 { - } } } } @@ -1628,7 +1561,7 @@ * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増) * tip锛氬悓姝� */ - private void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) { + private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) { try { List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); LocMast loc = null; @@ -1896,7 +1829,7 @@ /** * 鍏ュ嚭搴撴ā寮忓垏鎹㈠嚱鏁� */ - public void ioConvert() { + public synchronized void ioConvert() { try { // 鏍规嵁杈撻�佺嚎plc閬嶅巻 for (DevpSlave devp : slaveProperties.getDevp()) { @@ -1956,7 +1889,7 @@ } - public void outOfDevp() { + public synchronized void outOfDevp() { List<WrkMast> wrkMasts = wrkMastMapper.selectPick(); for (WrkMast wrkMast : wrkMasts) { if (basDevpService.selectCount(new EntityWrapper<BasDevp>().eq("wrk_no", wrkMast.getWrkNo())) == 0) { @@ -1970,7 +1903,7 @@ } - public void autoEmptyOut() { + public synchronized void autoEmptyOut() { DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); Integer autoOutSite = 12; //濡傛灉绔欑偣鍙嚭绂佺敤锛屽垯涓嶇敓鎴愮┖鐩樺嚭搴撲换鍔� @@ -1989,11 +1922,27 @@ if (null != pakoutEmpty) { return; } - //鏈紑WMS鍒嗘敮锛岃姹俉MS鐢熸垚绌烘澘鍑哄簱鏈啓 + try { + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/auto/emptyOut/v1") + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { + JSONObject data = (JSONObject) jsonObject.get("data"); + log.info((String) data.get("msg")); + } else { + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyOut/v1","", response); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } } } - public void autoEmptyIn() { + public synchronized void autoEmptyIn() { DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); Integer autoInSite = 12; StaProtocol staProtocol = devpThread.getStation().get(autoInSite); @@ -2008,7 +1957,26 @@ && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() > 9990) //宸ヤ綔鍙蜂负0鎴栬�呭伐浣滃彿鏄�9991~9999锛堣緭閫佹満鐣欑敤锛� ) { - //鏈紑WMS鍒嗘敮锛岃姹俉MS鐢熸垚绌烘澘鍏ュ簱鏈啓 + try { + LocTypeDto locTypeDto = new LocTypeDto((short) 1, (short) 1, (short) 1); + + + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/auto/emptyIn/v1") + .setJson(JSON.toJSONString(locTypeDto)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + if (jsonObject.getInteger("code").equals(200)) { + log.info((String) jsonObject.get("msg")); + } else { + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/auto/emptyIn/v1", JSON.toJSONString(locTypeDto), response); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } } } } -- Gitblit v1.9.1