BI月台指标字段修改
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
package com.mhd.bi.domain.biComprehensive.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO;
|
||||
|
||||
/**
|
||||
* 综合态势-真实业务数据 Mapper(跨库查询,与月台监测 BiPlatformRealDataMapper 同方案)
|
||||
*
|
||||
* <p>数据来源:</p>
|
||||
* <ul>
|
||||
* <li>运输订单量:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER(OMS 运输业务单)</li>
|
||||
* <li>百公里油耗:NGWL_TEST_WLHY.TMS_EXPENSE_REPORT(TMS 运输作业单,字段 FUEL_CONSUMPTION / HEAVYLOAD_MILEAGE)</li>
|
||||
* </ul>
|
||||
*/
|
||||
public interface BiComprehensiveRealDataMapper {
|
||||
|
||||
/**
|
||||
* 运输订单量:统计本年度(CREATE_TIME 在当前年)全部组织的运输业务单数量。
|
||||
* 统计范围:全部组织,不按机构过滤。
|
||||
*/
|
||||
Long countCurrentYearTransportOrders();
|
||||
|
||||
/**
|
||||
* 百公里油耗统计:统计本年度油耗量与重载里程均非空的记录,
|
||||
* 返回 总油耗量 / 总重载里程 / 参与条数,由调用方计算百公里油耗。
|
||||
*/
|
||||
RealFuelStatPO queryCurrentYearFuelStat();
|
||||
}
|
||||
+63
@@ -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 跨库查询)
|
||||
*
|
||||
* <p>实现方案与「月台监测指标查询」一致:每次调用实时查库,查不到/查库异常返回 0,不影响其它字段。</p>
|
||||
*/
|
||||
@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,保留一位小数。
|
||||
*
|
||||
* <p>统计范围:TMS 运输作业单 TMS_EXPENSE_REPORT,本年度、全部组织、油耗量与重载里程均非空。</p>
|
||||
* <p>总重载里程为 0 或查询失败时返回 0,避免除零。</p>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
-1
@@ -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 默认方法组装)。
|
||||
*
|
||||
* <p>其中「运输订单量」「百公里油耗」为实时查询业务库的真实数据,
|
||||
* 每次调用实时组装并覆盖更新快照表最新一条,实现方案与「月台监测指标查询」一致;</p>
|
||||
* <p>其余字段仍取自 BI_COMPREHENSIVE_SNAPSHOT 最新快照。</p>
|
||||
*
|
||||
* <p>仅当这两项实时数据发生变化时才覆盖更新快照,避免无意义的写库。</p>
|
||||
*/
|
||||
@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<String, Object> fp = new LinkedHashMap<>();
|
||||
if (vo == null) {
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
fp.put("orderCount", vo.getOrderCount());
|
||||
fp.put("fuelConsumptionPerHundredKm", vo.getFuelConsumptionPerHundredKm());
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-5
@@ -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)预约总数量(作为平均时长的分母)
|
||||
*
|
||||
* <p>任务平均作业时长 = totalWorkHours ÷ totalCount,由 Service 层计算。</p>
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -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;
|
||||
|
||||
|
||||
+71
-7
@@ -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<PlatformVehicleItemVO> 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<RealTaskLoadPO> 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<RealTaskLoadPO> loads = queryTaskLoadToday();
|
||||
if (loads.isEmpty()) {
|
||||
|
||||
+4
-3
@@ -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)
|
||||
|
||||
+3
@@ -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);
|
||||
|
||||
+20
-4
@@ -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);
|
||||
|
||||
+5
-3
@@ -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;
|
||||
|
||||
+4
-4
@@ -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<Integer> incomeTrend;
|
||||
|
||||
+3
@@ -25,4 +25,7 @@ public class PlatformOverviewVO {
|
||||
|
||||
@ApiModelProperty("今日作业任务,单位:个")
|
||||
private Integer todayTasks;
|
||||
|
||||
@ApiModelProperty("月台周转率,单位:%(今日已出场的记录数 ÷ 今日全部记录数 × 100)")
|
||||
private Double platformTurnoverRate;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveRealDataMapper">
|
||||
|
||||
<!-- 运输订单量:本年度、全部组织
|
||||
数据来源:OMS 运输业务单 NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||
统计口径:CREATE_TIME 在本年度;IS_DELETE = 0 表示未删除。
|
||||
注:若该表删除标记实际为 DEL_FLAG,请将下方 IS_DELETE 替换为 DEL_FLAG -->
|
||||
<select id="countCurrentYearTransportOrders" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||
WHERE CREATE_TIME IS NOT NULL
|
||||
AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
AND IS_DELETE = 0
|
||||
</select>
|
||||
|
||||
<!-- 百公里油耗:本年度、全部组织,油耗量与重载里程均非空的记录
|
||||
数据来源:TMS 运输作业单 NGWL_TEST_WLHY.TMS_EXPENSE_REPORT
|
||||
返回:总油耗量、总重载里程、参与条数(由 Service 层做除法)
|
||||
公式:百公里油耗 = 总油耗量(FUEL_CONSUMPTION) ÷ 总重载里程(HEAVYLOAD_MILEAGE) × 100 -->
|
||||
<select id="queryCurrentYearFuelStat" resultType="com.mhd.bi.domain.biComprehensive.repository.po.RealFuelStatPO">
|
||||
SELECT
|
||||
SUM(FUEL_CONSUMPTION) AS totalOil,
|
||||
SUM(HEAVYLOAD_MILEAGE) AS totalHeavyMileage,
|
||||
COUNT(1) AS totalCount
|
||||
FROM NGWL_TEST_WLHY.TMS_EXPENSE_REPORT
|
||||
WHERE FUEL_CONSUMPTION IS NOT NULL
|
||||
AND HEAVYLOAD_MILEAGE IS NOT NULL
|
||||
AND CREATE_TIME IS NOT NULL
|
||||
AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -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
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 月台概览:totalPlatforms(总条数)、operatingPlatforms(作业状态=占用,JOB_STATUS: 0空闲 1占用) -->
|
||||
<select id="queryPlatformOverview" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformOverviewPO">
|
||||
SELECT
|
||||
@@ -71,6 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
||||
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
||||
callStatusTotal 叫号状态合计:已签到 + 已叫号 + 已过号 = FLOW_STATUS IN ('2','3','4') 且 预约日期 = 今天
|
||||
todayExited 今日已出场:FLOW_STATUS = '11' 且 预约日期 = 今天(月台周转率的分子)
|
||||
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
|
||||
@@ -78,6 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
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 ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
|
||||
SUM(CASE WHEN FLOW_STATUS IN ('2','3','4') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS callStatusTotal,
|
||||
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS todayExited,
|
||||
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
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
@@ -85,6 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
||||
<select id="countMonthTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
@@ -93,21 +101,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
</select>
|
||||
|
||||
<!-- 本月任务平均作业时长 / 完成率统计:
|
||||
avgDurationHours 平均时长(小时)= AVG((EXIT_TIME - ENTRY_TIME) * 24)
|
||||
仅 ENTRY_TIME 与 EXIT_TIME 都不为空时参与;
|
||||
durationCount 参与平均时长统计的有效条数;
|
||||
completedCount 本月(TARGET_DATE)已出场(EXIT_TIME IS NOT NULL)的数量;
|
||||
totalCount 本月(TARGET_DATE)预约总数量。
|
||||
<!-- 本月任务平均作业时长 / 完成率统计(统计范围:本月 TARGET_DATE 在当月的记录):
|
||||
totalWorkHours 本月任务作业时长合计(小时):
|
||||
未进入月台 -> 0
|
||||
已进入且已离开 -> EXIT_TIME - ENTRY_TIME
|
||||
已进入但未离开 -> SYSDATE - ENTRY_TIME
|
||||
completedCount 本月已出场(EXIT_TIME IS NOT NULL)的数量;
|
||||
totalCount 本月预约总数量(作为平均时长的分母)。
|
||||
avgDurationHours 由 Service 层计算 = totalWorkHours ÷ totalCount(任务平均作业时长)
|
||||
-->
|
||||
<select id="queryMonthTaskStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO">
|
||||
SELECT
|
||||
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||
THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||
END) AS avgDurationHours,
|
||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS durationCount,
|
||||
SUM(CASE
|
||||
WHEN ENTRY_TIME IS NULL THEN 0
|
||||
WHEN EXIT_TIME IS NOT NULL THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||
ELSE (SYSDATE - ENTRY_TIME) * 24
|
||||
END) AS totalWorkHours,
|
||||
SUM(CASE WHEN EXIT_TIME IS NOT NULL
|
||||
AND TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
@@ -116,8 +125,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS totalCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, '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
|
||||
@@ -130,11 +142,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY COUNT(1) DESC
|
||||
</select>
|
||||
|
||||
<!-- 月台监控-按楼层统计:楼层从叫号月台 WINDOW_NAME 解析(如 S1-01 / N1-02 -> F1),不依赖字母前缀,只取 - 前面那段的数字
|
||||
platformCount 来自 QMS_WINDOW_INFO;todayReservedVehicles/operatingVehicles 来自 QMS_MAIN_BUSINESS(按 TARGET_DATE=今天) -->
|
||||
<!-- 月台监控-按楼层统计:
|
||||
floorNo 楼层号,取自月台表 QMS_WINDOW_INFO.PLATFORM_FLOOR(不再从 WINDOW_NAME 截取)
|
||||
platformCount 该楼层月台数量(QMS_WINDOW_INFO)
|
||||
todayReservedVehicles 该楼层今日预约车辆数(按预约时已选的月台/叫号月台关联楼层)
|
||||
operatingVehicles 该楼层当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10)
|
||||
说明:楼层维度以「月台表」为准;车辆预约时若已选月台(WINDOW_NAME 非空)即计入对应楼层,
|
||||
未选月台的车无法归属楼层,故不计入任何楼层(避免虚增)。 -->
|
||||
<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,
|
||||
W.PLATFORM_FLOOR AS floorNo,
|
||||
COUNT(DISTINCT W.WINDOW_NAME) AS platformCount,
|
||||
COUNT(DISTINCT CASE
|
||||
WHEN TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE) THEN mb.CAR_NO
|
||||
@@ -147,11 +164,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
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
|
||||
WHERE W.PLATFORM_FLOOR IS NOT NULL
|
||||
GROUP BY W.PLATFORM_FLOOR
|
||||
ORDER BY W.PLATFORM_FLOOR DESC
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 任务类型统计(来自 NGWL_TEST_YMS.QMS_MAIN_BUSINESS 预约登记表):
|
||||
按本月预约车辆数(TARGET_DATE 在当前月)按 BUSINESS_NAME 业务类型分组统计 -->
|
||||
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
|
||||
|
||||
@@ -8,6 +8,17 @@
|
||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||
</insert>
|
||||
|
||||
<!-- 覆盖更新综合态势快照最新一条(实时组装后落库,同月台监测) -->
|
||||
<update id="updateLatestComprehensiveSnapshot">
|
||||
update NGWL_TEST_BI.BI_COMPREHENSIVE_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_COMPREHENSIVE_SNAPSHOT t where t.DEL_FLAG = 1)
|
||||
</update>
|
||||
|
||||
|
||||
<insert id="insertWarehouseTransportSnapshot">
|
||||
insert into NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||
|
||||
Reference in New Issue
Block a user