<template>
|
<div class="btns">
|
<el-button type="primary" size="small" @click="getMetadata()" v-if="isShowBtn">进口网分仪数采</el-button>
|
<el-button type="primary" size="small" @click="getMetadata0" v-if="isShowBtn">国产网分仪数采</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>
|
|
<script>
|
import {
|
queryDataAcquisitionConfigurationTwo,
|
} from '@/api/cnas/resourceDemand/device.js'
|
export default {
|
props: ['itemList', 'param', 'equipOptions'],
|
data() {
|
return {
|
itemConfig: [],
|
itemListNew: [],
|
dialogVisible: false,
|
form: {},
|
channel: [],
|
rules: {
|
memoryDir: [
|
{ required: true, message: '请选择通道', trigger: 'change' }
|
],
|
},
|
isShowBtn: false,//是否展示按钮
|
}
|
},
|
methods: {
|
init() {
|
console.log(222222, this.param)
|
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)
|
if (obj && obj.label && obj.label.indexOf('网络分析仪') > -1) {
|
equip = obj
|
this.isShowBtn = true
|
}
|
}
|
return equip
|
},
|
// 进口网分仪数采
|
async getMetadata() {
|
let equip = this.init()
|
if (equip) {
|
await this.getItemConfig(equip)
|
this.itemListNew.forEach(item => {
|
if (item.inspectionItemType == 1) {
|
let obj = this.itemConfig.find(m => m.inspectionItem == item.inspectionItem)
|
if (obj) {
|
item.aisle = obj.importedChannel
|
item.position = obj.importedParts
|
}
|
}
|
})
|
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) {
|
let res = await queryDataAcquisitionConfigurationTwo({ ...param })
|
if (res.code == 200) {
|
this.itemConfig = res.data
|
}
|
},
|
// 进口网分仪
|
gatherNetworkAnalyzerSampleItem() {
|
// 传参数
|
// 生成请求信息
|
const preStr =
|
'<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><CalValue xmlns="zhrf_CollectData"><dataGridView>'
|
const ednStr = '</dataGridView></CalValue></soap:Body></soap:Envelope>'
|
let requireData = ''
|
const electricItem = this.itemListNew.find(m => m.inspectionItem == '电容(测试值)')
|
if (electricItem) {
|
electricItem.itemValue = this.param[electricItem.id].resValue.v.v
|
}
|
const dataArr = []
|
let dataItem
|
let flag = true
|
let flagMsg = ''
|
const temperatureItem = this.itemListNew.find(m => m.inspectionItem == '温度')
|
if (temperatureItem) {
|
temperatureItem.itemValue = this.param[temperatureItem.id].resValue.v.v
|
}
|
console.log('temperatureItem', temperatureItem)
|
const temperature = temperatureItem ? temperatureItem.itemValue : null
|
|
const cdItem = this.itemListNew.find(m => m.inspectionItem == '电缆长度')
|
if (cdItem) {
|
cdItem.itemValue = this.param[cdItem.id].resValue.v.v
|
}
|
|
const cdItems = this.itemListNew.find(m => m.inspectionItem == '送检长度转换系数')
|
if (cdItems) {
|
cdItems.itemValue = this.param[cdItems.id].resValue.v.v
|
}
|
const res =
|
(cdItem ? cdItem.itemValue : 0) * (cdItems ? cdItems.itemValue : 0)
|
const num = this.roundFun(res, 6)
|
const cd = cdItem && cdItems ? num : null
|
console.log('cd', cd)
|
if (cd && cd != null) {
|
if (temperature && temperature != null) {
|
if (
|
electricItem &&
|
electricItem != null &&
|
electricItem.itemValue != null
|
) {
|
let phaseDifferenceFlag = true
|
this.itemListNew.forEach(item => {
|
if (item.inspectionItem.indexOf('衰减') > -1 && item.inspectionItemType == 1) {
|
dataItem = {
|
Column1: item.inspectionItem,
|
TD: item.aisle == null ? '0' : item.aisle,
|
BW: item.position == null ? '0' : item.position,
|
temperture: temperature,
|
cd: cd
|
}
|
dataArr.push(dataItem)
|
// 判断是否有部位、通道
|
if (item.aisle == null || item.aisle == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',通道值为空;'
|
}
|
if (item.position == null || item.position == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',部位值为空;'
|
}
|
} else if (item.inspectionItem.indexOf('驻波比') > -1 && item.inspectionItemType == 1
|
) {
|
dataItem = {
|
Column1: item.inspectionItem,
|
TD: item.aisle == null ? '0' : item.aisle,
|
BW: item.position == null ? '0' : item.position
|
}
|
dataArr.push(dataItem)
|
// 判断是否有部位、通道
|
if (item.aisle == null || item.aisle == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',通道值为空;'
|
}
|
if (item.position == null || item.position == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',部位值为空;'
|
}
|
} else if (item.inspectionItem.indexOf('相位差') > -1 && item.inspectionItemType == 1
|
) {
|
dataItem = {
|
Column1: item.inspectionItem,
|
// Column2: item.itemReference,// TODO: 相位差-周期数
|
TD: item.aisle == null ? '0' : item.aisle,
|
BW: item.position == null ? '0' : item.position
|
}
|
dataArr.push(dataItem)
|
// 判断是否有部位、通道
|
if (item.aisle == null || item.aisle == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',通道值为空;'
|
}
|
if (item.position == null || item.position == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',部位值为空;'
|
}
|
// TODO:
|
// if (
|
// item.itemReference == null ||
|
// item.itemReference.indexOf('数') < 0
|
// ) {
|
// phaseDifferenceFlag = false
|
// }
|
} else if (item.inspectionItem.indexOf('特性阻抗') > -1 && item.inspectionItemType == 1
|
) {
|
dataItem = {
|
Column1: item.inspectionItem,
|
TD: item.aisle == null ? '0' : item.aisle,
|
BW: item.position == null ? '0' : item.position,
|
DR: electricItem ? electricItem.itemValue : '0'
|
}
|
dataArr.push(dataItem)
|
// 判断是否有部位、通道
|
if (item.aisle == null || item.aisle == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',通道值为空;'
|
}
|
if (item.position == null || item.position == '') {
|
flag = false
|
flagMsg = flagMsg + item.inspectionItem + ',部位值为空;'
|
}
|
}
|
})
|
if (phaseDifferenceFlag) {
|
const _that = this
|
if (dataArr.length > 0) {
|
// 判断相位差、特性阻抗的顺序位置,相位差在前、平均特性阻抗在后
|
const index0 = dataArr.findIndex((item) => {
|
return item.Column1.indexOf('相位差') >= 0
|
})
|
const index1 = dataArr.findIndex((item) => {
|
return item.Column1.indexOf('特性阻抗') >= 0
|
})
|
if (index0 >= 0) {
|
if (index1 >= 0) {
|
if (index0 < index1) {
|
if (flag) {
|
const dataArrStr = JSON.stringify(dataArr)
|
requireData = preStr + dataArrStr + ednStr
|
console.log(3333, requireData)
|
this.gatherLoadingShow = true
|
$.ajax({
|
type: 'post',
|
url:
|
'http://127.0.0.1:8089/zhrf_CollectData.asmx?op=CalValue',
|
headers: {
|
'Content-Type': 'text/xml;charset=utf-8'
|
},
|
data: requireData,
|
success: function (response) {
|
console.log('response', response)
|
const resJson = response
|
// TODO
|
if (resJson.message) {
|
const resData = resJson.data
|
if (resData.length > 0) {
|
resData.forEach((resDataEle) => {
|
const paramItem = _that.dataList[
|
'采集项'
|
].find((ele) => {
|
return ele.itemName == resDataEle.Column1
|
})
|
if (paramItem) {
|
paramItem.acqItemValue =
|
resDataEle.Column3
|
paramItem.calItemValue =
|
resDataEle.Column4
|
paramItem.itemValue = resDataEle.Column5
|
}
|
})
|
}
|
} else {
|
console.log('获取网分仪数据失败')
|
}
|
_that.gatherLoadingShow = false
|
},
|
error: function (
|
XMLHttpRequest,
|
textStatus,
|
errorThrown
|
) {
|
console.log('获取网分仪接口异常')
|
_that.gatherLoadingShow = false
|
}
|
})
|
} else {
|
this.$message.error(flagMsg)
|
}
|
} else {
|
this.$message.error('相位差需平均特性阻抗之前')
|
}
|
} else {
|
this.$message.error('无平均特性阻抗')
|
}
|
} else {
|
this.$message.error('无相位差')
|
}
|
} else {
|
this.$message.error('无检测项目需进行采集')
|
}
|
} else {
|
this.$message.error('相位差要求范围格式错误')
|
}
|
} else {
|
this.$message.error('电容标准不能为空')
|
}
|
} else {
|
this.$message.error('温度不能为空')
|
}
|
} else {
|
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
|
}
|
return Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
|
},
|
},
|
}
|
</script>
|
|
<style scoped>
|
.btns {
|
display: flex;
|
align-items: center;
|
margin-right: 10px;
|
}
|
</style>
|