diff --git a/src/utils/file.js b/src/utils/file.js index 88867ca..f5bcc69 100644 --- a/src/utils/file.js +++ b/src/utils/file.js @@ -1,6 +1,11 @@ import { Modal } from 'ant-design-vue' import { saveAs } from 'file-saver' import JSZip from 'jszip' +import Vue from 'vue' +import signMd5Utils from '@/utils/encryption/signMd5Utils' +import Axios from 'axios' +import { ACCESS_TOKEN, TENANT_ID } from '@/store/mutation-types' +import { message } from 'ant-design-vue' /** * 弹窗填入文件名保存文件 @@ -85,3 +90,52 @@ export const zipFile = async (fileList, zipName) => { const content = await zip.generateAsync({ type: 'blob' }) return new File([content], zipName, { type: content.type }) } + +/** + * 根据响应头获取文件名 + * @param {String} contentDisposition + */ +export function getFileNameByHeaderContentDisposition(contentDisposition) { + const patt = new RegExp('file[Nn]ame=([^;]+\\.[^\\.;]+);*') + contentDisposition = decodeURI(contentDisposition) + const result = patt.exec(contentDisposition) + let fileName = result[1] + fileName = fileName.replace(/"/g, '') + return fileName +} + +export const fetchAndDownload = async (url, data) => { + const apiBaseUrl = window._CONFIG['domianURL'] || '/jeecg-boot' + const sign = signMd5Utils.getSign(url, data) + const response = await Axios({ + baseURL: apiBaseUrl, + method: 'post', + url, + data: data, + headers: { + 'X-Sign': sign, + 'X-TIMESTAMP': signMd5Utils.getTimestamp(), + 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN), + 'tenant-id': Vue.ls.get(TENANT_ID) + } + }) + const { status, headers, data: responseData } = response + if (status == 200) { + if (typeof responseData == 'object') { + const { message: msg } = responseData + message.error(msg) + throw new Error(msg) + } else { + const disposition = headers['content-disposition'] + const fileName = getFileNameByHeaderContentDisposition(disposition) + if (typeof responseData == 'string') { + const blob = new Blob([responseData], { type: headers['content-type'] }) + saveAs(blob, fileName) + return fileName + } + } + } else { + message.error('This operation fails. Contact your system administrator') + throw new Error('This operation fails. Contact your system administrator') + } +} diff --git a/src/views/spectrumAnalysis/clearSampleCache.js b/src/views/spectrumAnalysis/clearSampleCache.js new file mode 100644 index 0000000..f5a8de3 --- /dev/null +++ b/src/views/spectrumAnalysis/clearSampleCache.js @@ -0,0 +1,17 @@ +import { deleteAction } from '@/api/manage' +/** + * 发起请求清理后端对sample的缓存 + * @param {Array} sampleList + */ +export const clearSampleCache = (sampleList) => { + sampleList.forEach(sample => { + const { inputFileName: fileName, sampleFileName, qcFileName } = sample + let url = '/gamma/delPHDCache', + params = { fileName } + if (sample.sampleType == 'B') { + url = '/spectrumAnalysis/deleteSpectrumCacheData' + params = { sampleFileName , qcFileName } + } + deleteAction(url, params) + }) +} \ No newline at end of file diff --git a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue index 0777afb..7140185 100644 --- a/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/BetaGammaModals/BetaGammaExtrapolationModal.vue @@ -51,7 +51,7 @@ class="custom-tool-tip" :style="{ top: customToolTip.top + 'px', - left: customToolTip.left + 'px' + left: customToolTip.left + 'px', }" >
Channel: {{ customToolTip.channel }}
@@ -62,7 +62,7 @@ class="custom-tool-tip" :style="{ top: customToolTip2.top + 'px', - left: customToolTip2.left + 'px' + left: customToolTip2.left + 'px', }" >
Channel: {{ customToolTip2.channel }}
@@ -89,10 +89,18 @@
Gamma Window Setting
Gamma Window Begin:
- + Channel
Gamma Window End:
- + Channel
@@ -100,9 +108,19 @@
Parameter Setting
Min of Energy:
- keV + + keV
Half Life:
- Day + + Day
@@ -137,7 +155,7 @@ > @@ -196,7 +214,7 @@ import { getAction, postAction } from '@/api/manage' import { useBaseChartSetting } from '../../../useChart' import TitleOverBorder from '../../TitleOverBorder.vue' import SampleDataMixin from '@/views/spectrumAnalysis/SampleDataMixin' -import { isNullOrUndefined } from '@/utils/util' +import { isNumber } from 'xe-utils/methods' const initialGammaChartOption = { grid: { @@ -204,7 +222,7 @@ const initialGammaChartOption = { right: 15, bottom: 10, left: 10, - containLabel: true + containLabel: true, }, xAxis: { min: 0, @@ -212,21 +230,21 @@ const initialGammaChartOption = { interval: 64, axisLine: { lineStyle: { - color: 'rgb(119, 181, 213, 0.5)' - } + color: 'rgb(119, 181, 213, 0.5)', + }, }, splitLine: { show: true, lineStyle: { - color: 'rgba(119, 181, 213, .2)' - } + color: 'rgba(119, 181, 213, .2)', + }, }, axisTick: { - show: false + show: false, }, axisLabel: { - color: '#ade6ee' - } + color: '#ade6ee', + }, }, yAxis: { min: 0, @@ -235,57 +253,57 @@ const initialGammaChartOption = { axisLine: { show: true, lineStyle: { - color: 'rgb(119, 181, 213, 0.5)' - } + color: 'rgb(119, 181, 213, 0.5)', + }, }, splitLine: { show: true, lineStyle: { - color: 'rgba(119, 181, 213, .2)' - } + color: 'rgba(119, 181, 213, .2)', + }, }, axisTick: { - show: false + show: false, }, axisLabel: { - color: '#ade6ee' + color: '#ade6ee', }, - animation: false + animation: false, }, series: [ { type: 'line', itemStyle: { - color: '#04ADD9' + color: '#04ADD9', }, symbol: 'none', data: [], markLine: { symbol: 'none', label: { - show: false + show: false, }, animation: false, emphasis: { - disabled: true + disabled: true, }, lineStyle: { - color: '#f00' + color: '#f00', }, - data: [{ xAxis: -1 }, { xAxis: -1 }] + data: [{ xAxis: -1 }, { xAxis: -1 }], }, - animation: false + animation: false, }, { type: 'line', itemStyle: { - color: '#A8DA56' + color: '#A8DA56', }, symbol: 'none', data: [], - animation: false - } - ] + animation: false, + }, + ], } const initialBetaChartOption = { @@ -294,7 +312,7 @@ const initialBetaChartOption = { right: 15, bottom: 10, left: 10, - containLabel: true + containLabel: true, }, xAxis: { min: 0, @@ -302,21 +320,21 @@ const initialBetaChartOption = { interval: 64, axisLine: { lineStyle: { - color: 'rgb(119, 181, 213, 0.5)' - } + color: 'rgb(119, 181, 213, 0.5)', + }, }, splitLine: { show: true, lineStyle: { - color: 'rgba(119, 181, 213, .2)' - } + color: 'rgba(119, 181, 213, .2)', + }, }, axisTick: { - show: false + show: false, }, axisLabel: { - color: '#ade6ee' - } + color: '#ade6ee', + }, }, yAxis: { min: 0, @@ -325,57 +343,57 @@ const initialBetaChartOption = { axisLine: { show: true, lineStyle: { - color: 'rgb(119, 181, 213, 0.5)' - } + color: 'rgb(119, 181, 213, 0.5)', + }, }, splitLine: { show: true, lineStyle: { - color: 'rgba(119, 181, 213, .2)' - } + color: 'rgba(119, 181, 213, .2)', + }, }, axisTick: { - show: false + show: false, }, axisLabel: { - color: '#ade6ee' + color: '#ade6ee', }, - animation: false + animation: false, }, series: [ { type: 'line', itemStyle: { - color: '#04ADD9' + color: '#04ADD9', }, symbol: 'none', data: [], markLine: { symbol: 'none', label: { - show: false + show: false, }, animation: false, emphasis: { - disabled: true + disabled: true, }, lineStyle: { - color: '#f00' + color: '#f00', }, - data: [] + data: [], }, - animation: false + animation: false, }, { type: 'line', itemStyle: { - color: '#A8DA56' + color: '#A8DA56', }, symbol: 'none', data: [], - animation: false - } - ] + animation: false, + }, + ], } const initialResultChartOption = { @@ -384,23 +402,23 @@ const initialResultChartOption = { { type: 'line', itemStyle: { - color: '#04ADD9' + color: '#04ADD9', }, symbol: 'none', data: [], - animation: false + animation: false, }, { type: 'scatter', itemStyle: { - color: 'red' + color: 'red', }, symbolSize: 6, data: [], zlevel: 2, - animation: false - } - ] + animation: false, + }, + ], } initialResultChartOption.yAxis.boundaryGap = ['20%', '20%'] @@ -411,30 +429,30 @@ const columns = [ customRender: (_, __, index) => { return index + 1 }, - align: 'center' + align: 'center', }, { title: 'Eb', dataIndex: 'eb', - align: 'center' + align: 'center', }, { title: 'Nx', dataIndex: 'nx', - align: 'center' + align: 'center', }, { title: 'Ny', dataIndex: 'ny', - align: 'center' + align: 'center', }, { title: 'Delete', scopedSlots: { - customRender: 'delete' + customRender: 'delete', }, - align: 'center' - } + align: 'center', + }, ] const initialModel = { @@ -442,20 +460,20 @@ const initialModel = { windowEnd: undefined, minEnergy: 0.1, halfLife: 5.243, - fitType: 'liner' + fitType: 'liner', } // Function of Fitting const funcList = { liner: 'y = ax + b', - poly2: 'y = axx + bx + c' + poly2: 'y = axx + bx + c', } export default { mixins: [ModalMixin, SampleDataMixin], components: { CustomChart, - TitleOverBorder + TitleOverBorder, }, data() { this.columns = columns @@ -469,14 +487,14 @@ export default { left: 0, visible: false, channel: '', - energy: '' + energy: '', }, customToolTip2: { top: 0, left: 0, visible: false, channel: '', - energy: '' + energy: '', }, totalCount: [0, 0], @@ -490,7 +508,7 @@ export default { model: cloneDeep(initialModel), tableList: [], - isAnalysing: false + isAnalysing: false, } }, methods: { @@ -502,7 +520,7 @@ export default { this.resultChartOption = cloneDeep(initialResultChartOption) this.model = cloneDeep(initialModel) - this.currFunction = funcList[this.model.fitType] + this.handleFuncChange() this.tableList = [] this.calculateTotalCount() @@ -516,7 +534,7 @@ export default { const { sampleId, inputFileName: sampleFileName } = this.sampleData const { success, result, message } = await getAction('/spectrumAnalysis/viewExtrapolation', { sampleId, - sampleFileName + sampleFileName, }) if (success) { this.detail = result @@ -526,7 +544,7 @@ export default { betaProjectedSeriseData, gammaChannelEnergy, gammaOriginSeriseData, - gammaProjectedSeriseData + gammaProjectedSeriseData, } = result this.gammaChannelEnergy = gammaChannelEnergy @@ -579,8 +597,8 @@ export default { // 如果是左键 if (isMouseLeft) { // 如果有右值且左值大于等于右值,清空 - if (!isNullOrUndefined(this.model.windowEnd) && xAxis >= this.model.windowEnd) { - this.clearMarkLineAndToolTip() + if (!isNumber(this.model.windowEnd) && xAxis >= this.model.windowEnd) { + this.reset() return } @@ -591,8 +609,8 @@ export default { } // 如果是右键 else { - if (!isNullOrUndefined(this.model.windowBegin) && xAxis <= this.model.windowBegin) { - this.clearMarkLineAndToolTip() + if (!isNumber(this.model.windowBegin) && xAxis <= this.model.windowBegin) { + this.reset() return } @@ -612,10 +630,11 @@ export default { currToolTip.energy = parseInt(energy) + 'keV' this.calculateTotalCount() + this.getTableAndChartData() } }, - clearMarkLineAndToolTip() { + reset() { const markLineData = this.gammaSpectrumChartOption.series[0].markLine.data markLineData[0].xAxis = -1 markLineData[1].xAxis = -1 @@ -626,12 +645,18 @@ export default { this.model.windowBegin = null this.model.windowEnd = null + this.tableList = [] + const [lineSeries, scatterSeries] = this.resultChartOption.series + lineSeries.data = [] + scatterSeries.data = [] + this.calculateTotalCount() }, // 计算Total Count calculateTotalCount() { - if (!this.model.windowBegin || !this.model.windowEnd || this.model.windowBegin >= this.model.windowEnd) { + const { windowBegin, windowEnd } = this.model + if (!isNumber(windowBegin) || !isNumber(windowEnd) || windowBegin >= windowEnd) { this.totalCount = [0, 0] return } @@ -658,56 +683,96 @@ export default { exportEchartImg(this.$refs.chartRef.getChartInstance()) }, - // 分析 - async handleAnalyse() { + handleGammaWindowSettingChange() { + this.calculateTotalCount() + this.getTableAndChartData() + }, + + handleParameterSettingChange() { + this.getTableAndChartData() + }, + + /** + * 获取表格和图表数据 + */ + async getTableAndChartData() { const { windowBegin, windowEnd, minEnergy, halfLife, fitType } = this.model - if ( - isNullOrUndefined(windowBegin) || - isNullOrUndefined(windowEnd) || - isNullOrUndefined(minEnergy) || - isNullOrUndefined(halfLife) - ) { + const [lineSeries, scatterSeries] = this.resultChartOption.series + lineSeries.data = [] + + if (!this.validateSettingValue()) { + scatterSeries.data = [] + this.tableList = [] return } - try { - const { sampleFileName, detFileName } = this.sampleData + const { sampleId, dbName, sampleFileName, detFileName } = this.sampleData + try { const params = { - sampleId: null, - dbName: '', + sampleId, + dbName, sampleFileName, detFileName, gammaBegin: windowBegin, gammaEnd: windowEnd, minEnergy, halfLife, - fitType //选择Linear 传 liner 选择2-Polynomial 传 poly2 + fitType, //选择Linear 传 liner 选择2-Polynomial 传 poly2 } + const { success, result, message } = await postAction('/spectrumAnalysis/changeDataExtrapolation', params) + if (success) { + const { resultViewScatterDataValue, tableData } = result + scatterSeries.data = resultViewScatterDataValue.map(({ x, y }) => [x, y]) + this.resetResultChartPerform() + + this.tableList = tableData + } else { + this.$message.error(message) + } + } catch (error) { + console.error(error) + } + }, + + // 分析 + async handleAnalyse() { + const { minEnergy, halfLife, fitType } = this.model + if (!this.validateSettingValue()) { + return + } + try { + const { acquisitionRealTime: acqRealTime, acquisitionStart: acqStartTime } = this.detail + + const params = { + eb: this.tableList.map(({ eb }) => eb), + nx: this.tableList.map(({ nx }) => nx), + ny: this.tableList.map(({ ny }) => ny), + acqRealTime, + minEnergy, + halfLife, + acqStartTime, + fitType, + } + this.isAnalysing = true const { success, result, message } = await postAction('/spectrumAnalysis/analyseExtrapolation', params) if (success) { - console.log('%c [ ]-679', 'font-size:13px; background:pink; color:#bf2c9f;', result) const { functionFit, // Function of Fitting resultViewLineDataValue, // 折线 - resultViewScatterDataValue, // 原点 - tableData, // 表格数据 - xeAct + xeAct, } = result this.currFunction = functionFit - const [lineSeries, scatterSeries] = this.resultChartOption.series + const [lineSeries] = this.resultChartOption.series lineSeries.data = resultViewLineDataValue.map(({ x, y }) => [x, y]) - scatterSeries.data = resultViewScatterDataValue.map(({ x, y }) => [x, y]) this.resetResultChartPerform() this.xeActivity = { referenceTime: this.detail.acquisitionStart, - activity: Number.isNaN(xeAct)? xeAct: Number(xeAct).toPrecision(6) + activity: Number.isNaN(xeAct) ? xeAct : Number(xeAct).toPrecision(6), } - - this.tableList = tableData } else { this.$message.error(message) } @@ -718,6 +783,18 @@ export default { } }, + validateSettingValue() { + const { windowBegin, windowEnd, minEnergy, halfLife } = this.model + if (!isNumber(windowBegin) || !isNumber(windowEnd) || !isNumber(minEnergy) || !isNumber(halfLife)) { + return false + } + + return true + }, + + /** + * 图表最大值、最小值等设为按实际情况取值 + */ resetResultChartPerform() { this.resultChartOption.yAxis.min = undefined this.resultChartOption.yAxis.max = undefined @@ -731,8 +808,8 @@ export default { handleDel(index) { this.tableList.splice(index, 1) this.resultChartOption.series[1].data.splice(index, 1) - } - } + }, + }, } diff --git a/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcCanberraIecTransfer.vue b/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcCanberraIecTransfer.vue index 68d9e79..3dc449b 100644 --- a/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcCanberraIecTransfer.vue +++ b/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcCanberraIecTransfer.vue @@ -1,11 +1,7 @@ diff --git a/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcImsTransfer.vue b/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcImsTransfer.vue index 5a2ff6a..00e85b4 100644 --- a/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcImsTransfer.vue +++ b/src/views/spectrumAnalysis/components/Modals/FtransltModal/components/IntSpcImsTransfer.vue @@ -3,10 +3,10 @@
- + - + @@ -14,7 +14,7 @@ show-time format="YYYY/MM/DD HH:mm:ss" valueFormat="YYYY/MM/DD HH:mm:ss" - v-model="intSpacImsParams.startTime" + v-model="params.collect_start" /> @@ -22,12 +22,12 @@ show-time format="YYYY/MM/DD HH:mm:ss" valueFormat="YYYY/MM/DD HH:mm:ss" - v-model="intSpacImsParams.stopTime" + v-model="params.collect_stop" />

Total air volume sampled

- +
@@ -35,43 +35,43 @@
- + Designator
- +
- + Station code
- +
- + Detector code
- +
- + Sample geometry
- +
- + P G B - + PREL FULL @@ -80,44 +80,27 @@

Sample reference identification

- +

Background measurement identification

- +
- Transmit time + Transmit time
-
-
- -
ORTEC int.spc
-
-
-
- Data type -
- -
-
-
- -
IMS .ims .rms
-
-
-
- +
@@ -125,50 +108,58 @@ + + \ No newline at end of file diff --git a/src/views/spectrumAnalysis/components/Modals/FtransltModal/index.vue b/src/views/spectrumAnalysis/components/Modals/FtransltModal/index.vue index 9323783..7f5a87b 100644 --- a/src/views/spectrumAnalysis/components/Modals/FtransltModal/index.vue +++ b/src/views/spectrumAnalysis/components/Modals/FtransltModal/index.vue @@ -1,5 +1,5 @@