fix: 修复部分内存溢出问题,修改beta下的分析全部谱时的逻辑,修复切换谱后,即使已经分析过了,还是无法保存的问题

This commit is contained in:
Xu Zhimeng 2024-04-12 17:00:00 +08:00
parent 990ab9def5
commit 333a7fd1f4
5 changed files with 115 additions and 51 deletions

View File

@ -30,9 +30,10 @@ export default {
this._chart.setOption(this.option, this.opts)
this.initEventListener()
},
destroyed() {
beforeDestroy() {
if (this._chart) {
this._chart.dispose()
this._chart = null
}
},
methods: {

View File

@ -190,6 +190,10 @@ export default {
analyseCurrentSpectrum: {
type: Object,
},
sampleList: {
type: Array,
required: true,
},
},
data() {
this.SampleType = SampleType
@ -238,7 +242,7 @@ export default {
this.qcFlagsVisible = true
}, 100)
},
destroyed() {
beforeDestroy() {
this.cancelLastRequest()
this.$bus.$off('ReAnalyses', this.handleReAnalyse)
@ -559,6 +563,16 @@ export default {
})
this.$emit('reAnalyCurr', res.result.savedAnalysisResult, res.result.XeData)
this.handleReAnalyse(res.result)
updateSampleData({
inputFileName: this.sample.inputFileName,
key: 'XeData',
data: res.result.XeData,
})
updateSampleData({
inputFileName: this.sample.inputFileName,
key: 'savedAnalysisResult',
data: res.result.savedAnalysisResult,
})
if (res.result.bProcessed) {
this.$message.success(res.result.message)
} else {
@ -571,47 +585,77 @@ export default {
})
},
//
getAnalyzeAllSpectrum() {
let params = {
dbNames: [this.sample.dbName],
sampleIds: [this.sample.sampleId ? this.sample.sampleId : ''],
sampleFileNames: [this.sample.inputFileName],
gasFileNames: [this.sample.gasFileName],
detFileNames: [this.sample.detFileName],
qcFileNames: [this.sample.qcFileName],
async getAnalyzeAllSpectrum() {
const regExp = /^([A-Z]{1,}\d{1,})_/
const regMatched = this.sample.inputFileName.match(regExp)
const currStationName = regMatched[1]
const dbNames = [],
sampleIds = [],
sampleFileNames = [],
gasFileNames = [],
detFileNames = [],
qcFileNames = []
const matchedSampleList = this.sampleList.filter((item) => item.inputFileName.includes(currStationName))
matchedSampleList.forEach(
({ dbName, sampleId, inputFileName, sampleFileName, gasFileName, detFileName, qcFileName, qcFileStatus }) => {
dbNames.push(dbName || '')
sampleIds.push(sampleId || '')
sampleFileNames.push(sampleFileName || inputFileName || '')
gasFileNames.push(gasFileName || '')
detFileNames.push(detFileName || '')
qcFileNames.push(qcFileStatus ? qcFileName : '')
}
)
const params = {
dbNames,
sampleIds,
sampleFileNames,
gasFileNames,
detFileNames,
qcFileNames,
currentFileName: this.sample.inputFileName,
}
postAction('/spectrumAnalysis/analyseAllSpectrum', params).then((res) => {
if (res.success) {
// this.analyseCurrentSpectrum = res.result
this.$emit('sendXeData', res.result.XeData)
res.result.XeData.forEach((item) => {
const { success, result, message } = await postAction('/spectrumAnalysis/analyseAllSpectrum', params)
if (success) {
//
Object.entries(result).forEach(([inputFileName, sampleInfo]) => {
const { XeData, savedAnalysisResult, bProcessed, message } = sampleInfo
XeData.forEach((item) => {
item.conc = parseFloat(item.conc.toPrecision(6))
item.concErr = parseFloat(item.concErr.toPrecision(6))
item.lc = parseFloat(item.lc.toPrecision(6))
item.mdc = parseFloat(item.mdc.toPrecision(6))
})
this.$emit('reAnalyAll', res.result.savedAnalysisResult, res.result.XeData)
//
this.removeOtherBetaSamples()
} else {
this.$message.warning(res.message)
}
})
},
if (inputFileName == this.sample.inputFileName) {
this.$emit('sendXeData', XeData)
this.$emit('reAnalyAll', savedAnalysisResult, XeData)
this.handleReAnalyse(sampleInfo)
// beta
removeOtherBetaSamples() {
const regExp = /([A-Z]+\d+_\d+)(-[\w\s_\.]+)/
const stationAndDetectorName = this.sample.inputFileName.replace(regExp, '$1')
// +
const filterList = sampleList.filter((item) => {
const inputFileName = item.inputFileName
return inputFileName == this.sample.inputFileName || !inputFileName.startsWith(stationAndDetectorName)
})
if (bProcessed) {
this.$message.success(message)
} else {
this.$message.warning(message)
}
}
setSampleList(filterList)
updateSampleData({
inputFileName,
key: 'XeData',
data: XeData,
})
updateSampleData({
inputFileName,
key: 'savedAnalysisResult',
data: savedAnalysisResult,
})
})
} else {
this.$message.warning(message)
}
},
//
@ -703,11 +747,6 @@ export default {
// this.currResultDisplay = newVal.XeData
this.resultDisplay = cloneDeep(newVal.XeData) || []
this.sortResultDisplay()
updateSampleData({
inputFileName: this.sample.inputFileName,
key: 'XeData',
data: newVal.XeData,
})
},
// immediate: true,
deep: true,

View File

@ -629,7 +629,7 @@ export default {
this.$bus.$on('betaRefresh', this.getData)
this.getData()
},
destroyed() {
beforeDestroy() {
this.$bus.$off('betaRefresh', this.handleReset)
this.$bus.$off('betaRefresh', this.getData)
},

View File

@ -191,8 +191,8 @@ export default {
stripSumOrCutLine: null,
stripReferenceLine: null,
}
;(this.peakList = []), // Peak
(this.baseCtrls = {}) // BaseCtrls
this.peakList = [] // Peak
this.baseCtrls = {} // BaseCtrls
return {
abc: false,
@ -254,7 +254,7 @@ export default {
window.addEventListener('keydown', this.handleKeyboardEvent)
window.addEventListener('click', this.closePeakInfomationTooltip)
},
destroyed() {
beforeDestroy() {
this.cancelLastRequest()
this.$bus.$off('gammaRefresh', this.handleRefresh)
@ -264,8 +264,16 @@ export default {
window.removeEventListener('click', this.closePeakInfomationTooltip)
if (this.qcFlagsTimer) {
clearTimeout(this.qcFlagsTimer)
window.clearTimeout(this.qcFlagsTimer)
}
this.closeWebSocket()
if (this.websocketTimer) {
window.clearTimeout(this.websocketTimer)
}
this.websock = null
},
deactivated() {
// Object.keys(this.subOperatorsState).forEach(k => {
@ -465,10 +473,10 @@ export default {
let token = Vue.ls.get(ACCESS_TOKEN)
this.websock = new WebSocket(url, [token])
//update-end-author:taoyan date:2022-4-22 for: v2.4.6 websocket #3278
this.websock.onopen = this.websocketOnopen
this.websock.onerror = this.websocketOnerror
this.websock.onmessage = this.websocketOnmessage
this.websock.onclose = this.websocketOnclose
this.websock.addEventListener('open', this.websocketOnopen)
this.websock.addEventListener('error', this.websocketOnerror)
this.websock.addEventListener('message', this.websocketOnmessage)
this.websock.addEventListener('close', this.websocketOnclose)
},
websocketOnopen: function () {
// console.log('WebSocket1231')
@ -494,12 +502,25 @@ export default {
if (that.lockReconnect) return
that.lockReconnect = true
//
setTimeout(function () {
this.websocketTimer = setTimeout(function () {
console.info('尝试重连...')
that.initWebSocket()
that.lockReconnect = false
}, 20000)
},
// websocket
closeWebSocket() {
if (this.websock) {
this.websock.removeEventListener('open', this.websocketOnopen)
this.websock.removeEventListener('error', this.websocketOnerror)
this.websock.removeEventListener('message', this.websocketOnmessage)
this.websock.removeEventListener('close', this.websocketOnclose)
this.websock.close()
this.websock = null
}
},
//
async getSampleDetail() {
const { dbName, sampleId, analyst } = this.sample

View File

@ -63,6 +63,7 @@
:sampleInfo="sampleInfo"
:sample="sampleData"
:analyseCurrentSpectrum="analyseCurrentSpectrumData"
:sampleList="sampleList"
/>
<!-- Beta-Gamma 分析 -->
<div v-else class="empty">Please Select a Sample</div>
@ -281,7 +282,7 @@ import BGLogViewer from './components/Modals/BetaGammaModals/BGLogViewer.vue'
import { saveAs } from 'file-saver'
import CompareFromDbModal from './components/Modals/CompareFromDBModal.vue'
import { clearSampleData, updateSampleDataAnaly } from '@/utils/SampleStore'
import { clearSampleData, getSampleData, updateSampleDataAnaly } from '@/utils/SampleStore'
//
const ANALYZE_TYPE = {
@ -466,7 +467,7 @@ export default {
window.addEventListener('beforeunload', this.handleCleanAll)
},
destroyed() {
beforeDestroy() {
this.$bus.$off('reanalyse', this.handleReanalyse)
clearSampleData()
this.handleCleanAll()
@ -504,6 +505,7 @@ export default {
}
this.resultDisplayFlag = arg
this.params_toDB.stationName = val
this.params_toDB.savedAnalysisResult = flag
this.isReAnalyed_beta = this.isReAnalyed_beta ? this.isReAnalyed_beta : flag
},
getCheckFlag(val) {
@ -608,12 +610,13 @@ export default {
// Bbeta-gamma P Ggamma
if (sample.sampleType == 'B') {
this.analysisType = ANALYZE_TYPE.BETA_GAMMA
const sampleData = getSampleData(sample.inputFileName)
this.params_toDB.savedAnalysisResult = sampleData ? sampleData.data.savedAnalysisResult : false
} else {
this.analysisType = ANALYZE_TYPE.GAMMA
}
this.sampleData = this.newSampleData = sample
this.currSampleDet = this.allSampleDet[sample.inputFileName]
this.params_toDB.savedAnalysisResult = sample.sampleId ? true : false
this.params_toDB.comment = ''
},