From 619bb4fa99082700aa90f440c23904bc3d5d6ccd Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期二, 12 十二月 2023 19:54:45 +0800 Subject: [PATCH] #拣料回库 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 369 ++++++++++++++++++++++++++-------------------------- 1 files changed, 186 insertions(+), 183 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 323e43a..ccdf575 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -450,27 +450,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 +478,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(); } } } @@ -554,27 +570,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) { @@ -582,39 +598,55 @@ 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; + } - staProtocol.setStaNo(pickSta.getBackSta().shortValue());//鍐欏叆鐩爣绔� - MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + 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(); + } } } @@ -633,10 +665,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()); @@ -648,10 +676,33 @@ if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() - && (staProtocol.getWorkNo() > 0) +// && (staProtocol.getWorkNo() > 0) && staProtocol.isPakMk()) { - WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue()); + 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); + } + if (wrkMast == null) {//鎵句笉鍒板伐浣滄。 continue; } @@ -660,28 +711,6 @@ || 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) { - continue; - } - - if (!locMast.getLocSts().equals("F")) { - flag = true; - th = loc + "搴撲綅瀛樺湪鏈洖搴撲换鍔�"; - break; - } - } - if (flag) { - News.info(th); - continue; - } - //*********************鍚屽簱浣嶇粍鏍¢獙********************* // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { @@ -696,11 +725,11 @@ param.setWrkNo(wrkMast.getWrkNo()); param.setBarcode(wrkMast.getBarcode()); param.setIoType(107);//鐩樼偣 - param.setSourceStaNo(wrkMast.getStaNo()); + param.setSourceStaNo(pickSta.getStaNo()); 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(); @@ -2924,6 +2953,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 -> { @@ -3962,63 +3992,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