From 839b330a81489332300c39d74ba70713b142f80f Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 08 十二月 2023 12:00:24 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 2281 ++++++++++++++++++++++++++++++---------------------------- 1 files changed, 1,183 insertions(+), 1,098 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 b655e3a..1f21b56 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -405,111 +405,115 @@ */ @Transactional public synchronized void stnToCrnStnPick(){ - for (DevpSlave devp : slaveProperties.getDevp()) { - // 閬嶅巻鎷f枡鍏ュ簱鍙� - for (DevpSlave.Sta pickSta : devp.getPickInSta()) { - if (pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339) { - continue; - } + try { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鎷f枡鍏ュ簱鍙� + for (DevpSlave.Sta pickSta : devp.getPickInSta()) { + if (pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339) { + continue; + } - // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); - if (staProtocol == null) { - continue; - } else { - staProtocol = staProtocol.clone(); - } - if (staProtocol.isAutoing() - && staProtocol.isLoading() - && staProtocol.isInEnable() + // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() // && (staProtocol.getWorkNo() > 0) - && staProtocol.isPakMk()){ + && staProtocol.isPakMk()) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); - if (barcodeThread == null) { - continue; - } - String barcode = barcodeThread.getBarcode(); - if(Cools.isEmpty(barcode)) { - continue; - } - if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { - continue; - } - - WrkMast wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); - if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 - continue; - } - - if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) - || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { - continue; - } - - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - boolean flag = false; - String th = ""; - List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); - for (String loc : innerLoc) { - LocMast locMast = locMastService.selectById(loc); - if (locMast == null) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if (Cools.isEmpty(barcode)) { + continue; + } + if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { continue; } - if (!locMast.getLocSts().equals("F")) { - flag = true; - th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; - break; + WrkMast wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode); + if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 + continue; } - } - if (flag) { - News.info(th); - continue; - } - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� - if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { - News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); - continue; - } + if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { + continue; + } - String sourceLocNo = wrkMast.getSourceLocNo().trim(); - LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 - if (liftStaProtocol == null) { - continue; - } + //*********************鍚屽簱浣嶇粍鏍¢獙********************* + boolean flag = false; + String th = ""; + List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); + for (String loc : innerLoc) { + LocMast locMast = locMastService.selectById(loc); + if (locMast == null) { + continue; + } - // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� - wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 - wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 - wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯 + if (!locMast.getLocSts().equals("F")) { + flag = true; + th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; + break; + } + } + if (flag) { + News.info(th); + continue; + } + //*********************鍚屽簱浣嶇粍鏍¢獙********************* + + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { + News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); + continue; + } + + String sourceLocNo = wrkMast.getSourceLocNo().trim(); + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 + if (liftStaProtocol == null) { + continue; + } + + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 + wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 + wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯 // wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔� // wrkMast.setCrnNo(dto.getCrnNo()); - wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� - wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� - wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� - wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� - wrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(wrkMast) == 0) { - News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); - continue; - } + wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� + wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� + wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� + wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� + wrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) == 0) { + News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + continue; + } - // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� - LocMast locMast = locMastService.selectById(sourceLocNo); - locMast.setLocSts("Q"); - locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)) { - News.info("淇敼搴撲綅鐘舵�佸け璐�"); - continue; + // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� + LocMast locMast = locMastService.selectById(sourceLocNo); + locMast.setLocSts("Q"); + locMast.setModiTime(new Date()); + if (!locMastService.updateById(locMast)) { + News.info("淇敼搴撲綅鐘舵�佸け璐�"); + continue; + } } } - } + } + } catch (Exception e) { + e.printStackTrace(); } } @@ -518,101 +522,105 @@ */ @Transactional public synchronized void stnToCrnStnPick2(){ - for (DevpSlave devp : slaveProperties.getDevp()) { - // 閬嶅巻鎷f枡鍏ュ簱鍙� - for (DevpSlave.Sta pickSta : devp.getPickInSta()) { - if (!(pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339)) { - continue; - } - - // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); - if (staProtocol == null) { - continue; - } else { - staProtocol = staProtocol.clone(); - } - if (staProtocol.isAutoing() - && staProtocol.isLoading() - && staProtocol.isInEnable() - && (staProtocol.getWorkNo() > 0) - && staProtocol.isPakMk()){ - - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 + try { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鎷f枡鍏ュ簱鍙� + for (DevpSlave.Sta pickSta : devp.getPickInSta()) { + if (!(pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339)) { continue; } - if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) - || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { + // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); + if (staProtocol == null) { continue; + } else { + staProtocol = staProtocol.clone(); } + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && (staProtocol.getWorkNo() > 0) + && staProtocol.isPakMk()) { - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - boolean flag = false; - String th = ""; - List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); - for (String loc : innerLoc) { - LocMast locMast = locMastService.selectById(loc); - if (locMast == null) { + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); + if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 continue; } - if (!locMast.getLocSts().equals("F")) { - flag = true; - th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; - break; + if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { + continue; } - } - if (flag) { - News.info(th); - continue; - } - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� - if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { - News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); - continue; - } + //*********************鍚屽簱浣嶇粍鏍¢獙********************* + boolean flag = false; + String th = ""; + List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); + for (String loc : innerLoc) { + LocMast locMast = locMastService.selectById(loc); + if (locMast == null) { + continue; + } - String sourceLocNo = wrkMast.getSourceLocNo().trim(); - LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 - if (liftStaProtocol == null) { - continue; - } + if (!locMast.getLocSts().equals("F")) { + flag = true; + th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; + break; + } + } + if (flag) { + News.info(th); + continue; + } + //*********************鍚屽簱浣嶇粍鏍¢獙********************* - // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� - wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 - wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 - wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯 + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { + News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); + continue; + } + + String sourceLocNo = wrkMast.getSourceLocNo().trim(); + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 + if (liftStaProtocol == null) { + continue; + } + + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54,107->57 + wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 + wrkMast.setSourceStaNo(pickSta.getBackSta()); // 婧愮珯 // wrkMast.setStaNo(dto.getStaNo()); // 鐩爣绔� // wrkMast.setCrnNo(dto.getCrnNo()); - wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� - wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� - wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� - wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� - wrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(wrkMast) == 0) { - News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); - continue; - } + wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� + wrkMast.setLocNo(sourceLocNo); // 鐩爣搴撲綅 = 鍑哄簱鏃剁殑婧愬簱浣� + wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� + wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� + wrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) == 0) { + News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + continue; + } - // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� - LocMast locMast = locMastService.selectById(sourceLocNo); - locMast.setLocSts("Q"); - locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)) { - News.info("淇敼搴撲綅鐘舵�佸け璐�"); - continue; - } + // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� + LocMast locMast = locMastService.selectById(sourceLocNo); + locMast.setLocSts("Q"); + locMast.setModiTime(new Date()); + if (!locMastService.updateById(locMast)) { + News.info("淇敼搴撲綅鐘舵�佸け璐�"); + continue; + } - staProtocol.setStaNo(pickSta.getBackSta().shortValue());//鍐欏叆鐩爣绔� - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + staProtocol.setStaNo(pickSta.getBackSta().shortValue());//鍐欏叆鐩爣绔� + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + } } - } + } + } catch (Exception e) { + e.printStackTrace(); } } @@ -621,119 +629,123 @@ */ @Transactional public synchronized void stnToCrnStnPlate(){ - for (DevpSlave devp : slaveProperties.getDevp()) { - // 閬嶅巻鎷f枡鍏ュ簱鍙� - for (DevpSlave.Sta pickSta : devp.getPickInSta()) { + try { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻鎷f枡鍏ュ簱鍙� + for (DevpSlave.Sta pickSta : devp.getPickInSta()) { // if (pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339) { // continue; // } - // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); - if (staProtocol == null) { - continue; - } else { - staProtocol = staProtocol.clone(); - } - if (staProtocol.isAutoing() - && staProtocol.isLoading() - && staProtocol.isInEnable() - && (staProtocol.getWorkNo() > 0) - && staProtocol.isPakMk()){ - - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 + // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); + if (staProtocol == null) { continue; + } else { + staProtocol = staProtocol.clone(); } + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && (staProtocol.getWorkNo() > 0) + && staProtocol.isPakMk()) { - if ((wrkMast.getIoType() != 107) - || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) { - continue; - } - - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - boolean flag = false; - String th = ""; - List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); - for (String loc : innerLoc) { - LocMast locMast = locMastService.selectById(loc); - if (locMast == null) { + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); + if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 continue; } - if (!locMast.getLocSts().equals("F")) { - flag = true; - th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; - break; + if ((wrkMast.getIoType() != 107) + || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { + continue; } - } - if (flag) { - News.info(th); - continue; - } - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� - if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { - News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); - continue; - } - - //鐩樼偣鎵炬柊搴撲綅 - try { - LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//婧愬簱浣� - SearchLocParam param = new SearchLocParam(); - param.setWrkNo(wrkMast.getWrkNo()); - param.setBarcode(wrkMast.getBarcode()); - param.setIoType(107);//鐩樼偣 - param.setSourceStaNo(wrkMast.getStaNo()); - param.setLocType1(locMast.getLocType1()); - String response = new HttpHandler.Builder() - .setUri(wmsUrl) - .setPath("/rpc/pakin/loc/v1") - .setJson(JSON.toJSONString(param)) - .build() - .doPost(); - JSONObject jsonObject = JSON.parseObject(response); - Integer code = jsonObject.getInteger("code"); - if (code.equals(200)) { - StartupDto dto = jsonObject.getObject("data", StartupDto.class); - - //鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 - LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); - if (liftStaProtocol == null) { - News.info(wrkMast.getWrkNo() + "鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯澶辫触"); + //*********************鍚屽簱浣嶇粍鏍¢獙********************* + boolean flag = false; + String th = ""; + List<String> innerLoc = Utils.getGroupInnerLoc(wrkMast.getSourceLocNo()); + for (String loc : innerLoc) { + LocMast locMast = locMastService.selectById(loc); + if (locMast == null) { continue; } - // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� - wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 107->57 - wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 - wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 婧愮珯 - wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� - wrkMast.setLocNo(dto.getLocNo()); // 鐩爣搴撲綅 - wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� - wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� - wrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(wrkMast) == 0) { - News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); - continue; + if (!locMast.getLocSts().equals("F")) { + flag = true; + th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; + break; } - - staProtocol.setStaNo(dto.getSourceStaNo().shortValue());//鍐欏叆鐩爣绔� - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - - } else if (code == 500){ - News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } - } catch (Exception e) { - e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - } + if (flag) { + News.info(th); + continue; + } + //*********************鍚屽簱浣嶇粍鏍¢獙********************* + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { + News.info(wrkMast.getWrkNo() + "淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); + continue; + } + + //鐩樼偣鎵炬柊搴撲綅 + try { + LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//婧愬簱浣� + SearchLocParam param = new SearchLocParam(); + param.setWrkNo(wrkMast.getWrkNo()); + param.setBarcode(wrkMast.getBarcode()); + param.setIoType(107);//鐩樼偣 + param.setSourceStaNo(wrkMast.getStaNo()); + param.setLocType1(locMast.getLocType1()); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/pakin/loc/v1") + .setJson(JSON.toJSONString(param)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) { + StartupDto dto = jsonObject.getObject("data", StartupDto.class); + + //鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); + if (liftStaProtocol == null) { + News.info(wrkMast.getWrkNo() + "鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯澶辫触"); + continue; + } + + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 107->57 + wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵��: 2.璁惧涓婅蛋 + wrkMast.setSourceStaNo(dto.getSourceStaNo()); // 婧愮珯 + wrkMast.setStaNo(liftStaProtocol.getStaNo());//鐩爣绔� + wrkMast.setLocNo(dto.getLocNo()); // 鐩爣搴撲綅 + wrkMast.setShuttleNo(null); // 绌挎杞︽竻绌� + wrkMast.setLiftNo(null);// 鎻愬崌鏈烘竻绌� + wrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) == 0) { + News.info(wrkMast.getWrkNo() + "鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + continue; + } + + staProtocol.setStaNo(dto.getSourceStaNo().shortValue());//鍐欏叆鐩爣绔� + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + + } else if (code == 500) { + News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + + } } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -975,31 +987,35 @@ * 鍒濆鍖栧疄鏃跺湴鍥� */ public synchronized void initRealtimeBasMap() { - for (int i = 1; i <= 10; i++) {//鎬诲叡鍥涘眰妤� - Object data = redisUtil.get(RedisKeyType.MAP.key + i); - if (data == null) {//redis鍦板浘鏁版嵁涓虹┖锛屼粠鏁版嵁搴撲腑鑾峰彇 - BasMap basMap = basMapService.selectLatestMap(i); - if (basMap == null) { - //鏁版嵁搴撲腑涔熶笉瀛樺湪鍦板浘鏁版嵁锛屼粠鍦板浘鏂囦欢涓幏鍙� - //杞藉叆鍦板浘 - NavigateMapData mapData = new NavigateMapData(i); - List<List<MapNode>> lists = mapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱) + try { + for (int i = 1; i <= 10; i++) {//鎬诲叡鍥涘眰妤� + Object data = redisUtil.get(RedisKeyType.MAP.key + i); + if (data == null) {//redis鍦板浘鏁版嵁涓虹┖锛屼粠鏁版嵁搴撲腑鑾峰彇 + BasMap basMap = basMapService.selectLatestMap(i); + if (basMap == null) { + //鏁版嵁搴撲腑涔熶笉瀛樺湪鍦板浘鏁版嵁锛屼粠鍦板浘鏂囦欢涓幏鍙� + //杞藉叆鍦板浘 + NavigateMapData mapData = new NavigateMapData(i); + List<List<MapNode>> lists = mapData.getJsonData(-1, null, null);//鑾峰彇瀹屾暣鍦板浘(鍖呮嫭鍏ュ簱鍑哄簱) - //瀛樺叆鏁版嵁搴� - basMap = new BasMap(); - basMap.setData(JSON.toJSONString(lists)); - basMap.setCreateTime(new Date()); - basMap.setUpdateTime(new Date()); - basMap.setLev(i); + //瀛樺叆鏁版嵁搴� + basMap = new BasMap(); + basMap.setData(JSON.toJSONString(lists)); + basMap.setCreateTime(new Date()); + basMap.setUpdateTime(new Date()); + basMap.setLev(i); - if (!basMapService.insert(basMap)) { - log.info("鍦板浘鏁版嵁瀛樺偍澶辫触"); + if (!basMapService.insert(basMap)) { + log.info("鍦板浘鏁版嵁瀛樺偍澶辫触"); + } } - } - //灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis - redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); + //灏嗘暟鎹簱鍦板浘鏁版嵁瀛樺叆redis + redisUtil.set(RedisKeyType.MAP.key + i, JSON.toJSONString(basMap)); + } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -1063,30 +1079,34 @@ * 鍏ュ簱 ===>> 鍥涘悜绌挎杞﹀叆搴撲綔涓氫笅鍙� */ public synchronized void shuttleInExecute() { - List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4(); - for (WrkMast wrkMast : wrkMasts) { - //鑾峰彇婧愮珯 - BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); - if (sourceBasDevp == null) { - continue;//绔欑偣涓嶅瓨鍦� - } + try { + List<WrkMast> wrkMasts = wrkMastMapper.selectInStep4(); + for (WrkMast wrkMast : wrkMasts) { + //鑾峰彇婧愮珯 + BasDevp sourceBasDevp = basDevpService.selectById(wrkMast.getSourceStaNo()); + if (sourceBasDevp == null) { + continue;//绔欑偣涓嶅瓨鍦� + } - //鑾峰彇鐩爣绔� - LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); - if (liftStaProtocol == null) { - continue;//绔欑偣涓嶅瓨鍦� - } + //鑾峰彇鐩爣绔� + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(sourceBasDevp.getLiftNo(), Utils.getLev(wrkMast.getLocNo())); + if (liftStaProtocol == null) { + continue;//绔欑偣涓嶅瓨鍦� + } - // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢锛岃嚜鍔ㄣ�佺┖闂层�佹湁鐗� - if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { - News.info("{}浠诲姟锛岃緭閫佺珯鐐圭姸鎬佷笉婊¤冻鍏ュ簱銆傝緭閫佺珯鐐�:{}", wrkMast.getWrkNo(), JSON.toJSONString(liftStaProtocol)); - continue; - } + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢锛岃嚜鍔ㄣ�佺┖闂层�佹湁鐗� + if (!(liftStaProtocol.getModel() && !liftStaProtocol.getBusy() && liftStaProtocol.getHasTray())) { + News.info("{}浠诲姟锛岃緭閫佺珯鐐圭姸鎬佷笉婊¤冻鍏ュ簱銆傝緭閫佺珯鐐�:{}", wrkMast.getWrkNo(), JSON.toJSONString(liftStaProtocol)); + continue; + } - boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//灏忚溅鎼叆搴撲腑 - if (!step1) { - continue; + boolean step1 = this.shuttleInExecuteStep1(wrkMast, liftStaProtocol);//灏忚溅鎼叆搴撲腑 + if (!step1) { + continue; + } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -1212,11 +1232,15 @@ * 鍑哄簱 ===>> 鍥涘悜绌挎杞﹀嚭搴撲綔涓氫笅鍙� */ public synchronized void shuttleOutExecute() { - for (WrkMast wrkMast : wrkMastMapper.selectBy2125()) { - boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//灏忚溅鎼嚭搴撲腑 - if (!step1) { - continue; + try { + for (WrkMast wrkMast : wrkMastMapper.selectBy2125()) { + boolean step1 = this.shuttleOutExecuteStep1(wrkMast);//灏忚溅鎼嚭搴撲腑 + if (!step1) { + continue; + } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -1363,106 +1387,110 @@ * 鍥涘悜绌挎杞︿换鍔″畬鎴� */ public synchronized void shuttleFinished() { - for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { - //鑾峰彇鍥涘悜绌挎杞︿俊鎭� - NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); - NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); - if (shuttleProtocol == null) { - continue; - } + try { + for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { + //鑾峰彇鍥涘悜绌挎杞︿俊鎭� + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; + } - //鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭銆佸皬杞﹀浜庣┖闂茬姸鎬� - if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //浠诲姟瀹屾垚绛夊緟纭 - && shuttleProtocol.getTaskNo() != 0 - && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id - ) { - //灏嗕换鍔℃。鏍囪涓哄畬鎴� - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); - if (wrkMast != null) { - switch (wrkMast.getWrkSts().intValue()) { - case 5://5.灏忚溅鎼繍涓� ==> 9.鍏ュ簱瀹屾垚 - wrkMast.setWrkSts(9L); - shuttleProtocol.setTaskNo(0); - if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { - //閲婃斁灏忚溅浠ょ墝 - shuttleProtocol.setToken(0); - } - break; - case 22://22.灏忚溅鎼繍涓� ==> 23.灏忚溅鎼繍瀹屾垚 - wrkMast.setWrkSts(23L); - shuttleProtocol.setTaskNo(0); - if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { - //閲婃斁灏忚溅浠ょ墝 - shuttleProtocol.setToken(0); - } - break; - case 102://102.灏忚溅绉诲姩鑷崇珯鐐� ==> 103.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� - wrkMast.setWrkSts(103L); - break; - case 104://104.灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 105.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� - wrkMast.setWrkSts(105L); - shuttleProtocol.setTaskNo(0);//娓呯悊宸ヤ綔鍙� - break; - case 108://108.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� - wrkMast.setWrkSts(109L); - break; - case 110://110.灏忚溅绉诲姩涓� ==> 111.灏忚溅绉诲姩瀹屾垚 - wrkMast.setWrkSts(111L); - shuttleProtocol.setTaskNo(0); - if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { - //閲婃斁灏忚溅浠ょ墝 - shuttleProtocol.setToken(0); - } - break; - default: - } - - if (wrkMastMapper.updateById(wrkMast) > 0) { - if (wrkMast.getWrkSts() == 111) { - // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� - if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) { - log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo()); - } - // 鍒犻櫎宸ヤ綔涓绘。 - if (!wrkMastService.deleteById(wrkMast)) { - log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo()); - } + //鍥涘悜绌挎杞︾姸鎬佷负绛夊緟纭銆佸皬杞﹀浜庣┖闂茬姸鎬� + if (shuttleProtocol.getProtocolStatus() == ShuttleProtocolStatusType.WAITING.id //浠诲姟瀹屾垚绛夊緟纭 + && shuttleProtocol.getTaskNo() != 0 + && shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id + ) { + //灏嗕换鍔℃。鏍囪涓哄畬鎴� + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(shuttleProtocol.getTaskNo()); + if (wrkMast != null) { + switch (wrkMast.getWrkSts().intValue()) { + case 5://5.灏忚溅鎼繍涓� ==> 9.鍏ュ簱瀹屾垚 + wrkMast.setWrkSts(9L); + shuttleProtocol.setTaskNo(0); + if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { + //閲婃斁灏忚溅浠ょ墝 + shuttleProtocol.setToken(0); + } + break; + case 22://22.灏忚溅鎼繍涓� ==> 23.灏忚溅鎼繍瀹屾垚 + wrkMast.setWrkSts(23L); + shuttleProtocol.setTaskNo(0); + if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { + //閲婃斁灏忚溅浠ょ墝 + shuttleProtocol.setToken(0); + } + break; + case 102://102.灏忚溅绉诲姩鑷崇珯鐐� ==> 103.灏忚溅绉诲姩鑷崇珯鐐瑰畬鎴� + wrkMast.setWrkSts(103L); + break; + case 104://104.灏忚溅杩佸叆鎻愬崌鏈轰腑 ==> 105.灏忚溅杩佸叆鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(105L); + shuttleProtocol.setTaskNo(0);//娓呯悊宸ヤ綔鍙� + break; + case 108://108.灏忚溅杩佸嚭鎻愬崌鏈轰腑 ==> 109.灏忚溅杩佸嚭鎻愬崌鏈哄畬鎴� + wrkMast.setWrkSts(109L); + break; + case 110://110.灏忚溅绉诲姩涓� ==> 111.灏忚溅绉诲姩瀹屾垚 + wrkMast.setWrkSts(111L); + shuttleProtocol.setTaskNo(0); + if (shuttleProtocol.getToken().equals(wrkMast.getWrkNo())) { + //閲婃斁灏忚溅浠ょ墝 + shuttleProtocol.setToken(0); + } + break; + default: } - //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� - shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); - //婧愬簱浣嶆竻闆� - shuttleProtocol.setSourceLocNo(null); - //鐩爣搴撲綅娓呴浂 - shuttleProtocol.setLocNo(null); - //浠诲姟鎸囦护娓呴浂 - shuttleProtocol.setAssignCommand(null); - News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); + if (wrkMastMapper.updateById(wrkMast) > 0) { + if (wrkMast.getWrkSts() == 111) { + // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� + if (wrkMastLocMapper.save(wrkMast.getWrkNo()) <= 0) { + log.info("淇濆瓨宸ヤ綔鍘嗗彶妗workNo={0}]澶辫触", wrkMast.getWrkNo()); + } + // 鍒犻櫎宸ヤ綔涓绘。 + if (!wrkMastService.deleteById(wrkMast)) { + log.info("鍒犻櫎宸ヤ綔涓绘。[workNo={0}]澶辫触", wrkMast.getWrkNo()); + } + } + + //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� + shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); + //婧愬簱浣嶆竻闆� + shuttleProtocol.setSourceLocNo(null); + //鐩爣搴撲綅娓呴浂 + shuttleProtocol.setLocNo(null); + //浠诲姟鎸囦护娓呴浂 + shuttleProtocol.setAssignCommand(null); + News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); + } else { + News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); + } } else { - News.error("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傚洓鍚戠┛姊溅鍙�={}锛屽伐浣滃彿={}", shuttleProtocol.getShuttleNo(), shuttleProtocol.getTaskNo()); + ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand(); + if (!assignCommand.getAuto()) { + //鎵嬪姩妯″紡 + //宸ヤ綔鍙锋竻闆� + shuttleProtocol.setTaskNo(0); + //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� + shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); + //婧愬簱浣嶆竻闆� + shuttleProtocol.setSourceLocNo(null); + //鐩爣搴撲綅娓呴浂 + shuttleProtocol.setLocNo(null); + //浠诲姟鎸囦护娓呴浂 + shuttleProtocol.setAssignCommand(null); + //娓呴浂浠ょ墝 + shuttleProtocol.setToken(0); + News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); + } } - }else { - ShuttleAssignCommand assignCommand = shuttleProtocol.getAssignCommand(); - if (!assignCommand.getAuto()) { - //鎵嬪姩妯″紡 - //宸ヤ綔鍙锋竻闆� - shuttleProtocol.setTaskNo(0); - //璁剧疆鍥涘悜绌挎杞︿负绌洪棽鐘舵�� - shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); - //婧愬簱浣嶆竻闆� - shuttleProtocol.setSourceLocNo(null); - //鐩爣搴撲綅娓呴浂 - shuttleProtocol.setLocNo(null); - //浠诲姟鎸囦护娓呴浂 - shuttleProtocol.setAssignCommand(null); - //娓呴浂浠ょ墝 - shuttleProtocol.setToken(0); - News.info("鍥涘悜绌挎杞﹀凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅銆傚洓鍚戠┛姊溅鍙�={}", shuttleProtocol.getShuttleNo()); - } + } } - + } catch (Exception e) { + e.printStackTrace(); } } @@ -1470,52 +1498,56 @@ * 鎻愬崌鏈轰换鍔� */ public synchronized void liftIoExecute() { - for (LiftSlave liftSlave : slaveProperties.getLift()) { - LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); - if (liftThread == null) { - continue; - } - LiftProtocol liftProtocol = liftThread.getLiftProtocol(); - if (liftProtocol == null) { - continue; - } - - if (!liftProtocol.isIdle()) { - News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftSlave.getId()); - continue; - } - - //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚﹁鍗犵敤 - if (liftProtocol.getToken() != 0) { - News.info("{}鍙锋彁鍗囨満锛屼护鐗屽凡琚嫭鍗�", liftSlave.getId()); - continue; - } - - //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� - List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103(); - if (wrkMasts.isEmpty()) { - continue; - } - - for (WrkMast wrkMast : wrkMasts) { - //鎼滅储鏄惁鏈夊叾浠栦换鍔″崰鐢ㄤ簡鎻愬崌鏈猴紝濡傛灉鍗犵敤鎻愬崌鏈虹殑浠诲姟鍜屽綋鍓嶄换鍔$浉鍚岋紝鍒欒繍琛屾墽琛� - WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); - if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { - News.info("{}鍙锋彁鍗囨満锛岃鍏朵粬浠诲姟{}鍗犵敤涓斿拰褰撳墠浠诲姟{}涓嶇浉鍚岋紝绂佹娲惧彂", liftSlave.getId(), wrkMast1.getWrkNo(), wrkMast.getWrkNo()); + try { + for (LiftSlave liftSlave : slaveProperties.getLift()) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + if (liftThread == null) { + continue; + } + LiftProtocol liftProtocol = liftThread.getLiftProtocol(); + if (liftProtocol == null) { continue; } - boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//鎻愬崌鏈哄叆搴� - if (!stepIn) { + if (!liftProtocol.isIdle()) { + News.info("{}鍙锋彁鍗囨満锛屽繖纰屼腑", liftSlave.getId()); continue; } - boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//鎻愬崌鏈哄嚭搴� - if (!stepOut) { + //鍒ゆ柇鎻愬崌鏈轰护鐗屾槸鍚﹁鍗犵敤 + if (liftProtocol.getToken() != 0) { + News.info("{}鍙锋彁鍗囨満锛屼护鐗屽凡琚嫭鍗�", liftSlave.getId()); continue; } + + //鎼滅储鏄惁鏈夊緟澶勭悊鐨勪换鍔� + List<WrkMast> wrkMasts = wrkMastMapper.selectLiftStep223103(); + if (wrkMasts.isEmpty()) { + continue; + } + + for (WrkMast wrkMast : wrkMasts) { + //鎼滅储鏄惁鏈夊叾浠栦换鍔″崰鐢ㄤ簡鎻愬崌鏈猴紝濡傛灉鍗犵敤鎻愬崌鏈虹殑浠诲姟鍜屽綋鍓嶄换鍔$浉鍚岋紝鍒欒繍琛屾墽琛� + WrkMast wrkMast1 = wrkMastMapper.selectLiftWrkMast(liftProtocol.getLiftNo().intValue()); + if (wrkMast1 != null && wrkMast1.getWrkNo().intValue() != wrkMast.getWrkNo().intValue()) { + News.info("{}鍙锋彁鍗囨満锛岃鍏朵粬浠诲姟{}鍗犵敤涓斿拰褰撳墠浠诲姟{}涓嶇浉鍚岋紝绂佹娲惧彂", liftSlave.getId(), wrkMast1.getWrkNo(), wrkMast.getWrkNo()); + continue; + } + + boolean stepIn = this.liftIoExecuteStepIn(wrkMast);//鎻愬崌鏈哄叆搴� + if (!stepIn) { + continue; + } + + boolean stepOut = this.liftIoExecuteStepOut(wrkMast);//鎻愬崌鏈哄嚭搴� + if (!stepOut) { + continue; + } + } + } - + } catch (Exception e) { + e.printStackTrace(); } } @@ -1775,85 +1807,89 @@ * 鎻愬崌鏈轰换鍔″畬鎴� */ public synchronized void liftFinished() { - for (LiftSlave liftSlave : slaveProperties.getLift()) { - //鑾峰彇鎻愬崌鏈轰俊鎭� - LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); - LiftProtocol liftProtocol = liftThread.getLiftProtocol(); - if (liftProtocol == null) { - continue; - } - - //鎻愬崌鏈轰负绛夊緟纭涓旂┖闂� - if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id - && liftProtocol.getTaskNo() != 0 - && !liftProtocol.getBusy() - ) { - BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString()); - int taskNo = liftProtocol.getTaskNo().intValue(); - if (basLiftOpt != null) { - taskNo = basLiftOpt.getWrkNo(); + try { + for (LiftSlave liftSlave : slaveProperties.getLift()) { + //鑾峰彇鎻愬崌鏈轰俊鎭� + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, liftSlave.getId()); + LiftProtocol liftProtocol = liftThread.getLiftProtocol(); + if (liftProtocol == null) { + continue; } - //灏嗕换鍔℃。鏍囪涓哄畬鎴� - WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); - if (wrkMast != null) { - switch (wrkMast.getWrkSts().intValue()) { - case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴� - wrkMast.setWrkSts(4L); - wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� - if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { - //閲婃斁鎻愬崌鏈轰护鐗� - liftProtocol.setToken(0); - } - break; - case 24://24.鎻愬崌鏈烘惉杩愪腑 ==> 25.鎻愬崌鏈烘惉杩愬畬鎴� - wrkMast.setWrkSts(25L); - if (wrkMast.getIoType() == 11) {//搴撲綅绉昏浆 - wrkMast.setWrkSts(4L);//4.鎻愬崌鏈烘惉杩愬畬鎴� - }else { - if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { - //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚 - wrkMast.setWrkSts(29L); - wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 - wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + //鎻愬崌鏈轰负绛夊緟纭涓旂┖闂� + if (liftProtocol.getProtocolStatus() == LiftProtocolStatusType.WAITING.id + && liftProtocol.getTaskNo() != 0 + && !liftProtocol.getBusy() + ) { + BasLiftOpt basLiftOpt = basLiftOptService.selectByDeviceWrk(liftProtocol.getTaskNo().toString()); + int taskNo = liftProtocol.getTaskNo().intValue(); + if (basLiftOpt != null) { + taskNo = basLiftOpt.getWrkNo(); + } + + //灏嗕换鍔℃。鏍囪涓哄畬鎴� + WrkMast wrkMast = wrkMastMapper.selectByWorkNo324104(taskNo); + if (wrkMast != null) { + switch (wrkMast.getWrkSts().intValue()) { + case 3://3.鎻愬崌鏈烘惉杩愪腑 ==> 4.鎻愬崌鏈烘惉杩愬畬鎴� + wrkMast.setWrkSts(4L); + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { + //閲婃斁鎻愬崌鏈轰护鐗� + liftProtocol.setToken(0); } - } + break; + case 24://24.鎻愬崌鏈烘惉杩愪腑 ==> 25.鎻愬崌鏈烘惉杩愬畬鎴� + wrkMast.setWrkSts(25L); + if (wrkMast.getIoType() == 11) {//搴撲綅绉昏浆 + wrkMast.setWrkSts(4L);//4.鎻愬崌鏈烘惉杩愬畬鎴� + } else { + if (wrkMast.getMk() == null || !wrkMast.getMk().equals("Y")) { + //涓嶉渶瑕佺敤鍒版満姊拌噦锛岀洿鎺ヨ浆29.鍑哄簱瀹屾垚 + wrkMast.setWrkSts(29L); + wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + } + } - if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { - //閲婃斁鎻愬崌鏈轰护鐗� - liftProtocol.setToken(0); - } + if (liftProtocol.getToken().equals(wrkMast.getWrkNo())) { + //閲婃斁鎻愬崌鏈轰护鐗� + liftProtocol.setToken(0); + } - break; - case 106://106.鎻愬崌鏈烘惉杩愪腑 ==> 107.鎻愬崌鏈烘惉杩愬畬鎴� - wrkMast.setWrkSts(107L); - break; - default: - } + break; + case 106://106.鎻愬崌鏈烘惉杩愪腑 ==> 107.鎻愬崌鏈烘惉杩愬畬鎴� + wrkMast.setWrkSts(107L); + break; + default: + } - if (wrkMastMapper.updateById(wrkMast) > 0) { - //璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵�� - liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); - //浠诲姟鎸囦护娓呴浂 - liftProtocol.setAssignCommand(null); - News.info("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬併�傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); - } else { - News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); - } - }else { - LiftAssignCommand assignCommand = liftProtocol.getAssignCommand(); - if (assignCommand != null) { - if (!assignCommand.getAuto()) { - //鎵嬪姩鎿嶄綔 + if (wrkMastMapper.updateById(wrkMast) > 0) { //璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵�� liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); //浠诲姟鎸囦护娓呴浂 liftProtocol.setAssignCommand(null); - News.info("鎻愬崌鏈哄凡纭鎵嬪姩鎿嶄綔銆傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); + News.info("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬併�傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); + } else { + News.error("鎻愬崌鏈哄凡纭涓斾换鍔″畬鎴愮姸鎬�,澶嶄綅澶辫触锛屼絾鏈壘鍒板伐浣滄。銆傛彁鍗囨満鍙�={}锛屽伐浣滃彿={}", liftProtocol.getLiftNo(), liftProtocol.getTaskNo()); + } + } else { + LiftAssignCommand assignCommand = liftProtocol.getAssignCommand(); + if (assignCommand != null) { + if (!assignCommand.getAuto()) { + //鎵嬪姩鎿嶄綔 + //璁剧疆鎻愬崌鏈轰负绌洪棽鐘舵�� + liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); + //浠诲姟鎸囦护娓呴浂 + liftProtocol.setAssignCommand(null); + News.info("鎻愬崌鏈哄凡纭鎵嬪姩鎿嶄綔銆傛彁鍗囨満鍙�={}", liftProtocol.getLiftNo()); + } } } } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -1861,40 +1897,44 @@ * 搴撲綅绉昏浆 */ public synchronized void locToLocExecute() { - //鑾峰彇鍑哄叆搴撳伐浣滄。 + try { + //鑾峰彇鍑哄叆搴撳伐浣滄。 // List<WrkMast> wrkMasts = wrkMastMapper.selectInOutWrkMast(); // if (wrkMasts.size() > 0) { // //鏈夊嚭鍏ュ簱浠诲姟锛屽繀椤荤瓑寰呬换鍔℃墽琛屽畬姣曞啀鎵ц搴撲綅绉昏浆 // return; // } - //鏌ヨ搴撲綅绉昏浆宸ヤ綔妗� - List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); - for (WrkMast wrkMast : wrkMasts1) { - if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { - boolean step1 = this.locToLocExecuteStep1(wrkMast);//鍚屾ゼ灞傚簱浣嶇Щ杞� - if (!step1) { - continue; - } - }else { - //璺ㄦゼ灞傚簱浣嶇Щ杞� - boolean step2 = this.locToLocExecuteStep2(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙� - if (!step2) { - continue; - } + //鏌ヨ搴撲綅绉昏浆宸ヤ綔妗� + List<WrkMast> wrkMasts1 = wrkMastMapper.selectLocToLocWrkMast(); + for (WrkMast wrkMast : wrkMasts1) { + if (Utils.getLev(wrkMast.getSourceLocNo()) == Utils.getLev(wrkMast.getLocNo())) { + boolean step1 = this.locToLocExecuteStep1(wrkMast);//鍚屾ゼ灞傚簱浣嶇Щ杞� + if (!step1) { + continue; + } + } else { + //璺ㄦゼ灞傚簱浣嶇Щ杞� + boolean step2 = this.locToLocExecuteStep2(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鍑哄簱鍙� + if (!step2) { + continue; + } - boolean step3 = this.locToLocExecuteStep3(wrkMast);//鎻愬崌鏈烘惉杩愯揣鐗� - if (!step3) { - continue; - } + boolean step3 = this.locToLocExecuteStep3(wrkMast);//鎻愬崌鏈烘惉杩愯揣鐗� + if (!step3) { + continue; + } - boolean step4 = this.locToLocExecuteStep4(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鐩爣搴撲綅 - if (!step4) { - continue; + boolean step4 = this.locToLocExecuteStep4(wrkMast);//璋冨害杞﹁締鍙栬揣骞惰繍閫佸埌鐩爣搴撲綅 + if (!step4) { + continue; + } + } } - + } catch (Exception e) { + e.printStackTrace(); } } @@ -2407,68 +2447,69 @@ * 绌烘爤鏉垮垵濮嬪寲鍏ュ簱,鍙夎溅鍏ュ簱绔欐斁璐� */ public void storeEmptyPlt(){ - for (DevpSlave devp : slaveProperties.getDevp()) { - // 閬嶅巻绌烘澘鍏ュ簱鍙� - for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { - // 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); - if (staProtocol == null) { - continue; - } else { - staProtocol = staProtocol.clone(); - } - // 绔欑偣鏉′欢鍒ゆ柇 - if (staProtocol.isAutoing() - && staProtocol.isLoading() - && staProtocol.isInEnable() - && staProtocol.isEmptyMk() - && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) - && staProtocol.isPakMk()) { + try { + for (DevpSlave devp : slaveProperties.getDevp()) { + // 閬嶅巻绌烘澘鍏ュ簱鍙� + for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) { + // 鑾峰彇绌烘澘鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(emptyInSta.getStaNo()); + if (staProtocol == null) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + // 绔欑偣鏉′欢鍒ゆ柇 + if (staProtocol.isAutoing() + && staProtocol.isLoading() + && staProtocol.isInEnable() + && staProtocol.isEmptyMk() + && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 || staProtocol.getWorkNo() <= 9999)) + && staProtocol.isPakMk()) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - String barcode = null; - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); - if (barcodeThread != null) { - String barcode0 = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode0)) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + String barcode = null; + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, emptyInSta.getBarcode()); + if (barcodeThread != null) { + String barcode0 = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode0)) { // News.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode0); - if(!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { - barcode = barcode0; + if (!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { + barcode = barcode0; + } } } - } - if (!Cools.isEmpty(barcode)) { - WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//鏉$爜瀛樺湪宸ヤ綔妗� - if (wrkMast != null) { - continue; - } - } - - LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); - - try { - LocTypeDto locTypeDto = new LocTypeDto(staProtocol); - - SearchLocParam param = new SearchLocParam(); - param.setIoType(10); if (!Cools.isEmpty(barcode)) { - param.setBarcode(barcode); + WrkMast wrkMast = wrkMastMapper.selectByBarcode(barcode);//鏉$爜瀛樺湪宸ヤ綔妗� + if (wrkMast != null) { + continue; + } } - param.setSourceStaNo(emptyInSta.getStaNo()); + + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, emptyInSta.getLed()); + + try { + LocTypeDto locTypeDto = new LocTypeDto(staProtocol); + + SearchLocParam param = new SearchLocParam(); + param.setIoType(10); + if (!Cools.isEmpty(barcode)) { + param.setBarcode(barcode); + } + param.setSourceStaNo(emptyInSta.getStaNo()); // param.setLocType1(locTypeDto.getLocType1()); - String response = new HttpHandler.Builder() - .setUri(wmsUrl) - .setPath("/rpc/pakin/loc/v1") - .setJson(JSON.toJSONString(param)) - .build() - .doPost(); - JSONObject jsonObject = JSON.parseObject(response); - Integer code = jsonObject.getInteger("code"); - if (code.equals(200)) { - StartupDto dto = jsonObject.getObject("data", StartupDto.class); - barcodeThread.setBarcode(""); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/pakin/loc/v1") + .setJson(JSON.toJSONString(param)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) { + StartupDto dto = jsonObject.getObject("data", StartupDto.class); + barcodeThread.setBarcode(""); // // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 // staProtocol.setWorkNo(dto.getWorkNo().shortValue()); // staProtocol.setStaNo(dto.getStaNo().shortValue()); @@ -2477,24 +2518,27 @@ // if (!result) { // throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); // } - } else { - if (ledThread != null) { - String errorMsg = jsonObject.getString("msg"); - if (!Cools.isEmpty(errorMsg)) { - MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); + } else { + if (ledThread != null) { + String errorMsg = jsonObject.getString("msg"); + if (!Cools.isEmpty(errorMsg)) { + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); + } } + News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } - News.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - } catch (Exception e) { - e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } - - } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2502,75 +2546,76 @@ * AGV琛ヨ揣 => 鐢熸垚鍏ュ簱閫氱煡妗� */ public void robotGenerateAgvTask() { -//妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 - for (DevpSlave devp : slaveProperties.getDevp()) { - // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(300); - if (staProtocol == null) { - continue; - } - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { - //鏌ヨ鏄惁鏈夊伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - if (wrkMast == null) { + try { + //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 + for (DevpSlave devp : slaveProperties.getDevp()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(300); + if (staProtocol == null) { continue; } - - if (wrkMast.getWrkSts() != 25) {//25.鎻愬崌鏈烘惉杩愬畬鎴� - continue; - } - - if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//鏍囪涓篩琛ㄧず闇�瑕佺敤鍒版満姊拌噦鎷f枡 - Short targetSta = null;//鐩爣绔� - //鍒ゆ柇鏈烘鑷傛嫞鏂欑珯鏄惁绌洪棽 - StaProtocol staProtocol303 = devpThread.getStation().get(303); - StaProtocol staProtocol317 = devpThread.getStation().get(317); - if (staProtocol303.isAutoing() && !staProtocol303.isLoading()) { - //鑷姩銆佹棤鐗� - targetSta = (short) 303; - } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) { - //鑷姩銆佹棤鐗� - targetSta = (short) 317; - } else { - continue;//娌℃湁绌洪棽绔欑偣 + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { + //鏌ヨ鏄惁鏈夊伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); + if (wrkMast == null) { + continue; } - if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { - //鍚慉GV鍙戣捣缁勬墭璇锋眰 - try { - HashMap<String, Object> param = new HashMap<>(); - param.put("wrkNo", wrkMast.getWrkNo()); - String response = new HttpHandler.Builder() - .setUri(wmsUrl) - .setPath("/rpc/replenishment") - .setJson(JSON.toJSONString(param)) - .build() - .doPost(); - JSONObject jsonObject = JSON.parseObject(response); - Integer code = jsonObject.getInteger("code"); - if (code.equals(200)) {//AGV缁勬墭鎴愬姛 - //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 - wrkMast.setStaNo(targetSta.intValue()); - wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 - wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� - if (wrkMastMapper.updateById(wrkMast) > 0) { - //鍚�300绔欏啓鍏ョ洰鏍囩珯 - staProtocol = staProtocol.clone(); - staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - try { - Thread.sleep(500); - } catch (Exception e) { - e.printStackTrace(); - } - continue; - } - } - } catch (Exception e) { - e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + if (wrkMast.getWrkSts() != 25) {//25.鎻愬崌鏈烘惉杩愬畬鎴� + continue; + } + + if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//鏍囪涓篩琛ㄧず闇�瑕佺敤鍒版満姊拌噦鎷f枡 + Short targetSta = null;//鐩爣绔� + //鍒ゆ柇鏈烘鑷傛嫞鏂欑珯鏄惁绌洪棽 + StaProtocol staProtocol303 = devpThread.getStation().get(303); + StaProtocol staProtocol317 = devpThread.getStation().get(317); + if (staProtocol303.isAutoing() && !staProtocol303.isLoading()) { + //鑷姩銆佹棤鐗� + targetSta = (short) 303; + } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading()) { + //鑷姩銆佹棤鐗� + targetSta = (short) 317; + } else { + continue;//娌℃湁绌洪棽绔欑偣 } + + if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) { + //鍚慉GV鍙戣捣缁勬墭璇锋眰 + try { + HashMap<String, Object> param = new HashMap<>(); + param.put("wrkNo", wrkMast.getWrkNo()); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/replenishment") + .setJson(JSON.toJSONString(param)) + .build() + .doPost(); + JSONObject jsonObject = JSON.parseObject(response); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) {//AGV缁勬墭鎴愬姛 + //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 + wrkMast.setStaNo(targetSta.intValue()); + wrkMast.setShuttleNo(null);//閲婃斁灏忚溅 + wrkMast.setLiftNo(null);//閲婃斁鎻愬崌鏈� + if (wrkMastMapper.updateById(wrkMast) > 0) { + //鍚�300绔欏啓鍏ョ洰鏍囩珯 + staProtocol = staProtocol.clone(); + staProtocol.setStaNo(targetSta);//绉诲姩鍒扮洰鏍囩珯 + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + try { + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } // //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 // wrkMast.setStaNo(targetSta.intValue()); @@ -2588,9 +2633,12 @@ // } // continue; // } + } } } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2598,54 +2646,58 @@ * AGV琛ヨ揣 => 鏈烘鑷傛嫞鏂� */ public void agvRestockByRobot() { - //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 - for (DevpSlave devp : slaveProperties.getDevp()) { - // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol303 = devpThread.getStation().get(303); - StaProtocol staProtocol317 = devpThread.getStation().get(317); - if (staProtocol303 == null || staProtocol317 == null) { - continue; - } - - if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { - //璋冨害鏈烘鑷� - //鏌ヨ鏄惁鏈夊伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue()); - if (wrkMast == null) { - continue; - } - List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); - if (wrkDetls.isEmpty()) { + try { + //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 + for (DevpSlave devp : slaveProperties.getDevp()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol303 = devpThread.getStation().get(303); + StaProtocol staProtocol317 = devpThread.getStation().get(317); + if (staProtocol303 == null || staProtocol317 == null) { continue; } - if (wrkMast.getInvWh() == null) { - wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔� - if (wrkMastMapper.updateById(wrkMast) > 0) { - RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303"); + if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) { + //璋冨害鏈烘鑷� + //鏌ヨ鏄惁鏈夊伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue()); + if (wrkMast == null) { + continue; + } + List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); + if (wrkDetls.isEmpty()) { + continue; + } + + if (wrkMast.getInvWh() == null) { + wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔� + if (wrkMastMapper.updateById(wrkMast) > 0) { + RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303"); + } + } + } + + if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) { + //璋冨害鏈烘鑷� + //鏌ヨ鏄惁鏈夊伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue()); + if (wrkMast == null) { + continue; + } + List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); + if (wrkDetls.isEmpty()) { + continue; + } + if (wrkMast.getInvWh() == null) { + wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔� + if (wrkMastMapper.updateById(wrkMast) > 0) { + RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317"); + } } } } - - if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) { - //璋冨害鏈烘鑷� - //鏌ヨ鏄惁鏈夊伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue()); - if (wrkMast == null) { - continue; - } - List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo()); - if (wrkDetls.isEmpty()) { - continue; - } - if (wrkMast.getInvWh() == null) { - wrkMast.setInvWh("Y");//鏍囪宸茬粡涓嬪彂鏈烘鑷備换鍔� - if (wrkMastMapper.updateById(wrkMast) > 0) { - RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317"); - } - } - } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2653,43 +2705,47 @@ * AGV琛ヨ揣(閫氱煡AGV鍙栬揣) */ public void agvRestockInto() { - //妫�娴�309鍜�312绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗� - for (DevpSlave devp : slaveProperties.getDevp()) { - // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol309 = devpThread.getStation().get(309); - StaProtocol staProtocol312 = devpThread.getStation().get(312); - if (staProtocol309 == null || staProtocol312 == null) { - continue; - } - - if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308绔欐潯鐮佸櫒 - if (barcodeThread == null) { + try { + //妫�娴�309鍜�312绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗� + for (DevpSlave devp : slaveProperties.getDevp()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol309 = devpThread.getStation().get(309); + StaProtocol staProtocol312 = devpThread.getStation().get(312); + if (staProtocol309 == null || staProtocol312 == null) { continue; } - String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - //閫氱煡AGV鍙栬揣 - agvRestockCall("301-1", barcode); - log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); - } - } - if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311绔欐潯鐮佸櫒 - if (barcodeThread == null) { - continue; + if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308绔欐潯鐮佸櫒 + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + //閫氱煡AGV鍙栬揣 + agvRestockCall("301-1", barcode); + log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); + } } - String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - //閫氱煡AGV鍙栬揣 - agvRestockCall("302-1", barcode); - log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); + + if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311绔欐潯鐮佸櫒 + if (barcodeThread == null) { + continue; + } + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + //閫氱煡AGV鍙栬揣 + agvRestockCall("302-1", barcode); + log.info("閫氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); + } } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2722,77 +2778,85 @@ * AGV琛ヨ揣(鎮寕绾块�氱煡AGV鍙栬揣) */ public void agvRestockIntoByHangingWire() { - //妫�娴�350鍜�351鎵爜鍣� - int[] barcodeStaNo = {11, 12};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒 - for (int staNo : barcodeStaNo) { - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); - if (barcodeThread == null) { - continue; - } - String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - if (barcode.contains("NoRead")) { + try { + //妫�娴�350鍜�351鎵爜鍣� + int[] barcodeStaNo = {11, 12};//11 => 350绔欐壂鐮佸櫒,12 => 351绔欐壂鐮佸櫒 + for (int staNo : barcodeStaNo) { + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo); + if (barcodeThread == null) { continue; } + String barcode = barcodeThread.getBarcode(); + if (!Cools.isEmpty(barcode)) { + if (barcode.contains("NoRead")) { + continue; + } - String agvStaNo = null; - if (staNo == 11) { - agvStaNo = "303-1"; - }else { - agvStaNo = "304-1"; + String agvStaNo = null; + if (staNo == 11) { + agvStaNo = "303-1"; + } else { + agvStaNo = "304-1"; + } + //閫氱煡AGV鍙栬揣 + boolean result = agvRestockCall(agvStaNo, barcode); + if (result) { + barcodeThread.setBarcode(""); + } + log.info(barcodeThread.getSlave().getId() + "鍙锋壂鐮佸櫒锛岄�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); } - //閫氱煡AGV鍙栬揣 - boolean result = agvRestockCall(agvStaNo, barcode); - if (result) { - barcodeThread.setBarcode(""); - } - log.info(barcodeThread.getSlave().getId() + "鍙锋壂鐮佸櫒锛岄�氱煡AGV鍙栬揣锛屾潯鐮佸彿锛�" + barcode); } + } catch (Exception e) { + e.printStackTrace(); } } // 300绔欐嫞鏂� public void pick300() { - //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 - for (DevpSlave devp : slaveProperties.getDevp()) { - // 鑾峰彇鍏ュ簱绔欎俊鎭� - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); - StaProtocol staProtocol = devpThread.getStation().get(300); - if (staProtocol == null) { - continue; - } - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { - //鏌ヨ鏄惁鏈夊伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - if (wrkMast == null) { + try { + //妫�娴�300绔欐槸鍚﹁嚜鍔ㄣ�佹湁鐗┿�佸伐浣滃彿 + for (DevpSlave devp : slaveProperties.getDevp()) { + // 鑾峰彇鍏ュ簱绔欎俊鎭� + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); + StaProtocol staProtocol = devpThread.getStation().get(300); + if (staProtocol == null) { continue; } + if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) { + //鏌ヨ鏄惁鏈夊伐浣滄。 + WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); + if (wrkMast == null) { + continue; + } - if (wrkMast.getWrkSts() != 29) {//29.鍑哄簱瀹屾垚 - continue; - } + if (wrkMast.getWrkSts() != 29) {//29.鍑哄簱瀹屾垚 + continue; + } - if (wrkMast.getMk() == null) { - Integer sourceStaNo = wrkMast.getSourceStaNo();//婧愮珯 - Integer staNo = wrkMast.getStaNo();//鐩爣绔� - //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 - wrkMast.setStaNo(sourceStaNo); - wrkMast.setSourceStaNo(staNo); - wrkMast.setMk("N"); - if (wrkMastMapper.updateById(wrkMast) > 0) { - //鍚�300绔欏啓鍏ョ洰鏍囩珯 - staProtocol = staProtocol.clone(); - staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//绉诲姩鍒扮洰鏍囩珯 - boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); - try { - Thread.sleep(500); - } catch (Exception e) { - e.printStackTrace(); + if (wrkMast.getMk() == null) { + Integer sourceStaNo = wrkMast.getSourceStaNo();//婧愮珯 + Integer staNo = wrkMast.getStaNo();//鐩爣绔� + //瑕嗙洊宸ヤ綔妗g洰鏍囩珯 + wrkMast.setStaNo(sourceStaNo); + wrkMast.setSourceStaNo(staNo); + wrkMast.setMk("N"); + if (wrkMastMapper.updateById(wrkMast) > 0) { + //鍚�300绔欏啓鍏ョ洰鏍囩珯 + staProtocol = staProtocol.clone(); + staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//绉诲姩鍒扮洰鏍囩珯 + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + try { + Thread.sleep(500); + } catch (Exception e) { + e.printStackTrace(); + } } } } } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2800,135 +2864,141 @@ * 鍑哄簱 ===>> 宸ヤ綔妗d俊鎭啓鍏ed鏄剧ず鍣� */ public void ledExecute() { - for (LedSlave led : slaveProperties.getLed()) { - // 鑾峰彇杈撻�佺嚎plc绾跨▼ - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); - // 鍛戒护闆嗗悎 - List<LedCommand> commands = new ArrayList<>(); - // 宸ヤ綔妗i泦鍚� - List<WrkMast> wrkMasts = new ArrayList<>(); - for (Integer staNo : led.getStaArr()) { - // 鑾峰彇鍙夎溅绔欑偣 - StaProtocol staProtocol = devpThread.getStation().get(staNo); - if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { - continue; - } else { - staProtocol = staProtocol.clone(); - } - // 鑾峰彇宸ヤ綔妗f暟鎹� - WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); - if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } - wrkMasts.add(wrkMast); - // 缁勮鍛戒护 - LedCommand ledCommand = new LedCommand(); - ledCommand.setWorkNo(wrkMast.getWrkNo()); - ledCommand.setIoType(wrkMast.getIoType()); - // 鍑哄簱妯″紡 - switch (wrkMast.getIoType()) { - case 101: - ledCommand.setTitle("鍏ㄦ澘鍑哄簱"); - break; - case 103: - ledCommand.setTitle("鎷f枡鍑哄簱"); - break; - case 104: - ledCommand.setTitle("骞舵澘鍑哄簱"); - break; - case 107: - ledCommand.setTitle("鐩樼偣鍑哄簱"); - break; - case 110: - ledCommand.setTitle("绌烘澘鍑哄簱"); - ledCommand.setEmptyMk(true); - break; - default: - News.error("浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); - break; - } - ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); - ledCommand.setLocNo(wrkMast.getLocNo()); - ledCommand.setStaNo(wrkMast.getStaNo()); - if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { - List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); - locDetls.forEach(locDetl -> { - Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkMast.getWrkNo()); - Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); - Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); - Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); - Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//鏂欑鐮� - WrkDetl detl = wrkDetlService.selectOne(wrapper); + try { + for (LedSlave led : slaveProperties.getLed()) { + // 鑾峰彇杈撻�佺嚎plc绾跨▼ + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); + // 鍛戒护闆嗗悎 + List<LedCommand> commands = new ArrayList<>(); + // 宸ヤ綔妗i泦鍚� + List<WrkMast> wrkMasts = new ArrayList<>(); + for (Integer staNo : led.getStaArr()) { + // 鑾峰彇鍙夎溅绔欑偣 + StaProtocol staProtocol = devpThread.getStation().get(staNo); + if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { + continue; + } else { + staProtocol = staProtocol.clone(); + } + // 鑾峰彇宸ヤ綔妗f暟鎹� + WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); + if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { + continue; + } + wrkMasts.add(wrkMast); + // 缁勮鍛戒护 + LedCommand ledCommand = new LedCommand(); + ledCommand.setWorkNo(wrkMast.getWrkNo()); + ledCommand.setIoType(wrkMast.getIoType()); + // 鍑哄簱妯″紡 + switch (wrkMast.getIoType()) { + case 101: + ledCommand.setTitle("鍏ㄦ澘鍑哄簱"); + break; + case 103: + ledCommand.setTitle("鎷f枡鍑哄簱"); + break; + case 104: + ledCommand.setTitle("骞舵澘鍑哄簱"); + break; + case 107: + ledCommand.setTitle("鐩樼偣鍑哄簱"); + break; + case 110: + ledCommand.setTitle("绌烘澘鍑哄簱"); + ledCommand.setEmptyMk(true); + break; + default: + News.error("浠诲姟鍏ュ嚭搴撶被鍨嬮敊璇紒锛侊紒[宸ヤ綔鍙凤細{}] [鍏ュ嚭搴撶被鍨嬶細{}]", wrkMast.getWrkNo(), wrkMast.getIoType()); + break; + } + ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); + ledCommand.setLocNo(wrkMast.getLocNo()); + ledCommand.setStaNo(wrkMast.getStaNo()); + if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { + List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); + locDetls.forEach(locDetl -> { + Wrapper<WrkDetl> wrapper = new EntityWrapper<WrkDetl>().eq("matnr", locDetl.getMatnr()).eq("wrk_no", wrkMast.getWrkNo()); + Utils.wapperSetCondition(wrapper, "batch", locDetl.getBatch()); + Utils.wapperSetCondition(wrapper, "three_code", locDetl.getThreeCode()); + Utils.wapperSetCondition(wrapper, "dead_time", locDetl.getDeadTime()); + Utils.wapperSetCondition(wrapper, "supp_code", locDetl.getSuppCode());//鏂欑鐮� + WrkDetl detl = wrkDetlService.selectOne(wrapper); - if (Cools.isEmpty(detl)) { - String suppCode = ""; - if (locDetl.getSuppCode() != null) { - suppCode = locDetl.getSuppCode(); - } - ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); - } else { - String suppCode = ""; - String orderNo = detl.getOrderNo(); - if (detl.getSuppCode() != null) { - suppCode = detl.getSuppCode(); - } - if (isJson(orderNo)) { - JSONArray orders = JSON.parseArray(orderNo); - for (Object order : orders) { - JSONObject order1 = (JSONObject) order; - ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), (Double) order1.get("anfme"), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode,(String) order1.get("orderNo"))); + if (Cools.isEmpty(detl)) { + String suppCode = ""; + if (locDetl.getSuppCode() != null) { + suppCode = locDetl.getSuppCode(); } + ledCommand.getMatDtos().add(new MatDto(locDetl.getMatnr(), locDetl.getMaktx(), 0D, locDetl.getAnfme(), locDetl.getSpecs(), suppCode)); } else { - ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode,detl.getOrderNo())); + String suppCode = ""; + String orderNo = detl.getOrderNo(); + if (detl.getSuppCode() != null) { + suppCode = detl.getSuppCode(); + } + if (isJson(orderNo)) { + JSONArray orders = JSON.parseArray(orderNo); + for (Object order : orders) { + JSONObject order1 = (JSONObject) order; + ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), (Double) order1.get("anfme"), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode, (String) order1.get("orderNo"))); + } + } else { + ledCommand.getMatDtos().add(new MatDto(detl.getMatnr(), detl.getMaktx(), detl.getAnfme(), (locDetl.getAnfme() - detl.getAnfme()), detl.getSpecs(), suppCode, detl.getOrderNo())); + } + + } - - - } - }); - - if (locDetls.isEmpty()) { - List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); - wrkDetls.forEach(wrkDetl -> { - ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode())); }); - } - } - commands.add(ledCommand); - } - Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); - // 鑾峰彇LED绾跨▼ - LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); - // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护 - if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { - continue; - } - // 鍛戒护涓嬪彂 ------------------------------------------------------------------------------- - if (!commands.isEmpty()) { - if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { - log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + if (locDetls.isEmpty()) { + List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); + wrkDetls.forEach(wrkDetl -> { + ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme(), wrkDetl.getAnfme(), wrkDetl.getSpecs(), wrkDetl.getSuppCode())); + }); + } + } + + commands.add(ledCommand); + } + Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet()); + // 鑾峰彇LED绾跨▼ + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); + // 鐩稿悓宸ヤ綔鍙烽泦鍚堝垯杩囨护 + if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { continue; - }else { - ledThread.setLedMk(false); } - } - - try { - // 淇敼涓绘。led鏍囪 - for (WrkMast wrkMast : wrkMasts) { - wrkMast.setOveMk("Y"); - wrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(wrkMast) == 0) { - throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�"); + // 鍛戒护涓嬪彂 ------------------------------------------------------------------------------- + if (!commands.isEmpty()) { + if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { + log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); + continue; + } else { + ledThread.setLedMk(false); } } - // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚� - ledThread.setWorkNos(workNos); + try { + // 淇敼涓绘。led鏍囪 + for (WrkMast wrkMast : wrkMasts) { + wrkMast.setOveMk("Y"); + wrkMast.setModiTime(new Date()); + if (wrkMastMapper.updateById(wrkMast) == 0) { + throw new CoolException("鏇存柊宸ヤ綔妗eけ璐�"); + } + } - } catch (Exception e) { - e.printStackTrace(); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + // 鏇存柊绾跨▼褰撳墠宸ヤ綔鍙烽泦鍚� + ledThread.setWorkNos(workNos); + + } catch (Exception e) { + e.printStackTrace(); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } - + } catch (Exception e) { + e.printStackTrace(); } } @@ -2936,7 +3006,8 @@ * 鍏朵粬 ===>> LED鏄剧ず鍣ㄥ浣嶏紝鏄剧ず榛樿淇℃伅 */ public void ledReset() { -// for (LedSlave led : slaveProperties.getLed()) { + try { + // for (LedSlave led : slaveProperties.getLed()) { // // // 鑾峰彇杈撻�佺嚎plc绾跨▼ // DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -2966,31 +3037,34 @@ // } // } // } - 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; + 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; + } + if (staProtocol.isLoading()) { + reset = false; + break; + } } - if (staProtocol.isLoading()) { - reset = false; - break; + // 鑾峰彇led绾跨▼ + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); + // led鏄剧ず榛樿鍐呭 + if (reset && !ledThread.isLedMk()) { + 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()); + } } } - // 鑾峰彇led绾跨▼ - LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); - // led鏄剧ず榛樿鍐呭 - if (reset && !ledThread.isLedMk()) { - 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()); - } - } + } catch (Exception e) { + e.printStackTrace(); } } @@ -2998,80 +3072,84 @@ * 鍥涘悜绌挎杞︾數閲忔娴� ===>> 鍙戣捣鍏呯數 */ public synchronized void loopShuttleCharge() { - for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { - //鑾峰彇鍥涘悜绌挎杞︾嚎绋� - NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); - NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); - if (shuttleProtocol == null) { - continue; - } - - //鍒ゆ柇褰撳墠灏忚溅鏄惁婊¤冻闇�瑕佸厖鐢佃姹� - if (!shuttleProtocol.isRequireCharge()) { - continue; - } - - WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttleProtocol.getShuttleNo().intValue()); - if (wrkCharge != null) {//宸叉湁鍏呯數浠诲姟 - continue; - } - - //灏忚溅鎵�鍦ㄦゼ灞� - int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); - ShuttleChargeType shuttleCharge = null; - - //鎼滅储灏忚溅鎵�鍦ㄦゼ灞傛湁娌℃湁鍏呯數妗� - for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { - if (lev != Utils.getLev(chargeType.locNo)) { - continue;//灏忚溅鍜屽厖鐢垫々涓嶅湪鍚屼竴灞� + try { + for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { + //鑾峰彇鍥涘悜绌挎杞︾嚎绋� + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId()); + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; } - //灏忚溅鍜屽厖鐢垫々鍦ㄥ悓涓�灞� - if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { - shuttleCharge = chargeType; - break; + //鍒ゆ柇褰撳墠灏忚溅鏄惁婊¤冻闇�瑕佸厖鐢佃姹� + if (!shuttleProtocol.isRequireCharge()) { + continue; } - } - if (shuttleCharge == null) { - //鍚屾ゼ灞傛病鏈夋壘鍒板厖鐢垫々锛屾壘鍙敤鍏呯數妗� - //灏忚溅鍚屾ゼ灞傛病鏈夊厖鐢垫々锛屽彧瑕佸厖鐢垫々鍙敤灏辩敓鎴愬厖鐢典换鍔� + WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttleProtocol.getShuttleNo().intValue()); + if (wrkCharge != null) {//宸叉湁鍏呯數浠诲姟 + continue; + } + + //灏忚溅鎵�鍦ㄦゼ灞� + int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo()); + ShuttleChargeType shuttleCharge = null; + + //鎼滅储灏忚溅鎵�鍦ㄦゼ灞傛湁娌℃湁鍏呯數妗� for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { - if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { - //鍒ゆ柇褰撳墠鍏呯數妗╂ゼ灞傛槸鍚︽湁灏忚溅锛屽鏈夊皬杞︼紝涓嶅垎閰嶈鍏呯數妗� - int chargeLev = Utils.getLev(chargeType.locNo);//鍏呯數妗╂ゼ灞� - boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//妫�娴嬫ゼ灞傛槸鍚︽湁绌挎杞� - if (checkLevHasShuttle) { - //褰撳墠鍏呯數妗╂ゼ灞傛湁绌挎杞︼紝涓嶅垎閰嶈鍏呯數妗� - continue; - } + if (lev != Utils.getLev(chargeType.locNo)) { + continue;//灏忚溅鍜屽厖鐢垫々涓嶅湪鍚屼竴灞� + } + //灏忚溅鍜屽厖鐢垫々鍦ㄥ悓涓�灞� + if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { shuttleCharge = chargeType; break; } } - } - if (shuttleCharge == null) { - continue; - } + if (shuttleCharge == null) { + //鍚屾ゼ灞傛病鏈夋壘鍒板厖鐢垫々锛屾壘鍙敤鍏呯數妗� + //灏忚溅鍚屾ゼ灞傛病鏈夊厖鐢垫々锛屽彧瑕佸厖鐢垫々鍙敤灏辩敓鎴愬厖鐢典换鍔� + for (ShuttleChargeType chargeType : ShuttleChargeType.values()) { + if (wrkChargeService.selectWorkingOfCharge(chargeType.id) == null) { + //鍒ゆ柇褰撳墠鍏呯數妗╂ゼ灞傛槸鍚︽湁灏忚溅锛屽鏈夊皬杞︼紝涓嶅垎閰嶈鍏呯數妗� + int chargeLev = Utils.getLev(chargeType.locNo);//鍏呯數妗╂ゼ灞� + boolean checkLevHasShuttle = Utils.checkLevHasShuttle(chargeLev);//妫�娴嬫ゼ灞傛槸鍚︽湁绌挎杞� + if (checkLevHasShuttle) { + //褰撳墠鍏呯數妗╂ゼ灞傛湁绌挎杞︼紝涓嶅垎閰嶈鍏呯數妗� + continue; + } - String chargeLocNo = shuttleCharge.locNo; - wrkCharge = new WrkCharge(); - wrkCharge.setShuttleNo(shuttle.getId()); - wrkCharge.setCharge(shuttleCharge.id); - wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); - wrkCharge.setWrkSts(51L); // 51.鍑嗗鍏呯數 - wrkCharge.setIoPri((double) 10); - wrkCharge.setLocNo(chargeLocNo); - wrkCharge.setMemo("charge"); - wrkCharge.setAppeTime(new Date()); - if (!wrkChargeService.insert(wrkCharge)) { - News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟澶辫触!!!", shuttle.getId()); - continue; - } + shuttleCharge = chargeType; + break; + } + } + } - News.info("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟鎴愬姛!!!", shuttle.getId()); + if (shuttleCharge == null) { + continue; + } + + String chargeLocNo = shuttleCharge.locNo; + wrkCharge = new WrkCharge(); + wrkCharge.setShuttleNo(shuttle.getId()); + wrkCharge.setCharge(shuttleCharge.id); + wrkCharge.setWrkNo(commonService.getChargeWorkNo(4)); + wrkCharge.setWrkSts(51L); // 51.鍑嗗鍏呯數 + wrkCharge.setIoPri((double) 10); + wrkCharge.setLocNo(chargeLocNo); + wrkCharge.setMemo("charge"); + wrkCharge.setAppeTime(new Date()); + if (!wrkChargeService.insert(wrkCharge)) { + News.error("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟澶辫触!!!", shuttle.getId()); + continue; + } + + News.info("淇濆瓨{}鍙峰洓鍚戠┛姊溅鍏呯數浠诲姟鎴愬姛!!!", shuttle.getId()); + } + } catch (Exception e) { + e.printStackTrace(); } } @@ -3079,157 +3157,164 @@ * 鎵ц鍥涘悜绌挎杞﹀厖鐢典换鍔� */ public synchronized void executeShuttleCharge() { - for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { - WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); - if (wrkCharge == null) { - continue; - } - - NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); - if (shuttleThread == null) { - continue; - } - NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); - if (shuttleProtocol == null) { - continue; - } - - if (wrkCharge.getWrkSts() == 51) { - if (!shuttleProtocol.isIdleNoCharge()) { + try { + for (ShuttleSlave shuttle : slaveProperties.getShuttle()) { + WrkCharge wrkCharge = wrkChargeService.selectWorking(shuttle.getId()); + if (wrkCharge == null) { continue; } - if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) { - //灏忚溅涓嶅湪鍏呯數妗╀綅缃� - shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//璋冨害灏忚溅鍘诲厖鐢垫々 + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, wrkCharge.getShuttleNo()); + if (shuttleThread == null) { + continue; + } + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { continue; } - //灏忚溅宸茬粡鍦ㄥ厖鐢垫々浣嶇疆锛屼笅鍙戝厖鐢靛懡浠� - NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), true); - ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); - commands.add(chargeCommand); - //鍒涘缓鍒嗛厤鍛戒护 - ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); - assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿 - assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//浠诲姟鍙� - assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//鍑哄簱妯″紡 - assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) - assignCommand.setCommands(commands);//杩愯鍛戒护 - - wrkCharge.setWrkSts(52L);//51.鐢熸垚鍏呯數浠诲姟 => 52.灏忚溅鍘诲厖鐢典腑 - wrkCharge.setModiTime(new Date()); - if (wrkChargeMapper.updateById(wrkCharge) > 0) { - //涓嬪彂浠诲姟 - MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); - } - } else if (wrkCharge.getWrkSts() == 52) { - //妫�娴嬪皬杞︽槸鍚︽弧鐢� - - //鑾峰彇婊$數闃堝�� - int maxPower = 95; - EntityWrapper<Config> wrapper = new EntityWrapper<>(); - wrapper.eq("code", "chargeMaxValue"); - Config config = configService.selectOne(wrapper); - if (config != null) { - maxPower = Integer.parseInt(config.getValue()); - } - - if (shuttleProtocol.getPowerPercent() < maxPower) { - continue; - } - - //***************鍒ゆ柇鏄惁婊″厖鏍″噯*************** - EntityWrapper<Config> wrapper1 = new EntityWrapper<>(); - wrapper.eq("code", "shuttleMaxPowerVerify"); - Config config1 = configService.selectOne(wrapper1); - if (config1 != null) { - if (config1.getValue().equals("true")) { - if (shuttleProtocol.getVoltage() < 5630) { - continue;//鐢靛帇涓嶅缁х画鍏呯數 - } - } - } - //***************鍒ゆ柇鏄惁婊″厖鏍″噯*************** - - //灏忚溅婊$數锛岀粨鏉熷厖鐢典换鍔� - NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false); - ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); - commands.add(chargeCommand); - //鍒涘缓鍒嗛厤鍛戒护 - ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); - assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿 - assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//浠诲姟鍙� - assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//鍑哄簱妯″紡 - assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) - assignCommand.setCommands(commands);//杩愯鍛戒护 - - //涓嬪彂浠诲姟 - MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); - try { - Thread.sleep(3000); - } catch (Exception e) { - e.printStackTrace(); - } - - wrkCharge.setWrkSts(53L);//52.灏忚溅鍘诲厖鐢典腑 => 53.灏忚溅鍏呯數瀹屾垚 - wrkCharge.setModiTime(new Date()); - if (wrkChargeMapper.updateById(wrkCharge) > 0) { - shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id); - shuttleProtocol.setTaskNo(0); - shuttleProtocol.setPakMk(false); - } - } else if (wrkCharge.getWrkSts() == 53) { - if (shuttleProtocol.getChargState() == 0) {//灏忚溅澶勪簬鏈厖鐢电姸鎬� - boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread); - if (!result) { + if (wrkCharge.getWrkSts() == 51) { + if (!shuttleProtocol.isIdleNoCharge()) { continue; } - wrkCharge.setWrkSts(60L);//53.灏忚溅鍏呯數瀹屾垚 => 60.鍏呯數浠诲姟瀹屾垚 + if (!shuttleProtocol.getCurrentLocNo().equals(wrkCharge.getLocNo())) { + //灏忚溅涓嶅湪鍏呯數妗╀綅缃� + shuttleDispatchUtils.dispatchShuttle(wrkCharge.getWrkNo(), wrkCharge.getLocNo(), shuttle.getId());//璋冨害灏忚溅鍘诲厖鐢垫々 + continue; + } + + //灏忚溅宸茬粡鍦ㄥ厖鐢垫々浣嶇疆锛屼笅鍙戝厖鐢靛懡浠� + NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), true); + ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); + commands.add(chargeCommand); + //鍒涘缓鍒嗛厤鍛戒护 + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿 + assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//浠诲姟鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//鍑哄簱妯″紡 + assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) + assignCommand.setCommands(commands);//杩愯鍛戒护 + + wrkCharge.setWrkSts(52L);//51.鐢熸垚鍏呯數浠诲姟 => 52.灏忚溅鍘诲厖鐢典腑 wrkCharge.setModiTime(new Date()); if (wrkChargeMapper.updateById(wrkCharge) > 0) { + //涓嬪彂浠诲姟 + MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); + } + } else if (wrkCharge.getWrkSts() == 52) { + //妫�娴嬪皬杞︽槸鍚︽弧鐢� + //鑾峰彇婊$數闃堝�� + int maxPower = 95; + EntityWrapper<Config> wrapper = new EntityWrapper<>(); + wrapper.eq("code", "chargeMaxValue"); + Config config = configService.selectOne(wrapper); + if (config != null) { + maxPower = Integer.parseInt(config.getValue()); + } + + if (shuttleProtocol.getPowerPercent() < maxPower) { + continue; + } + + //***************鍒ゆ柇鏄惁婊″厖鏍″噯*************** + EntityWrapper<Config> wrapper1 = new EntityWrapper<>(); + wrapper.eq("code", "shuttleMaxPowerVerify"); + Config config1 = configService.selectOne(wrapper1); + if (config1 != null) { + if (config1.getValue().equals("true")) { + if (shuttleProtocol.getVoltage() < 5630) { + continue;//鐢靛帇涓嶅缁х画鍏呯數 + } + } + } + //***************鍒ゆ柇鏄惁婊″厖鏍″噯*************** + + //灏忚溅婊$數锛岀粨鏉熷厖鐢典换鍔� + NyShuttleHttpCommand chargeCommand = NyHttpUtils.getChargeCommand(shuttle.getId(), wrkCharge.getWrkNo(), false); + ArrayList<NyShuttleHttpCommand> commands = new ArrayList<>(); + commands.add(chargeCommand); + //鍒涘缓鍒嗛厤鍛戒护 + ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); + assignCommand.setShuttleNo(shuttleProtocol.getShuttleNo());//鍥涘悜绌挎杞﹀彿 + assignCommand.setTaskNo(wrkCharge.getWrkNo().shortValue());//浠诲姟鍙� + assignCommand.setTaskMode(ShuttleTaskModeType.CHARGE.id.shortValue());//鍑哄簱妯″紡 + assignCommand.setSourceLocNo(shuttleProtocol.getCurrentLocNo());//婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) + assignCommand.setCommands(commands);//杩愯鍛戒护 + + //涓嬪彂浠诲姟 + MessageQueue.offer(SlaveType.Shuttle, assignCommand.getShuttleNo().intValue(), new Task(3, assignCommand)); + try { + Thread.sleep(3000); + } catch (Exception e) { + e.printStackTrace(); + } + + wrkCharge.setWrkSts(53L);//52.灏忚溅鍘诲厖鐢典腑 => 53.灏忚溅鍏呯數瀹屾垚 + wrkCharge.setModiTime(new Date()); + if (wrkChargeMapper.updateById(wrkCharge) > 0) { + shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE.id); + shuttleProtocol.setTaskNo(0); + shuttleProtocol.setPakMk(false); + } + } else if (wrkCharge.getWrkSts() == 53) { + if (shuttleProtocol.getChargState() == 0) {//灏忚溅澶勪簬鏈厖鐢电姸鎬� + boolean result = Utils.searchEmptyGroupToMoveShuttle(Utils.getLev(wrkCharge.getLocNo()), shuttleThread.getSlave().getId(), shuttleThread); + if (!result) { + continue; + } + + wrkCharge.setWrkSts(60L);//53.灏忚溅鍏呯數瀹屾垚 => 60.鍏呯數浠诲姟瀹屾垚 + wrkCharge.setModiTime(new Date()); + if (wrkChargeMapper.updateById(wrkCharge) > 0) { + + } } } + } - + } catch (Exception e) { + e.printStackTrace(); } - } /** * 鎵ц灏忚溅绉诲簱浠诲姟 */ public synchronized void shuttleMoveExecute() { - //鏌ヨ灏忚溅绉诲簱浠诲姟 - List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk(); - for (WrkMast wrkMast : wrkMasts) { - boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� - if (!stepMoveSta) { - continue; - } + try { + //鏌ヨ灏忚溅绉诲簱浠诲姟 + List<WrkMast> wrkMasts = wrkMastMapper.selectShuttleMoveWrk(); + for (WrkMast wrkMast : wrkMasts) { + boolean stepMoveSta = this.shuttleMoveExecuteStepMoveSta(wrkMast);//灏忚溅绉诲姩鍒扮珯鐐� + if (!stepMoveSta) { + continue; + } - boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈� - if (!stepIntoLift) { - continue; - } + boolean stepIntoLift = this.shuttleMoveExecuteStepIntoLift(wrkMast);//灏忚溅杩佸叆鎻愬崌鏈� + if (!stepIntoLift) { + continue; + } - boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//鎻愬崌鏈烘惉杩愪腑 - if (!stepLiftMove) { - continue; - } + boolean stepLiftMove = this.shuttleMoveExecuteStepLiftMove(wrkMast);//鎻愬崌鏈烘惉杩愪腑 + if (!stepLiftMove) { + continue; + } - boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈� - if (!stepOutLift) { - continue; - } + boolean stepOutLift = this.shuttleMoveExecuteStepOutLift(wrkMast);//灏忚溅杩佸嚭鎻愬崌鏈� + if (!stepOutLift) { + continue; + } - boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 - if (!stepMoveLoc) { - continue; - } + boolean stepMoveLoc = this.shuttleMoveExecuteStepMoveLoc(wrkMast);//灏忚溅绉诲姩鍒扮洰鏍囧簱浣嶄腑 + if (!stepMoveLoc) { + continue; + } + } + } catch (Exception e) { + e.printStackTrace(); } } -- Gitblit v1.9.1