| | |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.LocUtils; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | private LocRuleService locRuleService; |
| | | @Autowired |
| | | AgvBasDevpService agvBasDevpService; |
| | | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Autowired |
| | | private LocUtils locUtils; |
| | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public AgvLocMast getLocNo(int type, int floor, boolean isEmpty, boolean isCurrLev, String factory) { |
| | | public AgvLocMast getLocNo(int type, int floor, boolean isEmpty, boolean isCurrLev) { |
| | | // 目标库位 |
| | | AgvLocMast locMast = null; |
| | | // if(Cools.isEmpty(agvWaitPakinList)){ |
| | |
| | | |
| | | try { |
| | | // 开始查找库位 ==============================>> |
| | | // 四期项目:需要改查找库位逻辑 |
| | | // 箱壳入库 |
| | | if (type == 3 && factory != null) { |
| | | //优先入库吸塑1楼,在2楼 |
| | | locMast = locUtils.getLocNoRuleByFactory(type, isEmpty, factory); |
| | | } else if (type == 6) { |
| | | //半成品箱壳入库,入到吸塑2楼的370个库位里 |
| | | locMast = locUtils.getLocNoRuleByFloor(type, floor, isEmpty, 2); |
| | | // if (type == 3 && factory != null) { |
| | | // //优先入库吸塑1楼,在2楼 |
| | | // locMast = locUtils.getLocNoRuleByFactory(type, isEmpty, factory); |
| | | // } else if (type == 6) { |
| | | // //半成品箱壳入库,入到吸塑2楼的370个库位里 |
| | | // locMast = locUtils.getLocNoRuleByFloor(type, floor, isEmpty, 2); |
| | | // } else { |
| | | // //不动这个逻辑 |
| | | if (type == 6) { |
| | | locMast = locUtils.getLocNoRuleByFloor(type, floor); |
| | | } else { |
| | | //不动这个逻辑 |
| | | locMast = getLocNoRule(type, floor, isEmpty, isCurrLev); |
| | | } |
| | | // } |
| | | if (locMast != null) { |
| | | return locMast; |
| | | } |
| | |
| | | throw new CoolException(floor + "楼;该楼层没有空库位"); |
| | | } |
| | | |
| | | /* |
| | | 库位规则查找 |
| | | /** |
| | | * 库位规则查找,会预留20个库位 |
| | | */ |
| | | private AgvLocMast getLocByLocRule(AgvWaitPakin agvWaitPakin, int floor) { |
| | | List<AgvLocRule> agvLocRules = null; |
| | | agvLocRules = agvLocRuleService.selectList(new EntityWrapper<AgvLocRule>() |
| | | .eq("matnr", agvWaitPakin.getMatnr()) |
| | | .eq("batch", agvWaitPakin.getModel()) |
| | | .eq("floor", floor)); |
| | | if (Cools.isEmpty(agvLocRules)) { |
| | | agvLocRules = agvLocRuleService.selectList(new EntityWrapper<AgvLocRule>() |
| | | .eq("matnr", agvWaitPakin.getMatnr()) |
| | | .eq("floor", floor)); |
| | | public synchronized AgvLocMast getLocByLocRule20(int type, int floor, String factory, boolean flag) { |
| | | |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | List<AgvLocMast> agvLocMasts = new ArrayList<>(); |
| | | //不是空板优先找2层 |
| | | if (Cools.isEmpty(factory)) { |
| | | wrapper.eq("floor", floor).orderBy("lev1", true); |
| | | } else { |
| | | //B是二厂,G是三厂 |
| | | if (factory.equals("B")) { |
| | | wrapper.eq("floor", floor).orderBy("lev1", false).orderBy("row1", flag); |
| | | |
| | | } else { |
| | | wrapper.eq("floor", floor).orderBy("lev1", true); |
| | | |
| | | } |
| | | } |
| | | int num = 20; |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "LOC_3_NUM")); |
| | | if (config != null && !Cools.isEmpty(config.getValue())) { |
| | | num = Integer.parseInt(config.getValue()); |
| | | } |
| | | agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | int er = 0; |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | if (agvLocMast.getLev1() == 2) { |
| | | er++; |
| | | } |
| | | } |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")) { |
| | | if (agvLocMast1.getLev1() == 2) { |
| | | if (er > num) { |
| | | return agvLocMast1; |
| | | } |
| | | } else { |
| | | return agvLocMast1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | throw new CoolException("搜索库位时,未找到可入库库位。"); |
| | | } catch (Exception e) { |
| | | throw new CoolException("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | if (Cools.isEmpty(agvLocRules)) { |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 库位规则查找 |
| | | */ |
| | | public synchronized AgvLocMast getLocByLocRule(int type, int floor, String factory, boolean flag) { |
| | | |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | List<AgvLocMast> agvLocMasts = new ArrayList<>(); |
| | | //不是空板优先找2层 |
| | | if (Cools.isEmpty(factory)) { |
| | | wrapper.eq("floor", floor).orderBy("lev1", true); |
| | | } else { |
| | | //B是二厂,G是三厂 |
| | | switch (factory) { |
| | | case "B": |
| | | wrapper.eq("floor", floor).orderBy("lev1", false).orderBy("row1", flag); |
| | | break; |
| | | case "G": |
| | | wrapper.eq("floor", floor).orderBy("lev1", true); |
| | | break; |
| | | default: |
| | | wrapper.eq("floor", floor).orderBy("lev1", true); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | 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("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 库位规则查找 |
| | | */ |
| | | public AgvLocMast getLocByLocRule(int type, int floor, int lev1) { |
| | | |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).eq("lev1", lev1).orderBy("bay1", false); |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | 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("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 库位规则查找 |
| | | */ |
| | | public AgvLocMast getLocByLocRule2(int type, int floor, int lev1) { |
| | | |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).eq("lev1", lev1); |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | if (lev1 == 2) { |
| | | int num = 20; |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "LOC_3_NUM")); |
| | | if (config != null && !Cools.isEmpty(config.getValue())) { |
| | | num = Integer.parseInt(config.getValue()); |
| | | } |
| | | int er = agvLocMasts.size(); |
| | | if (er < num) { |
| | | throw new CoolException("搜索库位时,未找到可入库库位。20"); |
| | | } |
| | | } |
| | | 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("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 库位规则查找 |
| | | */ |
| | | public AgvLocMast getLocByFloorAndLev1(int type, int floor, int lev1) { |
| | | |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).eq("lev1", lev1); |
| | | |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")) { |
| | | return agvLocMast1; |
| | | } |
| | | } |
| | | return null; |
| | | } catch (Exception e) { |
| | | throw new CoolException("搜索库位时,未找到可入库库位。"); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 库位规则查找 |
| | | */ |
| | | public AgvLocMast getLocByFloor(int type, int floor) { |
| | | try { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).orderBy("lev1", false); |
| | | |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")) { |
| | | return agvLocMast1; |
| | | } |
| | | } |
| | | return null; |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | |
| | | for (AgvLocRule agvLocRule : agvLocRules) { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.between("row1", agvLocRule.getRowBeg(), agvLocRule.getRowEnd()) |
| | | .between("bay1", agvLocRule.getBayBeg(), agvLocRule.getBayEnd()) |
| | | .between("lev1", agvLocRule.getLevBeg(), agvLocRule.getLevEnd()) |
| | | .eq("floor", floor) |
| | | .eq("loc_sts", "O"); |
| | | AgvLocMast agvLocMast = agvLocMastService.selectOne(wrapper); |
| | | if (!Cools.isEmpty(agvLocMast)) { |
| | | return agvLocMast; |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /* |
| | |
| | | throw new CoolException("搜索库位时,楼层出错。"); |
| | | } |
| | | |
| | | public AgvLocMast getLocNoOnXiSuer(int type, int floor) { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).orderBy("lev1", false); |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | if (Cools.isEmpty(agvLocMasts)) { |
| | | return null; |
| | | } else { |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")) { |
| | | return agvLocMast1; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public AgvLocMast getLocNoOnXiSuer20(int type, int floor) { |
| | | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("loc_sts", "O").eq("loc_type1", type); |
| | | wrapper.eq("floor", floor).eq("lev1", 2); |
| | | List<AgvLocMast> agvLocMasts = agvLocMastService.selectList(wrapper); |
| | | if (Cools.isEmpty(agvLocMasts)) { |
| | | return null; |
| | | } else { |
| | | int num = 15; |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "LOC_6_NUM")); |
| | | if (config != null && !Cools.isEmpty(config.getValue())) { |
| | | num = Integer.parseInt(config.getValue()); |
| | | } |
| | | if (agvLocMasts.size() > num) { |
| | | for (AgvLocMast agvLocMast : agvLocMasts) { |
| | | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); |
| | | if (agvLocMast1.getLocSts().equals("O")) { |
| | | return agvLocMast1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | //随机取一个货位 |
| | | private AgvLocMast getLocNoRule(int type, int floor, boolean isEmpty, boolean isCurrLev) { |
| | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * |
| | | * @return locNo 检索到的库位号 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor) { |
| | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * |
| | | * @return locNo 检索自动接驳位 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor, String auto) { |
| | |
| | | |
| | | /** |
| | | * 检索库位号 |
| | | * |
| | | * @return locNo 检索可入接驳位 |
| | | */ |
| | | public AgvBasDevp getDevpNo(int type, int floor, String auto, String inEable) { |