|  |  |  | 
|---|
|  |  |  | private WrkDetlService wrkDetlService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ConfigService configService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 生成工作号 | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return locNo 检索到的库位号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Integer whsType = Utils.GetWhsType(sourceStaNo); | 
|---|
|  |  |  | RowLastno rowLastno = rowLastnoService.selectById(whsType); | 
|---|
|  |  |  | RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(rowLastno.getTypeId()); | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 库型 1: 标准堆垛机库  2: 平库  3: 穿梭板  4: 四向车  5: AGV  0: 未知 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | switch (rowLastnoType.getType()) { | 
|---|
|  |  |  | case 1: | 
|---|
|  |  |  | return getLocNoRun(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 0, locTypeDto, 0); | 
|---|
|  |  |  | case 2: | 
|---|
|  |  |  | log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 3: | 
|---|
|  |  |  | log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | case 4: | 
|---|
|  |  |  | return getLocNoRun4(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 4, locTypeDto, 0); | 
|---|
|  |  |  | case 5: | 
|---|
|  |  |  | return getLocNoRun5(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 0, locTypeDto, 0); | 
|---|
|  |  |  | default: | 
|---|
|  |  |  | log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto, String barcode) { | 
|---|
|  |  |  | List<Integer> crnList = new ArrayList<>(); | 
|---|
|  |  |  | if (barcode.startsWith("11")) { | 
|---|
|  |  |  | crnList.add(4); | 
|---|
|  |  |  | crnList.add(5); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config config = configService.selectConfigByCode("11CrnConfig"); | 
|---|
|  |  |  | List<Integer> list = JSON.parseArray(config.getValue(), Integer.class); | 
|---|
|  |  |  | for (Integer crn : list) { | 
|---|
|  |  |  | crnList.remove(crn); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("站点={} 未查询到对应的规则,{}", sourceStaNo,e.getMessage()); | 
|---|
|  |  |  | if (crnList.isEmpty()) { | 
|---|
|  |  |  | crnList.add(4); | 
|---|
|  |  |  | crnList.add(5); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | configService.updateValue("11CrnConfig", "[]"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!list.isEmpty()) { | 
|---|
|  |  |  | crnList.addAll(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (barcode.startsWith("13")) { | 
|---|
|  |  |  | crnList.add(1); | 
|---|
|  |  |  | crnList.add(2); | 
|---|
|  |  |  | crnList.add(3); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config config = configService.selectConfigByCode("13CrnConfig"); | 
|---|
|  |  |  | List<Integer> list = JSON.parseArray(config.getValue(), Integer.class); | 
|---|
|  |  |  | for (Integer crn : list) { | 
|---|
|  |  |  | crnList.remove(crn); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (crnList.isEmpty()) { | 
|---|
|  |  |  | crnList.add(1); | 
|---|
|  |  |  | crnList.add(2); | 
|---|
|  |  |  | crnList.add(3); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | configService.updateValue("13CrnConfig", "[]"); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if (!list.isEmpty()) { | 
|---|
|  |  |  | crnList.addAll(list); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (staDescId != 10) { | 
|---|
|  |  |  | //检测是否为呆滞料 | 
|---|
|  |  |  | String matnr = findLocNoAttributeVo.getMatnr(); | 
|---|
|  |  |  | Mat mat = matService.selectByMatnr(matnr); | 
|---|
|  |  |  | if (mat == null) { | 
|---|
|  |  |  | throw new CoolException(matnr + "物料信息不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (mat.getTscp() != null && mat.getTscp() == 1) { | 
|---|
|  |  |  | crnList.add(0, 1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else if (barcode.startsWith("16")) { | 
|---|
|  |  |  | crnList.add(6); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | throw new CoolException("托盘码:{}" + barcode + "规则错误,无法找到匹配堆垛机"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | StartupDto startupDto = null; | 
|---|
|  |  |  | StringBuilder builder = new StringBuilder(); | 
|---|
|  |  |  | for (Integer crnNo : crnList) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | startupDto = searchLocNoByCrnNo(staDescId, sourceStaNo, findLocNoAttributeVo, locTypeDto, crnNo); | 
|---|
|  |  |  | if(startupDto != null) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | builder.append(e.getMessage()).append(","); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(startupDto == null) { | 
|---|
|  |  |  | builder.append("找不到空库位"); | 
|---|
|  |  |  | throw new CoolException(builder.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Integer crnNo = startupDto.getCrnNo(); | 
|---|
|  |  |  | if (barcode.startsWith("11")) { | 
|---|
|  |  |  | Config config = configService.selectConfigByCode("11CrnConfig"); | 
|---|
|  |  |  | List<Integer> list = JSON.parseArray(config.getValue(), Integer.class); | 
|---|
|  |  |  | List<Integer> newList = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer crn : list) { | 
|---|
|  |  |  | if(crn == crnNo) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | newList.add(crn); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | newList.add(crnNo); | 
|---|
|  |  |  | configService.updateValue("11CrnConfig", JSON.toJSONString(newList)); | 
|---|
|  |  |  | }else if (barcode.startsWith("13")) { | 
|---|
|  |  |  | Config config = configService.selectConfigByCode("13CrnConfig"); | 
|---|
|  |  |  | List<Integer> list = JSON.parseArray(config.getValue(), Integer.class); | 
|---|
|  |  |  | List<Integer> newList = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer crn : list) { | 
|---|
|  |  |  | if(crn == crnNo) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | newList.add(crn); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | newList.add(crnNo); | 
|---|
|  |  |  | configService.updateValue("13CrnConfig", JSON.toJSONString(newList)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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, Integer crnNo) { | 
|---|
|  |  |  | Config devpTaskStackOverConfig = configService.selectConfigByCode("devpTaskStackOver"); | 
|---|
|  |  |  | int devpTaskStackOver = Integer.parseInt(devpTaskStackOverConfig.getValue()); | 
|---|
|  |  |  | Integer devpWorkingCount = queryDevpWorkingCount(); | 
|---|
|  |  |  | if (devpWorkingCount > devpTaskStackOver) { | 
|---|
|  |  |  | throw new CoolException("输送线任务过载,当前输送线承载数量:{}" + devpWorkingCount); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!basCrnpService.checkSiteError(crnNo, true)) { | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机异常"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config crnSearchDetectTaskCountConfig = configService.selectConfigByCode("crnSearchDetectTaskCount"); | 
|---|
|  |  |  | int crnSearchDetectTaskCount = Integer.parseInt(crnSearchDetectTaskCountConfig.getValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config applyInTaskTotalCountConfig = configService.selectConfigByCode("applyInTaskTotalCount"); | 
|---|
|  |  |  | int applyInTaskTotalCount = Integer.parseInt(applyInTaskTotalCountConfig.getValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Config emptyInKeepLimitConfig = configService.selectConfigByCode("emptyInKeepLimit"); | 
|---|
|  |  |  | int emptyInKeepLimit = Integer.parseInt(emptyInKeepLimitConfig.getValue()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57)); | 
|---|
|  |  |  | if (wrkMasts.size() > crnSearchDetectTaskCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), crnSearchDetectTaskCount); | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机已达到入库控制上限!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)); | 
|---|
|  |  |  | if (wrkMastsList.size() > applyInTaskTotalCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!!! 任务数量: {}, 控制数量:{}", wrkMastsList.size(), applyInTaskTotalCount); | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocMast> searchLocMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_type1", locTypeDto.getLocType1()).eq("loc_sts", "O").eq("crn_no", crnNo)); | 
|---|
|  |  |  | if (searchLocMasts.size() <= emptyInKeepLimit) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机到达空库位预留上限!!! 尺寸规格: {}", JSON.toJSONString(locTypeDto)); | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机到达空库位预留上限!尺寸规格:" + (locTypeDto.getLocType1() == 1 ? "高" : "低")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (crnNo == 1) { | 
|---|
|  |  |  | if (wrkMasts.size() >= 1) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), 1); | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机已达到入库控制上限!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast locMast = null; | 
|---|
|  |  |  | if (staDescId == 10) { | 
|---|
|  |  |  | //搜索空托盘 | 
|---|
|  |  |  | locMast = searchEmptyPallet(crnNo, locTypeDto); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //满托盘 | 
|---|
|  |  |  | locMast = searchMaxPallet(crnNo, findLocNoAttributeVo, locTypeDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(locMast == null) { | 
|---|
|  |  |  | throw new CoolException(crnNo + "号堆垛机找不到符合尺寸的空库位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.setWorkNo(workNo); | 
|---|
|  |  |  | startupDto.setCrnNo(locMast.getCrnNo()); | 
|---|
|  |  |  | startupDto.setSourceStaNo(sourceStaNo); | 
|---|
|  |  |  | startupDto.setLocNo(locNo); | 
|---|
|  |  |  | return startupDto; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Integer queryDevpWorkingCount() { | 
|---|
|  |  |  | List<WrkMast> wrkMastsIn = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .in("wrk_sts", 2, 3, 4, 5)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMastsOut = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .in("wrk_sts", 12, 14, 15)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int count = 0; | 
|---|
|  |  |  | count += wrkMastsIn.size(); | 
|---|
|  |  |  | count += wrkMastsOut.size(); | 
|---|
|  |  |  | return count; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //搜索满托盘库位 | 
|---|
|  |  |  | public LocMast searchMaxPallet(Integer crnNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) { | 
|---|
|  |  |  | //获取堆垛机排 | 
|---|
|  |  |  | List<Integer> rowList = locMastService.selectRowByCrnNo(crnNo); | 
|---|
|  |  |  | //获取深库位排 | 
|---|
|  |  |  | List<Integer> deepRowList = new ArrayList<>(); | 
|---|
|  |  |  | for (Integer row : rowList) { | 
|---|
|  |  |  | if (Utils.isDeepLoc(slaveProperties, row)) { | 
|---|
|  |  |  | deepRowList.add(row); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast targetLocMast = null; | 
|---|
|  |  |  | List<String> locNos = locDetlService.getSameDetlList(findLocNoAttributeVo.getMatnr(), deepRowList); | 
|---|
|  |  |  | for (String locNo : locNos) { | 
|---|
|  |  |  | //检测对应浅库位是否可用 | 
|---|
|  |  |  | String shallowLocNo = Utils.getShallowLoc(slaveProperties, locNo); | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(shallowLocNo); | 
|---|
|  |  |  | if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { | 
|---|
|  |  |  | targetLocMast = shallowLoc; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(targetLocMast == null) { | 
|---|
|  |  |  | if (crnNo == 1) { | 
|---|
|  |  |  | return searchMaxPalletByOne(crnNo, findLocNoAttributeVo, locTypeDto); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //相近物料匹配失败,搜索深库位可用空库位 | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .in("row1", deepRowList) | 
|---|
|  |  |  | .orderBy("lev1", true) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | for (LocMast locMast : locMasts) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //深库位直接选择 | 
|---|
|  |  |  | targetLocMast = locMast; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(targetLocMast == null) { | 
|---|
|  |  |  | //深库位搜索失败,搜索可用空库位 | 
|---|
|  |  |  | List<LocMast> shallowLocMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("lev1", true) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | for (LocMast locMast : shallowLocMasts) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | targetLocMast = locMast; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return targetLocMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //1号堆垛机搜索逻辑 | 
|---|
|  |  |  | public LocMast searchMaxPalletByOne(Integer crnNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) { | 
|---|
|  |  |  | List<Integer> nearRowList = new ArrayList<Integer>() {{ | 
|---|
|  |  |  | add(4); | 
|---|
|  |  |  | add(6); | 
|---|
|  |  |  | add(3); | 
|---|
|  |  |  | add(1); | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast targetLocMast = null; | 
|---|
|  |  |  | for (Integer row : nearRowList) { | 
|---|
|  |  |  | //相近物料匹配失败,搜索深库位可用空库位 | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("row1", row) | 
|---|
|  |  |  | .orderBy("lev1", true) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | for (LocMast locMast : locMasts) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //深库位直接选择 | 
|---|
|  |  |  | targetLocMast = locMast; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (targetLocMast != null) { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return targetLocMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //搜索空托盘 | 
|---|
|  |  |  | public LocMast searchEmptyPallet(Integer crnNo, LocTypeDto locTypeDto) { | 
|---|
|  |  |  | // 靠近摆放规则 --- 空托 | 
|---|
|  |  |  | LocMast targetLocMast = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_sts", "D") | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | for (LocMast loc : locMasts) { | 
|---|
|  |  |  | if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); | 
|---|
|  |  |  | // 检测目标库位是否为空库位 | 
|---|
|  |  |  | LocMast shallowLoc = locMastService.selectById(shallowLocNo); | 
|---|
|  |  |  | if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { | 
|---|
|  |  |  | if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { | 
|---|
|  |  |  | targetLocMast = shallowLoc; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (targetLocMast == null) { | 
|---|
|  |  |  | List<LocMast> locMastsList = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .orderBy("lev1", false) | 
|---|
|  |  |  | .orderBy("bay1", true)); | 
|---|
|  |  |  | for (LocMast locMast : locMastsList) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean shallowLoc = Utils.isShallowLoc(slaveProperties, locMast.getLocNo()); | 
|---|
|  |  |  | if (shallowLoc) { | 
|---|
|  |  |  | //浅库位,先判断深库位 | 
|---|
|  |  |  | String deepLoc2 = Utils.getDeepLoc2(slaveProperties, locMast.getLocNo()); | 
|---|
|  |  |  | if (!Cools.isEmpty(deepLoc2)) { | 
|---|
|  |  |  | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", deepLoc2) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast2)) { | 
|---|
|  |  |  | targetLocMast = locMast2; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //空的深库位直接选择 | 
|---|
|  |  |  | targetLocMast = locMast; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(targetLocMast == null) { | 
|---|
|  |  |  | //深库位找完都没找到,直接找浅库位 | 
|---|
|  |  |  | for (LocMast locMast : locMastsList) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //空库位直接选择 | 
|---|
|  |  |  | targetLocMast = locMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return targetLocMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    /** | 
|---|
|  |  |  | //     * 检索库位号 | 
|---|
|  |  |  | //     * | 
|---|
|  |  |  | //     * @param staDescId            路径ID | 
|---|
|  |  |  | //     * @param sourceStaNo          源站 | 
|---|
|  |  |  | //     * @param findLocNoAttributeVo 属性 | 
|---|
|  |  |  | //     * @param locTypeDto           类型 | 
|---|
|  |  |  | //     * @return locNo 检索到的库位号 | 
|---|
|  |  |  | //     */ | 
|---|
|  |  |  | //    @Transactional | 
|---|
|  |  |  | //    public StartupDto getLocNo(Integer staDescId, Integer sourceStaNo, FindLocNoAttributeVo findLocNoAttributeVo, LocTypeDto locTypeDto) { | 
|---|
|  |  |  | //        // try { | 
|---|
|  |  |  | //        Integer whsType = Utils.GetWhsType(sourceStaNo); | 
|---|
|  |  |  | //        RowLastno rowLastno = rowLastnoService.selectById(whsType); | 
|---|
|  |  |  | //        RowLastnoType rowLastnoType = rowLastnoTypeService.selectById(rowLastno.getTypeId()); | 
|---|
|  |  |  | //        /** | 
|---|
|  |  |  | //         * 库型 1: 标准堆垛机库  2: 平库  3: 穿梭板  4: 四向车  5: AGV  0: 未知 | 
|---|
|  |  |  | //         */ | 
|---|
|  |  |  | //        switch (rowLastnoType.getType()) { | 
|---|
|  |  |  | //            case 1: | 
|---|
|  |  |  | //                Config crnSearchDetectTaskCountConfig = configService.selectConfigByCode("crnSearchDetectTaskCount"); | 
|---|
|  |  |  | //                int crnSearchDetectTaskCount = Integer.parseInt(crnSearchDetectTaskCountConfig.getValue()); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                Config applyInTaskTotalCountConfig = configService.selectConfigByCode("applyInTaskTotalCount"); | 
|---|
|  |  |  | //                int applyInTaskTotalCount = Integer.parseInt(applyInTaskTotalCountConfig.getValue()); | 
|---|
|  |  |  | //                int crnNo = 7; | 
|---|
|  |  |  | //                boolean flag = true; | 
|---|
|  |  |  | //                List<String> data = new ArrayList<>(); | 
|---|
|  |  |  | //                while (crnNo > 1) { | 
|---|
|  |  |  | //                    crnNo--; | 
|---|
|  |  |  | //                    List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "O").eq("crn_no", crnNo).eq("whs_type", rowLastnoType.getType().longValue()).eq("loc_type1", locTypeDto.getLocType1()).eq("loc_type2", locTypeDto.getLocType2())); | 
|---|
|  |  |  | //                    if (locMasts.size() <= 15) { | 
|---|
|  |  |  | //                        log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}", JSON.toJSONString(locTypeDto)); | 
|---|
|  |  |  | //                        data.add(crnNo + "号没有空库位;"); | 
|---|
|  |  |  | //                    } else { | 
|---|
|  |  |  | //                        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57)); | 
|---|
|  |  |  | //                        if (wrkMasts.size() > crnSearchDetectTaskCount) { | 
|---|
|  |  |  | //                            log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), crnSearchDetectTaskCount); | 
|---|
|  |  |  | //                            data.add(crnNo + "号入库控制上限;"); | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)); | 
|---|
|  |  |  | //                        if (wrkMastsList.size() > applyInTaskTotalCount) { | 
|---|
|  |  |  | //                            log.error(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!!! 任务数量: {}, 控制数量:{}", wrkMastsList.size(), applyInTaskTotalCount); | 
|---|
|  |  |  | //                            data.add(crnNo + "号申请入库时总任务数量上限;"); | 
|---|
|  |  |  | //                            continue; | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  | //                        flag = false; | 
|---|
|  |  |  | //                        break; | 
|---|
|  |  |  | //                    } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //                if (!flag) { | 
|---|
|  |  |  | //                    return getLocNoRun(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 0, locTypeDto, 0); | 
|---|
|  |  |  | //                } else { | 
|---|
|  |  |  | //                    log.info("数据:{}", data); | 
|---|
|  |  |  | //                    throw new CoolException(data.toString()); | 
|---|
|  |  |  | //                } | 
|---|
|  |  |  | //            case 2: | 
|---|
|  |  |  | //                log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | //                break; | 
|---|
|  |  |  | //            case 3: | 
|---|
|  |  |  | //                log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | //                break; | 
|---|
|  |  |  | //            case 4: | 
|---|
|  |  |  | //                return getLocNoRun4(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 4, locTypeDto, 0); | 
|---|
|  |  |  | //            case 5: | 
|---|
|  |  |  | //                return getLocNoRun5(whsType, staDescId, sourceStaNo, findLocNoAttributeVo, 0, locTypeDto, 0); | 
|---|
|  |  |  | //            default: | 
|---|
|  |  |  | //                log.error("站点={} 未查询到对应的规则", sourceStaNo); | 
|---|
|  |  |  | //                break; | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | // | 
|---|
|  |  |  | ////        } catch (Exception e) { | 
|---|
|  |  |  | ////            log.error("站点={} 未查询到对应的规则,{}", sourceStaNo, e.getMessage()); | 
|---|
|  |  |  | ////        } | 
|---|
|  |  |  | //        return null; | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检索库位号 | 
|---|
|  |  |  | 
|---|
|  |  |  | curRow = locNecessaryParameters[1]; | 
|---|
|  |  |  | crnNo = locNecessaryParameters[2]; | 
|---|
|  |  |  | if (basCrnpService.checkSiteError(crnNo, true)) { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(wrkMasts.size() > crnSearchDetectTaskCount){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57)); | 
|---|
|  |  |  | if (wrkMasts.size() > crnSearchDetectTaskCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), crnSearchDetectTaskCount); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57, 101, 103, 107, 110) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)); | 
|---|
|  |  |  | if (wrkMastsList.size() > applyInTaskTotalCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!!! 任务数量: {}, 控制数量:{}", wrkMastsList.size(), applyInTaskTotalCount); | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | rowCount = locNecessaryParameters[0]; | 
|---|
|  |  |  | nearRow = locNecessaryParameters[3]; | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).eq("io_type", 1)); | 
|---|
|  |  |  | if (locMasts.size() - crnCountO <= 15) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); | 
|---|
|  |  |  | 
|---|
|  |  |  | boolean flag = true; | 
|---|
|  |  |  | //尝试找1号弯轨堆垛机库位 | 
|---|
|  |  |  | crnNo = 1; | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(wrkMasts.size() > crnSearchDetectTaskCount){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57)); | 
|---|
|  |  |  | if (wrkMasts.size() > crnSearchDetectTaskCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), crnSearchDetectTaskCount); | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57, 101, 103, 107, 110) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)); | 
|---|
|  |  |  | if (wrkMastsList.size() > applyInTaskTotalCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!!! 任务数量: {}, 控制数量:{}", wrkMastsList.size(), applyInTaskTotalCount); | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | 
|---|
|  |  |  | add(1); | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  | for (Integer near : nearRowList) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", near) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("whs_type", rowLastnoType.getType().longValue()) | 
|---|
|  |  |  | .eq("loc_type1", locTypeDto.getLocType1()) | 
|---|
|  |  |  | .eq("loc_type2", locTypeDto.getLocType2()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", near).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).eq("loc_type1", locTypeDto.getLocType1()).eq("loc_type2", locTypeDto.getLocType2())); | 
|---|
|  |  |  | int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).eq("io_type", 1)); | 
|---|
|  |  |  | if (locMasts.size() - crnCountO <= 15) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); | 
|---|
|  |  |  | 
|---|
|  |  |  | crnNo = 1; | 
|---|
|  |  |  | if (basCrnpService.checkSiteError(crnNo, true)) { | 
|---|
|  |  |  | boolean flag = true; | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | if(wrkMasts.size() > crnSearchDetectTaskCount){ | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57)); | 
|---|
|  |  |  | if (wrkMasts.size() > crnSearchDetectTaskCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到入库控制上限!!! 任务数量: {}, 控制数量:{}", wrkMasts.size(), crnSearchDetectTaskCount); | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo) | 
|---|
|  |  |  | .in("io_type", 1, 10, 53, 57, 101, 103, 107, 110) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<WrkMast> wrkMastsList = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).in("io_type", 1, 10, 53, 57, 101, 103, 107, 110)); | 
|---|
|  |  |  | if (wrkMastsList.size() > applyInTaskTotalCount) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机已达到申请入库时总任务数量上限(入库、出库)!!! 任务数量: {}, 控制数量:{}", wrkMastsList.size(), applyInTaskTotalCount); | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | 
|---|
|  |  |  | add(1); | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  | for (Integer near : nearRowList) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", near) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("whs_type", rowLastnoType.getType().longValue()) | 
|---|
|  |  |  | .eq("loc_type1", locTypeDto.getLocType1()) | 
|---|
|  |  |  | .eq("loc_type2", locTypeDto.getLocType2()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", near).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).eq("loc_type1", locTypeDto.getLocType1()).eq("loc_type2", locTypeDto.getLocType2())); | 
|---|
|  |  |  | int crnCountO = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("crn_no", crnNo).eq("io_type", 1)); | 
|---|
|  |  |  | if (locMasts.size() - crnCountO <= 15) { | 
|---|
|  |  |  | log.error(crnNo + "号堆垛机没有空库位!!! 尺寸规格: {}, 轮询次数:{}", JSON.toJSONString(locTypeDto), times); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  | 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) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取目标库位所在巷道最浅非空库位 | 
|---|
|  |  |  | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("whs_type", rowLastnoType.getType().longValue()) | 
|---|
|  |  |  | .eq("crn_no", locMast1.getCrnNo()) | 
|---|
|  |  |  | .eq("bay1", locMast1.getBay1()) | 
|---|
|  |  |  | .notIn("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("row1", false) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("whs_type", rowLastnoType.getType().longValue()).eq("crn_no", locMast1.getCrnNo()).eq("bay1", locMast1.getBay1()).notIn("loc_sts", "O").orderBy("row1", false)); | 
|---|
|  |  |  | if (locMastList.isEmpty()) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locMastF.getLocNo())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locDetl) && findLocNoAttributeVo.beSimilar(locDetl)) { | 
|---|
|  |  |  | String shallowLoc = Utils.getShallowLoc(slaveProperties, locMastF.getLocNo()); | 
|---|
|  |  |  | LocMast shallowLocMast = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", shallowLoc) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | LocMast shallowLocMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc).eq("loc_sts", "O")); | 
|---|
|  |  |  | if (shallowLocMast != null) { | 
|---|
|  |  |  | locMast = shallowLocMast; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 靠近摆放规则 --- 空托 //互通版 | 
|---|
|  |  |  | if (staDescId == 10 && Utils.BooleanWhsTypeStaIoType(rowLastno)) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!locMasts.isEmpty()) { | 
|---|
|  |  |  | for (LocMast loc : locMasts) { | 
|---|
|  |  |  | if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 1.按规则查找库位 | 
|---|
|  |  |  | if (Cools.isEmpty(locMast) && crnNo != 0) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", nearRow) | 
|---|
|  |  |  | .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).ne("inv_wh",1) | 
|---|
|  |  |  | .orderBy("lev1", true).orderBy("bay1", true)); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).ne("inv_wh", 1).orderBy("lev1", true).orderBy("bay1", true)); | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Utils.BooleanWhsTypeStaIoType(rowLastno)) { | 
|---|
|  |  |  | String shallowLoc = Utils.getShallowLoc(slaveProperties, locMast1.getLocNo()); | 
|---|
|  |  |  | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast2)) { | 
|---|
|  |  |  | locMast = locMast2; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Utils.BooleanWhsTypeStaIoType(rowLastno)) { | 
|---|
|  |  |  | String shallowLoc = Utils.getDeepLoc(slaveProperties, locMast1.getLocNo()); | 
|---|
|  |  |  | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | LocMast locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast2)) { | 
|---|
|  |  |  | locMast = locMast2; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc).eq("loc_sts", "F").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast2)) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | locMast2 = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", shallowLoc).eq("loc_sts", "D").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMast2)) { | 
|---|
|  |  |  | locMast = locMast1; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | //                locTypeDto.setLocType1((short)i); | 
|---|
|  |  |  | //                return getLocNo(1, staDescId, sourceStaNo, matnr,batch,grade, locTypeDto, 0); | 
|---|
|  |  |  | //            } | 
|---|
|  |  |  | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{},{}", JSON.toJSONString(locTypeDto), times,moveCrnNo); | 
|---|
|  |  |  | log.error("系统没有空库位!!! 尺寸规格: {}, 轮询次数:{},{}", JSON.toJSONString(locTypeDto), times, moveCrnNo); | 
|---|
|  |  |  | throw new CoolException("没有空库位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | //针对1号堆垛机打的补丁,防止找到库位时,找到最浅库位 | 
|---|
|  |  |  | String deepLoc2 = Utils.getDeepLoc2(slaveProperties, locMast.getLocNo()); | 
|---|
|  |  |  | if (!Cools.isEmpty(deepLoc2)) { | 
|---|
|  |  |  | LocMast locMastNew = locMastService.selectOne(new EntityWrapper<LocMast>().eq("crn_no",locMast.getCrnNo()) | 
|---|
|  |  |  | .eq("loc_no", deepLoc2).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | LocMast locMastNew = locMastService.selectOne(new EntityWrapper<LocMast>().eq("crn_no", locMast.getCrnNo()).eq("loc_no", deepLoc2).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (!Cools.isEmpty(locMastNew)) { | 
|---|
|  |  |  | locMast = locMastNew; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 获取目标站 | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", staDescId) | 
|---|
|  |  |  | .eq("stn_no", sourceStaNo) | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo()); | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>().eq("type_no", staDescId).eq("stn_no", sourceStaNo).eq("crn_no", locMast.getCrnNo()); | 
|---|
|  |  |  | staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo); | 
|---|
|  |  |  | 
|---|
|  |  |  | curRow = locNecessaryParameters[1]; | 
|---|
|  |  |  | crnNo = locNecessaryParameters[2]; | 
|---|
|  |  |  | nearRow = locNecessaryParameters[3]; | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("crn_no", crnNo).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("crn_no", crnNo).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue())); | 
|---|
|  |  |  | if (locMasts.size() <= 5) { | 
|---|
|  |  |  | nearRow = 0; | 
|---|
|  |  |  | times++; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Utils.BooleanWhsTypeSta(rowLastno, staDescId)) { | 
|---|
|  |  |  | // 获取目标站 | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", staDescId) | 
|---|
|  |  |  | .eq("stn_no", sourceStaNo) | 
|---|
|  |  |  | .eq("crn_no", crnNo); | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>().eq("type_no", staDescId).eq("stn_no", sourceStaNo).eq("crn_no", crnNo); | 
|---|
|  |  |  | staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | log.error("入库路径不存在:type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 1.按规则查找库位 | 
|---|
|  |  |  | if (Cools.isEmpty(locMast) && crnNo != 0) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", nearRow) | 
|---|
|  |  |  | .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()) | 
|---|
|  |  |  | .orderBy("lev1", true).orderBy("bay1", true));//最浅库位 | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).orderBy("lev1", true).orderBy("bay1", true));//最浅库位 | 
|---|
|  |  |  | //System.out.println(nearRow); | 
|---|
|  |  |  | //System.out.println(curRow); | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Utils.BooleanWhsTypeSta(rowLastno, staDescId)) { | 
|---|
|  |  |  | // 获取目标站 | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", staDescId) | 
|---|
|  |  |  | .eq("stn_no", sourceStaNo) | 
|---|
|  |  |  | .eq("crn_no", crnNo); | 
|---|
|  |  |  | wrapper = new EntityWrapper<StaDesc>().eq("type_no", staDescId).eq("stn_no", sourceStaNo).eq("crn_no", crnNo); | 
|---|
|  |  |  | staDesc = staDescService.selectOne(wrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | log.error("type_no={},stn_no={},crn_no={}", staDescId, sourceStaNo, crnNo); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 1.按规则查找库位 | 
|---|
|  |  |  | if (Cools.isEmpty(locMast) && crnNo != 0) { | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() | 
|---|
|  |  |  | .eq("row1", nearRow) | 
|---|
|  |  |  | .eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()) | 
|---|
|  |  |  | .orderBy("lev1", true).orderBy("bay1", true));//最浅库位 | 
|---|
|  |  |  | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("row1", nearRow).eq("loc_sts", "O").eq("whs_type", rowLastnoType.getType().longValue()).orderBy("lev1", true).orderBy("bay1", true));//最浅库位 | 
|---|
|  |  |  | for (LocMast locMast1 : locMasts) { | 
|---|
|  |  |  | if (!VersionUtils.locMoveCheckLocTypeComplete(locMast1, locTypeDto)) { | 
|---|
|  |  |  | continue; | 
|---|