From c635d78b479510ebe2556a420948effcd30a0731 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期六, 21 十二月 2024 18:40:43 +0800 Subject: [PATCH] 新建德森项目分支 --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/utils/LocUtils.java | 720 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 360 insertions(+), 360 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 02263e7..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,360 +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.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; - } - -} +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