修复下载影像bug
continuous-integration/drone/push Build is passing Details

uat_us
caiyiling 2024-01-26 10:26:09 +08:00
parent d26fbbde99
commit 1c2505377a
4 changed files with 98 additions and 63 deletions

View File

@ -1,7 +1,7 @@
import * as cornerstone from 'cornerstone-core' import * as cornerstone from 'cornerstone-core'
var taskPool = [] // 请求池 var taskPool = [] // 请求池
let numRequest = 0 // 正在执行数量 let numRequest = 0 // 正在执行数量
const maxRequest = 6 // 可配置 const maxRequest = 5 // 可配置
let taskTimer // 轮询的定时器 let taskTimer // 轮询的定时器
var cachedTask = {} // 存放的任务数据 var cachedTask = {} // 存放的任务数据
let sortType = 1 let sortType = 1
@ -10,9 +10,10 @@ let startExecuteTask = null
let endExecuteTask = performance.now() let endExecuteTask = performance.now()
// 执行下载 // 执行下载
async function executeTask() { async function executeTask() {
console.log(taskPool)
endExecuteTask = performance.now() endExecuteTask = performance.now()
i++ i++
// stopTaskTimer() stopTaskTimer()
if (taskPool.length > 0) { if (taskPool.length > 0) {
let startSortTime = performance.now() let startSortTime = performance.now()
if( sortType ){ if( sortType ){
@ -119,6 +120,14 @@ function removeTask(seriesId){
} }
startTaskTimer() startTaskTimer()
} }
function changePriority(seriesId){
taskPool.map(task=>{
if(task.seriesId === seriesId){
task.priority = parseInt(new Date().getTime()) * 10
}
})
sortTaskPool()
}
function setSortType(type){ function setSortType(type){
sortType = type sortType = type
} }
@ -147,6 +156,7 @@ export default {
executeTask, executeTask,
setSortType, setSortType,
sortTaskPool, sortTaskPool,
changePriority,
startTaskTimer, startTaskTimer,
stopTaskTimer, stopTaskTimer,
loadAndCacheImagePlus, loadAndCacheImagePlus,

View File

@ -152,7 +152,8 @@ export default {
firstInstanceId: '', firstInstanceId: '',
showDelete: false, showDelete: false,
loading: false, loading: false,
imageList: [] imageList: [],
showSeriesList: []
} }
}, },
created: function() { created: function() {
@ -307,17 +308,22 @@ export default {
this.currentSeriesIndex = seriesIndex this.currentSeriesIndex = seriesIndex
this.$refs.dicomViewer.loadImageStack(this.seriesList[seriesIndex]) this.$refs.dicomViewer.loadImageStack(this.seriesList[seriesIndex])
if (!series.loadStatus) { if (!series.loadStatus) {
series.isLoading = true requestPoolManager.changePriority(series.seriesId)
var p = new Date().getTime() // var isAddToTakPool = false
series.imageIds.map((imageId, i) => { // if (this.showSeriesList.includes(`${seriesIndex}`)) {
var priority = '' // isAddToTakPool = true
if (i === 0) { // } else {
priority = new Date(new Date().setHours(23, 59, 59, 999)).getTime() // this.showSeriesList.push(`${seriesIndex}`)
} else { // }
priority = p - 1 // if (!isAddToTakPool) {
} // var priority = parseInt(new Date().getTime())
this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) // series.isLoading = true
}) // series.imageIds.map((imageId) => {
// this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority })
// })
// } else {
// requestPoolManager.changePriority(series.seriesId)
// }
} }
}, },
initStudy() { initStudy() {

View File

@ -233,7 +233,8 @@ export default {
showDelete: 0, showDelete: 0,
imageList: [], imageList: [],
activeNames: [], activeNames: [],
relationActiveName: [] relationActiveName: [],
showSeriesList: []
} }
}, },
mounted() { mounted() {
@ -323,18 +324,22 @@ export default {
this.currentSeriesIndex = seriesIndex this.currentSeriesIndex = seriesIndex
this.$refs.dicomViewer.loadImageStack(this.studyList[studyIndex].SeriesList[seriesIndex]) this.$refs.dicomViewer.loadImageStack(this.studyList[studyIndex].SeriesList[seriesIndex])
if (!series.loadStatus) { if (!series.loadStatus) {
series.isLoading = true requestPoolManager.changePriority(series.seriesId)
var p = parseInt(new Date().getTime()) // var isAddToTakPool = false
series.imageIds.map((imageId, i) => { // if (this.showSeriesList.includes(`${studyIndex}_${seriesIndex}`)) {
var priority = '' // isAddToTakPool = true
if (i === 0) { // } else {
priority = parseInt(new Date().getTime()) * 10 // this.showSeriesList.push(`${studyIndex}_${seriesIndex}`)
} else { // }
priority = p - 1 // if (!isAddToTakPool) {
} // var priority = parseInt(new Date().getTime())
this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) // series.isLoading = true
// this.load(imageId, series.seriesId, priority) // series.imageIds.map((imageId, i) => {
}) // this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority })
// })
// } else {
// requestPoolManager.changePriority(series.seriesId)
// }
} }
}, },
changeReadingStatus(callback, data) { changeReadingStatus(callback, data) {
@ -515,7 +520,7 @@ export default {
this.imageLoaded(image, res.data.string('x0020000e')) this.imageLoaded(image, res.data.string('x0020000e'))
}) })
}) })
requestPoolManager.sortTaskPool()
this.imageList = [] this.imageList = []
} }
}, },

