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);
|
}
|
|
}
|