| | |
| | | // 堆垛机工位1有物料 |
| | | WrkMast wrkMast = wrkMastMapper.selectByPltType(crn.getId(), 1); |
| | | if (wrkMast != null) { |
| | | //先判断是出库还是入库 |
| | | //再判断是还有没有同类型的工作档 |
| | | // determine outbound or inbound |
| | | // check whether same-type work remains |
| | | if (wrkMast.getIoType() >= 100) { |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakOutStep1(crn.getId(), wrkMast.getSourceStaNo()); |
| | | if (wrkMast1 != null) { |
| | | if (Integer.parseInt(wrkMast1.getSourceLocNo().substring(3,5)) == 1 || (staProtocol.isAutoing() && staProtocol.isLoading())){ |
| | | if (shouldPrioritizePut(crn.getId(), wrkMast1.getSourceLocNo(), 1) || (staProtocol.isAutoing() && staProtocol.isLoading())){ |
| | | this.outPut(crn, crnProtocol, mark); |
| | | //continue; |
| | | }else { |
| | | this.outTake(crn, crnProtocol, 2, mark); |
| | | this.outTake(crn, crnProtocol, 0, mark); |
| | | } |
| | | //this.outTake(crn, crnProtocol, 2, mark); |
| | | //this.outTake(crn, crnProtocol, 0, mark); |
| | | } else { |
| | | this.outPut(crn, crnProtocol, mark); |
| | | } |
| | | } else { |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakInStep1All(wrkMast.getSourceStaNo(), crn.getId()); |
| | | if (wrkMast1 != null) { |
| | | this.inTake(crn, crnProtocol, 2, mark); |
| | | if (shouldPrioritizePut(crn.getId(), wrkMast1.getLocNo(), 1)) { |
| | | this.inPut(crn, crnProtocol, mark); |
| | | } else { |
| | | this.inTake(crn, crnProtocol, 0, mark); |
| | | } |
| | | } else { |
| | | this.inPut(crn, crnProtocol, mark); |
| | | } |
| | | } |
| | | } else { |
| | | log.error("" + mark + " - 1" + " - 有物料无工作档 ===》异常"); |
| | | log.error("" + mark + " - 1" + " - loaded station without work record"); |
| | | } |
| | | } else if (crnProtocol.getLoaded() == 0 && crnProtocol.getLoadedTwo() == 1) { |
| | | //News.error("工位1无物,工位2有物"); |
| | | // 堆垛机工位2有物料 |
| | | //News.error("station 1 empty, station 2 loaded"); |
| | | // stacker station 2 has load |
| | | WrkMast wrkMast = wrkMastMapper.selectByPltType(crn.getId(), 2); |
| | | if (wrkMast != null) { |
| | | //先判断是出库还是入库 |
| | | //再判断是还有没有同类型的工作档 |
| | | // determine outbound or inbound |
| | | // check whether same-type work remains |
| | | if (wrkMast.getIoType() >= 100) { |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakOutStep1(crn.getId(), wrkMast.getSourceStaNo()); |
| | | if (wrkMast1 != null) { |
| | | if (Integer.parseInt(wrkMast1.getSourceLocNo().substring(3,5)) == 29 || (staProtocol.isAutoing() && staProtocol.isLoading())){ |
| | | if (shouldPrioritizePut(crn.getId(), wrkMast1.getSourceLocNo(), 2) || (staProtocol.isAutoing() && staProtocol.isLoading())){ |
| | | this.outPut(crn, crnProtocol, mark); |
| | | //continue; |
| | | }else { |
| | | this.outTake(crn, crnProtocol, 1, mark); |
| | | this.outTake(crn, crnProtocol, 0, mark); |
| | | } |
| | | //this.outTake(crn, crnProtocol, 1, mark); |
| | | //this.outTake(crn, crnProtocol, 0, mark); |
| | | } else { |
| | | this.outPut(crn, crnProtocol, mark); |
| | | } |
| | | } else { |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakInStep1All(wrkMast.getSourceStaNo(), crn.getId()); |
| | | if (wrkMast1 != null) { |
| | | this.inTake(crn, crnProtocol, 1, mark); |
| | | if (shouldPrioritizePut(crn.getId(), wrkMast1.getLocNo(), 2)) { |
| | | this.inPut(crn, crnProtocol, mark); |
| | | } else { |
| | | this.inTake(crn, crnProtocol, 0, mark); |
| | | } |
| | | } else { |
| | | this.inPut(crn, crnProtocol, mark); |
| | | } |
| | | } |
| | | } else { |
| | | log.error("" + mark + " - 1" + " - 有物料无工作档 ===》异常"); |
| | | log.error("" + mark + " - 1" + " - loaded station without work record"); |
| | | } |
| | | } |
| | | } |
| | |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | private int getLocBay(String locNo) { |
| | | return Integer.parseInt(locNo.substring(2, 5)); |
| | | } |
| | | |
| | | private boolean canFallbackStation(String locNo) { |
| | | int bay = getLocBay(locNo); |
| | | return bay != 1 && bay != 29; |
| | | } |
| | | |
| | | private boolean shouldPrioritizePut(Integer crnId, String locNo, int loadedStation) { |
| | | int preferredStation = getCrnStation(locNo); |
| | | if (preferredStation == loadedStation) { |
| | | return true; |
| | | } |
| | | if (!canFallbackStation(locNo)) { |
| | | return false; |
| | | } |
| | | return wrkMastMapper.selectByPltType(crnId, preferredStation) != null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | crnStation = getCrnStation(wrkMast.getLocNo()); |
| | | } |
| | | if (wrkMastMapper.selectByPltType(slave.getId(), crnStation) != null) { |
| | | News.error("" + mark + " - 1" + " - 9" + " - 堆垛机改工位存在工作档,工位={}", crnStation); |
| | | break; |
| | | if (!canFallbackStation(wrkMast.getLocNo())) { |
| | | log.warn("CRN station fixed for bay={}, workNo={}, station={}", getLocBay(wrkMast.getLocNo()), wrkMast.getWrkNo(), crnStation); |
| | | continue; |
| | | } |
| | | int alternateStation = crnStation == 1 ? 2 : 1; |
| | | if (wrkMastMapper.selectByPltType(slave.getId(), alternateStation) != null) { |
| | | log.warn("CRN station busy for workNo={}, preferredStation={}", wrkMast.getWrkNo(), crnStation); |
| | | continue; |
| | | } |
| | | crnStation = alternateStation; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |
| | | if (wrkMastMapper.selectWorking(slave.getId()) != null) { |
| | | continue; |
| | | } |
| | |
| | | crnStation = getCrnStation(wrkMast.getSourceLocNo()); |
| | | } |
| | | if (wrkMastMapper.selectByPltType(slave.getId(), crnStation) != null) { |
| | | News.error("" + mark + " - 1" + " - 9" + " - 堆垛机改工位存在工作档,工位={}", crnStation); |
| | | break; |
| | | if (!canFallbackStation(wrkMast.getSourceLocNo())) { |
| | | log.warn("CRN station fixed for bay={}, workNo={}, station={}", getLocBay(wrkMast.getSourceLocNo()), wrkMast.getWrkNo(), crnStation); |
| | | continue; |
| | | } |
| | | int alternateStation = crnStation == 1 ? 2 : 1; |
| | | if (wrkMastMapper.selectByPltType(slave.getId(), alternateStation) != null) { |
| | | log.warn("CRN station busy for workNo={}, preferredStation={}", wrkMast.getWrkNo(), crnStation); |
| | | continue; |
| | | } |
| | | crnStation = alternateStation; |
| | | } |
| | | |
| | | // 已经存在吊车执行任务时,则过滤 |