From 2b281bba90896448df51873ceebde06c651578d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Mon, 11 May 2026 15:01:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E4=BD=93=E8=BF=90=E8=90=A5=E6=80=81?= =?UTF-8?q?=E5=8A=BF=E6=8E=A5=E5=8F=A3=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BiReportSnapshotMapperSupport.java | 38 +++++ .../mapper/BiSnapshotWriteMapper.java | 4 +- .../BiReportSnapshotSyncScheduler.java | 2 +- .../service/BiReportSnapshotSyncService.java | 29 +++- .../BiSnapshotWeeklyRandomDataBuilder.java | 139 ++++++++++++++++++ .../facadeApi/biReport/BiReportApi.java | 17 ++- .../facadeApi/biReport/dto/BiApiResult.java | 6 +- .../biSnapshotSync/BiSnapshotWriteMapper.xml | 5 + 8 files changed, 231 insertions(+), 9 deletions(-) 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 6d6086d4c..b9d4ad10b 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 @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.CustomerContributionRankVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.*; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.*; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -96,4 +97,41 @@ public final class BiReportSnapshotMapperSupport { .platformAlarmDistribution(Collections.emptyList()) .build(); } + + public static OverallOperationSituationVO emptyOverallOperationSituation() { + return OverallOperationSituationVO.builder() + .updateTime("") + .warehouse(OverallWarehouseOperationVO.builder() + .orderStatistics(OverallWarehouseOrderStatisticVO.builder() + .processedOrderCount(0L).changePercent(0d).build()) + .coreCapability(OverallWarehouseCoreCapabilityVO.builder() + .totalWarehouses(0).selfOperatedCount(0).outsourcedCount(0) + .operatingArea(0).areaUnit("") + .build()) + .orderTrendByMonth(Collections.emptyList()) + .throughputTrendByMonth(Collections.emptyList()) + .bizStatistics(OverallWarehouseBizStatisticVO.builder() + .customerCount(0L).coverageArea("") + .annualThroughput(0).throughputUnit("").throughputGrowth(0d) + .build()) + .capabilityRanking(Collections.emptyList()) + .build()) + .map(OverallMapSectionVO.builder().nodes(Collections.emptyList()).build()) + .transport(OverallTransportOperationVO.builder() + .orderSummary(OverallTransportOrderSummaryVO.builder() + .processedOrderCount(0L).changePercent(0d) + .annualFreight(0d).freightUnit("").freightGrowth(0d) + .build()) + .capacityStatistics(OverallTransportCapacityVO.builder() + .totalVehicles(0).ownedVehicles(0).socialVehicles(0) + .totalDrivers(0).ownedDrivers(0).socialDrivers(0) + .build()) + .orderTrendByMonth(Collections.emptyList()) + .freightTrendByMonth(Collections.emptyList()) + .orderDistribution(OverallTransportModeDistributionVO.builder() + .crossBorder(0L).domestic(0L).build()) + .enterpriseRanking(Collections.emptyList()) + .build()) + .build(); + } } 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 a6ca1a03e..597fe9e07 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 @@ -3,7 +3,7 @@ package com.mhd.bi.domain.biSnapshotSync.repository.mapper; import org.apache.ibatis.annotations.Param; /** - * 三张 BI 快照表写入(定时同步任务使用) + * BI 快照表写入(定时同步任务使用) */ public interface BiSnapshotWriteMapper { @@ -12,4 +12,6 @@ public interface BiSnapshotWriteMapper { int insertWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark); int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark); + + int insertOverallOperationSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark); } diff --git a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/scheduler/BiReportSnapshotSyncScheduler.java b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/scheduler/BiReportSnapshotSyncScheduler.java index f0229dac5..9a3301c8a 100644 --- a/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/scheduler/BiReportSnapshotSyncScheduler.java +++ b/mhd-bi/src/main/java/com/mhd/bi/domain/biSnapshotSync/scheduler/BiReportSnapshotSyncScheduler.java @@ -8,7 +8,7 @@ import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; /** - * 定时将业务快照写入 BI_COMPREHENSIVE_SNAPSHOT / BI_WAREHOUSE_TRANSPORT_SNAPSHOT / BI_PLATFORM_SURVEILLANCE_SNAPSHOT。 + * 定时将业务快照写入 BI_COMPREHENSIVE_SNAPSHOT / BI_WAREHOUSE_TRANSPORT_SNAPSHOT / BI_PLATFORM_SURVEILLANCE_SNAPSHOT / BI_OVERALL_OPERATION_SNAPSHOT。 *
默认关闭,需在配置中设置 {@code mhd.bi.snapshot-sync.enabled=true}。
*/ @Slf4j 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 e12fb6477..e951bd4c5 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 @@ -5,6 +5,7 @@ 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.ComprehensiveSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallOperationSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,10 +14,10 @@ import org.springframework.stereotype.Service; import java.util.Random; /** - * BI 三张快照表定时同步。 + * BI 快照表定时同步(综合态势 / 仓储运输 / 月台监测 / 总体运营态势)。 *当前(临时):{@code build*} 使用 {@link BiSnapshotWeeklyRandomDataBuilder},每次执行使用新的 {@link Random}, * 故同一天多次手动触发、以及每次定时任务执行,生成的模拟数据均不相同(仍在基准 ±20% 内)。
- *后续改造:在三个 {@code build*} 中改为查库/Feign 聚合真实业务并组装 VO。
+ *后续改造:在各 {@code build*} 中改为查库/Feign 聚合真实业务并组装 VO。
*/ @Slf4j @Service @@ -29,12 +30,13 @@ public class BiReportSnapshotSyncService { private final ObjectMapper objectMapper; /** - * 依次同步三张快照;单表失败不影响其它表,只记日志。 + * 依次同步各快照表;单表失败不影响其它表,只记日志。 */ public void syncAllSnapshots() { syncComprehensiveSnapshot(); syncWarehouseTransportSnapshot(); syncPlatformSurveillanceSnapshot(); + syncOverallOperationSnapshot(); } public void syncComprehensiveSnapshot() { @@ -79,6 +81,27 @@ public class BiReportSnapshotSyncService { } } + public void syncOverallOperationSnapshot() { + try { + OverallOperationSituationVO vo = buildOverallOperationSnapshot(); + String json = objectMapper.writeValueAsString(vo); + int rows = biSnapshotWriteMapper.insertOverallOperationSnapshot(json, REMARK_SYNC); + if (rows < 1) { + log.warn("BI 总体运营态势快照 INSERT 影响行数为 {},请确认 NGWL_TEST_BI.BI_OVERALL_OPERATION_SNAPSHOT", rows); + } + log.info("BI 总体运营态势快照已写入, affectedRows={}", rows); + } catch (Exception e) { + log.error("BI 总体运营态势快照同步失败", e); + } + } + + /** + * TODO 业务落地:改为查询真实数据组装 VO。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#overallOperation(Random)}。 + */ + protected OverallOperationSituationVO buildOverallOperationSnapshot() { + return BiSnapshotWeeklyRandomDataBuilder.overallOperation(new Random()); + } + /** * TODO 业务落地:改为查询真实数据组装 VO。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#comprehensive(Random)}。 */ 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 4b8eba8d3..6617d7d5e 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 @@ -3,6 +3,7 @@ package com.mhd.bi.domain.biSnapshotSync.support; import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.CustomerContributionRankVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.*; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.*; import java.time.LocalDate; @@ -232,6 +233,144 @@ public final class BiSnapshotWeeklyRandomDataBuilder { .build(); } + /** + * 总体运营态势:与 {@code create_bi_overall_operation_dm.sql} 内置 PAYLOAD_JSON 一致(不随 Random 抖动)。 + */ + public static OverallOperationSituationVO overallOperation(Random r) { + return overallReferenceDashboard(); + } + + /** + * 与产品约定返回值示例一致,供快照同步与联调。 + */ + public static OverallOperationSituationVO overallReferenceDashboard() { + return OverallOperationSituationVO.builder() + .updateTime("2026-05-11 10:55:00") + .warehouse(OverallWarehouseOperationVO.builder() + .orderStatistics(OverallWarehouseOrderStatisticVO.builder() + .processedOrderCount(6767L) + .changePercent(5.4) + .build()) + .coreCapability(OverallWarehouseCoreCapabilityVO.builder() + .totalWarehouses(10) + .selfOperatedCount(4) + .outsourcedCount(6) + .operatingArea(28) + .areaUnit("万m²") + .build()) + .orderTrendByMonth(Arrays.asList( + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("1月").inboundOrders(700L).outboundOrders(450L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("2月").inboundOrders(900L).outboundOrders(550L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("3月").inboundOrders(800L).outboundOrders(480L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("4月").inboundOrders(550L).outboundOrders(300L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("5月").inboundOrders(750L).outboundOrders(350L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("6月").inboundOrders(580L).outboundOrders(320L).build(), + OverallWarehouseOrderTrendMonthVO.builder().monthLabel("7月").inboundOrders(780L).outboundOrders(400L).build() + )) + .throughputTrendByMonth(Arrays.asList( + OverallThroughputTrendMonthVO.builder().monthLabel("11月").throughput(10).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("12月").throughput(14).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("1月").throughput(23).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("2月").throughput(22).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("3月").throughput(17).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("4月").throughput(18).build(), + OverallThroughputTrendMonthVO.builder().monthLabel("5月").throughput(9).build() + )) + .bizStatistics(OverallWarehouseBizStatisticVO.builder() + .customerCount(582L) + .coverageArea("覆盖港珠澳") + .annualThroughput(26) + .throughputUnit("万吨") + .throughputGrowth(8.5) + .build()) + .capabilityRanking(Arrays.asList( + OverallWarehouseCapabilityRankVO.builder().rank(1).name("君华仓").processedVolume("2,400单").throughput("5.2万吨").utilizationRate("85%").build(), + OverallWarehouseCapabilityRankVO.builder().rank(2).name("遂宁仓").processedVolume("1,800单").throughput("4.1万吨").utilizationRate("78%").build(), + OverallWarehouseCapabilityRankVO.builder().rank(3).name("横琴仓").processedVolume("1,200单").throughput("3.5万吨").utilizationRate("92%").build(), + OverallWarehouseCapabilityRankVO.builder().rank(4).name("新南仓").processedVolume("800单").throughput("2.2万吨").utilizationRate("65%").build(), + OverallWarehouseCapabilityRankVO.builder().rank(5).name("谷丰仓").processedVolume("567单").throughput("1.8万吨").utilizationRate("45%").build() + )) + .build()) + .map(OverallMapSectionVO.builder() + .nodes(Arrays.asList( + OverallMapNodeVO.builder() + .type("headquarters") + .name("总部") + .location(Arrays.asList(113.3, 22.5)) + .build(), + OverallMapNodeVO.builder() + .type("businessUnit") + .name("业务单元") + .location(Arrays.asList(113.6, 22.8)) + .tooltip(OverallMapTooltipVO.builder() + .title("通宇业务情况分析") + .data(Arrays.asList( + OverallMapTooltipDataItemVO.builder().label("在途车辆").value(3).build(), + OverallMapTooltipDataItemVO.builder().label("在途订单").value(11).build() + )) + .build()) + .build(), + OverallMapNodeVO.builder() + .type("warehouse") + .name("通宇保税仓") + .location(Arrays.asList(113.4, 22.3)) + .tooltip(OverallMapTooltipVO.builder() + .title("通宇保税仓情况分析") + .data(Arrays.asList( + OverallMapTooltipDataItemVO.builder().label("入库作业").value(1).build(), + OverallMapTooltipDataItemVO.builder().label("出库作业").value(1).build() + )) + .build()) + .build() + )) + .build()) + .transport(OverallTransportOperationVO.builder() + .orderSummary(OverallTransportOrderSummaryVO.builder() + .processedOrderCount(5240L) + .changePercent(6.2) + .annualFreight(2.6) + .freightUnit("万吨") + .freightGrowth(8.5) + .build()) + .capacityStatistics(OverallTransportCapacityVO.builder() + .totalVehicles(320) + .ownedVehicles(100) + .socialVehicles(220) + .totalDrivers(400) + .ownedDrivers(160) + .socialDrivers(240) + .build()) + .orderTrendByMonth(Arrays.asList( + OverallTransportOrderTrendMonthVO.builder().monthLabel("1月").count(100L).build(), + OverallTransportOrderTrendMonthVO.builder().monthLabel("2月").count(120L).build(), + OverallTransportOrderTrendMonthVO.builder().monthLabel("3月").count(230L).build(), + OverallTransportOrderTrendMonthVO.builder().monthLabel("4月").count(110L).build(), + OverallTransportOrderTrendMonthVO.builder().monthLabel("5月").count(150L).build(), + OverallTransportOrderTrendMonthVO.builder().monthLabel("6月").count(200L).build() + )) + .freightTrendByMonth(Arrays.asList( + OverallTransportFreightTrendMonthVO.builder().monthLabel("1月").freight(80).build(), + OverallTransportFreightTrendMonthVO.builder().monthLabel("2月").freight(110).build(), + OverallTransportFreightTrendMonthVO.builder().monthLabel("3月").freight(240).build(), + OverallTransportFreightTrendMonthVO.builder().monthLabel("4月").freight(100).build(), + OverallTransportFreightTrendMonthVO.builder().monthLabel("5月").freight(140).build(), + OverallTransportFreightTrendMonthVO.builder().monthLabel("6月").freight(190).build() + )) + .orderDistribution(OverallTransportModeDistributionVO.builder() + .crossBorder(2400L) + .domestic(2300L) + .build()) + .enterpriseRanking(Arrays.asList( + OverallTransportEnterpriseRankVO.builder().rank(1).name("通宇").processedVolume("2,400单").freight("5.2万吨").onTimeRate("85%").build(), + OverallTransportEnterpriseRankVO.builder().rank(2).name("南岐").processedVolume("1,800单").freight("4.1万吨").onTimeRate("78%").build(), + OverallTransportEnterpriseRankVO.builder().rank(3).name("谷丰").processedVolume("1,200单").freight("3.5万吨").onTimeRate("92%").build(), + OverallTransportEnterpriseRankVO.builder().rank(4).name("仓码").processedVolume("800单").freight("2.2万吨").onTimeRate("65%").build(), + OverallTransportEnterpriseRankVO.builder().rank(5).name("横琴").processedVolume("567单").freight("1.8万吨").onTimeRate("45%").build() + )) + .build()) + .build(); + } + /** * 基准与 SQL 脚本 alternate sample 一致 */ 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 2923cf61d..614feaf2f 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 @@ -3,10 +3,12 @@ package com.mhd.bi.interfaces.facadeApi.biReport; import com.mhd.bi.domain.biSnapshotSync.service.BiReportSnapshotSyncService; import com.mhd.bi.domain.biComprehensive.service.BiComprehensiveReportService; import com.mhd.bi.domain.biPlatformSurveillance.service.BiPlatformSurveillanceReportService; +import com.mhd.bi.domain.biOverallOperation.service.BiOverallOperationReportService; import com.mhd.bi.domain.biWarehouseTransport.service.BiWarehouseTransportReportService; import com.mhd.bi.interfaces.facadeApi.biReport.dto.BiApiResult; import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO; +import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallOperationSituationVO; import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO; import com.mhd.common.core.web.controller.BaseController; import io.swagger.annotations.Api; @@ -38,11 +40,14 @@ public class BiReportApi extends BaseController { @Autowired private BiPlatformSurveillanceReportService biPlatformSurveillanceReportService; + @Autowired + private BiOverallOperationReportService biOverallOperationReportService; + @Autowired private BiReportSnapshotSyncService biReportSnapshotSyncService; - @ApiOperation(value = "手动触发快照同步", notes = "立即写入三张快照表;须带 X-BI-Access-Token") + @ApiOperation(value = "手动触发快照同步", notes = "立即写入各 BI 快照表(综合、仓储运输、月台监测、总体运营);须带 X-BI-Access-Token") @PostMapping("/snapshotSync/run") public BiApiResult