| | |
| | | |
| | | private StationCycleCapacityVo buildSnapshot() { |
| | | GraphContext context = buildStationGraph(); |
| | | Map<Integer, Integer> workNoMap = buildStationWorkNoMap(); |
| | | StationOccupancyContext occupancyContext = buildStationOccupancyContext(); |
| | | Map<Integer, Integer> workNoMap = occupancyContext.workNoMap; |
| | | Set<Integer> manualStationSet = occupancyContext.manualStationSet; |
| | | |
| | | Set<Integer> availableStationSet = new HashSet<>(context.graph.keySet()); |
| | | availableStationSet.removeAll(context.excludeStationSet); |
| | |
| | | int loopNo = 1; |
| | | int totalStationCount = 0; |
| | | int taskStationCount = 0; |
| | | int manualStationCount = 0; |
| | | int occupiedStationCount = 0; |
| | | Set<Integer> actualWorkNoSet = new HashSet<>(); |
| | | |
| | | for (Set<Integer> scc : sccList) { |
| | |
| | | |
| | | List<Integer> workNoList = new ArrayList<>(); |
| | | int currentLoopTaskCount = 0; |
| | | int currentLoopManualStationCount = 0; |
| | | for (Integer stationId : stationIdList) { |
| | | Integer workNo = workNoMap.get(stationId); |
| | | if (workNo != null && workNo > 0) { |
| | | workNoList.add(workNo); |
| | | currentLoopTaskCount++; |
| | | actualWorkNoSet.add(workNo); |
| | | continue; |
| | | } |
| | | if (manualStationSet.contains(stationId)) { |
| | | currentLoopManualStationCount++; |
| | | } |
| | | } |
| | | |
| | |
| | | loopVo.setWorkNoList(workNoList); |
| | | loopVo.setStationCount(stationIdList.size()); |
| | | loopVo.setTaskCount(currentLoopTaskCount); |
| | | loopVo.setCurrentLoad(calcCurrentLoad(currentLoopTaskCount, stationIdList.size())); |
| | | loopVo.setManualStationCount(currentLoopManualStationCount); |
| | | loopVo.setOccupiedStationCount(currentLoopTaskCount + currentLoopManualStationCount); |
| | | loopVo.setCurrentLoad(calcCurrentLoad(toNonNegative(loopVo.getOccupiedStationCount()), stationIdList.size())); |
| | | loopList.add(loopVo); |
| | | |
| | | totalStationCount += stationIdList.size(); |
| | | taskStationCount += currentLoopTaskCount; |
| | | manualStationCount += currentLoopManualStationCount; |
| | | occupiedStationCount += toNonNegative(loopVo.getOccupiedStationCount()); |
| | | } |
| | | } |
| | | |
| | | int reserveTaskCount = mergeReserveTaskCount(loopList, actualWorkNoSet); |
| | | taskStationCount += reserveTaskCount; |
| | | occupiedStationCount += reserveTaskCount; |
| | | |
| | | StationCycleCapacityVo vo = new StationCycleCapacityVo(); |
| | | vo.setLoopList(loopList); |
| | | vo.setLoopCount(loopList.size()); |
| | | vo.setTotalStationCount(totalStationCount); |
| | | vo.setTaskStationCount(taskStationCount); |
| | | vo.setCurrentLoad(calcCurrentLoad(taskStationCount, totalStationCount)); |
| | | vo.setManualStationCount(manualStationCount); |
| | | vo.setOccupiedStationCount(occupiedStationCount); |
| | | vo.setCurrentLoad(calcCurrentLoad(occupiedStationCount, totalStationCount)); |
| | | vo.setRefreshTime(new Date()); |
| | | return vo; |
| | | } |
| | |
| | | Collections.sort(workNoList); |
| | | |
| | | int mergedTaskCount = toNonNegative(loopVo.getTaskCount()) + 1; |
| | | int mergedOccupiedCount = toNonNegative(loopVo.getOccupiedStationCount()) + 1; |
| | | loopVo.setTaskCount(mergedTaskCount); |
| | | loopVo.setCurrentLoad(calcCurrentLoad(mergedTaskCount, toNonNegative(loopVo.getStationCount()))); |
| | | loopVo.setOccupiedStationCount(mergedOccupiedCount); |
| | | loopVo.setCurrentLoad(calcCurrentLoad(mergedOccupiedCount, toNonNegative(loopVo.getStationCount()))); |
| | | mergedCount++; |
| | | } |
| | | |
| | |
| | | || (isBarcodeStation != null && isBarcodeStation == 1); |
| | | } |
| | | |
| | | private Map<Integer, Integer> buildStationWorkNoMap() { |
| | | Map<Integer, Integer> workNoMap = new HashMap<>(); |
| | | private StationOccupancyContext buildStationOccupancyContext() { |
| | | StationOccupancyContext context = new StationOccupancyContext(); |
| | | List<DeviceConfig> devpList = deviceConfigService.list(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Devp))); |
| | | if (devpList == null || devpList.isEmpty()) { |
| | | return workNoMap; |
| | | return context; |
| | | } |
| | | |
| | | for (DeviceConfig deviceConfig : devpList) { |
| | |
| | | } |
| | | Integer taskNo = protocol.getTaskNo(); |
| | | if (taskNo != null && taskNo > 0) { |
| | | workNoMap.put(protocol.getStationId(), taskNo); |
| | | context.workNoMap.put(protocol.getStationId(), taskNo); |
| | | continue; |
| | | } |
| | | if (!protocol.isAutoing()) { |
| | | context.manualStationSet.add(protocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | | return workNoMap; |
| | | return context; |
| | | } |
| | | |
| | | private List<Set<Integer>> findStrongConnectedComponents(Map<Integer, Set<Integer>> graph) { |
| | |
| | | private final Map<Integer, Set<Integer>> graph = new HashMap<>(); |
| | | private final Set<Integer> excludeStationSet = new HashSet<>(); |
| | | } |
| | | |
| | | private static class StationOccupancyContext { |
| | | private final Map<Integer, Integer> workNoMap = new HashMap<>(); |
| | | private final Set<Integer> manualStationSet = new HashSet<>(); |
| | | } |
| | | } |