| | |
| | | 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(List<AgvWaitPakin> agvWaitPakinList, int floor) { |
| | | public AgvLocMast getLocNo(int type, int floor,boolean isEmpty,boolean isCurrLev) { |
| | | // 目标库位 |
| | | AgvLocMast locMast = null; |
| | | if(Cools.isEmpty(agvWaitPakinList)){ |
| | | return getLocNoRule(floor); // 1. 随机库位 |
| | | } |
| | | // if(Cools.isEmpty(agvWaitPakinList)){ |
| | | // return getLocNoRule(type); // 1. 随机库位 |
| | | // } |
| | | |
| | | //库位规则 |
| | | locMast = getLocByLocRule(agvWaitPakinList.get(0),floor); // 2. 按库位规则搜索 |
| | | if(!Cools.isEmpty(locMast)){ |
| | | return locMast; |
| | | } |
| | | // //库位规则 |
| | | // locMast = getLocByLocRule(agvWaitPakinList.get(0),floor); // 2. 按库位规则搜索 |
| | | // if(!Cools.isEmpty(locMast)){ |
| | | // return locMast; |
| | | // } |
| | | // |
| | | // |
| | | // //库位编码规则 |
| | | // locMast = getLocByLocCodeRule(agvWaitPakinList.get(0),floor); |
| | | // if(!Cools.isEmpty(locMast)){ |
| | | // return locMast; |
| | | // } |
| | | // |
| | | // // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | // locMast = getLocByProximityRule(); |
| | | // if (locMast != null) { |
| | | // //找到库位,返回dto |
| | | // //return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | // } |
| | | // |
| | | // //根据物料频率搜索库位,频率高则搜索离缓存货架最近库位,频率低则搜索最远库位 |
| | | // Mat mat = matService.selectByMatnr(agvWaitPakinList.get(0).getMatnr()); |
| | | // if(Cools.isEmpty(mat.getBeBatch())){ |
| | | // mat.setBeBatch(0); |
| | | // } |
| | | // locMast = getLocByFre(mat.getBeBatch(), floor); |
| | | // if (locMast != null) { |
| | | // return locMast; |
| | | // } |
| | | |
| | | |
| | | //库位编码规则 |
| | | locMast = getLocByLocCodeRule(agvWaitPakinList.get(0),floor); |
| | | if(!Cools.isEmpty(locMast)){ |
| | | return locMast; |
| | | } |
| | | |
| | | // 靠近摆放规则 --- 相同订单号, 同天同规格物料 |
| | | locMast = getLocByProximityRule(); |
| | | if (locMast != null) { |
| | | //找到库位,返回dto |
| | | //return getLocNoStep6(staDescId, sourceStaNo, locMast);//返回dto |
| | | } |
| | | |
| | | //根据物料频率搜索库位,频率高则搜索离缓存货架最近库位,频率低则搜索最远库位 |
| | | Mat mat = matService.selectByMatnr(agvWaitPakinList.get(0).getMatnr()); |
| | | if(Cools.isEmpty(mat.getBeBatch())){ |
| | | mat.setBeBatch(0); |
| | | } |
| | | locMast = getLocByFre(mat.getBeBatch(), floor); |
| | | if (locMast != null) { |
| | | return locMast; |
| | | } |
| | | |
| | | |
| | | // 开始查找库位 ==============================>> |
| | | locMast = getLocNoRule(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 floor){ |
| | | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() |
| | | .eq("floor",floor) |
| | | .eq("loc_sts","O") |
| | | .eq(false,"loc_type2",1)); |
| | | 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")); |
| | | } |
| | | |
| | | } |