| | |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNo( Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, LocTypeDto locTypeDto) { |
| | | public StartupDto getLocNo( Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, LocTypeDto locTypeDto,boolean mixture) { |
| | | try{ |
| | | Integer whsType = Utils.GetWhsType(sourceStaNo); |
| | | RowLastno rowLastno = rowLastnoService.selectById(whsType); |
| | |
| | | log.error("站点={} 未查询到对应的规则",sourceStaNo); |
| | | break; |
| | | case 4: |
| | | return getLocNoRun4(whsType,staDescId,sourceStaNo,matnr,batch,grade,4,locTypeDto,0); |
| | | return getLocNoRun4(whsType,staDescId,sourceStaNo,matnr,batch,grade,4,locTypeDto,0,mixture); |
| | | case 5: |
| | | return getLocNoRun5(whsType,staDescId,sourceStaNo,matnr,batch,grade,0,locTypeDto,0); |
| | | default: |
| | |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type",rowLastnoType.getType().longValue())); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast2; |
| | | locMast = locMast1; |
| | | break; |
| | | } else { |
| | | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type",rowLastnoType.getType().longValue())); |
| | | if (!Cools.isEmpty(locMast2)) { |
| | | locMast = locMast2; |
| | | locMast = locMast1; |
| | | break; |
| | | } |
| | | } |
| | |
| | | return startupDto; |
| | | } |
| | | |
| | | public StartupDto getLocNoRun4(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times) { |
| | | public StartupDto getLocNoRun4(Integer whsType, Integer staDescId, Integer sourceStaNo, String matnr, String batch, String grade, Integer moveCrnNo, LocTypeDto locTypeDto, int times,boolean mixture) { |
| | | if (Cools.isEmpty(matnr)) { //物料号 |
| | | matnr = ""; |
| | | } |
| | |
| | | throw new CoolException("无可用库位"); |
| | | } |
| | | |
| | | |
| | | // 相似工作档案 --- 同天同规格物料 |
| | | if (!Cools.isEmpty(matnr) && (staDescId == 1 || staDescId == 11 || staDescId == 111) ) { |
| | | //查询相似工作档案 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectWrkMastWrkDetlMatnrBatch(staDescId, matnr, batch,grade, crnNo); |
| | | int nearbay = 0; //相似工作档案 目标库位列 |
| | | int nearlev = 0; //相似工作档案 目标库位层 |
| | | for (WrkMast wrkMast:wrkMasts){ |
| | | int curRowW = curRow; //相似工作档案 最深库位排 |
| | | int nearRowW = nearRow; //相似工作档案 最浅库位排 |
| | | if (Cools.isEmpty(wrkMast.getLocNo())){ |
| | | continue; |
| | | } |
| | | //目标排为最外层排 |
| | | if (Utils.getRow(wrkMast.getLocNo())==nearRow){ |
| | | continue; |
| | | } |
| | | //起始站不一致 |
| | | if (!wrkMast.getSourceStaNo().equals(sourceStaNo)){ |
| | | continue; |
| | | } |
| | | //相同列、层过滤 |
| | | if (Utils.getBay(wrkMast.getLocNo())==nearbay && Utils.getLev(wrkMast.getLocNo())==nearlev){ |
| | | continue; |
| | | }else { |
| | | nearbay=Utils.getBay(wrkMast.getLocNo()); |
| | | nearlev=Utils.getLev(wrkMast.getLocNo()); |
| | | } |
| | | |
| | | //获取目标库位所在巷道并排序 |
| | | // List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,wrkMast.getLocNo(), curRow>nearRow); |
| | | LocMast locMastGro = locMastService.selectById(wrkMast.getLocNo()); |
| | | |
| | | for (int i = 0; i < crnNumber*2; i++) { |
| | | if (!(Utils.getRow(locMastGro.getLocNo())>nearRowW && Utils.getRow(locMastGro.getLocNo())<=curRowW) && !(Utils.getRow(locMastGro.getLocNo())<nearRowW && Utils.getRow(locMastGro.getLocNo())>=curRowW) ){ |
| | | int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRowW, crnNumber,whsType); |
| | | curRowW = locNecessaryParameters[1]; |
| | | nearRowW = locNecessaryParameters[3]; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | //获取目标库位所在巷道最浅非空库位 |
| | | LocMast locMast2 = locMastService.selectLocByLocStsPakInShuttleF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); |
| | | |
| | | //目标库位所在巷道最浅非空库位存在&&非最外侧库位&&入库状态 |
| | | if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && (locMast2.getLocSts().equals("S") || locMast2.getLocSts().equals("Q"))){ |
| | | //获取库存明细 |
| | | WrkDetl wrkDetl = wrkDetlService.selectOne(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | //判断同规格物料 |
| | | if (!Cools.isEmpty(wrkDetl) && matnr.equals(wrkDetl.getMatnr()) |
| | | && batch.equals(batch.isEmpty() ? "":wrkDetl.getBatch()) |
| | | && grade.equals(grade.isEmpty()? "":wrkDetl.getBrand())){ |
| | | int bay2=0; |
| | | if (Utils.getBay(locMast2.getLocNo())>nearRowW){ |
| | | bay2=Utils.getBay(locMast2.getLocNo())-1; |
| | | } else { |
| | | bay2=Utils.getBay(locMast2.getLocNo())+1; |
| | | } |
| | | String targetLocNo = locMast2.getLocNo().substring(0,2) +zerofill(String.valueOf(bay2), 3) + locMast2.getLocNo().substring(5); |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",targetLocNo).eq("loc_sts","O")); |
| | | if (Cools.isEmpty(locMast)){ |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | // 相似工作档 --- 空托 |
| | | if (Cools.isEmpty(locMast) && staDescId == 10) { |
| | | List<WrkMast> wrkMasts =wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("io_type",10).eq("crn_no",crnNo).eq("whs_type",rowLastnoType.getType().longValue())); |
| | | int nearbay = 0; |
| | | int nearlev = 0; |
| | | for (WrkMast wrkMast:wrkMasts){ |
| | | int curRowW = curRow; //相似工作档案 最深库位排 |
| | | int nearRowW = nearRow; //相似工作档案 最浅库位排 |
| | | if (Cools.isEmpty(wrkMast.getLocNo())){ |
| | | continue; |
| | | } |
| | | if (Utils.getRow(wrkMast.getLocNo())==nearRow){ |
| | | continue; |
| | | } |
| | | //起始站不一致 |
| | | if (!wrkMast.getSourceStaNo().equals(sourceStaNo)){ |
| | | continue; |
| | | } |
| | | if (Utils.getBay(wrkMast.getLocNo())==nearbay && Utils.getLev(wrkMast.getLocNo())==nearlev){ |
| | | continue; |
| | | }else { |
| | | nearbay=Utils.getBay(wrkMast.getLocNo()); |
| | | nearlev=Utils.getLev(wrkMast.getLocNo()); |
| | | } |
| | | // List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,wrkMast.getLocNo(), curRow>nearRow); |
| | | LocMast locMastGro = locMastService.selectById(wrkMast.getLocNo()); |
| | | |
| | | for (int i = 0; i < crnNumber*2; i++) { |
| | | if (!(Utils.getRow(locMastGro.getLocNo())>nearRowW && Utils.getRow(locMastGro.getLocNo())<=curRowW) && !(Utils.getRow(locMastGro.getLocNo())<nearRowW && Utils.getRow(locMastGro.getLocNo())>=curRowW) ){ |
| | | int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRowW, crnNumber,whsType); |
| | | curRowW = locNecessaryParameters[1]; |
| | | nearRowW = locNecessaryParameters[3]; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | LocMast locMast2 = locMastService.selectLocByLocStsPakInShuttleF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); |
| | | |
| | | if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && locMast2.getLocSts().equals("S")){ |
| | | int bay2=0; |
| | | if (Utils.getBay(locMast2.getLocNo())>nearRowW){ |
| | | bay2=Utils.getBay(locMast2.getLocNo())-1; |
| | | } else { |
| | | bay2=Utils.getBay(locMast2.getLocNo())+1; |
| | | } |
| | | String targetLocNo = locMast2.getLocNo().substring(0,2) +zerofill(String.valueOf(bay2), 3) + locMast2.getLocNo().substring(5); |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",targetLocNo).eq("loc_sts","O")); |
| | | if (Cools.isEmpty(locMast)){ |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 空托 //互通版 |
| | | if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(rowLastno)) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("crn_no",7)); |
| | | int nearbay = 0; |
| | | int nearlev = 0; |
| | | for (LocMast locMastSign:locMasts){ |
| | | int curRowW = curRow; //相似工作档案 最深库位排 |
| | | int nearRowW = nearRow; //相似工作档案 最浅库位排 |
| | | if (Cools.isEmpty(locMastSign.getLocNo())){ |
| | | continue; |
| | | } |
| | | if (Utils.getRow(locMastSign.getLocNo())==nearRow){ |
| | | continue; |
| | | } |
| | | if (Utils.getBay(locMastSign.getLocNo())==nearbay && Utils.getLev(locMastSign.getLocNo())==nearlev){ |
| | | continue; |
| | | }else { |
| | | nearbay=Utils.getBay(locMastSign.getLocNo()); |
| | | nearlev=Utils.getLev(locMastSign.getLocNo()); |
| | | } |
| | | // List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,wrkMast.getLocNo(), curRow>nearRow); |
| | | LocMast locMastGro = locMastService.selectById(locMastSign.getLocNo()); |
| | | |
| | | for (int i = 0; i < crnNumber*2; i++) { |
| | | if (!(Utils.getRow(locMastGro.getLocNo())>nearRowW && Utils.getRow(locMastGro.getLocNo())<=curRowW) && !(Utils.getRow(locMastGro.getLocNo())<nearRowW && Utils.getRow(locMastGro.getLocNo())>=curRowW) ){ |
| | | int[] locNecessaryParameters = Utils.LocNecessaryParameters(rowLastno, curRowW, crnNumber,whsType); |
| | | curRowW = locNecessaryParameters[1]; |
| | | nearRowW = locNecessaryParameters[3]; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | LocMast locMast2 = locMastService.selectLocByLocStsPakInShuttleF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); |
| | | |
| | | if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && locMast2.getLocSts().equals("S")){ |
| | | int bay2=0; |
| | | if (Utils.getBay(locMast2.getLocNo())>nearRowW){ |
| | | bay2=Utils.getBay(locMast2.getLocNo())-1; |
| | | } else { |
| | | bay2=Utils.getBay(locMast2.getLocNo())+1; |
| | | } |
| | | String targetLocNo = locMast2.getLocNo().substring(0,2) +zerofill(String.valueOf(bay2), 3) + locMast2.getLocNo().substring(5); |
| | | locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",targetLocNo).eq("crn_no",7).eq("loc_sts","O")); |
| | | if (Cools.isEmpty(locMast)){ |
| | | continue; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | Wrapper<StaDesc> wrapper = null; |
| | | StaDesc staDesc = null; |
| | | BasDevp staNo = null; |
| | |
| | | |
| | | // 1.按规则查找库位 |
| | | if (Cools.isEmpty(locMast) && crnNo != 0) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("bay1", nearRow) |
| | | .eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()) |
| | | .eq("crn_no",7) |
| | | .orderBy("lev1",true).orderBy("row1",false));//最浅库位 |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | int floor = 0; |
| | | if (locTypeDto.getLev1() == null){ |
| | | if (locTypeDto.getLocType1() == 1){ |
| | | int F1count = locMastService.selectCount(new EntityWrapper<LocMast>() |
| | | .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1", locTypeDto.getLocType1()) |
| | | .eq("lev1", 1)); |
| | | if (F1count <= 10) { |
| | | int F2count = locMastService.selectCount(new EntityWrapper<LocMast>() |
| | | .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1", locTypeDto.getLocType1()) |
| | | .eq("lev1", 2)); |
| | | if (F2count <= 10) { |
| | | throw new CoolException("库位不足"); |
| | | }else { |
| | | floor = 2; |
| | | } |
| | | }else { |
| | | floor = 1; |
| | | } |
| | | |
| | | }else if (locTypeDto.getLocType1() == 2){ |
| | | int F3count = locMastService.selectCount(new EntityWrapper<LocMast>() |
| | | .in("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1", locTypeDto.getLocType1()) |
| | | .eq("lev1", 3)); |
| | | if (F3count <= 10) { |
| | | throw new CoolException("库位不足"); |
| | | } |
| | | floor = 3; |
| | | }else { |
| | | throw new CoolException("库位高度数据异常"); |
| | | } |
| | | } |
| | | |
| | | if (locTypeDto.getLev1() != null){ |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("bay1", nearRow) |
| | | .in("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .eq("lev1",locTypeDto.getLev1()).orderBy("row1",false));//最浅库位 |
| | | }else { |
| | | if (floor == 0){ |
| | | throw new CoolException("库位已满"); |
| | | } |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("bay1", nearRow) |
| | | .in("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .eq("lev1",floor).orderBy("row1",false));//最浅库位 |
| | | } |
| | | |
| | | |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (locMast != null){ |
| | |
| | | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | continue; |
| | | } |
| | | if (Utils.BooleanWhsTypeStaIoType(rowLastno)){ |
| | | //获取目标库位所在巷道最深空库位 |
| | | // LocMast locMast2 = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); |
| | | // if (!Cools.isEmpty(locMast2) && locMast2.getBay1()==curRow) { |
| | | // locMast = locMast2; |
| | | // break; |
| | | // } |
| | | List<LocMast> locMasts1 = null; |
| | | if (curRow < nearRow){ |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .orderBy("bay1",true)); |
| | | if(locMasts1.size() == 3 || (curRow>20 && locMasts1.size() == 2)){ |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .orderBy("bay1",false)); |
| | | } |
| | | }else { |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .orderBy("bay1",false)); |
| | | } |
| | | if (Cools.isEmpty(locMasts1)) { |
| | | continue; |
| | | } |
| | | for (LocMast locMastGro1 : locMasts1) { |
| | | if (locMastGro1.getLocSts().equals("O")){ |
| | | locMast = locMastGro1; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | List<LocMast> locMasts1 = null; |
| | | if (nearRow == 2 || nearRow ==7 || nearRow == 12){ |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1",true)); |
| | | }else { |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1",false)); |
| | | } |
| | | } |
| | | |
| | | //未找到 允许混料 |
| | | if (Cools.isEmpty(locMast) && Utils.BooleanWhsTypeStaIoType(rowLastno)){ |
| | | for (LocMast locMast1 : locMasts) { |
| | | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { |
| | | continue; |
| | | if (Cools.isEmpty(locMasts1)) { |
| | | continue; |
| | | } |
| | | for (LocMast locMastGro1 : locMasts1) { |
| | | if (locMastGro1.getLocSts().equals("P") || locMastGro1.getLocSts().equals("Q") || locMastGro1.getLocSts().equals("R")) { |
| | | break; |
| | | } |
| | | if (Utils.BooleanWhsTypeStaIoType(rowLastno)){ |
| | | //获取目标库位所在巷道并排序 |
| | | // List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow); |
| | | |
| | | //获取目标库位所在巷道最浅非空库位 |
| | | LocMast locMast2 = locMastService.selectLocByLocStsPakInF(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); |
| | | if (Cools.isEmpty(locMast2)) { |
| | | LocMast locMast3 = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); |
| | | if (!Cools.isEmpty(locMast3)) { |
| | | locMast = locMast3; |
| | | break; |
| | | } |
| | | } else { |
| | | if ((locMast2.getLocSts().equals("F") && staDescId == 1) || (locMast2.getLocSts().equals("D") && staDescId == 10)){ |
| | | LocMast locMast3 = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); |
| | | if (!Cools.isEmpty(locMast3)) { |
| | | locMast = locMast3; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (locMastGro1.getLocSts().equals("O")){ |
| | | locMast = locMastGro1; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 |
| | | if (times < rowCount*2) { |
| | | times = times + 1; |
| | | return getLocNoRun4(whsType, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times); |
| | | return getLocNoRun4(whsType, staDescId, sourceStaNo, matnr, batch, grade,moveCrnNo, locTypeDto, times,mixture); |
| | | } |
| | | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); |
| | | throw new CoolException("没有空库位"); |