| New file | 
|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.constant; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class AsrsConstants { | 
|---|
|  |  |  | //B是二厂,G是三厂 | 
|---|
|  |  |  | public static final String ERCHANG = "B"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String SANCHANG = "G"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.param.*; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.service.impl.OrderServiceImpl; | 
|---|
|  |  |  | import com.zy.asrs.utils.OrderUtils; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import lombok.Synchronized; | 
|---|
|  |  |  | import org.slf4j.Logger; | 
|---|
|  |  |  | 
|---|
|  |  |  | params.getCombParams().forEach(combParam -> { | 
|---|
|  |  |  | agvMobileService.comb(combParam, getUserId()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //获取判断时哪个厂的订单 | 
|---|
|  |  |  | String csocode = params.getCombParams().get(0).getCombMats().get(0).getCsocode(); | 
|---|
|  |  |  | String factory = OrderUtils.getFactory(csocode); | 
|---|
|  |  |  | params.setContainerType(Short.valueOf(params.getContainerCode().substring(0, 2))); | 
|---|
|  |  |  | workService.emptyPlateIn(params.getDevNo(), params.getContainerCode(), params.getContainerType(), getUserId(), false); | 
|---|
|  |  |  | workService.emptyPlateIn(params.getDevNo(), params.getContainerCode(), params.getContainerType(), getUserId(), false,factory); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok("生成工作档成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (AgvMobileStartParam.Pda pda : params.getPad()) { | 
|---|
|  |  |  | pda.setContainerType(Short.valueOf(pda.getContainerCode().substring(0, 2))); | 
|---|
|  |  |  | workService.emptyPlateIn(pda.getDevNo(), pda.getContainerCode(), pda.getContainerType(), getUserId(), false); | 
|---|
|  |  |  | workService.emptyPlateIn(pda.getDevNo(), pda.getContainerCode(), pda.getContainerType(), getUserId(), false,null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 空板入库 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | String emptyPlateIn(String station,String containerCode,Short containerType, Long userId, boolean emptyAutoIn); | 
|---|
|  |  |  | String emptyPlateIn(String station,String containerCode,Short containerType, Long userId, boolean emptyAutoIn, String factory ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | void emptyPlateOut(String station, int containerType, Long userId); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | 入库 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public String emptyPlateIn(String station, String containerCode, Short containerType, Long userId, boolean emptyAutoIn) { | 
|---|
|  |  |  | public String emptyPlateIn(String station, String containerCode, Short containerType, Long userId, boolean emptyAutoIn,String factory) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "elevatorTasks")); | 
|---|
|  |  |  | if (Cools.isEmpty(config)) { | 
|---|
|  |  |  | if (isCurrLev.get()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true,factory); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false); | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false,factory); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | List<AgvWrkMast> agvWrkMasts = agvWrkMastService.selectList(new EntityWrapper<AgvWrkMast>().like("loc_no", "02F1").like("source_loc_no", "F1")); | 
|---|
|  |  |  | if (Integer.parseInt(config.getValue()) <= agvWrkMasts.size()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true,factory); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (isCurrLev.get()) { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true); | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, true,factory); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false); | 
|---|
|  |  |  | agvLocMast = agvCommonService.getLocNo(locType, agvBasDevp.getFloor(), false, false,factory); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //agvLocMast = agvCommonService.getLocNo(locType,agvBasDevp.getFloor(),false,false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | private static final List<Integer> MOVE_TYPE_List = new ArrayList<Integer>() {{ | 
|---|
|  |  |  | add(11); | 
|---|
|  |  |  | add(12); | 
|---|
|  |  |  | //add(53); | 
|---|
|  |  |  | add(53); | 
|---|
|  |  |  | add(101); | 
|---|
|  |  |  | add(103); | 
|---|
|  |  |  | add(108); | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.utils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.constant.AsrsConstants; | 
|---|
|  |  |  | import com.zy.asrs.entity.AgvLocMast; | 
|---|
|  |  |  | import com.zy.asrs.service.AgvLocMastService; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class LocUtils { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private AgvLocMastService agvLocMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询库位 | 
|---|
|  |  |  | * @param type | 
|---|
|  |  |  | * @param factory | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public   AgvLocMast getLocNoRuleByFactory(int type, String factory) { | 
|---|
|  |  |  | if (Cools.isEmpty(factory)) { | 
|---|
|  |  |  | throw new CoolException("搜索库位时,订单类型错误"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("loc_sts", "O").eq("loc_type1", type); | 
|---|
|  |  |  | List<AgvLocMast> agvLocMasts = new ArrayList<>(); | 
|---|
|  |  |  | if (factory.equalsIgnoreCase(AsrsConstants.ERCHANG)) { | 
|---|
|  |  |  | wrapper.orderBy("lev1", false); | 
|---|
|  |  |  | } else if (factory.equalsIgnoreCase(AsrsConstants.SANCHANG)) { | 
|---|
|  |  |  | wrapper.orderBy("lev1", true); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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("搜索库位时,未找到可入库库位。"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询库位 | 
|---|
|  |  |  | * @param type | 
|---|
|  |  |  | * @param floor | 
|---|
|  |  |  | * @return | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public AgvLocMast getLocNoRuleByFloor(int type, Integer floor, Integer lev1) { | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | EntityWrapper<AgvLocMast> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | wrapper.eq("loc_sts", "O").eq("loc_type1", type).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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | throw new CoolException("搜索库位时,未找到可入库库位。"); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | throw new CoolException("搜索库位时,未找到可入库库位。"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
| New file | 
|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.utils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.zy.asrs.constant.AsrsConstants; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public class OrderUtils { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 判断时哪个厂的订单 | 
|---|
|  |  |  | * 订单编号里有B是二厂,G是三厂 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static String getFactory(String threeCode) { | 
|---|
|  |  |  | if (Cools.isEmpty(threeCode)) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (threeCode.contains(AsrsConstants.ERCHANG)) { | 
|---|
|  |  |  | return AsrsConstants.ERCHANG; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return AsrsConstants.SANCHANG; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.utils.LocUtils; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.stereotype.Service; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | AgvBasDevpService agvBasDevpService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocUtils locUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int getWorkNo(Integer wrkMk) { | 
|---|
|  |  |  | AgvWrkLastno wrkLastno = agvWrkLastnoService.selectById(wrkMk); | 
|---|
|  |  |  | if (Cools.isEmpty(wrkLastno)) { | 
|---|
|  |  |  | 
|---|
|  |  |  | int sNo = wrkLastno.getSNo(); | 
|---|
|  |  |  | int eNo = wrkLastno.getENo(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | workNo = workNo>=eNo ? sNo : workNo+1; | 
|---|
|  |  |  | workNo = workNo >= eNo ? sNo : workNo + 1; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | while (true) { | 
|---|
|  |  |  | AgvWrkMast wrkMast = agvWrkMastService.selectById(workNo); | 
|---|
|  |  |  | if (null != wrkMast) { | 
|---|
|  |  |  | workNo = workNo>=eNo ? sNo : workNo+1; | 
|---|
|  |  |  | workNo = workNo >= eNo ? sNo : workNo + 1; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (workNo > 0){ | 
|---|
|  |  |  | if (workNo > 0) { | 
|---|
|  |  |  | wrkLastno.setWrkNo(workNo); | 
|---|
|  |  |  | agvWrkLastnoService.updateById(wrkLastno); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (workNo == 0) { | 
|---|
|  |  |  | throw new CoolException("生成工作号失败,请联系管理员"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (agvWrkMastService.selectById(workNo)!=null) { | 
|---|
|  |  |  | if (agvWrkMastService.selectById(workNo) != null) { | 
|---|
|  |  |  | throw new CoolException("生成工作号" + workNo + "在工作档中已存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | * 检索库位号 | 
|---|
|  |  |  | * @return locNo 检索到的库位号 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public AgvLocMast getLocNo(int type, int floor,boolean isEmpty,boolean isCurrLev) { | 
|---|
|  |  |  | public AgvLocMast getLocNo(int type, int floor, boolean isEmpty, boolean isCurrLev, String factory) { | 
|---|
|  |  |  | // 目标库位 | 
|---|
|  |  |  | AgvLocMast locMast = null; | 
|---|
|  |  |  | //        if(Cools.isEmpty(agvWaitPakinList)){ | 
|---|
|  |  |  | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | // 开始查找库位 ==============================>> | 
|---|
|  |  |  | //如果是半成品箱壳 | 
|---|
|  |  |  | if (type == 6) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | // 四期项目:需要改查找库位逻辑 | 
|---|
|  |  |  | // 箱壳入库 | 
|---|
|  |  |  | if (type == 3) { | 
|---|
|  |  |  | //优先入库吸塑1楼,在2楼 | 
|---|
|  |  |  | locMast = locUtils.getLocNoRuleByFactory(type, factory); | 
|---|
|  |  |  | } else if (type == 6) { | 
|---|
|  |  |  | //半成品箱壳入库,入到吸塑2楼的370个库位里 | 
|---|
|  |  |  | locMast = locUtils.getLocNoRuleByFloor(type, floor, 2); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | //不动这个逻辑 | 
|---|
|  |  |  | locMast = getLocNoRule(type,floor,isEmpty,isCurrLev); | 
|---|
|  |  |  | locMast = getLocNoRule(type, floor, isEmpty, isCurrLev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (locMast != null) { | 
|---|
|  |  |  | return locMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | throw new CoolException(floor+"楼;该楼层没有空库位===>"+e.getMessage()); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | throw new CoolException(floor + "楼;该楼层没有空库位===>" + e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //找不到库位,抛出异常 | 
|---|
|  |  |  | throw new CoolException(floor+"楼;该楼层没有空库位"); | 
|---|
|  |  |  | throw new CoolException(floor + "楼;该楼层没有空库位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq("matnr", agvWaitPakin.getMatnr()) | 
|---|
|  |  |  | .eq("batch", agvWaitPakin.getModel()) | 
|---|
|  |  |  | .eq("floor", floor)); | 
|---|
|  |  |  | if(Cools.isEmpty(agvLocRules)){ | 
|---|
|  |  |  | if (Cools.isEmpty(agvLocRules)) { | 
|---|
|  |  |  | agvLocRules = agvLocRuleService.selectList(new EntityWrapper<AgvLocRule>() | 
|---|
|  |  |  | .eq("matnr", agvWaitPakin.getMatnr()) | 
|---|
|  |  |  | .eq("floor", floor)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(Cools.isEmpty(agvLocRules)){ | 
|---|
|  |  |  | if (Cools.isEmpty(agvLocRules)) { | 
|---|
|  |  |  | 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"); | 
|---|
|  |  |  | 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)){ | 
|---|
|  |  |  | if (!Cools.isEmpty(agvLocMast)) { | 
|---|
|  |  |  | return agvLocMast; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 靠近摆放规则 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private AgvLocMast getLocByProximityRule(){ | 
|---|
|  |  |  | private AgvLocMast getLocByProximityRule() { | 
|---|
|  |  |  | //to do | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 根据物料频率查找 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | private AgvLocMast getLocByFre(int fre, int floor){ | 
|---|
|  |  |  | if(floor == 1){ | 
|---|
|  |  |  | if(fre == 1){ | 
|---|
|  |  |  | private AgvLocMast getLocByFre(int fre, int floor) { | 
|---|
|  |  |  | if (floor == 1) { | 
|---|
|  |  |  | if (fre == 1) { | 
|---|
|  |  |  | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() | 
|---|
|  |  |  | .eq("floor",floor) | 
|---|
|  |  |  | .eq("loc_sts","O") | 
|---|
|  |  |  | .orderBy("bay1",false)); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("bay1", false)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() | 
|---|
|  |  |  | .eq("floor",floor) | 
|---|
|  |  |  | .eq("loc_sts","O") | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("bay1")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(floor == 3){ | 
|---|
|  |  |  | if(fre == 1){ | 
|---|
|  |  |  | if (floor == 3) { | 
|---|
|  |  |  | if (fre == 1) { | 
|---|
|  |  |  | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() | 
|---|
|  |  |  | .eq("floor",floor) | 
|---|
|  |  |  | .eq("loc_sts","O") | 
|---|
|  |  |  | .orderBy("row1",false)); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("row1", false)); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>() | 
|---|
|  |  |  | .eq("floor",floor) | 
|---|
|  |  |  | .eq("loc_sts","O") | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .orderBy("row1")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | throw new CoolException("搜索库位时,楼层出错。"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //随机取一个货位 | 
|---|
|  |  |  | private AgvLocMast getLocNoRule(int type,int floor,boolean isEmpty,boolean isCurrLev){ | 
|---|
|  |  |  | 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 ) { | 
|---|
|  |  |  | if (floor >= 4) { | 
|---|
|  |  |  | floor = 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderBy = true; | 
|---|
|  |  |  | 
|---|
|  |  |  | orderBy = false; | 
|---|
|  |  |  | levCount = 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | wrapper.eq("floor", floor).eq("lev1", 1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | if (isCurrLev) { | 
|---|
|  |  |  | wrapper.eq("floor", floor).eq("lev1",1); | 
|---|
|  |  |  | wrapper.eq("floor", floor).eq("lev1", 1); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | wrapper.eq("floor", floor).orderBy("lev1",!orderBy); | 
|---|
|  |  |  | wrapper.eq("floor", floor).orderBy("lev1", !orderBy); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //当目标库位是1楼 | 
|---|
|  |  |  | if(floor == 1) { | 
|---|
|  |  |  | wrapper.orderBy("loc_no",false); | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | return getLocNoRule(type, floor, isEmpty, isCurrLev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (AgvLocMast agvLocMast : agvLocMasts){ | 
|---|
|  |  |  | for (AgvLocMast agvLocMast : agvLocMasts) { | 
|---|
|  |  |  | AgvLocMast agvLocMast1 = agvLocMastService.selectOne(new EntityWrapper<AgvLocMast>().eq("loc_no", agvLocMast.getLocNo())); | 
|---|
|  |  |  | if (agvLocMast1.getLocSts().equals("O")){ | 
|---|
|  |  |  | if (agvLocMast1.getLocSts().equals("O")) { | 
|---|
|  |  |  | return agvLocMast1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | throw new CoolException("搜索库位时,未找到可入库库位。"); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | throw new CoolException("搜索库位时,未找到可入库库位。"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检索库位号 | 
|---|
|  |  |  | * @return locNo 检索到的库位号 | 
|---|
|  |  |  | 
|---|
|  |  |  | AgvBasDevp basDevp = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 开始查找库位 ==============================>> | 
|---|
|  |  |  | basDevp = getDevpNoRule(type,floor); | 
|---|
|  |  |  | basDevp = getDevpNoRule(type, floor); | 
|---|
|  |  |  | if (basDevp != null) { | 
|---|
|  |  |  | return basDevp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //找不到库位,抛出异常 | 
|---|
|  |  |  | throw new CoolException("楼层号:"+floor+";该楼层没有空接驳位"); | 
|---|
|  |  |  | throw new CoolException("楼层号:" + floor + ";该楼层没有空接驳位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | AgvBasDevp basDevp = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 开始查找库位 ==============================>> | 
|---|
|  |  |  | basDevp = getDevpNoAuto(type,floor,auto); | 
|---|
|  |  |  | basDevp = getDevpNoAuto(type, floor, auto); | 
|---|
|  |  |  | if (basDevp != null) { | 
|---|
|  |  |  | return basDevp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //找不到库位,抛出异常 | 
|---|
|  |  |  | throw new CoolException("楼层号:"+floor+";该楼层没有空接驳位"); | 
|---|
|  |  |  | throw new CoolException("楼层号:" + floor + ";该楼层没有空接驳位"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 检索库位号 | 
|---|
|  |  |  | * @return locNo 检索可入接驳位 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public AgvBasDevp getDevpNo(int type, int floor, String auto ,String inEable) { | 
|---|
|  |  |  | public AgvBasDevp getDevpNo(int type, int floor, String auto, String inEable) { | 
|---|
|  |  |  | // 目标库位 | 
|---|
|  |  |  | AgvBasDevp basDevp = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 开始查找库位 ==============================>> | 
|---|
|  |  |  | basDevp = getDevpNoInEable(type,floor,inEable); | 
|---|
|  |  |  | basDevp = getDevpNoInEable(type, floor, inEable); | 
|---|
|  |  |  | if (basDevp != null) { | 
|---|
|  |  |  | return basDevp; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //随机取一个货位 | 
|---|
|  |  |  | private AgvBasDevp getDevpNoRule(int type,int floor){ | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_type1", type) | 
|---|
|  |  |  | .like("dev_no", "DB")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //随机取一个货位 | 
|---|
|  |  |  | private AgvBasDevp getDevpNoAuto(int type,int floor,String auto){ | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | .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){ | 
|---|
|  |  |  | 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")); | 
|---|
|  |  |  | .eq("loc_sts", "O") | 
|---|
|  |  |  | .eq("floor", floor) | 
|---|
|  |  |  | .eq("loc_type1", type) | 
|---|
|  |  |  | .eq("in_enable", inEable) | 
|---|
|  |  |  | .like("dev_no", "DB")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|