| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private LocRuleService locRuleService; |
| | | @Autowired |
| | | AgvBasDevpService agvBasDevpService; |
| | | |
| | | public int getWorkNo(Integer wrkMk) { |
| | | AgvWrkLastno wrkLastno = agvWrkLastnoService.selectById(wrkMk); |
| | |
| | | * 检索库位号 |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public AgvLocMast getLocNo(int type, int floor) { |
| | | public AgvLocMast getLocNo(int type, int floor,boolean isEmpty,boolean isCurrLev) { |
| | | // 目标库位 |
| | | AgvLocMast locMast = null; |
| | | // if(Cools.isEmpty(agvWaitPakinList)){ |
| | |
| | | // } |
| | | |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | locMast = getLocNoRule(type,floor); |
| | | if (locMast != null) { |
| | | return locMast; |
| | | try{ |
| | | // 开始查找库位 ==============================>> |
| | | locMast = getLocNoRule(type,floor,isEmpty,isCurrLev); |
| | | if (locMast != null) { |
| | | return locMast; |
| | | } |
| | | }catch (Exception e){ |
| | | throw new CoolException(floor+"楼;该楼层没有空库位===>"+e.getMessage()); |
| | | } |
| | | |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("该楼层没有空库位"); |
| | | throw new CoolException(floor+"楼;该楼层没有空库位"); |
| | | } |
| | | |
| | | /* |
| | |
| | | } |
| | | |
| | | //随机取一个货位 |
| | | private AgvLocMast getLocNoRule(int type,int floor){ |
| | | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() |
| | | .eq("loc_sts","O") |
| | | .eq("floor",floor) |
| | | .eq("loc_type1",type)); |
| | | private AgvLocMast getLocNoRule(int type,int floor,boolean isEmpty,boolean isCurrLev){ |
| | | Boolean orderBy = false; |
| | | int levCount = 0; |
| | | int times = 1; |
| | | if (floor == 1 || floor >= 4) { |
| | | if (floor >= 4 ) { |
| | | floor = 1; |
| | | } |
| | | orderBy = true; |
| | | levCount = 2; |
| | | } else { |
| | | orderBy = false; |
| | | levCount = 1; |
| | | } |
| | | try{ |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | List<AgvLocMast> agvLocMasts = new ArrayList<>(); |
| | | //不是空板优先找2层 |
| | | if (isEmpty) { |
| | | wrapper.eq("floor", floor).eq("lev1",1); |
| | | } else { |
| | | if (isCurrLev) { |
| | | wrapper.eq("floor", floor).eq("lev1",1); |
| | | } else { |
| | | wrapper.eq("floor", floor).orderBy("lev1",!orderBy); |
| | | } |
| | | } |
| | | |
| | | |
| | | //当目标库位是1楼 |
| | | if(floor == 1) { |
| | | wrapper.orderBy("loc_no",false); |
| | | } |
| | | agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | //是否当前层 |
| | | if (Cools.isEmpty(agvLocMasts) && !isCurrLev) { |
| | | if (times < levCount) { |
| | | times++; |
| | | return getLocNoRule(type,floor,isEmpty,isCurrLev); |
| | | } |
| | | } |
| | | for (AgvLocMast agvLocMast : agvLocMasts){ |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")){ |
| | | return agvLocMast1; |
| | | } |
| | | } |
| | | throw new CoolException("搜索库位时,未找到可入库库位。"); |
| | | }catch (Exception e){ |
| | | throw new CoolException("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | } |
| | | /** |
| | | * 检索库位号 |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor) { |
| | | // 目标库位 |
| | | AgvBasDevp basDevp = null; |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | basDevp = getDevpNoRule(type,floor); |
| | | if (basDevp != null) { |
| | | return basDevp; |
| | | } |
| | | |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("楼层号:"+floor+";该楼层没有空接驳位"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * @return locNo 检索自动接驳位 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor, String auto) { |
| | | // 目标库位 |
| | | AgvBasDevp basDevp = null; |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | basDevp = getDevpNoAuto(type,floor,auto); |
| | | if (basDevp != null) { |
| | | return basDevp; |
| | | } |
| | | |
| | | //找不到库位,抛出异常 |
| | | throw new CoolException("楼层号:"+floor+";该楼层没有空接驳位"); |
| | | } |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * @return locNo 检索可入接驳位 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor, String auto ,String inEable) { |
| | | // 目标库位 |
| | | AgvBasDevp basDevp = null; |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | basDevp = getDevpNoInEable(type,floor,inEable); |
| | | if (basDevp != null) { |
| | | return basDevp; |
| | | } |
| | | |
| | | //找不到库位,抛出异常 |
| | | return basDevp; |
| | | } |
| | | |
| | | //随机取一个货位 |
| | | private AgvBasDevp getDevpNoRule(int type,int floor){ |
| | | return agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>() |
| | | .eq("loc_sts","O") |
| | | .eq("floor",floor) |
| | | .eq("loc_type1",type) |
| | | .like("dev_no","DB")); |
| | | } |
| | | |
| | | //随机取一个货位 |
| | | private AgvBasDevp getDevpNoAuto(int type,int floor,String auto){ |
| | | return agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>() |
| | | .eq("loc_sts","O") |
| | | .eq("floor",floor) |
| | | .eq("loc_type1",type) |
| | | .eq("autoing",auto) |
| | | .like("dev_no","DB")); |
| | | } |
| | | |
| | | //随机取一个货位 |
| | | private AgvBasDevp getDevpNoInEable(int type,int floor,String inEable){ |
| | | return agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>() |
| | | .eq("loc_sts","O") |
| | | .eq("floor",floor) |
| | | .eq("loc_type1",type) |
| | | .eq("in_enable",inEable) |
| | | .like("dev_no","DB")); |
| | | } |
| | | |
| | | } |