BI大屏新加仓储运营专区接口查询

This commit is contained in:
秦鸿展
2026-05-15 10:31:06 +08:00
parent 3a6cefa0f6
commit d0836cb5c6
26 changed files with 778 additions and 3 deletions
@@ -6,6 +6,7 @@ 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 com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@@ -134,4 +135,35 @@ public final class BiReportSnapshotMapperSupport {
.build())
.build();
}
public static WarehouseOperationZoneVO emptyWarehouseOperationZone() {
return WarehouseOperationZoneVO.builder()
.storageOverview(WhStorageOverviewVO.builder()
.title("").value(0).unit("").subText("").build())
.operationStats(WhOperationStatsVO.builder()
.title("").value(0).unit("").growthRate("").trend("").build())
.businessPlanning(WhBusinessPlanningVO.builder()
.generalWarehouse(0).coldStorage(0).foodProcessing(0).automatedStorage(0).build())
.throughputTrend(Collections.emptyList())
.areaDistribution(WhAreaDistributionVO.builder()
.utilizationRate("").details(Collections.emptyList()).build())
.capacityUtilizationTrend(WhCapacityUtilizationTrendVO.builder()
.peakLabel("").data(Collections.emptyList()).build())
.orderStatistics(WhOrderStatisticsVO.builder()
.annualOrders(0L).quarterlyOrders(0L).monthlyOrders(0L).build())
.serviceStatistics(WhServiceStatisticsVO.builder()
.clients(0).coverage("").onTimeRate("").rateChange("").build())
.orderTrend(Collections.emptyList())
.turnoverRateTrend(WhTurnoverRateTrendVO.builder()
.currentMonth("").annual("").data(Collections.emptyList()).build())
.serviceCapacity(Collections.emptyList())
.realTimeAnalysis(WhRealTimeAnalysisVO.builder()
.utilizationRate(WhRealTimeGaugeVO.builder().value("").comparison("").trend("").build())
.rentalRate(WhRealTimeGaugeVO.builder().value("").comparison("").trend("").build())
.build())
.mapPopup(WhMapPopupVO.builder()
.warehouseName("").totalArea("").totalSku(0).todayOrders(0)
.utilizationRate("").rentalRate("").build())
.build();
}
}
@@ -14,4 +14,6 @@ public interface BiSnapshotWriteMapper {
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
int insertOverallOperationSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
int insertWarehouseOperationZoneSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
}
@@ -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_OVERALL_OPERATION_SNAPSHOT。
* 定时将业务快照写入 BI_COMPREHENSIVE_SNAPSHOT / BI_WAREHOUSE_TRANSPORT_SNAPSHOT / BI_PLATFORM_SURVEILLANCE_SNAPSHOT / BI_OVERALL_OPERATION_SNAPSHOT / BI_WAREHOUSE_OPERATION_ZONE_SNAPSHOT
* <p>默认关闭,需在配置中设置 {@code mhd.bi.snapshot-sync.enabled=true}。</p>
*/
@Slf4j
@@ -3,10 +3,12 @@ package com.mhd.bi.domain.biSnapshotSync.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
import com.mhd.bi.domain.biSnapshotSync.support.BiSnapshotWeeklyRandomDataBuilder;
import com.mhd.bi.domain.biWarehouseOperationZone.support.WarehouseOperationZoneDemoData;
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.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperationZoneVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -14,7 +16,7 @@ import org.springframework.stereotype.Service;
import java.util.Random;
/**
* BI 快照表定时同步(综合态势 / 仓储运输 / 月台监测 / 总体运营态势)。
* BI 快照表定时同步(综合态势 / 仓储运输 / 月台监测 / 总体运营态势 / 仓储运营专区)。
* <p><b>当前(临时)</b>{@code build*} 使用 {@link BiSnapshotWeeklyRandomDataBuilder},每次执行使用新的 {@link Random}
* 故<b>同一天多次手动触发、以及每次定时任务执行</b>,生成的模拟数据均<b>不相同</b>(仍在基准 ±20% 内)。</p>
* <p><b>后续改造</b>:在各 {@code build*} 中改为查库/Feign 聚合真实业务并组装 VO。</p>
@@ -37,6 +39,7 @@ public class BiReportSnapshotSyncService {
syncWarehouseTransportSnapshot();
syncPlatformSurveillanceSnapshot();
syncOverallOperationSnapshot();
syncWarehouseOperationZoneSnapshot();
}
public void syncComprehensiveSnapshot() {
@@ -95,6 +98,20 @@ public class BiReportSnapshotSyncService {
}
}
public void syncWarehouseOperationZoneSnapshot() {
try {
WarehouseOperationZoneVO vo = buildWarehouseOperationZoneSnapshot();
String json = objectMapper.writeValueAsString(vo);
int rows = biSnapshotWriteMapper.insertWarehouseOperationZoneSnapshot(json, REMARK_SYNC);
if (rows < 1) {
log.warn("BI 仓储运营专区快照 INSERT 影响行数为 {},请确认 NGWL_TEST_BI.BI_WAREHOUSE_OPERATION_ZONE_SNAPSHOT", rows);
}
log.info("BI 仓储运营专区快照已写入, affectedRows={}", rows);
} catch (Exception e) {
log.error("BI 仓储运营专区快照同步失败", e);
}
}
/**
* TODO 业务落地:改为查询真实数据组装 VO。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#overallOperation(Random)}。
*/
@@ -118,4 +135,11 @@ public class BiReportSnapshotSyncService {
protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() {
return BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(new Random());
}
/**
* TODO 业务落地:改为查询真实数据组装 VO。当前为 {@link WarehouseOperationZoneDemoData} 静态示例。
*/
protected WarehouseOperationZoneVO buildWarehouseOperationZoneSnapshot() {
return WarehouseOperationZoneDemoData.build();
}
}
@@ -0,0 +1,20 @@
package com.mhd.bi.domain.biWarehouseOperationZone.repository.mapper;
import com.mhd.bi.domain.biReport.support.BiReportSnapshotMapperSupport;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperationZoneVO;
/**
* 仓储运营专区:取 NGWL_TEST_BI.BI_WAREHOUSE_OPERATION_ZONE_SNAPSHOT 最新 PAYLOAD_JSON 并解析。
*/
public interface BiWarehouseOperationZoneReportMapper {
String selectLatestPayloadJson();
default WarehouseOperationZoneVO loadLatestWarehouseOperationZone() {
return BiReportSnapshotMapperSupport.parsePayload(
selectLatestPayloadJson(),
WarehouseOperationZoneVO.class,
BiReportSnapshotMapperSupport::emptyWarehouseOperationZone,
"仓储运营专区");
}
}
@@ -0,0 +1,21 @@
package com.mhd.bi.domain.biWarehouseOperationZone.service;
import com.mhd.bi.domain.biWarehouseOperationZone.repository.mapper.BiWarehouseOperationZoneReportMapper;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperationZoneVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* 南光物流业务经营分析 · 仓储运营专区
*/
@Service
public class BiWarehouseOperationZoneReportService {
@Resource
private BiWarehouseOperationZoneReportMapper biWarehouseOperationZoneReportMapper;
public WarehouseOperationZoneVO loadLatestWarehouseOperationZone() {
return biWarehouseOperationZoneReportMapper.loadLatestWarehouseOperationZone();
}
}
@@ -0,0 +1,139 @@
package com.mhd.bi.domain.biWarehouseOperationZone.support;
import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.*;
import java.util.Arrays;
import java.util.List;
/**
* 仓储运营专区快照演示数据(对齐大屏示例 JSON;后续可改为真实聚合)。
*/
public final class WarehouseOperationZoneDemoData {
private WarehouseOperationZoneDemoData() {
}
public static WarehouseOperationZoneVO build() {
List<WhThroughputMonthItemVO> throughputTrend = Arrays.asList(
WhThroughputMonthItemVO.builder().month("11月").value(10).build(),
WhThroughputMonthItemVO.builder().month("12月").value(14).build(),
WhThroughputMonthItemVO.builder().month("1月").value(22).build(),
WhThroughputMonthItemVO.builder().month("2月").value(21).build(),
WhThroughputMonthItemVO.builder().month("3月").value(13).build(),
WhThroughputMonthItemVO.builder().month("4月").value(16).build(),
WhThroughputMonthItemVO.builder().month("5月").value(8).build()
);
List<WhAreaDistributionDetailVO> areaDetails = Arrays.asList(
WhAreaDistributionDetailVO.builder().name("普通仓出租面积").value(9400).unit("").build(),
WhAreaDistributionDetailVO.builder().name("自动化立库出租面积").value(9400).unit("").build(),
WhAreaDistributionDetailVO.builder().name("闲置面积").value(9400).unit("").build(),
WhAreaDistributionDetailVO.builder().name("冷冻仓出租面积").value(9400).unit("").build()
);
List<WhMonthRatePointVO> capTrendData = Arrays.asList(
WhMonthRatePointVO.builder().month("1月").rate(20).build(),
WhMonthRatePointVO.builder().month("2月").rate(30).build(),
WhMonthRatePointVO.builder().month("3月").rate(55).build(),
WhMonthRatePointVO.builder().month("4月").rate(40).build(),
WhMonthRatePointVO.builder().month("5月").rate(45).build(),
WhMonthRatePointVO.builder().month("6月").rate(60).build(),
WhMonthRatePointVO.builder().month("7月").rate(50).build()
);
List<WhMonthRatePointVO> orderTrend = Arrays.asList(
WhMonthRatePointVO.builder().month("1月").rate(100).build(),
WhMonthRatePointVO.builder().month("2月").rate(90).build(),
WhMonthRatePointVO.builder().month("3月").rate(75).build(),
WhMonthRatePointVO.builder().month("4月").rate(70).build(),
WhMonthRatePointVO.builder().month("5月").rate(95).build(),
WhMonthRatePointVO.builder().month("6月").rate(85).build()
);
List<WhMonthRatePointVO> turnoverData = Arrays.asList(
WhMonthRatePointVO.builder().month("11月").rate(10).build(),
WhMonthRatePointVO.builder().month("12月").rate(15).build(),
WhMonthRatePointVO.builder().month("1月").rate(22).build(),
WhMonthRatePointVO.builder().month("2月").rate(20).build(),
WhMonthRatePointVO.builder().month("3月").rate(12).build(),
WhMonthRatePointVO.builder().month("4月").rate(16).build()
);
List<WhServiceCapacityRowVO> serviceCapacity = Arrays.asList(
WhServiceCapacityRowVO.builder().rank(1).name("君华仓").totalArea("1.2万m²").processed("2,400单").throughput("2.2万吨").build(),
WhServiceCapacityRowVO.builder().rank(2).name("通宇仓").totalArea("1.2万m²").processed("1,800单").throughput("1.1万吨").build(),
WhServiceCapacityRowVO.builder().rank(3).name("横琴仓").totalArea("1.2万m²").processed("1,200单").throughput("1.5万吨").build(),
WhServiceCapacityRowVO.builder().rank(4).name("新南仓").totalArea("1.2万m²").processed("800单").throughput("2.1万吨").build(),
WhServiceCapacityRowVO.builder().rank(5).name("谷丰仓").totalArea("1.2万m²").processed("567单").throughput("1.8万吨").build()
);
return WarehouseOperationZoneVO.builder()
.storageOverview(WhStorageOverviewVO.builder()
.title("仓储面积")
.value(10)
.unit("万m²")
.subText("覆盖仓库数8个")
.build())
.operationStats(WhOperationStatsVO.builder()
.title("年吞吐量")
.value(26)
.unit("万吨")
.growthRate("8.5%")
.trend("up")
.build())
.businessPlanning(WhBusinessPlanningVO.builder()
.generalWarehouse(43000)
.coldStorage(15000)
.foodProcessing(11000)
.automatedStorage(5200)
.build())
.throughputTrend(throughputTrend)
.areaDistribution(WhAreaDistributionVO.builder()
.utilizationRate("85%")
.details(areaDetails)
.build())
.capacityUtilizationTrend(WhCapacityUtilizationTrendVO.builder()
.peakLabel("60%")
.data(capTrendData)
.build())
.orderStatistics(WhOrderStatisticsVO.builder()
.annualOrders(525440L)
.quarterlyOrders(225120L)
.monthlyOrders(23560L)
.build())
.serviceStatistics(WhServiceStatisticsVO.builder()
.clients(582)
.coverage("覆盖港珠澳")
.onTimeRate("98.2%")
.rateChange("0.4%")
.build())
.orderTrend(orderTrend)
.turnoverRateTrend(WhTurnoverRateTrendVO.builder()
.currentMonth("3次")
.annual("4次")
.data(turnoverData)
.build())
.serviceCapacity(serviceCapacity)
.realTimeAnalysis(WhRealTimeAnalysisVO.builder()
.utilizationRate(WhRealTimeGaugeVO.builder()
.value("50.8%")
.comparison("3.4%")
.trend("up")
.build())
.rentalRate(WhRealTimeGaugeVO.builder()
.value("70.8%")
.comparison("3.4%")
.trend("up")
.build())
.build())
.mapPopup(WhMapPopupVO.builder()
.warehouseName("通宇保税仓")
.totalArea("2000m2")
.totalSku(668)
.todayOrders(237)
.utilizationRate("85%")
.rentalRate("37.1%")
.build())
.build();
}
}