aijinhui
2023-09-26 6642bd2b06a87e8498bc83a0cc0e2a3d8ca2a582
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
package com.ruoyi.health.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo;
import com.ruoyi.common.core.domain.HealthVo;
import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
import com.ruoyi.common.core.domain.TreeDeptWell;
import com.ruoyi.common.core.domain.TreeSelectWell;
import com.ruoyi.common.core.domain.TreeSelectWellJson;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.health.client.EquipmentsHealthClient;
import com.ruoyi.health.param.GetEquipmentAlertInfoParam;
import com.ruoyi.health.param.GetFMTrendParam;
import com.ruoyi.health.param.GetTrendParam;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.utils.result.Results;
import com.ruoyi.utils.soap.ARDSoapUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
 
/**
 * @author Administrator
 */
@RestController
@RequestMapping("/health")
@Api(tags = "设备健康管理")
public class HealthController {
 
    @Autowired
    ISysConfigService configService;
 
    @Resource
    private IArdAlarmpointsWellService ardAlarmpointsWellService;
 
    @Autowired
    private ISysUserService sysUserService;
 
    @Autowired
    private ISysDeptService sysDeptService;
 
 
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getEquipmentListByUser')")
    @ApiOperation("根据权限获取设备列表")
    @GetMapping("getEquipmentListByUser")
    public Results getEquipmentListByUser(){
        //查询用户ID
        String usersId = SecurityUtils.getUserId();
        //根据userId查询部门Id
        SysUser sysUser = sysUserService.selectUserById(usersId);
        //根据当前deptId或者当前及所属下级的所有deptId
        List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
        //根据deptId获取对应所有兴趣点数据
        List<ArdAlarmpointsWellDeptVo> list = ardAlarmpointsWellService.wellListDept(deptList);
        //查询接口返回的设备列表
        String url = configService.getHealth();
        Map<String, Object> map = new HashMap();
        String result = ARDSoapUtil.postSoapResult(url, "GetEquipmentList", map);
        if ("".equals(result)) {
            //返回结果为空
            return Results.succeed("没有设备信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        //等级
        int count0 = 0,count1 = 0,count2 = 0;
        //装数据
        List<TreeDeptWell> treeDeptWells = new ArrayList<>();
        if ((int) mapResult.get("code") == 200) {
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            //循环得到权限下匹配数据
            for (int i = 0; i < listResult.size(); i++) {
                String equipNumber = (String) listResult.get(i).get("EquipNumber");
                if(equipNumber!=null){
                    for (int j = 0; j < list.size(); j++) {
                        String wellId = list.get(j).getWellId();
                        if(wellId!=null){
                            if(wellId.equals(equipNumber)){
                                //返回设备数据
                                TreeDeptWell treeDeptWell = new TreeDeptWell();
                                treeDeptWell.setId((Integer) listResult.get(i).get("id"));
                                treeDeptWell.setEquipName((String) listResult.get(i).get("EquipName"));
                                treeDeptWell.setEquipNumber((String) listResult.get(i).get("EquipNumber"));
                                treeDeptWell.setEquipLevel((String) listResult.get(i).get("EquipLevel"));
                                treeDeptWell.setEquipKey((String) listResult.get(i).get("EquipKey"));
                                treeDeptWell.setMeasureDate((String) listResult.get(i).get("MeasureDate"));
                                treeDeptWell.setLongitude(list.get(j).getLongitude());
                                treeDeptWell.setLatitude(list.get(j).getLatitude());
                                treeDeptWell.setAltitude(list.get(j).getAltitude());
                                treeDeptWell.setDeptId(list.get(j).getDeptId());
                                treeDeptWell.setAncestors(list.get(j).getAncestors());
                                treeDeptWell.setParentId(list.get(j).getParentId());
                                treeDeptWell.setDeptName(list.get(j).getDeptName());
                                treeDeptWells.add(treeDeptWell);
                                if(listResult.get(i).get("EquipLevel").equals("0")){
                                    count0++;
                                }else if(listResult.get(i).get("EquipLevel").equals("1")){
                                    count1++;
                                }else if(listResult.get(i).get("EquipLevel").equals("2")){
                                    count2++;
                                }
                                break;
                            }
                        }
                    }
                }
            }
            //根据deptList查询出用户及以下的所有部门信息
            List<SysDept> sysDepts = sysDeptService.allByUser(deptList);
            //循环查询出该用户的所有上级ID
            List<String> userParentId = new ArrayList<>();
            for (int i = 0; i < sysDepts.size(); i++) {
                Long userDeptId = sysDepts.get(i).getDeptId();
                if(usersId.equals(userDeptId)){
                    String ancestors = sysDepts.get(i).getAncestors();
                    if(ancestors.contains(",")){
                        userParentId = Arrays.asList(ancestors.split(","));
                    }else {
                        userParentId.add(ancestors);
                    }
                    break;
                }
            }
            //把部门层级和数据结合
//            List<TreeDeptWell> treeDeptWells = new ArrayList<>();
            for (int i = 0; i < sysDepts.size(); i++) {
                //部门ID
                SysDept sysDept = sysDepts.get(i);
                Long deptId = sysDept.getDeptId();
                for (int j = 0; j < treeDeptWells.size(); j++) {
                    //设备的部门ID
                    TreeDeptWell healthVo = treeDeptWells.get(j);
                    Long healthDeptId = healthVo.getDeptId();
                    if(deptId.equals(healthDeptId)){
                        //父级结构赋值
                        String thisAncestors = healthVo.getAncestors();
                        List<String> ancestorsA = Arrays.asList(thisAncestors.split(","));
                        ancestorsA.removeAll(userParentId);
                        for (int k = 0; k < ancestorsA.size(); k++) {
                            Long ancestor = Long.parseLong(ancestorsA.get(k));
                            //循环最终List判断是否有该数据的父级,如果没有就填进去
                            boolean wellTrue = false;
                            if(ancestor==0){
                                //父类集合为0则是最顶级上面没有
                                wellTrue = true;
                            }else {
                                for (int l = 0; l < treeDeptWells.size(); l++) {
                                    //如果该父类集合在结构中已经存在并且不是设备数据就不用重复添加了
                                    Long treeId = treeDeptWells.get(l).getDeptId();
                                    Integer id = treeDeptWells.get(l).getId();
                                    if(ancestor.equals(treeId)){
                                        wellTrue = true;
                                    }
                                }
                            }
                            if(!wellTrue){
                                SysDept sysDept1 = sysDeptService.selectDeptById(ancestor);
                                TreeDeptWell treeDeptWell = new TreeDeptWell();
                                treeDeptWell.setDeptId(ancestor);
                                treeDeptWell.setAncestors(sysDept1.getAncestors());
                                treeDeptWell.setDeptName(sysDept1.getDeptName());
                                treeDeptWell.setParentId(sysDept1.getParentId());
                                treeDeptWells.add(treeDeptWell);
                            }
                        }
                    }
                }
            }
            List<TreeDeptWell> tree = sysDeptService.wellTree(treeDeptWells);
            TreeSelectWellJson treeSelectWellJson = new TreeSelectWellJson();
            treeSelectWellJson.setWellList(tree);
            treeSelectWellJson.setCount0(count0);
            treeSelectWellJson.setCount1(count1);
            treeSelectWellJson.setCount2(count2);
            return Results.succeed(treeSelectWellJson);
        } else {
            //错误提示
            return Results.error((String) mapResult.get("errmsg"));
        }
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getEquipmentList')")
    @ApiOperation("获取设备列表")
    @GetMapping("getEquipmentList")
    public Results getEquipmentList(){
        String url = configService.getHealth();
        JSONObject j = new JSONObject();
        Map<String, Object> map = new HashMap();
        String result = ARDSoapUtil.postSoapResult(url, "GetEquipmentList", map);
        if ("".equals(result)) {
            //返回结果为空
            return Results.succeed("没有设备信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        if ((int) mapResult.get("code") == 200) {
            j.put("code", mapResult.get("code"));
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            for (int i = 0; i < listResult.size(); i++) {
                Map<String, Object> mapTemp = listResult.get(i);
                int id = (Integer) mapTemp.get("id");  //主键id
//                String equipKey = (String) mapTemp.get("EquipKey");  //设备Key
//                String equipNumber = (String) mapTemp.get("EquipNumber");  //设备编号
//                String equipName = (String) mapTemp.get("EquipName");   //设备名称
//                String equipLevel = (String) mapTemp.get("EquipLevel");  //设备报警等级 0正常 1注意 2严重
//                String measureDate = (String) mapTemp.get("MeasureDate");  //最近一次测量时间
                j.put(id + "", mapTemp);
            }
        } else {
            //错误提示
            j.put("errmsg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getMeasureByEquipName')")
    @ApiOperation("根据name获取某个油井测点列表")
    @GetMapping("getMeasureByEquipName")
    public Results getMeasureByEquipName(String equipNumber){
        String url = configService.getHealth();
        JSONObject j = new JSONObject();
        Map<String, Object> map = new HashMap();
        String result = ARDSoapUtil.postSoapResult(url, "GetEquipmentList", map);
        String equipKey = "";
        if ("".equals(result)) {
            //返回结果为空
            return Results.succeed("没有设备信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        if ((int) mapResult.get("code") == 200) {
            j.put("code", mapResult.get("code"));
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            for (int i = 0; i < listResult.size(); i++) {
                Map<String, Object> mapTemp = listResult.get(i);
                String equipNumberTemp = (String) mapTemp.get("EquipNumber");   //设备名称
                if (equipNumberTemp.equals(equipNumber)) {
                    //名称匹配,即为要获取的设备;
                    equipKey = (String) mapTemp.get("EquipKey");  //设备Key
                }
            }
            if ("".equals(equipKey)) {
                return Results.succeed("没有测点信息");
            }
            //获取设备的测点列表
            Map<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put("EquipKey", equipKey);
            String eResult = ARDSoapUtil.postSoapResult(url, "GetMeasureByEquipKey", hashMap);
            if ("".equals(eResult)) {
                //返回结果为空
                return Results.succeed("没有测点信息");
            }
            Map<String, Object> map1 = (Map<String, Object>) JSON.parse((String) eResult);
            if ((int) map1.get("code") == 200) {
                j.put("code", map1.get("code"));
                List<Map<String, Object>> list = (List<Map<String, Object>>) JSON.parse((String) map1.get("resdata"));
//                for (int i = 0; i < listResult.size(); i++) {
//                    Map<String, Object> mapTemp = listResult.get(i);
//                    int id = (Integer) mapTemp.get("id");   //主键id
//                    String measureKey = (String) mapTemp.get("MeasureKey");  //测点key
//                    String measureNumber = (String) mapTemp.get("MeasureNumber");  //测点编号
//                    String measureName = (String) mapTemp.get("MeasureName");   //测点名称
//                    String measureLevel = (String) mapTemp.get("MeasureLevel");  //测点报警等级 0正常 1注意 2严重
//                    String sensorType = (String) mapTemp.get("SensorType");  //传感器类型
//                    String betry = (String) mapTemp.get("BETRY");//电量
//                }
                j.put("listResult", list);
            } else {
                //错误提示
                j.put("errmsg", mapResult.get("errmsg"));
                j.put("code", mapResult.get("code"));
            }
        } else {
            //错误提示
            j.put("errmsg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getTrend')")
    @ApiOperation("获取某油井一段时间的测量趋势")
    @GetMapping("getTrend")
    public JSONObject getTrend(GetTrendParam getTrendParam){
        String url = configService.getHealth();
        Map<String , Object> map = new HashMap<String , Object>();
        map.put("MeasureKey", getTrendParam.getMeasureKey());
        map.put("StartTime", getTrendParam.getStartTime());
        map.put("EndTime", getTrendParam.getEndTime());
        JSONObject j = new JSONObject();
        String result = ARDSoapUtil.postSoapResult(url ,"GetTrend" ,  map);
        if ("".equals(result)){
            j.put("msg", "没有测点信息");
            j.put("code", 500);
        }
        Map<String,Object> mapResult = (Map<String, Object>) JSON.parse((String)result);
        if ( (int) mapResult.get("code") == 200){
            j.put("code", mapResult.get("code"));
            List<Map<String , Object>> listResult = (List<Map<String, Object>>)JSON.parse((String)mapResult.get("resdata"));
 
            if(listResult.size()>0){
                for(int i = 0 ; i<listResult.size(); i++){
                    Map<String , Object> mapTemp = listResult.get(i);
                    BigDecimal value = (BigDecimal)mapTemp.get("Value");  //数值
                    String measureStr = (String)mapTemp.get("MeasureDate");  //测量时间
                    measureStr = measureStr.substring(measureStr.indexOf("(")+1, measureStr.indexOf(")",2));
                    SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    String measureDate = f.format(Long.valueOf(measureStr));
                    mapTemp.put("MeasureDate", measureDate);
                    mapTemp.put("Value", value.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
                j.put("data",listResult);
            }else {
                j.put("data",new ArrayList<>());
            }
        }else{
            //错误提示
            j.put("msg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return j;
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getWaveDataByIndex')")
    @ApiOperation("获取某次测量数据的图谱")
    @GetMapping("getWaveDataByIndex")
    public Results getWaveDataByIndex(String id){
        String url = configService.getHealth();
        Map<String , Object> map = new HashMap<String , Object>();
        map.put("id", id);
        JSONObject j = new JSONObject();
        String result = ARDSoapUtil.postSoapResult(url ,"GetWaveDataByIndex" ,  map);
        if ("".equals(result)){
            return Results.succeed("没有测点信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        if ((int) mapResult.get("code") == 200) {
            j.put("code", mapResult.get("code"));
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            int frequency = (Integer) listResult.get(0).get("Frequency"); //频宽
            int lines = (Integer) listResult.get(0).get("Lines");//线数
            int measureCycle = (Integer) listResult.get(0).get("MeasureCycle");//采样时间
            List waveDataImage = (List) listResult.get(0).get("WaveDataImage");//时域图谱
            List FrequencyDataImage = (List) listResult.get(0).get("FrequencyDataImage"); //频域图谱
            j.put("frequency", frequency);
            j.put("lines", lines);
            j.put("measureCycle", measureCycle);
            j.put("waveDataImage", waveDataImage);
            j.put("FrequencyDataImage", FrequencyDataImage);
        } else {
            //错误提示
            j.put("errmsg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getAlertInfo')")
    @ApiOperation("获取某个测点的最后一次报警信息")
    @GetMapping("getAlertInfo")
    public Results getAlertInfo(String number){
        String url = configService.getHealth();
        Map<String , Object> map = new HashMap<String , Object>();
        map.put("WellNumber", number);
        JSONObject j = new JSONObject();
        String result = ARDSoapUtil.postSoapResult(url ,"GetWellAlertInfo" ,  map);
        if ("".equals(result)){
            return Results.succeed("没有测点信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        if ((int) mapResult.get("code") == 200) {
            j.put("code", mapResult.get("code"));
 
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            j.put("listResult", listResult);
            for (int i = 0; i < listResult.size(); i++) {
                Map<String, Object> mapTemp = listResult.get(i);
                int id = (Integer) mapTemp.get("id");   //主键id
                String position = (String) mapTemp.get("position");  //异常部位
                String problem = (String) mapTemp.get("problem");  //异常问题(失效模式)
                String suggestion = (String) mapTemp.get("suggestion");  //改善建议
            }
        } else {
            //错误提示
            j.put("errmsg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getFMTrend')")
    @ApiOperation("获取某异常问题(失效模式)的趋势")
    @GetMapping("getFMTrend")
    public Results getFMTrend(GetFMTrendParam getFMTrendParam){
        String url = configService.getHealth();
        Map<String , Object> map = new HashMap<String , Object>();
        map.put("id", getFMTrendParam.getId());
        map.put("StartTime", getFMTrendParam.getStartTime());
        map.put("EndTime", getFMTrendParam.getEndTime());
        JSONObject j = new JSONObject();
        String result = ARDSoapUtil.postSoapResult(url ,"GetFMTrend" ,  map);
        if ("".equals(result)){
            return Results.succeed("没有测点信息");
        }
        Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result);
        if ((int) mapResult.get("code") == 200) {
            j.put("code", mapResult.get("code"));
 
            List<Map<String, Object>> listResult = (List<Map<String, Object>>) JSON.parse((String) mapResult.get("resdata"));
            j.put("listResult", listResult);
            for (int i = 0; i < listResult.size(); i++) {
                Map<String, Object> mapTemp = listResult.get(i);
                int id = (Integer) mapTemp.get("id");   //主键id
                String value = (String) mapTemp.get("Value");  //数值
                String measureStr = (String) mapTemp.get("MeasureDate");  //测量时间
            }
        } else {
            //错误提示
            j.put("errmsg", mapResult.get("errmsg"));
            j.put("code", mapResult.get("code"));
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:getMeasureByEquipKey')")
    @ApiOperation("根据key获取某个油井测点列表")
    @GetMapping("getMeasureByEquipKey")
    public Results getMeasureByEquipKey(String equipKey){
        JSONObject j = new JSONObject();
        String url = configService.getHealth();
        //获取设备的测点列表
        Map<String, Object> hashMap = new HashMap<String, Object>();
        hashMap.put("EquipKey", equipKey);
        String eResult = ARDSoapUtil.postSoapResult(url, "GetMeasureByEquipKey", hashMap);
        if ("".equals(eResult)) {
            //返回结果为空
            return Results.succeed("没有测点信息");
        }
        Map<String, Object> map1 = (Map<String, Object>) JSON.parse((String) eResult);
        if ((int) map1.get("code") == 200) {
            j.put("code", map1.get("code"));
            List<Map<String, Object>> list = (List<Map<String, Object>>) JSON.parse((String) map1.get("resdata"));
            j.put("listResult", list);
        }
        return Results.succeed(j);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:GetPartsAlertLeve')")
    @ApiOperation("获取ID获取点位")
    @GetMapping("GetPartsAlertLevel")
    public Results GetPartsAlertLevel(Integer id){
        List<SysConfig> sysConfigs = configService.getAccPwd();
        String account = null,password = null,url = null;
        for (int i = 0; i < sysConfigs.size(); i++) {
            SysConfig sysConfig = sysConfigs.get(i);
            if("eqHealthUrl".equals(sysConfig.getConfigKey())){
                url = sysConfig.getConfigValue();
            }
            if("eqHealthAccount".equals(sysConfig.getConfigKey())){
                account = sysConfig.getConfigValue();
            }
            if("eqHealthPassword".equals(sysConfig.getConfigKey())){
                password = sysConfig.getConfigValue();
            }
        }
        String tokenUrl = url+"/RoadFlowApi/Home/ValidLogin";
        Map<String, Object> loginResult = EquipmentsHealthClient.getToken(tokenUrl, account, password);
        String token = (String) ((Map<String, Object>) ((Map<String, Object>) loginResult.get("data")).get("data")).get("token");
        String GetPartsAlertLeveUrl = url + "/RoadFlowApi/ZX/MeasureData/GetPartsAlertLevel";
        Map<String, Object> map = EquipmentsHealthClient.GetPartsAlertLeve(GetPartsAlertLeveUrl, token,id);
        return Results.succeed(map);
    }
 
    @PreAuthorize("@ss.hasPermi('sy:syCar:GetEquipmentAlertInfo')")
    @ApiOperation("根据ID获取详细说明")
    @GetMapping("GetEquipmentAlertInfo")
    public  Results GetEquipmentAlertInfo(GetEquipmentAlertInfoParam param){
        Integer id = param.getId();
        String key = param.getPosition();
        List<SysConfig> sysConfigs = configService.getAccPwd();
        String account = null,password = null,url = null;
        for (int i = 0; i < sysConfigs.size(); i++) {
            SysConfig sysConfig = sysConfigs.get(i);
            if("eqHealthUrl".equals(sysConfig.getConfigKey())){
                url = sysConfig.getConfigValue();
            }
            if("eqHealthAccount".equals(sysConfig.getConfigKey())){
                account = sysConfig.getConfigValue();
            }
            if("eqHealthPassword".equals(sysConfig.getConfigKey())){
                password = sysConfig.getConfigValue();
            }
        }
        String tokenUrl = url+"/RoadFlowApi/Home/ValidLogin";
        Map<String, Object> loginResult = EquipmentsHealthClient.getToken(tokenUrl, account, password);
        String token = (String) ((Map<String, Object>) ((Map<String, Object>) loginResult.get("data")).get("data")).get("token");
        String GetEquipmentAlertInfoUrl = url + "/RoadFlowApi/ZX/MeasureData/GetEquipmentAlertInfo";
        Map<String, Object> map = EquipmentsHealthClient.GetEquipmentAlertInfo(GetEquipmentAlertInfoUrl, token,id);
        List<Object> list = (List<Object>) ((Map<String, Object>) map.get("data")).get("rows");
        List<Map<String,Object>> rList = new ArrayList<>();
        if(list.size()>0){
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> listMap = (Map<String, Object>) list.get(i);
                String position = (String) listMap.get("position");
                if(key.equals(position)){
                    rList.add(listMap);
                }
            }
        }
        return Results.succeed(rList);
    }
}