|
@@ -0,0 +1,280 @@
|
|
|
|
+<template>
|
|
|
|
+ <GraphNodeDialog ref="graphNodeDialog" :title="graphNodeDialogTitle" :graph-id="props.graphId"></GraphNodeDialog>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-col :span="20">
|
|
|
|
+ <el-row>
|
|
|
|
+ <div v-if="graphData.status == GraphStatus.GRAPH_STATUS_NORMAL">图谱数据还没有进行检查</div>
|
|
|
|
+ <div v-if="graphData.status == GraphStatus.GRAPH_STATUS_NEED_CHECK">图谱数据已经开始检查</div>
|
|
|
|
+ <div v-if="graphData.status == GraphStatus.GRAPH_STATUS_CHECKING">
|
|
|
|
+ 图谱数据正在进行检查……
|
|
|
|
+
|
|
|
|
+ 总计 {{ progressData.nodes_count }}个节点,{{ progressData.edges_count }}个关系,
|
|
|
|
+ 已处理 {{ progressData.processed_nodes_count }}个节点,{{ progressData.processed_edges_count }}个关系
|
|
|
|
+ </div>
|
|
|
|
+ <div v-if="graphData.status == GraphStatus.GRAPH_STATUS_CHECKED">图谱数据检查完成</div>
|
|
|
|
+
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-row style="margin:15px;">
|
|
|
|
+ <el-form :model="searchForm" :inline="true" label-position="right">
|
|
|
|
+ <el-form-item label="检查项目" prop="event_name" :label-width="70"
|
|
|
|
+ style="margin-left:0px;margin-right:0px;">
|
|
|
|
+ <el-select v-model="searchForm.event_name" placeholder="请选择任务类型" style="width:100px;">
|
|
|
|
+ <el-option v-for="item in pageData.event_names" :key="item" :label="item"
|
|
|
|
+ :value="item"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ </el-form-item>
|
|
|
|
+
|
|
|
|
+ <el-form-item label="任务类型" prop="start_category" :label-width="70"
|
|
|
|
+ style="margin-left:5px;margin-right:0px;">
|
|
|
|
+
|
|
|
|
+ </el-form-item>
|
|
|
|
+ <el-form-item style="justify-items: right;margin-left:10px;">
|
|
|
|
+ <el-button type="primary" @click="handleSearch">搜索</el-button>
|
|
|
|
+ <el-button type="primary" @click="handleSearchReset" style="margin-left:5px;">重置</el-button>
|
|
|
|
+ <el-button @click="handleRefreshTable" style="margin-left:5px;" type="success">刷新</el-button>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-table :data="pageData.records" style="width: 100%; border:1px solid #EFEFEF;">
|
|
|
|
+ <el-table-column prop="id" label="ID" width="150">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span>{{ scope.row.id }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="event_name" label="检查项目" width="150">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span>{{ scope.row.event_name }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column prop="event_name" label="对象" width="250">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <span v-if="scope"> {{ scope.row.event_data.name }}</span>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ <el-table-column label="操作" width="150">
|
|
|
|
+ <template #default="scope">
|
|
|
|
+ <el-button type="success" plain @click="handleShowReportEvent(scope.row)">查看</el-button>
|
|
|
|
+ </template>
|
|
|
|
+ </el-table-column>
|
|
|
|
+ </el-table>
|
|
|
|
+ </el-row>
|
|
|
|
+ <el-row>
|
|
|
|
+ <el-pagination background layout="prev, pager, next" :total="pageData.total"
|
|
|
|
+ :page-size="pageData.page_size" @current-change="handleCurrentPageChange"
|
|
|
|
+ :current-page.sync="pageData.page">
|
|
|
|
+ </el-pagination>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-col>
|
|
|
|
+ <el-col :span="4">
|
|
|
|
+ <el-row v-if="graphData.status == GraphStatus.GRAPH_STATUS_CHECKING">
|
|
|
|
+ 正在检查中
|
|
|
|
+ <el-progress :percentage="progressValue" style="width:250px;"></el-progress>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+ <el-menu default-active="1" mode="vertical" @select="handleMenuSelect">
|
|
|
|
+ <el-menu-item index="1" v-if="graphData.status == GraphStatus.GRAPH_STATUS_NORMAL">
|
|
|
|
+ <span slot="title">
|
|
|
|
+ 开始检查
|
|
|
|
+ </span>
|
|
|
|
+ </el-menu-item>
|
|
|
|
+ <el-menu-item index="1" v-if="graphData.status == GraphStatus.GRAPH_STATUS_CHECKED">
|
|
|
|
+ <span slot="title">
|
|
|
|
+ 重新开始检查
|
|
|
|
+ </span>
|
|
|
|
+ </el-menu-item>
|
|
|
|
+ </el-menu>
|
|
|
|
+ </el-col>
|
|
|
|
+ </el-row>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script setup lang="ts">
|
|
|
|
+import { ref, computed, onMounted, watch, onUnmounted } from 'vue'
|
|
|
|
+import type { TabsInstance } from 'element-plus'
|
|
|
|
+import TableRelation from './TableRelation.vue'
|
|
|
|
+import TableIndividualNode from './TableIndividualNode.vue'
|
|
|
|
+import TableContradictions from './TableContradictions.vue'
|
|
|
|
+import { ElMessageBox, ElNotification } from 'element-plus'
|
|
|
|
+import type { GraphData } from '@/api/AgentApi'
|
|
|
|
+import {
|
|
|
|
+ createGraphCheckReport, getGraph, GraphStatus,
|
|
|
|
+ getGraphCheckProgress, getGraphCheckProgressValue, getGraphCheckProgressData,
|
|
|
|
+ getGraphCheckReport, getGraphCheckReportEvents
|
|
|
|
+} from '@/api/GraphApi'
|
|
|
|
+
|
|
|
|
+import GraphNodeDialog from '@/dialogs/GraphNodeDialog.vue'
|
|
|
|
+import { set } from 'date-fns'
|
|
|
|
+
|
|
|
|
+const props = defineProps({
|
|
|
|
+ graphId: { type: Number, required: true, default: 0 }
|
|
|
|
+
|
|
|
|
+})
|
|
|
|
+watch(() => props.graphId, () => {
|
|
|
|
+ loadGraph()
|
|
|
|
+})
|
|
|
|
+interface ProgressData {
|
|
|
|
+ nodes_count: number;
|
|
|
|
+ edges_count: number;
|
|
|
|
+ processed_nodes_count: number;
|
|
|
|
+ processed_edges_count: number;
|
|
|
|
+}
|
|
|
|
+interface PageData {
|
|
|
|
+ page: number;
|
|
|
|
+ pages: number;
|
|
|
|
+ page_size: number;
|
|
|
|
+ total: number;
|
|
|
|
+ records: GraphData[];
|
|
|
|
+ event_names: string[];
|
|
|
|
+}
|
|
|
|
+interface ReportEventData {
|
|
|
|
+ event_code: string
|
|
|
|
+ event_data: any
|
|
|
|
+}
|
|
|
|
+interface EventSearchData {
|
|
|
|
+ event_name: string
|
|
|
|
+}
|
|
|
|
+const searchForm = ref<EventSearchData>({ event_name: "" })
|
|
|
|
+const tabPosition = ref<TabsInstance['tabPosition']>('left')
|
|
|
|
+const graphData = ref<GraphData>({} as GraphData)
|
|
|
|
+const reportData = ref<any>({})
|
|
|
|
+const progressValue = ref(0)
|
|
|
|
+const progressData = ref<ProgressData>({} as ProgressData)
|
|
|
|
+const graphNodeDialog = ref<InstanceType<typeof GraphNodeDialog>>()
|
|
|
|
+const graphNodeDialogTitle = ref("")
|
|
|
|
+const pageData = ref<PageData>({ page: 1, pages: 1, page_size: 10, total: 0, records: [], event_names: [] })
|
|
|
|
+var timer: number = 0
|
|
|
|
+function handleMenuSelect(key: string, keyPath: string) {
|
|
|
|
+
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ `创建图谱的检查报告需要2-30分钟,具体取决于节点和关系的数量,是否开始?`,
|
|
|
|
+ '提示',
|
|
|
|
+ ).then(() => {
|
|
|
|
+
|
|
|
|
+ createGraphCheckReport({ graph_id: props.graphId }).then((res) => {
|
|
|
|
+ ElNotification({
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: '检查报告已经开始,请稍后查看',
|
|
|
|
+ type: 'success',
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ graphData.value.status = GraphStatus.GRAPH_STATUS_CHECKING
|
|
|
|
+ if (timer == 0) {
|
|
|
|
+ clearInterval(timer)
|
|
|
|
+ timer = setInterval(loadCheckingProgress, 3000)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+function handleShowReportEvent(data: any) {
|
|
|
|
+ console.log(data)
|
|
|
|
+ var report_content: ReportEventData = JSON.parse(data.event_content)
|
|
|
|
+ if (report_content.event_code == "isolated_node") {
|
|
|
|
+ if (graphNodeDialog.value) {
|
|
|
|
+ graphNodeDialogTitle.value = "孤立节点"
|
|
|
|
+ graphNodeDialog.value.showDialog(true, report_content.event_data.id)
|
|
|
|
+ } else {
|
|
|
|
+ ElNotification({
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: '孤立节点',
|
|
|
|
+ type: 'success',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (report_content.event_code == "multiple_node_types") {
|
|
|
|
+ ElMessageBox.confirm(
|
|
|
|
+ `节点 ${report_content.event_data.name} 有多个类型: ${report_content.event_data.types}`,
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function handleSearch() {
|
|
|
|
+ pageData.value.page = 1
|
|
|
|
+ pageData.value.pages = 0
|
|
|
|
+ pageData.value.total = 0
|
|
|
|
+ pageData.value.records = []
|
|
|
|
+ loadGraphCheckReportEvents()
|
|
|
|
+}
|
|
|
|
+function handleSearchReset() {
|
|
|
|
+ pageData.value.page = 1
|
|
|
|
+ pageData.value.pages = 0
|
|
|
|
+ pageData.value.total = 0
|
|
|
|
+ pageData.value.records = []
|
|
|
|
+ searchForm.value = { event_name: "" }
|
|
|
|
+ loadGraphCheckReportEvents()
|
|
|
|
+}
|
|
|
|
+const handleRefreshTable = () => {
|
|
|
|
+ handleCurrentPageChange(pageData.value.page)
|
|
|
|
+}
|
|
|
|
+const loadCheckingProgress = () => {
|
|
|
|
+ console.log("loadCheckingProgress")
|
|
|
|
+ getGraphCheckProgress(props.graphId).then((res) => {
|
|
|
|
+ reportData.value = res.records[0]
|
|
|
|
+ if (reportData.value == undefined) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if (!reportData.value.report_content) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ var jsonData = JSON.parse(reportData.value.report_content)
|
|
|
|
+ if (jsonData) {
|
|
|
|
+ progressValue.value = getGraphCheckProgressValue(jsonData)
|
|
|
|
+ progressData.value = getGraphCheckProgressData(jsonData) as ProgressData
|
|
|
|
+ console.log(progressValue.value)
|
|
|
|
+ if (progressValue.value == 100) {
|
|
|
|
+ clearInterval(timer)
|
|
|
|
+ timer = 0
|
|
|
|
+ graphData.value.status = GraphStatus.GRAPH_STATUS_CHECKED
|
|
|
|
+ ElNotification({
|
|
|
|
+ title: '提示',
|
|
|
|
+ message: '检查报告已经完成',
|
|
|
|
+ type: 'success',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+function handleCurrentPageChange(page: number) {
|
|
|
|
+ pageData.value.page = page
|
|
|
|
+ loadGraphCheckReportEvents()
|
|
|
|
+}
|
|
|
|
+const loadGraphCheckReportEvents = () => {
|
|
|
|
+ getGraphCheckReportEvents(props.graphId, pageData.value.page, pageData.value.page_size, searchForm.value.event_name).then((res) => {
|
|
|
|
+ if (res.records) {
|
|
|
|
+ pageData.value.records = res.records
|
|
|
|
+ pageData.value.pages = res.meta.pages
|
|
|
|
+ pageData.value.total = res.meta.total
|
|
|
|
+ pageData.value.event_names = res.meta.event_names
|
|
|
|
+ pageData.value.records.forEach((item: any) => {
|
|
|
|
+ var report_content: ReportEventData = JSON.parse(item.event_content)
|
|
|
|
+ item.event_data = report_content.event_data
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+const loadGraph = () => {
|
|
|
|
+ if (props.graphId == 0) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ getGraph(props.graphId).then((res) => {
|
|
|
|
+ graphData.value = res.records[0]
|
|
|
|
+ if (graphData.value.status == GraphStatus.GRAPH_STATUS_NEED_CHECK || graphData.value.status == GraphStatus.GRAPH_STATUS_CHECKING) {
|
|
|
|
+ timer = setInterval(loadCheckingProgress, 3000)
|
|
|
|
+ }
|
|
|
|
+ if (graphData.value.status == GraphStatus.GRAPH_STATUS_CHECKED) {
|
|
|
|
+ loadGraphCheckReportEvents()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+onMounted(() => {
|
|
|
|
+ loadGraph()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+onUnmounted(() => {
|
|
|
|
+ if (timer) {
|
|
|
|
+ clearInterval(timer)
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+</script>
|