上传添加时间戳
continuous-integration/drone/push Build is passing Details

uat_us
熊飞 2024-01-18 11:17:54 +08:00
parent 033a34cf1e
commit 8081b33a97
2 changed files with 211 additions and 178 deletions

View File

@ -24,7 +24,28 @@ async function ossGenerateSTS() {
switch (res.Result.ObjectStoreUse) { switch (res.Result.ObjectStoreUse) {
case 'AliyunOSS': case 'AliyunOSS':
Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName Vue.prototype.OSSclientConfig.bucket = Vue.prototype.OSSclientConfig.bucketName
Vue.prototype.OSSclient = new OSS(Vue.prototype.OSSclientConfig) let OSSclient = new OSS(Vue.prototype.OSSclientConfig)
Vue.prototype.OSSclient = {
put: function (objectName, object) {
return new Promise(async (resolve, reject) => {
try {
objectName = objectName + '_' + new Date().getTime()
let res = await OSSclient.put(objectName, object)
if (res && res.url) {
resolve({
name: objectName,
url: Vue.prototype.OSSclientConfig.viewEndpoint + objectName
})
} else {
reject()
}
} catch (e) {
console.log(e)
reject()
}
})
}
}
break break
case 'MinIO': case 'MinIO':
let minioClient = new Minio.Client(Vue.prototype.OSSclientConfig); let minioClient = new Minio.Client(Vue.prototype.OSSclientConfig);

View File

@ -1021,195 +1021,207 @@ export default {
archiveStudy(index, config) { archiveStudy(index, config) {
var scope = this var scope = this
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
preArchiveDicomStudy({ try {
trialId: scope.trialId, preArchiveDicomStudy({
siteId: scope.data.SiteId,
subjectId: scope.subjectId,
subjectVisitId: scope.subjectVisitId,
// failedFileCount: scope.uploadQueues[index].dicomInfo.failedFileCount,
fileSize: scope.uploadQueues[index].dicomInfo.fileSize,
fileCount: scope.uploadQueues[index].dicomInfo.fileCount,
IsDicomReUpload: scope.uploadQueues[index].uploadState.AllowReUpload
}).then(async res => {
let dicomInfo = scope.uploadQueues[index].dicomInfo
let seriesNum = scope.uploadQueues[index].seriesList.length
let fileNum = scope.uploadQueues[index].fileList.length
let seriesList = scope.uploadQueues[index].seriesList
let fileList = scope.uploadQueues[index].fileList
dicomInfo.seriesNum = seriesNum
dicomInfo.fileNum = fileNum
dicomInfo.siteId = scope.data.SiteId
dicomInfo.subjectId = scope.data.SubjectId
dicomInfo.subjectVisitId = scope.subjectVisitId
let t = setInterval(() => {
dicomUploadInProgress({
trialId: scope.trialId,
studyInstanceUid: dicomInfo.studyUid
}).then(res => {
})
}, 5000)
scope.myInterval.push(t)
let Record = {
Failed: [],
Existed: [],
Uploaded: [],
FileCount: 0
}
let params = {
trialId: scope.trialId, trialId: scope.trialId,
siteId: scope.data.SiteId, siteId: scope.data.SiteId,
subjectId: scope.subjectId, subjectId: scope.subjectId,
subjectVisitId: scope.subjectVisitId, subjectVisitId: scope.subjectVisitId,
studyMonitorId: res.Result, // failedFileCount: scope.uploadQueues[index].dicomInfo.failedFileCount,
failedFileCount: 0, fileSize: scope.uploadQueues[index].dicomInfo.fileSize,
RecordPath: null, fileCount: scope.uploadQueues[index].dicomInfo.fileCount,
study: { IsDicomReUpload: scope.uploadQueues[index].uploadState.AllowReUpload
studyId: dicomInfo.studyId, }).then(async res => {
studyInstanceUid: dicomInfo.studyUid, let dicomInfo = scope.uploadQueues[index].dicomInfo
studyTime: dicomInfo.studyTime, let seriesNum = scope.uploadQueues[index].seriesList.length
description: dicomInfo.description, let fileNum = scope.uploadQueues[index].fileList.length
seriesCount: dicomInfo.seriesNum, let seriesList = scope.uploadQueues[index].seriesList
instanceCount: dicomInfo.fileNum, let fileList = scope.uploadQueues[index].fileList
institutionName: dicomInfo.institutionName, dicomInfo.seriesNum = seriesNum
patientId: config.DicomStoreInfo.SubjectCode, dicomInfo.fileNum = fileNum
patientName: '', dicomInfo.siteId = scope.data.SiteId
patientAge: '', dicomInfo.subjectId = scope.data.SubjectId
patientSex: config.DicomStoreInfo.SubjectSex, dicomInfo.subjectVisitId = scope.subjectVisitId
accessionNumber: dicomInfo.accNumber, let t = setInterval(() => {
patientBirthDate: '', dicomUploadInProgress({
acquisitionTime: dicomInfo.acquisitionTime, trialId: scope.trialId,
acquisitionNumber: dicomInfo.acquisitionNumber, studyInstanceUid: dicomInfo.studyUid
triggerTime: dicomInfo.triggerTime, }).then(res => {
bodyPartExamined: '', })
seriesList: [], }, 5000)
scope.myInterval.push(t)
let Record = {
Failed: [],
Existed: [],
Uploaded: [],
FileCount: 0
} }
} let params = {
let arr = [] trialId: scope.trialId,
for (let i = 0; i < seriesList.length; i++) { siteId: scope.data.SiteId,
let v = seriesList[i] subjectId: scope.subjectId,
let instanceList = [] subjectVisitId: scope.subjectVisitId,
let ImageResizePath studyMonitorId: res.Result,
for (let ii = 0; ii < v.instanceList.length; ii++) { failedFileCount: 0,
arr.push((function (){ RecordPath: null,
return new Promise(async resolve1 => { study: {
let o = v.instanceList[ii] studyId: dicomInfo.studyId,
let name = `${v.instanceList[ii].instanceUid}_${v.instanceList[ii].file.webkitRelativePath}` studyInstanceUid: dicomInfo.studyUid,
if (o.isReUpload) { studyTime: dicomInfo.studyTime,
dicomInfo.failedFileCount++ description: dicomInfo.description,
Record.Existed.push(name) seriesCount: dicomInfo.seriesNum,
Record.FileCount++ instanceCount: dicomInfo.fileNum,
} else { institutionName: dicomInfo.institutionName,
let path = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${v.seriesUid}/${o.instanceUid}/${scope.getGuid(dicomInfo.studyUid + v.seriesUid + o.instanceUid + params.trialId)}` patientId: config.DicomStoreInfo.SubjectCode,
let res = await dcmUpload(path, o.file, config) patientName: '',
if (!res) { patientAge: '',
params.failedFileCount++ patientSex: config.DicomStoreInfo.SubjectSex,
} else { accessionNumber: dicomInfo.accNumber,
dicomInfo.failedFileCount++ patientBirthDate: '',
if (ii === 0 && o.modality !== 'SR') { acquisitionTime: dicomInfo.acquisitionTime,
let fileId = cornerstoneWADOImageLoader.wadouri.fileManager.add( acquisitionNumber: dicomInfo.acquisitionNumber,
o.file triggerTime: dicomInfo.triggerTime,
) bodyPartExamined: '',
let blob = await scope.dicomToPng(fileId, o.imageColumns, o.imageRows) seriesList: [],
let thumbnailPath = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${v.seriesUid}/${v.seriesUid}.png` }
let OSSclient = scope.OSSclient }
let seriesRes = await OSSclient.put(thumbnailPath, blob) let arr = []
if (seriesRes && seriesRes.url) { for (let i = 0; i < seriesList.length; i++) {
ImageResizePath = scope.$getObjectName(seriesRes.url) let v = seriesList[i]
let instanceList = []
let ImageResizePath
for (let ii = 0; ii < v.instanceList.length; ii++) {
arr.push((function (){
return new Promise(async resolve1 => {
try {
let o = v.instanceList[ii]
let name = `${v.instanceList[ii].instanceUid}_${v.instanceList[ii].file.webkitRelativePath}`
if (o.isReUpload) {
dicomInfo.failedFileCount++
Record.Existed.push(name)
Record.FileCount++
} else {
let path = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${v.seriesUid}/${o.instanceUid}/${scope.getGuid(dicomInfo.studyUid + v.seriesUid + o.instanceUid + params.trialId)}`
let res = await dcmUpload(path, o.file, config)
console.log('imageRes', res)
if (!res || !res.url) {
params.failedFileCount++
} else {
dicomInfo.failedFileCount++
if (ii === 0 && o.modality !== 'SR') {
let fileId = cornerstoneWADOImageLoader.wadouri.fileManager.add(
o.file
)
let blob = await scope.dicomToPng(fileId, o.imageColumns, o.imageRows)
let thumbnailPath = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${v.seriesUid}/${v.seriesUid}.png`
let OSSclient = scope.OSSclient
let seriesRes = await OSSclient.put(thumbnailPath, blob)
console.log('seriesRes', seriesRes)
if (seriesRes && seriesRes.url) {
ImageResizePath = scope.$getObjectName(seriesRes.url)
}
}
}
if (res && res.url) {
instanceList.push({
studyInstanceUid: dicomInfo.studyUid,
seriesInstanceUid: v.seriesUid,
sopInstanceUid: o.instanceUid,
instanceNumber: o.instanceNumber,
instanceTime: o.instanceTime,
imageRows: o.imageRows,
imageColumns: o.imageColumns,
sliceLocation: o.sliceLocation,
sliceThickness: o.sliceThickness,
numberOfFrames: o.numberOfFrames,
pixelSpacing: o.pixelSpacing,
imagerPixelSpacing: o.imagerPixelSpacing,
frameOfReferenceUID: o.frameOfReferenceUID,
windowCenter: o.windowCenter,
windowWidth: o.windowWidth,
path: scope.$getObjectName(res.url)
})
Record.Uploaded.push(name)
Record.FileCount++
} else {
Record.Failed.push(name)
Record.FileCount++
} }
} }
resolve1()
} catch (e) {
console.log(e)
resolve1()
} }
if (res && res.url) { })
instanceList.push({ })())
studyInstanceUid: dicomInfo.studyUid, if (arr.length >= 66 || ii === v.instanceList.length - 1) {
seriesInstanceUid: v.seriesUid, await Promise.all(arr)
sopInstanceUid: o.instanceUid, arr = []
instanceNumber: o.instanceNumber, }
instanceTime: o.instanceTime,
imageRows: o.imageRows,
imageColumns: o.imageColumns,
sliceLocation: o.sliceLocation,
sliceThickness: o.sliceThickness,
numberOfFrames: o.numberOfFrames,
pixelSpacing: o.pixelSpacing,
imagerPixelSpacing: o.imagerPixelSpacing,
frameOfReferenceUID: o.frameOfReferenceUID,
windowCenter: o.windowCenter,
windowWidth: o.windowWidth,
path: scope.$getObjectName(res.url)
})
Record.Uploaded.push(name)
Record.FileCount++
} else {
Record.Failed.push(name)
Record.FileCount++
}
}
resolve1()
})
})())
if (arr.length >= 66 || ii === v.instanceList.length - 1) {
await Promise.all(arr)
arr = []
} }
params.study.seriesList.push({
studyInstanceUid: dicomInfo.studyUid,
seriesInstanceUid: v.seriesUid,
seriesNumber: v.seriesNumber,
seriesTime: v.seriesTime,
sliceThickness: v.sliceThickness,
imagePositionPatient: v.imagePositionPatient,
imageOrientationPatient: v.imageOrientationPatient,
sequenceName: v.sequenceName,
protocolName: v.protocolName,
imagerPixelSpacing: v.imagerPixelSpacing,
acquisitionTime: dicomInfo.acquisitionTime,
acquisitionNumber: dicomInfo.acquisitionNumber,
triggerTime: dicomInfo.triggerTime,
modality: v.modality,
description: v.description,
instanceCount: v.instanceList.length,
bodyPartExamined: dicomInfo.bodyPart,
instanceList: instanceList,
ImageResizePath: ImageResizePath,
})
} }
params.study.seriesList.push({ console.log(Record)
studyInstanceUid: dicomInfo.studyUid, let text = JSON.stringify(Record)
seriesInstanceUid: v.seriesUid, let logJsonBlob = scope.generateTxtFile(text)
seriesNumber: v.seriesNumber, console.log(logJsonBlob)
seriesTime: v.seriesTime, let logJsonObjectName = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${params.studyMonitorId}.txt`
sliceThickness: v.sliceThickness, let logRes = await scope.OSSclient.put(logJsonObjectName, logJsonBlob)
imagePositionPatient: v.imagePositionPatient, if (logRes && logRes.url) {
imageOrientationPatient: v.imageOrientationPatient, params.study.instanceCount = dicomInfo.failedFileCount
sequenceName: v.sequenceName, params.RecordPath = logJsonObjectName
protocolName: v.protocolName, addOrUpdateArchiveStudy(params).then(res => {
imagerPixelSpacing: v.imagerPixelSpacing, if (dicomInfo.failedFileCount === dicomInfo.fileCount) {
acquisitionTime: dicomInfo.acquisitionTime, scope.$message.success(scope.$t('trials:uploadDicomList:label:uploaded'))
acquisitionNumber: dicomInfo.acquisitionNumber, } else {
triggerTime: dicomInfo.triggerTime, scope.$alert(scope.$t('trials:uploadDicomList:label:uploadFailed'))
modality: v.modality, }
description: v.description, // scope.uploadQueues[index].uploadState.selected = true
instanceCount: v.instanceList.length, scope.uploadQueues[index].uploadState.selected = true
bodyPartExamined: dicomInfo.bodyPart, scope.uploadQueues[index].uploadState.record = Record
instanceList: instanceList, // scope.$refs.dicomFilesTable.toggleRowSelection(scope.uploadQueues[index])
ImageResizePath: ImageResizePath, scope.getStudyInfo()
}) if (scope.$route.path !== '/trials/trials-panel/visit/crc-question') {
} scope.$emit('getList')
console.log(Record) }
let text = JSON.stringify(Record) clearInterval(t)
let logJsonBlob = scope.generateTxtFile(text) resolve()
console.log(logJsonBlob) }).catch((res) => {
let logJsonObjectName = `/${params.trialId}/Image/${params.siteId}/${params.subjectId}/${params.subjectVisitId}/${dicomInfo.studyUid}/${params.studyMonitorId}.txt` scope.uploadQueues[index].uploadState.record = Record
let logRes = await scope.OSSclient.put(logJsonObjectName, logJsonBlob) reject()
if (logRes && logRes.url) { clearInterval(t)
params.study.instanceCount = dicomInfo.failedFileCount })
params.RecordPath = logJsonObjectName } else {
addOrUpdateArchiveStudy(params).then(res => { scope.$alert(scope.$t('trials:uploadDicomList:label:generateLogFailed'))
if (dicomInfo.failedFileCount === dicomInfo.fileCount) {
scope.$message.success(scope.$t('trials:uploadDicomList:label:uploaded'))
} else {
scope.$alert(scope.$t('trials:uploadDicomList:label:uploadFailed'))
}
// scope.uploadQueues[index].uploadState.selected = true
scope.uploadQueues[index].uploadState.selected = true
scope.uploadQueues[index].uploadState.record = Record
// scope.$refs.dicomFilesTable.toggleRowSelection(scope.uploadQueues[index])
scope.getStudyInfo()
if (scope.$route.path !== '/trials/trials-panel/visit/crc-question') {
scope.$emit('getList')
}
clearInterval(t)
resolve()
}).catch((res) => {
scope.uploadQueues[index].uploadState.record = Record
reject() reject()
clearInterval(t) clearInterval(t)
}) }
} else { })
scope.$alert(scope.$t('trials:uploadDicomList:label:generateLogFailed')) } catch (e) {
reject() console.log(e)
clearInterval(t) reject()
} }
})
}) })
}, },
generateTxtFile(text) { generateTxtFile(text) {