优化轮询

This commit is contained in:
wu.jifen
2025-06-24 13:29:48 +08:00
parent d454eb1256
commit b740c7e6c1
4 changed files with 72 additions and 27 deletions

View File

@@ -526,3 +526,12 @@ export function relatedApps(data) {
export function downloadOriginalFile(data) {
return getUrl(`/datasetDocumentEx/download/original_file?documentId=` + data)
}
// 获取知识库里未完成的知识挖掘数据
export function getUnfinishedExtract(data) {
return request({
url: getUrl(`/datasetDocumentEx/unfinishedExtract?datasetId=` + data),
method: 'get',
noLoading: true
})
}

View File

@@ -1,7 +1,7 @@
let envInfo = process.env
let [admin, jifen, zixi, hz] = [
envInfo.VUE_APP_ADMIN,
'http://192.168.8.65:7196/',
'http://192.168.2.68:7196/',
'http://192.168.8.165:7196/',
'http://10.147.17.161:7196/'
]

View File

@@ -281,24 +281,10 @@ export default {
title: '提示',
message: this.$createElement('i', {}, this.extractStatusResults)
})
this.extractStatus.timer = setInterval(async () => {
const { content } = await datasetDocumentEx({
documentId: this.documentId
}).content
this.extractStatus.status = content.extractStatus
if (
Number(content.extractStatus) === 1 ||
Number(content.extractStatus) === 2
) {
this.$notify({
title: '提示',
type: 'success',
message: this.$createElement('i', {}, this.extractStatusResults)
})
clearInterval(this.extractStatus.timer)
}
}, 5000)
datasetDocumentEx({ documentId: this.documentId })
.then(() => {
this.onBack()
})
},
onBack() {
this.$router.history.go(-1)

View File

@@ -270,10 +270,10 @@
:wrapperClosable='false'
>
<words
ref='words'
@openMetaDrawer='handleMetaData'
@close='close'
:document-extract-id='documentExtractId'
ref="words"
@openMetaDrawer="handleMetaData"
@close="close"
:document-extract-id="documentExtractId"
></words>
</el-drawer>
</div>
@@ -286,7 +286,9 @@ import {
datasetsExPages,
datasetUpdate,
downloadOriginalFile,
getDatasetById, getExtractResultList,
getDatasetById,
getExtractResultList,
getUnfinishedExtract,
relatedApps
} from '@/api/generatedApi'
import { getUserList } from '@/api/generatedApi/system'
@@ -363,7 +365,7 @@ export default {
splitRules: '',
extractRules: ''
},
documentExtractId: '',
documentExtractId: ''
}
},
props: {},
@@ -663,6 +665,53 @@ export default {
},
handleRelatedApp(item) {
// console.log(item)
},
// 获取正在执行的知识挖掘文档
getExtractingData() {
let { datasetId } = this.$route.query
// 判断是否已经在轮询中,防止重复启动定时器
if (this.pollingTimer) return
// 开始轮询
let documentIds = []
this.pollingTimer = setInterval(async () => {
try {
const res = await getUnfinishedExtract(datasetId)
if (res.content.result === '0' && res.content.content.length > 0) {
documentIds = res.content.content
// 禁用知识挖掘按钮
documentIds.map(docId => {
let filterItem = this.list.find(item => {
return item.id === docId
})
if (filterItem) {
if (filterItem.extractStatus < 2) {
filterItem.extractStatus = 4
}
}
})
} else {
// 清除定时器
clearInterval(this.pollingTimer)
this.pollingTimer = null
// 启用知识挖掘按钮
documentIds.map(docId => {
let filterItem = this.list.find(item => {
return item.id === docId
})
if (filterItem) {
if (filterItem.extractStatus > 2) {
filterItem.extractStatus = 1
}
}
})
}
} catch (error) {
clearInterval(this.pollingTimer)
this.pollingTimer = null
}
}, 3000)
}
},
filters: {
@@ -699,6 +748,7 @@ export default {
// this.viewDocumentDetail(row[0])
// sessionStorage.removeItem('documentId')
// }, 1000)
this.getExtractingData()
},
computed: {
datasetId() {
@@ -755,7 +805,7 @@ export default {
},
{
key: '状态',
prop: 'statusLabel',
prop: 'statusLabel'
// render: (h, params) => {
// let label = this.displayStatus.find(item => {
// return item.value === params.row.displayStatus
@@ -878,7 +928,7 @@ export default {
size: 'mini',
icon: 'el-icon-cpu',
title: '知识挖掘',
disabled: params.row.optStatus < 2
disabled: params.row.optStatus < 2 || params.row.extractStatus > 2
},
on: {
click: () => this.handleKnowledgeMining(params.row)