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