| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 货架核心功能 |
| | |
| | | * 双深找库位 |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto) { |
| | | |
| | | // 目标库位 |
| | | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo,LocTypeDto locTypeDto,int times) { |
| | | LocMast locMast; |
| | | |
| | | // // 搜索空托 |
| | | // locMast = getLocNoStep4(staDescId, sourceStaNo); |
| | | // if (locMast != null) { |
| | | // //找到库位,返回dto |
| | | // return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | // } |
| | | |
| | | //搜索整个空库位组 |
| | | locMast = getLocNoStepSingle(locTypeDto); |
| | | |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | | |
| | | // 搜索单品(整个库位组) |
| | | private LocMast getLocNoStepSingle(LocTypeDto locTypeDto) { |
| | | |
| | | LocMast locMast = null; |
| | | //单品 |
| | | List<LocMast> locMasts = locMastService.selectAreaEmpty(locTypeDto.getLocType1());//搜索货物 |
| | | |
| | | // 获取模式为电脑模式,无任务的堆垛机列表:防止分配到堆垛机不可用 |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().eq("crn_sts",3) |
| | | .eq("wrk_no",0)); |
| | | if (basCrnps.isEmpty()) { |
| | | // 都有任务则获取电脑模式的堆垛机列表 |
| | | basCrnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>().eq("crn_sts",3)); |
| | | } |
| | | if (basCrnps.isEmpty()) { |
| | | throw new CoolException("没有可用堆垛机,堆垛机停止或异常"); |
| | | } |
| | | // 可用堆垛机列表 |
| | | List<Integer> crnNoList = basCrnps.stream().map(BasCrnp::getCrnNo).collect(Collectors.toList()); |
| | | |
| | | // 搜索深库位 |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","1,4,5,8,9,12,13,16,17,20,21,24").orderBy("lev1,bay1,row1")); |
| | | |
| | | // 深库位没有则搜索浅库位 |
| | | if (locMasts.isEmpty()) { |
| | | locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts","O").in("crn_no",crnNoList).in("row1","2,3,6,7,10,11,14,15,18,19,22,23").orderBy("lev1,bay1,row1")); |
| | | } |
| | | if (locMasts.isEmpty()) { |
| | | throw new CoolException("没有可用库位"); |
| | | } |
| | | |
| | | // 记录堆垛机是否查询过,避免重复查询 |
| | | Map<Integer,Boolean> crnMap = new HashMap<>(); |
| | | for (LocMast mast : locMasts) { |
| | | List<String> groupLoc = Utils.getGroupLocNo(mast.getLocNo(), true); |
| | | // if (!locMastService.checkAllLocEmpty(groupLoc)) { |
| | | // continue; |
| | | // } |
| | | |
| | | LocMast tmp = null; |
| | | for (String loc : groupLoc) { |
| | | LocMast locMast1 = locMastService.selectByLoc(loc); |
| | | if (locMast1 == null) { |
| | | continue; |
| | | if (crnMap.get(mast.getCrnNo()) == null) { |
| | | //预留空库位 |
| | | if (locMastService.checkEmptyCount(mast, 10)) { |
| | | locMast = mast; |
| | | break; |
| | | } else { |
| | | crnMap.put(mast.getCrnNo(),true); |
| | | } |
| | | |
| | | if (!locMast1.getLocSts().equals("O")) { |
| | | continue; |
| | | } |
| | | |
| | | tmp = locMast1; |
| | | break; |
| | | } |
| | | |
| | | //预留空库位 |
| | | if (tmp != null && locMastService.checkEmptyCount(mast, 10)) { |
| | | locMast = tmp; |
| | | break; |
| | | } |
| | | } |
| | | |