| | |
| | | package com.zy.asrs.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | 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.model.protocol.CrnProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | |
| | |
| | | |
| | | //获取入库任务可用排 |
| | | public static List<Integer> getInTaskEnableRow() { |
| | | return getInTaskEnableRow(new ArrayList<>()); |
| | | } |
| | | |
| | | //获取入库任务可用排 |
| | | public static List<Integer> getInTaskEnableRow(List<Integer> excludeCrnList) { |
| | | List<Integer> list = new ArrayList<>(); |
| | | try { |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | |
| | | List<WrkMast> currentCrnTask = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("crn_no", currentCircleTaskCrnNo)); |
| | | if (currentCrnTask.size() <= 1) { |
| | | if (basCrnp != null) { |
| | | String controlRowsStr = basCrnp.getControlRows(); |
| | | if(!Cools.isEmpty(controlRowsStr)){ |
| | | List<Integer> rows = JSON.parseArray(controlRowsStr, Integer.class); |
| | | List<List<Integer>> rowList = basCrnp.getControlRows$(); |
| | | for (List<Integer> rows : rowList) { |
| | | list.addAll(rows); |
| | | wrapper.ne("crn_no", currentCircleTaskCrnNo); |
| | | } |
| | | wrapper.ne("crn_no", currentCircleTaskCrnNo); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (crnProtocol.getMode() != CrnModeType.AUTO.id) { |
| | | continue; |
| | | } |
| | | |
| | | List<WrkMast> inWrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", basCrnp.getCrnNo()) |
| | | .eq("io_type", WrkIoType.IN.id) |
| | | ); |
| | | // 检查是否超过最大入库任务数 |
| | | if(inWrkMasts.size() >= basCrnp.getMaxInTask()){ |
| | | News.info("堆垛机:{} 已达最大入库任务数,当前任务数:{}", basCrnp.getCrnNo(), inWrkMasts.size()); |
| | | continue; |
| | | } |
| | | if (excludeCrnList.contains(basCrnp.getCrnNo())) { |
| | | continue; |
| | | } |
| | | enabledCrnps.add(basCrnp); |
| | | } |
| | | |
| | | enabledCrnps.sort(Comparator.comparingInt(o -> map.getOrDefault(o.getCrnNo(), 0))); |
| | | |
| | | for (BasCrnp basCrnp : enabledCrnps) { |
| | | String controlRowsStr = basCrnp.getControlRows(); |
| | | if (Cools.isEmpty(controlRowsStr)) { |
| | | continue; |
| | | List<List<Integer>> rowList = basCrnp.getControlRows$(); |
| | | for (List<Integer> rows : rowList) { |
| | | list.addAll(rows); |
| | | } |
| | | List<Integer> rows = JSON.parseArray(controlRowsStr, Integer.class); |
| | | list.addAll(rows); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | public static Map<String, Object> convertObjectToMap(Object obj) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | //获取深库位排号 |
| | | public static List<Integer> getDeepRowList() { |
| | | List<Integer> rowList = new ArrayList<>(); |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | if (basCrnpService == null) { |
| | | return rowList; |
| | | } |
| | | |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<BasCrnp>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | String deepRowsStr = basCrnp.getDeepRows(); |
| | | if(!Cools.isEmpty(deepRowsStr)){ |
| | | List<Integer> rows = JSON.parseArray(deepRowsStr, Integer.class); |
| | | rowList.addAll(rows); |
| | | } |
| | | } |
| | | return rowList; |
| | | } |
| | | |
| | | //获取浅库位排号 |
| | | public static Integer getShallowRowByDeepRow(Integer deepRow) { |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | if (basCrnpService == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<Integer> deepRowList = getDeepRowList(); |
| | | if (!deepRowList.contains(deepRow)) { |
| | | return null; |
| | | } |
| | | |
| | | List<Integer> controlRowList = null; |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | List<List<Integer>> rowList = basCrnp.getControlRows$(); |
| | | for (List<Integer> rows : rowList) { |
| | | if (rows.contains(deepRow)) { |
| | | controlRowList = rows; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (controlRowList != null) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | for (Integer row : controlRowList) { |
| | | if (deepRow.equals(row)) { |
| | | continue; |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //获取深库位排号 |
| | | public static Integer getDeepRowByShallowRow(Integer shallowRow) { |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | if (basCrnpService == null) { |
| | | return null; |
| | | } |
| | | |
| | | List<Integer> controlRowList = null; |
| | | List<Integer> deepRowList = null; |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | List<List<Integer>> rowList = basCrnp.getControlRows$(); |
| | | for (List<Integer> rows : rowList) { |
| | | if (rows.contains(shallowRow)) { |
| | | controlRowList = rows; |
| | | deepRowList = JSON.parseArray(basCrnp.getDeepRows(), Integer.class); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (controlRowList != null) { |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (deepRowList == null) { |
| | | return null; |
| | | } |
| | | |
| | | for (Integer row : controlRowList) { |
| | | if (!deepRowList.contains(row)) { |
| | | continue; |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | return null; |
| | | } |
| | | } |