Compare commits
16
Commits
7f6006ca48
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43b95f3f07 | ||
|
|
44f2579e3f | ||
|
|
ca5b6e4672 | ||
|
|
6b991363c6 | ||
|
|
84c7fa7647 | ||
|
|
c0d2faaaf1 | ||
|
|
8324d8dc31 | ||
|
|
6ce35b58e4 | ||
|
|
700556ea63 | ||
|
|
100a8d87ac | ||
|
|
b0c9a41f07 | ||
|
|
82d5eda139 | ||
|
|
07393e43ff | ||
|
|
08858f24d6 | ||
|
|
a994241400 | ||
|
|
a9be03961a |
@@ -20,7 +20,7 @@ import java.util.Set;
|
||||
* bms财务结算系统feign调用接口
|
||||
*/
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-bms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "${feign.url.mhd-bms-service:}",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "BmsService", value = ServiceNameConstants.BMS_SERVICE, url = "http://10.102.192.32:8019",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface BmsServiceFeign {
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-oms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "${feign.url.mhd-oms-service:}",fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "OmsService", value = ServiceNameConstants.OMS_SERVICE,url = "http://10.102.192.33:8017",fallbackFactory = RemoteOmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface OmsServiceFeign {
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-wlhy-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "${feign.url.mhd-wlhy-service:}",configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "commonWlhyServiceFeign",value = ServiceNameConstants.WLHY_SERVICE,url = "http://10.102.192.31:8014",configuration = FeignAutoConfiguration.class)
|
||||
public interface WlhyServiceFeign {
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
* @date 2024/5/10 8:58
|
||||
**/
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-wms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE,url = "${feign.url.mhd-wms-service:}",fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "remoteWmsServiceFeign",value = ServiceNameConstants.WMS_SERVICE,url = "http://10.102.192.32:8016",fallbackFactory = RemoteWmsFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface WmsServiceFeign {
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Map;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.xxl-job-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "${feign.url.xxl-job-service:}",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "XxlJobService", value = ServiceNameConstants.XXL_JOB_SERVICE,url = "http://10.102.192.33:8020",fallbackFactory = RemoteXxlJobFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface XxlJobServiceFeign {
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-yms-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "${feign.url.mhd-yms-service:}",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "YmsService", value = ServiceNameConstants.YMS_SERVICE,url = "http://10.102.192.33:8018",fallbackFactory = RemoteBmsFeignFallbackFactory.class, configuration = FeignAutoConfiguration.class)
|
||||
public interface YmsServiceFeign {
|
||||
|
||||
/**
|
||||
|
||||
+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();
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.mhd.bi.domain.biComprehensive.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 百公里油耗统计(真实数据,来自 TMS 运输作业单 TMS_EXPENSE_REPORT)
|
||||
*
|
||||
* <p>统计口径:本年度、全部组织、油耗量(FUEL_CONSUMPTION)与重载里程(HEAVYLOAD_MILEAGE)均非空的记录。</p>
|
||||
* <p>百公里油耗 = 总油耗量 ÷ 总重载里程 × 100</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealFuelStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 总油耗量(仅统计油耗量非空的记录) */
|
||||
private BigDecimal totalOil;
|
||||
|
||||
/** 总重载里程(仅统计重载里程非空的记录,且油量非空) */
|
||||
private BigDecimal totalHeavyMileage;
|
||||
|
||||
/** 参与统计的记录数 */
|
||||
private Long totalCount;
|
||||
}
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
+31
-1
@@ -10,6 +10,15 @@ 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.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +38,7 @@ public interface BiPlatformRealDataMapper {
|
||||
/** 今日作业任务数 */
|
||||
Long countTodayTasks();
|
||||
|
||||
/** 车辆状态统计(今日) */
|
||||
/** 车辆状态统计(今日,含叫号状态合计 callStatusTotal = 已签到+已叫号+已过号) */
|
||||
RealVehicleStatusPO queryVehicleStatusToday();
|
||||
|
||||
/** 本月任务量 */
|
||||
@@ -41,6 +50,27 @@ public interface BiPlatformRealDataMapper {
|
||||
/** 任务负荷(今日 24 小时) */
|
||||
List<RealTaskLoadPO> queryTaskLoadToday();
|
||||
|
||||
/** 近半年平均作业时长(按月分组:月台作业时长 / 园区作业时长 合计 + 任务数) */
|
||||
List<RealMonthlyAvgDurationPO> queryMonthlyAvgDuration();
|
||||
|
||||
/** 今日平均作业时长(月台作业平均时长 / 园区平均时长,仅统计两端时间都非空的记录) */
|
||||
RealTodayAvgDurationPO queryTodayAvgDuration();
|
||||
|
||||
/**
|
||||
* 今日月台作业超时统计(超时记录数 / 有效记录总数)。
|
||||
* 参考用时取自 YMS QMS_STATIC_FIELD.FIELD_CODE = 'platform_work_ref_minutes'
|
||||
*/
|
||||
RealOvertimeStatPO queryTodayOvertimeStat(@Param("refCode") String refCode);
|
||||
|
||||
/**
|
||||
* 今日园区作业超时统计(超时记录数 / 有效记录总数)。
|
||||
* 参考用时取自 YMS QMS_STATIC_FIELD.FIELD_CODE = 'yard_work_ref_minutes'
|
||||
*/
|
||||
RealOvertimeStatPO queryTodayYardOvertimeStat(@Param("refCode") String refCode);
|
||||
|
||||
/** 今日月台作业超时记录列表(月台名称 / 车牌号 / 超时时长) */
|
||||
List<RealOvertimeRecordPO> queryTodayOvertimeList(@Param("refCode") String refCode);
|
||||
|
||||
/** 今日预约-业务类型统计(按 businessName 分组统计今日预约数量) */
|
||||
List<RealBusinessTypeStatPO> queryTodayBusinessTypeStats();
|
||||
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 按月平均作业时长(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
*
|
||||
* <p>用于「平均作业时长」近半年趋势图,双系列:月台作业 / 园区作业。</p>
|
||||
* <ul>
|
||||
* <li>月台作业时长 = 离开月台时间(OUT_WINDOWS_TIME) - 进入月台时间(IN_WINDOWS_TIME)</li>
|
||||
* <li>园区作业时长 = 实际出场时间(EXIT_TIME) - 实际进入时间(ENTRY_TIME)</li>
|
||||
* </ul>
|
||||
* <p>各月平均 = 该月有效记录的时长合计 ÷ 该月任务数。</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealMonthlyAvgDurationPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 月份,格式 yyyy-MM */
|
||||
private String monthOfYear;
|
||||
|
||||
/** 该月任务数(预约记录数,作为平均时长的分母) */
|
||||
private Long taskCount;
|
||||
|
||||
/** 该月月台作业时长合计(小时);未进入月台计 0,已进入未离开按 SYSDATE - IN_WINDOWS_TIME */
|
||||
private Double platformWorkHours;
|
||||
|
||||
/** 该月园区作业时长合计(小时);未进场计 0,已进场未出场按 SYSDATE - ENTRY_TIME */
|
||||
private Double yardWorkHours;
|
||||
}
|
||||
+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 - IN_WINDOWS_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;
|
||||
}
|
||||
}
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 今日月台作业超时记录(真实数据)
|
||||
*
|
||||
* <p>用于「超时记录列表」:月台名称 / 车牌号码 / 超时时长(分钟)。</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealOvertimeRecordPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 月台名称 */
|
||||
private String windowName;
|
||||
|
||||
/** 车牌号码 */
|
||||
private String carNo;
|
||||
|
||||
/** 超时时长(分钟)= 月台作业时长 - 参考用时 */
|
||||
private Long overtimeMinutes;
|
||||
|
||||
/** 月台作业参考用时(分钟) */
|
||||
private Long refMinutes;
|
||||
|
||||
/** 月台作业时长(分钟) */
|
||||
private Long platformMinutes;
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 今日作业超时统计(月台作业 / 园区作业 通用)
|
||||
*
|
||||
* <p>分母只计入「能取到参考用时 且 作业时长两端时间都非空」的记录。</p>
|
||||
* <ul>
|
||||
* <li>月台作业:参考用时 code = platform_work_ref_minutes;
|
||||
* 时长 = OUT_WINDOWS_TIME - IN_WINDOWS_TIME</li>
|
||||
* <li>园区作业:参考用时 code = yard_work_ref_minutes;
|
||||
* 时长 = EXIT_TIME - ENTRY_TIME</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Data
|
||||
public class RealOvertimeStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 超时记录数:作业时长 > 参考用时 */
|
||||
private Long overtimeCount;
|
||||
|
||||
/** 有效记录总数(分母) */
|
||||
private Long totalCount;
|
||||
}
|
||||
+4
@@ -23,4 +23,8 @@ public class RealPlatformFloorStatPO implements Serializable {
|
||||
|
||||
/** 当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10) */
|
||||
private Long operatingVehicles;
|
||||
|
||||
/** 该楼层月台作业平均时长(分钟)= SUM(该楼层有效月台作业时长) ÷ 该楼层有效记录数 */
|
||||
private Double avgPlatformMinutes;
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -4,15 +4,17 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 任务负荷统计(按小时,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
* 任务负荷统计(按 2 小时分组,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
*
|
||||
* <p>「小时趋势」需求:每 2 小时分组统计一次,按车辆进入月台时间 IN_WINDOWS_TIME 分桶。</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealTaskLoadPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 0-23 小时 */
|
||||
/** 2 小时分组的起始小时,取值 0,2,4,...,22 */
|
||||
private Integer hourOfDay;
|
||||
|
||||
/** 该小时段任务数 */
|
||||
/** 该 2 小时时段任务数 */
|
||||
private Long taskCount;
|
||||
}
|
||||
}
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.mhd.bi.domain.biPlatformRealData.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 今日平均作业时长(真实数据,来自 TEST_NGWL_YMS.QMS_MAIN_BUSINESS)
|
||||
*
|
||||
* <p>用于「效率统计(本日)」中的:</p>
|
||||
* <ul>
|
||||
* <li>月台作业平均时长 avgPlatformDurationHours</li>
|
||||
* <li>园区平均时长 avgYardDurationHours</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>统计范围:今日预约记录(TARGET_DATE = 今天),且只统计时长两端的字段都非空的记录:</p>
|
||||
* <ul>
|
||||
* <li>月台作业时长 = 离开月台时间(OUT_WINDOWS_TIME) - 进入月台时间(IN_WINDOWS_TIME)
|
||||
* → 只统计 IN_WINDOWS_TIME 与 OUT_WINDOWS_TIME 都非空的记录</li>
|
||||
* <li>园区作业时长 = 实际出场时间(EXIT_TIME) - 实际进入时间(ENTRY_TIME)
|
||||
* → 只统计 ENTRY_TIME 与 EXIT_TIME 都非空的记录</li>
|
||||
* </ul>
|
||||
* <p>平均时长 = 有效记录时长合计 ÷ 有效记录数,由 Service 层或 SQL 直接完成。</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealTodayAvgDurationPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 月台作业平均时长(小时),仅统计同时有进入与离开月台时间的记录 */
|
||||
private Double avgPlatformDurationHours;
|
||||
|
||||
/** 园区平均时长(小时),仅统计同时有实际进入与实际出场时间的记录 */
|
||||
private Double avgYardDurationHours;
|
||||
}
|
||||
+6
@@ -19,6 +19,12 @@ public class RealVehicleStatusPO implements Serializable {
|
||||
/** 当前等待作业(FLOW_STATUS IN '1','2','3' 已预约/已签到/已叫号) */
|
||||
private Long waiting;
|
||||
|
||||
/** 叫号状态合计:已签到 + 已叫号 + 已过号(FLOW_STATUS IN '2','3','4',预约日期为今天) */
|
||||
private Long callStatusTotal;
|
||||
|
||||
/** 今日已出场(FLOW_STATUS = '11',预约日期为今天),用于月台周转率 */
|
||||
private Long todayExited;
|
||||
|
||||
/** 当前作业中 */
|
||||
private Long operatingVehicles;
|
||||
|
||||
|
||||
+287
-23
@@ -12,11 +12,23 @@ 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.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO;
|
||||
import com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO;
|
||||
|
||||
import com.mhd.bi.domain.biPlatformSurveillance.repository.mapper.BiPlatformSurveillanceReportMapper;
|
||||
import com.mhd.bi.domain.biStaticField.service.BiStaticFieldService;
|
||||
|
||||
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.AvgOperationDurationTrendItemVO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.OvertimeRecordItemVO;
|
||||
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;
|
||||
@@ -98,17 +110,27 @@ 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());
|
||||
}
|
||||
// 入园超时率/超时数量 按业务要求恒为 0,不纳入指纹
|
||||
// 准时率与平均时长为实时业务数据,纳入指纹
|
||||
if (vo.getEfficiencyStatistics() != null) {
|
||||
fp.put("platformOnTimeRate", vo.getEfficiencyStatistics().getPlatformOnTimeRate());
|
||||
fp.put("yardOnTimeRate", vo.getEfficiencyStatistics().getYardOnTimeRate());
|
||||
fp.put("avgPlatformDuration", vo.getEfficiencyStatistics().getAvgPlatformDuration());
|
||||
fp.put("avgYardDuration", vo.getEfficiencyStatistics().getAvgYardDuration());
|
||||
}
|
||||
if (vo.getVehicleStatus() != null) {
|
||||
fp.put("todayReservedVehicles", vo.getVehicleStatus().getTodayReservedVehicles());
|
||||
fp.put("notCheckedIn", vo.getVehicleStatus().getNotCheckedIn());
|
||||
fp.put("waiting", vo.getVehicleStatus().getWaiting());
|
||||
fp.put("callStatusTotal", vo.getVehicleStatus().getCallStatusTotal());
|
||||
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());
|
||||
@@ -138,7 +160,34 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
fp.put("taskLoadStatistics", loads);
|
||||
}
|
||||
if (vo.getAvgOperationDurationTrend() != null) {
|
||||
|
||||
|
||||
List<Map<String, Object>> trend = new ArrayList<>();
|
||||
for (AvgOperationDurationTrendItemVO item : vo.getAvgOperationDurationTrend()) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("month", item.getMonth());
|
||||
m.put("yardDuration", item.getYardDuration());
|
||||
m.put("platformDuration", item.getPlatformDuration());
|
||||
trend.add(m);
|
||||
}
|
||||
fp.put("avgOperationDurationTrend", trend);
|
||||
}
|
||||
fp.put("taskOvertimeRate", vo.getTaskOvertimeRate());
|
||||
if (vo.getOvertimeRecords() != null) {
|
||||
List<Map<String, Object>> recs = new ArrayList<>();
|
||||
for (OvertimeRecordItemVO r : vo.getOvertimeRecords()) {
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("windowName", r.getWindowName());
|
||||
m.put("carNo", r.getCarNo());
|
||||
m.put("overtimeMinutes", r.getOvertimeMinutes());
|
||||
recs.add(m);
|
||||
}
|
||||
fp.put("overtimeRecords", recs);
|
||||
}
|
||||
|
||||
if (vo.getTaskTypeStatistics() != null) {
|
||||
|
||||
Map<String, Object> m = new LinkedHashMap<>();
|
||||
m.put("totalTasks", vo.getTaskTypeStatistics().getTotalTasks());
|
||||
if (vo.getTaskTypeStatistics().getTaskTypes() != null) {
|
||||
@@ -226,6 +275,8 @@ public class BiPlatformRealDataService {
|
||||
if (po.getTodayReservedVehicles() == null) po.setTodayReservedVehicles(0L);
|
||||
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;
|
||||
@@ -235,13 +286,19 @@ public class BiPlatformRealDataService {
|
||||
po.setTodayReservedVehicles(0L);
|
||||
po.setNotCheckedIn(0L);
|
||||
po.setWaiting(0L);
|
||||
po.setCallStatusTotal(0L);
|
||||
po.setTodayExited(0L);
|
||||
po.setOperatingVehicles(0L);
|
||||
po.setCompletedVehicles(0L);
|
||||
return po;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public long countMonthTasks() {
|
||||
|
||||
|
||||
try {
|
||||
Long n = biPlatformRealDataMapper.countMonthTasks();
|
||||
return n == null ? 0L : n;
|
||||
@@ -253,19 +310,31 @@ public class BiPlatformRealDataService {
|
||||
|
||||
/**
|
||||
* 本月任务平均时长 / 完成率统计:
|
||||
* - avgDurationHours:累计(EXIT_TIME - ENTRY_TIME)小时数 / 参与数;任一为空的行不参与
|
||||
* - totalWorkHours:本月任务作业时长合计(小时);未进入月台计 0,已进入未离开按 SYSDATE - IN_WINDOWS_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();
|
||||
@@ -392,31 +461,59 @@ public class BiPlatformRealDataService {
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率(实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100% 取整)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(calcTodayOnTimeRate());
|
||||
}
|
||||
// 作业准时率:任务超时率 + 月台作业准时率 = 100%(需求约定)
|
||||
// 月台作业准时率 = 100 - 月台作业超时率
|
||||
double platformOvertime = calcTodayTaskOvertimeRate();
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(
|
||||
(int) Math.round(100.0 - platformOvertime));
|
||||
// 园区作业准时率 = 100 - 园区作业超时率
|
||||
double yardOvertime = calcTodayYardOvertimeRate();
|
||||
template.getEfficiencyStatistics().setYardOnTimeRate(
|
||||
(int) Math.round(100.0 - yardOvertime));
|
||||
}
|
||||
|
||||
|
||||
// 平均作业时长(本日):月台作业平均时长 / 园区平均时长(真实数据,仅统计两端时间都非空的今日记录)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
RealTodayAvgDurationPO avg = queryTodayAvgDuration();
|
||||
template.getEfficiencyStatistics().setAvgPlatformDuration(avg.getAvgPlatformDurationHours());
|
||||
template.getEfficiencyStatistics().setAvgYardDuration(avg.getAvgYardDurationHours());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 作业车辆状态统计:真实数据源,无条件覆盖(含等待作业 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().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();
|
||||
@@ -429,41 +526,208 @@ public class BiPlatformRealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
// 任务负荷:有真实数据源;真实为空则清空不用模板模拟,有数据则按真实小时覆盖
|
||||
// 平均装卸时长按业务要求恒为 0,不用真实值覆盖
|
||||
|
||||
|
||||
|
||||
// 小时趋势(今日,每 2 小时分组):有真实数据源则按真实分桶重建,无数据则清空
|
||||
List<RealTaskLoadPO> loads = queryTaskLoadToday();
|
||||
if (loads.isEmpty()) {
|
||||
template.setTaskLoadStatistics(new ArrayList<>());
|
||||
} else if (template.getTaskLoadStatistics() != null) {
|
||||
Map<Integer, Long> hourMap = new HashMap<>();
|
||||
} else {
|
||||
Map<Integer, Long> bucketMap = new HashMap<>();
|
||||
for (RealTaskLoadPO l : loads) {
|
||||
hourMap.put(l.getHourOfDay(), l.getTaskCount());
|
||||
}
|
||||
for (TaskLoadItemVO item : template.getTaskLoadStatistics()) {
|
||||
Integer hour = parseHourFromLabel(item.getTime());
|
||||
if (hour != null && hourMap.containsKey(hour)) {
|
||||
item.setTaskCount(hourMap.get(hour).intValue());
|
||||
if (l != null && l.getHourOfDay() != null) {
|
||||
bucketMap.put(l.getHourOfDay(), l.getTaskCount() == null ? 0L : l.getTaskCount());
|
||||
}
|
||||
}
|
||||
// 固定输出 0,2,4,...,22 共 12 个桶,无数据桶补 0,保证前端坐标轴连续
|
||||
List<TaskLoadItemVO> items = new ArrayList<>();
|
||||
for (int h = 0; h < 24; h += 2) {
|
||||
Long cnt = bucketMap.get(h);
|
||||
items.add(TaskLoadItemVO.builder()
|
||||
.time(String.format("%02d:00", h))
|
||||
.taskCount(cnt == null ? 0 : cnt.intValue())
|
||||
.build());
|
||||
}
|
||||
template.setTaskLoadStatistics(items);
|
||||
}
|
||||
|
||||
|
||||
// 任务类型统计:本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组(真实业务数据)
|
||||
template.setTaskTypeStatistics(queryMonthTransportOrderByType());
|
||||
|
||||
// 平均作业时长趋势:近半年按月统计(月台作业平均时长 / 园区作业平均时长)
|
||||
template.setAvgOperationDurationTrend(queryAvgOperationDurationTrend());
|
||||
|
||||
// 任务超时率 + 月台作业超时记录列表(依赖 YMS QMS_STATIC_FIELD 参考用时配置)
|
||||
template.setTaskOvertimeRate(calcTodayTaskOvertimeRate());
|
||||
template.setOvertimeRecords(queryTodayOvertimeRecords());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
private static Integer parseHourFromLabel(String label) {
|
||||
if (label == null) return null;
|
||||
|
||||
|
||||
/**
|
||||
* 今日平均作业时长(效率统计-本日),保留两位小数,单位:小时。
|
||||
* - avgPlatformDurationHours:月台作业平均时长;仅统计同时有进入与离开月台时间的今日记录
|
||||
* - avgYardDurationHours: 园区平均时长;仅统计同时有实际进入与实际出场时间的今日记录
|
||||
* 查询失败或无有效记录时返回 0。
|
||||
*/
|
||||
public RealTodayAvgDurationPO queryTodayAvgDuration() {
|
||||
RealTodayAvgDurationPO po = new RealTodayAvgDurationPO();
|
||||
po.setAvgPlatformDurationHours(0d);
|
||||
po.setAvgYardDurationHours(0d);
|
||||
try {
|
||||
String s = label.replace("时", "").trim();
|
||||
return Integer.parseInt(s);
|
||||
RealTodayAvgDurationPO row = biPlatformRealDataMapper.queryTodayAvgDuration();
|
||||
if (row != null) {
|
||||
if (row.getAvgPlatformDurationHours() != null) {
|
||||
po.setAvgPlatformDurationHours(
|
||||
Math.round(row.getAvgPlatformDurationHours() * 100.0) / 100.0);
|
||||
}
|
||||
if (row.getAvgYardDurationHours() != null) {
|
||||
po.setAvgYardDurationHours(
|
||||
Math.round(row.getAvgYardDurationHours() * 100.0) / 100.0);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
log.error("【YMS】统计今日平均作业时长失败: {}", e.getMessage(), e);
|
||||
}
|
||||
return po;
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日任务超时率(%)= 超时记录数 ÷ 有效记录总数 × 100%,保留两位小数。
|
||||
* 有效记录:月台已配置参考用时(platform_work_ref_minutes),且该记录同时有进入/离开月台时间。
|
||||
* 无有效记录时返回 0。
|
||||
*/
|
||||
public double calcTodayTaskOvertimeRate() {
|
||||
try {
|
||||
RealOvertimeStatPO po = biPlatformRealDataMapper
|
||||
.queryTodayOvertimeStat(BiStaticFieldService.CODE_PLATFORM_WORK_REF_MINUTES);
|
||||
return calcRateFromStat(po);
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计今日任务超时率失败: {}", e.getMessage(), e);
|
||||
return 0d;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日园区作业超时率(%)= 园区作业时长 > 园区参考用时的记录数 ÷ 有效记录总数 × 100%。
|
||||
* 有效记录:能取到园区参考用时(yard_work_ref_minutes),且记录同时有实际进入/实际出场时间。
|
||||
* 无有效记录时返回 0。
|
||||
*/
|
||||
public double calcTodayYardOvertimeRate() {
|
||||
try {
|
||||
RealOvertimeStatPO po = biPlatformRealDataMapper
|
||||
.queryTodayYardOvertimeStat(BiStaticFieldService.CODE_YARD_WORK_REF_MINUTES);
|
||||
return calcRateFromStat(po);
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计今日园区作业超时率失败: {}", e.getMessage(), e);
|
||||
return 0d;
|
||||
}
|
||||
}
|
||||
|
||||
/** 由超时统计 PO 计算百分比,保留两位小数;无有效记录返回 0 */
|
||||
private static double calcRateFromStat(RealOvertimeStatPO po) {
|
||||
if (po == null) {
|
||||
return 0d;
|
||||
}
|
||||
long total = po.getTotalCount() == null ? 0L : po.getTotalCount();
|
||||
long overtime = po.getOvertimeCount() == null ? 0L : po.getOvertimeCount();
|
||||
if (total <= 0) {
|
||||
return 0d;
|
||||
}
|
||||
return Math.round(((double) overtime / (double) total) * 100.0 * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 今日月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟)。
|
||||
* 查询失败返回空列表。
|
||||
*/
|
||||
public List<OvertimeRecordItemVO> queryTodayOvertimeRecords() {
|
||||
List<OvertimeRecordItemVO> result = new ArrayList<>();
|
||||
try {
|
||||
List<RealOvertimeRecordPO> rows = biPlatformRealDataMapper
|
||||
.queryTodayOvertimeList(BiStaticFieldService.CODE_PLATFORM_WORK_REF_MINUTES);
|
||||
|
||||
if (rows == null) {
|
||||
return result;
|
||||
}
|
||||
for (RealOvertimeRecordPO r : rows) {
|
||||
if (r == null) {
|
||||
continue;
|
||||
}
|
||||
result.add(OvertimeRecordItemVO.builder()
|
||||
.windowName(r.getWindowName())
|
||||
.carNo(r.getCarNo())
|
||||
.overtimeMinutes(r.getOvertimeMinutes())
|
||||
.refMinutes(r.getRefMinutes())
|
||||
.platformMinutes(r.getPlatformMinutes())
|
||||
.build());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】查询今日月台作业超时记录失败: {}", e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 近半年「平均作业时长」趋势(近 6 个月,按月正序,含无数据月份补 0):
|
||||
|
||||
|
||||
* - platformDuration:月台作业平均时长 = SUM(月台作业时长) ÷ 该月任务数
|
||||
* - yardDuration: 园区作业平均时长 = SUM(园区作业时长) ÷ 该月任务数
|
||||
* 均保留两位小数,单位:小时。
|
||||
*/
|
||||
public List<AvgOperationDurationTrendItemVO> queryAvgOperationDurationTrend() {
|
||||
List<AvgOperationDurationTrendItemVO> result = new ArrayList<>();
|
||||
Map<String, RealMonthlyAvgDurationPO> map = new HashMap<>();
|
||||
try {
|
||||
List<RealMonthlyAvgDurationPO> rows = biPlatformRealDataMapper.queryMonthlyAvgDuration();
|
||||
if (rows != null) {
|
||||
for (RealMonthlyAvgDurationPO r : rows) {
|
||||
if (r != null && r.getMonthOfYear() != null) {
|
||||
map.put(r.getMonthOfYear().trim(), r);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】统计近半年平均作业时长失败: {}", e.getMessage(), e);
|
||||
return result;
|
||||
}
|
||||
|
||||
// 生成近 6 个月的标签(含当前月),保证无数据月份也返回一条(值为 0)
|
||||
java.time.LocalDate now = java.time.LocalDate.now();
|
||||
java.time.format.DateTimeFormatter keyFmt = java.time.format.DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
for (int i = 5; i >= 0; i--) {
|
||||
java.time.LocalDate m = now.minusMonths(i);
|
||||
String key = m.format(keyFmt);
|
||||
RealMonthlyAvgDurationPO po = map.get(key);
|
||||
AvgOperationDurationTrendItemVO item = new AvgOperationDurationTrendItemVO();
|
||||
// 展示用月份标签,如 "9月"
|
||||
item.setMonth(m.getMonthValue() + "月");
|
||||
if (po != null) {
|
||||
long cnt = po.getTaskCount() == null ? 0L : po.getTaskCount();
|
||||
double platformHours = po.getPlatformWorkHours() == null ? 0d : po.getPlatformWorkHours();
|
||||
double yardHours = po.getYardWorkHours() == null ? 0d : po.getYardWorkHours();
|
||||
item.setPlatformDuration(cnt > 0
|
||||
? Math.round((platformHours / (double) cnt) * 100.0) / 100.0 : 0d);
|
||||
item.setYardDuration(cnt > 0
|
||||
? Math.round((yardHours / (double) cnt) * 100.0) / 100.0 : 0d);
|
||||
} else {
|
||||
item.setPlatformDuration(0d);
|
||||
item.setYardDuration(0d);
|
||||
}
|
||||
result.add(item);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* FLOW_STATUS 数字转中文:1已预约 2已签到 3已叫号 4已过号 5已进场 6已称重 7已装车 8二次称重 9已结算 10已还卡 11已出场 12已取消
|
||||
|
||||
*/
|
||||
private static String translateFlowStatus(String flowStatus) {
|
||||
if (flowStatus == null) return null;
|
||||
|
||||
+9
-4
@@ -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,9 +85,12 @@ 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).operatingVehicles(0).completedVehicles(0).build())
|
||||
.todayReservedVehicles(0).notCheckedIn(0).waiting(0)
|
||||
.callStatusTotal(0)
|
||||
.operatingVehicles(0).completedVehicles(0).build())
|
||||
.avgOperationDurationTrend(Collections.emptyList())
|
||||
.monthlyTaskStatistics(MonthlyTaskStatisticsVO.builder()
|
||||
.taskTotal(0).taskTotalYoY(0).avgTaskDuration(0d).avgDurationYoY(0)
|
||||
@@ -99,6 +102,8 @@ public final class BiReportSnapshotMapperSupport {
|
||||
.platformAlarmStatistics(PlatformAlarmStatisticsVO.builder()
|
||||
.todayAlarmTotal(0).handled(0).unhandled(0).build())
|
||||
.platformAlarmDistribution(Collections.emptyList())
|
||||
.taskOvertimeRate(0d)
|
||||
.overtimeRecords(Collections.emptyList())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -9,8 +9,13 @@ 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 updateLatestWarehouseTransportSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||
|
||||
int insertPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||
|
||||
int updateLatestPlatformSurveillanceSnapshot(@Param("payloadJson") String payloadJson, @Param("remark") String remark);
|
||||
|
||||
+88
-28
@@ -19,6 +19,8 @@ import com.mhd.bi.domain.biPlatformRealData.repository.po.RealPlatformVehiclePO;
|
||||
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 com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -45,6 +47,8 @@ public class BiReportSnapshotSyncService {
|
||||
private final BiSnapshotWriteMapper biSnapshotWriteMapper;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final BiPlatformRealDataService biPlatformRealDataService;
|
||||
private final com.mhd.bi.domain.biWarehouseTransport.service.BiWarehouseTransportRealDataService biWarehouseTransportRealDataService;
|
||||
|
||||
|
||||
/**
|
||||
* 依次同步各快照表;单表失败不影响其它表,只记日志。
|
||||
@@ -143,11 +147,33 @@ public class BiReportSnapshotSyncService {
|
||||
return BiSnapshotWeeklyRandomDataBuilder.comprehensive(new Random());
|
||||
}
|
||||
|
||||
/** TODO 业务落地:改为查询真实数据。临时实现见 {@link BiSnapshotWeeklyRandomDataBuilder#warehouseTransport(Random)}。 */
|
||||
/**
|
||||
* 仓储运输:订单量 / 今日订单 / 今日运输车次 / 客户贡献排名 用真实数据覆盖;
|
||||
* 其余(趋势类、周转率、货量等)仍为写死模板。
|
||||
*/
|
||||
protected WarehouseTransportSituationVO buildWarehouseTransportSnapshot() {
|
||||
return BiSnapshotWeeklyRandomDataBuilder.warehouseTransport(new Random());
|
||||
WarehouseTransportSituationVO template =
|
||||
BiSnapshotWeeklyRandomDataBuilder.warehouseTransport(new Random(20260825L));
|
||||
|
||||
// ====== 真实数据:仓储订单量(WMS 入库单 + 出库单,本年度/本季度/本月度,全部组织) ======
|
||||
RealWarehouseOrderStatPO orderStat = biWarehouseTransportRealDataService.queryWarehouseOrderStat();
|
||||
template.setCurrentYearOrders(orderStat.getCurrentYearOrders());
|
||||
template.setCurrentQuarterOrders(orderStat.getCurrentQuarterOrders().intValue());
|
||||
template.setCurrentMonthOrders(orderStat.getCurrentMonthOrders().intValue());
|
||||
|
||||
// ====== 真实数据:今日订单数量(OMS 运输业务单) ======
|
||||
template.setOrderCount((int) biWarehouseTransportRealDataService.countTodayTransportOrders());
|
||||
|
||||
// ====== 真实数据:今日运输车次(TMS 运输单) ======
|
||||
template.setTransportTrips((int) biWarehouseTransportRealDataService.countTodayTransportTrips());
|
||||
|
||||
// ====== 真实数据:客户贡献排名(OMS 近半年前 5 名货主) ======
|
||||
template.setCustomerContributionRank(biWarehouseTransportRealDataService.queryCustomerContributionRank());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
/** TODO 业务落地:部分字段改为真实数据,其余仍写死。 */
|
||||
protected PlatformSurveillanceVO buildPlatformSurveillanceSnapshot() {
|
||||
// 固定种子,保证写死字段每次生成值一致(真实字段随后实时覆盖)
|
||||
@@ -194,22 +220,48 @@ public class BiReportSnapshotSyncService {
|
||||
template.getPlatformOverview().setCurrentOccupancyRate(rate);
|
||||
template.getPlatformOverview().setTodayTasks(todayTasks);
|
||||
|
||||
// 作业准时率 = 实际进入时间 < 预约日期+预约结束时间 的车辆 / 今日预约总数 × 100%(取整)
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(biPlatformRealDataService.calcTodayOnTimeRate());
|
||||
}
|
||||
// 作业准时率:任务超时率 + 月台作业准时率 = 100%;园区作业准时率 = 100 - 园区超时率
|
||||
template.getEfficiencyStatistics().setPlatformOnTimeRate(
|
||||
(int) Math.round(100.0 - biPlatformRealDataService.calcTodayTaskOvertimeRate()));
|
||||
template.getEfficiencyStatistics().setYardOnTimeRate(
|
||||
(int) Math.round(100.0 - biPlatformRealDataService.calcTodayYardOvertimeRate()));
|
||||
}
|
||||
|
||||
|
||||
// ====== 真实数据:平均作业时长(本日)月台作业平均时长 / 园区平均时长 ======
|
||||
if (template.getEfficiencyStatistics() != null) {
|
||||
com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO avg =
|
||||
biPlatformRealDataService.queryTodayAvgDuration();
|
||||
template.getEfficiencyStatistics().setAvgPlatformDuration(avg.getAvgPlatformDurationHours());
|
||||
template.getEfficiencyStatistics().setAvgYardDuration(avg.getAvgYardDurationHours());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ====== 真实数据:作业车辆状态统计 ======
|
||||
RealVehicleStatusPO vs = biPlatformRealDataService.queryVehicleStatusToday();
|
||||
if (template.getVehicleStatus() != null) {
|
||||
template.getVehicleStatus().setTodayReservedVehicles(vs.getTodayReservedVehicles().intValue());
|
||||
template.getVehicleStatus().setNotCheckedIn(vs.getNotCheckedIn().intValue());
|
||||
template.getVehicleStatus().setWaiting(vs.getWaiting().intValue());
|
||||
// 叫号状态合计:已签到 + 已叫号 + 已过号(一个字段表示三个状态的总数量)
|
||||
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) {
|
||||
@@ -218,10 +270,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);
|
||||
@@ -232,42 +285,49 @@ public class BiReportSnapshotSyncService {
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 真实数据:任务负荷(今日 24 小时) ======
|
||||
// ====== 真实数据:小时趋势(今日,每 2 小时分组) ======
|
||||
List<RealTaskLoadPO> loads = biPlatformRealDataService.queryTaskLoadToday();
|
||||
if (!loads.isEmpty() && template.getTaskLoadStatistics() != null) {
|
||||
Map<Integer, Long> hourMap = new HashMap<>();
|
||||
if (loads.isEmpty()) {
|
||||
template.setTaskLoadStatistics(new ArrayList<>());
|
||||
} else {
|
||||
Map<Integer, Long> bucketMap = new HashMap<>();
|
||||
for (RealTaskLoadPO l : loads) {
|
||||
hourMap.put(l.getHourOfDay(), l.getTaskCount());
|
||||
}
|
||||
for (com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO item : template.getTaskLoadStatistics()) {
|
||||
Integer hour = parseHourFromLabel(item.getTime());
|
||||
if (hour != null) {
|
||||
Long n = hourMap.get(hour);
|
||||
if (n != null) item.setTaskCount(n.intValue());
|
||||
if (l != null && l.getHourOfDay() != null) {
|
||||
bucketMap.put(l.getHourOfDay(), l.getTaskCount() == null ? 0L : l.getTaskCount());
|
||||
}
|
||||
}
|
||||
// 固定输出 0,2,4,...,22 共 12 个桶,无数据桶补 0
|
||||
List<com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO> items = new ArrayList<>();
|
||||
for (int h = 0; h < 24; h += 2) {
|
||||
Long cnt = bucketMap.get(h);
|
||||
items.add(com.mhd.bi.interfaces.facadeApi.biReport.vo.platform.TaskLoadItemVO.builder()
|
||||
.time(String.format("%02d:00", h))
|
||||
.taskCount(cnt == null ? 0 : cnt.intValue())
|
||||
.build());
|
||||
}
|
||||
template.setTaskLoadStatistics(items);
|
||||
}
|
||||
|
||||
|
||||
// ====== 真实数据:任务类型统计(本月 YMS QMS_MAIN_BUSINESS 按业务类型 BUSINESS_NAME 分组) ======
|
||||
template.setTaskTypeStatistics(biPlatformRealDataService.queryMonthTransportOrderByType());
|
||||
|
||||
// ====== 真实数据:平均作业时长趋势(近半年按月:月台作业平均时长 / 园区作业平均时长) ======
|
||||
template.setAvgOperationDurationTrend(biPlatformRealDataService.queryAvgOperationDurationTrend());
|
||||
|
||||
// ====== 真实数据:任务超时率 + 月台作业超时记录列表(依赖 YMS QMS_STATIC_FIELD 参考用时) ======
|
||||
template.setTaskOvertimeRate(biPlatformRealDataService.calcTodayTaskOvertimeRate());
|
||||
template.setOvertimeRecords(biPlatformRealDataService.queryTodayOvertimeRecords());
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
private static Integer parseHourFromLabel(String label) {
|
||||
if (label == null) return null;
|
||||
// "15时" -> 15
|
||||
try {
|
||||
String s = label.replace("时", "").trim();
|
||||
return Integer.parseInt(s);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TODO 业务落地:改为查询真实数据组装 VO。当前为 {@link WarehouseOperationZoneDemoData} 静态示例。
|
||||
*/
|
||||
|
||||
protected WarehouseOperationZoneVO buildWarehouseOperationZoneSnapshot() {
|
||||
return WarehouseOperationZoneDemoData.build();
|
||||
}
|
||||
|
||||
+24
-17
@@ -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();
|
||||
}
|
||||
@@ -136,13 +136,14 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
.build());
|
||||
}
|
||||
|
||||
// 效率统计(本日):入园区超时率、超时数量、月台作业准时率、园区作业准时率 按业务要求恒为 0
|
||||
EfficiencyStatisticsVO eff = EfficiencyStatisticsVO.builder()
|
||||
.entryOvertimeRate(jitterPercentInt(Baseline.P_ENT_OT, r))
|
||||
.overtimeCount(Math.max(0, jitterInt(Baseline.P_OT_CNT, r)))
|
||||
.platformOnTimeRate(jitterPercentInt(Baseline.P_PL_OT, r))
|
||||
.avgPlatformDuration(Math.max(0.1, jitterDouble(Baseline.P_AVG_PL, r)))
|
||||
.yardOnTimeRate(jitterPercentInt(Baseline.P_YD_OT, r))
|
||||
.avgYardDuration(Math.max(0.1, jitterDouble(Baseline.P_AVG_YD, r)))
|
||||
.entryOvertimeRate(0)
|
||||
.overtimeCount(0)
|
||||
.platformOnTimeRate(0)
|
||||
.avgPlatformDuration(0d)
|
||||
.yardOnTimeRate(0)
|
||||
.avgYardDuration(0d)
|
||||
.build();
|
||||
|
||||
PlatformOverviewVO overview = PlatformOverviewVO.builder()
|
||||
@@ -150,15 +151,19 @@ 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()
|
||||
.todayReservedVehicles(Math.max(0, jitterInt(Baseline.P_RESV, r)))
|
||||
.notCheckedIn(Math.max(0, jitterInt(Baseline.P_NC, r)))
|
||||
.waiting(Math.max(0, jitterInt(Baseline.P_WAIT, r)))
|
||||
.callStatusTotal(Math.max(0, jitterInt(Baseline.P_CALL_STATUS_TOTAL, r)))
|
||||
.operatingVehicles(Math.max(0, jitterInt(Baseline.P_OPV, r)))
|
||||
.completedVehicles(Math.max(0, jitterInt(Baseline.P_DONE, r)))
|
||||
.build();
|
||||
|
||||
|
||||
List<AvgOperationDurationTrendItemVO> avgTrend = new ArrayList<>();
|
||||
for (int i = 0; i < Baseline.P_MO_LABELS.length; i++) {
|
||||
avgTrend.add(AvgOperationDurationTrendItemVO.builder()
|
||||
@@ -221,9 +226,13 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
.unhandled(unhandled)
|
||||
.build())
|
||||
.platformAlarmDistribution(dist)
|
||||
// 任务超时率 / 超时记录列表:实时查库覆盖,模板给 0/空兜底
|
||||
.taskOvertimeRate(0d)
|
||||
.overtimeRecords(new ArrayList<>())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 总体运营态势:与 {@code create_bi_overall_operation_dm.sql} 内置 PAYLOAD_JSON 一致(不随 Random 抖动)。
|
||||
*/
|
||||
@@ -359,7 +368,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;
|
||||
@@ -391,19 +400,15 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
{"闽D99887", "作业中", "#07", "142"},
|
||||
{"粤B66220", "已离园", "#29", "201"}
|
||||
};
|
||||
static final int P_ENT_OT = 42;
|
||||
static final int P_OT_CNT = 28;
|
||||
static final int P_PL_OT = 88;
|
||||
static final double P_AVG_PL = 3.8;
|
||||
static final int P_YD_OT = 91;
|
||||
static final double P_AVG_YD = 5.2;
|
||||
static final int P_TOT_PL = 58;
|
||||
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;
|
||||
static final int P_CALL_STATUS_TOTAL = 680;
|
||||
static final int P_OPV = 1_180;
|
||||
static final int P_DONE = 1_420;
|
||||
static final String[] P_MO_LABELS = {"5月", "6月", "7月"};
|
||||
@@ -415,8 +420,10 @@ public final class BiSnapshotWeeklyRandomDataBuilder {
|
||||
static final int P_MT_AVG_YOY = -3;
|
||||
static final int P_MT_CR = 97;
|
||||
static final int P_MT_CR_YOY = 2;
|
||||
static final String[] P_LOAD_T = {"8时", "10时", "14时"};
|
||||
static final int[] P_LOAD_C = {45, 120, 156};
|
||||
/** 小时趋势:每 2 小时一个桶,0:00 ~ 22:00 共 12 个 */
|
||||
static final String[] P_LOAD_T = {"00:00", "02:00", "04:00", "06:00", "08:00", "10:00",
|
||||
"12:00", "14:00", "16:00", "18:00", "20:00", "22:00"};
|
||||
static final int[] P_LOAD_C = {5, 3, 2, 8, 45, 120, 130, 156, 110, 70, 30, 12};
|
||||
static final String[] P_AL_D = {"1日", "2日", "3日"};
|
||||
static final int[] P_AL_C = {6, 9, 4};
|
||||
static final int P_TT_TOT = 5_100;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.mhd.bi.domain.biStaticField.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BI 业务静态字段配置 Mapper(YMS 库 NGWL_TEST_YMS.QMS_STATIC_FIELD)
|
||||
*
|
||||
* <p>SQL 见 BiStaticFieldMapper.xml。</p>
|
||||
*/
|
||||
public interface BiStaticFieldMapper {
|
||||
|
||||
/** 按字段编码查询全部有效配置(含 GLOBAL / FLOOR / WINDOW 各作用域,供程序按优先级取值) */
|
||||
List<BiStaticFieldPO> queryByCode(@Param("fieldCode") String fieldCode);
|
||||
|
||||
/** 批量按字段编码查询有效配置 */
|
||||
List<BiStaticFieldPO> queryByCodes(@Param("fieldCodes") List<String> fieldCodes);
|
||||
|
||||
/** 查询全部有效配置 */
|
||||
List<BiStaticFieldPO> queryAll();
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.mhd.bi.domain.biStaticField.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 业务静态字段配置(来自 NGWL_TEST_YMS.QMS_STATIC_FIELD)
|
||||
*
|
||||
* <p>集中存放指标计算所需的参考值/基准值,当前使用:</p>
|
||||
* <ul>
|
||||
* <li>platform_work_ref_minutes 月台作业参考用时(分钟)</li>
|
||||
* <li>yard_work_ref_minutes 园区作业参考用时(分钟)</li>
|
||||
* </ul>
|
||||
* <p>后续新增静态字段只需往表里 INSERT,无需改代码结构。</p>
|
||||
*/
|
||||
@Data
|
||||
public class BiStaticFieldPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 静态字段编码 */
|
||||
private String fieldCode;
|
||||
|
||||
/** 静态字段名称 */
|
||||
private String fieldName;
|
||||
|
||||
/** 作用域类型:GLOBAL-全局 FLOOR-按楼层 WINDOW-按月台 */
|
||||
private String scopeType;
|
||||
|
||||
/** 作用域编码:GLOBAL 时为 ALL;FLOOR 时为楼层;WINDOW 时为月台名 */
|
||||
private String scopeCode;
|
||||
|
||||
/** 字段值(字符串,程序按需转换) */
|
||||
private String fieldValue;
|
||||
|
||||
/** 单位 */
|
||||
private String unit;
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.mhd.bi.domain.biStaticField.service;
|
||||
|
||||
import com.mhd.bi.domain.biStaticField.repository.mapper.BiStaticFieldMapper;
|
||||
import com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* BI 业务静态字段配置业务层(YMS 库 QMS_STATIC_FIELD)
|
||||
*
|
||||
* <p>集中提供参考值/基准值等静态配置的读取能力,后续新增静态字段只需往表里 INSERT。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BiStaticFieldService {
|
||||
|
||||
/** 月台作业参考用时(分钟) */
|
||||
public static final String CODE_PLATFORM_WORK_REF_MINUTES = "platform_work_ref_minutes";
|
||||
|
||||
/** 园区作业参考用时(分钟) */
|
||||
public static final String CODE_YARD_WORK_REF_MINUTES = "yard_work_ref_minutes";
|
||||
|
||||
/** 作用域:全局 */
|
||||
private static final String SCOPE_GLOBAL = "GLOBAL";
|
||||
/** 作用域:按月台 */
|
||||
private static final String SCOPE_WINDOW = "WINDOW";
|
||||
/** 作用域:按楼层 */
|
||||
private static final String SCOPE_FLOOR = "FLOOR";
|
||||
|
||||
@Resource
|
||||
private BiStaticFieldMapper biStaticFieldMapper;
|
||||
|
||||
/**
|
||||
* 按字段编码查询全部有效配置;查询失败返回空列表。
|
||||
*/
|
||||
public List<BiStaticFieldPO> queryByCode(String fieldCode) {
|
||||
try {
|
||||
List<BiStaticFieldPO> list = biStaticFieldMapper.queryByCode(fieldCode);
|
||||
return list == null ? Collections.emptyList() : list;
|
||||
} catch (Exception e) {
|
||||
log.error("【YMS】查询静态字段配置失败, fieldCode={}: {}", fieldCode, e.getMessage(), e);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按「WINDOW > FLOOR > GLOBAL」优先级取静态字段值(字符串)。取不到返回 null。
|
||||
*
|
||||
* @param fieldCode 字段编码
|
||||
* @param windowName 月台名(可为空)
|
||||
* @param floor 楼层(可为空)
|
||||
*/
|
||||
public String resolveValue(String fieldCode, String windowName, String floor) {
|
||||
List<BiStaticFieldPO> list = queryByCode(fieldCode);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String globalVal = null;
|
||||
String floorVal = null;
|
||||
for (BiStaticFieldPO po : list) {
|
||||
if (po == null || po.getFieldValue() == null) {
|
||||
continue;
|
||||
}
|
||||
String scopeType = po.getScopeType() == null ? "" : po.getScopeType().trim().toUpperCase();
|
||||
String scopeCode = po.getScopeCode();
|
||||
if (SCOPE_WINDOW.equals(scopeType) && windowName != null && windowName.equals(scopeCode)) {
|
||||
return po.getFieldValue(); // 最高优先级,直接返回
|
||||
}
|
||||
if (SCOPE_FLOOR.equals(scopeType) && floor != null && floor.equals(scopeCode)) {
|
||||
floorVal = po.getFieldValue();
|
||||
}
|
||||
if (SCOPE_GLOBAL.equals(scopeType)) {
|
||||
globalVal = po.getFieldValue();
|
||||
}
|
||||
}
|
||||
return floorVal != null ? floorVal : globalVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取静态字段的数值(分钟等整数),取不到或非数字返回 null。
|
||||
*/
|
||||
public Long resolveLongValue(String fieldCode, String windowName, String floor) {
|
||||
String v = resolveValue(fieldCode, windowName, floor);
|
||||
if (v == null || v.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Long.valueOf(v.trim());
|
||||
} catch (Exception e) {
|
||||
log.warn("【YMS】静态字段值非数字, fieldCode={}, value={}", fieldCode, v);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 月台作业参考用时(分钟),按月台/楼层解析;取不到返回 null */
|
||||
public Long resolvePlatformWorkRefMinutes(String windowName, String floor) {
|
||||
return resolveLongValue(CODE_PLATFORM_WORK_REF_MINUTES, windowName, floor);
|
||||
}
|
||||
|
||||
/** 园区作业参考用时(分钟),按月台/楼层解析;取不到返回 null */
|
||||
public Long resolveYardWorkRefMinutes(String windowName, String floor) {
|
||||
return resolveLongValue(CODE_YARD_WORK_REF_MINUTES, windowName, floor);
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.repository.mapper;
|
||||
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO;
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 仓储运输-真实业务数据 Mapper(跨库查询,与月台监测同方案)
|
||||
*
|
||||
* <p>数据来源:</p>
|
||||
* <ul>
|
||||
* <li>库存订单量:NGWL_TEST_WMS.STOCK_IN_ORDER + NGWL_TEST_WMS.STOCK_OUT_ORDER</li>
|
||||
* <li>今日订单数量:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER</li>
|
||||
* <li>今日运输车次:NGWL_TEST_WLHY.TMS_TRANSPORT_NOTE</li>
|
||||
* <li>客户贡献排名:NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER 按货主聚合近半年</li>
|
||||
* </ul>
|
||||
*/
|
||||
public interface BiWarehouseTransportRealDataMapper {
|
||||
|
||||
/** 仓储订单量:本年度 / 本季度 / 本月度(WMS 入库单 + 出库单),全部组织 */
|
||||
RealWarehouseOrderStatPO queryWarehouseOrderStat();
|
||||
|
||||
/** 今日订单数量:OMS 运输业务单,今日创建 */
|
||||
Long countTodayTransportOrders();
|
||||
|
||||
/** 今日运输车次:TMS 运单(运输单),今日创建,一个单 = 一个车次 */
|
||||
Long countTodayTransportTrips();
|
||||
|
||||
/** 客户贡献排名:OMS 运输业务单,近半年按货主聚合订单数,取前 5 名 */
|
||||
List<RealCustomerRankPO> queryCustomerRankTop5();
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 客户贡献排名项(真实数据,来自 OMS 运输业务单)
|
||||
*
|
||||
* <p>统计范围:全部组织,近半年,按货主聚合作业量,取前 5 名。</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealCustomerRankPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 货主/客户名称 */
|
||||
private String customerName;
|
||||
|
||||
/** 订单数(单) */
|
||||
private Long customerAmount;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.repository.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 仓储订单量统计(真实数据)
|
||||
*
|
||||
* <p>数据来源:WMS 入库业务单 NGWL_TEST_WMS.STOCK_IN_ORDER + 出库业务单 NGWL_TEST_WMS.STOCK_OUT_ORDER</p>
|
||||
* <p>统计范围:全部组织</p>
|
||||
*/
|
||||
@Data
|
||||
public class RealWarehouseOrderStatPO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 本年度订单数(入库 + 出库) */
|
||||
private Long currentYearOrders;
|
||||
|
||||
/** 本季度订单数(入库 + 出库) */
|
||||
private Long currentQuarterOrders;
|
||||
|
||||
/** 本月度订单数(入库 + 出库) */
|
||||
private Long currentMonthOrders;
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.service;
|
||||
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportRealDataMapper;
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO;
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.CustomerContributionRankVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 仓储运输-真实业务数据业务层(封装 WMS / OMS / TMS 跨库查询)
|
||||
*
|
||||
* <p>实现方案与「月台监测指标查询」一致:实时查库,查不到或异常返回 0/空,不影响其它字段。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BiWarehouseTransportRealDataService {
|
||||
|
||||
@Resource
|
||||
private BiWarehouseTransportRealDataMapper biWarehouseTransportRealDataMapper;
|
||||
|
||||
/**
|
||||
* 仓储订单量:本年度 / 本季度 / 本月度(WMS 入库单 + 出库单),全部组织。
|
||||
* 查询失败返回全 0。
|
||||
*/
|
||||
public RealWarehouseOrderStatPO queryWarehouseOrderStat() {
|
||||
RealWarehouseOrderStatPO po = new RealWarehouseOrderStatPO();
|
||||
po.setCurrentYearOrders(0L);
|
||||
po.setCurrentQuarterOrders(0L);
|
||||
po.setCurrentMonthOrders(0L);
|
||||
try {
|
||||
RealWarehouseOrderStatPO row = biWarehouseTransportRealDataMapper.queryWarehouseOrderStat();
|
||||
if (row != null) {
|
||||
po.setCurrentYearOrders(row.getCurrentYearOrders() == null ? 0L : row.getCurrentYearOrders());
|
||||
po.setCurrentQuarterOrders(row.getCurrentQuarterOrders() == null ? 0L : row.getCurrentQuarterOrders());
|
||||
po.setCurrentMonthOrders(row.getCurrentMonthOrders() == null ? 0L : row.getCurrentMonthOrders());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【WMS】统计仓储订单量失败: {}", e.getMessage(), e);
|
||||
}
|
||||
return po;
|
||||
}
|
||||
|
||||
/** 今日订单数量:OMS 运输业务单,今日创建;查询失败返回 0 */
|
||||
public long countTodayTransportOrders() {
|
||||
try {
|
||||
Long n = biWarehouseTransportRealDataMapper.countTodayTransportOrders();
|
||||
return n == null ? 0L : n;
|
||||
} catch (Exception e) {
|
||||
log.error("【OMS】统计今日订单数量失败: {}", e.getMessage(), e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/** 今日运输车次:TMS 运输单,今日创建(一个单 = 一个车次);查询失败返回 0 */
|
||||
public long countTodayTransportTrips() {
|
||||
try {
|
||||
Long n = biWarehouseTransportRealDataMapper.countTodayTransportTrips();
|
||||
return n == null ? 0L : n;
|
||||
} catch (Exception e) {
|
||||
log.error("【TMS】统计今日运输车次失败: {}", e.getMessage(), e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户贡献排名(前 5 名货主,近半年订单数)。
|
||||
* 查询失败返回空数组结构的对象,前端可正常渲染。
|
||||
*/
|
||||
public CustomerContributionRankVO queryCustomerContributionRank() {
|
||||
List<String> names = new ArrayList<>();
|
||||
List<Integer> amounts = new ArrayList<>();
|
||||
try {
|
||||
List<RealCustomerRankPO> rows = biWarehouseTransportRealDataMapper.queryCustomerRankTop5();
|
||||
if (rows != null) {
|
||||
for (RealCustomerRankPO r : rows) {
|
||||
if (r == null || r.getCustomerName() == null) {
|
||||
continue;
|
||||
}
|
||||
names.add(r.getCustomerName());
|
||||
amounts.add(r.getCustomerAmount() == null ? 0 : r.getCustomerAmount().intValue());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("【OMS】查询客户贡献排名失败: {}", e.getMessage(), e);
|
||||
names = new ArrayList<>();
|
||||
amounts = new ArrayList<>();
|
||||
}
|
||||
return CustomerContributionRankVO.builder()
|
||||
.customerName(names.isEmpty() ? Collections.emptyList() : names)
|
||||
.customerAmount(amounts.isEmpty() ? Collections.emptyList() : amounts)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
+107
-1
@@ -1,18 +1,124 @@
|
||||
package com.mhd.bi.domain.biWarehouseTransport.service;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mhd.bi.domain.biSnapshotSync.repository.mapper.BiSnapshotWriteMapper;
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.mapper.BiWarehouseTransportReportMapper;
|
||||
import com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO;
|
||||
import com.mhd.bi.interfaces.facadeApi.biReport.vo.WarehouseTransportSituationVO;
|
||||
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>
|
||||
* <ol>
|
||||
* <li>先读快照最新一条作为基底;</li>
|
||||
* <li>实时查业务库,用真实数据覆盖以下字段:
|
||||
* 本年度订单 / 本季度订单 / 本月度订单(WMS 入库业务单 + 出库业务单)、
|
||||
* 今日订单数量(OMS 运输业务单)、今日运输车次(TMS 运单)、
|
||||
* 客户贡献排名(OMS 近半年前 5 名货主);</li>
|
||||
* <li>对「真实业务数据」计算指纹,与快照最新一条比对:
|
||||
* 未变化则跳过落库直接返回;已变化则覆盖更新快照最新一条,无记录时插入兜底。</li>
|
||||
* </ol>
|
||||
* <p>其余字段(趋势类、周转率、货量等)仍取自快照模板值,不纳入指纹。</p>
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BiWarehouseTransportReportService {
|
||||
|
||||
private static final String REMARK_REALTIME = "realtime warehouse-transport";
|
||||
|
||||
@Resource
|
||||
private BiWarehouseTransportReportMapper biWarehouseTransportReportMapper;
|
||||
|
||||
@Resource
|
||||
private BiWarehouseTransportRealDataService biWarehouseTransportRealDataService;
|
||||
|
||||
@Resource
|
||||
private BiSnapshotWriteMapper biSnapshotWriteMapper;
|
||||
|
||||
@Resource
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
/**
|
||||
* 实时组装仓储运输数据:快照基底 + 实时业务数据覆盖;
|
||||
* 仅当实时业务数据(WMS/OMS/TMS 查出的字段)发生变化时,才覆盖更新
|
||||
* BI_WAREHOUSE_TRANSPORT_SNAPSHOT 快照表最新一条后返回。
|
||||
* 表中尚无记录时插入一条兜底。
|
||||
*/
|
||||
public WarehouseTransportSituationVO loadLatestWarehouseTransport() {
|
||||
return biWarehouseTransportReportMapper.loadLatestWarehouseTransport();
|
||||
WarehouseTransportSituationVO vo = biWarehouseTransportReportMapper.loadLatestWarehouseTransport();
|
||||
if (vo == null) {
|
||||
vo = new WarehouseTransportSituationVO();
|
||||
}
|
||||
|
||||
// 仓储订单量:WMS 入库业务单 + 出库业务单(本年度 / 本季度 / 本月度,全部组织)
|
||||
RealWarehouseOrderStatPO orderStat = biWarehouseTransportRealDataService.queryWarehouseOrderStat();
|
||||
vo.setCurrentYearOrders(orderStat.getCurrentYearOrders());
|
||||
vo.setCurrentQuarterOrders(orderStat.getCurrentQuarterOrders().intValue());
|
||||
vo.setCurrentMonthOrders(orderStat.getCurrentMonthOrders().intValue());
|
||||
|
||||
// 今日订单数量:OMS 运输业务单
|
||||
vo.setOrderCount((int) biWarehouseTransportRealDataService.countTodayTransportOrders());
|
||||
|
||||
// 今日运输车次:TMS 运输单(一个单 = 一个车次)
|
||||
vo.setTransportTrips((int) biWarehouseTransportRealDataService.countTodayTransportTrips());
|
||||
|
||||
// 客户贡献排名:OMS 运输业务单,近半年前 5 名货主(订单数)
|
||||
vo.setCustomerContributionRank(biWarehouseTransportRealDataService.queryCustomerContributionRank());
|
||||
|
||||
try {
|
||||
String fullJson = objectMapper.writeValueAsString(vo);
|
||||
String fingerprint = realDataFingerprint(vo);
|
||||
|
||||
String latestJson = biWarehouseTransportReportMapper.selectLatestPayloadJson();
|
||||
if (StringUtils.isNotBlank(latestJson)) {
|
||||
WarehouseTransportSituationVO latestVo =
|
||||
objectMapper.readValue(latestJson.trim(), WarehouseTransportSituationVO.class);
|
||||
if (Objects.equals(fingerprint, realDataFingerprint(latestVo))) {
|
||||
log.info("BI 仓储运输实时业务数据未变化,跳过落库");
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
int rows = biSnapshotWriteMapper.updateLatestWarehouseTransportSnapshot(fullJson, REMARK_REALTIME);
|
||||
if (rows < 1) {
|
||||
// 表中无最新记录可更新,插入一条兜底
|
||||
biSnapshotWriteMapper.insertWarehouseTransportSnapshot(fullJson, REMARK_REALTIME);
|
||||
}
|
||||
log.info("BI 仓储运输实时数据已落库(覆盖最新, 数据变化), affectedRows={}", rows);
|
||||
} catch (Exception e) {
|
||||
log.error("BI 仓储运输实时数据落库失败", e);
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实时业务数据指纹:仅含实时查库得到的字段(本年度/本季度/本月度订单、今日订单数量、
|
||||
* 今日运输车次、客户贡献排名),用于判断是否需要覆盖更新快照;
|
||||
* 其余字段取自快照模板,不纳入指纹,其变化不会触发更新。
|
||||
*/
|
||||
private String realDataFingerprint(WarehouseTransportSituationVO vo) throws Exception {
|
||||
Map<String, Object> fp = new LinkedHashMap<>();
|
||||
if (vo == null) {
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
fp.put("currentYearOrders", vo.getCurrentYearOrders());
|
||||
fp.put("currentQuarterOrders", vo.getCurrentQuarterOrders());
|
||||
fp.put("currentMonthOrders", vo.getCurrentMonthOrders());
|
||||
fp.put("orderCount", vo.getOrderCount());
|
||||
fp.put("transportTrips", vo.getTransportTrips());
|
||||
if (vo.getCustomerContributionRank() != null) {
|
||||
fp.put("customerName", vo.getCustomerContributionRank().getCustomerName());
|
||||
fp.put("customerAmount", vo.getCustomerContributionRank().getCustomerAmount());
|
||||
}
|
||||
return objectMapper.writeValueAsString(fp);
|
||||
}
|
||||
}
|
||||
|
||||
+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;
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ public class CustomerContributionRankVO {
|
||||
@ApiModelProperty("客户名称")
|
||||
private List<String> customerName;
|
||||
|
||||
@ApiModelProperty("客户金额,单位:万元")
|
||||
@ApiModelProperty("客户订单数,单位:单")
|
||||
private List<Integer> customerAmount;
|
||||
}
|
||||
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.mhd.bi.interfaces.facadeApi.biReport.vo.platform;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ApiModel("月台监测-月台作业超时记录")
|
||||
public class OvertimeRecordItemVO {
|
||||
|
||||
@ApiModelProperty("月台名称")
|
||||
private String windowName;
|
||||
|
||||
@ApiModelProperty("车牌号码")
|
||||
private String carNo;
|
||||
|
||||
@ApiModelProperty("超时时长,单位:分钟(= 月台作业时长 - 参考用时)")
|
||||
private Long overtimeMinutes;
|
||||
|
||||
@ApiModelProperty("月台作业参考用时,单位:分钟")
|
||||
private Long refMinutes;
|
||||
|
||||
@ApiModelProperty("月台作业时长,单位:分钟")
|
||||
private Long platformMinutes;
|
||||
}
|
||||
+3
@@ -25,4 +25,7 @@ public class PlatformOverviewVO {
|
||||
|
||||
@ApiModelProperty("今日作业任务,单位:个")
|
||||
private Integer todayTasks;
|
||||
|
||||
@ApiModelProperty("月台周转率,单位:%(今日已出场的记录数 ÷ 今日全部记录数 × 100)")
|
||||
private Double platformTurnoverRate;
|
||||
}
|
||||
|
||||
+6
@@ -48,4 +48,10 @@ public class PlatformSurveillanceVO {
|
||||
|
||||
@ApiModelProperty("月台告警分布")
|
||||
private List<PlatformAlarmDistItemVO> platformAlarmDistribution;
|
||||
|
||||
@ApiModelProperty("任务超时率,单位:%(月台作业时长 > 参考用时的记录数 ÷ 总记录数 × 100)")
|
||||
private Double taskOvertimeRate;
|
||||
|
||||
@ApiModelProperty("月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟)")
|
||||
private List<OvertimeRecordItemVO> overtimeRecords;
|
||||
}
|
||||
|
||||
+3
@@ -23,6 +23,9 @@ public class VehicleStatusVO {
|
||||
@ApiModelProperty("当前等待作业(已预约/已签到/已叫号),单位:辆")
|
||||
private Integer waiting;
|
||||
|
||||
@ApiModelProperty("已签到+已叫号+已过号(FLOW_STATUS IN 2/3/4),单位:辆")
|
||||
private Integer callStatusTotal;
|
||||
|
||||
@ApiModelProperty("当前作业中,单位:辆")
|
||||
private Integer operatingVehicles;
|
||||
|
||||
|
||||
@@ -19,14 +19,14 @@ spring:
|
||||
# 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.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
|
||||
@@ -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 <- 月台作业时长(分钟),用「进入月台 / 离开月台」时间:
|
||||
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_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
|
||||
THEN CAST((mb.EXIT_TIME - mb.ENTRY_TIME) * 24 * 60 AS BIGINT)
|
||||
ELSE 0
|
||||
WHEN mb.IN_WINDOWS_TIME IS NULL THEN 0
|
||||
WHEN mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||
THEN CAST((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 AS BIGINT)
|
||||
ELSE CAST((SYSDATE - mb.IN_WINDOWS_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,8 @@ 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
|
||||
@@ -70,18 +76,109 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<!-- 车辆状态统计:今日的统计(按创建时间 CREATE_TIME / 流程状态)
|
||||
todayReservedVehicles 改为按预约日期 TARGET_DATE(其它 3 项保持 CREATE_TIME)
|
||||
waiting 等待作业:FLOW_STATUS IN ('1','2','3') 已预约/已签到/已叫号 且 预约日期 = 今天
|
||||
callStatusTotal 叫号状态合计:已签到 + 已叫号 + 已过号 = FLOW_STATUS IN ('2','3','4') 且 预约日期 = 今天
|
||||
todayExited 今日已出场:FLOW_STATUS = '11' 且 预约日期 = 今天(月台周转率的分子)
|
||||
completedVehicles 今日作业车辆总数: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
|
||||
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 ('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
|
||||
SUM(CASE WHEN FLOW_STATUS = '11' AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE) THEN 1 ELSE 0 END) AS completedVehicles
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- ======================= 月台作业参考用时 / 超时相关 =======================
|
||||
参考用时取自 YMS 库静态字段配置表 NGWL_TEST_YMS.QMS_STATIC_FIELD:
|
||||
FIELD_CODE = 'platform_work_ref_minutes'
|
||||
取值优先级:WINDOW(按月台) > FLOOR(按楼层) > GLOBAL(全局)
|
||||
下面用 LEFT JOIN 三级关联 + COALESCE 实现优先级取值,
|
||||
REF_MINUTES 为空表示该月台未配置参考用时,其记录不计入超时率分母 -->
|
||||
|
||||
<!-- 可复用的参考用时关联条件(YMS 库静态字段配置表 QMS_STATIC_FIELD)
|
||||
取值优先级:WINDOW(按月台) > FLOOR(按楼层) > GLOBAL(全局) -->
|
||||
<sql id="joinStaticRef">
|
||||
INNER JOIN NGWL_TEST_YMS.QMS_STATIC_FIELD ref
|
||||
ON ref.FIELD_CODE = #{refCode}
|
||||
AND ref.DEL_FLAG = 1
|
||||
AND ref.FIELD_VALUE IS NOT NULL
|
||||
AND (
|
||||
(ref.SCOPE_TYPE = 'WINDOW' AND ref.SCOPE_CODE = mb.WINDOW_NAME)
|
||||
OR (ref.SCOPE_TYPE = 'FLOOR' AND ref.SCOPE_CODE = wi.PLATFORM_FLOOR)
|
||||
OR (ref.SCOPE_TYPE = 'GLOBAL')
|
||||
)
|
||||
</sql>
|
||||
|
||||
<!-- 今日作业超时统计(通用:月台作业 / 园区作业,由 refCode + 时长表达式区分)
|
||||
分母只计入「能取到参考用时 且 时长两端时间都非空」的记录
|
||||
overtimeCount 超时记录数:作业时长(分钟) > 参考用时
|
||||
totalCount 有效记录总数(分母)
|
||||
超时率 = overtimeCount / totalCount × 100%,由 Service 层计算 -->
|
||||
<select id="queryTodayOvertimeStat" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO">
|
||||
SELECT
|
||||
SUM(CASE WHEN (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||
THEN 1 ELSE 0 END) AS overtimeCount,
|
||||
COUNT(1) AS totalCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||
<include refid="joinStaticRef"/>
|
||||
WHERE mb.TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||
AND mb.IN_WINDOWS_TIME IS NOT NULL
|
||||
AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||
</select>
|
||||
|
||||
<!-- 今日园区作业超时统计(时长 = 实际出场 - 实际进入;参考用时 yard_work_ref_minutes)
|
||||
用于计算「园区作业准时率 = 1 - 超时率」 -->
|
||||
<select id="queryTodayYardOvertimeStat" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeStatPO">
|
||||
SELECT
|
||||
SUM(CASE WHEN (mb.EXIT_TIME - mb.ENTRY_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||
THEN 1 ELSE 0 END) AS overtimeCount,
|
||||
COUNT(1) AS totalCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||
<include refid="joinStaticRef"/>
|
||||
WHERE mb.TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||
AND mb.ENTRY_TIME IS NOT NULL
|
||||
AND mb.EXIT_TIME IS NOT NULL
|
||||
</select>
|
||||
|
||||
<!-- 今日月台作业超时记录列表(月台名称 / 车牌号码 / 超时时长分钟):
|
||||
超时时长 = 月台作业时长 - 参考用时 -->
|
||||
<select id="queryTodayOvertimeList" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealOvertimeRecordPO">
|
||||
SELECT
|
||||
mb.WINDOW_NAME AS windowName,
|
||||
mb.CAR_NO AS carNo,
|
||||
CAST(((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 - ref.REF_MINUTES) AS BIGINT) AS overtimeMinutes,
|
||||
ref.REF_MINUTES AS refMinutes,
|
||||
CAST((mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 AS BIGINT) AS platformMinutes
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS mb
|
||||
LEFT JOIN NGWL_TEST_YMS.QMS_WINDOW_INFO wi
|
||||
ON wi.WINDOW_NAME = mb.WINDOW_NAME
|
||||
<include refid="joinStaticRef"/>
|
||||
WHERE mb.TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(mb.TARGET_DATE) = TRUNC(SYSDATE)
|
||||
AND mb.IN_WINDOWS_TIME IS NOT NULL
|
||||
AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||
AND (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60 > ref.REF_MINUTES
|
||||
ORDER BY overtimeMinutes DESC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<!-- 本月任务量:按预约日期 TARGET_DATE(Y预约日期)统计本月预约总数量 -->
|
||||
|
||||
<select id="countMonthTasks" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
@@ -89,21 +186,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 本月任务作业时长合计(小时),用「进入月台 / 离开月台」时间:
|
||||
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_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 IN_WINDOWS_TIME IS NULL THEN 0
|
||||
WHEN OUT_WINDOWS_TIME IS NOT NULL THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||
ELSE (SYSDATE - IN_WINDOWS_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')
|
||||
@@ -112,8 +210,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
|
||||
@@ -126,11 +227,18 @@ 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
|
||||
platformCount 该楼层月台数量(QMS_WINDOW_INFO)
|
||||
todayReservedVehicles 该楼层今日预约车辆数(按预约时已选的月台/叫号月台关联楼层)
|
||||
operatingVehicles 该楼层当前作业车辆数(FLOW_STATUS IN 5,6,7,8,9,10)
|
||||
avgPlatformMinutes 该楼层月台作业平均时长(分钟)
|
||||
公式:SUM(该楼层有效记录的月台作业时长) ÷ 该楼层有效记录数
|
||||
有效记录:同时有进入月台(IN_WINDOWS_TIME)与离开月台(OUT_WINDOWS_TIME)时间
|
||||
说明:楼层维度以「月台表」为准;车辆预约时若已选月台(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
|
||||
@@ -139,15 +247,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
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
|
||||
END) AS operatingVehicles,
|
||||
ROUND(AVG(CASE
|
||||
WHEN mb.IN_WINDOWS_TIME IS NOT NULL AND mb.OUT_WINDOWS_TIME IS NOT NULL
|
||||
THEN (mb.OUT_WINDOWS_TIME - mb.IN_WINDOWS_TIME) * 24 * 60
|
||||
END), 0) AS avgPlatformMinutes
|
||||
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">
|
||||
@@ -162,18 +276,73 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
ORDER BY COUNT(1) DESC
|
||||
</select>
|
||||
|
||||
<!-- 任务负荷(今日 24 小时时段):按 EXTRACT(HOUR FROM ENTRY_TIME) 统计 -->
|
||||
<!-- 今日平均作业时长(效率统计-本日):
|
||||
avgPlatformDurationHours 月台作业平均时长(小时)
|
||||
统计范围:今日预约记录中「同时有进入月台时间(IN_WINDOWS_TIME)和离开月台时间(OUT_WINDOWS_TIME)」的记录
|
||||
公式:AVG((OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24)
|
||||
avgYardDurationHours 园区平均时长(小时)
|
||||
统计范围:今日预约记录中「同时有实际进入时间(ENTRY_TIME)和实际出场时间(EXIT_TIME)」的记录
|
||||
公式:AVG((EXIT_TIME - ENTRY_TIME) * 24) -->
|
||||
<select id="queryTodayAvgDuration" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTodayAvgDurationPO">
|
||||
SELECT
|
||||
AVG(CASE WHEN IN_WINDOWS_TIME IS NOT NULL AND OUT_WINDOWS_TIME IS NOT NULL
|
||||
THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||
END) AS avgPlatformDurationHours,
|
||||
AVG(CASE WHEN ENTRY_TIME IS NOT NULL AND EXIT_TIME IS NOT NULL
|
||||
THEN (EXIT_TIME - ENTRY_TIME) * 24
|
||||
END) AS avgYardDurationHours
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TRUNC(TARGET_DATE) = TRUNC(SYSDATE)
|
||||
</select>
|
||||
|
||||
<!-- 近半年「平均作业时长」趋势(按月分组,取最近 6 个月):
|
||||
|
||||
taskCount 该月任务数(预约记录数,作为平均时长的分母);
|
||||
platformWorkHours 该月月台作业时长合计(小时):
|
||||
未进入月台(IN_WINDOWS_TIME 为空) -> 0
|
||||
已进入且已离开月台(OUT_WINDOWS_TIME 非空) -> OUT_WINDOWS_TIME - IN_WINDOWS_TIME
|
||||
已进入但未离开月台 -> SYSDATE - IN_WINDOWS_TIME
|
||||
yardWorkHours 该月园区作业时长合计(小时):
|
||||
未进场(ENTRY_TIME 为空) -> 0
|
||||
已进场且已出场(EXIT_TIME 非空) -> EXIT_TIME - ENTRY_TIME
|
||||
已进场但未出场 -> SYSDATE - ENTRY_TIME
|
||||
平均时长由 Service 层计算 = 时长合计 ÷ taskCount -->
|
||||
<select id="queryMonthlyAvgDuration" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealMonthlyAvgDurationPO">
|
||||
SELECT
|
||||
TO_CHAR(TARGET_DATE, 'YYYY-MM') AS monthOfYear,
|
||||
COUNT(1) AS taskCount,
|
||||
SUM(CASE
|
||||
WHEN IN_WINDOWS_TIME IS NULL THEN 0
|
||||
WHEN OUT_WINDOWS_TIME IS NOT NULL THEN (OUT_WINDOWS_TIME - IN_WINDOWS_TIME) * 24
|
||||
ELSE (SYSDATE - IN_WINDOWS_TIME) * 24
|
||||
END) AS platformWorkHours,
|
||||
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 yardWorkHours
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE TARGET_DATE IS NOT NULL
|
||||
AND TARGET_DATE >= ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -5)
|
||||
GROUP BY TO_CHAR(TARGET_DATE, 'YYYY-MM')
|
||||
ORDER BY 1
|
||||
</select>
|
||||
|
||||
<!-- 小时趋势(今日,每 2 小时分组统计一次):
|
||||
按车辆进入月台时间 IN_WINDOWS_TIME 分桶,桶为 0,2,4,...,22 -->
|
||||
<select id="queryTaskLoadToday" resultType="com.mhd.bi.domain.biPlatformRealData.repository.po.RealTaskLoadPO">
|
||||
SELECT
|
||||
EXTRACT(HOUR FROM ENTRY_TIME) AS hourOfDay,
|
||||
COUNT(1) AS taskCount
|
||||
FLOOR(EXTRACT(HOUR FROM IN_WINDOWS_TIME) / 2) * 2 AS hourOfDay,
|
||||
COUNT(1) AS taskCount
|
||||
FROM NGWL_TEST_YMS.QMS_MAIN_BUSINESS
|
||||
WHERE ENTRY_TIME IS NOT NULL
|
||||
AND TRUNC(ENTRY_TIME) = TRUNC(SYSDATE)
|
||||
GROUP BY EXTRACT(HOUR FROM ENTRY_TIME)
|
||||
ORDER BY EXTRACT(HOUR FROM ENTRY_TIME)
|
||||
WHERE IN_WINDOWS_TIME IS NOT NULL
|
||||
AND TRUNC(IN_WINDOWS_TIME) = TRUNC(SYSDATE)
|
||||
GROUP BY FLOOR(EXTRACT(HOUR FROM IN_WINDOWS_TIME) / 2) * 2
|
||||
ORDER BY 1
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 月台管理列表:查询 YMS qms_window_info 月台/鹤位窗口
|
||||
机构名称 deptName <- sys_dept.DEPT_NAME(d.dept_id = a.ORG_NO 关联)
|
||||
鹤位屏名称 berrNames <- qms_window_berr(WINDOW_ID/BERR_ID) join qms_berr_config(ID/BERR_NAME),WM_CONCAT 拼接
|
||||
|
||||
@@ -8,11 +8,33 @@
|
||||
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})
|
||||
</insert>
|
||||
|
||||
<!-- 覆盖更新仓储运输快照最新一条(实时组装后落库,同月台监测) -->
|
||||
<update id="updateLatestWarehouseTransportSnapshot">
|
||||
update NGWL_TEST_BI.BI_WAREHOUSE_TRANSPORT_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_WAREHOUSE_TRANSPORT_SNAPSHOT t where t.DEL_FLAG = 1)
|
||||
</update>
|
||||
|
||||
|
||||
<insert id="insertPlatformSurveillanceSnapshot">
|
||||
insert into NGWL_TEST_BI.BI_PLATFORM_SURVEILLANCE_SNAPSHOT (PAYLOAD_JSON, CREATE_TIME, UPDATE_TIME, DEL_FLAG, REMARK)
|
||||
values (#{payloadJson}, SYSDATE, SYSDATE, 1, #{remark})
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?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.biStaticField.repository.mapper.BiStaticFieldMapper">
|
||||
|
||||
<!-- 业务静态字段配置(YMS 库):按字段编码查询全部有效配置
|
||||
含 GLOBAL / FLOOR / WINDOW 各作用域,由程序按「WINDOW > FLOOR > GLOBAL」优先级取值 -->
|
||||
<select id="queryByCode" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||
SELECT
|
||||
FIELD_CODE AS fieldCode,
|
||||
FIELD_NAME AS fieldName,
|
||||
SCOPE_TYPE AS scopeType,
|
||||
SCOPE_CODE AS scopeCode,
|
||||
FIELD_VALUE AS fieldValue,
|
||||
UNIT AS unit
|
||||
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||
WHERE DEL_FLAG = 1
|
||||
AND FIELD_CODE = #{fieldCode}
|
||||
</select>
|
||||
|
||||
<!-- 批量按字段编码查询 -->
|
||||
<select id="queryByCodes" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||
SELECT
|
||||
FIELD_CODE AS fieldCode,
|
||||
FIELD_NAME AS fieldName,
|
||||
SCOPE_TYPE AS scopeType,
|
||||
SCOPE_CODE AS scopeCode,
|
||||
FIELD_VALUE AS fieldValue,
|
||||
UNIT AS unit
|
||||
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||
WHERE DEL_FLAG = 1
|
||||
AND FIELD_CODE IN
|
||||
<foreach collection="fieldCodes" item="c" open="(" separator="," close=")">
|
||||
#{c}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部有效配置 -->
|
||||
<select id="queryAll" resultType="com.mhd.bi.domain.biStaticField.repository.po.BiStaticFieldPO">
|
||||
SELECT
|
||||
FIELD_CODE AS fieldCode,
|
||||
FIELD_NAME AS fieldName,
|
||||
SCOPE_TYPE AS scopeType,
|
||||
SCOPE_CODE AS scopeCode,
|
||||
FIELD_VALUE AS fieldValue,
|
||||
UNIT AS unit
|
||||
FROM NGWL_TEST_YMS.QMS_STATIC_FIELD
|
||||
WHERE DEL_FLAG = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?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.biWarehouseTransport.repository.mapper.BiWarehouseTransportRealDataMapper">
|
||||
|
||||
<!-- 仓储订单量:本年度 / 本季度 / 本月度 = 入库业务单 + 出库业务单 数量合计
|
||||
统计范围:全部组织
|
||||
口径:del_flag = 1(有效);本季度用「月份向上取整 / 3」判断同季度 -->
|
||||
|
||||
<select id="queryWarehouseOrderStat" resultType="com.mhd.bi.domain.biWarehouseTransport.repository.po.RealWarehouseOrderStatPO">
|
||||
SELECT
|
||||
(SELECT NVL(SUM(c), 0) FROM (
|
||||
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
UNION ALL
|
||||
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
)) AS currentYearOrders,
|
||||
(SELECT NVL(SUM(c), 0) FROM (
|
||||
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
AND CEIL(TO_NUMBER(TO_CHAR(CREATE_TIME, 'MM')) / 3) = CEIL(TO_NUMBER(TO_CHAR(SYSDATE, 'MM')) / 3)
|
||||
UNION ALL
|
||||
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY') = TO_CHAR(SYSDATE, 'YYYY')
|
||||
AND CEIL(TO_NUMBER(TO_CHAR(CREATE_TIME, 'MM')) / 3) = CEIL(TO_NUMBER(TO_CHAR(SYSDATE, 'MM')) / 3)
|
||||
)) AS currentQuarterOrders,
|
||||
(SELECT NVL(SUM(c), 0) FROM (
|
||||
SELECT COUNT(1) AS c FROM NGWL_TEST_WMS.STOCK_IN_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
UNION ALL
|
||||
SELECT COUNT(1) FROM NGWL_TEST_WMS.STOCK_OUT_ORDER
|
||||
WHERE del_flag = 1 AND TO_CHAR(CREATE_TIME, 'YYYY-MM') = TO_CHAR(SYSDATE, 'YYYY-MM')
|
||||
)) AS currentMonthOrders
|
||||
FROM DUAL
|
||||
</select>
|
||||
|
||||
<!-- 今日订单数量:OMS 运输业务单,今日创建,全部组织 -->
|
||||
<select id="countTodayTransportOrders" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||
WHERE CREATE_TIME IS NOT NULL
|
||||
AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE)
|
||||
AND IS_DELETE = 0
|
||||
</select>
|
||||
|
||||
<!-- 今日运输车次:TMS 运输单(运单),今日创建,全部组织
|
||||
口径:一个单 = 一个车次,直接按单计数(不做单号去重,避免单号为空被漏计) -->
|
||||
<select id="countTodayTransportTrips" resultType="java.lang.Long">
|
||||
SELECT COUNT(1)
|
||||
FROM NGWL_TEST_WLHY.TMS_TRANSPORT_NOTE
|
||||
WHERE CREATE_TIME IS NOT NULL
|
||||
AND TRUNC(CREATE_TIME) = TRUNC(SYSDATE)
|
||||
AND (IS_DELETE IS NULL OR IS_DELETE = 0)
|
||||
</select>
|
||||
|
||||
<!-- 客户贡献排名:OMS 运输业务单,近半年按货主(APPOINT_SHIPPER)聚合订单数,取前 5 名
|
||||
统计范围:全部组织;口径:一个单 = 一单,COUNT(1) -->
|
||||
<select id="queryCustomerRankTop5" resultType="com.mhd.bi.domain.biWarehouseTransport.repository.po.RealCustomerRankPO">
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
APPOINT_SHIPPER AS customerName,
|
||||
CEIL(COUNT(1)) AS customerAmount
|
||||
FROM NGWL_TEST_OMS.BUSINESS_DOCUMENT_ORDER
|
||||
WHERE CREATE_TIME IS NOT NULL
|
||||
AND CREATE_TIME >= ADD_MONTHS(TRUNC(SYSDATE, 'MM'), -5)
|
||||
AND IS_DELETE = 0
|
||||
AND APPOINT_SHIPPER IS NOT NULL
|
||||
AND APPOINT_SHIPPER != ''
|
||||
GROUP BY APPOINT_SHIPPER
|
||||
ORDER BY COUNT(1) DESC
|
||||
)
|
||||
WHERE ROWNUM <= 5
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+1
-1
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(value = "mhd-third-party-service",url = "${feign.url.mhd-third-party-service:}", configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(value = "mhd-third-party-service",url = "http://10.102.192.31:8012", configuration = FeignAutoConfiguration.class)
|
||||
public interface ThirdPartyServiceFeign {
|
||||
|
||||
//查询当前组织所有三方接口信息
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.Map;
|
||||
* 三方服务 Feign
|
||||
*/
|
||||
// 目标地址由 nacos 配置项 feign.url.mhd-third-party-service 指定,未配置时按服务名走服务发现
|
||||
@FeignClient(contextId = "thirdPartyServiceFeign",url = "${feign.url.mhd-third-party-service:}", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
|
||||
@FeignClient(contextId = "thirdPartyServiceFeign",url = "http://10.102.192.31:8012", value = ServiceNameConstants.THIRDPARTY_CENTER, configuration = FeignAutoConfiguration.class)
|
||||
public interface ThirdPartyServiceFeign {
|
||||
|
||||
//查询当前组织所有三方接口信息
|
||||
|
||||
+2
@@ -32,6 +32,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
@@ -205,6 +206,7 @@ public class HandoverTaskOrderApplicationService {
|
||||
* @param handoverTaskOrderDO
|
||||
* @return Boolean
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean completeHandover(HandoverTaskOrderDO handoverTaskOrderDO){
|
||||
Boolean result = handoverTaskOrderDomainService.completeHandover(handoverTaskOrderDO);
|
||||
List<MaterialInventoryParamDO> clearoutParamDOs = handoverTaskOrderDomainService.getLastClearoutParamDOs();
|
||||
|
||||
+2
-2
@@ -994,7 +994,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
MaterialInventory materialInventory = new MaterialInventory();
|
||||
materialInventoryPO.setUpdateTime(new Date());
|
||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventoryPO);
|
||||
}
|
||||
}
|
||||
private void qxff(BigDecimal netWeight, BigDecimal grossWeight, BigDecimal volume, BigDecimal area, BigDecimal quantity, Long materialInventoryId) {
|
||||
@@ -1092,7 +1092,7 @@ public class MaterialInventoryImpl extends ServiceImpl<MaterialInventoryMapper,
|
||||
materialInventoryPO.setUpdateTime(new Date());
|
||||
MaterialInventory materialInventory = new MaterialInventory();
|
||||
com.mhd.common.core.utils.bean.BeanUtils.copyProperties(materialInventoryPO, materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventory);
|
||||
materialInventoryMapper.updateById(materialInventoryPO);
|
||||
|
||||
Long warehouseId = materialInventoryPO.getWarehouseId();
|
||||
boolean needPush = false;
|
||||
|
||||
+3
-1
@@ -860,7 +860,9 @@ public class StockShelfOrderDomainService {
|
||||
//修改入库单状态: 1-已创建 2-已审核 3-收货中 4-上架中 5-已入库
|
||||
updateStockInOrder(stockShelfOrderPO, 5);
|
||||
//上架修改物料库存
|
||||
List<ShelfMaterialDetail> shelfMaterialDetailList = shelfMaterialDetailService.list(new QueryWrapper<ShelfMaterialDetail>().lambda().eq(ShelfMaterialDetail::getShelfOrderNumber, stockShelfOrderPO.getShelfOrderNumber()));
|
||||
List<ShelfMaterialDetail> shelfMaterialDetailList = shelfMaterialDetailService.list(new QueryWrapper<ShelfMaterialDetail>().lambda()
|
||||
.eq(ShelfMaterialDetail::getShelfOrderNumber, stockShelfOrderPO.getShelfOrderNumber())
|
||||
.eq(ShelfMaterialDetail::getDelFlag, 1));
|
||||
//修改库存
|
||||
StockShelfOrderDO stockShelfOrderDO = new StockShelfOrderDO();
|
||||
BeanUtils.copyProperties(stockShelfOrderPO, stockShelfOrderDO);
|
||||
|
||||
@@ -16,7 +16,7 @@ spring:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
server-addr: 10.102.192.30:6848
|
||||
server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
@@ -25,7 +25,7 @@ spring:
|
||||
# server-addr: 127.0.0.1:8848
|
||||
# server-addr: 10.33.0.129:6010
|
||||
# 线上测试环境配置 容器名+端口号
|
||||
server-addr: 10.102.192.30:6848
|
||||
server-addr: 10.102.192.31:6848
|
||||
username: nacos
|
||||
password: manhuoda@2023
|
||||
#线上正式环境
|
||||
|
||||
Reference in New Issue
Block a user