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 { export default {
mixins: [SampleDataMixin], mixins: [SampleDataMixin],
components: { CustomChart, TitleOverBorder }, components: { CustomChart, TitleOverBorder },
props: {
isFirstFitting: {
type: Boolean,
required: false,
},
},
data() { data() {
this.columns = columns this.columns = columns
@ -594,7 +600,7 @@ export default {
recalculateROICountsFor: [], recalculateROICountsFor: [],
count: 0, // tableWidgets count: 0, // tableWidgets
isFirstFitting: true, // isFirstFitting: true,
isInverse: false, // isInverse: false, //
betaIsFitting: false, betaIsFitting: false,
} }
@ -608,12 +614,14 @@ export default {
}, },
async getData() { async getData() {
const { sampleId = '', qcFileName } = this.newSampleData // sampleFileName 20231101xiao
const { sampleId = '', qcFileName, sampleFileName = inputFileName } = this.newSampleData
try { try {
this.isLoading = true this.isLoading = true
const res = await getAction('/spectrumAnalysis/viewBetaDetectorCalibration', { const res = await getAction('/spectrumAnalysis/viewBetaDetectorCalibration', {
sampleId, sampleId,
qcFileName, qcFileName,
sampleFileName
}) })
if (res.success) { if (res.success) {
const { CToE, EToC, betaEnergy, gammaEnergy, gammaGatedBetaSpectrum, histogramData, oldScatterSeries } = const { CToE, EToC, betaEnergy, gammaEnergy, gammaGatedBetaSpectrum, histogramData, oldScatterSeries } =
@ -623,7 +631,7 @@ export default {
this.oldScatterSeries = oldScatterSeries this.oldScatterSeries = oldScatterSeries
this.count = oldScatterSeries.length this.count = oldScatterSeries.length
this.isFirstFitting = true // this.isFirstFitting = true
this.betaGammaChartOption.series.data = histogramData.map(({ b, g, c }) => [b, g, c]) this.betaGammaChartOption.series.data = histogramData.map(({ b, g, c }) => [b, g, c])
this.gammaEnergy = gammaEnergy this.gammaEnergy = gammaEnergy
@ -644,6 +652,13 @@ export default {
this.figureChartOption.series[0].markPoint.data = oldScatterSeries.map(({ x, y }) => ({ xAxis: x, yAxis: y })) this.figureChartOption.series[0].markPoint.data = oldScatterSeries.map(({ x, y }) => ({ xAxis: x, yAxis: y }))
this.oldChartOption = cloneDeep(this.figureChartOption) 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 { } else {
this.$message.error(res.message) this.$message.error(res.message)
} }
@ -861,6 +876,7 @@ export default {
// Reset Button // Reset Button
handleReset() { handleReset() {
this.removeCache("calibration-beta:"+this.newSampleData.inputFileName) // fitting 20231101:xiao
this.newCalibrationFuncModel = cloneDeep(newCalibrationFuncModel) this.newCalibrationFuncModel = cloneDeep(newCalibrationFuncModel)
this.list = [] this.list = []
this.newE2C = [] this.newE2C = []
@ -880,7 +896,9 @@ export default {
} }
try { try {
const { success, result, message } = await postAction('/spectrumAnalysis/fitting', { 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 // 20231028Xiao
tempPoints: this.list.length > 0 tempPoints: this.list.length > 0
? this.list.map((item) => ({ x: item.channel, y: item.energy })) ? this.list.map((item) => ({ x: item.channel, y: item.energy }))
@ -891,49 +909,15 @@ export default {
count: this.isFirstFitting || !this.isInverse ? undefined : this.count, count: this.isFirstFitting || !this.isInverse ? undefined : this.count,
}) })
if (success) { if (success) {
this.isFirstFitting = false // this.isFirstFitting = false
this.betaIsFitting = true this.betaIsFitting = true
this.$emit('isFitting', this.betaIsFitting) this.$emit('isFitting', true) // reAnalyzeisFirstFittingtrue 20231101xiao
const { EToC, newLineSeries, newScatterSeriesData, tableWidgets, CToE } = result this.setCache("calibration-beta:"+this.newSampleData.inputFileName, result) // ReAnalyze 20231101xiao
this.newE2C = EToC
this.newLineSeries = newLineSeries
if (tableWidgets) { this.setFirringResult(result)
this.list = tableWidgets
}
// C to E
if (CToE) {
const [paramA, paramB, paramC] = CToE
this.newCalibrationFuncModel = {
paramA: Number(paramA).toPrecision(6),
paramB: Number(paramB).toPrecision(6),
paramC: Number(paramC).toPrecision(6),
}
}
const energyValues = newLineSeries.map((item) => item.y)
const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
const energyMax = Math.max(Math.max(...energyValues), prevMax)
const energyMin = Math.min(Math.min(...energyValues), prevMin)
const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
this.figureChartOption.yAxis.max = max
this.figureChartOption.yAxis.min = min
this.figureChartOption.yAxis.interval = interval
this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
if (newScatterSeriesData) {
this.figureChartOption.series[1].markPoint.data = newScatterSeriesData.map(({ x, y }) => {
return {
xAxis: x,
yAxis: y,
}
})
}
} else { } else {
this.$message.error(message) this.$message.error(message)
} }
@ -942,6 +926,49 @@ export default {
} }
}, },
// fittingReAnalyze 20231101xiao
setFirringResult(result){
const { EToC, newLineSeries, newScatterSeriesData, tableWidgets, CToE } = result
this.newE2C = EToC
this.newLineSeries = newLineSeries
if (tableWidgets) {
this.list = tableWidgets
}
// C to E
if (CToE) {
const [paramA, paramB, paramC] = CToE
this.newCalibrationFuncModel = {
paramA: Number(paramA).toPrecision(6),
paramB: Number(paramB).toPrecision(6),
paramC: Number(paramC).toPrecision(6),
}
}
const energyValues = newLineSeries.map((item) => item.y)
const { max: prevMax, min: prevMin } = this.oldChartOption.yAxis
const energyMax = Math.max(Math.max(...energyValues), prevMax)
const energyMin = Math.min(Math.min(...energyValues), prevMin)
const { min, max, interval } = splitAxis(energyMax, energyMin, 4)
this.figureChartOption.yAxis.max = max
this.figureChartOption.yAxis.min = min
this.figureChartOption.yAxis.interval = interval
this.figureChartOption.series[1].data = newLineSeries.map(({ x, y }) => [x, y])
if (newScatterSeriesData) {
this.figureChartOption.series[1].markPoint.data = newScatterSeriesData.map(({ x, y }) => {
return {
xAxis: x,
yAxis: y,
}
})
}
},
// Figure Chart // Figure Chart
getFigureChartMaxAndMin() { getFigureChartMaxAndMin() {
const [series0, series1] = this.figureChartOption.series const [series0, series1] = this.figureChartOption.series
@ -985,6 +1012,15 @@ export default {
} }
return 0 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: { computed: {
rectHeight() { rectHeight() {

View File

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

View File

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