随机获取可用且有空库位的堆垛机号,找新巷道时增加判断
| | |
| | | List<LocMast> findOutMast(Short locType1, List<Integer> crnNos); |
| | | |
| | | //找单品类型,最内侧空库位 |
| | | LocMast findInEmptyLocMast(Short locType1, @Param("rows") List<Integer> rows); |
| | | List<LocMast> findInEmptyLocMast(Short locType1, @Param("rows") List<Integer> rows, Integer crnNo); |
| | | |
| | | //在库位组中搜索可入的空库位 |
| | | List<LocMast> findEmptyLocMastByLocNos(Short locType1, @Param("locNos") List<String> locNos); |
| | | List<LocMast> findEmptyLocMastByLocNos(Short locType1, @Param("locNos") List<String> locNos, Integer crnNo); |
| | | |
| | | //搜索低频(混放区域)空库位 |
| | | List<LocMast> findEmptyLowFrequencyLocMast(Short locType1); |
| | | List<LocMast> findEmptyLowFrequencyLocMast(Short locType1, Integer crnNo); |
| | | |
| | | List<LocMast> findEmptyLocMast(Short locType1, Integer crnNo); |
| | | |
| | | List<LocMast> selectLocByLev(Integer lev); |
| | | |
| | |
| | | List<LocMast> findOutMast(Short locType1, List<Integer> crnNos); |
| | | |
| | | //找单品类型,最内侧空库位 |
| | | LocMast findInEmptyLocMast(Short locType1, List<Integer> rows); |
| | | List<LocMast> findInEmptyLocMast(Short locType1, List<Integer> rows, Integer crnNo); |
| | | |
| | | //在库位组中搜索可入的空库位 |
| | | List<LocMast> findEmptyLocMastByLocNos(Short locType1, List<String> locNos); |
| | | List<LocMast> findEmptyLocMastByLocNos(Short locType1, List<String> locNos, Integer crnNo); |
| | | |
| | | //搜索低频(混放区域)空库位 |
| | | List<LocMast> findEmptyLowFrequencyLocMast(Short locType1); |
| | | List<LocMast> findEmptyLowFrequencyLocMast(Short locType1, Integer crnNo); |
| | | |
| | | List<LocMast> findEmptyLocMast(Short locType1, Integer crnNo); |
| | | |
| | | //查询指定楼层的库位数据 |
| | | List<LocMast> selectLocByLev(Integer lev); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public LocMast findInEmptyLocMast(Short locType1, List<Integer> rows) { |
| | | return this.baseMapper.findInEmptyLocMast(locType1, rows); |
| | | public List<LocMast> findInEmptyLocMast(Short locType1, List<Integer> rows, Integer crnNo) { |
| | | return this.baseMapper.findInEmptyLocMast(locType1, rows, crnNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocMast> findEmptyLocMastByLocNos(Short locType1, List<String> locNos) { |
| | | return this.baseMapper.findEmptyLocMastByLocNos(locType1, locNos); |
| | | public List<LocMast> findEmptyLocMastByLocNos(Short locType1, List<String> locNos, Integer crnNo) { |
| | | return this.baseMapper.findEmptyLocMastByLocNos(locType1, locNos, crnNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocMast> findEmptyLowFrequencyLocMast(Short locType1) { |
| | | return this.baseMapper.findEmptyLowFrequencyLocMast(locType1); |
| | | public List<LocMast> findEmptyLowFrequencyLocMast(Short locType1, Integer crnNo) { |
| | | return this.baseMapper.findEmptyLowFrequencyLocMast(locType1, crnNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<LocMast> findEmptyLocMast(Short locType1, Integer crnNo) { |
| | | return this.baseMapper.findEmptyLocMast(locType1, crnNo); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | |
| | |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 随机获取可用且有空库位的堆垛机号 |
| | | */ |
| | | public static Integer getRandomCrnNo(List<Integer> crnNos, Short locType1) { |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | LocMastService locMastService = SpringUtils.getBean(LocMastService.class); |
| | | Random random = new Random(); |
| | | //可用堆垛机list |
| | | ArrayList<Integer> normalCrnNos = new ArrayList<>(); |
| | | for (Integer crnNo : crnNos) { |
| | | List<LocMast> emptyLocMast = locMastService.findEmptyLocMast(locType1, crnNo); |
| | | if (basCrnpService.checkSiteError(crnNo, true) && emptyLocMast.size() > 0) { |
| | | normalCrnNos.add(crnNo); |
| | | } |
| | | } |
| | | if (normalCrnNos.size() == 0) { |
| | | throw new CoolException("没有可用堆垛机"); |
| | | } |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = normalCrnNos.get(random.nextInt(normalCrnNos.size())); |
| | | return randomCrnNo; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | List<String> groupLoc = Utils.getGroupLoc("1300801"); |
| | | System.out.println(groupLoc); |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | |
| | | /** |
| | | * 货架核心功能 |
| | |
| | | |
| | | if (matType != null) { |
| | | if (matType == 1) {//单品类型入库 |
| | | locMast = getLocNoStep2(locTypeDto, matNos, rows); |
| | | locMast = getLocNoStep2(locTypeDto, matNos, rows, crnNos); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoFinalStep(staDescId, sourceStaNo, locMast);//返回dto |
| | |
| | | locMast = getLocNoStep3(locTypeDto, crnNos); |
| | | if (locMast == null) { |
| | | //高频没有找到库位,找低频混放区域库位 |
| | | locMast = getLocNoStep4(locTypeDto); |
| | | locMast = getLocNoStep4(locTypeDto, crnNos); |
| | | } |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoFinalStep(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | } else if (matType == 3) {//低频混放类型 |
| | | locMast = getLocNoStep4(locTypeDto); |
| | | locMast = getLocNoStep4(locTypeDto, crnNos); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | return getLocNoFinalStep(staDescId, sourceStaNo, locMast);//返回dto |
| | |
| | | } |
| | | |
| | | //单品类型入库 |
| | | private LocMast getLocNoStep2(LocTypeDto locTypeDto, List<String> matNos, List<Integer> rows) { |
| | | private LocMast getLocNoStep2(LocTypeDto locTypeDto, List<String> matNos, List<Integer> rows, List<Integer> crnNos) { |
| | | LocMast locMast = null; |
| | | |
| | | //先找工作档 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectSameWrkMast(matNos.get(0)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | List<String> groupLoc = Utils.getGroupLoc(wrkMast.getLocNo()); |
| | | List<LocMast> locMasts = locMastService.findEmptyLocMastByLocNos(locTypeDto.getLocType1(), groupLoc); |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = Utils.getRandomCrnNo(crnNos, locTypeDto.getLocType1()); |
| | | List<LocMast> locMasts = locMastService.findEmptyLocMastByLocNos(locTypeDto.getLocType1(), groupLoc, randomCrnNo); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //检测当前库位内侧其他库位是否为D、F、X、S |
| | | if (Utils.checkInsideLocIsDFXS(locMast0.getLocNo())) { |
| | |
| | | List<String> locNos = locDetlService.getSameDetl(matNos.get(0)); |
| | | for (String locNo : locNos) { |
| | | List<String> groupLoc = Utils.getGroupLoc(locNo); |
| | | List<LocMast> locMasts = locMastService.findEmptyLocMastByLocNos(locTypeDto.getLocType1(), groupLoc); |
| | | List<LocMast> locMasts = locMastService.findEmptyLocMastByLocNos(locTypeDto.getLocType1(), groupLoc, null); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //检测当前库位内侧其他库位是否为D、F、X |
| | | if (Utils.checkInsideLocIsDFX(locMast0.getLocNo())) { |
| | |
| | | |
| | | //未找到巷道,找一条新的空巷道 |
| | | if (locMast == null) { |
| | | locMast = locMastService.findInEmptyLocMast(locTypeDto.getLocType1(), rows);//找一条新的空巷道 |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = Utils.getRandomCrnNo(crnNos, locTypeDto.getLocType1()); |
| | | List<LocMast> locMasts = locMastService.findInEmptyLocMast(locTypeDto.getLocType1(), rows, randomCrnNo);//找一条新的空巷道 |
| | | for (LocMast locMast0 : locMasts) { |
| | | //检测当前库位内侧其他库位是否为D、F、X |
| | | if (Utils.checkInsideLocIsDFX(locMast0.getLocNo())) { |
| | | //内侧其他库位不是D、F、X。不能选取该库位 |
| | | continue; |
| | | } |
| | | |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | // 浅库位对应堆垛机必须可用且无异常 |
| | | if (basCrnpService.checkSiteError(locMast0.getCrnNo(), true)) { |
| | | // 因库位移转、需预留空库位 |
| | | if (locMastService.checkEmptyCount(locMast0, 10)) { |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return locMast; |
| | |
| | | //高频类型入最外侧库位 |
| | | private LocMast getLocNoStep3(LocTypeDto locTypeDto, List<Integer> crnNos) { |
| | | LocMast locMast = null; |
| | | |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = Utils.getRandomCrnNo(crnNos, locTypeDto.getLocType1()); |
| | | ArrayList<Integer> randomCrnNos = new ArrayList<>(); |
| | | randomCrnNos.add(randomCrnNo); |
| | | |
| | | //找最外侧空库位 |
| | | List<LocMast> locMasts = locMastService.findOutMast(locTypeDto.getLocType1(), crnNos); |
| | | List<LocMast> locMasts = locMastService.findOutMast(locTypeDto.getLocType1(), randomCrnNos); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //检测当前库位内侧其他库位是否为D、F、X |
| | | if (Utils.checkInsideLocIsDFX(locMast0.getLocNo())) { |
| | |
| | | } |
| | | |
| | | //低频类型,直接找混放区域 |
| | | private LocMast getLocNoStep4(LocTypeDto locTypeDto) { |
| | | private LocMast getLocNoStep4(LocTypeDto locTypeDto, List<Integer> crnNos) { |
| | | LocMast locMast = null; |
| | | List<LocMast> locMasts = locMastService.findEmptyLowFrequencyLocMast(locTypeDto.getLocType1()); |
| | | |
| | | //随机可用堆垛机号 |
| | | Integer randomCrnNo = Utils.getRandomCrnNo(crnNos, locTypeDto.getLocType1()); |
| | | |
| | | List<LocMast> locMasts = locMastService.findEmptyLowFrequencyLocMast(locTypeDto.getLocType1(), randomCrnNo); |
| | | for (LocMast locMast0 : locMasts) { |
| | | //检测当前库位内侧其他库位是否为D、F、X |
| | | if (Utils.checkInsideLocIsDFX(locMast0.getLocNo())) { |
| | |
| | | #{item} |
| | | </foreach> |
| | | and loc_sts = 'O' |
| | | order by row1,bay1,lev1 |
| | | order by bay1,lev1,row1, |
| | | </select> |
| | | |
| | | <select id="findInEmptyLocMast" resultMap="BaseResultMap"> |
| | | select top 1 * from asr_loc_mast |
| | | select * from asr_loc_mast |
| | | where loc_type2 = 1 |
| | | and loc_type1 = #{locType1} |
| | | and row1 in |
| | |
| | | #{item} |
| | | </foreach> |
| | | and loc_sts = 'O' |
| | | order by row1,bay1,lev1 |
| | | and crn_no = #{crnNo} |
| | | order by bay1,lev1,row1 |
| | | </select> |
| | | |
| | | <select id="findEmptyLocMastByLocNos" resultMap="BaseResultMap"> |
| | |
| | | #{item} |
| | | </foreach> |
| | | and loc_sts = 'O' |
| | | order by row1,bay1,lev1 |
| | | <if test="crnNo != null || crnNo != ''"> |
| | | and crn_no = #{crnNo} |
| | | </if> |
| | | order by bay1,lev1,row1 |
| | | </select> |
| | | |
| | | <select id="findEmptyLowFrequencyLocMast" resultMap="BaseResultMap"> |
| | |
| | | where loc_type2 = 3 |
| | | and loc_type1 = #{locType1} |
| | | and loc_sts = 'O' |
| | | order by row1,bay1,lev1 |
| | | and crn_no = #{crnNo} |
| | | order by bay1,lev1,row1 |
| | | </select> |
| | | |
| | | <select id="findEmptyLocMast" resultMap="BaseResultMap"> |
| | | select * from asr_loc_mast |
| | | where loc_type1 = #{locType1} |
| | | and loc_sts = 'O' |
| | | and crn_no = #{crnNo} |
| | | order by bay1,lev1,row1 |
| | | </select> |
| | | |
| | | <select id="selectLocByLev" resultMap="BaseResultMap"> |