|
|
@ -274,73 +274,76 @@ public class WarnServiceImpl implements WarnService { |
|
|
// exaHistoryReqVO.setEndTime("2023-10-28 23:00:00");
|
|
|
// exaHistoryReqVO.setEndTime("2023-10-28 23:00:00");
|
|
|
// exaHistoryReqVO.setInterval(60L);
|
|
|
// exaHistoryReqVO.setInterval(60L);
|
|
|
List<List<Double>> inputData = exaUtils.getHistory(EXA_IP, exaHistoryReqVO); |
|
|
List<List<Double>> inputData = exaUtils.getHistory(EXA_IP, exaHistoryReqVO); |
|
|
|
|
|
exaHistoryReqVO.setItemName(outpoint); |
|
|
List<List<Double>> outputData = exaUtils.getHistory(EXA_IP, exaHistoryReqVO); |
|
|
List<List<Double>> outputData = exaUtils.getHistory(EXA_IP, exaHistoryReqVO); |
|
|
// 4. 数据校验
|
|
|
// 4. 数据校验
|
|
|
if (inputData.isEmpty() || outputData.isEmpty()) { |
|
|
if (inputData != null || outputData != null) { |
|
|
throw exception(EXA_HISTORY_IS_EMPTY,"历史数据为空,point: " + point + ", outputPoint: " + outpoint); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//直接深拷贝outputData
|
|
|
//直接深拷贝outputData
|
|
|
//上限值列表
|
|
|
//上限值列表
|
|
|
List<List<Double>> upList = new ArrayList<>(outputData.size()); |
|
|
List<List<Double>> upList = new ArrayList<>(outputData.size()); |
|
|
for (List<Double> inner : outputData) { |
|
|
for (List<Double> inner : outputData) { |
|
|
upList.add(new ArrayList<>(inner)); |
|
|
upList.add(new ArrayList<>(inner)); |
|
|
} |
|
|
} |
|
|
//下限值列表
|
|
|
//下限值列表
|
|
|
List<List<Double>> lowList = new ArrayList<>(outputData.size()); |
|
|
List<List<Double>> lowList = new ArrayList<>(outputData.size()); |
|
|
for (List<Double> inner : outputData) { |
|
|
for (List<Double> inner : outputData) { |
|
|
lowList.add(new ArrayList<>(inner)); |
|
|
lowList.add(new ArrayList<>(inner)); |
|
|
} |
|
|
} |
|
|
//告警值列表
|
|
|
//告警值列表
|
|
|
List<List<Double>> errorList = new ArrayList<>(outputData.size()); |
|
|
List<List<Double>> errorList = new ArrayList<>(outputData.size()); |
|
|
for (List<Double> inner : outputData) { |
|
|
for (List<Double> inner : outputData) { |
|
|
errorList.add(new ArrayList<>(inner)); |
|
|
errorList.add(new ArrayList<>(inner)); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 7. 数据处理:计算上下限、误差标记
|
|
|
|
|
|
for (int i = 0; i < outputData.size(); i++) { |
|
|
|
|
|
List<Double> inputRow = inputData.get(i); |
|
|
|
|
|
List<Double> outputRow = outputData.get(i); |
|
|
|
|
|
Double inputValue = inputRow.size() > 1 ? inputRow.get(1) : null; |
|
|
|
|
|
Double outputValue = outputRow.size() > 1 ? outputRow.get(1) : null; |
|
|
|
|
|
// 计算上下限
|
|
|
|
|
|
double h = (outputValue != null ? outputValue : 0) + Double.parseDouble(uplimit); |
|
|
|
|
|
double l = (outputValue != null ? outputValue : 0) + Double.parseDouble(lowlimit); |
|
|
|
|
|
|
|
|
|
|
|
// ⚠️ 分别拷贝
|
|
|
|
|
|
List<Double> upRow = new ArrayList<>(outputRow); |
|
|
|
|
|
upRow.set(1, h); |
|
|
|
|
|
upList.set(i, upRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Double> lowRow = new ArrayList<>(outputRow); |
|
|
|
|
|
lowRow.set(1, l); |
|
|
|
|
|
lowList.set(i, lowRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Double> errorRow = new ArrayList<>(outputRow); |
|
|
|
|
|
|
|
|
|
|
|
// 误差标记(1表示异常,null表示正常)
|
|
|
|
|
|
if (inputValue != null && (inputValue < l || inputValue > h)) { |
|
|
|
|
|
errorRow.set(1, 1.0); |
|
|
|
|
|
} else { |
|
|
|
|
|
errorRow.set(1, null); |
|
|
|
|
|
} |
|
|
} |
|
|
errorList.set(i, errorRow); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 8. 组装结果对象
|
|
|
// 7. 数据处理:计算上下限、误差标记
|
|
|
AlarmTrendRespVO result = new AlarmTrendRespVO(); |
|
|
for (int i = 0; i < outputData.size(); i++) { |
|
|
result.setRealTimeList(inputData); |
|
|
List<Double> inputRow = inputData.get(i); |
|
|
result.setUpList(upList); |
|
|
List<Double> outputRow = outputData.get(i); |
|
|
result.setLowList(lowList); |
|
|
Double inputValue = inputRow.size() > 1 ? inputRow.get(1) : null; |
|
|
result.setErrorList(errorList); |
|
|
Double outputValue = outputRow.size() > 1 ? outputRow.get(1) : null; |
|
|
result.setGzpName(warnDO.getGzpName() + " " + warnDO.getUnit()); |
|
|
// 计算上下限
|
|
|
result.setValueList(Arrays.asList(inputData, upList, lowList, errorList)); |
|
|
double h = (outputValue != null ? outputValue : 0) + Double.parseDouble(uplimit); |
|
|
result.setTagList(Arrays.asList("实时值", "上限值", "下限值", "告警值")); |
|
|
double l = (outputValue != null ? outputValue : 0) + Double.parseDouble(lowlimit); |
|
|
return result; |
|
|
|
|
|
|
|
|
// ⚠️ 分别拷贝
|
|
|
|
|
|
List<Double> upRow = new ArrayList<>(outputRow); |
|
|
|
|
|
upRow.set(1, h); |
|
|
|
|
|
upList.set(i, upRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Double> lowRow = new ArrayList<>(outputRow); |
|
|
|
|
|
lowRow.set(1, l); |
|
|
|
|
|
lowList.set(i, lowRow); |
|
|
|
|
|
|
|
|
|
|
|
List<Double> errorRow = new ArrayList<>(outputRow); |
|
|
|
|
|
|
|
|
|
|
|
// 误差标记(1表示异常,null表示正常)
|
|
|
|
|
|
if (inputValue != null && (inputValue < l || inputValue > h)) { |
|
|
|
|
|
errorRow.set(1, 1.0); |
|
|
|
|
|
} else { |
|
|
|
|
|
errorRow.set(1, null); |
|
|
|
|
|
} |
|
|
|
|
|
errorList.set(i, errorRow); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 8. 组装结果对象
|
|
|
|
|
|
AlarmTrendRespVO result = new AlarmTrendRespVO(); |
|
|
|
|
|
result.setRealTimeList(inputData); |
|
|
|
|
|
result.setUpList(upList); |
|
|
|
|
|
result.setLowList(lowList); |
|
|
|
|
|
result.setErrorList(errorList); |
|
|
|
|
|
result.setGzpName(warnDO.getGzpName() + " " + warnDO.getUnit()); |
|
|
|
|
|
result.setValueList(Arrays.asList(inputData, upList, lowList, errorList)); |
|
|
|
|
|
result.setTagList(Arrays.asList("实时值", "上限值", "下限值", "告警值")); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
log.error("getAlarmTrend error, point: {}", point); |
|
|
|
|
|
throw exception(ALARM_TREND_FAILED, "获取告警趋势失败: 数据为空"); |
|
|
|
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("getAlarmTrend error", e); |
|
|
log.error("getAlarmTrend error", e); |
|
|
throw exception(ALARM_TREND_FAILED, "获取告警趋势失败: " + e.getMessage()); |
|
|
throw exception(ALARM_TREND_FAILED, "获取告警趋势失败: " + e.getMessage()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|