| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | |
| | | * @param findLocNoAttributeVo 属性 |
| | | * @param locTypeDto 类型 |
| | | * @return locNo 检索到的库位号 |
| | | * wms-dev |
| | | */ |
| | | @Transactional |
| | | public StartupDto getLocNoToWmsDev(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto, String barcode,int[] row) { |
| | | StartupDto startupDto = null; |
| | | StringBuilder builder = new StringBuilder(); |
| | | try { |
| | | startupDto = searchLocNoByCrnNoToWmsDev(staDescId, sourceStaNo, findLocNoAttributeVo, locTypeDto,row); |
| | | } catch (Exception e) { |
| | | builder.append(e.getMessage()).append(","); |
| | | } |
| | | |
| | | if(startupDto == null) { |
| | | builder.append("找不到空库位"); |
| | | throw new CoolException(builder.toString()); |
| | | } |
| | | |
| | | return startupDto; |
| | | } |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * |
| | | * @param staDescId 路径ID |
| | | * @param sourceStaNo 源站 |
| | | * @param findLocNoAttributeVo 属性 |
| | | * @param locTypeDto 类型 |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | @Transactional |
| | | public StartupDto searchLocNoByCrnNo(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) { |
| | |
| | | // 生成工作号 |
| | | int workNo = getWorkNo(0); |
| | | // 返回dto |
| | | startupDto.setWorkNo(workNo); |
| | | startupDto.setTaskNo(workNo); |
| | | startupDto.setCrnNo(locMast.getCrnNo()); |
| | | startupDto.setSourceStaNo(sourceStaNo); |
| | | startupDto.setLocNo(locNo); |
| | | startupDto.setTaskPri(13.0); |
| | | return startupDto; |
| | | } |
| | | |
| | | @Transactional |
| | | public StartupDto searchLocNoByCrnNoToWmsDev(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto,int[] row) { |
| | | LocMast locMast = null; |
| | | if (staDescId == 10) { |
| | | //搜索空托盘 |
| | | locMast = searchEmptyPallet(locTypeDto); |
| | | }else { |
| | | //满托盘 |
| | | locMast = searchMaxPalletToWmsDev(findLocNoAttributeVo, locTypeDto,row); |
| | | } |
| | | |
| | | if(locMast == null) { |
| | | throw new CoolException("找不到符合尺寸的空库位"); |
| | | } |
| | | |
| | | StartupDto startupDto = new StartupDto(); |
| | | |
| | | // 获取目标站 |
| | | // Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>().eq("type_no", staDescId).eq("stn_no", sourceStaNo).eq("crn_no", locMast.getCrnNo()); |
| | | // StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | // if (Cools.isEmpty(staDesc)) { |
| | | // log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo); |
| | | // throw new CoolException("入库路径不存在"); |
| | | // } else { |
| | | // BasDevp staNo = basDevpService.selectById(staDesc.getCrnStn()); |
| | | // if (!staNo.getAutoing().equals("Y")) { |
| | | // log.error("目标站" + staDesc.getCrnStn() + "不可用"); |
| | | // throw new CoolException("目标站"+staDesc.getCrnStn()+"不可用"); |
| | | // } |
| | | // startupDto.setStaNo(staNo.getDevNo()); |
| | | // } |
| | | String locNo = locMast.getLocNo(); |
| | | // 生成工作号 |
| | | int workNo = getWorkNo(0); |
| | | // 返回dto |
| | | startupDto.setTaskNo(workNo); |
| | | startupDto.setCrnNo(locMast.getCrnNo()); |
| | | startupDto.setSourceStaNo(sourceStaNo); |
| | | startupDto.setLocNo(locToLocNo(locNo)); |
| | | startupDto.setTaskPri(13.0); |
| | | return startupDto; |
| | | } |
| | | public String locToLocNo(String locNo){//0100203 |
| | | int row = Integer.parseInt(locNo.substring(0, 2)); |
| | | int bay = Integer.parseInt(locNo.substring(2, 5)); |
| | | int lev = Integer.parseInt(locNo.substring(5, 7)); |
| | | return row + "-" +bay + "-" + lev; |
| | | } |
| | | |
| | | //搜索满托盘库位 |
| | |
| | | return targetLocMast; |
| | | } |
| | | |
| | | //搜索满托盘库位 wms-dev |
| | | public LocMast searchMaxPalletToWmsDev(FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto,int[] rows) { |
| | | LocMast targetLocMast = null; |
| | | List<String> locNos = locDetlService.getSameDetlListToWmsDev(findLocNoAttributeVo.getMatnr(),rows); |
| | | for (String locNo : locNos) { |
| | | //获取通道组 |
| | | List<Integer> locRowGroupDesc = Utils.getLocGroupDesc(slaveProperties, locNo); |
| | | for (Integer row : locRowGroupDesc) { |
| | | String deepLocNo = Utils.getLocNo(row, Utils.getBay(locNo), Utils.getLev(locNo)); |
| | | LocMast deepLoc = locMastService.selectById(deepLocNo); |
| | | if (deepLoc == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (deepLoc.getLocSts().equals("F")) { |
| | | continue; |
| | | } else if (deepLoc.getLocSts().equals("O")) { |
| | | targetLocMast = deepLoc; |
| | | break; |
| | | }else { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | if(targetLocMast == null) { |
| | | //相近物料匹配失败,搜索可用空库位组 |
| | | |
| | | //获取设备楼层 |
| | | // List<Integer> levList = basCrnpService.getLevList(); |
| | | // Collections.shuffle(levList); |
| | | // |
| | | // List<Integer> locLevList = locMastService.getLevList(); |
| | | // levList.addAll(locLevList); |
| | | |
| | | // for (Integer lev : levList) { |
| | | // List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | // .eq("loc_sts", "O") |
| | | // .in("row1",rows) |
| | | // .orderBy("bay1", true)); |
| | | List<LocMast> locMasts = locMastService.selectLoc(rows); |
| | | for (LocMast locMast : locMasts) { |
| | | String locNo = locMast.getLocNo(); |
| | | //获取通道组 |
| | | List<Integer> locRowGroupDesc = Utils.getLocGroupDesc(slaveProperties, locNo); |
| | | |
| | | boolean flag = true; |
| | | for (Integer row : locRowGroupDesc) { |
| | | String deepLocNo = Utils.getLocNo(row, Utils.getBay(locNo), Utils.getLev(locNo)); |
| | | LocMast deepLoc = locMastService.selectById(deepLocNo); |
| | | if (deepLoc == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!deepLoc.getLocSts().equals("O")) { |
| | | flag = false; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (flag) { |
| | | for (Integer row : locRowGroupDesc) { |
| | | String deepLocNo = Utils.getLocNo(row, Utils.getBay(locNo), Utils.getLev(locNo)); |
| | | LocMast deepLoc = locMastService.selectById(deepLocNo); |
| | | if (deepLoc == null) { |
| | | continue; |
| | | } |
| | | |
| | | targetLocMast = deepLoc; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // if (targetLocMast != null) { |
| | | // break; |
| | | // } |
| | | // } |
| | | |
| | | } |
| | | return targetLocMast; |
| | | } |
| | | |
| | | //搜索空托盘库位 |
| | | public LocMast searchEmptyPallet(LocTypeDto locTypeDto) { |
| | | LocMast targetLocMast = null; |