| | |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Value("${channel.channelMax}") |
| | | private Integer channelMax; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, int times) { |
| | | // whsType = getWhsType(sourceStaNo, times); |
| | | StartupDto startupDto = new StartupDto(); |
| | | if (sourceStaNo.equals(100)){ |
| | | whsType=1; |
| | | }else if (sourceStaNo.equals(200)){ |
| | | whsType=2; |
| | | } |
| | | |
| | | StartupDto startupDto = new StartupDto(); |
| | | RowLastno rowLastno = rowLastnoService.selectById(whsType); |
| | | if (Cools.isEmpty(rowLastno)) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | |
| | | int sRow = rowLastno.getsRow(); |
| | | int eRow = rowLastno.geteRow(); |
| | | int crn_qty = rowLastno.getCrnQty(); |
| | | int rowCount = eRow - sRow + 1; |
| | | int rowCount = eRow - sRow; |
| | | // 目标堆垛机号 |
| | | int crnNo = crn_qty; |
| | | // 目标库位 |
| | | LocMast locMast = null; |
| | | |
| | | // 如果没有相近物料,则按规则轮询货架 |
| | | if (null == locMast) { |
| | | switch (curRow){ |
| | | case 2: |
| | | if (curRow==3){ |
| | | curRow = 4; |
| | | break; |
| | | case 4: |
| | | curRow = 6; |
| | | break; |
| | | case 6: |
| | | curRow = 8; |
| | | break; |
| | | case 8: |
| | | curRow = 11; |
| | | break; |
| | | case 11: |
| | | curRow = 13; |
| | | break; |
| | | case 13: |
| | | }else if (curRow==4){ |
| | | curRow = 3; |
| | | break; |
| | | case 3: |
| | | curRow = 5; |
| | | break; |
| | | case 5: |
| | | curRow = 7; |
| | | break; |
| | | case 7: |
| | | curRow = 9; |
| | | break; |
| | | case 9: |
| | | curRow = 12; |
| | | break; |
| | | case 12: |
| | | curRow = 14; |
| | | break; |
| | | case 14: |
| | | curRow = 2; |
| | | break; |
| | | } |
| | | }else { |
| | | rowCount=0; |
| | | } |
| | | |
| | | if (crnNo == 0) { |
| | |
| | | rowLastnoService.updateById(rowLastno); |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | |
| | | // 1.当检索库排为浅库位排时,优先寻找当前库排的深库位排 |
| | | // if (locMast == null) { |
| | | // if (Utils.isShallowLoc(slaveProperties, curRow)) { |
| | | // Integer deepRow = Utils.getDeepRow(slaveProperties, curRow); |
| | | // locMast = locMastService.queryFreeLocMast(deepRow, locTypeDto.getLocType1()); |
| | | // // todo:luxiaotao 如果用浅排找到的深库位,那么则需要判断这个深库位对应的浅库位是否有货(F、X、D) |
| | | // // 因库位移转、需预留空库位 |
| | | // if (!locMastService.checkEmptyCount(locMast)) { |
| | | // locMast = null; |
| | | // } |
| | | // } |
| | | if (Cools.isEmpty(locMast)) { |
| | | |
| | | Integer ruleId = Integer.parseInt(Parameter.get().getFindLocRule()); |
| | | if (ruleId == 0){//默认规则 |
| | | locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1()); |
| | | if (whsType!=1){ |
| | | locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | } else if (ruleId == 1){ //按测试设备排序,优先排满单台设备 |
| | | locMast = locMastService.queryFreeLocMast1(2, locTypeDto.getLocType1()); |
| | | locMast = locMastService.queryFreeLocMast1(curRow, locTypeDto.getLocType1() ,channelMax+1); |
| | | } else if (ruleId == 2){//按通道排序,均匀分配每台设备 |
| | | locMast = locMastService.queryFreeLocMast2(2, locTypeDto.getLocType1(), curRow); |
| | | } else { |
| | | locMast = locMastService.queryFreeLocMast(2, locTypeDto.getLocType1()); |
| | | } |
| | | |
| | | locMast = locMastService.queryFreeLocMast2(curRow, locTypeDto.getLocType1() ); |
| | | } else { //默认规则 |
| | | locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | } |
| | | // } |
| | | } |
| | | |
| | | // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位 |
| | | if (Cools.isEmpty(locMast)) { |
| | |
| | | startupDto.setStaNo(staNo.getDevNo()); |
| | | startupDto.setLocNo(locNo); |
| | | return startupDto; |
| | | } |
| | | |
| | | |
| | | public static String zerofill(String msg, Integer count) { |
| | | if (msg.length() == count) { |
| | | return msg; |
| | | } else if (msg.length() > count) { |
| | | return msg.substring(0, 16); |
| | | } else { |
| | | StringBuilder msgBuilder = new StringBuilder(msg); |
| | | for(int i = 0; i < count - msg.length(); ++i) { |
| | | msgBuilder.insert(0, "0"); |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | } |