fix: 修复PHDParser 对异形文件名解析问题
This commit is contained in:
parent
88348f4f78
commit
d31a12b8e4
|
@ -17,6 +17,21 @@ export const isSample = dataType => {
|
||||||
return ['SAMPLEPHD', 'SPHDP', 'SPHDF'].includes(dataType)
|
return ['SAMPLEPHD', 'SPHDP', 'SPHDF'].includes(dataType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getSampleTypeIdentify = dataType => {
|
||||||
|
if(isSample(dataType)) {
|
||||||
|
return 'S'
|
||||||
|
} else {
|
||||||
|
switch (dataType) {
|
||||||
|
case PHD_DATA_TYPE.QCPHD:
|
||||||
|
return 'Q'
|
||||||
|
case PHD_DATA_TYPE.DETBKPHD:
|
||||||
|
return 'D'
|
||||||
|
case PHD_DATA_TYPE.GASBKPHD:
|
||||||
|
return 'G'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class PHDParser {
|
export class PHDParser {
|
||||||
/**
|
/**
|
||||||
* 根据Block解析出的结果集
|
* 根据Block解析出的结果集
|
||||||
|
@ -75,8 +90,8 @@ export class PHDParser {
|
||||||
this.fileType = headerInfoLine1[2]
|
this.fileType = headerInfoLine1[2]
|
||||||
this.qualify = headerInfoLine1[4]
|
this.qualify = headerInfoLine1[4]
|
||||||
|
|
||||||
const liveTime = parseFloat(this.getBlockStr('Acquisition', 0, 3)).toFixed(1)
|
const liveTime = parseFloat(this.getBlockStr('Acquisition', 0, 3))
|
||||||
this.liveTime = liveTime.indexOf('.0') == -1 ? liveTime : liveTime.slice(0, -2)
|
this.liveTime = parseFloat(liveTime.toPrecision(6))
|
||||||
|
|
||||||
// 如果解析的是sample 文件,则解析相关联的文件
|
// 如果解析的是sample 文件,则解析相关联的文件
|
||||||
if (this.isSample) {
|
if (this.isSample) {
|
||||||
|
@ -87,6 +102,9 @@ export class PHDParser {
|
||||||
} else {
|
} else {
|
||||||
this.sampleFilePrefix = this.getGammaFilePrefix(headerInfo[2])
|
this.sampleFilePrefix = this.getGammaFilePrefix(headerInfo[2])
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const filePrefixes = this.getFilePrefixes(headerInfo[2])
|
||||||
|
this.sampleFilePrefix = filePrefixes.splice(0, 1)[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,10 @@ import Vue from 'vue'
|
||||||
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
import { ACCESS_TOKEN } from '@/store/mutation-types'
|
||||||
import StripModal from './components/Modals/StripModal.vue'
|
import StripModal from './components/Modals/StripModal.vue'
|
||||||
import { FilePicker } from '@/utils/FilePicker'
|
import { FilePicker } from '@/utils/FilePicker'
|
||||||
import { zipFile } from '@/utils/file'
|
import { readFile, zipFile } from '@/utils/file'
|
||||||
import { findNearPeak } from '@/utils/sampleHelper'
|
import { findNearPeak } from '@/utils/sampleHelper'
|
||||||
import { add, subtract } from 'xe-utils/methods'
|
import { add, subtract } from 'xe-utils/methods'
|
||||||
|
import { PHDParser, isSample, getSampleTypeIdentify } from '@/utils/phdHelper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
|
@ -1372,7 +1373,7 @@ export default {
|
||||||
DetailedInformation: this.detailedInfomation,
|
DetailedInformation: this.detailedInfomation,
|
||||||
QCFlag: this.qcFlags,
|
QCFlag: this.qcFlags,
|
||||||
BaseCtrls: this.baseCtrls,
|
BaseCtrls: this.baseCtrls,
|
||||||
bAnalyed: this.bAnalyed
|
bAnalyed: this.bAnalyed,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.clearCompareLine()
|
this.clearCompareLine()
|
||||||
|
@ -1382,7 +1383,16 @@ export default {
|
||||||
|
|
||||||
// 分析工具Accept时刷新部分数据
|
// 分析工具Accept时刷新部分数据
|
||||||
handleAccept(data) {
|
handleAccept(data) {
|
||||||
const { allData, peak, shadowChannelChart, shadowEnergyChart, shapeChannelData, shapeEnergyData, barChart, BaseCtrls } = data
|
const {
|
||||||
|
allData,
|
||||||
|
peak,
|
||||||
|
shadowChannelChart,
|
||||||
|
shadowEnergyChart,
|
||||||
|
shapeChannelData,
|
||||||
|
shapeEnergyData,
|
||||||
|
barChart,
|
||||||
|
BaseCtrls,
|
||||||
|
} = data
|
||||||
|
|
||||||
const result = {
|
const result = {
|
||||||
DetailedInformation: this.detailedInfomation,
|
DetailedInformation: this.detailedInfomation,
|
||||||
|
@ -1395,7 +1405,7 @@ export default {
|
||||||
peak,
|
peak,
|
||||||
BaseCtrls,
|
BaseCtrls,
|
||||||
bAnalyed: this.bAnalyed,
|
bAnalyed: this.bAnalyed,
|
||||||
barChart
|
barChart,
|
||||||
}
|
}
|
||||||
this.clearCompareLine()
|
this.clearCompareLine()
|
||||||
this.redrawPeakLine()
|
this.redrawPeakLine()
|
||||||
|
@ -1423,18 +1433,26 @@ export default {
|
||||||
try {
|
try {
|
||||||
const [fileHandle] = await FilePicker.chooseFile(false, [{ accept: { 'text/phd': ['.phd'] } }])
|
const [fileHandle] = await FilePicker.chooseFile(false, [{ accept: { 'text/phd': ['.phd'] } }])
|
||||||
const file = await fileHandle.getFile()
|
const file = await fileHandle.getFile()
|
||||||
|
const text = await readFile(file)
|
||||||
|
const parser = new PHDParser(text)
|
||||||
|
const { sampleFilePrefix, qualify, dataType, liveTime } = parser
|
||||||
|
|
||||||
|
const hide = this.$message.loading('Uploading...', 0)
|
||||||
|
|
||||||
const zipedFiles = await zipFile([file], 'test.zip')
|
const zipedFiles = await zipFile([file], 'test.zip')
|
||||||
try {
|
try {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', zipedFiles)
|
formData.append('file', zipedFiles)
|
||||||
const { success, message } = await postAction('/spectrumFile/upload', formData)
|
const { success, message } = await postAction('/spectrumFile/upload', formData)
|
||||||
if (success) {
|
if (success) {
|
||||||
this.handleFileSelect(file.name)
|
this.handleFileSelect(`${sampleFilePrefix}${getSampleTypeIdentify(dataType)}_${qualify}_${liveTime}.PHD`)
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(message)
|
this.$message.error(message)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
} finally {
|
||||||
|
hide()
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user