| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * @author Munch D. Luffy |
| | |
| | | for (String c : split) { |
| | | WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c)); |
| | | if (!Cools.isEmpty(byId)) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type),false); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type) |
| | | .last("LIMIT 1")); |
| | | if (!Objects.isNull(loc)) { |
| | | curLoc = loc.getCode(); |
| | | break; |
| | |
| | | for (String c : split) { |
| | | WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c)); |
| | | if (!Cools.isEmpty(byId)) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type),false); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .last("LIMIT 1")); |
| | | if (!Objects.isNull(loc)) { |
| | | deepLoc = loc.getCode(); |
| | | break; |
| | |
| | | if (Cools.isEmpty(autoRunContainerEndYz)) { |
| | | return; |
| | | } |
| | | |
| | | String autoRunContainerEndYzCount = configService.getVal("AUTO_RUN_CHECK_OUT_YZ_COUNT", String.class); |
| | | if (Cools.isEmpty(autoRunContainerEndYzCount)) { |
| | | return; |
| | | } |
| | | int autoOutCount = Integer.parseInt(autoRunContainerEndYzCount); |
| | | if (autoOutCount <= 0) { |
| | | return; |
| | | } |
| | | List<Long> souLocArea = new ArrayList<>(); |
| | | List<Long> endLocArea = new ArrayList<>(); |
| | | String curLoc = null; |
| | | String deepLoc = null; |
| | | try{ |
| | | String[] split = autoRunAreaStartYz.split(";"); |
| | | for (String c : split) { |
| | | for (String c : autoRunAreaStartYz.split(";")) { |
| | | WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c)); |
| | | if (!Cools.isEmpty(byId)) { |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type),false); |
| | | if (!Objects.isNull(loc)) { |
| | | curLoc = loc.getCode(); |
| | | break; |
| | | } |
| | | souLocArea.add(byId.getId()); |
| | | } |
| | | } |
| | | if (souLocArea.isEmpty()) { |
| | | return; |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("配置参数AUTO_RUN_AREA_START_YZ解析失败,请检查!!!"); |
| | | } |
| | | //容器集合 |
| | | //每个容器对应的容器码类型 |
| | | // |
| | | |
| | | try{ |
| | | // String[] containerList = autoRunContainerEndYz.split(";"); |
| | | // ArrayList<Long> CONTAINER_IDS = new ArrayList<>(); |
| | | // for (String c : containerList) { |
| | | // CONTAINER_IDS.add(Long.parseLong(c)); |
| | | // } |
| | | BasContainer basContainer = basContainerService.getOne(new LambdaQueryWrapper<BasContainer>() |
| | | .in(BasContainer::getContainerType, 1, false)); |
| | | // if (Cools.isEmpty(basContainer)){ |
| | | // throw new CoolException("未查询到相关容器规则"); |
| | | // } |
| | | // |
| | | // |
| | | List<Long> areaList = new ArrayList<>();//所有库区 |
| | | // List<Long> areaList1 = new ArrayList<>();//所有容器类型 |
| | | // List<Long> areaList2 = new ArrayList<>();//所有库区 |
| | | // List<Long> areaList3 = new ArrayList<>();//所有库区 |
| | | |
| | | boolean sign = true; |
| | | // //容器类型查询 起点 |
| | | String[] split = autoRunAreaEndYz.split(";"); |
| | | for (String c : split) { |
| | | WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c)); |
| | | if (!Cools.isEmpty(byId)) { |
| | | if (sign){ |
| | | areaList.add(byId.getId()); |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getAreaId, byId.getId()).eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type),false); |
| | | if (!Objects.isNull(loc)) { |
| | | deepLoc = loc.getCode(); |
| | | sign = false; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | String barcodeType = "barcode REGEXP '"+basContainer.getCodeType()+"'"; |
| | | List<Loc> loc1 = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .apply(barcodeType) |
| | | .eq(Loc::getDeleted, 0) |
| | | .eq(Loc::getStatus, 1) |
| | | .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type) |
| | | .in(Loc::getAreaId, areaList) |
| | | .orderByDesc(Loc::getId)); |
| | | |
| | | |
| | | } catch (Exception e){ |
| | | log.error("配置参数AUTO_RUN_AREA_START_YZ解析失败,请检查!!!"); |
| | | } |
| | | |
| | | if (curLoc == null || deepLoc == null) { |
| | | return; |
| | | } |
| | | LocToTaskParams params = new LocToTaskParams(); |
| | | params.setOrgLoc(curLoc).setTarLoc(deepLoc); |
| | | //生成移库位任务 |
| | | locItemService.genMoveTask(params, 9999L); |
| | | try{ |
| | | for (String c : autoRunAreaEndYz.split(";")) { |
| | | WarehouseAreas byId = warehouseAreasService.getById(Integer.parseInt(c)); |
| | | if (!Cools.isEmpty(byId)) { |
| | | endLocArea.add(byId.getId()); |
| | | } |
| | | } |
| | | if (endLocArea.isEmpty()) { |
| | | return; |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("配置参数AUTO_RUN_OUT_END_YZ解析失败,请检查!!!"); |
| | | return; |
| | | } |
| | | |
| | | ConcurrentHashMap<String,Integer> CONTAINER_IDS = new ConcurrentHashMap<>();//需要补充的容器查询条件 |
| | | // ArrayList<String> CONTAINER_IDS = new ArrayList<>();//需要补充的容器查询条件 |
| | | try{ |
| | | String[] containerList = autoRunContainerEndYz.split(";"); |
| | | for (String c : containerList) {//容器集合 |
| | | long parseLong = Long.parseLong(c); |
| | | BasContainer basContainer = basContainerService.getOne(new LambdaQueryWrapper<BasContainer>() |
| | | .eq(BasContainer::getContainerType, parseLong).last("LIMIT 1")); |
| | | if (Cools.isEmpty(basContainer)){ |
| | | throw new CoolException("未查询到相关容器规则,容器编码CONTAINER_ID:"+c); |
| | | } |
| | | //查询终点是否需要补充此容器 |
| | | String barcodeType = "barcode REGEXP '"+basContainer.getCodeType()+"'"; |
| | | int count = locService.count(new LambdaQueryWrapper<Loc>() |
| | | .apply(barcodeType) |
| | | .in(Loc::getUseStatus, new ArrayList<>(Arrays.asList( |
| | | LocStsType.LOC_STS_TYPE_D.type, |
| | | LocStsType.LOC_STS_TYPE_S.type |
| | | ))) |
| | | .in(Loc::getAreaId, endLocArea) |
| | | .eq(Loc::getDeleted, 0) |
| | | .eq(Loc::getStatus, 1) |
| | | .orderByDesc(Loc::getId)); |
| | | if (!Cools.isEmpty(count) && count<autoOutCount){ |
| | | CONTAINER_IDS.put(barcodeType, autoOutCount-count); |
| | | } |
| | | } |
| | | } catch (Exception e){ |
| | | log.error("配置参数AUTO_RUN_AREA_START_YZ解析失败,请检查!!!"); |
| | | return; |
| | | } |
| | | List<LocToTaskParams> locMove = new ArrayList<>(); |
| | | List<String> locList = new ArrayList<>(); |
| | | for (ConcurrentHashMap.Entry<String,Integer> entry : CONTAINER_IDS.entrySet()) { |
| | | String barcodeType = entry.getKey();// 获取String键 |
| | | Integer entryValue = entry.getValue();// 获取数量 |
| | | List<Loc> souLocList = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .apply(barcodeType) |
| | | .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type) |
| | | .in(Loc::getAreaId, souLocArea) |
| | | .eq(Loc::getDeleted, 0) |
| | | .eq(Loc::getStatus, 1) |
| | | .orderByDesc(Loc::getId)); |
| | | for (Loc souLoc : souLocList) { |
| | | if (entryValue<=0){ |
| | | break; |
| | | } |
| | | entryValue--; |
| | | |
| | | Loc endLoc = locService.getOne(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | | .in(Loc::getAreaId, endLocArea) |
| | | .notIn(!locList.isEmpty(), Loc::getCode, locList) |
| | | .eq(Loc::getDeleted, 0) |
| | | .eq(Loc::getStatus, 1) |
| | | .orderByDesc(Loc::getId).last("LIMIT 1")); |
| | | if (Cools.isEmpty(souLoc)){ |
| | | continue; |
| | | } |
| | | locMove.add(new LocToTaskParams().setOrgLoc(souLoc.getCode()).setTarLoc(endLoc.getCode())); |
| | | locList.add(endLoc.getCode()); |
| | | } |
| | | } |
| | | |
| | | if (locMove.isEmpty()) { |
| | | return; |
| | | } |
| | | for (LocToTaskParams locToTaskParams : locMove) { |
| | | //生成移库位任务 |
| | | try{ |
| | | locItemService.genMoveTask(locToTaskParams, 9999L); |
| | | }catch (Exception e){ |
| | | log.error("生成移库位任务失败,请检查!!!"+locToTaskParams.toString()); |
| | | } |
| | | } |
| | | } |
| | | } |