|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocDirectionService locDirectionService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Long WHS_TYPE = 0L;//默认立库 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 生成工作号 | 
|---|
|  |  |  | * | 
|---|
|  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, List<String> matnrs, String batch, Long hostId, LocTypeDto locTypeDto, int times) { | 
|---|
|  |  |  | if (sourceStaNo==999){//平库内置判断站点(临时解决方案) | 
|---|
|  |  |  | WHS_TYPE = 1L;//平库 | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | WHS_TYPE = 0L;//立库 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 目标库位 | 
|---|
|  |  |  | LocMast locMast = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd(), hostId); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd(), hostId,WHS_TYPE); | 
|---|
|  |  |  | for (LocMast locMast0 : locMasts) { | 
|---|
|  |  |  | //预留空库位 | 
|---|
|  |  |  | if (locMastService.checkEmptyCount(locMast0, 10, hostId)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(LocMast::getLocSts, "D") | 
|---|
|  |  |  | .eq(LocMast::getLocType1, locTypeDto.getLocType1()) | 
|---|
|  |  |  | .eq(LocMast::getCrnNo, staDesc.getDeviceNo()) | 
|---|
|  |  |  | .eq(LocMast::getWhsType, WHS_TYPE) | 
|---|
|  |  |  | .eq(LocMast::getHostId, hostId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<LocMast> wrapper1 = new LambdaQueryWrapper<LocMast>() | 
|---|
|  |  |  | .eq(LocMast::getLocSts, "O") | 
|---|
|  |  |  | .eq(LocMast::getLocType1, locTypeDto.getLocType1()) | 
|---|
|  |  |  | .eq(LocMast::getCrnNo, staDesc.getDeviceNo()) | 
|---|
|  |  |  | .eq(LocMast::getWhsType, WHS_TYPE) | 
|---|
|  |  |  | .eq(LocMast::getHostId, hostId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //库位搜索范围 | 
|---|
|  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<LocMast> wrapper1 = new LambdaQueryWrapper<LocMast>() | 
|---|
|  |  |  | .eq(LocMast::getLocSts, "O") | 
|---|
|  |  |  | .eq(LocMast::getHostId, hostId) | 
|---|
|  |  |  | .in(LocMast::getRow1, curRow) | 
|---|
|  |  |  | .orderByAsc(LocMast::getLev1); | 
|---|
|  |  |  | .eq(LocMast::getLocType1, locTypeDto.getLocType1()) | 
|---|
|  |  |  | .le(LocMast::getRow1, eRow) | 
|---|
|  |  |  | .ge(LocMast::getRow1, sRow) | 
|---|
|  |  |  | //                .in(LocMast::getRow1, curRow) | 
|---|
|  |  |  | .orderByAsc(LocMast::getLev1) | 
|---|
|  |  |  | .orderByAsc(LocMast::getBay1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //库位搜索范围 | 
|---|
|  |  |  | LocRangeDto locRangeDto = locTypeDto.getLocRangeDto(); | 
|---|
|  |  |  | if (locRangeDto != null) { | 
|---|
|  |  |  | 
|---|
|  |  |  | for (LocMast mast : locMasts) { | 
|---|
|  |  |  | LocMast innerLoc = null; | 
|---|
|  |  |  | for (String loc : Utils.getGroupLoc(mast.getLocNo(), hostId)) { | 
|---|
|  |  |  | //1 2 | 
|---|
|  |  |  | LocMast one = locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, loc).eq(LocMast::getHostId, hostId)); | 
|---|
|  |  |  | if (!one.getLocSts().equals("O")) { | 
|---|
|  |  |  | innerLoc = null; | 
|---|
|  |  |  | //                    innerLoc = null; | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (innerLoc == null) { | 
|---|
|  |  |  | List<Integer> innerDeepRow = locDirectionService.getInnerDeepRow(hostId); | 
|---|
|  |  |  | if (innerDeepRow.contains(one.getRow1())) { | 
|---|
|  |  |  | innerLoc = one; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | innerLoc = one; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                if (innerLoc == null) { | 
|---|
|  |  |  | //                    List<Integer> innerDeepRow = locDirectionService.getInnerDeepRow(hostId); | 
|---|
|  |  |  | ////                    if (innerDeepRow.contains(one.getRow1())) { | 
|---|
|  |  |  | //                    innerLoc = one; | 
|---|
|  |  |  | ////                    } | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(innerLoc == null) { | 
|---|