From 23bc853bf89485a3a85c3dc022e539547ab7ebe5 Mon Sep 17 00:00:00 2001 From: cpT <1@123> Date: 星期日, 29 六月 2025 17:52:40 +0800 Subject: [PATCH] #改造 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 498 ++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 309 insertions(+), 189 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 438cf44..cf13d45 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -102,6 +102,8 @@ @Value("${constant-parameters.avoidDistance}") private Long avoidDistance; + @Autowired + private TaskWrkLogServiceImpl taskWrkLogService; public void generateStoreWrkFile() { try { @@ -127,7 +129,7 @@ boolean back = false; String errMsg = "-"; if (staProtocol.getGrossWt()>=600){ - errMsg = "瓒呴噸"; + errMsg = "瓒呴噸锛�"+staProtocol.getGrossWt()+"kg"; back = true; } if (staProtocol.isFrontErr()) { @@ -150,10 +152,10 @@ errMsg = "鍙宠秴闄�"; back = true; } - if (!back && staProtocol.isWeightErr()) { - errMsg = "瓒呴噸"; - back = true; - } +// if (!back && staProtocol.isWeightErr()) { +// errMsg = "瓒呴噸"; +// back = true; +// } if (!back && staProtocol.isBarcodeErr()) { errMsg = "鎵爜澶辫触"; back = true; @@ -223,7 +225,7 @@ TaskWrk taskWrk1 = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("barcode", barcode)); if (!Cools.isEmpty(taskWrk1)) { log.info("鎵樼洏鐮侊細" + barcode + "浠诲姟妗e瓨鍦�"); - if (taskWrk1.getIoType() == 1 && taskWrk1.getStatus() < 3 && taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString())) { + if (taskWrk1.getIoType() == 1 && taskWrk1.getStatus() < 3 && (taskWrk1.getStartPoint().equals(staProtocol.getSiteId().toString()) || taskWrk1.getStartPoint().equals(String.valueOf((staProtocol.getSiteId()+1))))) { StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() .eq("CRN_NO", taskWrk1.getCrnNo()).eq("TYPE_NO", 1).eq("STN_NO", staProtocol.getSiteId())); @@ -382,10 +384,10 @@ errMsg = "鍙宠秴闄�"; back = true; } - if (!back && staProtocol.isWeightErr()) { - errMsg = "瓒呴噸"; - back = true; - } +// if (!back && staProtocol.isWeightErr()) { +// errMsg = "瓒呴噸"; +// back = true; +// } // 閫�鍥� if (back) { if (stano == inSta.getBackSta().shortValue()) { @@ -701,6 +703,51 @@ } /** + * 鍫嗗灈鏈�5鍒嗛挓鏃犱换鍔″垯鍥炲埌婧愮偣 + */ + public void crnStnToOutStnSou() { + for (CrnSlave crn : slaveProperties.getCrn()) { + try{ + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + BasCrnp basCrnp = basCrnpService.selectById(crn.getId()); + if (basCrnp == null) { + log.error("{}鍙峰爢鍨涙満灏氭湭鍦ㄦ暟鎹簱杩涜缁存姢锛�", crn.getId()); + continue; + } + + if (crnProtocol.getLaneNo()!=0 && (crnProtocol.getBay()!=1 || crnProtocol.getLevel()!=1)){ + if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.statusType == CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0) { + //鑾峰彇宸ヤ綔妗� + List<TaskWrk> taskWrks = taskWrkMapper.selectByLaneNo(crnProtocol.getLaneNo()); + if (!taskWrks.isEmpty()) { + continue; + } + List<TaskWrkLog> taskWrkLogs = taskWrkLogService.selectList(new EntityWrapper<TaskWrkLog>().eq("CRN_NO",crnProtocol.getLaneNo()).orderBy("COMPLETE_TIME",true)); + if (taskWrkLogs.isEmpty()) { + CrnCommand command = new CrnCommand(); + if (!MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(4, command))) { + log.error("鍫嗗灈鏈鸿嚜鍔ㄥ洖婧愮偣澶辫触锛屽爢鍨涙満鍙�={}", crnProtocol.getCrnNo()); + } + } +// long differenceInSeconds = TimeCalculatorUtils.differenceInMilliseconds(taskWrkLogs.get(0).getCompleteTime(), new Date()); +// if (differenceInSeconds <= 1000) { +// return; +// } + + } + } + } catch (Exception e){ + log.error("鍫嗗灈鏈�5鍒嗛挓鏃犱换鍔″垯鍥炲埌婧愮偣澶辫触"); + } + } + } + + /** * 鍏ュ嚭搴� ===>> 鍫嗗灈鏈哄叆鍑哄簱浣滀笟涓嬪彂 */ public synchronized void crnIoExecute() throws IOException { @@ -727,8 +774,12 @@ } } - // 搴撲綅绉昏浆 - this.locToLoc(crn, crnProtocol); + try{ + // 搴撲綅绉昏浆 + this.locToLoc(crn, crnProtocol); + } catch (Exception e) { + log.error("搴撲綅绉昏浆澶辫触"); + } // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO @@ -1206,80 +1257,81 @@ */ public void storeFinished() throws InterruptedException { for (CrnSlave crnSlave : slaveProperties.getCrn()) { - // 鑾峰彇鍫嗗灈鏈轰俊鎭� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnSlave.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { - continue; - } - - CrnSlave crn = new CrnSlave(crnSlave); - - if (!crnSlave.getId().equals(crnProtocol.getLaneNo())) { - for (CrnSlave crnOther : slaveProperties.getCrn()) { - if (crnOther.getId().equals(crnProtocol.getLaneNo())) { - crn.updateCrnInStn(crnOther); - } - } - } - - // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 - if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { - //鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 - TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crnProtocol.getLaneNo(), crnProtocol.getTaskNo().intValue()); - if (Cools.isEmpty(taskWrk) && crnProtocol.getTaskNo() != 999) { - log.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽贩閬撳彿={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getLaneNo(), crnProtocol.getTaskNo()); + try{ + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnSlave.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { continue; } -// Thread.sleep(300); - //纭瀹屾垚淇″彿 - CrnOperatorParam crnOperatorParam = new CrnOperatorParam(); - crnOperatorParam.setCrnNo(crn.getId()); - Date now = new Date(); - crnController.crnTaskComplete(crnOperatorParam); - if (!Cools.isEmpty(taskWrk)) { - if (taskWrk.getIoType() == 1 && taskWrk.getWrkSts() == 3) { - taskWrk.setWrkSts(4);//鍏ュ簱瀹屾垚 - taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 - //鏇存柊搴撲綅鐘舵�� - LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); - locMast.setLocSts("F");//F.鍦ㄥ簱 - locMast.setBarcode(taskWrk.getBarcode());//鎵樼洏鐮� - locMast.setModiTime(now); - locMast.setModiUser(9999L); - locMastService.updateById(locMast); - } else if (taskWrk.getIoType() == 2 && taskWrk.getWrkSts() == 12) { - taskWrk.setWrkSts(13);//鍑哄簱瀹屾垚 - taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 - //鏇存柊搴撲綅鐘舵�� - LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); - locMast.setLocSts("O");//O.绌哄簱浣� - locMast.setBarcode("");//鎵樼洏鐮� - locMast.setModiTime(now); - locMast.setModiUser(9999L); - locMastService.updateById(locMast); - } else if (taskWrk.getIoType() == 3 && taskWrk.getWrkSts() == 12) { - taskWrk.setWrkSts(4);//鍏ュ簱瀹屾垚 - taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 - //鏇存柊搴撲綅鐘舵�� - LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); - locMast.setLocSts("F");//F.鍦ㄥ簱 - locMast.setBarcode(taskWrk.getBarcode());//鎵樼洏鐮� - locMast.setModiTime(now); - locMast.setModiUser(9999L); - locMastService.updateById(locMast); + CrnSlave crn = new CrnSlave(crnSlave); - LocMast locMast1 = locMastService.selectByLocNo(taskWrk.getStartPoint()); - locMast1.setLocSts("O");//O.绌哄簱浣� - locMast1.setBarcode("");//鎵樼洏鐮� - locMast1.setModiTime(now); - locMast1.setModiUser(9999L); - locMastService.updateById(locMast1); + if (!crnSlave.getId().equals(crnProtocol.getLaneNo())) { + for (CrnSlave crnOther : slaveProperties.getCrn()) { + if (crnOther.getId().equals(crnProtocol.getLaneNo())) { + crn.updateCrnInStn(crnOther); + } } - taskWrk.setModiTime(now); - taskWrk.setCompleteTime(now); - taskWrkService.updateById(taskWrk); + } + + // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 + if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { + //鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 + TaskWrk taskWrk = taskWrkMapper.selectCrnNoInWorking(crnProtocol.getLaneNo(), crnProtocol.getTaskNo().intValue()); + if (Cools.isEmpty(taskWrk) && crnProtocol.getTaskNo() != 999) { + log.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽贩閬撳彿={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getLaneNo(), crnProtocol.getTaskNo()); + continue; + } +// Thread.sleep(300); + //纭瀹屾垚淇″彿 + CrnOperatorParam crnOperatorParam = new CrnOperatorParam(); + crnOperatorParam.setCrnNo(crn.getId()); + Date now = new Date(); + + crnController.crnTaskComplete(crnOperatorParam); + if (!Cools.isEmpty(taskWrk)) { + if (taskWrk.getIoType() == 1 && taskWrk.getWrkSts() == 3) { + taskWrk.setWrkSts(4);//鍏ュ簱瀹屾垚 + taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 + //鏇存柊搴撲綅鐘舵�� + LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); + locMast.setLocSts("F");//F.鍦ㄥ簱 + locMast.setBarcode(taskWrk.getBarcode());//鎵樼洏鐮� + locMast.setModiTime(now); + locMast.setModiUser(9999L); + locMastService.updateById(locMast); + } else if (taskWrk.getIoType() == 2 && taskWrk.getWrkSts() == 12) { + taskWrk.setWrkSts(13);//鍑哄簱瀹屾垚 + taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 + //鏇存柊搴撲綅鐘舵�� + LocMast locMast = locMastService.selectByLocNo(taskWrk.getStartPoint()); + locMast.setLocSts("O");//O.绌哄簱浣� + locMast.setBarcode("");//鎵樼洏鐮� + locMast.setModiTime(now); + locMast.setModiUser(9999L); + locMastService.updateById(locMast); + } else if (taskWrk.getIoType() == 3 && taskWrk.getWrkSts() == 12) { + taskWrk.setWrkSts(4);//鍏ュ簱瀹屾垚 + taskWrk.setStatus(TaskStatusType.OVER.id);//瀹岀粨 + //鏇存柊搴撲綅鐘舵�� + LocMast locMast = locMastService.selectByLocNo(taskWrk.getTargetPoint()); + locMast.setLocSts("F");//F.鍦ㄥ簱 + locMast.setBarcode(taskWrk.getBarcode());//鎵樼洏鐮� + locMast.setModiTime(now); + locMast.setModiUser(9999L); + locMastService.updateById(locMast); + + LocMast locMast1 = locMastService.selectByLocNo(taskWrk.getStartPoint()); + locMast1.setLocSts("O");//O.绌哄簱浣� + locMast1.setBarcode("");//鎵樼洏鐮� + locMast1.setModiTime(now); + locMast1.setModiUser(9999L); + locMastService.updateById(locMast1); + } + taskWrk.setModiTime(now); + taskWrk.setCompleteTime(now); + taskWrkService.updateById(taskWrk); // try { @@ -1319,8 +1371,11 @@ // log.error("wcs瀹岀粨浠诲姟涓婃姤wms澶辫触,鎶ラ敊淇℃伅锛�", e); //// throw new CoolException("wcs娲惧彂鍏ュ簱浠诲姟涓婃姤wms澶辫触"); // } - } + } + } + } catch (Exception e){ + log.error("鍫嗗灈鏈烘墽琛屽宸ヤ綔妗g殑瀹屾垚鎿嶄綔澶辫触 ===>> [id:{}] [error:{}]", crnSlave.getId(), e.getMessage()); } } } @@ -1331,114 +1386,117 @@ public void recCrnErr() { Date now = new Date(); for (CrnSlave crn : slaveProperties.getCrn()) { - // 鑾峰彇鍫嗗灈鏈轰俊鎭� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { - continue; - } - if (crnProtocol.getModeType() != CrnModeType.STOP) { - // 鏈変换鍔� - if (crnProtocol.getTaskNo() != 0) { - BasErrLog latest = basErrLogService.findLatestByTaskNo(crn.getId(), crnProtocol.getTaskNo().intValue()); - // 鏈夊紓甯� - if (latest == null) { + try{ + // 鑾峰彇鍫嗗灈鏈轰俊鎭� + CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); + CrnProtocol crnProtocol = crnThread.getCrnProtocol(); + if (crnProtocol == null) { + continue; + } + 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) { + TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); + if (taskWrk == null) { + continue; + } + BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm().intValue()); + String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); + BasErrLog basErrLog = new BasErrLog( + null, // 缂栧彿 + taskWrk.getWrkNo(), // 宸ヤ綔鍙� + now, // 鍙戠敓鏃堕棿 + null, // 缁撴潫鏃堕棿 + taskWrk.getWrkSts().longValue(), // 宸ヤ綔鐘舵�� + taskWrk.getIoType(), // 鍏ュ嚭搴撶被鍨� + crn.getId(), // 鍫嗗灈鏈� + null, // plc + taskWrk.getTargetPoint(), // 鐩爣搴撲綅 + 0, // 鐩爣绔� + 0, // 婧愮珯 + taskWrk.getStartPoint(), // 婧愬簱浣� + taskWrk.getBarcode(), // 鏉$爜 + (int) crnProtocol.getAlarm(), // 寮傚父鐮� + errName, // 寮傚父 + 1, // 寮傚父鎯呭喌 + taskWrk.getCreateTime(), // 浠诲姟鏃堕棿(鎺ユ敹鏃堕棿) + null, // 娣诲姞浜哄憳 + now, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + "浠诲姟涓紓甯�" // 澶囨敞 + ); + if (!basErrLogService.insert(basErrLog)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); + } + } + } 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()); + } + } + } + // 鏃犱换鍔� + } else { + BasErrLog latest = basErrLogService.findLatest(crn.getId()); + // 鏈夊紓甯� if (crnProtocol.getAlarm() != null && crnProtocol.getAlarm() > 0) { - TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(crnProtocol.getTaskNo())); - if (taskWrk == null) { - continue; + // 璁板綍鏂板紓甯� + 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); + } } - BasCrnError crnError = basCrnErrorMapper.selectById(crnProtocol.getAlarm().intValue()); - String errName = crnError == null ? String.valueOf(crnProtocol.getAlarm()) : crnError.getErrName(); - BasErrLog basErrLog = new BasErrLog( - null, // 缂栧彿 - taskWrk.getWrkNo(), // 宸ヤ綔鍙� - now, // 鍙戠敓鏃堕棿 - null, // 缁撴潫鏃堕棿 - taskWrk.getWrkSts().longValue(), // 宸ヤ綔鐘舵�� - taskWrk.getIoType(), // 鍏ュ嚭搴撶被鍨� - crn.getId(), // 鍫嗗灈鏈� - null, // plc - taskWrk.getTargetPoint(), // 鐩爣搴撲綅 - 0, // 鐩爣绔� - 0, // 婧愮珯 - taskWrk.getStartPoint(), // 婧愬簱浣� - taskWrk.getBarcode(), // 鏉$爜 - (int) crnProtocol.getAlarm(), // 寮傚父鐮� - errName, // 寮傚父 - 1, // 寮傚父鎯呭喌 - now, // 娣诲姞鏃堕棿 - null, // 娣诲姞浜哄憳 - now, // 淇敼鏃堕棿 - null, // 淇敼浜哄憳 - "浠诲姟涓紓甯�" // 澶囨敞 - ); - if (!basErrLogService.insert(basErrLog)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", crn.getId(), errName); - } - } - } 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()); - } - } - } - // 鏃犱换鍔� - } 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); - } - } - // 鏃犲紓甯� - } 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 { + // 寮傚父淇 + 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()); + } } } } } + } catch (Exception e){ + log.error("鍫嗗灈鏈哄紓甯镐俊鎭褰曞け璐� ===>> [id:{}] [error:{}]", crn.getId(), e.getMessage()); } - } } @@ -1632,12 +1690,15 @@ if (taskWrk != null) { Integer stano = staProtocol.getStaNo(); if (staProtocol.getSiteId() == 1004 || staProtocol.getSiteId()==1020){ - + // 鍒ゆ柇鏄惁婊¤冻鍙栬揣鏉′欢 + if (!staProtocol.isLoading()) { + return null; + } // 灏哄妫�娴嬪紓甯� boolean back = false; String errMsg = "-"; if (staProtocol.getGrossWt()>=600){ - errMsg = "瓒呴噸"; + errMsg = "瓒呴噸锛�"+staProtocol.getGrossWt()+"kg"; back = true; } if (staProtocol.isFrontErr()) { @@ -1660,10 +1721,10 @@ errMsg = "鍙宠秴闄�"; back = true; } - if (!back && staProtocol.isWeightErr()) { - errMsg = "瓒呴噸"; - back = true; - } +// if (!back && staProtocol.isWeightErr()) { +// errMsg = "瓒呴噸"; +// back = true; +// } if (!back && staProtocol.isBarcodeErr()) { errMsg = "鎵爜澶辫触"; back = true; @@ -1712,6 +1773,52 @@ } } return null; + } + public boolean deviceDetection(RgvSlave.RgvStn inSta,Integer rgvNo) { + ArrayList<Integer> arrayList = new ArrayList<Integer>() {{ + add(1009); + add(1011); + add(1012); + add(1014); + add(1016); + }}; + try{ + + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, inSta.getDevpPlcId()); + ArrayList<Integer> listW = new ArrayList<Integer>(); + ArrayList<Integer> listL = new ArrayList<Integer>(); + for (Integer staNo : arrayList){ + StaProtocol staProtocol = devpThread.getStation().get(staNo); + if (staProtocol == null) { + RgvErrCache.updateRgvErr(rgvNo,staNo+"绔欑偣鏁版嵁涓㈠け"); + return false; + } + // 鍒ゆ柇鏄惁婊¤冻鍙栬揣鏉′欢 + if (staProtocol.getWorkNo() != 0) { + if (!listW.contains(staProtocol.getWorkNo())) { + listW.add(staProtocol.getWorkNo()); + } + } + // 鍒ゆ柇鏄惁婊¤冻鍙栬揣鏉′欢 + if (staProtocol.isLoading()) { + if (!listL.contains(staProtocol.getStaNo())) { + listL.add(staProtocol.getStaNo()); + } + } + } + if (listW.size()>=3){ + RgvErrCache.updateRgvErr(rgvNo,"绛夊緟1012鎷i�夛紝闃叉鍫靛"); + return false; + } + if (listL.size()>=3){ + RgvErrCache.updateRgvErr(rgvNo,"绛夊緟1012鎷i�夛紝闃叉鍫靛"); + return false; + } + } catch (Exception e){ + RgvErrCache.updateRgvErr(rgvNo,"1012妫�娴嬪紓甯革細"+e.getMessage()); + return false; + } + return true; } public boolean rgvOtherStatusEnable(RgvSlave slave) { @@ -1775,6 +1882,7 @@ if (rgvOtherIDLEOther(rgvSlave)){ if (!rgvOtherIDLE(rgvSlave,staList.get(0))){ System.out.println("绌洪棽灏辫繎璺宠繃==="+rgvSlave.getId()+"==="); + RgvErrCache.updateRgvErr(rgvSlave.getId(),staList.get(0)+"绌洪棽灏辫繎璺宠繃"); sign=true; } @@ -1855,6 +1963,8 @@ if (rgvOtherIDLEOther2(rgvSlave)){ if (!rgvOtherIDLE2(rgvSlave,staList.get(0))){ System.out.println("杩愯灏辫繎璺宠繃==="+rgvSlave.getId()+"==="); + RgvErrCache.updateRgvErr(rgvSlave.getId(),staList.get(0)+"杩愯灏辫繎璺宠繃"); + sign=true; } } @@ -2017,6 +2127,8 @@ } } + RgvErrCache.updateRgvErr(rgvSlave.getId(),"鏈煡璇㈠埌鍙墽琛屼换鍔�"); + } else { //鍙敤鍖哄煙灏辫繎鍙栬揣 //灏辫繎鎺掑簭 @@ -2103,6 +2215,11 @@ if (targetPointConvert == null) { return false; } + if (targetPointConvert == 1009){ + if (!deviceDetection(rgvStn, rgvSlave.getId())){ + return false; + } + } BasDevpPosition basDevpPositionSou = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", rgvStn.getStaNo())); BasDevpPosition basDevpPositionEnd = basDevpPositionService.selectOne(new EntityWrapper<BasDevpPosition>().eq("DEV_NO", targetPointConvert)); @@ -2139,6 +2256,8 @@ } } catch (Exception e) { log.error("浠诲姟鐢熸垚澶辫触issued1===銆嬪紓甯镐俊鎭細{}", e.getMessage()); + RgvErrCache.updateRgvErr(rgvSlave.getId(),rgvStn.getStaNo()+"绔欑偣浠诲姟鐢熸垚澶辫触issued1"); + return false; } @@ -2156,6 +2275,7 @@ } } catch (Exception e) { log.error("浠诲姟鐢熸垚澶辫触issued2===銆嬪紓甯镐俊鎭細{}", e.getMessage()); + RgvErrCache.updateRgvErr(rgvSlave.getId(),rgvStn.getStaNo()+"绔欑偣浠诲姟鐢熸垚澶辫触issued2"); } return true; } -- Gitblit v1.9.1