fix:1 修改fitting逻辑解决计算错误问题;2 增加数据缓存,再次打开他弹窗回显上一次fitting结果

This commit is contained in:
xiaoguangbin 2023-11-02 10:12:38 +08:00
parent 9e1377d5df
commit fea099fe4f
3 changed files with 174 additions and 88 deletions

View File

@ -545,6 +545,12 @@ const newCalibrationFuncModel = {
export default {
mixins: [SampleDataMixin],
components: { CustomChart, TitleOverBorder },
props: {
isFirstFitting: {
type: Boolean,
required: false,
},
},
data() {
this.columns = columns
@ -594,7 +600,7 @@ export default {
recalculateROICountsFor: [],
count: 0, // tableWidgets
isFirstFitting: true,
// isFirstFitting: true,
isInverse: false, //
betaIsFitting: false,
}
@ -608,12 +614,14 @@ export default {
},
async getData() {
const { sampleId = '', qcFileName } = this.newSampleData
// sampleFileName 20231101xiao
const { sampleId = '', qcFileName, sampleFileName = inputFileName } = this.newSampleData
try {
this.isLoading = true
const res = await getAction('/spectrumAnalysis/viewBetaDetectorCalibration', {
sampleId,
qcFileName,
sampleFileName
})
if (res.success) {
const { CToE, EToC, betaEnergy, gammaEnergy, gammaGatedBetaSpectrum, histogramData, oldScatterSeries } =
@ -623,7 +631,7 @@ export default {
this.oldScatterSeries = oldScatterSeries
this.count = oldScatterSeries.length
this.isFirstFitting = true
// this.isFirstFitting = true
this.betaGammaChartOption.series.data = histogramData.map(({ b, g, c }) => [b, g, c])
this.gammaEnergy = gammaEnergy
@ -644,6 +652,13 @@ export default {
this.figureChartOption.series[0].markPoint.data = oldScatterSeries.map(({ x, y }) => ({ xAxis: x, yAxis: y }))
this.oldChartOption = cloneDeep(this.figureChartOption)
// reanalyzefittingReanalyze 20231101xiao
// todo fitting
if(this.getCache("calibration-beta:"+this.newSampleData.inputFileName)) {
this.setFirringResult(this.getCache("calibration-beta:"+this.newSampleData.inputFileName))
return false;
}
} else {
this.$message.error(res.message)
}
@ -861,6 +876,7 @@ export default {
// Reset Button
handleReset() {
this.removeCache("calibration-beta:"+this.newSampleData.inputFileName) // fitting 20231101:xiao
this.newCalibrationFuncModel = cloneDeep(newCalibrationFuncModel)
this.list = []
this.newE2C = []
@ -880,7 +896,9 @@ export default {
}
try {
const { success, result, message } = await postAction('/spectrumAnalysis/fitting', {
...this.newCalibrationFuncModel,
...this.list.length <= 0 ? this.newCalibrationFuncModel : [], // list C to E 20231101xiao
sampleFileName: this.newSampleData.inputFileName,
tabName: "beta",
// 20231028Xiao
tempPoints: this.list.length > 0
? this.list.map((item) => ({ x: item.channel, y: item.energy }))
@ -891,10 +909,25 @@ export default {
count: this.isFirstFitting || !this.isInverse ? undefined : this.count,
})
if (success) {
this.isFirstFitting = false
// this.isFirstFitting = false
this.betaIsFitting = true
this.$emit('isFitting', this.betaIsFitting)
this.$emit('isFitting', true) // reAnalyzeisFirstFittingtrue 20231101xiao
this.setCache("calibration-beta:"+this.newSampleData.inputFileName, result) // ReAnalyze 20231101xiao
this.setFirringResult(result)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
// fittingReAnalyze 20231101xiao
setFirringResult(result){
const { EToC, newLineSeries, newScatterSeriesData, tableWidgets, CToE } = result
this.newE2C = EToC
this.newLineSeries = newLineSeries
@ -934,12 +967,6 @@ export default {
}
})
}
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
// Figure Chart
@ -985,6 +1012,15 @@ export default {
}
return 0
},
getCache(name){
return this.$ls.get(name)
},
setCache(name, data){
this.$ls.set(name, data)
},
removeCache(name){
this.$ls.remove(name) // fitting 20231101:xiao
}
},
computed: {
rectHeight() {

View File

@ -435,6 +435,12 @@ const newCalibrationFuncModel = {
export default {
mixins: [SampleDataMixin],
components: { CustomChart, TitleOverBorder },
props: {
isFirstFitting: {
type: Boolean,
required: false,
},
},
data() {
this.columns = columns
@ -466,7 +472,7 @@ export default {
recalculateROICountsFor: [],
count: 0, // tableWidgets
isFirstFitting: true,
// isFirstFitting: true,
isInverse: false, //
gammaIsFitting: false,
}
@ -480,12 +486,16 @@ export default {
},
async getData() {
const { sampleId = '', qcFileName } = this.newSampleData
console.log("isFirstFitting>>>"+this.isFirstFitting);
// sampleFileName 20231101xiao
const { sampleId = '', qcFileName, sampleFileName = inputFileName } = this.newSampleData
try {
this.isLoading = true
const res = await getAction('/spectrumAnalysis/viewGammaDetectorCalibration', {
sampleId,
qcFileName,
sampleFileName
})
if (res.success) {
@ -495,7 +505,7 @@ export default {
this.e2c = EToC
this.oldScatterSeries = oldScatterSeries
this.count = oldScatterSeries.length
this.isFirstFitting = true
// this.isFirstFitting = true
const { max: _max, min: _min, interval: _interval } = splitAxis(max, min, 4)
@ -519,6 +529,13 @@ export default {
this.figureChartOption.series[0].markPoint.data = oldScatterSeries.map(({ x, y }) => ({ xAxis: x, yAxis: y }))
this.oldChartOption = cloneDeep(this.figureChartOption)
// reanalyzefittingReanalyze 20231101xiao
// todo fitting
if(this.getCache("calibration-gamma:"+this.newSampleData.inputFileName)) {
this.setFirringResult(this.getCache("calibration-gamma:"+this.newSampleData.inputFileName))
return false;
}
} else {
this.$message.error(res.message)
}
@ -640,12 +657,13 @@ export default {
// Reset Button
handleReset() {
this.$ls.remove("calibration-gamma:"+this.newSampleData.inputFileName) // fitting 20231101:xiao
this.newCalibrationFuncModel = cloneDeep(newCalibrationFuncModel)
this.list = []
this.newE2C = []
this.figureChartOption = cloneDeep(this.oldChartOption)
this.isFirstFitting = true
this.isFirstFitting = false
this.isInverse = false
},
@ -657,8 +675,10 @@ export default {
}
try {
const { success, result, message } = await postAction('/spectrumAnalysis/fitting', {
...this.newCalibrationFuncModel,
// 20231028Xiao
...this.list.length <= 0 ? this.newCalibrationFuncModel : [], // list C to E 20231101xiao
sampleFileName: this.newSampleData.inputFileName,
tabName: "gamma",
// 20231028Xiao
tempPoints: this.list.length > 0
? this.list.map((item) => ({ x: item.channel, y: item.energy }))
: this.oldScatterSeries,
@ -669,10 +689,24 @@ export default {
count: this.isFirstFitting || !this.isInverse ? undefined : this.count,
})
if (success) {
this.isFirstFitting = false
// this.isFirstFitting = true
this.gammaIsFitting = false
this.$emit('isFitting', this.gammaIsFitting)
this.$emit('isFitting', true) // reAnalyzeisFirstFittingtrue 20231101xiao
this.setCache("calibration-gamma:"+this.newSampleData.inputFileName, result) // ReAnalyze 20231101xiao
this.setFirringResult(result)
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
// fittingReAnalyze 20231101xiao
setFirringResult(result){
const { EToC, newLineSeries, newScatterSeriesData, tableWidgets, CToE } = result
this.newE2C = EToC
this.newLineSeries = newLineSeries
@ -689,7 +723,6 @@ export default {
paramC: Number(paramC).toPrecision(6),
}
}
const energyValues = newLineSeries.map((item) => item.y)
const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
@ -710,12 +743,6 @@ export default {
yAxis: y,
}))
}
} else {
this.$message.error(message)
}
} catch (error) {
console.error(error)
}
},
// Figure Chart
@ -761,6 +788,15 @@ export default {
}
return 0
},
getCache(name){
return this.$ls.get(name)
},
setCache(name, data){
this.$ls.set(name, data)
},
removeCache(name){
this.$ls.remove(name) // fitting 20231101:xiao
}
},
}
</script>

View File

@ -6,10 +6,11 @@
class="beta-gamma-tool-of-calibration"
:footer="null"
destroy-on-close
@cancel="handleExit"
>
<a-tabs :animated="false" v-model="currTab">
<a-tab-pane tab="Gamma Detector Calibration" key="gamma">
<gamma-detector-calibration @isFitting="getFittingFlag_gamma" />
<gamma-detector-calibration @isFitting="getFittingFlag_gamma" :isFirstFitting="gammaEnergyValid"/>
</a-tab-pane>
<a-tab-pane tab="Beta Detector Calibration" key="beta">
<beta-detector-calibration @isFitting="getFittingFlag_beta" />
@ -69,7 +70,8 @@ export default {
checkDet: false,
},
betaEnergyValid: false,
gammaEnergyValid: true,
gammaEnergyValid: false,
isReanlyze: false
}
},
methods: {
@ -88,9 +90,15 @@ export default {
this.betaEnergyValid = val
},
getFittingFlag_gamma(val) {
console.log("zhiqian>>>"+this.gammaEnergyValid);
this.gammaEnergyValid = val
console.log("zhihou>>>"+this.gammaEnergyValid);
},
handleReAnalyse() {
// todo 1.fitting; 2.isReAnalyze
if(!this.gammaEnergyValid){
return false;
}
const regExp = /^([A-Z]{1,}\d{1,})_/
const regMatched = this.newSampleData.inputFileName.match(regExp)
const currStationName = regMatched[1]
@ -140,13 +148,19 @@ export default {
})
this.$emit('sendXeData', res.result.XeData)
this.$message.success('Analyse Success!')
this.visible = false
this.isReanlyze = true
this.handleExit()
} else {
this.$message.warning(res.message)
}
})
},
handleExit() {
this.gammaEnergyValid = this.isReanlyze
console.log("exit>>>this.isReanlyze>>>"+this.isReanlyze);
if(!this.isReanlyze && this.$ls.get("calibration-gamma:"+this.newSampleData.inputFileName)){
this.$ls.remove("calibration-gamma:"+this.newSampleData.inputFileName) // ReANalyzefitting 20231101:xiao
}
this.visible = false
},
},