|
@@ -12,6 +12,7 @@ import com.slibra.business.req.DecisionReq;
|
|
|
import com.slibra.business.req.PolicyReq;
|
|
|
import com.slibra.business.res.ShowValueCSBasic;
|
|
|
import com.slibra.business.res.ShowValueJSBasic;
|
|
|
+import com.slibra.common.DecimalUtils;
|
|
|
import com.slibra.common.constant.MyConstants;
|
|
|
import com.slibra.common.enums.BusinessEnum;
|
|
|
import com.slibra.common.utils.DateUtils;
|
|
@@ -65,6 +66,9 @@ public class AsyncTask {
|
|
|
@Autowired
|
|
|
private TXinyiForecastComparisonMapper xinyiForecastComparisonMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TXinyiBigTableHourMapper xinyiBigTableHourMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
*
|
|
@@ -95,6 +99,17 @@ public class AsyncTask {
|
|
|
|
|
|
//2024年5月28日14:14:26 下面是新增的 生化报警处理
|
|
|
this.handleSHWarning(tXinyiIndustry, normConfig, xinyiCalculate);
|
|
|
+
|
|
|
+ //2024年7月3日18:01:13 额外处理大表数据
|
|
|
+ this.addBigTable(tXinyiIndustry, xinyiCalculate);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addBigTable(TXinyiIndustry tXinyiIndustry, TXinyiCalculate xinyiCalculate) {
|
|
|
+ TXinyiBigTableHour xinyiBigTableHour = TXinyiBigTableHour.builder().build();
|
|
|
+
|
|
|
+ //todo 数据处理
|
|
|
+
|
|
|
+ this.xinyiBigTableHourMapper.insertTXinyiBigTableHour(xinyiBigTableHour);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -769,7 +784,7 @@ public class AsyncTask {
|
|
|
this.xinyiWarningRecordMapper.insertTXinyiWarningRecord(tXinyiWarningRecord);
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
//继续调用决策(普通问答)
|
|
|
this.askBigModelForSHWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
@@ -779,7 +794,7 @@ public class AsyncTask {
|
|
|
for (TXinyiWarningRecord xinyiWarningRecord : tXinyiWarningRecords) {//理论上只有一个的
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
//继续调用决策(普通问答)
|
|
|
this.askBigModelForSHWarning(xinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
@@ -883,12 +898,19 @@ public class AsyncTask {
|
|
|
//这种问答 没有历史问答的概念 直接把问题扔进去就行 无需查询历史记录
|
|
|
List<String> historyDates = new ArrayList<>();
|
|
|
//构建问题(替换提示词中的占位符)
|
|
|
- String shWarningPrompt = SH_WARNING_PROMPT;
|
|
|
+ /*String shWarningPrompt = SH_WARNING_PROMPT;
|
|
|
shWarningPrompt =shWarningPrompt.replace("#{0}", xinyiWarningRecord.getReason());
|
|
|
- shWarningPrompt =shWarningPrompt.replace("#{1}", String.valueOf(xinyiWarningRecord.getDesignVal()));
|
|
|
- shWarningPrompt =shWarningPrompt.replace("#{2}", String.valueOf(xinyiWarningRecord.getControlVal()));
|
|
|
- shWarningPrompt =shWarningPrompt.replace("#{3}", String.valueOf(xinyiWarningRecord.getWarningVal()));
|
|
|
- historyDates.add(shWarningPrompt);
|
|
|
+ shWarningPrompt =shWarningPrompt.replace("#{1}", String.valueOf(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getDesignVal(), INT_2)));
|
|
|
+ shWarningPrompt =shWarningPrompt.replace("#{2}", String.valueOf(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getControlVal(), INT_2)));
|
|
|
+ shWarningPrompt =shWarningPrompt.replace("#{3}", String.valueOf(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getWarningVal(), INT_2)));*/
|
|
|
+ //2024年7月5日10:08:54 拼接优化
|
|
|
+ StringBuilder prompt = new StringBuilder(SH_WARNING_PROMPT_1);
|
|
|
+ prompt.append(xinyiWarningRecord.getReason());
|
|
|
+ prompt.append(SH_WARNING_PROMPT_2).append(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getDesignVal(), INT_2));
|
|
|
+ prompt.append(SH_WARNING_PROMPT_3).append(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getControlVal(), INT_2));
|
|
|
+ prompt.append(SH_WARNING_PROMPT_4).append(DecimalUtils.getAbsAndScale(xinyiWarningRecord.getWarningVal(), INT_2));
|
|
|
+ prompt.append(SH_WARNING_PROMPT_5);
|
|
|
+ historyDates.add(prompt.toString());
|
|
|
// 获取输出流
|
|
|
ManagedChannel channel = null;
|
|
|
try {
|
|
@@ -921,9 +943,9 @@ public class AsyncTask {
|
|
|
chatReq.setSessionId(sessionId);
|
|
|
chatReq.setType(1);//0问答 1决策 2本地 3仿真预测
|
|
|
chatReq.setModule(3);//0专家问答 1智能工单 2智能体助手 3告警 4简报
|
|
|
- String showVal = this.buildShowValue(xinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ String showVal = this.buildShowValue(xinyiWarningRecord, tXinyiIndustry, normConfig, DateUtils.getNowDate());
|
|
|
chatReq.setShowVal(showVal);
|
|
|
- chatReq.setQuestion(shWarningPrompt);
|
|
|
+ chatReq.setQuestion(prompt.toString());
|
|
|
chatReq.setAnswer(sb.toString());
|
|
|
chatReq.setWarningId(String.valueOf(xinyiWarningRecord.getId()));
|
|
|
chatReq.setCounts(counts);//问答次数
|
|
@@ -959,9 +981,10 @@ public class AsyncTask {
|
|
|
* @param tXinyiWarningRecord
|
|
|
* @param tXinyiIndustry
|
|
|
* @param normConfig
|
|
|
- * @param isSpecial 机器人化验库,需要把总磷和总氮的值特殊处理一下
|
|
|
+ * @param isSpecial 机器人化验库,需要把总磷和总氮的值特殊处理一下
|
|
|
+ * @param nowDate
|
|
|
*/
|
|
|
- private void handleDecision(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig, boolean isSpecial) {
|
|
|
+ private void handleDecision(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig, boolean isSpecial, Date nowDate) {
|
|
|
log.info("进入了调⽤大模型决策接口");
|
|
|
ChatReq chatReq = new ChatReq();
|
|
|
// StringBuilder sb = new StringBuilder();
|
|
@@ -1097,7 +1120,7 @@ public class AsyncTask {
|
|
|
/*String userId = SecurityUtils.getUserId().toString();
|
|
|
String username = SecurityUtils.getUsername();*/
|
|
|
chatReq.setUserId(WARNING_DEFAULT_CREATE);
|
|
|
- String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig, nowDate);
|
|
|
chatReq.setShowVal(showVal);//前端展示的数据和提问的数据不一致
|
|
|
chatReq.setQuestion(dataJson);
|
|
|
chatReq.setAnswer(JSON.toJSONString(resultData));
|
|
@@ -1113,7 +1136,7 @@ public class AsyncTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private String buildShowValue(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig) {
|
|
|
+ private String buildShowValue(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig, Date nowDate) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
// JSONObject basic = new JSONObject();
|
|
|
Integer status = tXinyiWarningRecord.getStatus();
|
|
@@ -1150,10 +1173,11 @@ public class AsyncTask {
|
|
|
}
|
|
|
//通用的
|
|
|
// showValueBasic.setA(tXinyiWarningRecord.getReason());
|
|
|
- showValueCSBasic.setB(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM ,warningTime));
|
|
|
- showValueCSBasic.setC(tXinyiWarningRecord.getWarningVal());
|
|
|
- showValueCSBasic.setD(tXinyiWarningRecord.getControlVal());
|
|
|
- showValueCSBasic.setE(tXinyiWarningRecord.getDesignVal());
|
|
|
+// showValueCSBasic.setB(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM ,warningTime));
|
|
|
+ showValueCSBasic.setB(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM ,nowDate));
|
|
|
+ showValueCSBasic.setC(DecimalUtils.getAbsAndScale(tXinyiWarningRecord.getWarningVal(), INT_2));
|
|
|
+ showValueCSBasic.setD(DecimalUtils.getAbsAndScale(tXinyiWarningRecord.getControlVal(), INT_2));
|
|
|
+ showValueCSBasic.setE(DecimalUtils.getAbsAndScale(tXinyiWarningRecord.getDesignVal(), INT_2));
|
|
|
showValueCSBasic.setG(Math.min(count, MAX_COUNT));
|
|
|
if(tXinyiWarningRecord.getType() != 2)
|
|
|
showValueCSBasic.setI(status == 0 ? "报警中" : status == 1 ? "用户关闭" : status == 2 ? "系统关闭" : "应急处理中");
|
|
@@ -1177,8 +1201,8 @@ public class AsyncTask {
|
|
|
//通用的
|
|
|
// showValueBasic.setA(tXinyiWarningRecord.getReason());
|
|
|
showValueJSBasic.setB(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM ,warningTime));
|
|
|
- showValueJSBasic.setC(tXinyiWarningRecord.getWarningVal());
|
|
|
- showValueJSBasic.setE(tXinyiWarningRecord.getDesignVal());
|
|
|
+ showValueJSBasic.setC(DecimalUtils.getAbsAndScale(tXinyiWarningRecord.getWarningVal(), INT_2));
|
|
|
+ showValueJSBasic.setE(DecimalUtils.getAbsAndScale(tXinyiWarningRecord.getDesignVal(), INT_2));
|
|
|
showValueJSBasic.setG(Math.min(count, MAX_COUNT));
|
|
|
if(tXinyiWarningRecord.getType() != 2)
|
|
|
showValueJSBasic.setI(status == 0 ? "报警中" : status == 1 ? "用户关闭" : status == 2 ? "系统关闭" : "应急处理中");
|
|
@@ -1198,32 +1222,32 @@ public class AsyncTask {
|
|
|
JSONObject jsData = new JSONObject();
|
|
|
HashMap<Object, Object> temp1 = new HashMap<>();
|
|
|
BigDecimal jsSlq = tXinyiIndustry.getJsSlq();
|
|
|
- temp1.put("value", jsSlq);
|
|
|
+ temp1.put("value", DecimalUtils.getAbsAndScale(jsSlq, INT_2));
|
|
|
temp1.put("exceed", jsSlq.compareTo(normConfig.getJsslSjz()) >0);
|
|
|
jsData.put("流量", temp1);
|
|
|
HashMap<Object, Object> temp2 = new HashMap<>();
|
|
|
BigDecimal jsCod = tXinyiIndustry.getJsCod();
|
|
|
- temp2.put("value", jsCod);
|
|
|
+ temp2.put("value", DecimalUtils.getAbsAndScale(jsCod, INT_2));
|
|
|
temp2.put("exceed", jsCod.compareTo(normConfig.getJscodSjz()) > 0);
|
|
|
jsData.put("COD", temp2);
|
|
|
HashMap<Object, Object> temp3 = new HashMap<>();
|
|
|
BigDecimal jsNh3 = tXinyiIndustry.getJsNh3();
|
|
|
- temp3.put("value", jsNh3);
|
|
|
+ temp3.put("value", DecimalUtils.getAbsAndScale(jsNh3, INT_2));
|
|
|
temp3.put("exceed", jsNh3.compareTo(normConfig.getJsadSjz()) > 0);
|
|
|
jsData.put("NH3-N", temp3);
|
|
|
HashMap<Object, Object> temp4 = new HashMap<>();
|
|
|
BigDecimal jsTp = tXinyiIndustry.getJsTp();
|
|
|
- temp4.put("value", jsTp);
|
|
|
+ temp4.put("value", DecimalUtils.getAbsAndScale(jsTp, INT_2));
|
|
|
temp4.put("exceed", jsTp.compareTo(normConfig.getJszlSjz()) > 0);
|
|
|
jsData.put("TP", temp4);
|
|
|
HashMap<Object, Object> temp5 = new HashMap<>();
|
|
|
BigDecimal jsSs = tXinyiIndustry.getJsSs();
|
|
|
- temp5.put("value", jsSs);
|
|
|
+ temp5.put("value", DecimalUtils.getAbsAndScale(jsSs, INT_2));
|
|
|
temp5.put("exceed", jsSs.compareTo(normConfig.getJsssSjz()) > 0);
|
|
|
jsData.put("SS", temp5);
|
|
|
HashMap<Object, Object> temp6 = new HashMap<>();
|
|
|
BigDecimal jsTn = tXinyiIndustry.getJsTn();
|
|
|
- temp6.put("value", jsTn);
|
|
|
+ temp6.put("value", DecimalUtils.getAbsAndScale(jsTn, INT_2));
|
|
|
temp6.put("exceed", jsTn.compareTo(normConfig.getJszdSjz()) > 0);
|
|
|
jsData.put("TN", temp6);
|
|
|
return jsData;
|
|
@@ -1234,32 +1258,32 @@ public class AsyncTask {
|
|
|
JSONObject csData = new JSONObject();
|
|
|
HashMap<Object, Object> temp1 = new HashMap<>();
|
|
|
BigDecimal csSlq = tXinyiIndustry.getCsSlqc();
|
|
|
- temp1.put("value", csSlq);
|
|
|
+ temp1.put("value", DecimalUtils.getAbsAndScale(csSlq, INT_2));
|
|
|
temp1.put("exceed", false);//出水水量没有管控值
|
|
|
csData.put("流量", temp1);
|
|
|
HashMap<Object, Object> temp2 = new HashMap<>();
|
|
|
BigDecimal csCod = tXinyiIndustry.getCsCod();
|
|
|
- temp2.put("value", csCod);
|
|
|
+ temp2.put("value", DecimalUtils.getAbsAndScale(csCod, INT_2));
|
|
|
temp2.put("exceed", csCod.compareTo(normConfig.getCscodGkz()) > 0);
|
|
|
csData.put("COD", temp2);
|
|
|
HashMap<Object, Object> temp3 = new HashMap<>();
|
|
|
BigDecimal csNh3 = tXinyiIndustry.getCsNh3();
|
|
|
- temp3.put("value", csNh3);
|
|
|
+ temp3.put("value", DecimalUtils.getAbsAndScale(csNh3, INT_2));
|
|
|
temp3.put("exceed", csNh3.compareTo(normConfig.getCsadGkz()) > 0);
|
|
|
csData.put("NH3-N", temp3);
|
|
|
HashMap<Object, Object> temp4 = new HashMap<>();
|
|
|
BigDecimal csTp = tXinyiIndustry.getCsTp();
|
|
|
- temp4.put("value", csTp);
|
|
|
+ temp4.put("value", DecimalUtils.getAbsAndScale(csTp, INT_2));
|
|
|
temp4.put("exceed", csTp.compareTo(normConfig.getCszlGkz()) > 0);
|
|
|
csData.put("TP", temp4);
|
|
|
HashMap<Object, Object> temp5 = new HashMap<>();
|
|
|
BigDecimal csSs = tXinyiIndustry.getCsSs();
|
|
|
- temp5.put("value", csSs);
|
|
|
+ temp5.put("value", DecimalUtils.getAbsAndScale(csSs, INT_2));
|
|
|
temp5.put("exceed", csSs.compareTo(normConfig.getCsssGkz()) > 0);
|
|
|
csData.put("SS", temp5);
|
|
|
HashMap<Object, Object> temp6 = new HashMap<>();
|
|
|
BigDecimal csTn = tXinyiIndustry.getCsTn();
|
|
|
- temp6.put("value", csTn);
|
|
|
+ temp6.put("value", DecimalUtils.getAbsAndScale(csTn, INT_2));
|
|
|
temp6.put("exceed", csTn.compareTo(normConfig.getCszzGkz()) > 0);
|
|
|
csData.put("TN", temp6);
|
|
|
return csData;
|
|
@@ -1322,25 +1346,35 @@ public class AsyncTask {
|
|
|
}
|
|
|
}
|
|
|
}else{//有告警信息
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
if(CollectionUtils.isEmpty(tXinyiWarningRecords)){//之前没有告警记录
|
|
|
//保存到数据库中
|
|
|
this.xinyiWarningRecordMapper.insertTXinyiWarningRecord(tXinyiWarningRecord);
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, false);
|
|
|
+ this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, false, nowDate);
|
|
|
}
|
|
|
}else{
|
|
|
log.info("{}:之前已经有过告警记录了,且还是继续报警,无需重复添加报警,但是决策仍然要调用", category);
|
|
|
for (TXinyiWarningRecord xinyiWarningRecord : tXinyiWarningRecords) {//理论上只有一个的
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
+ //2024年7月5日10:45:24 逻辑调整:更新一直报警的那条记录的显示值
|
|
|
+ xinyiWarningRecord.setWarningVal(tXinyiWarningRecord.getWarningVal());
|
|
|
+// xinyiWarningRecord.setDesignVal(tXinyiWarningRecord.getDesignVal());
|
|
|
+// tXinyiWarningRecord.setControlVal(tXinyiWarningRecord.getControlVal());
|
|
|
+ xinyiWarningRecord.setTime(tXinyiWarningRecord.getTime());
|
|
|
+ xinyiWarningRecord.setUpdateTime(nowDate);
|
|
|
+ xinyiWarningRecord.setUpdateBy(WARNING_DEFAULT_CREATE);
|
|
|
+ //更新数据库
|
|
|
+ this.xinyiWarningRecordMapper.updateTXinyiWarningRecord(xinyiWarningRecord);
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, false);
|
|
|
+ this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, false, nowDate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1406,32 +1440,42 @@ public class AsyncTask {
|
|
|
}
|
|
|
}
|
|
|
}else{//有告警信息
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
if(CollectionUtils.isEmpty(tXinyiWarningRecords)){//之前没有告警记录
|
|
|
//保存到数据库中
|
|
|
this.xinyiWarningRecordMapper.insertTXinyiWarningRecord(tXinyiWarningRecord);
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, false);
|
|
|
+ this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, false, nowDate);
|
|
|
}
|
|
|
}else{
|
|
|
log.info("{}:之前已经有过告警记录了,且还是继续报警,无需重复添加报警,但是决策仍然要调用", category);
|
|
|
for (TXinyiWarningRecord xinyiWarningRecord : tXinyiWarningRecords) {//理论上只有一个的
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
+ //2024年7月5日10:45:24 逻辑调整:更新一直报警的那条记录的显示值
|
|
|
+ xinyiWarningRecord.setWarningVal(tXinyiWarningRecord.getWarningVal());
|
|
|
+// xinyiWarningRecord.setDesignVal(tXinyiWarningRecord.getDesignVal());
|
|
|
+// tXinyiWarningRecord.setControlVal(tXinyiWarningRecord.getControlVal());
|
|
|
+ xinyiWarningRecord.setTime(tXinyiWarningRecord.getTime());
|
|
|
+ xinyiWarningRecord.setUpdateTime(nowDate);
|
|
|
+ xinyiWarningRecord.setUpdateBy(WARNING_DEFAULT_CREATE);
|
|
|
+ //更新数据库
|
|
|
+ this.xinyiWarningRecordMapper.updateTXinyiWarningRecord(xinyiWarningRecord);
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, false);
|
|
|
+ this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, false, nowDate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void addChatRecordByWarning(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig) {
|
|
|
+ private void addChatRecordByDeviceErr(TXinyiWarningRecord tXinyiWarningRecord, TXinyiIndustry tXinyiIndustry, TXinyiNormConfig normConfig) {
|
|
|
ChatReq chatReq = new ChatReq();
|
|
|
//保存聊天记录
|
|
|
//将问答更新到数据库中
|
|
@@ -1441,7 +1485,7 @@ public class AsyncTask {
|
|
|
/*String userId = SecurityUtils.getUserId().toString();
|
|
|
String username = SecurityUtils.getUsername();*/
|
|
|
chatReq.setUserId(WARNING_DEFAULT_CREATE);
|
|
|
- String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig, DateUtils.getNowDate());
|
|
|
chatReq.setShowVal(showVal);//前端展示的数据和提问的数据不一致
|
|
|
chatReq.setQuestion(WARNING_DEFAULT_QUESTION);//本地问题
|
|
|
chatReq.setAnswer(tXinyiWarningRecord.getReason() + ",请检查设备是否正常运行");
|
|
@@ -1564,25 +1608,35 @@ public class AsyncTask {
|
|
|
}
|
|
|
}
|
|
|
}else{//有告警信息
|
|
|
+ Date nowDate = DateUtils.getNowDate();
|
|
|
if(CollectionUtils.isEmpty(tXinyiWarningRecords)){//之前没有告警记录
|
|
|
//保存到数据库中
|
|
|
this.xinyiWarningRecordMapper.insertTXinyiWarningRecord(tXinyiWarningRecord);
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, true);
|
|
|
+ this.handleDecision(tXinyiWarningRecord, tXinyiIndustry, normConfig, true, nowDate);
|
|
|
}
|
|
|
}else{
|
|
|
log.info("{}:之前已经有过告警记录了,且还是继续报警,无需重复添加报警,但是决策仍然要调用", category);
|
|
|
for (TXinyiWarningRecord xinyiWarningRecord : tXinyiWarningRecords) {//理论上只有一个的
|
|
|
if(WARNING_LEVEL_NO_DATE.equals(tXinyiWarningRecord.getLevel())){
|
|
|
//只保存一个普通的问答记录 不需要调用决策信息,但是实时数据还是要记录的
|
|
|
- this.addChatRecordByWarning(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
+ this.addChatRecordByDeviceErr(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
}else {
|
|
|
+ //2024年7月5日10:45:24 逻辑调整:更新一直报警的那条记录的显示值
|
|
|
+ xinyiWarningRecord.setWarningVal(tXinyiWarningRecord.getWarningVal());
|
|
|
+// xinyiWarningRecord.setDesignVal(tXinyiWarningRecord.getDesignVal());
|
|
|
+// tXinyiWarningRecord.setControlVal(tXinyiWarningRecord.getControlVal());
|
|
|
+ xinyiWarningRecord.setTime(tXinyiWarningRecord.getTime());
|
|
|
+ xinyiWarningRecord.setUpdateTime(nowDate);
|
|
|
+ xinyiWarningRecord.setUpdateBy(WARNING_DEFAULT_CREATE);
|
|
|
+ //更新数据库
|
|
|
+ this.xinyiWarningRecordMapper.updateTXinyiWarningRecord(xinyiWarningRecord);
|
|
|
//继续调用决策
|
|
|
- this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, true);
|
|
|
+ this.handleDecision(xinyiWarningRecord, tXinyiIndustry, normConfig, true, nowDate);
|
|
|
}
|
|
|
}
|
|
|
}
|