|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.service.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.service.impl.ServiceImpl; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocDetl; | 
|---|
|  |  |  | import com.zy.asrs.entity.LocMast; | 
|---|
|  |  |  | import com.zy.asrs.mapper.LocMastMapper; | 
|---|
|  |  |  | import com.zy.asrs.service.LocMastService; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.Collections; | 
|---|
|  |  |  | import java.util.Iterator; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | 
|---|
|  |  |  | private WorkService workService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> queryFreeLocMast(List<Integer> rows, Integer rowsLen, Short locType1) { | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMast(rows, rowsLen, locType1); | 
|---|
|  |  |  | public List<LocMast> queryFreeLocMast2(Short locType1, Integer rowBeg, Integer rowEnd, Integer bayBeg, Integer bayEnd, Integer levBeg, Integer levEnd) { | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMast2(locType1, rowBeg, rowEnd, bayBeg, bayEnd, levBeg, levEnd); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> queryFreeLocMast2(List<Integer> rows, Integer rowsLen, Short locType1) { | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMast(rows, rowsLen, locType1); | 
|---|
|  |  |  | public List<LocMast> selectAreaEmpty(Short locType1, Integer locType3) { | 
|---|
|  |  |  | return this.baseMapper.selectAreaEmpty(locType1, locType3); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public LocMast queryFreeLocMast0(Integer row, Short locType1) { | 
|---|
|  |  |  | return this.baseMapper.queryFreeLocMast0(row, locType1); | 
|---|
|  |  |  | public List<LocMast> selectAreaEmptyByLev(Short locType1, Integer locType3, Integer lev) { | 
|---|
|  |  |  | return this.baseMapper.selectAreaEmptyByLev(locType1, locType3, lev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return this.baseMapper.selectEmptyLocCount(locMast.getCrnNo()) > quaOfBlank; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean checkWhole(List<LocDetl> locDetls) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | return this.baseMapper.selectEmptyLocCount(locMast.getLocType3(), locMast.getLev1()) > quaOfBlank; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean isOutMost(String locNo, Boolean pakin) { | 
|---|
|  |  |  | return Integer.parseInt(locNo.substring(0, 2)) == Utils.getOutLayerRow(locNo, pakin); | 
|---|
|  |  |  | int row = Utils.getRow(locNo); | 
|---|
|  |  |  | int bay = Utils.getBay(locNo); | 
|---|
|  |  |  | ArrayList<Integer> list = new ArrayList<Integer>(){{ | 
|---|
|  |  |  | add(1);add(3);add(4);add(6); | 
|---|
|  |  |  | add(8);add(10);add(11); | 
|---|
|  |  |  | }}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (list.contains(row)) { | 
|---|
|  |  |  | return true;//最外侧库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (row == 13 && (bay >= 59 && bay <= 61)) { | 
|---|
|  |  |  | return true;//最外侧库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (bay < 59) { | 
|---|
|  |  |  | if (row == 13 || row == 14 || row == 16) { | 
|---|
|  |  |  | return true;//最外侧库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return false;//不是最外侧库位 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static void main(String[] args) { | 
|---|
|  |  |  | 
|---|
|  |  |  | int row = Utils.getRow(locNo); | 
|---|
|  |  |  | List<String> locNos = Utils.getGroupLoc(locNo); | 
|---|
|  |  |  | if (CommonService.FIRST_GROUP_ROW_LIST.contains(row)) { | 
|---|
|  |  |  | } else if (CommonService.SECOND_GROUP_ROW_LIST.contains(row)) { | 
|---|
|  |  |  | } else if (CommonService.SECOND_GROUP_ROW_LIST.contains(row) || CommonService.THIRD_GROUP_ROW_LIST.contains(row)) { | 
|---|
|  |  |  | Collections.reverse(locNos); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | throw new RuntimeException("库位解析异常"); | 
|---|
|  |  |  | 
|---|
|  |  |  | LocMast finalRes = null; | 
|---|
|  |  |  | for (String locNo0 : locNos) { | 
|---|
|  |  |  | LocMast locMast = this.selectById(locNo0); | 
|---|
|  |  |  | if (locMast == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (locMast.getLocSts().equals("O")) { | 
|---|
|  |  |  | if (finalRes == null) { | 
|---|
|  |  |  | finalRes = locMast; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public synchronized void breakUp(String locNo, List<String> excludeLocNos) { | 
|---|
|  |  |  | List<String> groupLoc = Utils.getGroupOuterLoc(locNo); | 
|---|
|  |  |  | Iterator<String> iterator = groupLoc.iterator(); | 
|---|
|  |  |  | while (iterator.hasNext()) { | 
|---|
|  |  |  | String next = iterator.next(); | 
|---|
|  |  |  | LocMast locMast = this.selectById(next); | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("D")) { | 
|---|
|  |  |  | if (!excludeLocNos.contains(locMast.getLocNo())) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | iterator.remove(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | workService.shuttleTransfer(groupLoc); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer getOutCrnNo(LocMast locMast) { | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public LocMast findNearloc(String locNo) { | 
|---|
|  |  |  | int row = getRow(locNo); | 
|---|
|  |  |  | LocMast locMast = null; | 
|---|
|  |  |  | List<String> groupOuterLoc = Utils.getGroupOuterLoc(locNo); | 
|---|
|  |  |  | if (!Cools.isEmpty(groupOuterLoc)) { | 
|---|
|  |  |  | locMast = this.baseMapper.selectAvailableNearLocAsc(groupOuterLoc); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return locMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public LocMast findInnerLoc(String locNo) { | 
|---|
|  |  |  | List<String> groupLoc = Utils.getGroupLoc(locNo); | 
|---|
|  |  |  | for (String loc : groupLoc) { | 
|---|
|  |  |  | LocMast tmp = this.baseMapper.selectByLoc(loc); | 
|---|
|  |  |  | if (tmp == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (tmp.getLocSts().equals("O")) { | 
|---|
|  |  |  | return tmp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 通过库位号获取 排 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static int getRow(String locNo) { | 
|---|
|  |  |  | if (!Cools.isEmpty(locNo)) { | 
|---|
|  |  |  | return Integer.parseInt(locNo.substring(0, 2)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | throw new RuntimeException("库位解析异常"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectAllPeakLoc() { | 
|---|
|  |  |  | return this.baseMapper.selectAllPeakLoc(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Boolean checkAllLocEmpty(List<String> groupOuterLoc) { | 
|---|
|  |  |  | List<LocMast> result = this.baseMapper.selectAllLocNotEmpty(groupOuterLoc); | 
|---|
|  |  |  | return result.size() <= 0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectLocByLev(Integer lev) { | 
|---|
|  |  |  | return this.baseMapper.selectLocByLev(lev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectEmptyByLocNos(List<String> locNos) { | 
|---|
|  |  |  | return this.baseMapper.selectEmptyByLocNos(locNos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public LocMast selectByLoc(String locNo) { | 
|---|
|  |  |  | return this.baseMapper.selectByLoc(locNo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer updateLocType2ByRBL(Integer locType2, Integer startRow, Integer endRow, Integer startBay, Integer endBay, Integer startLev, Integer endLev) { | 
|---|
|  |  |  | return this.baseMapper.updateLocType2ByRBL(locType2, startRow, endRow, startBay, endBay, startLev, endLev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateByLocNo(LocMast locMast){ | 
|---|
|  |  |  | this.update(locMast,new EntityWrapper<LocMast>().eq("loc_no",locMast.getLocNo())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public List<LocMast> selectLocDetlNotExist() { | 
|---|
|  |  |  | return this.baseMapper.selectLocDetlNotExist(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|