From 083ceafc0a7631c92df9464303deae343ef103ac Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期五, 11 三月 2022 14:30:51 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 853 ++++++++++++++------------------------------------------ 1 files changed, 222 insertions(+), 631 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 1c42ffe..5209aa8 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.core.common.Cools; -import com.core.common.DateUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.*; import com.zy.asrs.mapper.BasCrnErrorMapper; @@ -13,7 +12,6 @@ import com.zy.asrs.mapper.WrkMastMapper; import com.zy.asrs.service.*; import com.zy.asrs.utils.Utils; -import com.zy.asrs.utils.VersionUtils; import com.zy.common.model.LocTypeDto; import com.zy.common.model.MatDto; import com.zy.common.model.SearchLocParam; @@ -174,64 +172,6 @@ log.error("璇锋眰鎺ュ彛澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", wmsUrl+"/rpc/pakin/loc/v1", JSON.toJSONString(param), response); } - -// // 妫�绱㈠簱浣� -// LocTypeDto locTypeDto = new LocTypeDto(staProtocol); -// List<String> matNos = waitPakins.stream().map(WaitPakin::getMatnr).distinct().collect(Collectors.toList()); -// StartupDto startupDto = commonService.getLocNo(1, 1, inSta.getStaNo(), matNos, locTypeDto, 0); -// // 宸ヤ綔鍙� -// int workNo = startupDto.getWorkNo(); -// // 鎻掑叆宸ヤ綔鏄庣粏妗� -// wrkDetlService.createWorkDetail(workNo, waitPakins, barcode); -// -// // 鎻掑叆宸ヤ綔涓绘。 -// wrkMast = new WrkMast(); -// wrkMast.setWrkNo(workNo); -// wrkMast.setIoTime(new Date()); -// wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 -// wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱 -// wrkMast.setIoPri(10D); // 浼樺厛绾э細10 -// wrkMast.setCrnNo(startupDto.getCrnNo()); -// wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); -// wrkMast.setStaNo(startupDto.getStaNo()); -// wrkMast.setLocNo(startupDto.getLocNo()); -// wrkMast.setBarcode(barcode); // 鎵樼洏鐮� -// wrkMast.setFullPlt("Y"); // 婊℃澘锛歒 -// wrkMast.setPicking("N"); // 鎷f枡 -// wrkMast.setExitMk("N"); // 閫�鍑� -// wrkMast.setEmptyMk("N"); // 绌烘澘 -// wrkMast.setLinkMis("N"); -// // 鎿嶄綔浜哄憳鏁版嵁 -// wrkMast.setAppeTime(new Date()); -// wrkMast.setModiTime(new Date()); -// Integer insert = wrkMastMapper.insert(wrkMast); -// if (insert == 0) { -// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); -// } -// // 鏇存柊鐩爣搴撲綅鐘舵�� -// LocMast locMast = locMastService.selectById(startupDto.getLocNo()); -// locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 -// locMast.setModiTime(new Date()); -// if (!locMastService.updateById(locMast)){ -// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); -// } -// // 灏嗗叆搴撻�氱煡妗d慨鏀逛负宸插惎鍔� -// if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) { -// throw new CoolException("淇敼鍏ュ簱閫氱煡妗g姸鎬佷负宸插惎鍔ㄥけ璐�"); -// } -// -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 -// barcodeThread.setBarcode(""); -// staProtocol.setWorkNo((short) workNo); -// staProtocol.setStaNo(startupDto.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绔欑偣淇℃伅澶辫触"); -// } - } catch (Exception e) { e.printStackTrace(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); @@ -338,15 +278,6 @@ continue; } - // 鎷c�佺洏銆佸苟 浣滀笟绔欒浆鎹� -// int stnNo = 0; -// if (wrkMast.getStaNo() == 109) { -// stnNo = 127; -// } else if (wrkMast.getStaNo() == 113) { -// stnNo = 128; -// } else { -// log.error("{}鍙蜂换鍔℃暟鎹紓甯革紒", wrkMast.getWrkNo()); -// } // 鑾峰彇鐩爣绔� Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() .eq("type_no", wrkMast.getIoType() - 50) @@ -428,7 +359,7 @@ } if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) { // 鏌ヨ宸ヤ綔妗� - WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId()); + WrkMast wrkMast = wrkMastMapper.selectPakOutStep16(staProtocol.getSiteId()); if (wrkMast == null) { continue; } @@ -457,14 +388,14 @@ continue; } - // 鏇存柊宸ヤ綔妗g姸鎬佷负14澶辫触 - wrkMast.setWrkSts(14L); + // 鏇存柊宸ヤ綔妗g姸鎬佷负 17.鍑哄簱瀹屾垚 + wrkMast.setWrkSts(17L); wrkMast.setCrnEndTime(new Date()); if (wrkMastMapper.updateById(wrkMast) != 0) { // 澶嶄綅鍫嗗灈鏈� crnThread.setResetFlag(true); } else { - log.error("鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负14澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); + log.error("鏇存柊宸ヤ綔妗g殑宸ヤ綔鐘舵�佷负 17.鍑哄簱瀹屾垚 澶辫触锛侊紒锛� [宸ヤ綔鍙�:{}]", wrkMast.getWrkNo()); } } @@ -498,15 +429,19 @@ crnProtocol.setLastIo("O"); } } else if (basCrnp.getOutEnable().equals("Y")) { - this.locToCrnStn(crn, crnProtocol); // 鍑哄簱 - crnProtocol.setLastIo("I"); + // 鍑哄簱 + if (this.locToCrnStn(crn, crnProtocol)) { + crnProtocol.setLastIo("I"); + } } } // 濡傛灉鏈�杩戜竴娆℃槸鍑哄簱妯″紡 else if (crnProtocol.getLastIo().equals("O")) { if (basCrnp.getOutEnable().equals("Y")) { - this.locToCrnStn(crn, crnProtocol); // 鍑哄簱 - crnProtocol.setLastIo("I"); + // 鍑哄簱 + if (this.locToCrnStn(crn, crnProtocol)) { + crnProtocol.setLastIo("I"); + } } else if (basCrnp.getInEnable().equals("Y")) { // 鍏ュ簱 if (this.crnStnToLoc(crn, crnProtocol)) { @@ -515,8 +450,6 @@ } } } - // 搴撲綅绉昏浆 - this.locToLoc(crn, crnProtocol); } } @@ -571,7 +504,7 @@ // 鏈夊皬杞� if (steNo != null) { // 灏忚溅琛岃蛋鍒板爢鍨涙満寰呮惉绉荤偣 - if (wrkMast.getWrkSts() == 2L) { + if (wrkMast.getWrkSts() == 2L && wrkMast.getStaNo() == null) { this.letCarBeReady(wrkMast, steNo); } // 灏忚溅鎼蛋 @@ -731,7 +664,7 @@ } /** - * 鍏ュ簱 ===>> 鍫嗗灈鏈烘惉鍏ュ皬杞� + * 鍏ュ嚭搴� ===>> 鍫嗗灈鏈烘惉鍏ュ皬杞� */ public void carMoveIn(WrkMast wrkMast, Integer steNo, CrnProtocol crnProtocol) { // 鑾峰彇鍫嗗灈鏈轰俊鎭� @@ -742,6 +675,7 @@ // 鍫嗗灈鏈虹┖闂� if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) { LocMast locMast; + // 鍏ュ簱鎼� if (wrkMast.getWrkSts() <= 10) { locMast = locMastService.selectById(wrkMast.getLocNo()); // 鍫嗗灈鏈哄懡浠や笅鍙戝尯 -------------------------------------------------------------------------- @@ -768,7 +702,33 @@ log.error("淇敼宸ヤ綔妗g姸鎬� 3.灏忚溅寰呮惉 => 4.杩佸叆灏忚溅 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } } - + // 鍑哄簱鎼� + } else { + locMast = locMastService.selectById(wrkMast.getSourceLocNo()); + // 鍫嗗灈鏈哄懡浠や笅鍙戝尯 -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosX(steProtocol.getRow()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY(steProtocol.getBay()); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ(steProtocol.getLev()); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX(Utils.getGroupRow(locMast.getLocNo()).shortValue()); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 12.灏忚溅寰呮惉 => 13.杩佸叆灏忚溅 + Date now = new Date(); + wrkMast.setWrkSts(13L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 12.灏忚溅寰呮惉 => 13.杩佸叆灏忚溅 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } } } @@ -787,6 +747,14 @@ if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { // 鍫嗗灈鏈虹┖闂� if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) { + + BasSte basSte = basSteService.selectById(steNo); + if (basSte == null) { + log.error("{}鍙风┛姊溅鍦ㄦ暟鎹簱涓嶅瓨鍦紒锛侊紒", steNo); + return; + } + String idleLocNo = basSte.getIdleLoc(); + // 鍫嗗灈鏈哄懡浠や笅鍙戝尯 -------------------------------------------------------------------------- CrnCommand crnCommand = new CrnCommand(); crnCommand.setCrnNo(crnProtocol.getCrnNo()); // 鍫嗗灈鏈虹紪鍙� @@ -796,9 +764,9 @@ crnCommand.setSourcePosX(steProtocol.getRow()); // 婧愬簱浣嶆帓 crnCommand.setSourcePosY(steProtocol.getBay()); // 婧愬簱浣嶅垪 crnCommand.setSourcePosZ(steProtocol.getLev()); // 婧愬簱浣嶅眰 - crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 鐩爣搴撲綅鎺� - crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 鐩爣搴撲綅鍒� - crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 鐩爣搴撲綅灞� + crnCommand.setDestinationPosX((short) Utils.getRow(idleLocNo)); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY((short) Utils.getBay(idleLocNo)); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ((short) Utils.getLev(idleLocNo)); // 鐩爣搴撲綅灞� if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); } else { @@ -820,10 +788,10 @@ /** * 鍑哄簱 ===>> 搴撲綅鍒板爢鍨涙満绔� */ - public void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){ + public boolean locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){ for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) { // 鑾峰彇宸ヤ綔鐘舵�佷负11锛堢敓鎴愬嚭搴揑D锛夌殑鍑哄簱宸ヤ綔妗� - WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo()); + WrkMast wrkMast = wrkMastMapper.selectPakOutStep11(slave.getId(), crnStn.getStaNo()); if (wrkMast == null) { continue; } @@ -862,173 +830,126 @@ continue; } - // 鍙屾繁搴撲綅涓旀祬搴撲綅鏈夎揣锛屽垯闇�鍏堝娴呭簱浣嶈繘琛屽簱浣嶇Щ杞� - if (Utils.isDeepLoc(slaveProperties, wrkMast.getSourceLocNo())) { - String shallowLocNo = Utils.getShallowLoc(slaveProperties, wrkMast.getSourceLocNo()); - LocMast shallowLoc = locMastService.selectById(shallowLocNo); - // O.绌哄簱浣嶃�丵.鎷f枡/鐩樼偣/骞舵澘鍐嶅叆搴撱�丼.鍏ュ簱棰勭害銆乆.绂佺敤 鐩存帴鎼紒 - if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) { - WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo); - if (null == waitWrkMast) { - log.error("{}搴撲綅寮傚父锛屾湭妫�绱㈠埌鐩稿簲宸ヤ綔妗o紒", shallowLocNo); - } else { - waitWrkMast.setIoPri(15D); - waitWrkMast.setModiTime(new Date()); - if (wrkMastMapper.updateById(waitWrkMast) == 0) { - log.error("璋冩暣宸ヤ綔妗d紭鍏堢骇澶辫触锛佸伐浣滃彿={}", waitWrkMast.getWrkNo()); + // 鏈�澶栧眰搴撲綅锛岀洿鎺ュ爢鍨涙満鍑哄簱 + if (locMastService.isOutMost(wrkMast.getLocNo())) { + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(slave.getId()) != null) { + continue; + } + + // 鍫嗗灈鏈哄嚭搴� 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 16.鍚婅溅鍑哄簱涓� + Date now = new Date(); + wrkMast.setWrkSts(16L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 16.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + return true; + } + // 涓嶆槸鏈�澶栧眰搴撲綅锛岄渶瑕佷娇鐢ㄧ┛姊溅鎼繍鍚庯紝鍐嶅爢鍨涙満鍑哄簱 + } else { + // 褰撳墠缁勫簱浣嶆槸鍚︽湁绌挎杞� + Integer steNo = this.hasCarOfIdle(wrkMast.getLocNo()); + // 鏈夊皬杞� + if (steNo != null) { + if (wrkMast.getWrkSts() == 11L && wrkMast.getSteNo() == null) { + + // 缁欑┛姊溅涓嬪彂鍛戒护 璁╁叾灏嗚揣鐗╂尓鑷冲爢鍨涙満鎼繍鐐� + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { continue; } + if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { + + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + SteCommand steCommand = new SteCommand(); + steCommand.setSteNo(steNo); // 绌挎杞︾紪鍙� + steCommand.setTaskNo(wrkMast.getWrkNo()); // 宸ヤ綔鍙� + steCommand.setTaskMode(SteTaskModeType.TO_B); // 浠诲姟妯″紡: 鍘昏繎鐐� 绛夊緟鍫嗗灈鏈哄弶鍙� + // todo:luxiaotao + if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) { + log.error("绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", steNo, JSON.toJSON(steCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 14.灏忚溅鎼嚭搴� + Date now = new Date(); + wrkMast.setWrkSts(14L); + wrkMast.setSteNo(steNo); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 14.灏忚溅鎼嚭搴� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } } } - continue; - } else if (shallowLoc.getLocSts().equals("F") || shallowLoc.getLocSts().equals("D")) { - // 姝ゆ爣璁伴伩鍏嶅娆℃墽琛岀Щ搴撲换鍔� - if (Cools.isEmpty(wrkMast.getUpdMk()) || "N".equals(wrkMast.getUpdMk())) { - wrkMast.setUpdMk("Y"); - wrkMastMapper.updateById(wrkMast); - // 鐢熸垚宸ヤ綔妗c�佹敼鍙樻祬搴撲綅鐨勬簮搴�/鐩爣搴� 搴撲綅鐘舵�併�佷笅鍙戝爢鍨涙満鍛戒护锛堢珛椹墽琛�) - moveLocForDeepLoc(slave, shallowLoc); + if (wrkMast.getWrkSts() == 15L) { + // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� + if (wrkMastMapper.selectWorking(slave.getId()) != null) { + continue; + } + + // 鍫嗗灈鏈哄嚭搴� 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + CrnCommand crnCommand = new CrnCommand(); + crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� + crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� + crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� + crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 + crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 + crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 + crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 + crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺� + crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� + crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� + if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { + log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); + } else { + // 淇敼宸ヤ綔妗g姸鎬� 15.绛夊緟鍚婅溅 => 16.鍚婅溅鍑哄簱涓� + Date now = new Date(); + wrkMast.setWrkSts(16L); + wrkMast.setCrnStrTime(now); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 15.绛夊緟鍚婅溅 => 16.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + return true; + } } - log.error("{}浠诲姟鍑哄簱澶辫触锛屾祬搴撲綅鍫靛锛�", wrkMast.getWrkNo()); - continue; + + // 娌℃湁灏忚溅 + } else { + if (wrkMast.getWrkSts() == 11L && wrkMast.getStaNo() == null) { + // 瀵绘壘鏈�杩戠殑灏忚溅 + SteThread steThread = queryIdleCar(wrkMast); + if (steThread != null) { + // 璁╁皬杞︾瓑寰呮惉杩愬緟缁� + this.letCarBeReady(wrkMast, steThread.getSlave().getId()); + } + } + // 鍫嗗灈鏈烘惉杩愬皬杞� + if (wrkMast.getWrkSts() == 12L) { + this.carMoveIn(wrkMast, wrkMast.getSteNo(), crnProtocol); + } } } - // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� - if (wrkMastMapper.selectWorking(slave.getId()) != null) { - return; - } - - // 1.鍫嗗灈鏈哄紑濮嬬Щ鍔� - CrnCommand crnCommand = new CrnCommand(); - crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� - crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� - crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� - crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 - crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 - crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 - crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 - crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 鐩爣搴撲綅鎺� - crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 鐩爣搴撲綅鍒� - crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 鐩爣搴撲綅灞� - if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); - } else { - // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� - Date now = new Date(); - wrkMast.setWrkSts(12L); - wrkMast.setCrnStrTime(now); - wrkMast.setModiTime(now); - if (wrkMastMapper.updateById(wrkMast) == 0) { - log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); - } - } } } - } - - /** - * 搴撲綅绉昏浆 - */ - public void locToLoc(CrnSlave slave, CrnProtocol crnProtocol){ - // 鑾峰彇宸ヤ綔妗d俊鎭� - WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId()); - if (null == wrkMast) { - return; - } - // 鑾峰彇婧愬簱浣嶄俊鎭� - LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo()); - if (null == sourceSta) { - log.error("宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈡簮搴撲綅澶辫触锛佸伐浣滃彿={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo()); - return; - } - // 婧愬簱浣� 搴撲綅鐘舵�佸垽鏂� - if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("S")) { - return; - } - // 鑾峰彇鐩爣搴撲綅淇℃伅 - LocMast sta = locMastService.selectById(wrkMast.getLocNo()); - if (null == sta) { - log.error("宸ヤ綔妗e簱浣嶇Щ杞け璐ワ紝鍘熷洜锛氭绱㈢洰鏍囧簱浣嶅け璐ワ紒宸ヤ綔鍙�={}锛屾簮搴撲綅={}", wrkMast.getWrkNo(), wrkMast.getLocNo()); - return; - } - // 鑾峰彇鍫嗗灈鏈轰俊鎭� 骞� 鍒ゆ柇鏄惁鍙叆鍑� - BasCrnp basCrnp = basCrnpService.selectById(slave.getId()); - if (!basCrnp.getInEnable().equals("Y") && !basCrnp.getOutEnable().equals("Y")) { - return; - } - - // 鍫嗗灈鏈烘帶鍒惰繃婊� - if (!crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() != 0) { - return; - } - - // 宸茬粡瀛樺湪鍚婅溅鎵ц浠诲姟鏃讹紝鍒欒繃婊� - if (wrkMastMapper.selectLocMoving(slave.getId()) != null) { - return; - } - - // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- - CrnCommand crnCommand = new CrnCommand(); - crnCommand.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙� - crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 宸ヤ綔鍙� - crnCommand.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣� - crnCommand.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆 - crnCommand.setSourcePosX(sourceSta.getRow1().shortValue()); // 婧愬簱浣嶆帓 - crnCommand.setSourcePosY(sourceSta.getBay1().shortValue()); // 婧愬簱浣嶅垪 - crnCommand.setSourcePosZ(sourceSta.getLev1().shortValue()); // 婧愬簱浣嶅眰 - crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 鐩爣搴撲綅鎺� - crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 鐩爣搴撲綅鍒� - crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 鐩爣搴撲綅灞� - if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { - log.error("鍫嗗灈鏈哄懡浠や笅鍙戝け璐ワ紝鍫嗗灈鏈哄彿={}锛屼换鍔℃暟鎹�={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); - } else { - // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� - Date now = new Date(); - wrkMast.setWrkSts(12L); - wrkMast.setCrnStrTime(now); - wrkMast.setModiTime(now); - if (wrkMastMapper.updateById(wrkMast) == 0) { - log.error("銆愬簱浣嶇Щ杞�� 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); - } - } - - } - - - /** - * 鍫嗗灈鏈洪拡瀵逛簬灏忚溅杩佺Щ宸ヤ綔鐨勫畬鎴� - */ - @Async - public void carMoveFinished() { - for (CrnSlave crn : slaveProperties.getCrn()) { - // 鑾峰彇鍫嗗灈鏈轰俊鎭� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { continue; } - // 鐘舵�侊細绛夊緟纭 骞朵笖 浠诲姟瀹屾垚浣� = 1 - if (crnProtocol.statusType == CrnStatusType.WAITING && crnProtocol.getTaskNo() != 0) { - // 鑾峰彇鍏ュ簱寰呯‘璁ゅ伐浣滄。 - WrkMast wrkMast = wrkMastMapper.selectPakInStep45(crnProtocol.getTaskNo().intValue()); - if (wrkMast == null) { - log.error("鍫嗗灈鏈哄浜庣瓑寰呯‘璁や笖浠诲姟瀹屾垚鐘舵�侊紝浣嗘湭鎵惧埌宸ヤ綔妗c�傚爢鍨涙満鍙�={}锛屽伐浣滃彿={}", crn.getId(), crnProtocol.getTaskNo()); - continue; - } - // 鍏ュ簱 + 搴撲綅杞Щ ==> 6.灏忚溅寰呭叆 - if ((wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 5) || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)){ - wrkMast.setWrkSts(6L); - } else { - continue; - } - Date now = new Date(); - wrkMast.setCrnEndTime(now); - wrkMast.setModiTime(now); - // 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 - if (wrkMastMapper.updateById(wrkMast) > 0) { - // 鍫嗗灈鏈哄浣� - crnThread.setResetFlag(true); - } - - } - } + return false; } /** @@ -1051,7 +972,7 @@ continue; } // 鍏ュ簱 + 搴撲綅杞Щ - if (wrkMast.getWrkSts() == 7 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)){ + if (wrkMast.getWrkSts() == 7 || (wrkMast.getWrkSts() == 15 && wrkMast.getIoType() == 11)){ // 鍒ゆ柇鏄惁闇�瑕佸皬杞﹀叆搴� if (locMastService.isOutMost(wrkMast.getLocNo())) { // ==> 9.鍏ュ簱瀹屾垚 @@ -1096,7 +1017,7 @@ } } } - // 杩佸叆灏忚溅 瀹屾垚 + // 鍏ュ簱 ===>> 杩佸叆灏忚溅 瀹屾垚 } else if (wrkMast.getWrkSts() == 4) { // 4.杩佸叆灏忚溅 ==> 6.灏忚溅寰呭叆 wrkMast.setWrkSts(6L); @@ -1110,7 +1031,7 @@ } else { log.error("淇敼宸ヤ綔妗g姸鎬� 4.杩佸叆灏忚溅 => 6.灏忚溅寰呭叆 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } - // 杩佸嚭灏忚溅 瀹屾垚 + // 鍏ュ簱 ===>> 杩佸嚭灏忚溅 瀹屾垚 } else if (wrkMast.getWrkSts() == 5) { // 5.杩佸嚭灏忚溅 ==> 6.灏忚溅寰呭叆 wrkMast.setWrkSts(6L); @@ -1123,6 +1044,37 @@ crnThread.setResetFlag(true); } else { log.error("淇敼宸ヤ綔妗g姸鎬� 5.杩佸嚭灏忚溅 => 6.灏忚溅寰呭叆 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + // 鍑哄簱 ===>> 杩佸叆灏忚溅 瀹屾垚 + } else if (wrkMast.getWrkSts() == 13) { + // 缁欑┛姊溅涓嬪彂鍛戒护 + Integer steNo = wrkMast.getSteNo(); + SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo); + SteProtocol steProtocol = steThread.getSteProtocol(); + if (steProtocol == null) { continue; } + if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) { + // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- + SteCommand steCommand = new SteCommand(); + steCommand.setSteNo(steNo); // 绌挎杞︾紪鍙� + steCommand.setTaskNo(wrkMast.getWrkNo()); // 宸ヤ綔鍙� + steCommand.setTaskMode(SteTaskModeType.TO_B); // 浠诲姟妯″紡: 鍘昏繎鐐� 绛夊緟鍫嗗灈鏈哄弶鍙� + // todo:luxiaotao + if (!MessageQueue.offer(SlaveType.Ste, steNo, new Task(2, steCommand))) { + log.error("绌挎杞﹀懡浠や笅鍙戝け璐ワ紝绌挎杞﹀彿={}锛屼换鍔℃暟鎹�={}", steNo, JSON.toJSON(steCommand)); + } else { + // 13.杩佸叆灏忚溅 ==> 14.灏忚溅鎼嚭搴� + wrkMast.setWrkSts(14L); + Date now = new Date(); + wrkMast.setCrnEndTime(now); + wrkMast.setModiTime(now); + // 淇敼鎴愬姛鍚庡浣嶅爢鍨涙満 + if (wrkMastMapper.updateById(wrkMast) > 0) { + // 鍫嗗灈鏈哄浣� + crnThread.setResetFlag(true); + } else { + log.error("淇敼宸ヤ綔妗g姸鎬� 13.杩佸叆灏忚溅 ==> 14.灏忚溅鎼嚭搴� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } + } } } } @@ -1141,14 +1093,13 @@ if (steProtocol == null) { continue; } if (steProtocol.getStatusType().equals(SteStatusType.WAITING) && steProtocol.getTaskNo() != 0) { // 鏌ヨ鏄惁鏈夊緟鍏ュ簱鐨勪换鍔� - WrkMast wrkMast = wrkMastMapper.selectPakInStep8(steProtocol.getSteNo().intValue()); + WrkMast wrkMast = wrkMastMapper.selectCarWaiting(steProtocol.getTaskNo()); if (wrkMast == null) { continue; } switch (wrkMast.getWrkSts().intValue()) { case 2: // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.灏忚溅寰呮惉 wrkMast.setWrkSts(3L); - wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.灏忚溅寰呮惉 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); @@ -1159,10 +1110,29 @@ case 8: // 淇敼宸ヤ綔妗g姸鎬� 8.灏忚溅鎼叆搴� => 9.鍏ュ簱瀹屾垚 wrkMast.setWrkSts(9L); - wrkMast.setCrnStrTime(now); wrkMast.setModiTime(now); if (wrkMastMapper.updateById(wrkMast) == 0) { log.error("淇敼宸ヤ綔妗g姸鎬� 8.灏忚溅鎼叆搴� => 9.鍏ュ簱瀹屾垚 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } else { + steThread.setResetFlag(true); + } + break; + case 11: + // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.灏忚溅寰呮惉 + wrkMast.setWrkSts(12L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.灏忚溅寰呮惉 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); + } else { + steThread.setResetFlag(true); + } + break; + case 14: + // 淇敼宸ヤ綔妗g姸鎬� 14.灏忚溅鎼嚭搴� => 15.绛夊緟鍚婅溅 + wrkMast.setWrkSts(15L); + wrkMast.setModiTime(now); + if (wrkMastMapper.updateById(wrkMast) == 0) { + log.error("淇敼宸ヤ綔妗g姸鎬� 14.灏忚溅鎼嚭搴� => 15.绛夊緟鍚婅溅 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); } else { steThread.setResetFlag(true); } @@ -1366,62 +1336,6 @@ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - - - -// // 妫�绱㈠簱浣� -// LocTypeDto locTypeDto = new LocTypeDto(staProtocol); -// StartupDto startupDto = commonService.getLocNo(1, 10, emptyInSta.getStaNo(), null, locTypeDto, 0); -// // 宸ヤ綔鍙� -// int workNo = startupDto.getWorkNo(); -// -// try { -// // 鎻掑叆宸ヤ綔涓绘。 -// WrkMast wrkMast = new WrkMast(); -// wrkMast.setWrkNo(workNo); -// wrkMast.setIoTime(new Date()); -// wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細2.璁惧涓婅蛋 -// wrkMast.setIoType(10); // 鍏ュ嚭搴撶姸鎬侊細10.绌烘澘鍏ュ簱 -// wrkMast.setIoPri(10D); // 浼樺厛绾э細10 -// wrkMast.setCrnNo(startupDto.getCrnNo()); -// wrkMast.setSourceStaNo(startupDto.getSourceStaNo()); -// wrkMast.setStaNo(startupDto.getStaNo()); -// wrkMast.setLocNo(startupDto.getLocNo()); -// wrkMast.setFullPlt("N"); // 婊℃澘 -// wrkMast.setPicking("N"); // 鎷f枡 -// wrkMast.setExitMk("N"); // 閫�鍑� -// wrkMast.setEmptyMk("Y"); // 绌烘澘 -// wrkMast.setLinkMis("N"); -//// wrkMast.setCtnType(sourceStaNo.getCtnType()); // 瀹瑰櫒绫诲瀷 -// // 鎿嶄綔浜哄憳鏁版嵁 -// wrkMast.setAppeTime(new Date()); -// wrkMast.setModiTime(new Date()); -// Integer insert = wrkMastMapper.insert(wrkMast); -// if (insert == 0) { -// throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); -// } -// // 鏇存柊鐩爣搴撲綅鐘舵�� -// LocMast locMast = locMastService.selectById(startupDto.getLocNo()); -// locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 -// locMast.setModiTime(new Date()); -// if (!locMastService.updateById(locMast)){ -// throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); -// } -// // 鍛戒护涓嬪彂鍖� -------------------------------------------------------------------------- -// -// // 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护 -// staProtocol.setWorkNo((short) workNo); -// staProtocol.setStaNo(startupDto.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绔欑偣淇℃伅澶辫触"); -// } -// } catch (Exception e) { -// e.printStackTrace(); -// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); -// } - } @@ -1529,33 +1443,6 @@ */ @Async public void ledReset() { -// 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; -// } else { -// staProtocol = staProtocol.clone(); -// } -// if (staProtocol.getWorkNo() != 0) { -// reset = false; -// break; -// } -// } -// // 鑾峰彇led绾跨▼ -// LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId()); -// // led鏄剧ず榛樿鍐呭 -// if (reset) { -// if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) { -// log.error("{}鍙稬ED鍛戒护涓嬪彂澶辫触锛侊紒锛乕ip锛歿}] [port锛歿}]", led.getId(), led.getIp(), led.getPort()); -// } -// } -// } for (LedSlave led : slaveProperties.getLed()) { // 鑾峰彇杈撻�佺嚎plc绾跨▼ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); @@ -1586,304 +1473,8 @@ } } - /** - * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堝叆搴撶増) - * tip锛氬悓姝� - */ - @Transactional - public synchronized void moveLocForDeepLocPakin(CrnSlave crn, LocMast shallowLoc, WrkMast pakinWrkMast){ - LocMast loc = locMastService.selectById(pakinWrkMast.getLocNo()); - - // 鑾峰彇宸ヤ綔鍙� - int workNo = commonService.getWorkNo(0); - // 淇濆瓨宸ヤ綔妗� - WrkMast wrkMast = new WrkMast(); - wrkMast.setWrkNo(workNo); - wrkMast.setIoTime(new Date()); - wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID - wrkMast.setIoType(11); // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇 - wrkMast.setIoPri(15D); - wrkMast.setCrnNo(crn.getId()); - wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 婧愬簱浣� - wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅 - wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘 - wrkMast.setPicking("N"); // 鎷f枡 - wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 - wrkMast.setBarcode(shallowLoc.getBarcode()); // 鎵樼洏鐮� - wrkMast.setLinkMis("N"); - wrkMast.setCtnNo("Y"); // 鍏ュ簱闃诲搴撲綅绉昏浆鏍囪 - wrkMast.setAppeTime(new Date()); - wrkMast.setModiTime(new Date()); - int res = wrkMastMapper.insert(wrkMast); - if (res == 0) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); - } - // 宸ヤ綔妗f槑缁嗕繚瀛� - if (shallowLoc.getLocSts().equals("F")) { - List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); - for (LocDetl locDetl : locDetls) { - WrkDetl wrkDetl = new WrkDetl(); - wrkDetl.setWrkNo(workNo); - wrkDetl.setIoTime(new Date()); - wrkDetl.setQty(locDetl.getQty()); - VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 - wrkDetl.setAppeTime(new Date()); - wrkDetl.setModiTime(new Date()); - if (!wrkDetlService.insert(wrkDetl)) { - throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); - } - } - } - // 淇敼婧愬簱浣嶇姸鎬� - if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { - shallowLoc.setLocSts("S"); // S.鍏ュ簱棰勭害锛屽叆搴撻樆濉炲簱浣嶇Щ杞� - shallowLoc.setModiTime(new Date()); - if (!locMastService.updateById(shallowLoc)){ - throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); - } - } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); - } -// // 淇敼鐩爣搴撲綅鐘舵�� -// if (loc.getLocSts().equals("O")) { -// loc.setLocSts("S"); // S.鍏ュ簱棰勭害 -// loc.setModiTime(new Date()); -// if (!locMastService.updateById(loc)) { -// throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); -// } -// } else { -// throw new CoolException("绉昏浆澶辫触"); -// } - wrkMast.setLocNo(shallowLoc.getLocNo()); - if (wrkMastMapper.updateById(wrkMast) == 0) { - throw new CoolException("淇敼闃诲鍏ュ簱浠诲姟澶辫触"); - } - } - - /** - * 鍥犲弻娣卞簱浣嶉樆濉烇紝瀵规祬搴撲綅杩涜绉昏浆锛堢珛鍗虫墽琛岀増) - * tip锛氬悓姝� - */ - private void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc){ - List<Integer> rows = locMastService.queryDistinctRow(crn.getId()); - LocMast loc = null; - for (Integer row : rows) { - if (Utils.isDeepLoc(slaveProperties, row)) { - loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); - if (null != loc) { break; } - } - } - if (null == loc) { - for (Integer row : rows) { - if (Utils.isShallowLoc(slaveProperties, row)) { - loc = locMastService.queryFreeLocMast(row, shallowLoc.getLocType1()); - if (null != loc) { break; } - } - } - } - if (null == loc) { - throw new CoolException("鍙屾繁搴撲綅 --- 娴呭簱浣嶉樆濉炲紓甯革紒 寰呯Щ杞祬搴撲綅锛�" + shallowLoc.getLocNo()); - } - - // 鑾峰彇宸ヤ綔鍙� - int workNo = commonService.getWorkNo(0); - // 淇濆瓨宸ヤ綔妗� - WrkMast 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(shallowLoc.getLocNo()); // 婧愬簱浣� - wrkMast.setLocNo(loc.getLocNo()); // 鐩爣搴撲綅 - wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 婊℃澘 - wrkMast.setPicking("N"); // 鎷f枡 - wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 - wrkMast.setBarcode(shallowLoc.getBarcode()); // 鎵樼洏鐮� - wrkMast.setLinkMis("N"); - wrkMast.setAppeTime(new Date()); - wrkMast.setModiTime(new Date()); - int res = wrkMastMapper.insert(wrkMast); - if (res == 0) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); - } - // 宸ヤ綔妗f槑缁嗕繚瀛� - if (shallowLoc.getLocSts().equals("F")) { - List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo())); - for (LocDetl locDetl : locDetls) { - WrkDetl wrkDetl = new WrkDetl(); - wrkDetl.setWrkNo(workNo); - wrkDetl.setIoTime(new Date()); - wrkDetl.setQty(locDetl.getQty()); - VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 - wrkDetl.setAppeTime(new Date()); - wrkDetl.setModiTime(new Date()); - if (!wrkDetlService.insert(wrkDetl)) { - throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); - } - } - } - // 淇敼婧愬簱浣嶇姸鎬� - if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) { - shallowLoc.setLocSts("R"); // R.鍑哄簱棰勭害 - shallowLoc.setModiTime(new Date()); - if (!locMastService.updateById(shallowLoc)){ - throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); - } - } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); - } - // 淇敼鐩爣搴撲綅鐘舵�� - if (loc.getLocSts().equals("O")) { - loc.setLocSts("S"); // S.鍏ュ簱棰勭害 - loc.setModiTime(new Date()); - if (!locMastService.updateById(loc)) { - throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); - } - } else { - throw new CoolException("绉昏浆澶辫触"); - } - - } - - /** - * 鍫嗗灈鏈烘紨绀� ===>> 搴撲綅绉昏浆 - */ - public synchronized void crnDemoOfLocMove1(){ - for (CrnSlave crn : slaveProperties.getCrn()) { - if (!crn.getDemo()) { continue; } // 蹇呴』涓烘紨绀虹姸鎬� - - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { continue; } - - // 鍙湁褰撳爢鍨涙満绌洪棽 骞朵笖 鏃犱换鍔℃椂鎵嶇户缁墽琛� - if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { - // 鑾峰彇绉诲簱宸ヤ綔妗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(0); - // 淇濆瓨宸ヤ綔妗� - 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け璐�"); - } - // 宸ヤ綔妗f槑缁嗕繚瀛� -// List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLocNo)); -// for (LocDetl locDetl : locDetls) { -// WrkDetl wrkDetl = new WrkDetl(); -// wrkDetl.setWrkNo(workNo); -// wrkDetl.setIoTime(new Date()); -// wrkDetl.setAnfme(locDetl.getAnfme()); -// VersionUtils.setWrkDetl(wrkDetl, locDetl); // 鐗堟湰鎺у埗 -// wrkDetl.setAppeTime(new Date()); -// wrkDetl.setModiTime(new Date()); -// if (!wrkDetlService.insert(wrkDetl)) { -// throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); -// } -// } - // 淇敼婧愬簱浣嶇姸鎬� - if (sourceLoc.getLocSts().equals("D")) { - sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 - sourceLoc.setModiTime(new Date()); - if (!locMastService.updateById(sourceLoc)){ - throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); - } - } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐�"); - } - // 淇敼鐩爣搴撲綅鐘舵�� - if (loc.getLocSts().equals("O")) { - loc.setLocSts("S"); // S.鍏ュ簱棰勭害 - loc.setModiTime(new Date()); - if (!locMastService.updateById(loc)) { - throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); - } - } else { - throw new CoolException("绉昏浆澶辫触"); - } - - } - - } - } - - /** - * 鍫嗗灈鏈哄懡浠や笅鍙戝悗锛屽紓姝ヤ慨鏀瑰伐浣滄。鐘舵�� - */ - public synchronized void crnIoWrkMast(){ - for (CrnSlave crn : slaveProperties.getCrn()) { - // 鑾峰彇鍫嗗灈鏈轰俊鎭� - CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId()); - CrnProtocol crnProtocol = crnThread.getCrnProtocol(); - if (crnProtocol == null) { - continue; - } - Date now = new Date(); - // 鍫嗗灈鏈烘鍦ㄨ繍琛� - if (crnProtocol.getStatusType() != CrnStatusType.IDLE && crnProtocol.getTaskNo() != 0 && crnProtocol.getModeType() == CrnModeType.AUTO) { - // 鑾峰彇宸ヤ綔妗� - WrkMast wrkMast = wrkMastMapper.selectById(crnProtocol.getTaskNo()); - if (wrkMast == null) { continue; } - // 鍏ュ簱 - if (wrkMast.getWrkSts() == 1 || wrkMast.getWrkSts() == 2) { - log.warn("鍫嗗灈鏈洪潪绌洪棽鎯呭喌涓嬶紝寮�濮嬩慨鏀瑰伐浣滄。鐘舵�併�俒id:{},鏃堕棿锛歿}] >>>>> 鍫嗗灈鏈哄綋鍓嶇姸鎬佷负锛歿}銆備换鍔″彿:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); - // 淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� - wrkMast.setWrkSts(3L); - wrkMast.setCrnStrTime(now); - wrkMast.setModiTime(now); - if (wrkMastMapper.updateById(wrkMast) == 0) { - log.error("淇敼宸ヤ綔妗g姸鎬� 2.璁惧涓婅蛋 => 3.鍚婅溅鍏ュ簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); - } - log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); - } - // 鍑哄簱銆佺Щ搴� - if (wrkMast.getWrkSts() == 11) { - log.warn("鍫嗗灈鏈洪潪绌洪棽鎯呭喌涓嬶紝寮�濮嬩慨鏀瑰伐浣滄。鐘舵�併�俒id:{},鏃堕棿锛歿}] >>>>> 鍫嗗灈鏈哄綋鍓嶇姸鎬佷负锛歿}銆備换鍔″彿:{}", crn.getId(), DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), crnProtocol.getStatusType().desc, crnProtocol.getTaskNo()); - // 淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� - wrkMast.setWrkSts(12L); - wrkMast.setCrnStrTime(now); - wrkMast.setModiTime(now); - if (wrkMastMapper.updateById(wrkMast) == 0) { - log.error("淇敼宸ヤ綔妗g姸鎬� 11.鐢熸垚鍑哄簱ID => 12.鍚婅溅鍑哄簱涓� 澶辫触锛侊紒锛屽伐浣滃彿={}", wrkMast.getWrkNo()); - } - log.warn("淇敼宸ヤ綔妗g姸鎬佹垚鍔熴�俒鏃堕棿锛歿}] >>>>> 浠诲姟鍙�:{}", DateUtils.convert(now, DateUtils.yyyyMMddHHmmsssss_F), wrkMast.getWrkNo()); - } - } - - } - } } -- Gitblit v1.9.1