|
@@ -112,37 +112,7 @@ public class GRPCController extends BaseController {
|
|
if(StringUtils.isBlank(simulate) || "{}".equals(simulate))
|
|
if(StringUtils.isBlank(simulate) || "{}".equals(simulate))
|
|
type = 1;//决策
|
|
type = 1;//决策
|
|
//决策请求的业务参数
|
|
//决策请求的业务参数
|
|
-// List<HashMap<String, Object>> list = this.xinyiIndustryMapper.selectLast10RecordsForDecision();
|
|
|
|
- //2024年5月21日15:23:07 这里不能用关联查询处理,日报要获取最新的一条而不是今日的数据。
|
|
|
|
- List<DecisionReq> decisionReqs = this.xinyiIndustryMapper.selectLast10RecordsForDecisionOnlyIndustry();
|
|
|
|
- if(!CollectionUtils.isEmpty(decisionReqs)){
|
|
|
|
- for (DecisionReq decisionReq : decisionReqs) {
|
|
|
|
- //处理日报数据
|
|
|
|
- TXinyiDaily daily = this.xinyiDailyMapper.selectNewestData();
|
|
|
|
- if(!Objects.isNull(daily)){
|
|
|
|
- decisionReq.setT(daily.getJsSw());
|
|
|
|
- decisionReq.setSVI(daily.getWntjzsAll());
|
|
|
|
- decisionReq.setSV(daily.getWncjbAll());
|
|
|
|
- decisionReq.setMlvss(daily.getHfxwnndAll());
|
|
|
|
- decisionReq.setDoAna(daily.getYycRjyAll());
|
|
|
|
- decisionReq.setDoQue(daily.getQycRjyAll());
|
|
|
|
- //2024年5月26日11:59:02 干污泥量数据做了同步
|
|
|
|
- decisionReq.setGwnl(daily.getGWNL());
|
|
|
|
- BigDecimal jsBod5 = daily.getJsBod5();
|
|
|
|
- decisionReq.setBodIn(jsBod5);
|
|
|
|
- BigDecimal tpIn = decisionReq.getTpIn();
|
|
|
|
- BigDecimal tnIn = decisionReq.getTnIn();
|
|
|
|
- if(!Objects.isNull(jsBod5)){
|
|
|
|
- if(!Objects.isNull(tpIn) && tpIn.compareTo(new BigDecimal("0")) >0){
|
|
|
|
- decisionReq.setC(jsBod5.divide(tpIn, 4, RoundingMode.HALF_UP));
|
|
|
|
- }
|
|
|
|
- if(!Objects.isNull(tnIn) && tnIn.compareTo(new BigDecimal("0")) >0){
|
|
|
|
- decisionReq.setB(jsBod5.divide(tnIn, 4, RoundingMode.HALF_UP));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ List<DecisionReq> decisionReqs = getDecisionReqs();
|
|
String rows = JSON.toJSONString(decisionReqs, JSONWriter.Feature.WriteNulls);
|
|
String rows = JSON.toJSONString(decisionReqs, JSONWriter.Feature.WriteNulls);
|
|
String dataJson = "";
|
|
String dataJson = "";
|
|
try {
|
|
try {
|
|
@@ -204,26 +174,7 @@ public class GRPCController extends BaseController {
|
|
log.info("sessionId是{}\n决策最终要保存的数据是{}", sessionId, JSON.toJSONString(resultData));
|
|
log.info("sessionId是{}\n决策最终要保存的数据是{}", sessionId, JSON.toJSONString(resultData));
|
|
//保存聊天记录
|
|
//保存聊天记录
|
|
//将问答更新到数据库中
|
|
//将问答更新到数据库中
|
|
- chatReq.setSessionId(sessionId);
|
|
|
|
- chatReq.setType(type);//类型(0问答 1决策 2本地 3仿真预测)
|
|
|
|
- chatReq.setModule(3);//0=专家问答,1=智能工单,2=智能体助手,3.告警
|
|
|
|
-// String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
|
-// chatReq.setShowVal(feedback);//前端展示的数据和提问的数据不一致
|
|
|
|
- //如果主动调用决策 showVal应该是最新的那条历史记录对应的数据
|
|
|
|
- List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).build());
|
|
|
|
- if(!CollectionUtils.isEmpty(tXinyiChatRecords))
|
|
|
|
- chatReq.setShowVal(tXinyiChatRecords.get(0).getShowVal());
|
|
|
|
- chatReq.setQuestion(dataJson);
|
|
|
|
- chatReq.setAnswer(JSON.toJSONString(resultData));
|
|
|
|
- chatReq.setWarningId(warningId);
|
|
|
|
- chatReq.setCounts(1);//问答次数
|
|
|
|
- String userId = SecurityUtils.getUserId().toString();
|
|
|
|
- String username = SecurityUtils.getUsername();
|
|
|
|
- chatReq.setUserId(userId);
|
|
|
|
- chatReq.setCreateBy(username);
|
|
|
|
- chatReq.setCreateTime(DateUtils.getNowDate());
|
|
|
|
- //todo 现在测试,暂时注释掉。 等测试完毕,打开注释。
|
|
|
|
-// this.xinyiChatRecordMapper.insertTXinyiChatRecord(chatReq);
|
|
|
|
|
|
+ addChatRecord(chatReq, sessionId, type, warningId, dataJson, resultData);
|
|
// 关闭输出流
|
|
// 关闭输出流
|
|
try {
|
|
try {
|
|
outputStream.close();
|
|
outputStream.close();
|
|
@@ -235,6 +186,64 @@ public class GRPCController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void addChatRecord(ChatReq chatReq, String sessionId, int type, String warningId, String dataJson, List<String> resultData) {
|
|
|
|
+ chatReq.setSessionId(sessionId);
|
|
|
|
+ chatReq.setType(type);//类型(0问答 1决策 2本地 3仿真预测)
|
|
|
|
+ chatReq.setModule(3);//0=专家问答,1=智能工单,2=智能体助手,3.告警
|
|
|
|
+// String showVal = this.buildShowValue(tXinyiWarningRecord, tXinyiIndustry, normConfig);
|
|
|
|
+// chatReq.setShowVal(feedback);//前端展示的数据和提问的数据不一致
|
|
|
|
+ //如果主动调用决策 showVal应该是最新的那条历史记录对应的数据
|
|
|
|
+ List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).build());
|
|
|
|
+ if(!CollectionUtils.isEmpty(tXinyiChatRecords))
|
|
|
|
+ chatReq.setShowVal(tXinyiChatRecords.get(0).getShowVal());
|
|
|
|
+ chatReq.setQuestion(dataJson);
|
|
|
|
+ chatReq.setAnswer(JSON.toJSONString(resultData));
|
|
|
|
+ chatReq.setWarningId(warningId);
|
|
|
|
+ chatReq.setCounts(1);//问答次数
|
|
|
|
+ String userId = SecurityUtils.getUserId().toString();
|
|
|
|
+ String username = SecurityUtils.getUsername();
|
|
|
|
+ chatReq.setUserId(userId);
|
|
|
|
+ chatReq.setCreateBy(username);
|
|
|
|
+ chatReq.setCreateTime(DateUtils.getNowDate());
|
|
|
|
+ //todo 现在测试,暂时注释掉。 等测试完毕,打开注释。
|
|
|
|
+// this.xinyiChatRecordMapper.insertTXinyiChatRecord(chatReq);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<DecisionReq> getDecisionReqs() {
|
|
|
|
+ //List<HashMap<String, Object>> list = this.xinyiIndustryMapper.selectLast10RecordsForDecision();
|
|
|
|
+ //2024年5月21日15:23:07 这里不能用关联查询处理,日报要获取最新的一条而不是今日的数据。
|
|
|
|
+ List<DecisionReq> decisionReqs = this.xinyiIndustryMapper.selectLast10RecordsForDecisionOnlyIndustry();
|
|
|
|
+ if(!CollectionUtils.isEmpty(decisionReqs)){
|
|
|
|
+ for (DecisionReq decisionReq : decisionReqs) {
|
|
|
|
+ //处理日报数据
|
|
|
|
+ TXinyiDaily daily = this.xinyiDailyMapper.selectNewestData();
|
|
|
|
+ if(!Objects.isNull(daily)){
|
|
|
|
+ decisionReq.setT(daily.getJsSw());
|
|
|
|
+ decisionReq.setSVI(daily.getWntjzsAll());
|
|
|
|
+ decisionReq.setSV(daily.getWncjbAll());
|
|
|
|
+ decisionReq.setMlvss(daily.getHfxwnndAll());
|
|
|
|
+ decisionReq.setDoAna(daily.getYycRjyAll());
|
|
|
|
+ decisionReq.setDoQue(daily.getQycRjyAll());
|
|
|
|
+ //2024年5月26日11:59:02 干污泥量数据做了同步
|
|
|
|
+ decisionReq.setGwnl(daily.getGWNL());
|
|
|
|
+ BigDecimal jsBod5 = daily.getJsBod5();
|
|
|
|
+ decisionReq.setBodIn(jsBod5);
|
|
|
|
+ BigDecimal tpIn = decisionReq.getTpIn();
|
|
|
|
+ BigDecimal tnIn = decisionReq.getTnIn();
|
|
|
|
+ if(!Objects.isNull(jsBod5)){
|
|
|
|
+ if(!Objects.isNull(tpIn) && tpIn.compareTo(new BigDecimal("0")) >0){
|
|
|
|
+ decisionReq.setC(jsBod5.divide(tpIn, 4, RoundingMode.HALF_UP));
|
|
|
|
+ }
|
|
|
|
+ if(!Objects.isNull(tnIn) && tnIn.compareTo(new BigDecimal("0")) >0){
|
|
|
|
+ decisionReq.setB(jsBod5.divide(tnIn, 4, RoundingMode.HALF_UP));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return decisionReqs;
|
|
|
|
+ }
|
|
|
|
+
|
|
private String buildErrMsg() {
|
|
private String buildErrMsg() {
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("biz", DECISION_REPORT.getCode());
|
|
jsonObject.put("biz", DECISION_REPORT.getCode());
|