大屏月台接口查询修改

This commit is contained in:
秦鸿展
2026-09-01 14:09:23 +08:00
parent 8a9bbb3cef
commit 923afda21c
@@ -231,15 +231,18 @@ public class BiPlatformRealDataService {
} }
/** /**
* 实时组装月台监测数据:真实字段查 YMS 库,写死字段保留静态值 * 实时组装月台监测数据:原则「有真实数据源用真实,无真实数据源用写死模拟」
* 有真实数据源的字段(vehicles / platformOverview / vehicleStatus / taskLoad / taskTotal
* 无条件用 YMS 真实查询覆盖,真实为空即为空,不用模板兜底;
* 无真实数据源的字段(效率统计、趋势、告警、任务类型等)保留模板写死值。
* 每次调用实时查库,不经过快照表。 * 每次调用实时查库,不经过快照表。
*/ */
public PlatformSurveillanceVO buildRealTimePlatformSurveillance() { public PlatformSurveillanceVO buildRealTimePlatformSurveillance() {
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖) // 固定种子生成写死模板:仅用于没有真实数据源的字段
Random r = new Random(20260825L); Random r = new Random(20260825L);
PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r); PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r);
// 作业车辆列表 // 作业车辆列表:真实数据源,无条件覆盖(真实为空则返回空列表,不用模板模拟)
List<RealPlatformVehiclePO> realVehicles = queryVehicles(); List<RealPlatformVehiclePO> realVehicles = queryVehicles();
List<PlatformVehicleItemVO> vehicleVos = new ArrayList<>(); List<PlatformVehicleItemVO> vehicleVos = new ArrayList<>();
for (RealPlatformVehiclePO rv : realVehicles) { for (RealPlatformVehiclePO rv : realVehicles) {
@@ -252,52 +255,47 @@ public class BiPlatformRealDataService {
v.setPlatformDuration(rv.getPlatformDuration() == null ? 0 : rv.getPlatformDuration().intValue()); v.setPlatformDuration(rv.getPlatformDuration() == null ? 0 : rv.getPlatformDuration().intValue());
vehicleVos.add(v); vehicleVos.add(v);
} }
if (!vehicleVos.isEmpty()) { template.setVehicles(vehicleVos);
template.setVehicles(vehicleVos);
}
// 月台实时概览 // 月台实时概览:真实数据源,无条件覆盖
RealPlatformOverviewPO ov = queryPlatformOverview();
if (template.getPlatformOverview() != null) { if (template.getPlatformOverview() != null) {
template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue()); RealPlatformOverviewPO ov = queryPlatformOverview();
template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue());
int total = ov.getTotalPlatforms().intValue(); int total = ov.getTotalPlatforms().intValue();
int occ = ov.getOperatingPlatforms().intValue(); int occ = ov.getOperatingPlatforms().intValue();
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d; double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
template.getPlatformOverview().setTotalPlatforms(total);
template.getPlatformOverview().setOperatingPlatforms(occ);
template.getPlatformOverview().setCurrentOccupancyRate(rate); template.getPlatformOverview().setCurrentOccupancyRate(rate);
} template.getPlatformOverview().setTodayTasks((int) countTodayTasks());
long todayTasks = countTodayTasks();
if (template.getPlatformOverview() != null) {
template.getPlatformOverview().setTodayTasks((int) todayTasks);
} }
// 作业车辆状态统计 // 作业车辆状态统计:真实数据源,无条件覆盖
RealVehicleStatusPO vs = queryVehicleStatusToday();
if (template.getVehicleStatus() != null) { if (template.getVehicleStatus() != null) {
RealVehicleStatusPO vs = queryVehicleStatusToday();
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue()); template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue()); template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue()); template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue()); template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
} }
// 本月任务统计 taskTotal // 本月任务统计taskTotal 有真实数据源无条件覆盖;YoY 等无真实数据源保留模板写死值
long monthTasks = countMonthTasks();
if (template.getMonthlyTaskStatistics() != null) { if (template.getMonthlyTaskStatistics() != null) {
template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks); template.getMonthlyTaskStatistics().setTaskTotal((int) countMonthTasks());
} }
// 任务负荷(今日 24 小时) // 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
List<RealTaskLoadPO> loads = queryTaskLoadToday(); List<RealTaskLoadPO> loads = queryTaskLoadToday();
if (!loads.isEmpty() && template.getTaskLoadStatistics() != null) { if (loads.isEmpty()) {
template.setTaskLoadStatistics(new ArrayList<>());
} else if (template.getTaskLoadStatistics() != null) {
Map<Integer, Long> hourMap = new HashMap<>(); Map<Integer, Long> hourMap = new HashMap<>();
for (RealTaskLoadPO l : loads) { for (RealTaskLoadPO l : loads) {
hourMap.put(l.getHourOfDay(), l.getTaskCount()); hourMap.put(l.getHourOfDay(), l.getTaskCount());
} }
for (TaskLoadItemVO item : template.getTaskLoadStatistics()) { for (TaskLoadItemVO item : template.getTaskLoadStatistics()) {
Integer hour = parseHourFromLabel(item.getTime()); Integer hour = parseHourFromLabel(item.getTime());
if (hour != null) { if (hour != null && hourMap.containsKey(hour)) {
Long n = hourMap.get(hour); item.setTaskCount(hourMap.get(hour).intValue());
if (n != null) item.setTaskCount(n.intValue());
} }
} }
} }