From d4f6861fd78a901a0c2f2afb9e973ed0da4d69a4 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期一, 10 十月 2022 11:08:19 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 514 +++++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 391 insertions(+), 123 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 201904d..0ffb2d7 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -74,11 +74,15 @@ @Autowired private BasErrLogService basErrLogService; @Autowired + private BasSteErrLogService basSteErrLogService; + @Autowired private BasCrnErrorMapper basCrnErrorMapper; @Autowired private BasSteService basSteService; @Autowired private WrkChargeService wrkChargeService; + @Autowired + private BasSteErrService basSteErrService; @Autowired private CommonService commonService; @@ -114,11 +118,33 @@ } String barcode = barcodeThread.getBarcode(); if(!Cools.isEmpty(barcode)) { - log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); - if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { +// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", inSta.getBarcode(), barcode); + if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { + staProtocol.setWorkNo((short) 9995); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + + // led 寮傚父鏄剧ず + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); + } continue; } } else { + staProtocol.setWorkNo((short) 9995); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + + // led 寮傚父鏄剧ず + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); + if (ledThread != null) { + String errorMsg = "鎵爜澶辫触锛岃閲嶈瘯"; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); + } continue; } @@ -143,19 +169,39 @@ .build() .doPost(); JSONObject jsonObject = JSON.parseObject(response); - if (jsonObject.getInteger("code").equals(200)) { + LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed()); + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) { StartupDto dto = jsonObject.getObject("data", StartupDto.class); // plc 澶勭悊 barcodeThread.setBarcode(""); staProtocol.setWorkNo(dto.getWorkNo().shortValue()); staProtocol.setStaNo(dto.getStaNo().shortValue()); devpThread.setPakMk(staProtocol.getSiteId(), false); + boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); if (!result) { throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } - } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + } else if (code == 500){ + if (ledThread != null) { + String errorMsg = jsonObject.getString("msg"); + if (!Cools.isEmpty(errorMsg)) { + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); + } + } + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + } else if (code == 700) { + staProtocol.setWorkNo((short) 9995); + staProtocol.setStaNo(inSta.getBackSta().shortValue()); + devpThread.setPakMk(staProtocol.getSiteId(), false); + MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); + + // led 寮傚父鏄剧ず + if (ledThread != null) { + String errorMsg = barcode + "鎵樼洏璇嗗埆寮傚父锛岃鍏堣繘琛岀粍鎵橈紒"; + MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg)); + } } } catch (Exception e) { e.printStackTrace(); @@ -235,21 +281,21 @@ if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()){ // 鑾峰彇鏉$爜鎵弿浠俊鎭� - BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); - if (barcodeThread == null) { - continue; - } - String barcode = barcodeThread.getBarcode(); - if(!Cools.isEmpty(barcode)) { - log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); - if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { - continue; - } - } else { - continue; - } +// BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode()); +// if (barcodeThread == null) { +// continue; +// } +// String barcode = barcodeThread.getBarcode(); +// if(!Cools.isEmpty(barcode)) { +// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", pickSta.getBarcode(), barcode); +// if("NG".endsWith(barcode) || "NoRead".equals(barcode)) { +// continue; +// } +// } else { +// continue; +// } - WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); + WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo()); if (wrkMast == null) { // 鏃犳嫞鏂欐暟鎹� continue; @@ -272,9 +318,9 @@ try { // 淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。 - if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { - throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触"); - } +// if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) { +// throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏妗e巻鍙叉。澶辫触"); +// } // 淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗� if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) { throw new CoolException("淇濆瓨宸ヤ綔涓绘。鍘嗗彶妗eけ璐�"); @@ -292,6 +338,9 @@ wrkMast.setModiTime(new Date()); if (wrkMastMapper.updateById(wrkMast) == 0) { throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); + } + if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) { +// throw new CoolException("鏇存柊宸ヤ綔妗f暟鎹姸鎬佸け璐�"); } // 淇敼搴撲綅鐘舵�� Q.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴� LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); @@ -482,6 +531,12 @@ continue; } + // 杩囨护 + if (null != wrkMastMapper.selectPakout(slave.getId(), null)) { + log.error("{}鍏ュ簱浠诲姟鏃犳硶浣滀笟锛屽洜瀛樺湪鍑哄簱涓换鍔�!", wrkMast.getWrkNo()); + continue; + } + // 缃《浠诲姟 wrkMast.setIoPri((double) 9999); wrkMastMapper.updateById(wrkMast); @@ -489,11 +544,14 @@ // 鐩爣搴撲綅 ===>> 鏈�澶栧眰搴撲綅 if (locMastService.isOutMost(wrkMast.getLocNo())) { // 鍒ゆ柇灏忚溅鏄惁鍦ㄦ渶澶栧眰搴撲綅锛屽鏋滄槸鍒欐惉璧帮紝濡傛灉涓嶆槸锛屽垯鐩存帴鍫嗗灈鏈哄叆搴� - Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo()); + Integer steNo = this.hasCar(wrkMast.getLocNo()); // 鏈夊皬杞� if (steNo != null) { // 灏忚溅琛岃蛋鍒板爢鍨涙満寰呮惉绉荤偣 if (wrkMast.getWrkSts() == 2L && wrkMast.getSteNo() == null) { +// if (null != wrkMastMapper.selectPakin(slave.getId(), steNo)) { +// continue; +// } this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo()); } // 灏忚溅鎼蛋 @@ -654,6 +712,12 @@ // 鍫嗗灈鏈烘帶鍒惰繃婊� if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { + continue; + } + + // 杩囨护 + if (null != wrkMastMapper.selectPakin(slave.getId(), null)) { + log.error("{}鍑哄簱浠诲姟鏃犳硶浣滀笟锛屽洜瀛樺湪鍏ュ簱涓换鍔�!", wrkMast.getWrkNo()); continue; } @@ -836,6 +900,8 @@ if (locMastService.isOutMost(wrkMast.getSourceLocNo())) { // 鐩爣搴撲綅 ===>> 鏈�澶栧眰搴撲綅 if (locMastService.isOutMost(wrkMast.getLocNo())) { + // todo:luxiaotao 鍒ゆ柇鐩爣搴撲綅鏄惁瀛樺湪灏忚溅锛屽鏋滃瓨鍦紝鍒欐惉璧板皬杞� + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� @@ -1075,6 +1141,22 @@ } } } + } + + /** + * 褰撳墠搴撲綅缁勬槸鍚﹀瓨鍦ㄧ┖闂插皬杞� + */ + public Integer hasCar(String locNo) { + for (SteSlave ste : slaveProperties.getSte()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { continue; } + if (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) { + return steProtocol.getSteNo().intValue(); + } + } + return null; } /** @@ -1768,10 +1850,21 @@ } /** + * 寮傚父淇℃伅璁板綍 + */ + public void recErr() { + try { + this.recCrnErr(); + this.recSteErr(); + } catch (Exception e) { + log.error("recErr fail", e); + } + } + + /** * 鍫嗗灈鏈哄紓甯镐俊鎭褰� */ - @Async - public void recCrnErr(){ + private void recCrnErr(){ Date now = new Date(); for (CrnSlave crn : slaveProperties.getCrn()) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� @@ -1780,109 +1873,219 @@ if (crnProtocol == null) { continue; } - if (true) { -// if (crnProtocol.getModeType() != CrnModeType.STOP) { - // 鏈変换鍔� - if (crnProtocol.getTaskNo() != 0) { - BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue()); - // 鏈夊紓甯� - if (latest == null) { - if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { - WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); - if (wrkMast == null) { - continue; - } - BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); - String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); - BasErrLog basErrLog = new BasErrLog( - null, // 缂栧彿 - wrkMast.getWrkNo(), // 宸ヤ綔鍙� - now, // 鍙戠敓鏃堕棿 - null, // 缁撴潫鏃堕棿 - wrkMast.getWrkSts(), // 宸ヤ綔鐘舵�� - wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨� - crn.getId(), // 鍫嗗灈鏈� - null, // plc - wrkMast.getLocNo(), // 鐩爣搴撲綅 - wrkMast.getStaNo(), // 鐩爣绔� - wrkMast.getSourceStaNo(), // 婧愮珯 - wrkMast.getSourceLocNo(), // 婧愬簱浣� - wrkMast.getBarcode(), // 鏉$爜 - (int) crnProtocol.getAlarm(), // 寮傚父鐮� - errName, // 寮傚父 - 1, // 寮傚父鎯呭喌 - now, // 娣诲姞鏃堕棿 - null, // 娣诲姞浜哄憳 - now, // 淇敼鏃堕棿 - null, // 淇敼浜哄憳 - "浠诲姟涓紓甯�" // 澶囨敞 - ); - if (!basErrLogService.insert(basErrLog)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); - } + // 鏈変换鍔� + if (crnProtocol.getTaskNo() != 0) { + BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue()); + // 鏈夊紓甯� + if (latest == null) { + if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { + WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); + if (wrkMast == null) { + continue; } - } else { - // 寮傚父淇 - if (crnProtocol.getAlarm() == null || crnProtocol.getAlarm() == 0) { - latest.setEndTime(now); - latest.setUpdateTime(now); - latest.setStatus(2); - if (!basErrLogService.updateById(latest)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); - } + BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); + String errName = crnError==null? "鏈煡寮傚父":crnError.getErrName(); + BasErrLog basErrLog = new BasErrLog( + null, // 缂栧彿 + wrkMast.getWrkNo(), // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + wrkMast.getWrkSts(), // 宸ヤ綔鐘舵�� + wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨� + crn.getId(), // 鍫嗗灈鏈� + null, // plc + wrkMast.getLocNo(), // 鐩爣搴撲綅 + wrkMast.getStaNo(), // 鐩爣绔� + wrkMast.getSourceStaNo(), // 婧愮珯 + wrkMast.getSourceLocNo(), // 婧愬簱浣� + wrkMast.getBarcode(), // 鏉$爜 + (int) crnProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "浠诲姟涓紓甯�" // 澶囨敞 + ); + if (!basErrLogService.insert(basErrLog)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); } } - // 鏃犱换鍔� } else { - BasErrLog latest = basErrLogService.findLatest(crn.getId()); - // 鏈夊紓甯� - if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { - // 璁板綍鏂板紓甯� - if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { - BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); - String errName = crnError==null? String.valueOf(crnProtocol.getAlarm()):crnError.getErrName(); - BasErrLog basErrLog = new BasErrLog( - null, // 缂栧彿 - null, // 宸ヤ綔鍙� - now, // 鍙戠敓鏃堕棿 - null, // 缁撴潫鏃堕棿 - null, // 宸ヤ綔鐘舵�� - null, // 鍏ュ嚭搴撶被鍨� - crn.getId(), // 鍫嗗灈鏈� - null, // plc - null, // 鐩爣搴撲綅 - null, // 鐩爣绔� - null, // 婧愮珯 - null, // 婧愬簱浣� - null, // 鏉$爜 - (int)crnProtocol.getAlarm(), // 寮傚父鐮� - errName, // 寮傚父 - 1, // 寮傚父鎯呭喌 - now, // 娣诲姞鏃堕棿 - null, // 娣诲姞浜哄憳 - now, // 淇敼鏃堕棿 - null, // 淇敼浜哄憳 - "鏃犱换鍔″紓甯�" // 澶囨敞 - ); - if (!basErrLogService.insert(basErrLog)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); - } + // 寮傚父淇 + if (crnProtocol.getAlarm() == null || crnProtocol.getAlarm() == 0) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basErrLogService.updateById(latest)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); } - // 鏃犲紓甯� - } else { - // 寮傚父淇 - if (latest != null && latest.getStatus() == 1) { - latest.setEndTime(now); - latest.setUpdateTime(now); - latest.setStatus(2); - if (!basErrLogService.updateById(latest)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); - } + } + } + // 鏃犱换鍔� + } else { + BasErrLog latest = basErrLogService.findLatest(crn.getId()); + // 鏈夊紓甯� + if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { + // 璁板綍鏂板紓甯� + if (latest == null || (latest.getErrCode() != crnProtocol.getAlarm().intValue())) { + BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm()); + String errName = crnError==null? "鏈煡寮傚父":crnError.getErrName(); + BasErrLog basErrLog = new BasErrLog( + null, // 缂栧彿 + null, // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + null, // 宸ヤ綔鐘舵�� + null, // 鍏ュ嚭搴撶被鍨� + crn.getId(), // 鍫嗗灈鏈� + null, // plc + null, // 鐩爣搴撲綅 + null, // 鐩爣绔� + null, // 婧愮珯 + null, // 婧愬簱浣� + null, // 鏉$爜 + (int)crnProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "鏃犱换鍔″紓甯�" // 澶囨敞 + ); + if (!basErrLogService.insert(basErrLog)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); + } + } + // 鏃犲紓甯� + } else { + // 寮傚父淇 + if (latest != null && latest.getStatus() == 1) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basErrLogService.updateById(latest)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId()); } } } } + } + } + /** + * 绌挎杞﹀紓甯镐俊鎭褰� + */ + private void recSteErr(){ + Date now = new Date(); + for (SteSlave ste : slaveProperties.getSte()) { + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId()); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { + continue; + } + // 鏈変换鍔� + if (steProtocol.getTaskNo() != 0) { + BasSteErrLog latest = basSteErrLogService.findLatestByTaskNo(ste.getId(), steProtocol.getTaskNo().intValue()); + // 鏈夊紓甯� + if (latest == null) { + if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { + WrkMast wrkMast = wrkMastMapper.selectById(steProtocol.getTaskNo()); + if (wrkMast == null) { + continue; + } + BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); + String errName = steErr==null? "鏈煡寮傚父":steErr.getErrName(); + BasSteErrLog basSteErrLog = new BasSteErrLog( + null, // 缂栧彿 + wrkMast.getWrkNo(), // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + wrkMast.getWrkSts(), // 宸ヤ綔鐘舵�� + wrkMast.getIoType(), // 鍏ュ嚭搴撶被鍨� + ste.getId(), // 鍫嗗灈鏈� + null, // plc + wrkMast.getLocNo(), // 鐩爣搴撲綅 + wrkMast.getStaNo(), // 鐩爣绔� + wrkMast.getSourceStaNo(), // 婧愮珯 + wrkMast.getSourceLocNo(), // 婧愬簱浣� + wrkMast.getBarcode(), // 鏉$爜 + (int) steProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "浠诲姟涓紓甯�" // 澶囨敞 + ); + if (!basSteErrLogService.insert(basSteErrLog)) { + log.error("绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", ste.getId(), errName); + } + } + } else { + // 寮傚父淇 + if (steProtocol.getAlarm() == null || !steProtocol.isAlarm()) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basSteErrLogService.updateById(latest)) { + log.error("绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); + } + } + } + // 鏃犱换鍔� + } else { + BasSteErrLog latest = basSteErrLogService.findLatest(ste.getId()); + // 鏈夊紓甯� + if (steProtocol.getAlarm() != null && steProtocol.isAlarm()) { + // 璁板綍鏂板紓甯� + if (latest == null || (latest.getErrCode() != steProtocol.getAlarm().intValue())) { + BasSteErr steErr = basSteErrService.selectById(steProtocol.getAlarm()); + String errName = steErr==null? "鏈煡寮傚父":steErr.getErrName(); + BasSteErrLog basSteErrLog = new BasSteErrLog( + null, // 缂栧彿 + null, // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + null, // 宸ヤ綔鐘舵�� + null, // 鍏ュ嚭搴撶被鍨� + ste.getId(), // 鍫嗗灈鏈� + null, // plc + null, // 鐩爣搴撲綅 + null, // 鐩爣绔� + null, // 婧愮珯 + null, // 婧愬簱浣� + null, // 鏉$爜 + (int)steProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + now, // 娣诲姞鏃堕棿 + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "鏃犱换鍔″紓甯�" // 澶囨敞 + ); + if (!basSteErrLogService.insert(basSteErrLog)) { + log.error("绌挎杞lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", ste.getId(), errName); + } + } + // 鏃犲紓甯� + } else { + // 寮傚父淇 + if (latest != null && latest.getStatus() == 1) { + latest.setEndTime(now); + latest.setUpdateTime(now); + latest.setStatus(2); + if (!basSteErrLogService.updateById(latest)) { + log.error("绌挎杞lc寮傚父璁板綍淇澶辫触 ===>> [id:{}] [errLogId:{}]", ste.getId(), latest.getId()); + } + } + } + } } } @@ -1906,14 +2109,36 @@ staProtocol = staProtocol.clone(); } // 绔欑偣鏉′欢鍒ゆ柇 - if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() - && staProtocol.isEmptyMk() && (staProtocol.getWorkNo() == 0 || (staProtocol.getWorkNo() >= 9990 && staProtocol.getWorkNo() <= 9999) || staProtocol.getWorkNo() == 9997) && staProtocol.isPakMk()) { + 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)) { +// log.info("{}鍙锋潯鐮佹壂鎻忓櫒妫�娴嬫潯鐮佷俊鎭細{}", emptyInSta.getBarcode(), barcode0); + if(!"NG".endsWith(barcode0) && !"NoRead".equals(barcode0) && !"empty".equals(barcode0)) { + barcode = barcode0; + } + } + } + + 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() @@ -1923,7 +2148,8 @@ .build() .doPost(); JSONObject jsonObject = JSON.parseObject(response); - if (jsonObject.getInteger("code").equals(200)) { + Integer code = jsonObject.getInteger("code"); + if (code.equals(200)) { StartupDto dto = jsonObject.getObject("data", StartupDto.class); // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 @@ -1935,7 +2161,13 @@ throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触"); } } else { - log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); + if (ledThread != null) { + String errorMsg = jsonObject.getString("msg"); + if (!Cools.isEmpty(errorMsg)) { + MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, errorMsg)); + } + } + log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } } catch (Exception e) { e.printStackTrace(); @@ -2290,7 +2522,43 @@ } } - log.info("{}鍙峰爢鍨涙満瀵箋}搴撲綅杩涜婕旂ず", crn.getId(), locNo); +// log.info("{}鍙峰爢鍨涙満瀵箋}搴撲綅杩涜婕旂ず", crn.getId(), locNo); + + // 鑾峰彇绉诲簱宸ヤ綔妗d俊鎭� +// WrkMast wrkMast = wrkMastMapper.selectLocMove(crn.getId()); +// if (null != wrkMast) { continue; } +// +// LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId()); +// LocMast loc = locMastService.queryDemoLoc(crn.getId()); +// if (null == sourceLoc || null == loc) { continue; } +// +// String sourceLocNo = sourceLoc.getLocNo(); +// String locNo = loc.getLocNo(); +// +// // 鑾峰彇宸ヤ綔鍙� +// int workNo = commonService.getWorkNo(WorkNoType.PICK.type); +// // 淇濆瓨宸ヤ綔妗� +// wrkMast = new WrkMast(); +// wrkMast.setWrkNo(workNo); +// wrkMast.setIoTime(new Date()); +// wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID +// wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 +// wrkMast.setIoPri(13D); +// wrkMast.setCrnNo(crn.getId()); +// wrkMast.setSourceLocNo(sourceLocNo); // 婧愬簱浣� +// wrkMast.setLocNo(locNo); // 鐩爣搴撲綅 +// wrkMast.setFullPlt("N"); // 婊℃澘锛歒 +// wrkMast.setPicking("N"); // 鎷f枡 +// wrkMast.setExitMk("N"); // 閫�鍑� +// wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 +// wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� +// wrkMast.setLinkMis("N"); +// wrkMast.setAppeTime(new Date()); +// wrkMast.setModiTime(new Date()); +// int res = wrkMastMapper.insert(wrkMast); +// if (res == 0) { +// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); +// } } -- Gitblit v1.9.1