<template>
|
<div class="btns">
|
<el-button type="primary" size="small" @click="getMetadata()">进口网分仪数采</el-button>
|
<el-button type="primary" size="small">国产网分仪数采</el-button>
|
</div>
|
</template>
|
|
<script>
|
import {
|
queryDataAcquisitionConfigurationTwo,
|
} from '@/api/cnas/resourceDemand/device.js'
|
export default {
|
props: ['itemList', 'param', 'equipOptions'],
|
data() {
|
return {
|
itemConfig: [],
|
itemListNew: []
|
}
|
},
|
mounted() {
|
// console.log(this.param, this.itemList)
|
|
},
|
methods: {
|
async getMetadata() {
|
console.log(this.param, this.itemList)
|
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
|
}
|
}
|
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()
|
}
|
},
|
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
|
}
|
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 + ',部位值为空;'
|
}
|
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
|
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('电缆长度和送检长度转换系数不能为空')
|
}
|
},
|
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>
|