BI大屏总体运营态势查询修改1
This commit is contained in:
+78
@@ -0,0 +1,78 @@
|
|||||||
|
package com.mhd.bi.domain.biOverallOperation.support;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
import com.mhd.bi.domain.biReport.support.BiOnTimeDeliveryRateChartSupport;
|
||||||
|
import com.mhd.bi.domain.biReport.support.BiWarehouseCapabilityRankingSupport;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallOperationSituationVO;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallTransportOperationVO;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallWarehouseOperationVO;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总体运营态势:左侧保留 warehouse.capabilityRanking;右下角 transport.on_time_rate 替代 enterpriseRanking。
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public final class OverallOperationPayloadNormalizer {
|
||||||
|
|
||||||
|
private static final ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
|
private OverallOperationPayloadNormalizer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalizeJson(String json) {
|
||||||
|
if (StringUtils.isBlank(json)) {
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JsonNode root = MAPPER.readTree(json.trim());
|
||||||
|
boolean changed = false;
|
||||||
|
|
||||||
|
JsonNode warehouse = root.path("warehouse");
|
||||||
|
if (warehouse.isObject()) {
|
||||||
|
ObjectNode warehouseObj = (ObjectNode) warehouse;
|
||||||
|
if (warehouseObj.has("on_time_rate")) {
|
||||||
|
warehouseObj.remove("on_time_rate");
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonNode transport = root.path("transport");
|
||||||
|
if (transport.isObject()) {
|
||||||
|
ObjectNode transportObj = (ObjectNode) transport;
|
||||||
|
if (transportObj.has("enterpriseRanking")) {
|
||||||
|
transportObj.remove("enterpriseRanking");
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
if (!transportObj.has("on_time_rate")) {
|
||||||
|
transportObj.set("on_time_rate",
|
||||||
|
MAPPER.valueToTree(BiOnTimeDeliveryRateChartSupport.defaultChart()));
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed ? MAPPER.writeValueAsString(root) : json;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("总体运营态势 PAYLOAD_JSON 规范化失败,按原 JSON 解析", e);
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OverallOperationSituationVO ensureDefaults(OverallOperationSituationVO vo) {
|
||||||
|
if (vo == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
OverallWarehouseOperationVO warehouse = vo.getWarehouse();
|
||||||
|
if (warehouse != null
|
||||||
|
&& (warehouse.getCapabilityRanking() == null || warehouse.getCapabilityRanking().isEmpty())) {
|
||||||
|
warehouse.setCapabilityRanking(BiWarehouseCapabilityRankingSupport.defaultRanking());
|
||||||
|
}
|
||||||
|
OverallTransportOperationVO transport = vo.getTransport();
|
||||||
|
if (transport != null && BiOnTimeDeliveryRateChartSupport.isChartEmpty(transport.getOnTimeRate())) {
|
||||||
|
transport.setOnTimeRate(BiOnTimeDeliveryRateChartSupport.defaultChart());
|
||||||
|
}
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package com.mhd.bi.domain.biReport.support;
|
||||||
|
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.transportZone.TrMonthValuePointVO;
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.transportZone.TrTypedChartVO;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 准时配送率折线图(总体运营 transport.on_time_rate、运输运营专区 on_time_rate 共用)
|
||||||
|
*/
|
||||||
|
public final class BiOnTimeDeliveryRateChartSupport {
|
||||||
|
|
||||||
|
private BiOnTimeDeliveryRateChartSupport() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TrTypedChartVO defaultChart() {
|
||||||
|
return TrTypedChartVO.builder()
|
||||||
|
.title("准时配送率")
|
||||||
|
.type("line")
|
||||||
|
.unit("%")
|
||||||
|
.data(defaultMonthPoints())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<TrMonthValuePointVO> defaultMonthPoints() {
|
||||||
|
return Arrays.asList(
|
||||||
|
TrMonthValuePointVO.builder().month("1月").value(98).build(),
|
||||||
|
TrMonthValuePointVO.builder().month("2月").value(96).build(),
|
||||||
|
TrMonthValuePointVO.builder().month("3月").value(85).build(),
|
||||||
|
TrMonthValuePointVO.builder().month("4月").value(70).build(),
|
||||||
|
TrMonthValuePointVO.builder().month("5月").value(92).build(),
|
||||||
|
TrMonthValuePointVO.builder().month("6月").value(90).build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isChartEmpty(TrTypedChartVO chart) {
|
||||||
|
return chart == null || chart.getData() == null || chart.getData().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TrTypedChartVO emptyChartShell() {
|
||||||
|
return TrTypedChartVO.builder()
|
||||||
|
.title("")
|
||||||
|
.type("")
|
||||||
|
.unit("")
|
||||||
|
.data(Collections.emptyList())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package com.mhd.bi.domain.biReport.support;
|
||||||
|
|
||||||
|
import com.mhd.bi.interfaces.facadeApi.biReport.vo.overall.OverallWarehouseCapabilityRankVO;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总体运营态势左侧「仓储运营能力」表格默认数据
|
||||||
|
*/
|
||||||
|
public final class BiWarehouseCapabilityRankingSupport {
|
||||||
|
|
||||||
|
private BiWarehouseCapabilityRankingSupport() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<OverallWarehouseCapabilityRankVO> defaultRanking() {
|
||||||
|
return Arrays.asList(
|
||||||
|
OverallWarehouseCapabilityRankVO.builder().rank(1).name("横琴仓")
|
||||||
|
.processedVolume("2,400单").throughput("5.2万吨").utilizationRate("85%").build(),
|
||||||
|
OverallWarehouseCapabilityRankVO.builder().rank(2).name("陆路仓")
|
||||||
|
.processedVolume("1,800单").throughput("4.1万吨").utilizationRate("78%").build(),
|
||||||
|
OverallWarehouseCapabilityRankVO.builder().rank(3).name("联丰仓")
|
||||||
|
.processedVolume("1,200单").throughput("3.5万吨").utilizationRate("92%").build(),
|
||||||
|
OverallWarehouseCapabilityRankVO.builder().rank(4).name("香港仓")
|
||||||
|
.processedVolume("800单").throughput("2.2万吨").utilizationRate("65%").build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user