| | |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasDualCrnp; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasDualCrnpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnModeType; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.DualCrnProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | import com.zy.core.thread.DualCrnThread; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.text.DecimalFormat; |
| | |
| | | } |
| | | |
| | | //获取入库任务可用排 |
| | | public static List<Integer> getInTaskEnableRow() { |
| | | return getInTaskEnableRow(new ArrayList<>(), true); |
| | | public static List<Integer> getInTaskEnableRow(Integer stationId) { |
| | | return getInTaskEnableRow(stationId, new ArrayList<>(), new ArrayList<>(), true); |
| | | } |
| | | |
| | | //获取入库任务可用排 |
| | | public static List<Integer> getInTaskEnableRow(List<Integer> excludeCrnList, boolean maxInTaskControl) { |
| | | public static List<Integer> getInTaskEnableRow(Integer stationId, List<Integer> excludeCrnList, List<Integer> excludeDualCrnList, boolean maxInTaskControl) { |
| | | //获取堆垛机入库任务可用排 |
| | | List<Integer> rowList = getCrnInTaskEnableRow(stationId, excludeCrnList, maxInTaskControl); |
| | | //获取双工位堆垛机入库任务可用排 |
| | | List<Integer> dualRowList = getDualCrnInTaskEnableRow(stationId, excludeDualCrnList, maxInTaskControl); |
| | | if (!dualRowList.isEmpty()) { |
| | | rowList.addAll(dualRowList); |
| | | } |
| | | return rowList; |
| | | } |
| | | |
| | | //获取堆垛机入库任务可用排 |
| | | public static List<Integer> getCrnInTaskEnableRow(Integer stationId, List<Integer> excludeCrnList, boolean maxInTaskControl) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | try { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class); |
| | | WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | |
| | |
| | | if (excludeCrnList.contains(basCrnp.getCrnNo())) { |
| | | continue; |
| | | } |
| | | enabledCrnps.add(basCrnp); |
| | | |
| | | //计算站点是否可达该堆垛机 |
| | | List<StationObjModel> inStationList = basCrnp.getInStationList$(); |
| | | boolean enableGo = false; |
| | | for (StationObjModel stationObjModel : inStationList) { |
| | | try { |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(stationId, stationObjModel.getStationId()); |
| | | if(navigateNodes != null && !navigateNodes.isEmpty()) { |
| | | enableGo = true; |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | if (enableGo) { |
| | | enabledCrnps.add(basCrnp); |
| | | } |
| | | } |
| | | |
| | | enabledCrnps.sort(Comparator.comparingInt(o -> map.getOrDefault(o.getCrnNo(), 0))); |
| | |
| | | return list; |
| | | } |
| | | |
| | | //获取双工位堆垛机入库任务可用排 |
| | | public static List<Integer> getDualCrnInTaskEnableRow(Integer stationId, List<Integer> excludeCrnList, boolean maxInTaskControl) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | try { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | NavigateUtils navigateUtils = SpringUtils.getBean(NavigateUtils.class); |
| | | WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); |
| | | BasDualCrnpService basDualCrnpService = SpringUtils.getBean(BasDualCrnpService.class); |
| | | |
| | | Wrapper<BasDualCrnp> wrapper = new EntityWrapper<BasDualCrnp>() |
| | | .eq("in_enable", "Y") |
| | | .eq("status", 1); |
| | | |
| | | HashMap<Integer, Integer> map = new HashMap<>(); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<>()); |
| | | List<BasDualCrnp> basDualCrnps = basDualCrnpService.selectList(wrapper); |
| | | |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | Integer dualCrnNo = wrkMast.getDualCrnNo(); |
| | | map.put(dualCrnNo, map.getOrDefault(dualCrnNo, 0) + 1); |
| | | } |
| | | |
| | | List<BasDualCrnp> enabledCrnps = new ArrayList<>(); |
| | | for (BasDualCrnp basDualCrnp : basDualCrnps) { |
| | | DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, basDualCrnp.getCrnNo()); |
| | | if (dualCrnThread == null) { |
| | | continue; |
| | | } |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | if (dualCrnProtocol.getMode() != DualCrnModeType.AUTO.id) { |
| | | continue; |
| | | } |
| | | |
| | | List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("dual_crn_no", basDualCrnp.getCrnNo()) |
| | | .eq("io_type", WrkIoType.IN.id) |
| | | ); |
| | | // 检查是否超过最大入库任务数 |
| | | if (maxInTaskControl && inWrkMasts.size() >= basDualCrnp.getMaxInTask()) { |
| | | News.info("堆垛机:{} 已达最大入库任务数,当前任务数:{}", basDualCrnp.getCrnNo(), inWrkMasts.size()); |
| | | continue; |
| | | } |
| | | if (excludeCrnList.contains(basDualCrnp.getCrnNo())) { |
| | | continue; |
| | | } |
| | | |
| | | //计算站点是否可达该堆垛机 |
| | | List<StationObjModel> inStationList = basDualCrnp.getInStationList$(); |
| | | boolean enableGo = false; |
| | | for (StationObjModel stationObjModel : inStationList) { |
| | | try { |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(stationId, stationObjModel.getStationId()); |
| | | if(navigateNodes != null && !navigateNodes.isEmpty()) { |
| | | enableGo = true; |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | |
| | | if (enableGo) { |
| | | enabledCrnps.add(basDualCrnp); |
| | | } |
| | | } |
| | | |
| | | enabledCrnps.sort(Comparator.comparingInt(o -> map.getOrDefault(o.getCrnNo(), 0))); |
| | | |
| | | for (BasDualCrnp basDualCrnp : enabledCrnps) { |
| | | List<List<Integer>> rowList = basDualCrnp.getControlRows$(); |
| | | for (List<Integer> rows : rowList) { |
| | | list.addAll(rows); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public static Map<String, Object> convertObjectToMap(Object obj) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Class<?> clazz = obj.getClass(); |