diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/repository/mapper/BiComprehensiveRealDataMapper.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/repository/mapper/BiComprehensiveRealDataMapper.java
new file mode 100644
index 000000000..2f48eef35
--- /dev/null
+++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/repository/mapper/BiComprehensiveRealDataMapper.java
@@ -0,0 +1,27 @@
+package com.mhd.bi.domain.biComprehensive.repository.mapper;
+
+import com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO;
+
+/**
+ * 综合态势-真实业务数据 Mapper(跨库查询,与月台监测 BiPlatformRealDataMapper 同方案)
+ *
+ *
数据来源:
+ *
+ * - 运输订单量:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER(OMS 运输业务单)
+ * - 百公里油耗:NGWL_TEST_WLHY.TMS_EXPENSE_REPORT(TMS 运输作业单,字段 FUEL_CONSUMPTION / HEAVYLOAD_MILEAGE)
+ *
+ */
+public interface BiComprehensiveRealDataMapper {
+
+ /**
+ * 运输订单量:统计本年度(CREATE_TIME 在当前年)全部组织的运输业务单数量。
+ * 统计范围:全部组织,不按机构过滤。
+ */
+ Long countCurrentYearTransportOrders();
+
+ /**
+ * 百公里油耗统计:统计本年度油耗量与重载里程均非空的记录,
+ * 返回 总油耗量 / 总重载里程 / 参与条数,由调用方计算百公里油耗。
+ */
+ RealFuelStatPO queryCurrentYearFuelStat();
+}
diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveRealDataService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveRealDataService.java
new file mode 100644
index 000000000..b1c0c95de
--- /dev/null
+++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveRealDataService.java
@@ -0,0 +1,63 @@
+package com.mhd.bi.domain.biComprehensive.service;
+
+import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveRealDataMapper;
+import com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+
+/**
+ * 综合态势-真实业务数据业务层(封装 OMS / TMS 跨库查询)
+ *
+ * 实现方案与「月台监测指标查询」一致:每次调用实时查库,查不到/查库异常返回 0,不影响其它字段。
+ */
+@Slf4j
+@Service
+public class BiComprehensiveRealDataService {
+
+ @Resource
+ private BiComprehensiveRealDataMapper biComprehensiveRealDataMapper;
+
+ /**
+ * 运输订单量:本年度 OMS 运输业务单数量,范围全部组织。
+ * 查询失败或无数据返回 0。
+ */
+ public long countCurrentYearTransportOrders() {
+ try {
+ Long n = biComprehensiveRealDataMapper.countCurrentYearTransportOrders();
+ return n == null ? 0L : n;
+ } catch (Exception e) {
+ log.error("【OMS】统计本年度运输订单量失败: {}", e.getMessage(), e);
+ return 0L;
+ }
+ }
+
+ /**
+ * 百公里油耗 = 总油耗量 ÷ 总重载里程 × 100,保留一位小数。
+ *
+ * 统计范围:TMS 运输作业单 TMS_EXPENSE_REPORT,本年度、全部组织、油耗量与重载里程均非空。
+ * 总重载里程为 0 或查询失败时返回 0,避免除零。
+ */
+ public double calcCurrentYearFuelConsumptionPerHundredKm() {
+ try {
+ RealFuelStatPO po = biComprehensiveRealDataMapper.queryCurrentYearFuelStat();
+ if (po == null) {
+ return 0d;
+ }
+ BigDecimal totalOil = po.getTotalOil();
+ BigDecimal totalMileage = po.getTotalHeavyMileage();
+ if (totalOil == null || totalMileage == null || totalMileage.compareTo(BigDecimal.ZERO) <= 0) {
+ return 0d;
+ }
+ return totalOil.multiply(BigDecimal.valueOf(100))
+ .divide(totalMileage, 1, RoundingMode.HALF_UP)
+ .doubleValue();
+ } catch (Exception e) {
+ log.error("【TMS】计算本年度百公里油耗失败: {}", e.getMessage(), e);
+ return 0d;
+ }
+ }
+}
diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveReportService.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveReportService.java
index 2698baa54..cf7fcf0e8 100644
--- a/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveReportService.java
+++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biComprehensive/service/BiComprehensiveReportService.java
@@ -1,21 +1,99 @@
package com.mhd.bi.domain.biComprehensive.service;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveReportMapper;
+import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Objects;
/**
* 综合态势:数据访问仅经 Mapper(含 XML 内 SQL 与 Mapper 默认方法组装)。
+ *
+ * 其中「运输订单量」「百公里油耗」为实时查询业务库的真实数据,
+ * 每次调用实时组装并覆盖更新快照表最新一条,实现方案与「月台监测指标查询」一致;
+ * 其余字段仍取自 BI_COMPREHENSIVE_SNAPSHOT 最新快照。
+ *
+ * 仅当这两项实时数据发生变化时才覆盖更新快照,避免无意义的写库。
*/
+@Slf4j
@Service
public class BiComprehensiveReportService {
+ private static final String REMARK_REALTIME = "realtime comprehensive";
+
@Resource
private BiComprehensiveReportMapper biComprehensiveReportMapper;
+ @Resource
+ private BiSnapshotWriteMapper biSnapshotWriteMapper;
+
+ @Resource
+ private BiComprehensiveRealDataService biComprehensiveRealDataService;
+
+ @Resource
+ private ObjectMapper objectMapper;
+
+ /**
+ * 实时组装综合态势:快照其余字段 + 实时业务数据(运输订单量、百公里油耗);
+ * 仅当实时业务数据发生变化时,才覆盖更新 BI_COMPREHENSIVE_SNAPSHOT 快照表最新一条后返回。
+ * 表中尚无记录时插入一条兜底。
+ */
public ComprehensiveSituationVO loadLatestComprehensive() {
- return biComprehensiveReportMapper.loadLatestComprehensive();
+ ComprehensiveSituationVO vo = biComprehensiveReportMapper.loadLatestComprehensive();
+ if (vo == null) {
+ vo = new ComprehensiveSituationVO();
+ }
+
+ // 实时业务数据:运输订单量(OMS 运输业务单,本年度、全部组织)
+ vo.setOrderCount(biComprehensiveRealDataService.countCurrentYearTransportOrders());
+ // 实时业务数据:百公里油耗(TMS 运输作业单,本年度、全部组织,油耗量与重载里程均非空)
+ vo.setFuelConsumptionPerHundredKm(
+ biComprehensiveRealDataService.calcCurrentYearFuelConsumptionPerHundredKm());
+
+ try {
+ String fullJson = objectMapper.writeValueAsString(vo);
+ String fingerprint = realDataFingerprint(vo);
+
+ String latestJson = biComprehensiveReportMapper.selectLatestPayloadJson();
+ if (StringUtils.isNotBlank(latestJson)) {
+ ComprehensiveSituationVO latestVo =
+ objectMapper.readValue(latestJson.trim(), ComprehensiveSituationVO.class);
+ if (Objects.equals(fingerprint, realDataFingerprint(latestVo))) {
+ log.info("BI 综合态势实时业务数据未变化,跳过落库");
+ return vo;
+ }
+ }
+
+ int rows = biSnapshotWriteMapper.updateLatestComprehensiveSnapshot(fullJson, REMARK_REALTIME);
+ if (rows < 1) {
+ // 表中无最新记录可更新,插入一条兜底
+ biSnapshotWriteMapper.insertComprehensiveSnapshot(fullJson, REMARK_REALTIME);
+ }
+ log.info("BI 综合态势实时数据已落库(覆盖最新, 数据变化), affectedRows={}", rows);
+ } catch (Exception e) {
+ log.error("BI 综合态势实时数据落库失败", e);
+ }
+ return vo;
+ }
+
+ /**
+ * 实时业务数据指纹:仅含实时查库得到的字段(运输订单量、百公里油耗),
+ * 用于判断是否需要覆盖更新快照;其余字段取自快照,不纳入指纹。
+ */
+ private String realDataFingerprint(ComprehensiveSituationVO vo) throws Exception {
+ Map fp = new LinkedHashMap<>();
+ if (vo == null) {
+ return objectMapper.writeValueAsString(fp);
+ }
+ fp.put("orderCount", vo.getOrderCount());
+ fp.put("fuelConsumptionPerHundredKm", vo.getFuelConsumptionPerHundredKm());
+ return objectMapper.writeValueAsString(fp);
}
}
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
index 9f815b7ba..fab9f2046 100644
--- 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
@@ -6,16 +6,20 @@ import java.io.Serializable;
/**
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
- * avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与)
- * durationCount:参与平均时长统计的有效条数
+ * totalWorkHours:本月任务作业时长合计(小时),未进入月台计 0、已进入未离开按 SYSDATE-ENTRY_TIME
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
- * totalCount:本月(TARGET_DATE)预约总数量
+ * totalCount:本月(TARGET_DATE)预约总数量(作为平均时长的分母)
+ *
+ * 任务平均作业时长 = totalWorkHours ÷ totalCount,由 Service 层计算。
*/
@Data
public class RealMonthlyTaskDurationPO implements Serializable {
private static final long serialVersionUID = 1L;
- /** 平均作业时长(小时) */
+ /** 本月任务作业时长合计(小时) */
+ private Double totalWorkHours;
+
+ /** 平均作业时长(小时),由 Service 层按 totalWorkHours ÷ totalCount 计算 */
private Double avgDurationHours;
/** 参与平均时长统计的有效条数 */
@@ -26,4 +30,4 @@ public class RealMonthlyTaskDurationPO implements Serializable {
/** 本月预约总数量(按 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/RealVehicleStatusPO.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biPlatformRealData/repository/po/RealVehicleStatusPO.java
index dabf754e9..a27a2e1dc 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
@@ -22,6 +22,9 @@ public class RealVehicleStatusPO implements Serializable {
/** 叫号状态合计:已签到 + 已叫号 + 已过号(FLOW_STATUS IN '2','3','4',预约日期为今天) */
private Long callStatusTotal;
+ /** 今日已出场(FLOW_STATUS = '11',预约日期为今天),用于月台周转率 */
+ private Long todayExited;
+
/** 当前作业中 */
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 d96d17022..8b68e5892 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
@@ -100,9 +100,11 @@ public class BiPlatformRealDataService {
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
+ fp.put("platformTurnoverRate", vo.getPlatformOverview().getPlatformTurnoverRate());
}
if (vo.getEfficiencyStatistics() != null) {
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
+ fp.put("avgPlatformDuration", vo.getEfficiencyStatistics().getAvgPlatformDuration());
}
if (vo.getVehicleStatus() != null) {
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
@@ -233,6 +235,7 @@ public class BiPlatformRealDataService {
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
if (po.getWaiting() == null) po.setWaiting(0L);
if (po.getCallStatusTotal() == null) po.setCallStatusTotal(0L);
+ if (po.getTodayExited() == null) po.setTodayExited(0L);
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
return po;
@@ -243,6 +246,7 @@ public class BiPlatformRealDataService {
po.setNotCheckedIn(0L);
po.setWaiting(0L);
po.setCallStatusTotal(0L);
+ po.setTodayExited(0L);
po.setOperatingVehicles(0L);
po.setCompletedVehicles(0L);
return po;
@@ -251,7 +255,41 @@ public class BiPlatformRealDataService {
}
+ /**
+ * 月台作业平均时长(小时)= 今日作业车辆「月台作业时长(分钟)」之和 ÷ 车辆数 ÷ 60。
+ * 仅统计已进入月台(platformDuration 大于 0)的车辆;无有效数据返回 0。
+ * 保留两位小数。
+ */
+ public double calcTodayAvgPlatformDuration(List vehicles) {
+ try {
+ if (vehicles == null || vehicles.isEmpty()) {
+ return 0d;
+ }
+ long sumMinutes = 0L;
+ int count = 0;
+ for (PlatformVehicleItemVO v : vehicles) {
+ if (v == null || v.getPlatformDuration() == null) {
+ continue;
+ }
+ // 仅统计已进入月台的车辆(未进入月台时长为 0,不参与平均)
+ if (v.getPlatformDuration() > 0) {
+ sumMinutes += v.getPlatformDuration();
+ count++;
+ }
+ }
+ if (count <= 0) {
+ return 0d;
+ }
+ double avgHours = (double) sumMinutes / (double) count / 60.0;
+ return Math.round(avgHours * 100.0) / 100.0;
+ } catch (Exception e) {
+ log.error("【YMS】计算月台作业平均时长失败: {}", e.getMessage(), e);
+ return 0d;
+ }
+ }
+
public long countMonthTasks() {
+
try {
Long n = biPlatformRealDataMapper.countMonthTasks();
return n == null ? 0L : n;
@@ -263,19 +301,31 @@ public class BiPlatformRealDataService {
/**
* 本月任务平均时长 / 完成率统计:
- * - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
+ * - totalWorkHours:本月任务作业时长合计(小时);未进入月台计 0,已进入未离开按 SYSDATE-ENTRY_TIME
+ * - avgDurationHours:任务平均作业时长 = totalWorkHours ÷ 本月任务数(totalCount),保留两位小数
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
*/
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
try {
- return biPlatformRealDataMapper.queryMonthTaskStats();
+ RealMonthlyTaskDurationPO po = biPlatformRealDataMapper.queryMonthTaskStats();
+ if (po == null) {
+ return null;
+ }
+ // 任务平均作业时长 = 本月作业时长合计 ÷ 本月任务数(分母为 0 时返回 0)
+ long totalCount = po.getTotalCount() == null ? 0L : po.getTotalCount();
+ double totalHours = po.getTotalWorkHours() == null ? 0d : po.getTotalWorkHours();
+ po.setAvgDurationHours(totalCount > 0
+ ? Math.round((totalHours / (double) totalCount) * 100.0) / 100.0
+ : 0d);
+ return po;
} catch (Exception e) {
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
return null;
}
}
+
public List queryTaskLoadToday() {
try {
return biPlatformRealDataMapper.queryTaskLoadToday();
@@ -417,21 +467,29 @@ public class BiPlatformRealDataService {
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal().intValue());
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
-
-
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
+
+ // 月台周转率 = 今日已出场记录数 ÷ 今日全部记录数 × 100%(保留两位小数)
+ if (template.getPlatformOverview() != null) {
+ long todayTotal = vs.getTodayReservedVehicles() == null ? 0L : vs.getTodayReservedVehicles();
+ long todayExited = vs.getTodayExited() == null ? 0L : vs.getTodayExited();
+ double turnover = todayTotal > 0
+ ? Math.round(((double) todayExited / (double) todayTotal) * 100.0 * 100.0) / 100.0
+ : 0d;
+ template.getPlatformOverview().setPlatformTurnoverRate(turnover);
+ }
}
+
// 本月任务统计: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);
+ // 任务平均作业时长 = 本月任务作业时长合计 ÷ 本月任务数(已在 Service 层算好),保留两位小数
+ template.getMonthlyTaskStatistics().setAvgTaskDuration(monthStats.getAvgDurationHours());
}
Long total = monthStats.getTotalCount();
Long completed = monthStats.getCompletedCount();
@@ -444,6 +502,12 @@ public class BiPlatformRealDataService {
}
}
+ // 平均装卸时长 = 月台作业平均时长(今日作业车辆 platformDuration 的平均值,保留两位小数)
+ if (template.getEfficiencyStatistics() != null) {
+ template.getEfficiencyStatistics().setAvgPlatformDuration(calcTodayAvgPlatformDuration(vehicleVos));
+ }
+
+
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
List loads = queryTaskLoadToday();
if (loads.isEmpty()) {
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 914983d9c..0189558d3 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
@@ -43,9 +43,9 @@ public final class BiReportSnapshotMapperSupport {
return ComprehensiveSituationVO.builder()
.valueAddedServiceIncome(0L)
.inventoryTurnover(0)
- .orderCount(0)
+ .orderCount(0L)
.vehicleUtilizationRate(0d)
- .fuelConsumptionPerHundredKm(0)
+ .fuelConsumptionPerHundredKm(0d)
.incomeTrend(Collections.emptyList())
.build();
}
@@ -85,7 +85,8 @@ public final class BiReportSnapshotMapperSupport {
.entryOvertimeRate(0).overtimeCount(0).platformOnTimeRate(0)
.avgPlatformDuration(0d).yardOnTimeRate(0).avgYardDuration(0d).build())
.platformOverview(PlatformOverviewVO.builder()
- .totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build())
+ .totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0)
+ .platformTurnoverRate(0d).build())
.vehicleStatus(VehicleStatusVO.builder()
.todayReservedVehicles(0).notCheckedIn(0).waiting(0)
.callStatusTotal(0)
diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/repository/mapper/BiSnapshotWriteMapper.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/repository/mapper/BiSnapshotWriteMapper.java
index bf895ebbe..771277234 100644
--- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/repository/mapper/BiSnapshotWriteMapper.java
+++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/repository/mapper/BiSnapshotWriteMapper.java
@@ -9,6 +9,9 @@ public interface BiSnapshotWriteMapper {
int insertComprehensiveSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
+ int updateLatestComprehensiveSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
+
+
int insertWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
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 9843ae662..25a3fa275 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
@@ -200,6 +200,13 @@ public class BiReportSnapshotSyncService {
}
}
+ // 平均装卸时长 = 月台作业平均时长(今日作业车辆 platformDuration 的平均值,保留两位小数)
+ if (template.getEfficiencyStatistics() != null) {
+ template.getEfficiencyStatistics()
+ .setAvgPlatformDuration(biPlatformRealDataService.calcTodayAvgPlatformDuration(vehicleVos));
+ }
+
+
// ====== 真实数据:作业车辆状态统计 ======
RealVehicleStatusPO vs = biPlatformRealDataService.queryVehicleStatusToday();
if (template.getVehicleStatus() != null) {
@@ -209,12 +216,20 @@ public class BiReportSnapshotSyncService {
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
template.getVehicleStatus().setCallStatusTotal(vs.getCallStatusTotal() == null ? 0 : vs.getCallStatusTotal().intValue());
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
-
-
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
+ // 月台周转率 = 今日已出场记录数 ÷ 今日全部记录数 × 100%(保留两位小数)
+ if (template.getPlatformOverview() != null) {
+ long todayTotal = vs.getTodayReservedVehicles() == null ? 0L : vs.getTodayReservedVehicles();
+ long todayExited = vs.getTodayExited() == null ? 0L : vs.getTodayExited();
+ double turnover = todayTotal > 0
+ ? Math.round(((double) todayExited / (double) todayTotal) * 100.0 * 100.0) / 100.0
+ : 0d;
+ template.getPlatformOverview().setPlatformTurnoverRate(turnover);
+ }
}
+
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
long monthTasks = biPlatformRealDataService.countMonthTasks();
if (template.getMonthlyTaskStatistics() != null) {
@@ -223,10 +238,11 @@ public class BiReportSnapshotSyncService {
biPlatformRealDataService.queryMonthTaskStats();
if (monthStats != null) {
if (monthStats.getAvgDurationHours() != null) {
- double v = monthStats.getAvgDurationHours();
- template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
+ // 任务平均作业时长 = 本月作业时长合计 ÷ 本月任务数(Service 层已算好)
+ template.getMonthlyTaskStatistics().setAvgTaskDuration(monthStats.getAvgDurationHours());
}
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);
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 7b1012c18..d9e6eb371 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
@@ -79,9 +79,9 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
return ComprehensiveSituationVO.builder()
.valueAddedServiceIncome(jitterLong(Baseline.COMP_INCOME, r))
.inventoryTurnover(Math.max(1, jitterInt(Baseline.COMP_TURNOVER, r)))
- .orderCount(Math.max(0, jitterInt(Baseline.COMP_ORDERS, r)))
+ .orderCount((long) Math.max(0, jitterInt(Baseline.COMP_ORDERS, r)))
.vehicleUtilizationRate(jitterPercentDouble(Baseline.COMP_VEHICLE_PCT, r))
- .fuelConsumptionPerHundredKm(Math.max(1, jitterInt(Baseline.COMP_FUEL, r)))
+ .fuelConsumptionPerHundredKm(Math.max(1.0, jitterDouble(Baseline.COMP_FUEL, r)))
.incomeTrend(jitterIntArray(Baseline.COMP_INCOME_TREND, r))
.build();
}
@@ -150,6 +150,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
.currentOccupancyRate((double) jitterPercentInt(Baseline.P_OCC, r))
.operatingPlatforms(Math.max(0, jitterInt(Baseline.P_OP, r)))
.todayTasks(Math.max(0, jitterInt(Baseline.P_TASKS, r)))
+ .platformTurnoverRate(jitterPercentDouble(Baseline.P_TURNOVER, r))
.build();
VehicleStatusVO vs = VehicleStatusVO.builder()
@@ -362,7 +363,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
static final int COMP_TURNOVER = 18;
static final int COMP_ORDERS = 50_120;
static final double COMP_VEHICLE_PCT = 93.2;
- static final int COMP_FUEL = 12;
+ static final double COMP_FUEL = 12.5;
static final int[] COMP_INCOME_TREND = {195, 248, 302, 415, 366, 488};
static final double W_WH_RATE = 96.8;
@@ -404,6 +405,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
static final int P_OCC = 62;
static final int P_OP = 31;
static final int P_TASKS = 418;
+ static final double P_TURNOVER = 72.5;
static final int P_RESV = 2_850;
static final int P_NC = 920;
static final int P_WAIT = 680;
diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/ComprehensiveSituationVO.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/ComprehensiveSituationVO.java
index 8a8864352..85185fdcc 100644
--- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/ComprehensiveSituationVO.java
+++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/ComprehensiveSituationVO.java
@@ -25,14 +25,14 @@ public class ComprehensiveSituationVO {
@ApiModelProperty("库存周转率,单位:次")
private Integer inventoryTurnover;
- @ApiModelProperty("运输订单量,单位:单")
- private Integer orderCount;
+ @ApiModelProperty("运输订单量,单位:单(实时统计 OMS 运输业务单,本年度、全部组织)")
+ private Long orderCount;
@ApiModelProperty("车辆利用率,单位:%")
private Double vehicleUtilizationRate;
- @ApiModelProperty("百公里油耗,单位:升")
- private Integer fuelConsumptionPerHundredKm;
+ @ApiModelProperty("百公里油耗,单位:升(实时统计 TMS 运输作业单:总油耗量 ÷ 总重载里程 × 100)")
+ private Double fuelConsumptionPerHundredKm;
@ApiModelProperty("运输收入趋势,单位:万元(近半年,按月正序)")
private List incomeTrend;
diff --git a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java
index fc66de7b5..35ae5b797 100644
--- a/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java
+++ b/mhd-bi/src/main/java/com/mhd/bi/interfaces/facadeApi/biReport/vo/platform/PlatformOverviewVO.java
@@ -25,4 +25,7 @@ public class PlatformOverviewVO {
@ApiModelProperty("今日作业任务,单位:个")
private Integer todayTasks;
+
+ @ApiModelProperty("月台周转率,单位:%(今日已出场的记录数 ÷ 今日全部记录数 × 100)")
+ private Double platformTurnoverRate;
}
diff --git a/mhd-bi/src/main/resources/mapper/biComprehensive/BiComprehensiveRealDataMapper.xml b/mhd-bi/src/main/resources/mapper/biComprehensive/BiComprehensiveRealDataMapper.xml
new file mode 100644
index 000000000..21d9a6575
--- /dev/null
+++ b/mhd-bi/src/main/resources/mapper/biComprehensive/BiComprehensiveRealDataMapper.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml
index 578ae9b27..b58c8bc82 100644
--- a/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml
+++ b/mhd-bi/src/main/resources/mapper/biPlatformRealData/BiPlatformRealDataMapper.xml
@@ -8,7 +8,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
plateNumber <- qms_main_business.CAR_NO
status <- qms_main_business.FLOW_STATUS
platformId <- qms_main_business.WINDOW_NAME(叫号月台,主业务表直接有)
- platformDuration <- qms_main_business.EXIT_TIME - ENTRY_TIME(分钟)
+ platformDuration <- 月台作业时长(分钟):
+ 未进入月台(ENTRY_TIME 为空) -> 0
+ 已进入且已离开 -> EXIT_TIME - ENTRY_TIME
+ 已进入但未离开 -> SYSDATE - ENTRY_TIME
appointmentTime <- qms_main_business.CREATE_TIME
workFloor <- qms_window_info.PLATFORM_FLOOR(按 WINDOW_NAME 关联)
-->
@@ -18,9 +21,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mb.FLOW_STATUS AS status,
mb.WINDOW_NAME AS platformId,
CASE
- WHEN mb.EXIT_TIME IS NOT NULL AND mb.ENTRY_TIME IS NOT NULL
+ WHEN mb.ENTRY_TIME IS NULL THEN 0
+ WHEN mb.EXIT_TIME IS NOT NULL
THEN CAST((mb.EXIT_TIME - mb.ENTRY_TIME) * 24 * 60 AS BIGINT)
- ELSE 0
+ ELSE CAST((SYSDATE - mb.ENTRY_TIME) * 24 * 60 AS BIGINT)
END AS platformDuration,
TO_CHAR(mb.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') AS appointmentTime,
wi.PLATFORM_FLOOR AS workFloor
@@ -32,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY mb.CREATE_TIME DESC
+