Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
王奎兴
2026-08-26 14:08:38 +08:00
10 changed files with 261 additions and 11 deletions
@@ -4,6 +4,8 @@ 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.RealVehicleStatusPO;
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 java.util.List;
@@ -31,4 +33,10 @@ public interface BiPlatformRealDataMapper {
/** 任务负荷(今日 24 小时) */
List<RealTaskLoadPO> queryTaskLoadToday();
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
/** 月台监控-按楼层统计月台车辆(楼层、月台数量、今日预约车辆、当前作业车辆) */
List<RealPlatformFloorStatPO> queryPlatformFloorStats();
}
@@ -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
* 按业务类型分组统计今日预约数量
*/
@Data
public class RealBusinessTypeStatPO implements Serializable {
private static final long serialVersionUID = 1L;
/** 业务类型名称(qms_main_business.businessName */
private String businessName;
/** 今日预约数量 */
private Long count;
}
@@ -0,0 +1,26 @@
package com.mhd.bi.domain.biPlatformRealData.repository.po;
import lombok.Data;
import java.io.Serializable;
/**
* 月台监控-月台车辆统计(按楼层分组)
* 数据来源:TEST_NGWL_YMS.QMS_WINDOW_INFO(楼层+月台)与 QMS_MAIN_BUSINESS(当日预约/作业)
*/
@Data
public class RealPlatformFloorStatPO implements Serializable {
private static final long serialVersionUID = 1L;
/** 楼层(从叫号月台 WINDOW_NAME 解析,如 S1-01 -> F1 */
private String floorNo;
/** 该楼层的月台数量 */
private Long platformCount;
/** 今日预约车辆数(按 WINDOW_NAME 关联楼层) */
private Long todayReservedVehicles;
/** 当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10 */
private Long operatingVehicles;
}
@@ -1,22 +1,30 @@
package com.mhd.bi.domain.biPlatformRealData.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mhd.bi.domain.biPlatformRealData.repository.mapper.BiPlatformRealDataMapper;
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.RealVehicleStatusPO;
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.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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
/**
@@ -30,6 +38,96 @@ public class BiPlatformRealDataService {
@Resource
private BiPlatformRealDataMapper biPlatformRealDataMapper;
@Resource
private BiSnapshotWriteMapper biSnapshotWriteMapper;
@Resource
private BiPlatformSurveillanceReportMapper biPlatformSurveillanceReportMapper;
@Resource
private ObjectMapper objectMapper;
private static final String REMARK_REALTIME = "realtime platform-surveillance";
/**
* 实时组装月台监测数据;仅当真实业务数据(YMS 库查出的字段)发生变化时,
* 才覆盖更新 BI_PLATFORM_SURVEILLANCE_SNAPSHOT 快照表最新一条后返回。
* 写死字段变化不触发更新;表中尚无记录时插入一条兜底。
*/
public PlatformSurveillanceVO buildRealTimePlatformSurveillanceAndPersist() {
PlatformSurveillanceVO vo = buildRealTimePlatformSurveillance();
try {
String fullJson = objectMapper.writeValueAsString(vo);
String fingerprint = realDataFingerprint(vo);
String latestJson = biPlatformSurveillanceReportMapper.selectLatestPayloadJson();
if (StringUtils.isNotBlank(latestJson)) {
PlatformSurveillanceVO latestVo = objectMapper.readValue(latestJson.trim(), PlatformSurveillanceVO.class);
if (Objects.equals(fingerprint, realDataFingerprint(latestVo))) {
log.info("BI 月台监测真实业务数据未变化,跳过落库");
return vo;
}
}
int rows = biSnapshotWriteMapper.updateLatestPlatformSurveillanceSnapshot(fullJson, REMARK_REALTIME);
if (rows < 1) {
// 表中无最新记录可更新,插入一条兜底
biSnapshotWriteMapper.insertPlatformSurveillanceSnapshot(fullJson, REMARK_REALTIME);
}
log.info("BI 月台监测实时数据已落库(覆盖最新, 数据变化), affectedRows={}", rows);
} catch (Exception e) {
log.error("BI 月台监测实时数据落库失败", e);
}
return vo;
}
/**
* 提取月台监测的「真实业务数据」指纹(仅含 YMS 库查出的字段),用于判断业务数据是否变化。
* 写死/随机字段不纳入指纹,故其变化不会触发更新。
*/
private String realDataFingerprint(PlatformSurveillanceVO vo) throws Exception {
Map<String, Object> fp = new LinkedHashMap<>();
if (vo.getPlatformOverview() != null) {
fp.put("totalPlatforms", vo.getPlatformOverview().getTotalPlatforms());
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
}
if (vo.getVehicleStatus() != null) {
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
}
if (vo.getMonthlyTaskStatistics() != null) {
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
}
if (vo.getVehicles() != null) {
List<Map<String, Object>> vehicles = new ArrayList<>();
for (PlatformVehicleItemVO v : vo.getVehicles()) {
Map<String, Object> m = new LinkedHashMap<>();
m.put("appointmentTime", v.getAppointmentTime());
m.put("workFloor", v.getWorkFloor());
m.put("plateNumber", v.getPlateNumber());
m.put("status", v.getStatus());
m.put("platformId", v.getPlatformId());
m.put("platformDuration", v.getPlatformDuration());
vehicles.add(m);
}
fp.put("vehicles", vehicles);
}
if (vo.getTaskLoadStatistics() != null) {
List<Map<String, Object>> loads = new ArrayList<>();
for (TaskLoadItemVO item : vo.getTaskLoadStatistics()) {
Map<String, Object> m = new LinkedHashMap<>();
m.put("time", item.getTime());
m.put("taskCount", item.getTaskCount());
loads.add(m);
}
fp.put("taskLoadStatistics", loads);
}
return objectMapper.writeValueAsString(fp);
}
public List<RealPlatformVehiclePO> queryVehicles() {
try {
return biPlatformRealDataMapper.queryVehicles();
@@ -106,12 +204,39 @@ public class BiPlatformRealDataService {
}
}
/**
* 今日预约-业务类型统计:按业务类型分组统计今日预约数量。
* 例:今日预约航空打板 3 条 → 返回 {businessName:"航空打板", count:3}
*/
public List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats() {
try {
return biPlatformRealDataMapper.queryTodayBusinessTypeStats();
} catch (Exception e) {
log.error("【YMS】统计今日业务类型失败: {}", e.getMessage(), e);
return java.util.Collections.emptyList();
}
}
/**
* 月台监控-按楼层统计月台车辆:返回 {floorNo, platformCount, todayReservedVehicles, operatingVehicles}
* 实时查 YMS 库,不落库。
*/
public List<RealPlatformFloorStatPO> queryPlatformFloorStats() {
try {
return biPlatformRealDataMapper.queryPlatformFloorStats();
} catch (Exception e) {
log.error("【YMS】月台监控按楼层统计失败: {}", e.getMessage(), e);
return java.util.Collections.emptyList();
}
}
/**
* 实时组装月台监测数据:真实字段查 YMS 库,写死字段保留静态值。
* 每次调用实时查库,不经过快照表。
*/
public PlatformSurveillanceVO buildRealTimePlatformSurveillance() {
Random r = new Random();
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖)
Random r = new Random(20260825L);
PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r);
// 作业车辆列表
@@ -13,6 +13,8 @@ public interface BiSnapshotWriteMapper {
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
int updateLatestPlatformSurveillanceSnapshot(@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);
@@ -150,7 +150,8 @@ public class BiReportSnapshotSyncService {
/** TODO 业务落地:部分字段改为真实数据,其余仍写死。 */
protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() {
Random r = new Random();
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖)
Random r = new Random(20260825L);
// 写死数据复用原 builder
PlatformSurveillanceVO template = BiSnapshotWeeklyRandomDataBuilder.platformSurveillance(r);
@@ -4,6 +4,8 @@ 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.biPlatformRealData.service.BiPlatformRealDataService;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO;
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO;
import com.mhd.bi.domain.biOverallOperation.service.BiOverallOperationReportService;
import com.mhd.bi.domain.biHkMacaoServiceZone.service.BiHkMacaoServiceZoneReportService;
import com.mhd.bi.domain.biTransportOperationZone.service.BiTransportOperationZoneReportService;
@@ -30,6 +32,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* BI 报表接口
*/
@@ -96,12 +100,32 @@ public class BiReportApi extends BaseController {
}
/**
* 月台监测指标查询(实时查 YMS 库,真实字段 + 写死字段)
* 月台监测指标查询(实时查 YMS 库,真实字段 + 写死字段),并落库一条到 BI_PLATFORM_SURVEILLANCE_SNAPSHOT
*/
@ApiOperation(value = "月台监测指标查询", notes = "每次调用实时查询 YMS 库组装;部分字段为真实业务数据,部分为写死数据")
@ApiOperation(value = "月台监测指标查询", notes = "每次调用实时查询 YMS 库组装并写入快照表;部分字段为真实业务数据,部分为写死数据")
@GetMapping("/platformSurveillance")
public BiApiResult<PlatformSurveillanceVO> platformSurveillance() {
PlatformSurveillanceVO data = biPlatformRealDataService.buildRealTimePlatformSurveillance();
PlatformSurveillanceVO data = biPlatformRealDataService.buildRealTimePlatformSurveillanceAndPersist();
return BiApiResult.ok(data);
}
/**
* 今日预约-业务类型统计(实时查 YMS 库,不落库)
*/
@ApiOperation(value = "今日预约业务类型统计", notes = "按业务类型分组统计今日预约数量,实时查询 YMS 库,不落库;例:航空打板 3 条")
@GetMapping("/businessTypeStats")
public BiApiResult<List<RealBusinessTypeStatPO>> businessTypeStats() {
List<RealBusinessTypeStatPO> data = biPlatformRealDataService.queryTodayBusinessTypeStats();
return BiApiResult.ok(data);
}
/**
* 月台监控-按楼层统计月台车辆(实时查 YMS 库,不落库)
*/
@ApiOperation(value = "月台车辆统计(按楼层)", notes = "按楼层统计月台数量、今日预约车辆、当前作业车辆,实时查询 YMS 库,不落库")
@GetMapping("/platformFloorStats")
public BiApiResult<List<RealPlatformFloorStatPO>> platformFloorStats() {
List<RealPlatformFloorStatPO> data = biPlatformRealDataService.queryPlatformFloorStats();
return BiApiResult.ok(data);
}
//园区物流大屏接口----------------------------------------------------------------------
+4 -4
View File
@@ -14,19 +14,19 @@ spring:
discovery:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
server-addr: 10.33.0.129:6010
# server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.5:6848
username: nacos
password: manhuoda@2023
#线上正式环境
# server-addr: 10.102.192.30:6848
server-addr: 10.102.192.31:6848
# username: nacos
# password: manhuoda@2023
config:
# server-addr: 127.0.0.1:8848
# 线上测试环境配置 容器名+端口号
server-addr: 10.33.0.129:6010
# server-addr: 10.102.192.30:6848
# server-addr: 10.33.0.129:6010
server-addr: 10.102.192.31:6848
username: nacos
password: manhuoda@2023
#线上正式环境
@@ -46,11 +46,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
</select>
<!-- 车辆状态统计:今日的统计(按创建时间 / 流程状态)
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME
FLOW_STATUS: 1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消 -->
<select id="queryVehicleStatusToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO">
SELECT
SUM(CASE WHEN TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
SUM(CASE WHEN TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayReservedVehicles,
SUM(CASE WHEN FLOW_STATUS = '1' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS notCheckedIn,
SUM(CASE WHEN FLOW_STATUS IN ('5','6','7','8','9','10') AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS operatingVehicles,
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
@@ -65,6 +66,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
</select>
<!-- 今日预约-业务名称统计:按 BUSINESS_NAME(业务名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
SELECT
BUSINESS_NAME AS businessName,
COUNT(1) AS count
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
WHERE BUSINESS_NAME IS NOT NULL
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
GROUP BY BUSINESS_NAME
ORDER BY COUNT(1) DESC
</select>
<!-- 月台监控-按楼层统计:楼层从叫号月台 WINDOW_NAME 解析(如 S1-01 / N1-02 -> F1),不依赖字母前缀,只取 - 前面那段的数字
platformCount 来自 QMS_WINDOW_INFOtodayReservedVehicles/operatingVehicles 来自 QMS_MAIN_BUSINESS(按 TARGET_DATE=今天) -->
<select id="queryPlatformFloorStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformFloorStatPO">
SELECT
'F' || SUBSTR(W.WINDOW_NAME, INSTR(W.WINDOW_NAME,'-')-1, 1) AS floorNo,
COUNT(DISTINCT W.WINDOW_NAME) AS platformCount,
COUNT(DISTINCT CASE
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE) THEN mb.CAR_NO
END) AS todayReservedVehicles,
COUNT(DISTINCT CASE
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
AND mb.FLOW_STATUS IN ('5','6','7','8','9','10')
THEN mb.CAR_NO
END) AS operatingVehicles
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO W
LEFT JOIN NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
ON mb.WINDOW_NAME = W.WINDOW_NAME
WHERE W.WINDOW_NAME LIKE '%-%'
GROUP BY SUBSTR(W.WINDOW_NAME, INSTR(W.WINDOW_NAME,'-')-1, 1)
ORDER BY 1 DESC
</select>
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
SELECT
@@ -18,6 +18,15 @@
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
</insert>
<update id="updateLatestPlatformSurveillanceSnapshot">
update NGWL_TEST_BI.BI_PLATFORM_SURVEILLANCE_SNAPSHOT
set PAYLOAD_JSON = #{payloadJson},
UPDATE_TIME = SYSDATE,
REMARK = #{remark}
where DEL_FLAG = 1
and ID = (select max(t.ID) from NGWL_TEST_BI.BI_PLATFORM_SURVEILLANCE_SNAPSHOT t where t.DEL_FLAG = 1)
</update>
<insert id="insertOverallOperationSnapshot">
insert into NGWL_TEST_BI.BI_OVERALL_OPERATION_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})