From 6dcb479b81e65d63ceb2f9fae4eb1631e4ace029 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期二, 22 三月 2022 17:27:53 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 172 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 122 insertions(+), 50 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 4ec61b3..b10616d 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -105,41 +105,45 @@ continue; } String barcode = barcodeThread.getBarcode(); -// if(!Cools.isEmpty(barcode)) { -// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); -// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { -// continue; -// } -// } else { -// continue; -// } + if(!Cools.isEmpty(barcode)) { + log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + continue; + } + } else { + continue; + } // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); if (staProtocol == null) { continue; } else { staProtocol = staProtocol.clone(); } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if ( inSta.getStaNo()==180 && devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999) && 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; - } +// 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; +// } // 鍒ゆ柇閲嶅宸ヤ綔妗� WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode); @@ -266,13 +270,17 @@ // 閬嶅巻鍏ュ簱鍙� for (DevpSlave.Sta inSta : devp.getInSta()) { // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); if (staProtocol == null) { continue; } else { staProtocol = staProtocol.clone(); } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && !staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999) @@ -320,37 +328,41 @@ continue; } String barcode = barcodeThread.getBarcode(); -// if(!Cools.isEmpty(barcode)) { -// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); -// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { -// continue; -// } -// } else { -// continue; -// } + if(!Cools.isEmpty(barcode)) { + log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { + continue; + } + } else { + continue; + } // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); if (staProtocol == null) { continue; } else { staProtocol = staProtocol.clone(); } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){ - if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { - log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.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; - } +// if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) { +// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.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; +// } WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); if (wrkMast == null) { @@ -541,6 +553,57 @@ } /** + * 鍥炲師鐐癸紝鍫嗗灈鏈烘病鏈夋墽琛屼腑浠诲姟锛岃澶囧瓨鍦ㄥ叆搴撲换鍔℃椂鍙洖鍘熺偣 + */ + public void crnRebackHp(){ + for (CrnSlave crn : slaveProperties.getCrn()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); + if (basCrnp == null) { + log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); + continue; + } + if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(crn.getId()) != null) { + continue; + } + + //鍫嗗灈鏈烘湁鎵ц涓换鍔★紝杩囨护 + if (wrkMastMapper.selectCrnWorking(crn.getId()) != null) { + continue; + } + + //杈撻�佺嚎娌℃湁鍏ュ簱浠诲姟锛岃繃婊� + if (wrkMastMapper.selectDevWorking(crn.getId()) == null) { + continue; + } + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crn.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo((short) 1); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡: 鍥炲師鐐� + crnCommand.setSourcePosX((short) 0); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY((short) 0); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, crn.getId(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄洖鍘熺偣鍛戒护涓嬪彂澶辫触锛屽爢鍨涙満鍙�={}锛屼换鍔℃暟鎹�={}", crn.getId(), JSON.toJSON(crnCommand)); + } + } + } + } + + /** * 鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鍒板簱浣� */ public void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol){ @@ -691,13 +754,18 @@ continue; } // 鑾峰彇鍫嗗灈鏈哄嚭搴撶珯淇℃伅 - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId()); StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo()); if (staProtocol == null) { continue; } else { staProtocol = staProtocol.clone(); } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; } + + // 鏌ヨ绔欑偣璇︾粏淇℃伅 BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo()); if (staDetl == null) { @@ -818,7 +886,7 @@ } // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� - if (wrkMastMapper.selectLocMoving(slave.getId()) != null) { + if (wrkMastMapper.selectWorking(slave.getId()) != null) { return; } @@ -1017,13 +1085,17 @@ // 閬嶅巻绌烘澘鍏ュ簱鍙� for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { // 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); if (staProtocol == null) { continue; } else { staProtocol = staProtocol.clone(); } + +// // 鍏ュ嚭搴撴ā寮忓垽鏂� +// if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; } + // 绔欑偣鏉′欢鍒ゆ柇 if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9990 || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) { @@ -1598,14 +1670,14 @@ for (DevpSlave devp : slaveProperties.getDevp()) { SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - WrkMast pakoutOf2F = wrkMastMapper.selectWorkingPakoutOf2F(); - if (pakoutOf2F != null) { + WrkMast pakout = wrkMastMapper.selectWorkingPakout(); + if (pakout != null) { if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { // 鍑哄簱鍒囨崲涓� devpThread.ioMode = IoModeType.PAKOUT_BOOTING; - WrkMast pakinOf2F = wrkMastMapper.selectWorkingPakinOf2F(); - if (pakinOf2F == null && !devpThread.getStation().get(201).isLoading() && !devpThread.getStation().get(202).isLoading()) { + WrkMast pakin = wrkMastMapper.selectWorkingPakin(); + if (pakin == null) { // 鍑哄簱妯″紡 devpThread.ioMode = IoModeType.PAKOUT_MODE; } -- Gitblit v1.9.1