|  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //获取目标库位所在巷道最浅非空库位 | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |                 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"))){ | 
 |  |  | 
 |  |  |                     if (!Cools.isEmpty(wrkDetl) && matnr.equals(wrkDetl.getMatnr()) | 
 |  |  |                             && batch.equals(batch.isEmpty() ? "":wrkDetl.getBatch()) | 
 |  |  |                             && grade.equals(grade.isEmpty()? "":wrkDetl.getBrand())){ | 
 |  |  |                         int row2=0; | 
 |  |  |                         if (Utils.getRow(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                             row2=Utils.getRow(locMast2.getLocNo())-1; | 
 |  |  |                         int bay2=0; | 
 |  |  |                         if (Utils.getBay(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                             bay2=Utils.getBay(locMast2.getLocNo())-1; | 
 |  |  |                         } else { | 
 |  |  |                             row2=Utils.getRow(locMast2.getLocNo())+1; | 
 |  |  |                             bay2=Utils.getBay(locMast2.getLocNo())+1; | 
 |  |  |                         } | 
 |  |  |                         String targetLocNo = zerofill(String.valueOf(row2), 2) + locMast2.getLocNo().substring(2); | 
 |  |  |                         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; | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInShuttleF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |  | 
 |  |  |                 if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && locMast2.getLocSts().equals("S")){ | 
 |  |  |                     int row2=0; | 
 |  |  |                     if (Utils.getRow(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())-1; | 
 |  |  |                     int bay2=0; | 
 |  |  |                     if (Utils.getBay(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                         bay2=Utils.getBay(locMast2.getLocNo())-1; | 
 |  |  |                     }else { | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())+1; | 
 |  |  |                         bay2=Utils.getBay(locMast2.getLocNo())+1; | 
 |  |  |                     } | 
 |  |  |                     String targetLocNo = zerofill(String.valueOf(row2), 2) + locMast2.getLocNo().substring(2); | 
 |  |  |                     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; | 
 |  |  | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         boolean signRule1 = false; | 
 |  |  |         boolean signRule2 = false; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         if (Utils.BooleanWhsTypeStaIoType(rowLastno)){ | 
 |  |  |             // 靠近摆放规则 --- 同天同规格物料 //分离版 | 
 |  |  |             if (!Cools.isEmpty(matnr) &&  staDescId == 1){ | 
 |  |  | //                signRule1 = true; | 
 |  |  |             } | 
 |  |  |             // 靠近摆放规则 --- 同天同规格物料 //互通版 | 
 |  |  |             if (!Cools.isEmpty(matnr) && staDescId == 1) { | 
 |  |  |                 signRule2 = true; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             if (!Cools.isEmpty(matnr) &&  (staDescId == 11 || staDescId == 111)) { | 
 |  |  |                 signRule1 = true; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (signRule1){ | 
 |  |  |             if (nearRow!=curRow){ | 
 |  |  |                 List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
 |  |  |                         .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue())); | 
 |  |  |                 for (LocMast locMast1:locMasts){ | 
 |  |  |                     //获取巷道 | 
 |  |  | //                    List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow); | 
 |  |  |                     //获取目标库位所在巷道最浅非空库位 | 
 |  |  |                     LocMast locMastF = locMastService.selectLocByLocStsPakInF(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); | 
 |  |  |                     if (!Cools.isEmpty(locMastF) && locMastF.getLocSts().equals("F")){ | 
 |  |  |                         LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMastF.getLocNo())); | 
 |  |  |                         if (!Cools.isEmpty(locDetl) && matnr.equals(locDetl.getMatnr()) | 
 |  |  |                                 && batch.equals(batch.isEmpty() ? "" : locDetl.getBatch()) | 
 |  |  |                                 && grade.equals(grade.isEmpty() ? "" : locDetl.getBrand())) { | 
 |  |  |                             //获取目标库位所在巷道最深空库位 | 
 |  |  |                             locMast = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }else if (signRule2){ | 
 |  |  |             List<String> locNos = locDetlService.getSameDetlToday(matnr, sRow, eRow); | 
 |  |  |             int nearbay = 0; | 
 |  |  |             int nearlev = 0; | 
 |  |  |             for (String locNo : locNos) { | 
 |  |  |                 int curRowW = curRow;    //相似工作档案 最深库位排 | 
 |  |  |                 int nearRowW = nearRow;    //相似工作档案 最浅库位排 | 
 |  |  |                 if (Cools.isEmpty(locNo)){ | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 if (Utils.getRow(locNo)==nearRow){ | 
 |  |  |                     continue; | 
 |  |  |                 } | 
 |  |  |                 if (Utils.getBay(locNo)==nearbay && Utils.getLev(locNo)==nearlev){ | 
 |  |  |                     continue; | 
 |  |  |                 }else { | 
 |  |  |                     nearbay=Utils.getBay(locNo); | 
 |  |  |                     nearlev=Utils.getLev(locNo); | 
 |  |  |                 } | 
 |  |  | //                List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,wrkMast.getLocNo(), curRow>nearRow); | 
 |  |  |                 LocMast locMastGro = locMastService.selectById(locNo); | 
 |  |  |  | 
 |  |  |                 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); | 
 |  |  |                         curRowW = locNecessaryParameters[1]; | 
 |  |  |                         nearRowW = locNecessaryParameters[3]; | 
 |  |  |                     }else { | 
 |  |  |                         break; | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |  | 
 |  |  |                 if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && locMast2.getLocSts().equals("S")){ | 
 |  |  |                     int row2=0; | 
 |  |  |                     if (Utils.getRow(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())-1; | 
 |  |  |                     }else { | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())+1; | 
 |  |  |                     } | 
 |  |  |                     String targetLocNo = zerofill(String.valueOf(row2), 2) + locMast2.getLocNo().substring(2); | 
 |  |  |                     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("row1", nearRow).eq("loc_sts", "O")); | 
 |  |  | //            for (LocMast locMast1:locMasts){ | 
 |  |  | //                //获取巷道 | 
 |  |  | ////                List<String> groupOutsideLocCrn = Utils.getGroupOutLocCrn(curRow,nearRow,locMast1.getLocNo(), curRow>nearRow); | 
 |  |  | //                //获取目标库位所在巷道最浅非空库位 | 
 |  |  | //                LocMast locMastF = locMastService.selectLocByLocStsPakInF(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); | 
 |  |  | //                if (!Cools.isEmpty(locMastF) && locMastF.getLocSts().equals("D")){ | 
 |  |  | //                    //获取目标库位所在巷道最浅非空库位 | 
 |  |  | //                    locMast = locMastService.selectLocByLocStsPakInO(curRow,nearRow,locMast1,rowLastnoType.getType().longValue()); | 
 |  |  | //                    break; | 
 |  |  | //                } | 
 |  |  | //            } | 
 |  |  | //        } | 
 |  |  |  | 
 |  |  |         // 靠近摆放规则 --- 空托 //互通版 | 
 |  |  |         if (staDescId == 10  && Utils.BooleanWhsTypeStaIoType(rowLastno)) { | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |                 LocMast locMast2 = locMastService.selectLocByLocStsPakInShuttleF(curRowW,nearRowW,locMastGro,rowLastnoType.getType().longValue()); | 
 |  |  |  | 
 |  |  |                 if (!Cools.isEmpty(locMast2) && Utils.getRow(locMast2.getLocNo())!=nearRowW && locMast2.getLocSts().equals("S")){ | 
 |  |  |                     int row2=0; | 
 |  |  |                     if (Utils.getRow(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())-1; | 
 |  |  |                     int bay2=0; | 
 |  |  |                     if (Utils.getBay(locMast2.getLocNo())>nearRowW){ | 
 |  |  |                         bay2=Utils.getBay(locMast2.getLocNo())-1; | 
 |  |  |                     }else { | 
 |  |  |                         row2=Utils.getRow(locMast2.getLocNo())+1; | 
 |  |  |                         bay2=Utils.getBay(locMast2.getLocNo())+1; | 
 |  |  |                     } | 
 |  |  |                     String targetLocNo = zerofill(String.valueOf(row2), 2) + locMast2.getLocNo().substring(2); | 
 |  |  |                     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; | 
 |  |  | 
 |  |  |         // 1.按规则查找库位 | 
 |  |  |         if (Cools.isEmpty(locMast) && crnNo != 0) { | 
 |  |  |             List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
 |  |  |                     .eq("row1", nearRow) | 
 |  |  |                     .eq("bay1", nearRow) | 
 |  |  |                     .eq("loc_sts", "O").eq("whs_type",rowLastnoType.getType().longValue()) | 
 |  |  |                     .orderBy("lev1",true).orderBy("bay1",true));//最浅库位 | 
 |  |  |                     .orderBy("lev1",true).orderBy("row1",false));//最浅库位 | 
 |  |  |             for (LocMast locMast1 : locMasts) { | 
 |  |  |                 if (locMast != null){ | 
 |  |  |                     break; | 
 |  |  | 
 |  |  |                     if (curRow < nearRow){ | 
 |  |  |                         locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() | 
 |  |  |                                 .eq("gro1", locMast1.getGro1()) | 
 |  |  |                                 .orderBy("row1",true)); | 
 |  |  |                                 .orderBy("bay1",true)); | 
 |  |  |                         if(locMasts1.size() == 3  || (curRow>20 && locMasts1.size() == 2)){ | 
 |  |  |                             locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() | 
 |  |  |                                     .eq("gro1", locMast1.getGro1()) | 
 |  |  |                                     .orderBy("row1",false)); | 
 |  |  |                                     .orderBy("bay1",false)); | 
 |  |  |                         } | 
 |  |  |                     }else { | 
 |  |  |                         locMasts1 = locMastService.selectList(new EntityWrapper<LocMast>() | 
 |  |  |                                 .eq("gro1", locMast1.getGro1()) | 
 |  |  |                                 .orderBy("row1",false)); | 
 |  |  |                                 .orderBy("bay1",false)); | 
 |  |  |                     } | 
 |  |  |                     if (Cools.isEmpty(locMasts1)) { | 
 |  |  |                         continue; |