Browse Source

1、冷源瞬时冷量、累计冷量计算

dev_bl_eems
3067418132@qq.com 4 weeks ago
parent
commit
f15bc6056f
  1. 113
      mh-quartz/src/main/java/com/mh/quartz/task/GetOtherSysDataJob.java

113
mh-quartz/src/main/java/com/mh/quartz/task/GetOtherSysDataJob.java

@ -62,6 +62,12 @@ public class GetOtherSysDataJob {
"PowerTotal" // 机房累计读数 "PowerTotal" // 机房累计读数
}; };
//TODO 冷源制冷量
private final String[] coolingSourceMeters = new String[]{
"ColdRealLoadKW", // 瞬时冷量
"ColdRealLoadTONTatol" // 累计冷量
};
//TODO 主机总电表 //TODO 主机总电表
private final String[] powerMeters = new String[]{ private final String[] powerMeters = new String[]{
"ChPower", // 主机实时功率 "ChPower", // 主机实时功率
@ -138,10 +144,12 @@ public class GetOtherSysDataJob {
} }
// 判断如果等于totalMeters、powerMeters、freezePumpMeters、coolPumpMeters、towerMeters的点位,就下一个循环 // 判断如果等于totalMeters、powerMeters、freezePumpMeters、coolPumpMeters、towerMeters的点位,就下一个循环
if (totalMeters[0].equals(param.getMtCode()) || totalMeters[1].equals(param.getMtCode()) || if (totalMeters[0].equals(param.getMtCode()) || totalMeters[1].equals(param.getMtCode()) ||
powerMeters[0].equals(param.getMtCode()) || powerMeters[1].equals(param.getMtCode()) || powerMeters[0].equals(param.getMtCode()) || powerMeters[1].equals(param.getMtCode()) ||
freezePumpMeters[0].equals(param.getMtCode()) || freezePumpMeters[1].equals(param.getMtCode()) || freezePumpMeters[0].equals(param.getMtCode()) || freezePumpMeters[1].equals(param.getMtCode()) ||
coolPumpMeters[0].equals(param.getMtCode()) || coolPumpMeters[1].equals(param.getMtCode()) || coolPumpMeters[0].equals(param.getMtCode()) || coolPumpMeters[1].equals(param.getMtCode()) ||
towerMeters[0].equals(param.getMtCode()) || towerMeters[1].equals(param.getMtCode())) { towerMeters[0].equals(param.getMtCode()) || towerMeters[1].equals(param.getMtCode()) ||
coolingSourceMeters[0].equals(param.getMtCode()) || coolingSourceMeters[1].equals(param.getMtCode())
) {
continue; continue;
} }
@ -243,7 +251,8 @@ public class GetOtherSysDataJob {
/** /**
* 计算并添加汇总数据到cumulativeDatas * 计算并添加汇总数据到cumulativeDatas
* @param cumulativeDatas 累计读数数据列表 *
* @param cumulativeDatas 累计读数数据列表
* @param mtCodeToOtherNameMap mtCode到otherName的映射关系 * @param mtCodeToOtherNameMap mtCode到otherName的映射关系
*/ */
private void calculateAndAddSummaryData(List<AdvantechDatas<BigDecimal>> cumulativeDatas, HashMap<String, String> mtCodeToOtherNameMap) { private void calculateAndAddSummaryData(List<AdvantechDatas<BigDecimal>> cumulativeDatas, HashMap<String, String> mtCodeToOtherNameMap) {
@ -259,23 +268,37 @@ public class GetOtherSysDataJob {
CHWP_POWER("冷冻泵", "瞬时功率", "PriChWPPower", "冷冻泵总瞬时功率"), CHWP_POWER("冷冻泵", "瞬时功率", "PriChWPPower", "冷冻泵总瞬时功率"),
CWP_POWER("冷却泵", "瞬时功率", "CWPPower", "冷却泵总瞬时功率"), CWP_POWER("冷却泵", "瞬时功率", "CWPPower", "冷却泵总瞬时功率"),
CT_POWER("冷却塔", "瞬时功率", "CTPower", "冷却塔总瞬时功率"), CT_POWER("冷却塔", "瞬时功率", "CTPower", "冷却塔总瞬时功率"),
// 冷源瞬时冷量(特殊计算:SystemRealLoadTON - HPSystemRealLoadTON)
CH_COLD_INSTANT("冷源", "瞬时冷量", "ColdRealLoadKW", "冷源总冷量计瞬时冷量", true),
ALL_COLD_INSTANT("冷源", "累计冷量", "ColdRealLoadTONTatol", "冷源总冷量计读数TON", true),
ALL_POWER(null, "瞬时功率", "Power", "机房总瞬时功率"); ALL_POWER(null, "瞬时功率", "Power", "机房总瞬时功率");
private final String deviceKeyword; private final String deviceKeyword;
private final String dataKeyword; private final String dataKeyword;
private final String mtCode; private final String mtCode;
private final String description; private final String description;
private final boolean isColdCalculation; // 标记是否为冷量计算(需要用减法)
SummaryType(String deviceKeyword, String dataKeyword, String mtCode, String description) { SummaryType(String deviceKeyword, String dataKeyword, String mtCode, String description) {
this(deviceKeyword, dataKeyword, mtCode, description, false);
}
SummaryType(String deviceKeyword, String dataKeyword, String mtCode, String description, boolean isColdCalculation) {
this.deviceKeyword = deviceKeyword; this.deviceKeyword = deviceKeyword;
this.dataKeyword = dataKeyword; this.dataKeyword = dataKeyword;
this.mtCode = mtCode; this.mtCode = mtCode;
this.description = description; this.description = description;
this.isColdCalculation = isColdCalculation;
} }
} }
// 一次性遍历cumulativeDatas,分类累加各类型数据 // 一次性遍历cumulativeDatas,分类累加各类型数据
Map<SummaryType, BigDecimal> summaryMap = new HashMap<>(); Map<SummaryType, BigDecimal> summaryMap = new HashMap<>();
// 缓存原始数据,用于冷量差值计算(按tag缓存)
Map<String, BigDecimal> dataByTag = new HashMap<>();
// 初始化所有汇总类型 // 初始化所有汇总类型
for (SummaryType type : SummaryType.values()) { for (SummaryType type : SummaryType.values()) {
summaryMap.put(type, BigDecimal.ZERO); summaryMap.put(type, BigDecimal.ZERO);
@ -288,15 +311,84 @@ public class GetOtherSysDataJob {
String tag = data.getTag(); String tag = data.getTag();
BigDecimal value = new BigDecimal(data.getValue().toString()); BigDecimal value = new BigDecimal(data.getValue().toString());
// 缓存所有数据,用于冷量计算
dataByTag.put(tag, value);
// 遍历所有汇总类型进行匹配 // 遍历所有汇总类型进行匹配
for (SummaryType type : SummaryType.values()) { for (SummaryType type : SummaryType.values()) {
boolean matchesDataKeyword = tag.contains(type.dataKeyword); boolean matchesDataKeyword = tag.contains(type.dataKeyword);
boolean matchesDeviceKeyword = type.deviceKeyword == null || tag.contains(type.deviceKeyword); boolean matchesDeviceKeyword = type.deviceKeyword == null || tag.contains(type.deviceKeyword);
if (matchesDataKeyword && matchesDeviceKeyword) { if (matchesDataKeyword && matchesDeviceKeyword) {
summaryMap.merge(type, value, BigDecimal::add); // 冷量计算类型不进行累加,使用差值计算
if (!type.isColdCalculation) {
summaryMap.merge(type, value, BigDecimal::add);
}
}
}
}
// 对冷量计算类型执行差值计算
try {
// 从缓存中查找冷量相关数据
BigDecimal hpSystemRealLoadTONTatol = null; // 热泵累计冷量
BigDecimal hpSystemRealLoadTON = null; // 热泵瞬时冷量
BigDecimal systemRealLoadTON = null; // 系统瞬时冷量
BigDecimal systemRealLoadTONTatol = null; // 系统累计冷量
// 查找 hpSystemRealLoadTONTatol
for (Map.Entry<String, BigDecimal> entry : dataByTag.entrySet()) {
if (entry.getKey().contains("HPSystemRealLoadTONTatol")) {
hpSystemRealLoadTONTatol = entry.getValue();
break;
}
}
// 查找 HPSystemRealLoadTON
for (Map.Entry<String, BigDecimal> entry : dataByTag.entrySet()) {
if (entry.getKey().contains("HPSystemRealLoadTON")) {
hpSystemRealLoadTON = entry.getValue();
break;
}
}
// 查找 systemRealLoadTON
for (Map.Entry<String, BigDecimal> entry : dataByTag.entrySet()) {
if (entry.getKey().contains("SystemRealLoadTON")) {
systemRealLoadTON = entry.getValue();
break;
}
}
// 查找 SystemRealLoadTONTatol
for (Map.Entry<String, BigDecimal> entry : dataByTag.entrySet()) {
if (entry.getKey().contains("SystemRealLoadTONTatol")) {
systemRealLoadTONTatol = entry.getValue();
break;
} }
} }
// 计算瞬时冷量:systemRealLoadTON - HPSystemRealLoadTON
if (systemRealLoadTON != null && hpSystemRealLoadTON != null) {
BigDecimal coldRealLoadKW = systemRealLoadTON.subtract(hpSystemRealLoadTON);
summaryMap.put(SummaryType.CH_COLD_INSTANT, coldRealLoadKW);
log.info("计算瞬时冷量: {} - {} = {}", systemRealLoadTON, hpSystemRealLoadTON, coldRealLoadKW);
} else {
log.warn("瞬时冷量计算缺少必要数据,SystemRealLoadTON: {}, HPSystemRealLoadTON: {}",
systemRealLoadTON, hpSystemRealLoadTON);
}
// 计算累计冷量:SystemRealLoadTONTatol - HPSystemRealLoadTONTatol
if (systemRealLoadTONTatol != null && hpSystemRealLoadTONTatol != null) {
BigDecimal coldRealLoadTONTatol = systemRealLoadTONTatol.subtract(hpSystemRealLoadTONTatol);
summaryMap.put(SummaryType.ALL_COLD_INSTANT, coldRealLoadTONTatol);
log.info("计算累计冷量: {} - {} = {}", systemRealLoadTONTatol, hpSystemRealLoadTONTatol, coldRealLoadTONTatol);
} else {
log.warn("累计冷量计算缺少必要数据,SystemRealLoadTONTatol: {}, HPSystemRealLoadTONTatol: {}",
systemRealLoadTONTatol, hpSystemRealLoadTONTatol);
}
} catch (Exception e) {
log.error("计算冷量差值异常", e);
} }
// 创建并添加汇总数据点 // 创建并添加汇总数据点
@ -323,9 +415,10 @@ public class GetOtherSysDataJob {
/** /**
* 获取累计读数数据 * 获取累计读数数据
* @param mtCodes 点位编码列表 *
* @param mtCodes 点位编码列表
* @param mtCodeToOtherNameMap mtCode到otherName的映射关系 * @param mtCodeToOtherNameMap mtCode到otherName的映射关系
* @param realUrl 请求URL * @param realUrl 请求URL
* @return 解析后的数据列表 * @return 解析后的数据列表
*/ */
private List<AdvantechDatas<BigDecimal>> fetchCumulativeData(List<String> mtCodes, HashMap<String, String> mtCodeToOtherNameMap, String realUrl) { private List<AdvantechDatas<BigDecimal>> fetchCumulativeData(List<String> mtCodes, HashMap<String, String> mtCodeToOtherNameMap, String realUrl) {
@ -383,9 +476,9 @@ public class GetOtherSysDataJob {
/** /**
* 获取功率读数数据 * 获取功率读数数据
* *
* @param mtCodes 点位编码列表 * @param mtCodes 点位编码列表
* @param mtCodeToOtherNameMap mtCode到otherName的映射关系 * @param mtCodeToOtherNameMap mtCode到otherName的映射关系
* @param realValuesUrl 请求URL * @param realValuesUrl 请求URL
* @return 解析后的数据列表 * @return 解析后的数据列表
*/ */
private List<AdvantechDatas<BigDecimal>> fetchPowerData(List<String> mtCodes, HashMap<String, String> mtCodeToOtherNameMap, String realValuesUrl) { private List<AdvantechDatas<BigDecimal>> fetchPowerData(List<String> mtCodes, HashMap<String, String> mtCodeToOtherNameMap, String realValuesUrl) {

Loading…
Cancel
Save