|
@@ -15,9 +15,10 @@ import { useInfinite } from '@/composables/useInfinite';
|
|
|
import { useRecommend } from '@/composables/useRecommend';
|
|
|
import { useFetchStream } from '@/composables/useFetchStream';
|
|
|
import { useScroll } from '@/composables/useScroll';
|
|
|
+import { SIMULATE_ENUM } from './components/config';
|
|
|
|
|
|
const { recommendList } = useRecommend({type: 1});
|
|
|
-const { scrollRef, scrollToTop, scrollToBottomIfAtBottom } = useScroll();
|
|
|
+const { scrollRef, scrollToTop, scrollToBottom, scrollToBottomIfAtBottom } = useScroll();
|
|
|
const { refetch, cancelFetch } = useFetchStream("/grpc/decisionStream", { methdos: 'POST' }, false);
|
|
|
const { recordList, isFetching, onScrolltolower, onRestore, addHistoryRecord } = useInfinite('/front/bigModel/warning/pageList', { type: 0, warningStatus: 0 });
|
|
|
|
|
@@ -31,7 +32,7 @@ const flowParams = {
|
|
|
feedback: '',
|
|
|
category: '',
|
|
|
warningId: '',
|
|
|
- simulate: null
|
|
|
+ simulate: '{}'
|
|
|
};
|
|
|
|
|
|
const answerLoading = ref(false);
|
|
@@ -109,7 +110,6 @@ const columns = [
|
|
|
}
|
|
|
]
|
|
|
|
|
|
-
|
|
|
// 新建对话
|
|
|
const handleCreateDialog = () => {
|
|
|
console.log("handleCreateDialog");
|
|
@@ -132,44 +132,97 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
|
|
|
flowParams.category = category;
|
|
|
flowParams.warningId = id;
|
|
|
+ flowParams.feedback = '';
|
|
|
+ flowParams.simulate = '{}';
|
|
|
|
|
|
const { data } = await waterApi.getWaringDetails(id);
|
|
|
+ const res = await waterApi.getWaringForecast(id);
|
|
|
+
|
|
|
const showVal = JSON.parse(data.showVal);
|
|
|
const { basic, jsData, csData } = showVal;
|
|
|
const answer = JSON.parse(data.answer);
|
|
|
- const [ answerStrItem ] = answer;
|
|
|
- const answerObjItem = JSON.parse( answerStrItem );
|
|
|
-
|
|
|
+
|
|
|
cancelFetch();
|
|
|
|
|
|
answerResult.value = [];
|
|
|
|
|
|
- const textWhiteList = [
|
|
|
- { label: '报警时间', realKey: '报警时间', value: '', isWarning: false },
|
|
|
- { label: '报警值', realKey: '报警值', value: 'mg/L', isWarning: true },
|
|
|
- { label: '管控值', realKey: '管控值', value: 'mg/L', isWarning: false },
|
|
|
- { label: '标准值', realKey: '标准值', value: 'mg/L', isWarning: false },
|
|
|
- { label: '报警级别', realKey: '告警级别', value: '', isWarning: false },
|
|
|
- { label: '报警次数', realKey: '报警次数', value: '', isWarning: false },
|
|
|
- { label: '状态', realKey: '状态', value: '', isWarning: false }
|
|
|
- ]
|
|
|
+ const reportList = [];
|
|
|
+ const alertList = [];
|
|
|
+
|
|
|
+ answer.map(item => {
|
|
|
|
|
|
- if ( answerObjItem.biz === "DECISION_REPORT" ) {
|
|
|
+ const answerObjItem = JSON.parse( item );
|
|
|
|
|
|
- const answerContent = answer.map(item => {
|
|
|
- const itemParse = JSON.parse(item);
|
|
|
- return itemParse.message;
|
|
|
- }).join("");
|
|
|
+ console.log( answerObjItem );
|
|
|
+
|
|
|
+ if ( answerObjItem.biz === "DECISION_REPORT" ) {
|
|
|
+ reportList.push(answerObjItem.message);
|
|
|
+
|
|
|
+ // const answerContent = answer.map(item => {
|
|
|
+ // const itemParse = JSON.parse(item);
|
|
|
+ // return itemParse.message;
|
|
|
+ // }).join("");
|
|
|
+
|
|
|
+ // answerResult.value.push({
|
|
|
+ // biz: 'DECISION_REPORT',
|
|
|
+ // answer: answerContent,
|
|
|
+ // loading: false,
|
|
|
+ // delayLoading: false
|
|
|
+ // })
|
|
|
+ }
|
|
|
+
|
|
|
+ if( answerObjItem.biz === "DECISION_ALERT" ) {
|
|
|
+ alertList.push(item);
|
|
|
+ // const [ parseAnswer ] = answer.map(item => {
|
|
|
+ // const result = JSON.parse( item );
|
|
|
+ // result.message = Object.keys(result.message).map(key => ({ ...result.message[key], isActive: null }));
|
|
|
+ // return result;
|
|
|
+ // })
|
|
|
+
|
|
|
+ // answerResult.value.push({
|
|
|
+ // biz: 'DECISION_ALERT',
|
|
|
+ // loading: false,
|
|
|
+ // delayLoading: false,
|
|
|
+ // isAllSelect: false,
|
|
|
+ // list: parseAnswer?.message
|
|
|
+ // })
|
|
|
+ }
|
|
|
+
|
|
|
+ if (answerObjItem.biz === "DECISION_SIMULATE") {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // const usefulkeys = ['on', 'off'];
|
|
|
+ // const resultObj = {};
|
|
|
+
|
|
|
+ // usefulkeys.forEach(key => {
|
|
|
+ // const tempArr = data[key];
|
|
|
+
|
|
|
+ // resultObj[key] = tempArr.map(item => {
|
|
|
+ // return {
|
|
|
+ // ...item,
|
|
|
+ // label: SIMULATE_ENUM[item.name],
|
|
|
+ // inpVal: Array.isArray( item.value ) ? item.value.join() : item.value,
|
|
|
+ // errMsg: ''
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ }
|
|
|
|
|
|
+ })
|
|
|
+
|
|
|
+ if ( reportList.length ) {
|
|
|
+ const answerContent = reportList.join("");
|
|
|
answerResult.value.push({
|
|
|
biz: 'DECISION_REPORT',
|
|
|
answer: answerContent,
|
|
|
loading: false,
|
|
|
delayLoading: false
|
|
|
})
|
|
|
+ }
|
|
|
|
|
|
- } else {
|
|
|
- const [ parseAnswer ] = answer.map(item => {
|
|
|
+ if ( alertList.length ) {
|
|
|
+ const [ parseAnswer ] = alertList.map(item => {
|
|
|
const result = JSON.parse( item );
|
|
|
result.message = Object.keys(result.message).map(key => ({ ...result.message[key], isActive: null }));
|
|
|
return result;
|
|
@@ -183,7 +236,26 @@ const handleOpenContent = async ({ id, category }) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- console.log( basic );
|
|
|
+ // console.log( "reportList", reportList );
|
|
|
+ // console.log( "alertList", alertList );
|
|
|
+ // const [ answerStrItem ] = answer;
|
|
|
+ // const answerObjItem = JSON.parse( answerStrItem );
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // console.log( "answerObjItem", answer, JSON.parse(answerObjItem.message) );
|
|
|
+ const textWhiteList = [
|
|
|
+ { label: '报警时间', realKey: '报警时间', value: '', isWarning: false },
|
|
|
+ { label: '报警值', realKey: '报警值', value: 'mg/L', isWarning: true },
|
|
|
+ { label: '管控值', realKey: '管控值', value: 'mg/L', isWarning: false },
|
|
|
+ { label: '标准值', realKey: '标准值', value: 'mg/L', isWarning: false },
|
|
|
+ { label: '报警级别', realKey: '告警级别', value: '', isWarning: false },
|
|
|
+ { label: '报警次数', realKey: '报警次数', value: '', isWarning: false },
|
|
|
+ { label: '状态', realKey: '状态', value: '', isWarning: false }
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
textDataSources.value = format.textSorting(basic, textWhiteList);
|
|
|
|
|
|
jsTableData.value = [jsData];
|
|
@@ -196,6 +268,12 @@ const onChangeTabs = warningStatus => {
|
|
|
textDataSources.value = '';
|
|
|
answerLoading.value = false;
|
|
|
answerResult.value = [];
|
|
|
+ flowParams = {
|
|
|
+ feedback: '',
|
|
|
+ category: '',
|
|
|
+ warningId: '',
|
|
|
+ simulate: '{}'
|
|
|
+ };
|
|
|
cancelFetch();
|
|
|
onRestore({ warningStatus })
|
|
|
}
|
|
@@ -215,7 +293,7 @@ const onRegenerate = async () => {
|
|
|
|
|
|
let tempSimulate = null;
|
|
|
|
|
|
- answerLoading.value = true;
|
|
|
+ answerLoading.value = answerResult.value[len -1 ].biz !== 'DECISION_TABLE';
|
|
|
|
|
|
const params = {
|
|
|
body: JSON.stringify(flowParams),
|
|
@@ -230,6 +308,7 @@ const onRegenerate = async () => {
|
|
|
|
|
|
if (item.biz === 'DECISION_REPORT') {
|
|
|
tempReport.answer += item.message;
|
|
|
+ tempReport.delayLoading = false;
|
|
|
answerResult.value[len] = { ...tempReport };
|
|
|
}
|
|
|
|
|
@@ -239,7 +318,7 @@ const onRegenerate = async () => {
|
|
|
answerResult.value.push({
|
|
|
biz: 'DECISION_ALERT',
|
|
|
loading: true,
|
|
|
- delayLoading: true,
|
|
|
+ delayLoading: false,
|
|
|
isAllSelect: false,
|
|
|
list
|
|
|
})
|
|
@@ -251,7 +330,7 @@ const onRegenerate = async () => {
|
|
|
if ( lastAnswerItem.biz === 'DECISION_TABLE' ) {
|
|
|
answerResult.value[len - 1] = {
|
|
|
...lastAnswerItem,
|
|
|
- content: JSON.parse(item.message).pred.join(",")
|
|
|
+ content: JSON.parse(item.message).pred.join(", ")
|
|
|
}
|
|
|
} else {
|
|
|
const { off, on, pred } = JSON.parse(item.message);
|
|
@@ -264,7 +343,6 @@ const onRegenerate = async () => {
|
|
|
}
|
|
|
modalData.value = tempSimulate;
|
|
|
}
|
|
|
- console.log("DECISION_SIMULATE")
|
|
|
}
|
|
|
|
|
|
scrollToBottomIfAtBottom();
|
|
@@ -278,10 +356,18 @@ const onRegenerate = async () => {
|
|
|
if (answerItem?.biz) {
|
|
|
answerItem.loading = false;
|
|
|
answerItem.delayLoading = false;
|
|
|
+
|
|
|
+ if (answerItem.biz === 'DECISION_TABLE') {
|
|
|
+ scrollToBottom()
|
|
|
+ }
|
|
|
}
|
|
|
if (tempSimulate) {
|
|
|
answerResult.value.push(tempSimulate);
|
|
|
}
|
|
|
+
|
|
|
+ // setTimeout(() => {
|
|
|
+ // scrollToBottomIfAtBottom();
|
|
|
+ // }, 500)
|
|
|
}
|
|
|
catch(error) {
|
|
|
console.log("exist error .....", error);
|
|
@@ -367,8 +453,8 @@ const handleWelcomeRecommend = question => {
|
|
|
|
|
|
<ChatWelcome title="您好,我是LibraAI工艺管控助手" card-title="常见处理方案:"
|
|
|
:sub-title="[
|
|
|
- '报警分析功能具备实时监测与预警机制,检测到异常情况推送相关工作人员确保问题及时处理。',
|
|
|
- '报警时间为每小时警报,请大家及时处理。'
|
|
|
+ '水质报警功能针对五大核心指标实时监测,发现异常后将推送给相关人员决策方案',
|
|
|
+ '报警时间为每小时警报,请大家及时处理'
|
|
|
]"
|
|
|
:card-content="recommendList"
|
|
|
@on-click="handleWelcomeRecommend"
|
|
@@ -401,7 +487,7 @@ const handleWelcomeRecommend = question => {
|
|
|
</div>
|
|
|
</div>
|
|
|
</ChatBaseCard>
|
|
|
-
|
|
|
+
|
|
|
<section v-for="item,index in answerResult" :key="index">
|
|
|
<template v-if="item.biz === 'DECISION_REPORT'">
|
|
|
<ChatAnswer
|
|
@@ -411,7 +497,7 @@ const handleWelcomeRecommend = question => {
|
|
|
:content="item.answer"
|
|
|
></ChatAnswer>
|
|
|
</template>
|
|
|
- <!-- {{ item }} -->
|
|
|
+
|
|
|
<template v-if="item.biz === 'DECISION_ALERT'">
|
|
|
<ChatBaseCard
|
|
|
:loading="item.loading"
|
|
@@ -468,7 +554,7 @@ const handleWelcomeRecommend = question => {
|
|
|
</tbody>
|
|
|
</table>
|
|
|
<strong class="block mb-[16px]">预测推演结果:</strong>
|
|
|
- <span>出水硝酸盐:{{ item.content }}</span>
|
|
|
+ <span>未来三小时好氧池硝酸盐预测结果:{{ item.content }}</span>
|
|
|
</div>
|
|
|
</ChatAnswer>
|
|
|
<button class="
|
|
@@ -489,6 +575,7 @@ const handleWelcomeRecommend = question => {
|
|
|
:delay-loading="answerLoading"
|
|
|
:toggleVisibleIcons="false"
|
|
|
v-show="answerLoading"
|
|
|
+ loadingText="内容生成中,大概需要50秒..."
|
|
|
></ChatAnswer>
|
|
|
|
|
|
</TheChatView>
|