From 3529c33b475a37caac303d4c9587979c55ceee32 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期三, 13 十二月 2023 16:47:50 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 317 +++++++++++++++++++--------------------------------- 1 files changed, 114 insertions(+), 203 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 4cdda60..2179b60 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -409,10 +409,6 @@ 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()); @@ -450,27 +446,27 @@ 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; - } - - if (!locMast.getLocSts().equals("F")) { - flag = true; - th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; - break; - } - } - if (flag) { - News.info(th); - 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; +// } +// +// if (!locMast.getLocSts().equals("F")) { +// flag = true; +// th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; +// break; +// } +// } +// if (flag) { +// News.info(th); +// continue; +// } +// //*********************鍚屽簱浣嶇粍鏍¢獙********************* // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { @@ -478,35 +474,51 @@ continue; } - String sourceLocNo = wrkMast.getSourceLocNo().trim(); - LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(sourceLocNo));//鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 - if (liftStaProtocol == null) { - continue; - } + try { + LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());//婧愬簱浣� + SearchLocParam param = new SearchLocParam(); + param.setWrkNo(wrkMast.getWrkNo()); + param.setBarcode(wrkMast.getBarcode()); + param.setIoType(wrkMast.getIoType()); + param.setSourceStaNo(pickSta.getStaNo()); + param.setLocType1(locMast.getLocType1()); + String response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath("/rpc/pakin/loc/v2") + .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); - // 鏇存柊宸ヤ綔妗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; - } + //鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯 + LiftStaProtocol liftStaProtocol = NyLiftUtils.getLiftStaByLev(pickSta.getLiftNo(), Utils.getLev(dto.getLocNo())); + if (liftStaProtocol == null) { + News.info(wrkMast.getWrkNo() + "鑾峰彇鍥炲簱鎻愬崌鏈虹洰鏍囩珯澶辫触"); + continue; + } - // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� - LocMast locMast = locMastService.selectById(sourceLocNo); - locMast.setLocSts("Q"); - locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)) { - News.info("淇敼搴撲綅鐘舵�佸け璐�"); - continue; + // 鏇存柊宸ヤ綔妗f暟鎹姸鎬� + wrkMast.setIoType(wrkMast.getIoType() - 50); // 鍏ュ嚭搴撶被鍨�: 103->53,104->54 + 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; + } + } 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(); } } } @@ -525,11 +537,7 @@ 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; - } - + for (DevpSlave.Sta pickSta : devp.getPickInSta2()) { // 鑾峰彇鎷f枡鍏ュ簱绔欎俊鎭� DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo()); @@ -545,76 +553,16 @@ && staProtocol.isPakMk()) { WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 + if (wrkMast == null) { continue; } - - if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104) - || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { - continue; + if (wrkMast.getSteNo() == null) { + wrkMast.setSteNo(1); + wrkMastMapper.updateById(wrkMast); + staProtocol.setStaNo((short) 341);//鍐欏叆鐩爣绔� + staProtocol.setPakMk(false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); } - - //*********************鍚屽簱浣嶇粍鏍¢獙********************* - 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; - } - - 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; - } - - // 淇敼搴撲綅鐘舵�� 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)); } } @@ -647,30 +595,19 @@ // && (staProtocol.getWorkNo() > 0) && staProtocol.isPakMk()) { - WrkMast wrkMast = null; - if (pickSta.getStaNo() == 325 || pickSta.getStaNo() == 331 || pickSta.getStaNo() == 333 || pickSta.getStaNo() == 339) { - if (staProtocol.getWorkNo() == 0) { - continue; - } - //鏍规嵁宸ヤ綔鍙锋悳绱㈠伐浣滄。 - wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); - }else { - //鏍规嵁鎵樼洏鐮佹悳绱㈠伐浣滄。 - // 鑾峰彇鏉$爜鎵弿浠俊鎭� - 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 = wrkMastMapper.selectByBarcode(barcode); + // 鑾峰彇鏉$爜鎵弿浠俊鎭� + 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.selectByBarcode(barcode); if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 continue; } @@ -697,7 +634,7 @@ param.setLocType1(locMast.getLocType1()); String response = new HttpHandler.Builder() .setUri(wmsUrl) - .setPath("/rpc/pakin/loc/v1") + .setPath("/rpc/pakin/loc/v2") .setJson(JSON.toJSONString(param)) .build() .doPost(); @@ -1303,7 +1240,7 @@ if (wrkMast.getStaNo() == 300) { //鍑�300绔欙紝妫�娴�300绔欎换鍔℃暟閲� List<WrkMast> wrkMasts = wrkMastMapper.select300Wrk(); - if (wrkMasts.size() >= 4) { + if (wrkMasts.size() >= 20) { News.info("{}浠诲姟锛岃緭閫佺嚎浠诲姟杩囪浇{}", wrkMast.getWrkNo(), wrkMasts.size()); return false; } @@ -2921,6 +2858,7 @@ ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); ledCommand.setLocNo(wrkMast.getLocNo()); ledCommand.setStaNo(wrkMast.getStaNo()); + ledCommand.setBarcode(wrkMast.getBarcode()); if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", wrkMast.getSourceLocNo())); locDetls.forEach(locDetl -> { @@ -3959,63 +3897,36 @@ return true; } - /** - * 鍑哄叆搴撴ā寮忓垏鎹� - */ - public synchronized void outAndIn() { - try { - // 鏍规嵁杈撻�佺嚎plc閬嶅巻 - for (DevpSlave devp : slaveProperties.getDevp()) { - for (DevpSlave.Sta inSta : devp.getInSta()) { - Thread.sleep(500); - boolean a=true,b=true; - List<WrkMast> wrkMasts = wrkMastMapper.selectAll(inSta.getStaNo()); - if (Cools.isEmpty(wrkMasts)){ - b=false; - }else { - for (WrkMast wrkMast:wrkMasts){ - if (wrkMast.getSourceStaNo() > wrkMast.getStaNo()){ - a=false; - break; - } - } - } - switch (inSta.getStaNo()) { - case 102://1F - if (a && b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 11)); - }else if (b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 12)); - }else { - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 10)); - } - break; - case 202://2F - if (a && b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 21)); - }else if (b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 22)); - }else { - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 20)); - } - break; - case 302://3F - if (a && b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 31)); - }else if (b){ - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 32)); - }else { - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(3, 30)); - } - break; - } - } + //鎵弿璁惧PakMk鏍囪鏄惁瓒呮椂 + public synchronized void scanDevicePakMk() { + //鎵弿灏忚溅 + for (ShuttleSlave slave : slaveProperties.getShuttle()) { + NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); + NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol(); + if (shuttleProtocol == null) { + continue; } - } catch (Exception e) { - e.printStackTrace(); + if ((System.currentTimeMillis() - shuttleProtocol.getSendTime() > (1000*60*5)) && shuttleProtocol.getPakMk()) { + //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪 + shuttleProtocol.setPakMk(false);//澶嶄綅鏍囪 + } } - } + //鎵弿鎻愬崌鏈� + for (LiftSlave slave : slaveProperties.getLift()) { + LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId()); + LiftProtocol liftProtocol = liftThread.getLiftProtocol(); + if (liftProtocol == null) { + continue; + } + + if ((System.currentTimeMillis() - liftProtocol.getSendTime() > (1000*60*5)) && liftProtocol.getPakMk()) { + //璁惧瓒呰繃5鍒嗛挓杩樻病澶嶄綅鏍囪 + liftProtocol.setPakMk(false);//澶嶄綅鏍囪 + } + } + + } } -- Gitblit v1.9.1