View File

@ -170,6 +170,7 @@ export default {
return { return {
studyList: [], studyList: [],
cachedImages: [], cachedImages: [],
showSeriesList: [],
studyIndex: null, studyIndex: null,
seriesIndex: null, seriesIndex: null,
loading: false, loading: false,
@ -228,11 +229,12 @@ export default {
// cornerstone.events.addEventListener('cornerstoneimagecachechanged', this.cornerstoneimagecachechanged) // cornerstone.events.addEventListener('cornerstoneimagecachechanged', this.cornerstoneimagecachechanged)
}, },
beforeDestroy() { beforeDestroy() {
console.log('study---beforeDestroy')
cornerstone.imageCache.purgeCache() cornerstone.imageCache.purgeCache()
DicomEvent.$off('refreshStudyListMeasureData') DicomEvent.$off('refreshStudyListMeasureData')
}, },
methods: { methods: {
initStudyInfo(){ initStudyInfo() {
const loading = this.$loading({ fullscreen: true }) const loading = this.$loading({ fullscreen: true })
// //
this.getInitSeries().then((res) => { this.getInitSeries().then((res) => {
@ -243,18 +245,16 @@ export default {
console.log(res) console.log(res)
var i = res.findIndex(s => s.isCurrentTask) var i = res.findIndex(s => s.isCurrentTask)
if (i > -1) { if (i > -1) {
var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId) var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId)
if (idx > -1) { if (idx > -1) {
this.measureData = this.visitTaskList[idx].MeasureData this.measureData = this.visitTaskList[idx].MeasureData
this.studyList = this.visitTaskList[idx].StudyList this.studyList = this.visitTaskList[idx].StudyList
var priority = parseInt(new Date().getTime()) * 10 var priority = parseInt(new Date().getTime())
res[i].imageIds.map(image=>{ res[i].imageIds.map(image => {
priority -- priority--
this.imageList.push({ imageId: image, seriesId: res[i].seriesId, studyIndex: res[i].studyIndex, seriesIndex: res[i].seriesIndex, visitTaskId: res[i].visitTaskId, priority }) this.imageList.push({ imageId: image, seriesId: res[i].seriesId, studyIndex: res[i].studyIndex, seriesIndex: res[i].seriesIndex, visitTaskId: res[i].visitTaskId, priority })
}) })
// this.studyList.map((study, studyIndex) => { // this.studyList.map((study, studyIndex) => {
// study.SeriesList.map((series, seriesIndex) => { // study.SeriesList.map((series, seriesIndex) => {
// if (series.modality !== 'SR') { // if (series.modality !== 'SR') {
@ -605,20 +605,24 @@ export default {
if (!series.loadStatus && series.modality !== 'SR') { if (!series.loadStatus && series.modality !== 'SR') {
this.loopLoadStatus = -1 this.loopLoadStatus = -1
series.isLoading = true series.isLoading = true
var p = parseInt(new Date().getTime()) var isAddToTakPool = false
series.imageIds.map((imageId, i) => { if (this.showSeriesList.includes(`${studyIndex}_${seriesIndex}`)) {
var priority = '' isAddToTakPool = true
if (i === 0) {
priority = parseInt(new Date().getTime()) * 10
} else { } else {
priority = --p this.showSeriesList.push(`${studyIndex}_${seriesIndex}`)
} }
if (!isAddToTakPool) {
var priority = parseInt(new Date().getTime())
series.imageIds.map((imageId) => {
this.imageList.push({ imageId: imageId, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) this.imageList.push({ imageId: imageId, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority })
}) })
if (this.imageList.length > 0) { if (this.imageList.length > 0) {
this.loopLoadStatus = 0 this.loopLoadStatus = 0
this.loopLoad() this.loopLoad()
} }
} else {
requestPoolManager.changePriority(series.seriesId)
}
} }
DicomEvent.$emit('loadMeasurementList', { visitTaskId: this.visitTaskId, taskBlindName: this.taskBlindName }) DicomEvent.$emit('loadMeasurementList', { visitTaskId: this.visitTaskId, taskBlindName: this.taskBlindName })
@ -668,7 +672,7 @@ export default {
store.dispatch('reading/setActiveSeries', series) store.dispatch('reading/setActiveSeries', series)
}, },
loadImages(taskInfo) { loadImages(taskInfo) {
const isBaseLineTask = taskInfo.IsBaseLineTask // const isBaseLineTask = taskInfo.IsBaseLineTask
const isCurrentTask = taskInfo.IsCurrentTask const isCurrentTask = taskInfo.IsCurrentTask
// var priority = isCurrentTask ? parseInt(new Date().getTime()) : 999 // var priority = isCurrentTask ? parseInt(new Date().getTime()) : 999
var priority = parseInt(new Date().getTime()) var priority = parseInt(new Date().getTime())
@ -689,13 +693,12 @@ export default {
// }) // })
// } // }
// //
if(!isCurrentTask && study.IsCriticalSequence){ if (!isCurrentTask && study.IsCriticalSequence) {
series.imageIds.map(image => { series.imageIds.map(image => {
priority = priority - 1 priority = priority - 1
this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority })
}) })
} }
} }
}) })
}) })
@ -704,8 +707,7 @@ export default {
loopLoad() { loopLoad() {
if (this.imageList.length > 0) { if (this.imageList.length > 0) {
// requestPoolManager.startTaskTimer()
requestPoolManager.startTaskTimer()
this.imageList.map(image => { this.imageList.map(image => {
requestPoolManager.loadAndCacheImagePlus(image.imageId, image.seriesId, image.priority).then(res => { requestPoolManager.loadAndCacheImagePlus(image.imageId, image.seriesId, image.priority).then(res => {
this.imageLoaded({ visitTaskId: this.visitTaskId, imageId: image.imageId }, res.data.string('x0020000e')) this.imageLoaded({ visitTaskId: this.visitTaskId, imageId: image.imageId }, res.data.string('x0020000e'))
@ -721,9 +723,17 @@ export default {
console.log('loadSeries') console.log('loadSeries')
this.loopLoadStatus = -1 this.loopLoadStatus = -1
this.$set(this.studyList[studyIndex].SeriesList[seriesIndex], 'isLoading', true) this.$set(this.studyList[studyIndex].SeriesList[seriesIndex], 'isLoading', true)
var isAddToTakPool = false
if (this.showSeriesList.includes(`${studyIndex}_${seriesIndex}`)) {
isAddToTakPool = true
} else {
this.showSeriesList.push(`${studyIndex}_${seriesIndex}`)
}
if (!isAddToTakPool) {
const priority = parseInt(new Date().getTime()) const priority = parseInt(new Date().getTime())
series.imageIds.map(image => { series.imageIds.map(image => {
if (series.imageloadedArr.indexOf(image) === -1) { const index = this.cachedImages.findIndex(item => item.uri === image)
if (index === -1) {
this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority })
} }
}) })
@ -731,6 +741,9 @@ export default {
this.loopLoadStatus = 0 this.loopLoadStatus = 0
this.loopLoad() this.loopLoad()
} }
} else {
requestPoolManager.changePriority(series.seriesId)
}
}, },
// //
stopLoadSeries(series, studyIndex, seriesIndex) { stopLoadSeries(series, studyIndex, seriesIndex) {
@ -791,13 +804,13 @@ export default {
} }
} }
}, },
cornerstoneimagecachechanged(e){ cornerstoneimagecachechanged(e) {
const cacheInfo = cornerstone.imageCache.getCacheInfo() const cacheInfo = cornerstone.imageCache.getCacheInfo()
console.log(cacheInfo) console.log(cacheInfo)
}, },
cornerstoneimagecachefull(e){ cornerstoneimagecachefull(e) {
console.log('超过内存了') console.log('超过内存了')
}, }
} }
} }
</script> </script>
@ -809,6 +822,7 @@ export default {
width:100%; width:100%;
height: 100%; height: 100%;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden;
.dicom-desc{ .dicom-desc{
font-weight: bold; font-weight: bold;
font-size: 13px; font-size: 13px;