spring
2025-04-18 0885aa811a94cae8d7473c9b2957a447110c9b1d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<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>