| | |
| | | throw new CoolException("无可用库位"); |
| | | } |
| | | |
| | | |
| | | // 相似工作档案 --- 同天同规格物料 |
| | | if (!Cools.isEmpty(matnr) && (staDescId == 1 || staDescId == 11 || staDescId == 111) && !mixture ) { |
| | | //查询相似工作档案 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectWrkMastWrkDetlMatnrBatch(staDescId, matnr, batch,grade, crnNo); |
| | | int nearbay = 0; //相似工作档案 目标库位列 |
| | | int nearlev = 0; //相似工作档案 目标库位层 |
| | | for (WrkMast wrkMast:wrkMasts){ |
| | | LocMast locMastWrk = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getLocNo())); |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | if (locMastWrk.getBay1() >=1 && locMastWrk.getBay1()<=2){ |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMastWrk.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | }else if (locMastWrk.getBay1() >=4 && locMastWrk.getBay1()<=12){ |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMastWrk.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1", false)); |
| | | }else { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMastWrk.getGro1()) |
| | | .eq("crn_no", 7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1", true)); |
| | | } |
| | | if (Cools.isEmpty(locMasts)) { |
| | | continue; |
| | | } |
| | | for (LocMast locMastGro1 : locMasts) { |
| | | |
| | | if (locMastGro1.getBay1() == 2){ //wcs问题限制 |
| | | continue; |
| | | } |
| | | if (locMastGro1.getLocSts().equals("P") || locMastGro1.getLocSts().equals("Q")) { |
| | | break; |
| | | } |
| | | if (locMastGro1.getLocSts().equals("O")){ |
| | | locMast = locMastGro1; |
| | | 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>() |
| | | List<LocMast> locMasts = new ArrayList<>(); |
| | | int floor = 0; |
| | | 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("库位高度数据异常"); |
| | | } |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("bay1", nearRow) |
| | | .in("loc_sts", "O","X").eq("whs_type",rowLastnoType.getType().longValue()) |
| | | .in("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("lev1",true).orderBy("row1",false));//最浅库位 |
| | | .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) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1",true)); |
| | | if(locMast1.getBay1()>= 4 && locMast1.getBay1()<=12){ |
| | | locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("gro1", locMast1.getGro1()) |
| | | .eq("crn_no",7) |
| | | .eq("loc_type1",locTypeDto.getLocType1()) |
| | | .orderBy("bay1",false)); |
| | | } |
| | | }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(locMasts1)) { |
| | | continue; |
| | | } |
| | | for (LocMast locMastGro1 : locMasts1) { |
| | | if (mixture){ //混料只允许放 7 12 14 |
| | | if (locMastGro1.getBay1() != 7 && locMastGro1.getBay1() != 12 && locMastGro1.getBay1() != 14){ |
| | | continue; |
| | | } |
| | | }else { //不混料不允许放 7 12 14 |
| | | if (locMastGro1.getBay1() == 7 || locMastGro1.getBay1() == 12 || locMastGro1.getBay1() == 14){ |
| | | continue; |
| | | } |
| | | } |
| | | if (locMastGro1.getLocSts().equals("F")){ |
| | | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_No", locMastGro1.getLocNo())); |
| | | if (!locDetl.getMatnr().equals(matnr) || !locDetl.getBatch().equals(batch)){ |
| | | break; |
| | | } |
| | | } |
| | | if (locMastGro1.getLocSts().equals("P") || locMastGro1.getLocSts().equals("Q") || locMastGro1.getLocSts().equals("R")) { |
| | | break; |
| | | } |
| | | 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(locMasts1)) { |
| | | continue; |
| | | } |
| | | for (LocMast locMastGro1 : locMasts1) { |
| | | if (locMastGro1.getLocSts().equals("P") || locMastGro1.getLocSts().equals("Q") || locMastGro1.getLocSts().equals("R")) { |
| | | break; |
| | | } |
| | | if (locMastGro1.getLocSts().equals("O")){ |
| | | locMast = locMastGro1; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |