aijinhui
2023-09-06 cfa36565f54f4274e415af9899db2aedadbd7b76
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
package com.ruoyi.health.controller;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.system.service.ISysConfigService;
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 java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * @author Administrator
 */
@RestController
@RequestMapping("/health")
@Api(tags = "设备健康管理")
public class HealthController {
 
    @Autowired
    ISysConfigService configService;
 
    @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.error("没有设备信息");
        }
        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
                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("获取某个油井测点列表")
    @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.error("没有设备信息");
        }
        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.error("没有测点信息");
            }
            //获取设备的测点列表
            Map<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put("EquipKey", equipKey);
            String eResult = ARDSoapUtil.postSoapResult(url, "GetMeasureByEquipKey", hashMap);
            if ("".equals(eResult)) {
                //返回结果为空
                return Results.error("没有测点信息");
            }
            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);
            } 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);
    }
 
}