| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.StartupDto; |
| | |
| | | @Transactional |
| | | public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, int times) { |
| | | |
| | | if (sourceStaNo.equals(100)) { |
| | | whsType = 1; |
| | | locTypeDto.setLocType1((short) 1); |
| | | } else if (sourceStaNo.equals(200)) { |
| | | whsType = 2; |
| | | locTypeDto.setLocType1((short) 2); |
| | | } |
| | | |
| | | whsType = 1; |
| | | locTypeDto.setLocType1((short) 1); |
| | | StartupDto startupDto = new StartupDto(); |
| | | RowLastno rowLastno = rowLastnoService.selectById(whsType); |
| | | if (Cools.isEmpty(rowLastno)) { |
| | |
| | | int crnNo = crn_qty; |
| | | // 目标库位 |
| | | LocMast locMast = null; |
| | | |
| | | if (curRow == 3) { |
| | | curRow = 4; |
| | | } else if (curRow == 4) { |
| | | curRow = 3; |
| | | } else { |
| | | rowCount = 0; |
| | | } |
| | | |
| | | if (crnNo == 0) { |
| | | throw new CoolException("没有可用的堆垛机"); |
| | |
| | | rowLastno.setCurrentRow(curRow); |
| | | rowLastnoService.updateById(rowLastno); |
| | | |
| | | // 开始查找库位 ==============================> |
| | | int ruleId = Integer.parseInt(Parameter.get().getFindLocRule()); |
| | | if (whsType != 1) { |
| | | locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | } else if (ruleId == 1) { //按测试设备排序,优先排满单台设备 |
| | | locMast = locMastService.queryFreeLocMast1(curRow, locTypeDto.getLocType1(), channelMax + 1); |
| | | } else if (ruleId == 2) { //按通道排序,均匀分配每台设备 |
| | | Short locType2 = getLocType2Small(curRow, locTypeDto.getLocType1()); |
| | | locMast = locMastService.queryFreeLocMast2(curRow, locTypeDto.getLocType1(), locType2); |
| | | } else { //默认规则 |
| | | locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | if (crnNo==1){ |
| | | LocMast locMast1 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "F") |
| | | .eq("loc_type1", (short) 3));//待测库位 |
| | | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O") |
| | | .eq("loc_type1", (short) 1));//测试库位 |
| | | if (!Cools.isEmpty(locMast1)||Cools.isEmpty(locMast2)){ |
| | | List<LocMast> locMasts=locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O").eq("loc_type1", (short) 3) |
| | | .orderBy("row1",false).orderBy("bay1",true)); |
| | | if(!Cools.isEmpty(locMasts)){ |
| | | locMast = locMasts.get(0); |
| | | }else{ |
| | | throw new CoolException("没有待测库位无法入库!!!"); |
| | | } |
| | | } |
| | | } |
| | | // 靠近摆放规则 --- 空托 |
| | | if (staDescId == 10) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow)); |
| | | if (locMasts.size() > 0) { |
| | | for (LocMast loc : locMasts) { |
| | | if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { |
| | | continue; |
| | | } |
| | | String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); |
| | | // 检测目标库位是否为空库位 |
| | | LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { |
| | | if (shallowLoc.getLocType1()<locTypeDto.getLocType1()){ |
| | | continue; |
| | | } |
| | | if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { |
| | | locMast = shallowLoc; |
| | | crnNo = locMast.getCrnNo(); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (Cools.isEmpty(locMast)) { |
| | | List<LocMast> locMastList3 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O") |
| | | .eq("row1",3) |
| | | .notIn("loc_type1",1)); |
| | | if (!Cools.isEmpty(locMastList3)) { |
| | | locMast = locMastList3.get(0); |
| | | }else { |
| | | List<LocMast> locMastList1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "O") |
| | | .eq("row1",1) |
| | | .notIn("loc_type1",1)); |
| | | if (!Cools.isEmpty(locMastList1)) { |
| | | locMast = locMastList1.get(0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 2.库位当前所属尺寸无空库位时,调整尺寸参数,向上兼容检索库位 |
| | | if (Cools.isEmpty(locMast)){ |
| | | locMast = locMastService.queryFreeLocMast(1, locTypeDto.getLocType1()); |
| | | // // 开始查找库位 ==============================> |
| | | // int ruleId = Integer.parseInt(Parameter.get().getFindLocRule()); |
| | | // if (whsType != 1) { |
| | | // locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | // } else if (ruleId == 1) { //按测试设备排序,优先排满单台设备 |
| | | // locMast = locMastService.queryFreeLocMast1(curRow, locTypeDto.getLocType1(), channelMax + 1); |
| | | // } else if (ruleId == 2) { //按通道排序,均匀分配每台设备 |
| | | // Short locType2 = getLocType2Small(curRow, locTypeDto.getLocType1()); |
| | | // locMast = locMastService.queryFreeLocMast2(curRow, locTypeDto.getLocType1(), locType2); |
| | | // } else { //默认规则 |
| | | // locMast = locMastService.queryFreeLocMast(curRow, locTypeDto.getLocType1()); |
| | | // } |
| | | } |
| | | if (Cools.isEmpty(locMast)) { |
| | | // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 |
| | | if (times < rowCount) { |
| | | times = times + 1; |
| | | return getLocNo(1, staDescId, sourceStaNo, matNos, locTypeDto, times); |
| | | } |
| | | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | String locNo = locMast.getLocNo(); |