src/views/CNAS/resourceDemand/device/component/acquisitionConfig.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/views/business/inspectionTask/inspection.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/workers/DataWorker.worker.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/views/CNAS/resourceDemand/device/component/acquisitionConfig.vue
@@ -17,12 +17,14 @@ :span-method="spanMethod"> <el-table-column type="index" label="序号" align="center" width="65"></el-table-column> <el-table-column prop="deviceName" align="center" min-width="100" label="设备名称"></el-table-column> <el-table-column prop="fileType" align="center" label="文件后缀"></el-table-column> <el-table-column prop="collectUrl" align="center" min-width="100" show-overflow-tooltip label="采集地址"></el-table-column> <el-table-column prop="storageUrl" align="center" min-width="100" show-overflow-tooltip label="存储地址"></el-table-column> <el-table-column prop="ip" align="center" label="IP地址" min-width="100"></el-table-column> <el-table-column prop="fileType" align="center" label="文件后缀" v-if="deviceName && !deviceName.includes('网络分析')"></el-table-column> <el-table-column prop="collectUrl" align="center" min-width="100" show-overflow-tooltip label="采集地址" v-if="deviceName && !deviceName.includes('网络分析')"></el-table-column> <el-table-column prop="storageUrl" align="center" min-width="100" show-overflow-tooltip label="存储地址" v-if="deviceName && !deviceName.includes('网络分析')"></el-table-column> <el-table-column prop="ip" align="center" label="IP地址" min-width="100" v-if="deviceName && !deviceName.includes('网络分析')"></el-table-column> <el-table-column prop="sample" align="center" label="检验对象" show-overflow-tooltip min-width="150"></el-table-column> <el-table-column prop="inspectionItemClass" align="center" label="检验项分类" min-width="120"></el-table-column> @@ -349,6 +351,7 @@ channelList: [], dialogVisible5: false, upLoad5: false, currentInfo: {} }; }, // 方法集合 @@ -609,6 +612,7 @@ inspectionItemClass: row.inspectionItemClass, }; if (this.deviceName && this.deviceName.includes('网络分析')) { this.currentInfo = row this.dialogVisible5 = true; this.$set(this.configForm, 'importedParts', row.importedParts ? row.importedParts : '') this.$set(this.configForm, 'importedChannel', row.importedChannel ? row.importedChannel : '') @@ -765,11 +769,13 @@ this.$refs.configForm.resetFields(); }, submitForm5() { this.currentInfo.importedParts = this.configForm.importedParts this.currentInfo.importedChannel = this.configForm.importedChannel this.currentInfo.deviceId = this.deviceId saveDataAcquisitionConfiguration({ deviceId: this.deviceId, isDevice: true, importedParts: this.configForm.importedParts, importedChannel: this.configForm.importedChannel, isDevice: false, dataConfigList: [{ ...this.currentInfo }], }).then(res => { this.dialogVisible5 = false; this.init(); src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue
@@ -1,7 +1,26 @@ <template> <div class="btns"> <el-button type="primary" size="small" @click="getMetadata()">进口网分仪数采</el-button> <el-button type="primary" size="small">国产网分仪数采</el-button> <el-button type="primary" size="small" @click="getMetadata0">国产网分仪数采</el-button> <el-dialog title="国产网分" :visible.sync="dialogVisible" width="30%"> <el-form ref="form" :model="form" label-width="50px" :rules="rules"> <el-form-item label="IP"> <el-input v-model="form.serverIp" disabled></el-input> </el-form-item> <el-form-item label="端口"> <el-input v-model="form.serverPort" disabled></el-input> </el-form-item> <el-form-item label="通道" prop="memoryDir"> <el-select v-model="form.memoryDir" placeholder="请选择活动区域"> <el-option :label="item" :value="item" v-for="(item, index) in channel" :key="index"></el-option> </el-select> </el-form-item> </el-form> <span slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="saveForm">确 定</el-button> </span> </el-dialog> </div> </template> @@ -14,7 +33,15 @@ data() { return { itemConfig: [], itemListNew: [] itemListNew: [], dialogVisible: false, form: {}, channel: [], rules: { memoryDir: [ { required: true, message: '请选择通道', trigger: 'change' } ], } } }, mounted() { @@ -22,10 +49,8 @@ }, methods: { async getMetadata() { console.log(this.param, this.itemList) init() { this.itemListNew = this.HaveJson(this.itemList) let equip = null; for (let n in this.param) { let obj = this.equipOptions.find(m => m.value == this.param[n].equipValue[0].v.v) @@ -33,6 +58,10 @@ equip = obj } } return equip }, async getMetadata() { let equip = this.init() if (equip) { await this.getItemConfig(equip) this.itemListNew.forEach(item => { @@ -45,6 +74,18 @@ } }) this.gatherNetworkAnalyzerSampleItem() } }, getMetadata0() { let equip = this.init() if (equip) { this.form = { serverIp: equip.ip, serverPort: equip.port, memoryDir: null } this.channel = equip.channel ? equip.channel.split(',') : [] this.dialogVisible = true } }, async getItemConfig(param) { @@ -137,7 +178,7 @@ ) { dataItem = { Column1: item.inspectionItem, Column2: item.itemReference,// TODO: 相位差-周期数 // Column2: item.itemReference,// TODO: 相位差-周期数 TD: item.aisle == null ? '0' : item.aisle, BW: item.position == null ? '0' : item.position } @@ -151,12 +192,13 @@ flag = false flagMsg = flagMsg + item.inspectionItem + ',部位值为空;' } if ( item.itemReference == null || item.itemReference.indexOf('数') < 0 ) { phaseDifferenceFlag = false } // TODO: // if ( // item.itemReference == null || // item.itemReference.indexOf('数') < 0 // ) { // phaseDifferenceFlag = false // } } else if (item.inspectionItem.indexOf('特性阻抗') > -1 && item.inspectionItemType == 1 ) { dataItem = { @@ -193,6 +235,7 @@ if (flag) { const dataArrStr = JSON.stringify(dataArr) requireData = preStr + dataArrStr + ednStr console.log(3333, requireData) this.gatherLoadingShow = true $.ajax({ type: 'post', @@ -266,6 +309,212 @@ this.$message.error('电缆长度和送检长度转换系数不能为空') } }, saveForm() { this.$refs.form.validate((valid) => { if (valid) { // alert('submit!'); this.GuochanNetworkAnalyzer() } else { console.log('error submit!!'); return false; } }); }, // 国产网分仪 GuochanNetworkAnalyzer(type) { const { findFromCL } = this const temperture = findFromCL('温度') const num = findFromCL('电缆长度') * findFromCL('送检长度转换系数') const length = num ? this.roundFun(num, 6) : undefined const capacity = findFromCL('电容(测试值)') const Xiangweicha = this.itemListNew.find(m => m.inspectionItem.indexOf('相位差') > -1) let cycle if ( Xiangweicha && Xiangweicha.itemReference && Xiangweicha.itemReference.match(/周期数(\d+)/) ) { cycle = Xiangweicha.itemReference.match(/周期数(\d+)/)[1] } const index1 = this.itemListNew.findIndex(m => m.inspectionItem.indexOf('特性阻抗') > -1) // 国产 // 温度 // 电缆长度和送检长度转换系数 // 电容(测试值)-- 电容标准不能为空 // 相位差 存在 // 特性阻抗 存在 // 相位差的周期 // 轧纹 // 特性阻抗 存在 // 高温 // 温度 // 电缆长度和送检长度转换系数 // 特性阻抗 存在 // 京信 // 温度 // 电缆长度和送检长度转换系数 // 特性阻抗 存在 if (index1 < 0) { this.$message.error('无平均特性阻抗') return } if (type === '国产') { if (!capacity) { this.$message.error('电容标准不能为空') return } if (!Xiangweicha) { this.$message.error('无相位差') return } if (!cycle) { this.$message.error('无相位差周期数') return } } if (type === '国产' || type === '高温' || type === '京信') { if (!temperture) { this.$message.error('温度不能为空') return } if (!length) { this.$message.error('电缆长度和送检长度转换系数不能为空') return } } const loading = this.$loading({ lock: true, text: '数据采集中', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) const params = { ...this.form, temperture, length, cycle, capacity } getTCPValuesNew(params) .then((res) => { if (res.data.code === 0) { // 测试值acqItemValue -- decimalVal // 计算值calItemValue -- measureValue // 通道aisle -- channel 窗口 // 部位position -- trace 同一窗口下的不同轨迹线 // 值itemValue -- const data = res.data.data.filter((e) => e.ifLegal) data.forEach((e) => { if (e.decimalVal) { e.decimalVal = Math.abs(e.decimalVal) } if (e.measureValue) { e.measureValue = Math.abs(e.measureValue) } }) this.dataList['采集项'].forEach((e) => { if (e.itemName.indexOf('衰减') > -1) { const d = data.find((d) => { const match = d.label.match(/decay_(\d+)m/) return ( match && (match[1] + 'MHz衰减' === e.itemName || match[1] + 'MHZ衰减' === e.itemName || +match[1] / 1000 + 'GHz衰减' === e.itemName || +match[1] / 1000 + 'GHZ衰减' === e.itemName) && d.channel === +e.aisle ) }) if (d) { e.acqItemValue = this.roundFun(d.decimalVal, 3) e.calItemValue = this.roundFun(d.measureValue, 3) // e.itemValue = Math.min(e.acqItemValue, e.calItemValue) e.itemValue = e.calItemValue } } else if (e.itemName.indexOf('驻波比') > -1) { const trace1 = data.find((d) => { const match = d.label.match(/swr_(\d+)m/) return match && d.channel === +e.aisle && d.trace === 1 }) const trace2 = data.find((d) => { const match = d.label.match(/swr_(\d+)m/) if (type === '轧纹' && d.trace === 5) { d.trace = 2 // 轧纹网分仪配置不正确,手动修正 } return match && d.channel === +e.aisle && d.trace === 2 }) let [value1, value2, match1, match2] = [null, null, null, null] if (trace1) { value1 = this.roundFun(trace1.decimalVal, 3) match1 = this.roundFun(trace1.label.match(/swr_(\d+)m/)[1], 3) e.acqItemValue = `${value1}|${match1}` } if (trace2) { value2 = this.roundFun(trace2.decimalVal, 3) match2 = this.roundFun(trace2.label.match(/swr_(\d+)m/)[1], 3) e.calItemValue = `${value2}|${match2}` } if (trace1 || trace2) { e.itemValue = Math.max(value1, value2) } } else if (e.itemName.indexOf('相位差') > -1) { const d = data.find((d) => { return d.channel === +e.aisle && d.label === 'pha_mean' }) if (d) { e.acqItemValue = this.roundFun(d.decimalVal, 3) } } else if (e.itemName.indexOf('特性阻抗') > -1) { const trace1 = data.find((d) => { return ( d.channel === +e.aisle && d.trace === 1 && d.label === 'impedance_mean' ) }) const trace2 = data.find((d) => { return ( d.channel === +e.aisle && d.trace === 2 && d.label === 'impedance_mean' ) }) let [value1, value2] = [null, null] if (trace1) { value1 = this.roundFun(trace1.decimalVal, 3) e.calItemValue = this.roundFun(trace1.calculateValue, 3) e.itemValue = e.calItemValue } if (trace2) { value2 = this.roundFun(trace2.decimalVal, 3) e.calItemValue = this.roundFun(trace2.calculateValue, 3) e.itemValue = e.calItemValue } if (trace1 || trace2) { e.acqItemValue = `${value1}${value1 && value2 ? '|' : '' }${value2}` } } }) } }) .finally(() => { loading.close() }) }, findFromCL(type) { const obj = this.itemListNew.find(m => m.inspectionItem == type) if (obj) { return this.param[obj.id].resValue.v.v } else { return '' } }, roundFun(value, n) { if (value === null) { return null src/views/business/inspectionTask/inspection.vue
@@ -289,7 +289,7 @@ state == 1 "><span :style="`font-family:${n.v.ff} !important;`">{{ toFixed(n.v.v, n.v.ct) }}</span></template> }}</span></template> <template v-else-if=" n.v.ps != undefined && n.v.ps.value === '最终值' && src/workers/DataWorker.worker.js
@@ -7,147 +7,190 @@ let list = null; // 传递到主线程的数据 let result = { method:'', value:null } method: "", value: null, }; // 优化数采较多数据时--记录数采项目的Id数组,目的是取最后一个数采项目,传到主线程进行批量的数据采集保存 let arrSpecial = [] let arrSpecial = []; // 接收主线程传递过来的数据 self.onmessage = function(event) { self.onmessage = function (event) { const data = JSON.parse(event.data); dataAcquisitionInfo = data.dataAcquisitionInfo; list = data.list; // console.log(111,dataAcquisitionInfo) arrSpecial = [] arrSpecial = []; // 处理数据 handleData() } handleData(); }; function handleData(){ function handleData() { // 遍历数据列表 list.forEach((item,index)=>{ list.forEach((item, index) => { let num = 0; let str = '' item.forEach(m=>{ if(m.v.ps&&(m.v.ps.value=='检验子项'||m.v.ps.value=='检验项'||m.v.ps.value=='检验项分类')){ if(m.v.ps&&m.v.ps.value=='检验项分类'){ if(num==0){ num++ str = m.v.v+',' let str = ""; item.forEach((m) => { if ( m.v.ps && (m.v.ps.value == "检验子项" || m.v.ps.value == "检验项" || m.v.ps.value == "检验项分类") ) { if (m.v.ps && m.v.ps.value == "检验项分类") { if (num == 0) { num++; str = m.v.v + ","; } } if(m.v.ps&&m.v.ps.value=='检验项'){ if(num==1){ str = str+m.v.v + ',' num++ if (m.v.ps && m.v.ps.value == "检验项") { if (num == 1) { str = str + m.v.v + ","; num++; } else { str = m.v.v+',' num++ str = m.v.v + ","; num++; } } if(m.v.ps&&m.v.ps.value=='检验子项'){ str = str+m.v.v if (m.v.ps && m.v.ps.value == "检验子项") { str = str + m.v.v; } // 上面在记录检验项+检验子项的名称,如果数采包含检验项+检验子项的数据,则执行 if(dataAcquisitionInfo[str]){ let num = 0;//该检验项对应检验值的个数,用用判断最多有多少个检验值,如果多次采集超过了该个数,则赋值给最后一个检验值 list[index].forEach(n=>{ if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('检验值')){ num++ if (dataAcquisitionInfo[str]) { let num = 0; //该检验项对应检验值的个数,用用判断最多有多少个检验值,如果多次采集超过了该个数,则赋值给最后一个检验值 list[index].forEach((n) => { if ( n.v.ps && n.v.ps.value && typeof n.v.ps.value == "string" && n.v.ps.value.includes("检验值") ) { num++; } }) list[index].forEach((n,i)=>{ if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('检验值')){ let arr = n.v.ps.value.split('值') if(Array.isArray(dataAcquisitionInfo[str].value)){ }); list[index].forEach((n, i) => { if ( n.v.ps && n.v.ps.value && typeof n.v.ps.value == "string" && n.v.ps.value.includes("检验值") ) { let arr = n.v.ps.value.split("值"); if (Array.isArray(dataAcquisitionInfo[str].value)) { // 如果数据源为数组,则执行 for (let i = 0; i < dataAcquisitionInfo[str].value.length; i++) { if(i+1==arr[1]){ for ( let i = 0; i < dataAcquisitionInfo[str].value.length; i++ ) { if (i + 1 == arr[1]) { // 赋值数采优化检验项列表 arrSpecial.push(n.i) setTimeout(()=>{ let num0 = 0 if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ arrSpecial.push(n.i); setTimeout(() => { let num0 = 0; if ( n.v.ct && n.v.ct.fa && typeof n.v.ct.fa == "string" && n.v.ct.fa.includes(".") ) { // 保留模板配置的小数点位数 let str0 = n.v.ct.fa.split('.')[1] num0 = str0.length n.v.v = dataAcquisitionInfo[str].value[i]?Number(dataAcquisitionInfo[str].value[i]).toFixed(num0):dataAcquisitionInfo[str].value[i] }else{ // 直接赋值 let str0 = n.v.ct.fa.split(".")[1]; num0 = str0.length; n.v.v = dataAcquisitionInfo[str].value[i] ? Number(dataAcquisitionInfo[str].value[i]).toFixed( num0 ) : dataAcquisitionInfo[str].value[i]; } else { // 直接赋值 console.log(44444, dataAcquisitionInfo, str); n.v.v = dataAcquisitionInfo[str].value[i]; } // 传递给主线程 result = { method:'changeInput', value:{ list:list, n:n } } self.postMessage(JSON.stringify(result)) },2000) method: "changeInput", value: { list: list, n: n, }, }; self.postMessage(JSON.stringify(result)); }, 2000); } } }else{ } else { // 如果数据源为字符或数字,则执行 if(arr[1] ==dataAcquisitionInfo[str].frequency){ if (arr[1] == dataAcquisitionInfo[str].frequency) { // 如果数采次数等于检验值序号,则赋值给当前检验值 arrSpecial.push(n.i) setTimeout(()=>{ let num0 = 0 if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ arrSpecial.push(n.i); setTimeout(() => { let num0 = 0; if ( n.v.ct && n.v.ct.fa && typeof n.v.ct.fa == "string" && n.v.ct.fa.includes(".") ) { // 保留模板配置的小数点位数 let str0 = n.v.ct.fa.split('.')[1] num0 = str0.length n.v.v = dataAcquisitionInfo[str].value?Number(dataAcquisitionInfo[str].value).toFixed(num0):dataAcquisitionInfo[str].value }else{ // 直接赋值 let str0 = n.v.ct.fa.split(".")[1]; num0 = str0.length; n.v.v = dataAcquisitionInfo[str].value ? Number(dataAcquisitionInfo[str].value).toFixed(num0) : dataAcquisitionInfo[str].value; } else { // 直接赋值 n.v.v = dataAcquisitionInfo[str].value; } // 传递给主线程 result = { method:'changeInput', value:{ list:list, n:n } } self.postMessage(JSON.stringify(result)) },2000) }else if(Number(dataAcquisitionInfo[str].frequency)>num){ method: "changeInput", value: { list: list, n: n, }, }; self.postMessage(JSON.stringify(result)); }, 2000); } else if (Number(dataAcquisitionInfo[str].frequency) > num) { // 如果数采次数大于检验值序号,则赋值给最后一个检验值 if(n.v.ps.value.includes(num)){ arrSpecial.push(n.i) setTimeout(()=>{ let num0 = 0 if(n.v.ct&&n.v.ct.fa&&typeof n.v.ct.fa == 'string'&&n.v.ct.fa.includes('.')){ if (n.v.ps.value.includes(num)) { arrSpecial.push(n.i); setTimeout(() => { let num0 = 0; if ( n.v.ct && n.v.ct.fa && typeof n.v.ct.fa == "string" && n.v.ct.fa.includes(".") ) { // 保留模板配置的小数点位数 let str0 = n.v.ct.fa.split('.')[1] num0 = str0.length n.v.v = dataAcquisitionInfo[str].value?Number(dataAcquisitionInfo[str].value).toFixed(num0):dataAcquisitionInfo[str].value }else{ // 直接赋值 let str0 = n.v.ct.fa.split(".")[1]; num0 = str0.length; n.v.v = dataAcquisitionInfo[str].value ? Number(dataAcquisitionInfo[str].value).toFixed(num0) : dataAcquisitionInfo[str].value; } else { // 直接赋值 n.v.v = dataAcquisitionInfo[str].value; } // 传递给主线程 result = { method:'changeInput', value:{ list:list, n:n } } self.postMessage(JSON.stringify(result)) },2000) method: "changeInput", value: { list: list, n: n, }, }; self.postMessage(JSON.stringify(result)); }, 2000); } } } } }) }); } } }) }) }); }); // if(arrSpecial[arrSpecial.length-1]){ // //优化数采较多数据时-记录最后一个检验项的id,用于后续处理 // setTimeout(()=>{