diff --git a/src/utils/request-pool.js b/src/utils/request-pool.js index 0807f01b..ec19d322 100644 --- a/src/utils/request-pool.js +++ b/src/utils/request-pool.js @@ -1,7 +1,7 @@ import * as cornerstone from 'cornerstone-core' var taskPool = [] // 请求池 let numRequest = 0 // 正在执行数量 -const maxRequest = 6 // 可配置 +const maxRequest = 5 // 可配置 let taskTimer // 轮询的定时器 var cachedTask = {} // 存放的任务数据 let sortType = 1 @@ -10,9 +10,10 @@ let startExecuteTask = null let endExecuteTask = performance.now() // 执行下载 async function executeTask() { + console.log(taskPool) endExecuteTask = performance.now() i++ - // stopTaskTimer() + stopTaskTimer() if (taskPool.length > 0) { let startSortTime = performance.now() if( sortType ){ @@ -119,6 +120,14 @@ function removeTask(seriesId){ } startTaskTimer() } +function changePriority(seriesId){ + taskPool.map(task=>{ + if(task.seriesId === seriesId){ + task.priority = parseInt(new Date().getTime()) * 10 + } + }) + sortTaskPool() +} function setSortType(type){ sortType = type } @@ -147,6 +156,7 @@ export default { executeTask, setSortType, sortTaskPool, + changePriority, startTaskTimer, stopTaskTimer, loadAndCacheImagePlus, diff --git a/src/views/dicom-show/dicom-study.vue b/src/views/dicom-show/dicom-study.vue index cc8970d3..76ffae39 100644 --- a/src/views/dicom-show/dicom-study.vue +++ b/src/views/dicom-show/dicom-study.vue @@ -152,7 +152,8 @@ export default { firstInstanceId: '', showDelete: false, loading: false, - imageList: [] + imageList: [], + showSeriesList: [] } }, created: function() { @@ -307,17 +308,22 @@ export default { this.currentSeriesIndex = seriesIndex this.$refs.dicomViewer.loadImageStack(this.seriesList[seriesIndex]) if (!series.loadStatus) { - series.isLoading = true - var p = new Date().getTime() - series.imageIds.map((imageId, i) => { - var priority = '' - if (i === 0) { - priority = new Date(new Date().setHours(23, 59, 59, 999)).getTime() - } else { - priority = p - 1 - } - this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) - }) + requestPoolManager.changePriority(series.seriesId) + // var isAddToTakPool = false + // if (this.showSeriesList.includes(`${seriesIndex}`)) { + // isAddToTakPool = true + // } else { + // this.showSeriesList.push(`${seriesIndex}`) + // } + // if (!isAddToTakPool) { + // var priority = parseInt(new Date().getTime()) + // series.isLoading = true + // series.imageIds.map((imageId) => { + // this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) + // }) + // } else { + // requestPoolManager.changePriority(series.seriesId) + // } } }, initStudy() { diff --git a/src/views/dicom-show/dicom-visit.vue b/src/views/dicom-show/dicom-visit.vue index 85ee8aec..8ca4336c 100644 --- a/src/views/dicom-show/dicom-visit.vue +++ b/src/views/dicom-show/dicom-visit.vue @@ -233,7 +233,8 @@ export default { showDelete: 0, imageList: [], activeNames: [], - relationActiveName: [] + relationActiveName: [], + showSeriesList: [] } }, mounted() { @@ -323,18 +324,22 @@ export default { this.currentSeriesIndex = seriesIndex this.$refs.dicomViewer.loadImageStack(this.studyList[studyIndex].SeriesList[seriesIndex]) if (!series.loadStatus) { - series.isLoading = true - var p = parseInt(new Date().getTime()) - series.imageIds.map((imageId, i) => { - var priority = '' - if (i === 0) { - priority = parseInt(new Date().getTime()) * 10 - } else { - priority = p - 1 - } - this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) - // this.load(imageId, series.seriesId, priority) - }) + requestPoolManager.changePriority(series.seriesId) + // var isAddToTakPool = false + // if (this.showSeriesList.includes(`${studyIndex}_${seriesIndex}`)) { + // isAddToTakPool = true + // } else { + // this.showSeriesList.push(`${studyIndex}_${seriesIndex}`) + // } + // if (!isAddToTakPool) { + // var priority = parseInt(new Date().getTime()) + // series.isLoading = true + // series.imageIds.map((imageId, i) => { + // this.imageList.push({ imageId: imageId, seriesId: series.seriesId, priority }) + // }) + // } else { + // requestPoolManager.changePriority(series.seriesId) + // } } }, changeReadingStatus(callback, data) { @@ -515,7 +520,7 @@ export default { this.imageLoaded(image, res.data.string('x0020000e')) }) }) - + requestPoolManager.sortTaskPool() this.imageList = [] } }, diff --git a/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue b/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue index 60ab27b9..833696ac 100644 --- a/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue +++ b/src/views/trials/trials-panel/reading/dicoms/components/StudyList.vue @@ -170,6 +170,7 @@ export default { return { studyList: [], cachedImages: [], + showSeriesList: [], studyIndex: null, seriesIndex: null, loading: false, @@ -228,11 +229,12 @@ export default { // cornerstone.events.addEventListener('cornerstoneimagecachechanged', this.cornerstoneimagecachechanged) }, beforeDestroy() { + console.log('study---beforeDestroy') cornerstone.imageCache.purgeCache() DicomEvent.$off('refreshStudyListMeasureData') }, methods: { - initStudyInfo(){ + initStudyInfo() { const loading = this.$loading({ fullscreen: true }) // 初始化待渲染序列 this.getInitSeries().then((res) => { @@ -243,18 +245,16 @@ export default { console.log(res) var i = res.findIndex(s => s.isCurrentTask) if (i > -1) { - var idx = this.visitTaskList.findIndex(i => i.VisitTaskId === this.visitTaskId) if (idx > -1) { this.measureData = this.visitTaskList[idx].MeasureData this.studyList = this.visitTaskList[idx].StudyList - var priority = parseInt(new Date().getTime()) * 10 - res[i].imageIds.map(image=>{ - priority -- + var priority = parseInt(new Date().getTime()) + res[i].imageIds.map(image => { + 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) => { // study.SeriesList.map((series, seriesIndex) => { // if (series.modality !== 'SR') { @@ -605,19 +605,23 @@ export default { if (!series.loadStatus && series.modality !== 'SR') { this.loopLoadStatus = -1 series.isLoading = true - var p = parseInt(new Date().getTime()) - series.imageIds.map((imageId, i) => { - var priority = '' - if (i === 0) { - priority = parseInt(new Date().getTime()) * 10 - } else { - priority = --p + var isAddToTakPool = false + if (this.showSeriesList.includes(`${studyIndex}_${seriesIndex}`)) { + isAddToTakPool = true + } else { + 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 }) + }) + if (this.imageList.length > 0) { + this.loopLoadStatus = 0 + this.loopLoad() } - this.imageList.push({ imageId: imageId, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) - }) - if (this.imageList.length > 0) { - this.loopLoadStatus = 0 - this.loopLoad() + } else { + requestPoolManager.changePriority(series.seriesId) } } @@ -668,7 +672,7 @@ export default { store.dispatch('reading/setActiveSeries', series) }, loadImages(taskInfo) { - const isBaseLineTask = taskInfo.IsBaseLineTask + // const isBaseLineTask = taskInfo.IsBaseLineTask const isCurrentTask = taskInfo.IsCurrentTask // var priority = isCurrentTask ? parseInt(new Date().getTime()) : 999 var priority = parseInt(new Date().getTime()) @@ -689,13 +693,12 @@ export default { // }) // } // 均只下载关键序列 - if(!isCurrentTask && study.IsCriticalSequence){ + if (!isCurrentTask && study.IsCriticalSequence) { series.imageIds.map(image => { priority = priority - 1 this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) }) } - } }) }) @@ -704,15 +707,14 @@ export default { loopLoad() { if (this.imageList.length > 0) { - - requestPoolManager.startTaskTimer() + // requestPoolManager.startTaskTimer() this.imageList.map(image => { requestPoolManager.loadAndCacheImagePlus(image.imageId, image.seriesId, image.priority).then(res => { this.imageLoaded({ visitTaskId: this.visitTaskId, imageId: image.imageId }, res.data.string('x0020000e')) }) }) requestPoolManager.sortTaskPool() - + this.imageList = [] } }, @@ -721,15 +723,26 @@ export default { console.log('loadSeries') this.loopLoadStatus = -1 this.$set(this.studyList[studyIndex].SeriesList[seriesIndex], 'isLoading', true) - const priority = parseInt(new Date().getTime()) - series.imageIds.map(image => { - if (series.imageloadedArr.indexOf(image) === -1) { - this.imageList.push({ imageId: image, seriesId: series.seriesId, studyIndex: studyIndex, seriesIndex: seriesIndex, visitTaskId: series.visitTaskId, priority }) + 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()) + series.imageIds.map(image => { + 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 }) + } + }) + if (this.imageList.length > 0) { + this.loopLoadStatus = 0 + this.loopLoad() } - }) - if (this.imageList.length > 0) { - this.loopLoadStatus = 0 - this.loopLoad() + } else { + requestPoolManager.changePriority(series.seriesId) } }, // 暂停下载 @@ -791,13 +804,13 @@ export default { } } }, - cornerstoneimagecachechanged(e){ + cornerstoneimagecachechanged(e) { const cacheInfo = cornerstone.imageCache.getCacheInfo() console.log(cacheInfo) }, - cornerstoneimagecachefull(e){ + cornerstoneimagecachefull(e) { console.log('超过内存了') - }, + } } } @@ -809,6 +822,7 @@ export default { width:100%; height: 100%; overflow-y: auto; + overflow-x: hidden; .dicom-desc{ font-weight: bold; font-size: 13px;