From 2b6777abe41fb1d03533307e141e4f6924445d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Wed, 9 Sep 2026 13:47:46 +0800 Subject: [PATCH] =?UTF-8?q?BI=E6=A8=A1=E5=9D=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/BiPlatformRealDataMapper.java | 11 +- .../repository/po/RealBusinessTypeStatPO.java | 8 +- .../po/RealMonthlyTaskDurationPO.java | 29 ++++ .../repository/po/RealOnTimeStatPO.java | 20 +++ .../repository/po/RealTaskTypeStatPO.java | 20 +++ .../repository/po/RealVehicleStatusPO.java | 3 + .../service/BiPlatformRealDataService.java | 156 +++++++++++++++++- .../BiReportSnapshotMapperSupport.java | 2 +- .../service/BiReportSnapshotSyncService.java | 57 +++++-- .../BiSnapshotWeeklyRandomDataBuilder.java | 1 + .../facadeApi/biReport/BiReportApi.java | 4 +- .../biReport/vo/platform/VehicleStatusVO.java | 3 + .../BiPlatformRealDataMapper.xml | 80 +++++++-- 13 files changed, 355 insertions(+), 39 deletions(-) create mode 100644 mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealMonthlyTaskDurationPO.java create mode 100644 mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealOnTimeStatPO.java create mode 100644 mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskTypeStatPO.java diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/mapper/BiPlatformRealDataMapper.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/mapper/BiPlatformRealDataMapper.java index 3a4c041e8..d665e4726 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/mapper/BiPlatformRealDataMapper.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/mapper/BiPlatformRealDataMapper.java @@ -7,6 +7,9 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO; import java.util.List; @@ -35,9 +38,15 @@ public interface BiPlatformRealDataMapper { /** 任务负荷(今日 24 小时) */ List queryTaskLoadToday(); - /** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */ + /** 今日预约-租户统计(按 tenantName 分组统计今日预约数量) */ List queryTodayBusinessTypeStats(); + /** 今日作业准时率统计(total 今日预约总数;onTimeCount 今日准时车辆数) */ + RealOnTimeStatPO queryTodayOnTimeStats(); + + /** 任务类型统计(当月 OMS 运输订单按业务类型分组:1-跨境 2-国内) */ + List queryMonthTransportOrderByType(); + /** 月台监控-按楼层统计月台车辆(楼层、月台数量、今日预约车辆、当前作业车辆) */ List queryPlatformFloorStats(); diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealBusinessTypeStatPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealBusinessTypeStatPO.java index d9df6ab91..7e4dfb70d 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealBusinessTypeStatPO.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealBusinessTypeStatPO.java @@ -5,15 +5,15 @@ import lombok.Data; import java.io.Serializable; /** - * 今日预约-业务类型统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) - * 按业务类型分组统计今日预约数量 + * 今日预约-租户统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) + * 按租户名称分组统计今日预约数量 */ @Data public class RealBusinessTypeStatPO implements Serializable { private static final long serialVersionUID = 1L; - /** 业务类型名称(qms_main_business.businessName) */ - private String businessName; + /** 租户名称(qms_main_business.tenantName) */ + private String tenantName; /** 今日预约数量 */ private Long count; diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealMonthlyTaskDurationPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealMonthlyTaskDurationPO.java new file mode 100644 index 000000000..9f815b7ba --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealMonthlyTaskDurationPO.java @@ -0,0 +1,29 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) + * avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与) + * durationCount:参与平均时长统计的有效条数 + * completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量 + * totalCount:本月(TARGET_DATE)预约总数量 + */ +@Data +public class RealMonthlyTaskDurationPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 平均作业时长(小时) */ + private Double avgDurationHours; + + /** 参与平均时长统计的有效条数 */ + private Long durationCount; + + /** 本月已出场数量 */ + private Long completedCount; + + /** 本月预约总数量(按 TARGET_DATE 统计) */ + private Long totalCount; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealOnTimeStatPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealOnTimeStatPO.java new file mode 100644 index 000000000..0178405a7 --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealOnTimeStatPO.java @@ -0,0 +1,20 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 今日作业准时率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS) + * 准时率 = 今日实际进场时间在预约日期当天的车辆数 / 今日预约总车辆数 × 100% + */ +@Data +public class RealOnTimeStatPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 今日预约总车辆数 */ + private Long total; + + /** 今日准时车辆数(已进场且实际进场日期 = 预约日期) */ + private Long onTimeCount; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskTypeStatPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskTypeStatPO.java new file mode 100644 index 000000000..5f0a29c3c --- /dev/null +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealTaskTypeStatPO.java @@ -0,0 +1,20 @@ +package com.mhd.bi.domain.biPlatformRealData.repository.po; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 任务类型统计(真实数据,来自 NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER 运输订单) + * 按业务类型 businessCategory 分组统计当月数量:1-跨境运输 2-国内运输 + */ +@Data +public class RealTaskTypeStatPO implements Serializable { + private static final long serialVersionUID = 1L; + + /** 业务类型:1-跨境 2-国内 */ + private Integer businessCategory; + + /** 该类型当月单量 */ + private Long count; +} \ No newline at end of file diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java index 7f2f782a7..2cc77c420 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java @@ -16,6 +16,9 @@ public class RealVehicleStatusPO implements Serializable { /** 当前未签到 */ private Long notCheckedIn; + /** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */ + private Long waiting; + /** 当前作业中 */ private Long operatingVehicles; diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java index 703c71e2a..2b4c65556 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/service/BiPlatformRealDataService.java @@ -9,12 +9,17 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO; import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper; import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper; import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -91,16 +96,23 @@ public class BiPlatformRealDataService { if (vo.getPlatformOverview() != null) { fp.put("totalPlatforms", vo.getPlatformOverview().getTotalPlatforms()); fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms()); + fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate()); fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks()); } + if (vo.getEfficiencyStatistics() != null) { + fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate()); + } if (vo.getVehicleStatus() != null) { fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles()); fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn()); + fp.put("waiting", vo.getVehicleStatus().getWaiting()); fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles()); fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles()); } if (vo.getMonthlyTaskStatistics() != null) { fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal()); + fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration()); + fp.put("taskCompletionRate", vo.getMonthlyTaskStatistics().getTaskCompletionRate()); } if (vo.getVehicles() != null) { List> vehicles = new ArrayList<>(); @@ -126,6 +138,21 @@ public class BiPlatformRealDataService { } fp.put("taskLoadStatistics", loads); } + if (vo.getTaskTypeStatistics() != null) { + Map m = new LinkedHashMap<>(); + m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks()); + if (vo.getTaskTypeStatistics().getTaskTypes() != null) { + List> types = new ArrayList<>(); + for (TaskTypeCountItemVO it : vo.getTaskTypeStatistics().getTaskTypes()) { + Map tm = new LinkedHashMap<>(); + tm.put("type", it.getType()); + tm.put("count", it.getCount()); + types.add(tm); + } + m.put("taskTypes", types); + } + fp.put("taskTypeStatistics", m); + } return objectMapper.writeValueAsString(fp); } @@ -166,12 +193,34 @@ public class BiPlatformRealDataService { } } + /** + * 今日作业准时率 = 准时车辆数 / 今日预约车辆总数 × 100% + * 准时:今日(TARGET_DATE=今天)已进场且实际进场时间不超过该预约的预约结束时间 bookingEndTime; + * 实际进场时间超过 bookingEndTime 视为不准时。 + * 今日预约总数为 0 时返回 0。 + */ + public int calcTodayOnTimeRate() { + try { + RealOnTimeStatPO po = biPlatformRealDataMapper.queryTodayOnTimeStats(); + if (po == null) return 0; + long total = po.getTotal() == null ? 0L : po.getTotal(); + long onTime = po.getOnTimeCount() == null ? 0L : po.getOnTimeCount(); + if (total <= 0) return 0; + // 四舍五入到整数百分比 + return (int) Math.round(((double) onTime / (double) total) * 100.0); + } catch (Exception e) { + log.error("【YMS】计算今日作业准时率失败: {}", e.getMessage(), e); + return 0; + } + } + public RealVehicleStatusPO queryVehicleStatusToday() { try { RealVehicleStatusPO po = biPlatformRealDataMapper.queryVehicleStatusToday(); if (po == null) po = new RealVehicleStatusPO(); if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L); if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L); + if (po.getWaiting() == null) po.setWaiting(0L); if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L); if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L); return po; @@ -180,6 +229,7 @@ public class BiPlatformRealDataService { RealVehicleStatusPO po = new RealVehicleStatusPO(); po.setTodayReservedVehicles(0L); po.setNotCheckedIn(0L); + po.setWaiting(0L); po.setOperatingVehicles(0L); po.setCompletedVehicles(0L); return po; @@ -196,6 +246,21 @@ public class BiPlatformRealDataService { } } + /** + * 本月任务平均时长 / 完成率统计: + * - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与 + * - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100 + * 任一查询失败均返回 null,由调用方决定是否覆盖模板值。 + */ + public RealMonthlyTaskDurationPO queryMonthTaskStats() { + try { + return biPlatformRealDataMapper.queryMonthTaskStats(); + } catch (Exception e) { + log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e); + return null; + } + } + public List queryTaskLoadToday() { try { return biPlatformRealDataMapper.queryTaskLoadToday(); @@ -206,14 +271,50 @@ public class BiPlatformRealDataService { } /** - * 今日预约-业务类型统计:按业务类型分组统计今日预约数量。 - * 例:今日预约航空打板 3 条 → 返回 {businessName:"航空打板", count:3} + * 任务类型统计:当月 OMS 运输订单按业务类型分组(1-跨境运输,2-国内运输)。 + * 返回 {totalTasks: 当月跨境+国内运输总单量, taskTypes: [{type, count}]} + * 查询失败时返回空结构,不影响写死字段。 + */ + /** + * 任务类型统计:固定输出「跨境运输」「国内运输」两类,count 取当月 OMS 业务单真实单量; + * 当月无数据或查询失败时仍返回两类、count=0(不使用写死模板兜底)。 + */ + public TaskTypeStatisticsVO queryMonthTransportOrderByType() { + int crossBorder = 0; // 跨境运输 BUSINESS_CATEGORY=1 + int domestic = 0; // 国内运输 BUSINESS_CATEGORY=2 + try { + List rows = biPlatformRealDataMapper.queryMonthTransportOrderByType(); + if (rows != null) { + for (RealTaskTypeStatPO r : rows) { + if (r == null || r.getBusinessCategory() == null || r.getCount() == null) { + continue; + } + if (r.getBusinessCategory() == 1) { + crossBorder = r.getCount().intValue(); + } else if (r.getBusinessCategory() == 2) { + domestic = r.getCount().intValue(); + } + } + } + } catch (Exception e) { + log.error("【OMS】统计当月运输订单业务类型失败: {}", e.getMessage(), e); + // 失败时不回退写死模板,保持两类 count=0 + } + List items = new ArrayList<>(); + items.add(TaskTypeCountItemVO.builder().type("跨境运输").count(crossBorder).build()); + items.add(TaskTypeCountItemVO.builder().type("国内运输").count(domestic).build()); + return TaskTypeStatisticsVO.builder().totalTasks(crossBorder + domestic).taskTypes(items).build(); + } + + /** + * 今日预约-租户统计:按租户名称分组统计今日预约数量。 + * 例:今日预约某租户 3 条 → 返回 {tenantName:"某租户", count:3} */ public List queryTodayBusinessTypeStats() { try { return biPlatformRealDataMapper.queryTodayBusinessTypeStats(); } catch (Exception e) { - log.error("【YMS】统计今日业务类型失败: {}", e.getMessage(), e); + log.error("【YMS】统计今日租户预约失败: {}", e.getMessage(), e); return java.util.Collections.emptyList(); } } @@ -271,29 +372,63 @@ public class BiPlatformRealDataService { template.setVehicles(vehicleVos); // 月台实时概览:真实数据源,无条件覆盖 + // 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用) + // 月台占用率 = 占用 / 全部月台 + // 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量 + // 作业准时率 = 今日(实际进场时间在预约日期当天的车辆数) / 今日预约车辆总数 × 100% if (template.getPlatformOverview() != null) { - RealPlatformOverviewPO ov = queryPlatformOverview(); - int total = ov.getTotalPlatforms().intValue(); - int occ = ov.getOperatingPlatforms().intValue(); + List platformList = queryPlatformInfoList(); + int total = platformList == null ? 0 : platformList.size(); + int occ = 0; + if (platformList != null) { + for (RealPlatformInfoPO p : platformList) { + if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) { + occ++; + } + } + } double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d; + int todayTasks = (int) countTodayTasks(); template.getPlatformOverview().setTotalPlatforms(total); template.getPlatformOverview().setOperatingPlatforms(occ); template.getPlatformOverview().setCurrentOccupancyRate(rate); - template.getPlatformOverview().setTodayTasks((int) countTodayTasks()); + template.getPlatformOverview().setTodayTasks(todayTasks); + + // 作业准时率:准时车辆数 / 今日预约总数 × 100%(今日总数为 0 时返回 0) + if (template.getEfficiencyStatistics() != null) { + template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate()); + } } - // 作业车辆状态统计:真实数据源,无条件覆盖 + // 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号) if (template.getVehicleStatus() != null) { RealVehicleStatusPO vs = queryVehicleStatusToday(); template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue()); template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue()); + template.getVehicleStatus().setWaiting(vs.getWaiting().intValue()); template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue()); template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue()); } - // 本月任务统计:taskTotal 有真实数据源无条件覆盖;YoY 等无真实数据源保留模板写死值 + // 本月任务统计:taskTotal / avgTaskDuration / taskCompletionRate 均有真实数据源,无条件覆盖;YoY 保留模板写死值 if (template.getMonthlyTaskStatistics() != null) { template.getMonthlyTaskStatistics().setTaskTotal((int) countMonthTasks()); + RealMonthlyTaskDurationPO monthStats = queryMonthTaskStats(); + if (monthStats != null) { + if (monthStats.getAvgDurationHours() != null) { + // 保留两位小数 + double v = monthStats.getAvgDurationHours(); + template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0); + } + Long total = monthStats.getTotalCount(); + Long completed = monthStats.getCompletedCount(); + if (total != null && total > 0 && completed != null) { + int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0); + template.getMonthlyTaskStatistics().setTaskCompletionRate(rate); + } else { + template.getMonthlyTaskStatistics().setTaskCompletionRate(0); + } + } } // 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖 @@ -313,6 +448,9 @@ public class BiPlatformRealDataService { } } + // 任务类型统计:当月 OMS 业务单真实数据(固定跨境运输/国内运输两类,不使用写死模板兜底) + template.setTaskTypeStatistics(queryMonthTransportOrderByType()); + return template; } diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java index b3ac1ac64..f4b729e9a 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biReport/support/BiReportSnapshotMapperSupport.java @@ -87,7 +87,7 @@ public final class BiReportSnapshotMapperSupport { .platformOverview(PlatformOverviewVO.builder() .totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build()) .vehicleStatus(VehicleStatusVO.builder() - .todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build()) + .todayReservedVehicles(0).notCheckedIn(0).waiting(0).operatingVehicles(0).completedVehicles(0).build()) .avgOperationDurationTrend(Collections.emptyList()) .monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder() .taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0) diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java index b682590a2..a149ecf61 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/service/BiReportSnapshotSyncService.java @@ -16,7 +16,7 @@ import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperat import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO; import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO; -import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO; +import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformInfoPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO; import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO; import lombok.RequiredArgsConstructor; @@ -173,18 +173,33 @@ public class BiReportSnapshotSyncService { } // ====== 真实数据:月台实时概览 ====== - RealPlatformOverviewPO ov = biPlatformRealDataService.queryPlatformOverview(); + // 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用) + // 月台占用率 = 占用 / 全部月台 + // 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量 if (template.getPlatformOverview() != null) { - template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue()); - template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue()); - int total = ov.getTotalPlatforms().intValue(); - int occ = ov.getOperatingPlatforms().intValue(); + List platformList = biPlatformRealDataService.queryPlatformInfoList(); + int total = platformList == null ? 0 : platformList.size(); + int occ = 0; + if (platformList != null) { + for (RealPlatformInfoPO p : platformList) { + if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) { + occ++; + } + } + } double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d; + int todayTasks = (int) biPlatformRealDataService.countTodayTasks(); + template.getPlatformOverview().setTotalPlatforms(total); + template.getPlatformOverview().setOperatingPlatforms(occ); template.getPlatformOverview().setCurrentOccupancyRate(rate); - } - long todayTasks = biPlatformRealDataService.countTodayTasks(); - if (template.getPlatformOverview() != null) { - template.getPlatformOverview().setTodayTasks((int) todayTasks); + template.getPlatformOverview().setTodayTasks(todayTasks); + + // 作业准时率 = 准时车辆数 / 今日预约总数 × 100% + // 准时:今日(TARGET_DATE=今天)已进场且 ENTRY_TIME <= bookingEndTime(预约结束时间),超过视为不准时 + // 今日预约总数 = 0 时返回 0 + if (template.getEfficiencyStatistics() != null) { + template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate()); + } } // ====== 真实数据:作业车辆状态统计 ====== @@ -192,14 +207,31 @@ public class BiReportSnapshotSyncService { if (template.getVehicleStatus() != null) { template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue()); template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue()); + template.getVehicleStatus().setWaiting(vs.getWaiting().intValue()); template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue()); template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue()); } - // ====== 真实数据:本月任务统计 taskTotal ====== + // ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ====== long monthTasks = biPlatformRealDataService.countMonthTasks(); if (template.getMonthlyTaskStatistics() != null) { template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks); + com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO monthStats = + biPlatformRealDataService.queryMonthTaskStats(); + if (monthStats != null) { + if (monthStats.getAvgDurationHours() != null) { + double v = monthStats.getAvgDurationHours(); + template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0); + } + Long total = monthStats.getTotalCount(); + Long completed = monthStats.getCompletedCount(); + if (total != null && total > 0 && completed != null) { + int rate = (int) Math.round(((double) completed.longValue() / total.longValue()) * 100.0); + template.getMonthlyTaskStatistics().setTaskCompletionRate(rate); + } else { + template.getMonthlyTaskStatistics().setTaskCompletionRate(0); + } + } } // ====== 真实数据:任务负荷(今日 24 小时) ====== @@ -218,6 +250,9 @@ public class BiReportSnapshotSyncService { } } + // ====== 真实数据:任务类型统计(当月 OMS 业务单,固定跨境运输/国内运输两类,不使用写死模板兜底) ====== + template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType()); + return template; } diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java index 79f0cdd1a..81a872259 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/support/BiSnapshotWeeklyRandomDataBuilder.java @@ -415,6 +415,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder { static final int P_TASKS = 418; static final int P_RESV = 2_850; static final int P_NC = 920; + static final int P_WAIT = 680; static final int P_OPV = 1_180; static final int P_DONE = 1_420; static final String[] P_MO_LABELS = {"5月", "6月", "7月"}; diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java index 108afc412..664ab716b 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java +++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/BiReportApi.java @@ -122,9 +122,9 @@ public class BiReportApi extends BaseController { } /** - * 今日预约-业务类型统计(实时查 YMS 库,不落库) + * 今日预约-租户统计(实时查 YMS 库,不落库) */ - @ApiOperation(value = "今日预约业务类型统计", notes = "按业务类型分组统计今日预约数量,实时查询 YMS 库,不落库;例:航空打板 3 条") + @ApiOperation(value = "今日预约租户统计", notes = "按租户名称分组统计今日预约数量,实时查询 YMS 库,不落库;例:某租户 3 条") @GetMapping("/businessTypeStats") public BiApiResult> businessTypeStats() { List data = biPlatformRealDataService.queryTodayBusinessTypeStats(); diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/VehicleStatusVO.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/VehicleStatusVO.java index f71aefe19..db6015e93 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/VehicleStatusVO.java +++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/VehicleStatusVO.java @@ -20,6 +20,9 @@ public class VehicleStatusVO { @ApiModelProperty("当前未签到,单位:辆") private Integer notCheckedIn; + @ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆") + private Integer waiting; + @ApiModelProperty("当前作业中,单位:辆") private Integer operatingVehicles; diff --git a/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml index d3d0b3c12..ce5d839e4 100644 --- a/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml +++ b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml @@ -40,43 +40,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" FROM NGWL_TEST_YMS.QMS_WINDOW_INFO - + + + + - + - + + + + @@ -102,6 +145,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY 1 DESC + + +