| | |
| | | import com.zy.asrs.entity.BasDualCrnp; |
| | | import com.zy.asrs.entity.BasStation; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.entity.StationFlowCapacity; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasDualCrnpService; |
| | | import com.zy.asrs.service.BasStationService; |
| | | import com.zy.asrs.service.DeviceConfigService; |
| | | import com.zy.asrs.service.StationCycleCapacityService; |
| | | import com.zy.asrs.service.StationFlowCapacityService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.LinkedHashSet; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | @Service("autoTuneSnapshotService") |
| | | public class AutoTuneSnapshotServiceImpl implements AutoTuneSnapshotService { |
| | |
| | | private static final int DEFAULT_CRN_OUT_BATCH_RUNNING_LIMIT = 5; |
| | | private static final int DEFAULT_CONVEYOR_STATION_TASK_LIMIT = 30; |
| | | private static final int DEFAULT_AI_AUTO_TUNE_INTERVAL_MINUTES = 10; |
| | | private static final String DIRECTION_OUT = "OUT"; |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | |
| | | |
| | | @Autowired |
| | | private BasStationService basStationService; |
| | | |
| | | @Autowired |
| | | private StationFlowCapacityService stationFlowCapacityService; |
| | | |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | |
| | | if (basStationService == null) { |
| | | return result; |
| | | } |
| | | Set<Integer> outStationIds = loadOutStationIds(); |
| | | if (outStationIds.isEmpty()) { |
| | | return result; |
| | | } |
| | | QueryWrapper<BasStation> wrapper = new QueryWrapper<>(); |
| | | wrapper.in("station_id", outStationIds); |
| | | wrapper.orderByAsc("station_id"); |
| | | return buildStationOutTaskLimitMap(basStationService.list(wrapper)); |
| | | } |
| | | |
| | | private Set<Integer> loadOutStationIds() { |
| | | LinkedHashSet<Integer> stationIds = new LinkedHashSet<>(); |
| | | if (stationFlowCapacityService == null) { |
| | | return stationIds; |
| | | } |
| | | QueryWrapper<StationFlowCapacity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("direction_code", DIRECTION_OUT); |
| | | wrapper.orderByAsc("station_id"); |
| | | List<StationFlowCapacity> capacityList = safeList(stationFlowCapacityService.list(wrapper)); |
| | | for (StationFlowCapacity capacity : capacityList) { |
| | | if (capacity != null && capacity.getStationId() != null) { |
| | | stationIds.add(capacity.getStationId()); |
| | | } |
| | | } |
| | | return stationIds; |
| | | } |
| | | |
| | | Map<String, Integer> buildStationOutTaskLimitMap(List<BasStation> stationList) { |
| | | Map<String, Integer> result = new LinkedHashMap<>(); |
| | | for (BasStation station : safeList(stationList)) { |