BI模块修改
This commit is contained in:
+10
-1
@@ -7,6 +7,9 @@ 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.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,9 +38,15 @@ public interface BiPlatformRealDataMapper {
|
||||
/** 任务负荷(今日 24 小时) */
|
||||
List<RealTaskLoadPO> queryTaskLoadToday();
|
||||
|
||||
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
|
||||
/** 今日预约-租户统计(按 tenantName 分组统计今日预约数量) */
|
||||
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
|
||||
|
||||
/** 今日作业准时率统计(total 今日预约总数;onTimeCount 今日准时车辆数) */
|
||||
RealOnTimeStatPO queryTodayOnTimeStats();
|
||||
|
||||
/** 任务类型统计(当月 OMS 运输订单按业务类型分组:1-跨境 2-国内) */
|
||||
List<RealTaskTypeStatPO> queryMonthTransportOrderByType();
|
||||
|
||||
/** 月台监控-按楼层统计月台车辆(楼层、月台数量、今日预约车辆、当前作业车辆) */
|
||||
List<RealPlatformFloorStatPO> queryPlatformFloorStats();
|
||||
|
||||
|
||||
+4
-4
@@ -5,15 +5,15 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 今日预约-业务类型统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
* 按业务类型分组统计今日预约数量
|
||||
* 今日预约-租户统计(真实数据,来自 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;
|
||||
/** 租户名称(qms_main_business.tenantName) */
|
||||
private String tenantName;
|
||||
|
||||
/** 今日预约数量 */
|
||||
private Long count;
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 本月任务平均时长 / 完成率统计(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
* avgDurationHours:累计 (EXIT_TIME - ENTRY_TIME) 小时数(仅 ENTRY_TIME/EXIT_TIME 都不为空时参与)
|
||||
* durationCount:参与平均时长统计的有效条数
|
||||
* completedCount:已出场(EXIT_TIME IS NOT NULL)且预约日期在本月的数量
|
||||
* totalCount:本月(TARGET_DATE)预约总数量
|
||||
*/
|
||||
@Data
|
||||
public class RealMonthlyTaskDurationPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 平均作业时长(小时) */
|
||||
private Double avgDurationHours;
|
||||
|
||||
/** 参与平均时长统计的有效条数 */
|
||||
private Long durationCount;
|
||||
|
||||
/** 本月已出场数量 */
|
||||
private Long completedCount;
|
||||
|
||||
/** 本月预约总数量(按 TARGET_DATE 统计) */
|
||||
private Long totalCount;
|
||||
}
|
||||
+20
@@ -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)
|
||||
* 准时率 = 今日实际进场时间在预约日期当天的车辆数 / 今日预约总车辆数 × 100%
|
||||
*/
|
||||
@Data
|
||||
public class RealOnTimeStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 今日预约总车辆数 */
|
||||
private Long total;
|
||||
|
||||
/** 今日准时车辆数(已进场且实际进场日期 = 预约日期) */
|
||||
private Long onTimeCount;
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 任务类型统计(真实数据,来自 NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER 运输订单)
|
||||
* 按业务类型 businessCategory 分组统计当月数量:1-跨境运输 2-国内运输
|
||||
*/
|
||||
@Data
|
||||
public class RealTaskTypeStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 业务类型:1-跨境 2-国内 */
|
||||
private Integer businessCategory;
|
||||
|
||||
/** 该类型当月单量 */
|
||||
private Long count;
|
||||
}
|
||||
+3
@@ -16,6 +16,9 @@ public class RealVehicleStatusPO implements Serializable {
|
||||
/** 当前未签到 */
|
||||
private Long notCheckedIn;
|
||||
|
||||
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
|
||||
private Long waiting;
|
||||
|
||||
/** 当前作业中 */
|
||||
private Long operatingVehicles;
|
||||
|
||||
|
||||
+147
-9
@@ -9,12 +9,17 @@ 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.biPlatformRealData.repository.po.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO;
|
||||
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 com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeStatisticsVO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskTypeCountItemVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -91,16 +96,23 @@ public class BiPlatformRealDataService {
|
||||
if (vo.getPlatformOverview() != null) {
|
||||
fp.put("totalPlatforms", vo.getPlatformOverview().getTotalPlatforms());
|
||||
fp.put("operatingPlatforms", vo.getPlatformOverview().getOperatingPlatforms());
|
||||
fp.put("currentOccupancyRate", vo.getPlatformOverview().getCurrentOccupancyRate());
|
||||
fp.put("todayTasks", vo.getPlatformOverview().getTodayTasks());
|
||||
}
|
||||
if (vo.getEfficiencyStatistics() != null) {
|
||||
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
|
||||
}
|
||||
if (vo.getVehicleStatus() != null) {
|
||||
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
|
||||
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
|
||||
fp.put("waiting", vo.getVehicleStatus().getWaiting());
|
||||
fp.put("operatingVehicles", vo.getVehicleStatus().getOperatingVehicles());
|
||||
fp.put("completedVehicles", vo.getVehicleStatus().getCompletedVehicles());
|
||||
}
|
||||
if (vo.getMonthlyTaskStatistics() != null) {
|
||||
fp.put("taskTotal", vo.getMonthlyTaskStatistics().getTaskTotal());
|
||||
fp.put("avgTaskDuration", vo.getMonthlyTaskStatistics().getAvgTaskDuration());
|
||||
fp.put("taskCompletionRate", vo.getMonthlyTaskStatistics().getTaskCompletionRate());
|
||||
}
|
||||
if (vo.getVehicles() != null) {
|
||||
List<Map<String, Object>> vehicles = new ArrayList<>();
|
||||
@@ -126,6 +138,21 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
fp.put("taskLoadStatistics", loads);
|
||||
}
|
||||
if (vo.getTaskTypeStatistics() != null) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
|
||||
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
|
||||
List<Map<String, Object>> types = new ArrayList<>();
|
||||
for (TaskTypeCountItemVO it : vo.getTaskTypeStatistics().getTaskTypes()) {
|
||||
Map<String, Object> tm = new LinkedHashMap<>();
|
||||
tm.put("type", it.getType());
|
||||
tm.put("count", it.getCount());
|
||||
types.add(tm);
|
||||
}
|
||||
m.put("taskTypes", types);
|
||||
}
|
||||
fp.put("taskTypeStatistics", m);
|
||||
}
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
|
||||
@@ -166,12 +193,34 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日作业准时率 = 准时车辆数 / 今日预约车辆总数 × 100%
|
||||
* 准时:今日(TARGET_DATE=今天)已进场且实际进场时间不超过该预约的预约结束时间 bookingEndTime;
|
||||
* 实际进场时间超过 bookingEndTime 视为不准时。
|
||||
* 今日预约总数为 0 时返回 0。
|
||||
*/
|
||||
public int calcTodayOnTimeRate() {
|
||||
try {
|
||||
RealOnTimeStatPO po = biPlatformRealDataMapper.queryTodayOnTimeStats();
|
||||
if (po == null) return 0;
|
||||
long total = po.getTotal() == null ? 0L : po.getTotal();
|
||||
long onTime = po.getOnTimeCount() == null ? 0L : po.getOnTimeCount();
|
||||
if (total <= 0) return 0;
|
||||
// 四舍五入到整数百分比
|
||||
return (int) Math.round(((double) onTime / (double) total) * 100.0);
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】计算今日作业准时率失败: {}", e.getMessage(), e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public RealVehicleStatusPO queryVehicleStatusToday() {
|
||||
try {
|
||||
RealVehicleStatusPO po = biPlatformRealDataMapper.queryVehicleStatusToday();
|
||||
if (po == null) po = new RealVehicleStatusPO();
|
||||
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
|
||||
if (po.getNotCheckedIn() == null) po.setNotCheckedIn(0L);
|
||||
if (po.getWaiting() == null) po.setWaiting(0L);
|
||||
if (po.getOperatingVehicles() == null) po.setOperatingVehicles(0L);
|
||||
if (po.getCompletedVehicles() == null) po.setCompletedVehicles(0L);
|
||||
return po;
|
||||
@@ -180,6 +229,7 @@ public class BiPlatformRealDataService {
|
||||
RealVehicleStatusPO po = new RealVehicleStatusPO();
|
||||
po.setTodayReservedVehicles(0L);
|
||||
po.setNotCheckedIn(0L);
|
||||
po.setWaiting(0L);
|
||||
po.setOperatingVehicles(0L);
|
||||
po.setCompletedVehicles(0L);
|
||||
return po;
|
||||
@@ -196,6 +246,21 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 本月任务平均时长 / 完成率统计:
|
||||
* - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
|
||||
* - taskCompletionRate:已完成(EXIT_TIME 不为空 且 预约日期在本月)/ 本月预约总数量 ×100
|
||||
* 任一查询失败均返回 null,由调用方决定是否覆盖模板值。
|
||||
*/
|
||||
public RealMonthlyTaskDurationPO queryMonthTaskStats() {
|
||||
try {
|
||||
return biPlatformRealDataMapper.queryMonthTaskStats();
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计本月任务平均时长/完成率失败: {}", e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<RealTaskLoadPO> queryTaskLoadToday() {
|
||||
try {
|
||||
return biPlatformRealDataMapper.queryTaskLoadToday();
|
||||
@@ -206,14 +271,50 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日预约-业务类型统计:按业务类型分组统计今日预约数量。
|
||||
* 例:今日预约航空打板 3 条 → 返回 {businessName:"航空打板", count:3}
|
||||
* 任务类型统计:当月 OMS 运输订单按业务类型分组(1-跨境运输,2-国内运输)。
|
||||
* 返回 {totalTasks: 当月跨境+国内运输总单量, taskTypes: [{type, count}]}
|
||||
* 查询失败时返回空结构,不影响写死字段。
|
||||
*/
|
||||
/**
|
||||
* 任务类型统计:固定输出「跨境运输」「国内运输」两类,count 取当月 OMS 业务单真实单量;
|
||||
* 当月无数据或查询失败时仍返回两类、count=0(不使用写死模板兜底)。
|
||||
*/
|
||||
public TaskTypeStatisticsVO queryMonthTransportOrderByType() {
|
||||
int crossBorder = 0; // 跨境运输 BUSINESS_CATEGORY=1
|
||||
int domestic = 0; // 国内运输 BUSINESS_CATEGORY=2
|
||||
try {
|
||||
List<RealTaskTypeStatPO> rows = biPlatformRealDataMapper.queryMonthTransportOrderByType();
|
||||
if (rows != null) {
|
||||
for (RealTaskTypeStatPO r : rows) {
|
||||
if (r == null || r.getBusinessCategory() == null || r.getCount() == null) {
|
||||
continue;
|
||||
}
|
||||
if (r.getBusinessCategory() == 1) {
|
||||
crossBorder = r.getCount().intValue();
|
||||
} else if (r.getBusinessCategory() == 2) {
|
||||
domestic = r.getCount().intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【OMS】统计当月运输订单业务类型失败: {}", e.getMessage(), e);
|
||||
// 失败时不回退写死模板,保持两类 count=0
|
||||
}
|
||||
List<TaskTypeCountItemVO> items = new ArrayList<>();
|
||||
items.add(TaskTypeCountItemVO.builder().type("跨境运输").count(crossBorder).build());
|
||||
items.add(TaskTypeCountItemVO.builder().type("国内运输").count(domestic).build());
|
||||
return TaskTypeStatisticsVO.builder().totalTasks(crossBorder + domestic).taskTypes(items).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日预约-租户统计:按租户名称分组统计今日预约数量。
|
||||
* 例:今日预约某租户 3 条 → 返回 {tenantName:"某租户", count:3}
|
||||
*/
|
||||
public List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats() {
|
||||
try {
|
||||
return biPlatformRealDataMapper.queryTodayBusinessTypeStats();
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计今日业务类型失败: {}", e.getMessage(), e);
|
||||
log.error("【YMS】统计今日租户预约失败: {}", e.getMessage(), e);
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -271,29 +372,63 @@ public class BiPlatformRealDataService {
|
||||
template.setVehicles(vehicleVos);
|
||||
|
||||
// 月台实时概览:真实数据源,无条件覆盖
|
||||
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用)
|
||||
// 月台占用率 = 占用 / 全部月台
|
||||
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
|
||||
// 作业准时率 = 今日(实际进场时间在预约日期当天的车辆数) / 今日预约车辆总数 × 100%
|
||||
if (template.getPlatformOverview() != null) {
|
||||
RealPlatformOverviewPO ov = queryPlatformOverview();
|
||||
int total = ov.getTotalPlatforms().intValue();
|
||||
int occ = ov.getOperatingPlatforms().intValue();
|
||||
List<RealPlatformInfoPO> platformList = queryPlatformInfoList();
|
||||
int total = platformList == null ? 0 : platformList.size();
|
||||
int occ = 0;
|
||||
if (platformList != null) {
|
||||
for (RealPlatformInfoPO p : platformList) {
|
||||
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
|
||||
occ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
|
||||
int todayTasks = (int) countTodayTasks();
|
||||
template.getPlatformOverview().setTotalPlatforms(total);
|
||||
template.getPlatformOverview().setOperatingPlatforms(occ);
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
template.getPlatformOverview().setTodayTasks((int) countTodayTasks());
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率:准时车辆数 / 今日预约总数 × 100%(今日总数为 0 时返回 0)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate());
|
||||
}
|
||||
}
|
||||
|
||||
// 作业车辆状态统计:真实数据源,无条件覆盖
|
||||
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 waiting = 今日预约且 已预约/已签到/已叫号)
|
||||
if (template.getVehicleStatus() != null) {
|
||||
RealVehicleStatusPO vs = queryVehicleStatusToday();
|
||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||
}
|
||||
|
||||
// 本月任务统计:taskTotal 有真实数据源无条件覆盖;YoY 等无真实数据源保留模板写死值
|
||||
// 本月任务统计: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);
|
||||
}
|
||||
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);
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
|
||||
} else {
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
|
||||
@@ -313,6 +448,9 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
// 任务类型统计:当月 OMS 业务单真实数据(固定跨境运输/国内运输两类,不使用写死模板兜底)
|
||||
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ public final class BiReportSnapshotMapperSupport {
|
||||
.platformOverview(PlatformOverviewVO.builder()
|
||||
.totalPlatforms(0).currentOccupancyRate(0d).operatingPlatforms(0).todayTasks(0).build())
|
||||
.vehicleStatus(VehicleStatusVO.builder()
|
||||
.todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build())
|
||||
.todayReservedVehicles(0).notCheckedIn(0).waiting(0).operatingVehicles(0).completedVehicles(0).build())
|
||||
.avgOperationDurationTrend(Collections.emptyList())
|
||||
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
||||
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
||||
|
||||
+46
-11
@@ -16,7 +16,7 @@ import com.mhd.bi.interfaces.facadeApi.biReport.vo.warehouseZone.WarehouseOperat
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformVehicleItemVO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.service.BiPlatformRealDataService;
|
||||
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.RealPlatformInfoPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealVehicleStatusPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -173,18 +173,33 @@ public class BiReportSnapshotSyncService {
|
||||
}
|
||||
|
||||
// ====== 真实数据:月台实时概览 ======
|
||||
RealPlatformOverviewPO ov = biPlatformRealDataService.queryPlatformOverview();
|
||||
// 总月台 / 占用月台 来源:YMS 月台管理列表 QMS_WINDOW_INFO(JOB_STATUS=1 表示占用)
|
||||
// 月台占用率 = 占用 / 全部月台
|
||||
// 今日作业任务 来源:QMS_MAIN_BUSINESS 按预约时间 TARGET_DATE = 今天 的全部数量
|
||||
if (template.getPlatformOverview() != null) {
|
||||
template.getPlatformOverview().setTotalPlatforms(ov.getTotalPlatforms().intValue());
|
||||
template.getPlatformOverview().setOperatingPlatforms(ov.getOperatingPlatforms().intValue());
|
||||
int total = ov.getTotalPlatforms().intValue();
|
||||
int occ = ov.getOperatingPlatforms().intValue();
|
||||
List<RealPlatformInfoPO> platformList = biPlatformRealDataService.queryPlatformInfoList();
|
||||
int total = platformList == null ? 0 : platformList.size();
|
||||
int occ = 0;
|
||||
if (platformList != null) {
|
||||
for (RealPlatformInfoPO p : platformList) {
|
||||
if (p != null && p.getJobStatus() != null && p.getJobStatus() == 1) {
|
||||
occ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
double rate = total > 0 ? Math.round(((double) occ / total) * 100.0 * 100.0) / 100.0 : 0d;
|
||||
int todayTasks = (int) biPlatformRealDataService.countTodayTasks();
|
||||
template.getPlatformOverview().setTotalPlatforms(total);
|
||||
template.getPlatformOverview().setOperatingPlatforms(occ);
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
}
|
||||
long todayTasks = biPlatformRealDataService.countTodayTasks();
|
||||
if (template.getPlatformOverview() != null) {
|
||||
template.getPlatformOverview().setTodayTasks((int) todayTasks);
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率 = 准时车辆数 / 今日预约总数 × 100%
|
||||
// 准时:今日(TARGET_DATE=今天)已进场且 ENTRY_TIME <= bookingEndTime(预约结束时间),超过视为不准时
|
||||
// 今日预约总数 = 0 时返回 0
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate());
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:作业车辆状态统计 ======
|
||||
@@ -192,14 +207,31 @@ public class BiReportSnapshotSyncService {
|
||||
if (template.getVehicleStatus() != null) {
|
||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||
template.getVehicleStatus().setOperatingVehicles(vs.getOperatingVehicles().intValue());
|
||||
template.getVehicleStatus().setCompletedVehicles(vs.getCompletedVehicles().intValue());
|
||||
}
|
||||
|
||||
// ====== 真实数据:本月任务统计 taskTotal ======
|
||||
// ====== 真实数据:本月任务统计 taskTotal / avgTaskDuration / taskCompletionRate ======
|
||||
long monthTasks = biPlatformRealDataService.countMonthTasks();
|
||||
if (template.getMonthlyTaskStatistics() != null) {
|
||||
template.getMonthlyTaskStatistics().setTaskTotal((int) monthTasks);
|
||||
com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyTaskDurationPO monthStats =
|
||||
biPlatformRealDataService.queryMonthTaskStats();
|
||||
if (monthStats != null) {
|
||||
if (monthStats.getAvgDurationHours() != null) {
|
||||
double v = monthStats.getAvgDurationHours();
|
||||
template.getMonthlyTaskStatistics().setAvgTaskDuration(Math.round(v * 100.0) / 100.0);
|
||||
}
|
||||
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);
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(rate);
|
||||
} else {
|
||||
template.getMonthlyTaskStatistics().setTaskCompletionRate(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:任务负荷(今日 24 小时) ======
|
||||
@@ -218,6 +250,9 @@ public class BiReportSnapshotSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:任务类型统计(当月 OMS 业务单,固定跨境运输/国内运输两类,不使用写死模板兜底) ======
|
||||
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -415,6 +415,7 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
static final int P_TASKS = 418;
|
||||
static final int P_RESV = 2_850;
|
||||
static final int P_NC = 920;
|
||||
static final int P_WAIT = 680;
|
||||
static final int P_OPV = 1_180;
|
||||
static final int P_DONE = 1_420;
|
||||
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
|
||||
|
||||
@@ -122,9 +122,9 @@ public class BiReportApi extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日预约-业务类型统计(实时查 YMS 库,不落库)
|
||||
* 今日预约-租户统计(实时查 YMS 库,不落库)
|
||||
*/
|
||||
@ApiOperation(value = "今日预约业务类型统计", notes = "按业务类型分组统计今日预约数量,实时查询 YMS 库,不落库;例:航空打板 3 条")
|
||||
@ApiOperation(value = "今日预约租户统计", notes = "按租户名称分组统计今日预约数量,实时查询 YMS 库,不落库;例:某租户 3 条")
|
||||
@GetMapping("/businessTypeStats")
|
||||
public BiApiResult<List<RealBusinessTypeStatPO>> businessTypeStats() {
|
||||
List<RealBusinessTypeStatPO> data = biPlatformRealDataService.queryTodayBusinessTypeStats();
|
||||
|
||||
+3
@@ -20,6 +20,9 @@ public class VehicleStatusVO {
|
||||
@ApiModelProperty("当前未签到,单位:辆")
|
||||
private Integer notCheckedIn;
|
||||
|
||||
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
|
||||
private Integer waiting;
|
||||
|
||||
@ApiModelProperty("当前作业中,单位:辆")
|
||||
private Integer operatingVehicles;
|
||||
|
||||
|
||||
@@ -40,43 +40,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
FROM NGWL_TEST_YMS.QMS_WINDOW_INFO
|
||||
</select>
|
||||
|
||||
<!-- 今日作业任务:实际进入时间是今日的 -->
|
||||
<!-- 今日作业任务:按预约时间 TARGET_DATE(今日)统计主业务记录数 -->
|
||||
<select id="countTodayTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE ENTRY_TIME IS NOT NULL
|
||||
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
</select>
|
||||
|
||||
<!-- 今日作业准时率统计:
|
||||
total 今日预约总车辆数(TARGET_DATE = 今天)
|
||||
onTimeCount 今日准时车辆数(已进场且实际进场时间不超过该预约的预约结束时间 BOOKING_END_TIME)
|
||||
「准时」= 今日(TARGET_DATE=今天)已进场且 ENTRY_TIME <= BOOKING_END_TIME;超过则视为不准时
|
||||
准时率 = onTimeCount / total × 100%
|
||||
-->
|
||||
<select id="queryTodayOnTimeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOnTimeStatPO">
|
||||
SELECT
|
||||
SUM(CASE WHEN TARGET_DATE IS NOT NULL AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS total,
|
||||
SUM(CASE WHEN ENTRY_TIME IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
AND ENTRY_TIME <= BOOKING_END_TIME
|
||||
THEN 1 ELSE 0 END) AS onTimeCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
</select>
|
||||
|
||||
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
|
||||
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
||||
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
||||
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(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 ('1','2','3') AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS waiting,
|
||||
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
|
||||
</select>
|
||||
|
||||
<!-- 本月任务量:实际进入时间是本月的 -->
|
||||
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
||||
<select id="countMonthTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE ENTRY_TIME IS NOT NULL
|
||||
AND TO_CHAR(ENTRY_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
</select>
|
||||
|
||||
<!-- 今日预约-业务名称统计:按 BUSINESS_NAME(业务名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
||||
<!-- 本月任务平均作业时长 / 完成率统计:
|
||||
avgDurationHours 平均时长(小时)= AVG((EXIT_TIME - ENTRY_TIME) * 24)
|
||||
仅 ENTRY_TIME 与 EXIT_TIME 都不为空时参与;
|
||||
durationCount 参与平均时长统计的有效条数;
|
||||
completedCount 本月(TARGET_DATE)已出场(EXIT_TIME IS NOT NULL)的数量;
|
||||
totalCount 本月(TARGET_DATE)预约总数量。
|
||||
-->
|
||||
<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 EXIT_TIME IS NOT NULL
|
||||
AND TARGET_DATE IS NOT NULL
|
||||
AND TO_CHAR(TARGET_DATE, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
THEN 1 ELSE 0 END) AS completedCount,
|
||||
SUM(CASE WHEN TARGET_DATE IS NOT NULL
|
||||
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
|
||||
</select>
|
||||
|
||||
<!-- 今日预约-租户统计:按 TENANT_NAME(租户名称)分组统计今日预约数量,按预约日期 TARGET_DATE 过滤 -->
|
||||
<select id="queryTodayBusinessTypeStats" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealBusinessTypeStatPO">
|
||||
SELECT
|
||||
BUSINESS_NAME AS businessName,
|
||||
COUNT(1) AS count
|
||||
TENANT_NAME AS tenantName,
|
||||
COUNT(1) AS count
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE BUSINESS_NAME IS NOT NULL
|
||||
WHERE TENANT_NAME IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
GROUP BY BUSINESS_NAME
|
||||
GROUP BY TENANT_NAME
|
||||
ORDER BY COUNT(1) DESC
|
||||
</select>
|
||||
|
||||
@@ -102,6 +145,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY 1 DESC
|
||||
</select>
|
||||
|
||||
<!-- 任务类型统计(运输订单,来自 NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER):
|
||||
当月(CREATE_TIME 在当前月)按业务类型 BUSINESS_CATEGORY 分组统计
|
||||
BUSINESS_CATEGORY: 1-跨境运输 2-国内运输 -->
|
||||
<select id="queryMonthTransportOrderByType" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskTypeStatPO">
|
||||
SELECT
|
||||
BUSINESS_CATEGORY AS businessCategory,
|
||||
COUNT(1) AS count
|
||||
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||
WHERE BUSINESS_CATEGORY IN (1, 2)
|
||||
AND CREATE_TIME IS NOT NULL
|
||||
AND TO_CHAR(CREATE_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
GROUP BY BUSINESS_CATEGORY
|
||||
ORDER BY BUSINESS_CATEGORY
|
||||
</select>
|
||||
|
||||
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
|
||||
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
|
||||
SELECT
|
||||
|
||||
Reference in New Issue
Block a user