|
|
@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.alert.dal.mysql.report.ReportMapper; |
|
|
import cn.iocoder.yudao.module.alert.dal.mysql.warn.WarnCalcMapper; |
|
|
import cn.iocoder.yudao.module.alert.dal.mysql.warn.WarnCalcMapper; |
|
|
import cn.iocoder.yudao.module.alert.service.warn.WarnService; |
|
|
import cn.iocoder.yudao.module.alert.service.warn.WarnService; |
|
|
import cn.iocoder.yudao.module.alert.utils.EXAUtils; |
|
|
import cn.iocoder.yudao.module.alert.utils.EXAUtils; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.google.common.annotations.VisibleForTesting; |
|
|
import com.google.common.annotations.VisibleForTesting; |
|
|
import com.mzt.logapi.context.LogRecordContext; |
|
|
import com.mzt.logapi.context.LogRecordContext; |
|
|
import com.mzt.logapi.service.impl.DiffParseFunction; |
|
|
import com.mzt.logapi.service.impl.DiffParseFunction; |
|
|
@ -259,7 +260,7 @@ try{ |
|
|
// warn.setId(insertId);
|
|
|
// warn.setId(insertId);
|
|
|
//设置实例id
|
|
|
//设置实例id
|
|
|
warnSaveReqVO.setMpId(instant.getMpId()); |
|
|
warnSaveReqVO.setMpId(instant.getMpId()); |
|
|
warnSaveReqVO.setPointOrModel("model"); |
|
|
warnSaveReqVO.setPointOrModel("point"); |
|
|
|
|
|
|
|
|
warnSaveReqVO.setPointId(createReqVO.getInputInfo().get(reportObj.getAssess().get(j).getIndex())); |
|
|
warnSaveReqVO.setPointId(createReqVO.getInputInfo().get(reportObj.getAssess().get(j).getIndex())); |
|
|
warnSaveReqVO.setPointName(createReqVO.getInputName().get(reportObj.getAssess().get(j).getIndex())); |
|
|
warnSaveReqVO.setPointName(createReqVO.getInputName().get(reportObj.getAssess().get(j).getIndex())); |
|
|
@ -497,8 +498,8 @@ try{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
calcReqVO.setExA_IP(EXA_IP); |
|
|
calcReqVO.setExA_IP(EXA_IP); |
|
|
calcReqVO.setModel(JsonUtils.toJsonString(instant.getModelInfo())); |
|
|
calcReqVO.setModel(instant.getModelInfo()); |
|
|
calcReqVO.setInstantInfo_Str( JsonUtils.toJsonString(instant.getInstantInfo())); |
|
|
calcReqVO.setInstantInfo_Str(instant.getInstantInfo()); |
|
|
InstantInfoVO instantInfoVO = JsonUtils.parseObject(instant.getInstantInfo(), InstantInfoVO.class); |
|
|
InstantInfoVO instantInfoVO = JsonUtils.parseObject(instant.getInstantInfo(), InstantInfoVO.class); |
|
|
List<String> pointInfoList = instantInfoVO.getInputInfo(); |
|
|
List<String> pointInfoList = instantInfoVO.getInputInfo(); |
|
|
//循环point
|
|
|
//循环point
|
|
|
@ -512,8 +513,7 @@ try{ |
|
|
calcInfoMap.put("logic", warnCalc.getLastFormula().replaceAll("UPLIMIT", warnCalc.getUplimit()).replaceAll("LOWLIMIT", warnCalc.getLowlimit())); |
|
|
calcInfoMap.put("logic", warnCalc.getLastFormula().replaceAll("UPLIMIT", warnCalc.getUplimit()).replaceAll("LOWLIMIT", warnCalc.getLowlimit())); |
|
|
calcInfoMap.put("TimeLong", warnCalc.getTimeDurationThreshold()); |
|
|
calcInfoMap.put("TimeLong", warnCalc.getTimeDurationThreshold()); |
|
|
calcInfoMap.put("Vaild", true); // 注意字段名是否与实体类一致
|
|
|
calcInfoMap.put("Vaild", true); // 注意字段名是否与实体类一致
|
|
|
} |
|
|
} else { |
|
|
else{ |
|
|
|
|
|
calcInfoMap.put("logic", "1=1"); |
|
|
calcInfoMap.put("logic", "1=1"); |
|
|
calcInfoMap.put("TimeLong", "0"); |
|
|
calcInfoMap.put("TimeLong", "0"); |
|
|
calcInfoMap.put("Vaild", false); // 注意字段名是否与实体类一致
|
|
|
calcInfoMap.put("Vaild", false); // 注意字段名是否与实体类一致
|
|
|
@ -529,18 +529,34 @@ try{ |
|
|
|
|
|
|
|
|
//调用http接口,获取计算结果 http://120.26.116.243:8098/api/PCA/deepTrack
|
|
|
//调用http接口,获取计算结果 http://120.26.116.243:8098/api/PCA/deepTrack
|
|
|
String url = "http://120.26.116.243:8098/api/PCA/deepTrack"; |
|
|
String url = "http://120.26.116.243:8098/api/PCA/deepTrack"; |
|
|
|
|
|
String params = JsonUtils.toJsonString(calcReqVO); |
|
|
// 调用http接口,获取计算结果
|
|
|
// 调用http接口,获取计算结果
|
|
|
String result = HttpUtils.post(url, null, JsonUtils.toJsonString(calcReqVO)); |
|
|
String httpResult = HttpUtils.post(url, null, params); |
|
|
|
|
|
JSONObject jsonResult = JsonUtils.parseObject(httpResult, JSONObject.class); |
|
|
|
|
|
try { |
|
|
|
|
|
String result = jsonResult.getString("result"); |
|
|
|
|
|
if (!"OK".equals(result)) { |
|
|
|
|
|
throw exception(CALCULATE_ERROR, "计算失败"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw exception(CALCULATE_ERROR, "结果有误,返回结果为: " +jsonResult+ ",异常信息为: "+e.getMessage()); |
|
|
|
|
|
} |
|
|
// 解析返回结果
|
|
|
// 解析返回结果
|
|
|
instantCalcResultVO = JsonUtils.parseObject(result, InstantCalcResultVO.class); |
|
|
String rtn = jsonResult.getString("rtn"); |
|
|
|
|
|
// ... 新增:检查 rtn 是否为空
|
|
|
|
|
|
if (StrUtil.isBlank(rtn)) { |
|
|
|
|
|
throw exception(CALCULATE_ERROR, "计算结果 rtn 为空"); |
|
|
|
|
|
} |
|
|
|
|
|
// ... 新增:捕获 JSON 解析异常
|
|
|
|
|
|
try { |
|
|
|
|
|
instantCalcResultVO = JsonUtils.parseObject(rtn, InstantCalcResultVO.class); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw exception(CALCULATE_ERROR, "解析计算结果失败,rtn: " + rtn + ",异常信息: " + e.getMessage()); |
|
|
|
|
|
} |
|
|
// 3. 记录操作日志上下文
|
|
|
// 3. 记录操作日志上下文
|
|
|
LogRecordContext.putVariable("instant", calcReqVO); |
|
|
LogRecordContext.putVariable("instant", calcReqVO); |
|
|
return instantCalcResultVO; |
|
|
return instantCalcResultVO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|