| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wms.asrs.entity.*; |
| | | import com.zy.asrs.wms.asrs.entity.enums.LocStsType; |
| | | import com.zy.asrs.wms.asrs.entity.enums.OrderSettleType; |
| | | import com.zy.asrs.wms.asrs.entity.enums.*; |
| | | import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; |
| | | import com.zy.asrs.wms.asrs.service.*; |
| | | import com.zy.asrs.wms.utils.LocUtils; |
| | |
| | | private TaskDetlFieldLogService taskDetlFieldLogService; |
| | | @Autowired |
| | | private LocUtils locUtils; |
| | | @Autowired |
| | | private ShelvesRuleService shelvesRuleService; |
| | | @Autowired |
| | | private LanewayRuleService lanewayRuleService; |
| | | @Autowired |
| | | private CircleRuleService circleRuleService; |
| | | |
| | | @Override |
| | | public String generateTaskNo(Long taskType) { |
| | |
| | | |
| | | @Override |
| | | public Loc generateEmptyLoc(Long taskType, Integer locTypeHeight) { |
| | | Loc defaultLoc = null; |
| | | |
| | | //1.从库存或任务中匹配相邻库位 |
| | | defaultLoc = locUtils.getNeighborEmptyLoc(taskType, locTypeHeight); |
| | | if (defaultLoc != null) { |
| | | return defaultLoc; |
| | | List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime)); |
| | | if(shelvesRules.isEmpty()) { |
| | | throw new CoolException("未配置上架规则"); |
| | | } |
| | | |
| | | //2.获取推荐库位 |
| | | List<Loc> suggestLoc = locUtils.getSuggestEmptyLoc(taskType, locTypeHeight); |
| | | //获取库位 |
| | | if (!suggestLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterLoc(taskType, suggestLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | ShelvesRule shelvesRule = shelvesRules.get(0); |
| | | //可用巷道 |
| | | List<Long> laneList = shelvesRule.getLaneList(); |
| | | //可用巷道Row |
| | | List<Integer> laneRowList = new ArrayList<>(); |
| | | if (laneList != null) { |
| | | //获取巷道 |
| | | List<LanewayRule> lanewayRules = lanewayRuleService.listByIds(laneList); |
| | | for (LanewayRule lanewayRule : lanewayRules) { |
| | | laneRowList.addAll(lanewayRule.getLaneX$()); |
| | | laneRowList.addAll(lanewayRule.getLaneY$()); |
| | | } |
| | | } |
| | | |
| | | //3.从全局库位中获取(完整巷道) |
| | | List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight); |
| | | //获取库位 |
| | | if (!globalLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterAllLoc(globalLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | Integer currentLev = null; |
| | | if (shelvesRule.getRuleType().equals(ShelvesRuleType.HIGH.id)) { |
| | | //优先立体层 |
| | | currentLev = circleRuleService.getCurrentValueByFlag(CircleRuleType.LEV.flag); |
| | | } |
| | | |
| | | List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$(); |
| | | if(ruleDetls.isEmpty()) { |
| | | throw new CoolException("未配置上架规则明细"); |
| | | } |
| | | |
| | | Loc defaultLoc = null; |
| | | |
| | | for (ShelvesRuleDetl ruleDetl : ruleDetls) { |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.TASK_OR_LOC.id)) { |
| | | //从库存或任务中匹配相邻库位 |
| | | defaultLoc = locUtils.getNeighborEmptyLoc(taskType, locTypeHeight); |
| | | if (defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.SUGGEST.id)) { |
| | | //获取推荐库位 |
| | | List<Loc> suggestLoc = locUtils.getSuggestEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev); |
| | | //获取库位 |
| | | if (!suggestLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterLoc(taskType, suggestLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) { |
| | | //从全局库位中获取(完整巷道) |
| | | List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev); |
| | | //获取库位 |
| | | if (!globalLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterAllLoc(globalLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | throw new CoolException("商品不存在"); |
| | | } |
| | | |
| | | List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime)); |
| | | if(shelvesRules.isEmpty()) { |
| | | throw new CoolException("未配置上架规则"); |
| | | } |
| | | ShelvesRule shelvesRule = shelvesRules.get(0); |
| | | //可用巷道 |
| | | List<Long> laneList = shelvesRule.getLaneList(); |
| | | //可用巷道Row |
| | | List<Integer> laneRowList = new ArrayList<>(); |
| | | if (laneList != null) { |
| | | //获取巷道 |
| | | List<LanewayRule> lanewayRules = lanewayRuleService.listByIds(laneList); |
| | | for (LanewayRule lanewayRule : lanewayRules) { |
| | | laneRowList.addAll(lanewayRule.getLaneX$()); |
| | | laneRowList.addAll(lanewayRule.getLaneY$()); |
| | | } |
| | | } |
| | | |
| | | Integer currentLev = null; |
| | | if (shelvesRule.getRuleType().equals(ShelvesRuleType.HIGH.id)) { |
| | | //优先立体层 |
| | | currentLev = circleRuleService.getCurrentValueByFlag(CircleRuleType.LEV.flag); |
| | | } |
| | | |
| | | List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$(); |
| | | if(ruleDetls.isEmpty()) { |
| | | throw new CoolException("未配置上架规则明细"); |
| | | } |
| | | |
| | | Loc defaultLoc = null; |
| | | |
| | | //1.从库存或任务中匹配相邻库位 |
| | | defaultLoc = locUtils.getNeighborLoc(taskType, detl, locTypeHeight); |
| | | if (defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | for (ShelvesRuleDetl ruleDetl : ruleDetls) { |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.TASK_OR_LOC.id)) { |
| | | //从库存或任务中匹配相邻库位 |
| | | defaultLoc = locUtils.getNeighborLoc(taskType, detl, locTypeHeight); |
| | | if (defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | |
| | | //2.获取推荐库位 |
| | | List<Loc> suggestLoc = locUtils.getSuggestLoc(taskType, mat.getId(), detl.getBatch(), locTypeHeight); |
| | | //获取库位 |
| | | if (!suggestLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterLoc(taskType, suggestLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.SUGGEST.id)) { |
| | | //获取推荐库位 |
| | | List<Loc> suggestLoc = locUtils.getSuggestLoc(taskType, mat.getId(), detl.getBatch(), locTypeHeight, laneRowList, currentLev); |
| | | //获取库位 |
| | | if (!suggestLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterLoc(taskType, suggestLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) { |
| | | //从全局库位中获取(完整巷道) |
| | | List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev); |
| | | //获取库位 |
| | | if (!globalLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterAllLoc(globalLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //3.从全局库位中获取(完整巷道) |
| | | List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight); |
| | | //获取库位 |
| | | if (!globalLoc.isEmpty()) { |
| | | defaultLoc = locUtils.filterAllLoc(globalLoc); |
| | | if(defaultLoc != null) { |
| | | return defaultLoc; |
| | | } |
| | | } |
| | | |
| | | return defaultLoc; |
| | | } |
| | | |