BI大屏单表查询修改
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
package com.mhd.bi.domain.biComprehensive.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biReport.support.BiReportSnapshotMapperSupport;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO;
|
||||
|
||||
/**
|
||||
* 综合态势:SQL 见 BiComprehensiveReportMapper.xml;取数与组装均在 Mapper 层完成。
|
||||
*/
|
||||
public interface BiComprehensiveReportMapper {
|
||||
|
||||
String selectLatestPayloadJson();
|
||||
|
||||
/**
|
||||
* 最新快照 → VO(内部调用 {@link #selectLatestPayloadJson()})
|
||||
*/
|
||||
default ComprehensiveSituationVO loadLatestComprehensive() {
|
||||
return BiReportSnapshotMapperSupport.parsePayload(
|
||||
selectLatestPayloadJson(),
|
||||
ComprehensiveSituationVO.class,
|
||||
BiReportSnapshotMapperSupport::emptyComprehensiveSituation,
|
||||
"综合态势");
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.mhd.bi.domain.biComprehensive.service;
|
||||
|
||||
import com.mhd.bi.domain.biComprehensive.repository.mapper.BiComprehensiveReportMapper;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.ComprehensiveSituationVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 综合态势:数据访问仅经 Mapper(含 XML 内 SQL 与 Mapper 默认方法组装)。
|
||||
*/
|
||||
@Service
|
||||
public class BiComprehensiveReportService {
|
||||
|
||||
@Resource
|
||||
private BiComprehensiveReportMapper biComprehensiveReportMapper;
|
||||
|
||||
public ComprehensiveSituationVO loadLatestComprehensive() {
|
||||
return biComprehensiveReportMapper.loadLatestComprehensive();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.bi.domain.biPlatformSurveillance.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biReport.support.BiReportSnapshotMapperSupport;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
|
||||
|
||||
/**
|
||||
* 月台监测:SQL 见 BiPlatformSurveillanceReportMapper.xml;取数与组装均在 Mapper 层完成。
|
||||
*/
|
||||
public interface BiPlatformSurveillanceReportMapper {
|
||||
|
||||
String selectLatestPayloadJson();
|
||||
|
||||
default PlatformSurveillanceVO loadLatestPlatformSurveillance() {
|
||||
return BiReportSnapshotMapperSupport.parsePayload(
|
||||
selectLatestPayloadJson(),
|
||||
PlatformSurveillanceVO.class,
|
||||
BiReportSnapshotMapperSupport::emptyPlatformSurveillance,
|
||||
"月台监测");
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.mhd.bi.domain.biPlatformSurveillance.service;
|
||||
|
||||
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.PlatformSurveillanceVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class BiPlatformSurveillanceReportService {
|
||||
|
||||
@Resource
|
||||
private BiPlatformSurveillanceReportMapper biPlatformSurveillanceReportMapper;
|
||||
|
||||
public PlatformSurveillanceVO loadLatestPlatformSurveillance() {
|
||||
return biPlatformSurveillanceReportMapper.loadLatestPlatformSurveillance();
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.mhd.bi.domain.biReport.support;
|
||||
|
||||
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.platform.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Mapper 层使用的快照 JSON 解析与空态(SQL 仅定义在对应 Mapper.xml)
|
||||
*/
|
||||
@Slf4j
|
||||
public final class BiReportSnapshotMapperSupport {
|
||||
|
||||
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||
|
||||
private BiReportSnapshotMapperSupport() {
|
||||
}
|
||||
|
||||
public static <T> T parsePayload(String json, Class<T> type, Supplier<T> empty, String logLabel) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
return empty.get();
|
||||
}
|
||||
try {
|
||||
return MAPPER.readValue(json.trim(), type);
|
||||
} catch (Exception e) {
|
||||
log.warn("{} PAYLOAD_JSON 解析失败,返回空态", logLabel, e);
|
||||
return empty.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static ComprehensiveSituationVO emptyComprehensiveSituation() {
|
||||
return ComprehensiveSituationVO.builder()
|
||||
.valueAddedServiceIncome(0L)
|
||||
.inventoryTurnover(0)
|
||||
.orderCount(0)
|
||||
.vehicleUtilizationRate(0d)
|
||||
.fuelConsumptionPerHundredKm(0)
|
||||
.incomeTrend(Collections.emptyList())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static WarehouseTransportSituationVO emptyWarehouseTransportSituation() {
|
||||
return WarehouseTransportSituationVO.builder()
|
||||
.warehouseDistributionOnTimeRate(0d)
|
||||
.currentYearOrders(0L)
|
||||
.currentQuarterOrders(0)
|
||||
.currentMonthOrders(0)
|
||||
.warehouseOrderTrend(Collections.emptyList())
|
||||
.throughput(Collections.emptyList())
|
||||
.currentMonthTurnoverRate(0)
|
||||
.currentYearTurnoverRate(0)
|
||||
.inventoryTurnoverTrend(Collections.emptyList())
|
||||
.totalTransportIncome(0)
|
||||
.orderCount(0)
|
||||
.transportTrips(0)
|
||||
.annualTransportVolume(0)
|
||||
.transportOrderTotal(0)
|
||||
.crossBorderTransportOrder(0)
|
||||
.domesticTransportOrder(0)
|
||||
.transportTripsTrend(Collections.emptyList())
|
||||
.vehicleUtilizationRate(Collections.emptyList())
|
||||
.warehouseDockSyncRate(Collections.emptyList())
|
||||
.customerContributionRank(CustomerContributionRankVO.builder()
|
||||
.customerName(Collections.emptyList())
|
||||
.customerAmount(Collections.emptyList())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static PlatformSurveillanceVO emptyPlatformSurveillance() {
|
||||
return PlatformSurveillanceVO.builder()
|
||||
.vehicles(Collections.emptyList())
|
||||
.efficiencyStatistics(EfficiencyStatisticsVO.builder()
|
||||
.entryOvertimeRate(0).overtimeCount(0).platformOnTimeRate(0)
|
||||
.avgPlatformDuration(0d).yardOnTimeRate(0).avgYardDuration(0d).build())
|
||||
.platformOverview(PlatformOverviewVO.builder()
|
||||
.totalPlatforms(0).currentOccupancyRate(0).operatingPlatforms(0).todayTasks(0).build())
|
||||
.vehicleStatus(VehicleStatusVO.builder()
|
||||
.todayReservedVehicles(0).notCheckedIn(0).operatingVehicles(0).completedVehicles(0).build())
|
||||
.avgOperationDurationTrend(Collections.emptyList())
|
||||
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
||||
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
||||
.taskCompletionRate(0).completionRateYoY(0).build())
|
||||
.taskLoadStatistics(Collections.emptyList())
|
||||
.platformAlarmTrend(Collections.emptyList())
|
||||
.taskTypeStatistics(TaskTypeStatisticsVO.builder()
|
||||
.totalTasks(0).taskTypes(Collections.emptyList()).build())
|
||||
.platformAlarmStatistics(PlatformAlarmStatisticsVO.builder()
|
||||
.todayAlarmTotal(0).handled(0).unhandled(0).build())
|
||||
.platformAlarmDistribution(Collections.emptyList())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biReport.support.BiReportSnapshotMapperSupport;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO;
|
||||
|
||||
/**
|
||||
* 仓储运输:SQL 见 BiWarehouseTransportReportMapper.xml;取数与组装均在 Mapper 层完成。
|
||||
*/
|
||||
public interface BiWarehouseTransportReportMapper {
|
||||
|
||||
String selectLatestPayloadJson();
|
||||
|
||||
default WarehouseTransportSituationVO loadLatestWarehouseTransport() {
|
||||
return BiReportSnapshotMapperSupport.parsePayload(
|
||||
selectLatestPayloadJson(),
|
||||
WarehouseTransportSituationVO.class,
|
||||
BiReportSnapshotMapperSupport::emptyWarehouseTransportSituation,
|
||||
"仓储运输");
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.service;
|
||||
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportReportMapper;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class BiWarehouseTransportReportService {
|
||||
|
||||
@Resource
|
||||
private BiWarehouseTransportReportMapper biWarehouseTransportReportMapper;
|
||||
|
||||
public WarehouseTransportSituationVO loadLatestWarehouseTransport() {
|
||||
return biWarehouseTransportReportMapper.loadLatestWarehouseTransport();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user