From d0226747665355acecd5b4f2b5c0beb020586729 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期五, 17 一月 2025 15:37:32 +0800 Subject: [PATCH] # 23. PDA拣货单据,勾选或点击确认按钮后,完成当前单据 (已完成) 24. PDA出库成功后,界面数据重置,避免重复操作 (已修复) 25. PDA接口请求,添加一个Loading遮档 (已修复) 27. 非平库单据,在平库可做入库操作 (已修复) 28. 平库已组拖数据,组拖完成后依然可组拖 (已修复) 29. 平库入库后,订单明细没有添加(已修复) 30. 平库入库后,单据类型没有修改(已修复) 31. 没有绑定播种位,不能进行播种,前后端都需加判定(已修复) 33. 平库入库未修改入库已完成数量(已修复) 34. cacheSite缓存站点逻辑需重新梳理,入库生成波次时(已完成) 35. PDA添加发货确认,默认全选 (已修复) 36. 大屏获取任务时,是由容器到达的拖盘码确认通知 (已修复) 37. 拣货单序号不显示 问题修复 (已修复) 42. pda发货确认,添加不同颜色区分是否全部完成拣货,绿色全部拣货完成,红色完成部分拣货(已修复) 43. CTU入库完成后,订单明细没有删除,执行中数量清空(已修复) 44. 平库入库完成后,历史档明细完成数量没有更新 (已修复) 45. PDA料号不显示 (已修复) 46. 发货完成后,波次管理数据未加入历史档 (已修复) --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java | 676 ++++++++++++++++++++++++++++++-------------------------- 1 files changed, 360 insertions(+), 316 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java index 06d9e13..ee538ea 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java @@ -1,316 +1,360 @@ -package com.zy.asrs.wms.utils; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.zy.asrs.framework.common.Cools; -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.LocTypeHeightType; -import com.zy.asrs.wms.asrs.mapper.ViewLocDetlMapper; -import com.zy.asrs.wms.asrs.mapper.ViewTaskDetlMapper; -import com.zy.asrs.wms.asrs.service.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Component -public class LocUtils { - - @Autowired - private TaskService taskService; - @Autowired - private LocService locService; - @Autowired - private SuggestLocRuleService suggestLocRuleService; - @Autowired - private LanewayRuleService lanewayRuleService; - @Autowired - private LocTypeService locTypeService; - @Autowired - private LocTypeBindService locTypeBindService; - @Autowired - private ViewLocDetlMapper viewLocDetlMapper; - @Autowired - private ViewTaskDetlMapper viewTaskDetlMapper; - - //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�(婊℃墭鐩�) - public Loc getNeighborLoc(Long taskType, OrderDetl orderDetl, Integer locTypeHeight) { - //婊℃墭鐩� - //浠庝换鍔′腑杩涜鍖归厤 - List<Loc> locs = new ArrayList<>(); - List<Map<String, Object>> list = viewTaskDetlMapper.getList(orderDetl.getMat$().getMatnr(), orderDetl.getBatch(), orderDetl.getUniqueField()); - for (Map<String, Object> map : list) { - Task task = taskService.getById(map.get("taskId").toString()); - if(task == null) { - continue; - } - - String targetLoc = task.getTargetLoc(); - Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, targetLoc)); - if(one == null) { - continue; - } - locs.add(one); - } - - Loc loc = filterLoc(taskType, locs); - if (loc != null) { - return loc; - } - - //浠庡簱瀛樹腑杩涜鍖归厤 - List<Loc> locs2 = new ArrayList<>(); - List<Map<String, Object>> list2 = viewLocDetlMapper.getList(orderDetl.getMat$().getMatnr(), orderDetl.getBatch(), orderDetl.getUniqueField()); - for (Map<String, Object> map : list2) { - Loc one = locService.getById(map.get("locId").toString()); - if(one == null) { - continue; - } - locs2.add(one); - } - - Loc loc2 = filterLoc(taskType, locs2); - if (loc2 != null) { - return loc2; - } - return null; - } - - //鑾峰彇鎺ㄨ崘搴撲綅(婊℃墭鐩�) - public List<Loc> getSuggestLoc(Long taskType, Long matId, String batch, Integer locTypeHeight) { - //婊℃墭鐩� - List<Loc> locs = new ArrayList<>(); - LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); - if (locTypeHeightType == null) { - throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); - } - //鑾峰彇搴撲綅楂樺害 - LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); - //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� - List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); - - LambdaQueryWrapper<SuggestLocRule> wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SuggestLocRule::getLocType, 1); - wrapper.eq(SuggestLocRule::getMatId, matId); - if (!Cools.isEmpty(batch)) { - wrapper.eq(SuggestLocRule::getBatch, batch); - } - List<SuggestLocRule> suggestLocRules = suggestLocRuleService.list(wrapper); - for (SuggestLocRule suggestLocRule : suggestLocRules) { - LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.ge(Loc::getRow1, suggestLocRule.getStartRow()); - queryWrapper.le(Loc::getRow1, suggestLocRule.getTargetRow()); - queryWrapper.ge(Loc::getBay1, suggestLocRule.getStartBay()); - queryWrapper.le(Loc::getBay1, suggestLocRule.getTargetBay()); - queryWrapper.ge(Loc::getLev1, suggestLocRule.getStartLev()); - queryWrapper.le(Loc::getLev1, suggestLocRule.getTargetLev()); - queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); - queryWrapper.in(Loc::getId, locIdList); - List<Loc> list = locService.list(queryWrapper); - if (!list.isEmpty()) { - locs.addAll(list); - } - } - return locs; - } - - //鑾峰彇鍏ㄥ眬搴撲綅(瀹屾暣宸烽亾) - public List<Loc> getGlobalLoc(Long taskType, Integer locTypeHeight) { - List<Loc> locs = new ArrayList<>(); - LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); - if (locTypeHeightType == null) { - throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); - } - //鑾峰彇搴撲綅楂樺害 - LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); - //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� - List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); - - LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); - queryWrapper.in(Loc::getId, locIdList); - List<Loc> list = locService.list(queryWrapper); - if (!list.isEmpty()) { - locs.addAll(list); - } - return locs; - } - - //浠庡簱浣嶉泦鍚堜腑鑾峰彇绗﹀悎娣辨祬鐨勫簱浣� - public Loc filterLoc(Long taskType, List<Loc> locs) { - if (locs == null || locs.isEmpty()) { - return null; - } - - Loc defaultLoc = null; - for (Loc loc : locs) { - //鑾峰彇搴撲綅鎵�鍦ㄥ贩閬� - LanewayRule lanewayRule = lanewayRuleService.getLaneByLoc(loc); - if(lanewayRule == null) { - throw new CoolException("搴撲綅鏈厤缃贩閬�"); - } - - //鑾峰彇搴撲綅鏂瑰悜 - List<Integer> direction = null; - if (lanewayRule.getLaneX$().contains(loc.getRow1())) { - direction = lanewayRule.getLaneX$(); - }else { - direction = lanewayRule.getLaneY$(); - } - - for (Integer row : direction) { - Loc one = locService.getOne(new LambdaQueryWrapper<Loc>() - .eq(Loc::getRow1, row) - .eq(Loc::getBay1, loc.getBay1()) - .eq(Loc::getLev1, loc.getLev1())); - if (one == null) { - continue; - } - - if(one.getLocStsId() != LocStsType.O.val()) { - continue; - } - - //褰撳墠搴撲綅鏄┖搴撲綅 - defaultLoc = one; - break; - } - - if (defaultLoc != null) { - break; - } - } - - return defaultLoc; - } - - //浠庡簱浣嶉泦鍚堜腑鑾峰彇瀹屾暣绌哄贩閬� - public Loc filterAllLoc(List<Loc> locs) { - if (locs == null || locs.isEmpty()) { - return null; - } - - Loc defaultLoc = null; - for (Loc loc : locs) { - //鑾峰彇搴撲綅鎵�鍦ㄥ贩閬� - LanewayRule lanewayRule = lanewayRuleService.getLaneByLoc(loc); - if(lanewayRule == null) { - throw new CoolException("搴撲綅鏈厤缃贩閬�"); - } - - //鑾峰彇搴撲綅鏂瑰悜 - List<Integer> direction = null; - if (lanewayRule.getLaneX$().contains(loc.getRow1())) { - direction = lanewayRule.getLaneX$(); - }else { - direction = lanewayRule.getLaneY$(); - } - - boolean flag = false; - List<Loc> allLocs = new ArrayList<>(); - for (Integer row : direction) { - Loc one = locService.getOne(new LambdaQueryWrapper<Loc>() - .eq(Loc::getRow1, row) - .eq(Loc::getBay1, loc.getBay1()) - .eq(Loc::getLev1, loc.getLev1())); - if (one == null) { - continue; - } - - if(one.getLocStsId() != LocStsType.O.val()) { - flag = true; - break; - } - - allLocs.add(one); - } - - if (flag) { - continue; - } - - if (!allLocs.isEmpty()) { - defaultLoc = allLocs.get(0); - break;//鎵惧埌涓�涓畬鏁寸┖宸烽亾 - } - } - - return defaultLoc; - } - - //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�(绌烘墭鐩�) - public Loc getNeighborEmptyLoc(Long taskType, Integer locTypeHeight) { - //浠庝换鍔′腑杩涜鍖归厤 - List<Loc> locs = new ArrayList<>(); - List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskType, 10)); - for (Task task : list) { - String targetLoc = task.getTargetLoc(); - Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, targetLoc)); - if(one == null) { - continue; - } - locs.add(one); - } - - Loc loc = filterLoc(taskType, locs); - if (loc != null) { - return loc; - } - - //浠庡簱瀛樹腑杩涜鍖归厤 - List<Loc> locs2 = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.D.val())); - Loc loc2 = filterLoc(taskType, locs2); - if (loc2 != null) { - return loc2; - } - return null; - } - - //鑾峰彇鎺ㄨ崘搴撲綅(绌烘墭鐩�) - public List<Loc> getSuggestEmptyLoc(Long taskType, Integer locTypeHeight) { - List<Loc> locs = new ArrayList<>(); - //绌烘墭鐩� - List<SuggestLocRule> suggestLocRules = suggestLocRuleService.list(new LambdaQueryWrapper<SuggestLocRule>().eq(SuggestLocRule::getLocType, 0)); - for (SuggestLocRule suggestLocRule : suggestLocRules) { - LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.ge(Loc::getRow1, suggestLocRule.getStartRow()); - queryWrapper.le(Loc::getRow1, suggestLocRule.getTargetRow()); - queryWrapper.ge(Loc::getBay1, suggestLocRule.getStartBay()); - queryWrapper.le(Loc::getBay1, suggestLocRule.getTargetBay()); - queryWrapper.ge(Loc::getLev1, suggestLocRule.getStartLev()); - queryWrapper.le(Loc::getLev1, suggestLocRule.getTargetLev()); - queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); - List<Loc> list = locService.list(queryWrapper); - if (!list.isEmpty()) { - locs.addAll(list); - } - } - return locs; - } - - //鑾峰彇鍏ㄥ眬搴撲綅(瀹屾暣宸烽亾) - public List<Loc> getGlobalEmptyLoc(Long taskType, Integer locTypeHeight) { - List<Loc> locs = new ArrayList<>(); - LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); - if (locTypeHeightType == null) { - throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); - } - //鑾峰彇搴撲綅楂樺害 - LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); - //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� - List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); - - LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); - queryWrapper.in(Loc::getId, locIdList); - List<Loc> list = locService.list(queryWrapper); - if (!list.isEmpty()) { - locs.addAll(list); - } - return locs; - } - -} +package com.zy.asrs.wms.utils; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.framework.common.Cools; +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.LocTypeHeightType; +import com.zy.asrs.wms.asrs.entity.param.FieldParam; +import com.zy.asrs.wms.asrs.mapper.ViewLocDetlMapper; +import com.zy.asrs.wms.asrs.mapper.ViewTaskDetlMapper; +import com.zy.asrs.wms.asrs.service.*; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Component +public class LocUtils { + + @Autowired + private TaskService taskService; + @Autowired + private LocService locService; + @Autowired + private SuggestLocRuleService suggestLocRuleService; + @Autowired + private LanewayRuleService lanewayRuleService; + @Autowired + private LocTypeService locTypeService; + @Autowired + private LocTypeBindService locTypeBindService; + @Autowired + private ViewLocDetlMapper viewLocDetlMapper; + @Autowired + private ViewTaskDetlMapper viewTaskDetlMapper; + @Autowired + private MatService matService; + + //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�(婊℃墭鐩�) + public Loc getNeighborLoc(Long taskType, Long matId, String batch, List<FieldParam> uniqueFields, Integer locTypeHeight) { + //婊℃墭鐩� + Mat mat = matService.getById(matId); + if (mat == null) { + return null; + } + + //浠庝换鍔′腑杩涜鍖归厤 + List<Loc> locs = new ArrayList<>(); + List<Map<String, Object>> list = viewTaskDetlMapper.getList(mat.getMatnr(), batch, uniqueFields); + for (Map<String, Object> map : list) { + Task task = taskService.getById(map.get("taskId").toString()); + if (task == null) { + continue; + } + + String targetLoc = task.getTargetLoc(); + Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, targetLoc)); + if (one == null) { + continue; + } + locs.add(one); + } + + Loc loc = filterLoc(taskType, locs); + if (loc != null) { + return loc; + } + + //浠庡簱瀛樹腑杩涜鍖归厤 + List<Loc> locs2 = new ArrayList<>(); + List<Map<String, Object>> list2 = viewLocDetlMapper.getList(mat.getMatnr(), batch, uniqueFields, null); + for (Map<String, Object> map : list2) { + Loc one = locService.getById(map.get("locId").toString()); + if (one == null) { + continue; + } + locs2.add(one); + } + + Loc loc2 = filterLoc(taskType, locs2); + if (loc2 != null) { + return loc2; + } + return null; + } + + //鑾峰彇鎺ㄨ崘搴撲綅(婊℃墭鐩�) + public List<Loc> getSuggestLoc(Long taskType, Long matId, String batch, Integer locTypeHeight, List<Integer> laneRowList, Integer currentLev) { + //婊℃墭鐩� + List<Loc> locs = new ArrayList<>(); + LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); + if (locTypeHeightType == null) { + throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); + } + //鑾峰彇搴撲綅楂樺害 + LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); + //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� + List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); + + LambdaQueryWrapper<SuggestLocRule> wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SuggestLocRule::getLocType, 1); + wrapper.eq(SuggestLocRule::getMatId, matId); + if (!Cools.isEmpty(batch)) { + wrapper.eq(SuggestLocRule::getBatch, batch); + } + List<SuggestLocRule> suggestLocRules = suggestLocRuleService.list(wrapper); + for (SuggestLocRule suggestLocRule : suggestLocRules) { + LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.ge(Loc::getRow1, suggestLocRule.getStartRow()); + queryWrapper.le(Loc::getRow1, suggestLocRule.getTargetRow()); + queryWrapper.ge(Loc::getBay1, suggestLocRule.getStartBay()); + queryWrapper.le(Loc::getBay1, suggestLocRule.getTargetBay()); + queryWrapper.ge(Loc::getLev1, suggestLocRule.getStartLev()); + queryWrapper.le(Loc::getLev1, suggestLocRule.getTargetLev()); + queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); + queryWrapper.in(Loc::getId, locIdList); + + if (laneRowList != null && !laneRowList.isEmpty()) { + queryWrapper.in(Loc::getRow1, laneRowList); + } + + if (currentLev != null) { + queryWrapper.eq(Loc::getLev1, currentLev); + } + + List<Loc> list = locService.list(queryWrapper); + if (!list.isEmpty()) { + locs.addAll(list); + } + } + return locs; + } + + //鑾峰彇鍏ㄥ眬搴撲綅(瀹屾暣宸烽亾) + public List<Loc> getGlobalLoc(Long taskType, Integer locTypeHeight, List<Integer> laneRowList, Integer currentLev) { + List<Loc> locs = new ArrayList<>(); + LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); + if (locTypeHeightType == null) { + throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); + } + //鑾峰彇搴撲綅楂樺害 + LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); + //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� + List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); + + LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); + queryWrapper.in(Loc::getId, locIdList); + + if (laneRowList != null && !laneRowList.isEmpty()) { + queryWrapper.in(Loc::getRow1, laneRowList); + } + + if (currentLev != null) { + queryWrapper.eq(Loc::getLev1, currentLev); + } + + List<Loc> list = locService.list(queryWrapper); + if (!list.isEmpty()) { + locs.addAll(list); + } + return locs; + } + + //浠庡簱浣嶉泦鍚堜腑鑾峰彇绗﹀悎娣辨祬鐨勫簱浣� + public Loc filterLoc(Long taskType, List<Loc> locs) { + if (locs == null || locs.isEmpty()) { + return null; + } + + Loc defaultLoc = null; + for (Loc loc : locs) { + //鑾峰彇搴撲綅鎵�鍦ㄥ贩閬� + LanewayRule lanewayRule = lanewayRuleService.getLaneByLoc(loc); + if(lanewayRule == null) { + throw new CoolException("搴撲綅鏈厤缃贩閬�"); + } + + //鑾峰彇搴撲綅鏂瑰悜 + List<Integer> direction = null; + if (lanewayRule.getLaneX$().contains(loc.getRow1())) { + direction = lanewayRule.getLaneX$(); + }else { + direction = lanewayRule.getLaneY$(); + } + + for (Integer row : direction) { + Loc one = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getRow1, row) + .eq(Loc::getBay1, loc.getBay1()) + .eq(Loc::getLev1, loc.getLev1())); + if (one == null) { + continue; + } + + if(one.getLocStsId() != LocStsType.O.val()) { + continue; + } + + //褰撳墠搴撲綅鏄┖搴撲綅 + defaultLoc = one; + break; + } + + if (defaultLoc != null) { + break; + } + } + + return defaultLoc; + } + + //浠庡簱浣嶉泦鍚堜腑鑾峰彇瀹屾暣绌哄贩閬� + public Loc filterAllLoc(List<Loc> locs) { + if (locs == null || locs.isEmpty()) { + return null; + } + + Loc defaultLoc = null; + for (Loc loc : locs) { + //鑾峰彇搴撲綅鎵�鍦ㄥ贩閬� + LanewayRule lanewayRule = lanewayRuleService.getLaneByLoc(loc); + if(lanewayRule == null) { + throw new CoolException("搴撲綅鏈厤缃贩閬�"); + } + + //鑾峰彇搴撲綅鏂瑰悜 + List<Integer> direction = null; + if (lanewayRule.getLaneX$().contains(loc.getRow1())) { + direction = lanewayRule.getLaneX$(); + }else { + direction = lanewayRule.getLaneY$(); + } + + boolean flag = false; + List<Loc> allLocs = new ArrayList<>(); + for (Integer row : direction) { + Loc one = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getRow1, row) + .eq(Loc::getBay1, loc.getBay1()) + .eq(Loc::getLev1, loc.getLev1())); + if (one == null) { + continue; + } + + if(one.getLocStsId() != LocStsType.O.val()) { + flag = true; + break; + } + + allLocs.add(one); + } + + if (flag) { + continue; + } + + if (!allLocs.isEmpty()) { + defaultLoc = allLocs.get(0); + break;//鎵惧埌涓�涓畬鏁寸┖宸烽亾 + } + } + + return defaultLoc; + } + + //浠庡簱瀛樻垨浠诲姟涓尮閰嶇浉閭诲簱浣�(绌烘墭鐩�) + public Loc getNeighborEmptyLoc(Long taskType, Integer locTypeHeight) { + //浠庝换鍔′腑杩涜鍖归厤 + List<Loc> locs = new ArrayList<>(); + List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getTaskType, 10)); + for (Task task : list) { + String targetLoc = task.getTargetLoc(); + Loc one = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, targetLoc)); + if(one == null) { + continue; + } + locs.add(one); + } + + Loc loc = filterLoc(taskType, locs); + if (loc != null) { + return loc; + } + + //浠庡簱瀛樹腑杩涜鍖归厤 + List<Loc> locs2 = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.D.val())); + Loc loc2 = filterLoc(taskType, locs2); + if (loc2 != null) { + return loc2; + } + return null; + } + + //鑾峰彇鎺ㄨ崘搴撲綅(绌烘墭鐩�) + public List<Loc> getSuggestEmptyLoc(Long taskType, Integer locTypeHeight, List<Integer> laneRowList, Integer currentLev) { + List<Loc> locs = new ArrayList<>(); + //绌烘墭鐩� + List<SuggestLocRule> suggestLocRules = suggestLocRuleService.list(new LambdaQueryWrapper<SuggestLocRule>().eq(SuggestLocRule::getLocType, 0)); + for (SuggestLocRule suggestLocRule : suggestLocRules) { + LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.ge(Loc::getRow1, suggestLocRule.getStartRow()); + queryWrapper.le(Loc::getRow1, suggestLocRule.getTargetRow()); + queryWrapper.ge(Loc::getBay1, suggestLocRule.getStartBay()); + queryWrapper.le(Loc::getBay1, suggestLocRule.getTargetBay()); + queryWrapper.ge(Loc::getLev1, suggestLocRule.getStartLev()); + queryWrapper.le(Loc::getLev1, suggestLocRule.getTargetLev()); + queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); + + if (laneRowList != null && !laneRowList.isEmpty()) { + queryWrapper.in(Loc::getRow1, laneRowList); + } + + if (currentLev != null) { + queryWrapper.eq(Loc::getLev1, currentLev); + } + + List<Loc> list = locService.list(queryWrapper); + if (!list.isEmpty()) { + locs.addAll(list); + } + } + return locs; + } + + //鑾峰彇鍏ㄥ眬搴撲綅(瀹屾暣宸烽亾) + public List<Loc> getGlobalEmptyLoc(Long taskType, Integer locTypeHeight, List<Integer> laneRowList, Integer currentLev) { + List<Loc> locs = new ArrayList<>(); + LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locTypeHeight); + if (locTypeHeightType == null) { + throw new CoolException("搴撲綅楂樺害绫诲瀷寮傚父"); + } + //鑾峰彇搴撲綅楂樺害 + LocType locType = locTypeService.getOne(new LambdaQueryWrapper<LocType>().eq(LocType::getFlag, locTypeHeightType.flag)); + //绗﹀悎搴撲綅楂樺害鐨勫簱浣嶉泦鍚� + List<Long> locIdList = locTypeBindService.getLocIdListByType(locType); + + LambdaQueryWrapper<Loc> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Loc::getLocStsId, LocStsType.O.val()); + queryWrapper.in(Loc::getId, locIdList); + + if (laneRowList != null && !laneRowList.isEmpty()) { + queryWrapper.in(Loc::getRow1, laneRowList); + } + + if (currentLev != null) { + queryWrapper.eq(Loc::getLev1, currentLev); + } + + List<Loc> list = locService.list(queryWrapper); + if (!list.isEmpty()) { + locs.addAll(list); + } + return locs; + } + +} -- Gitblit v1.9.1