From 9a43e3aecfe477dfeae2a32ab758a2f5739614fb Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 19 九月 2023 16:58:33 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | 251 +++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 236 insertions(+), 15 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
index 25a597c..ff86ec3 100644
--- a/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
+++ b/ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
@@ -1,13 +1,24 @@
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.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;
@@ -18,8 +29,10 @@
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -34,6 +47,160 @@
@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(){
+ String usersId = SecurityUtils.getUserId();
+ //鏍规嵁userId鏌ヨ閮ㄩ棬Id
+ SysUser sysUser = sysUserService.selectUserById(usersId);
+ //鏍规嵁褰撳墠deptId鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪eptId
+ List<Long> deptList = sysDeptService.deptIdBySub(sysUser.getDeptId());
+ //鏍规嵁deptId鑾峰彇瀵瑰簲鎵�鏈夊叴瓒g偣鏁版嵁
+ 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);
+ JSONArray jsonArray = new JSONArray();
+ //ancestors瀛楁鏈�闀跨殑鏁版嵁
+ String longest = "";
+ //绛夌骇
+ int count0 = 0,count1 = 0,count2 = 0;
+ //瑁呮暟鎹�
+ List<HealthVo> healthVos = 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++) {
+ JSONObject jsonObject = new JSONObject();
+ String equipNumber = (String) listResult.get(i).get("EquipNumber");
+ if(equipNumber!=null){
+ for (int j = 0; j < list.size(); j++) {
+ String ancestors = list.get(j).getAncestors();
+ if (ancestors.length() > longest.length()) {
+ longest = ancestors;
+ }
+ String wellId = list.get(j).getWellId();
+ if(wellId!=null){
+ if(wellId.equals(equipNumber)){
+ //杩斿洖璁惧鏁版嵁
+ HealthVo healthVo = new HealthVo();
+ healthVo.setId((Integer) listResult.get(i).get("id"));
+ healthVo.setEquipName((String) listResult.get(i).get("EquipName"));
+ healthVo.setEquipNumber((String) listResult.get(i).get("EquipNumber"));
+ healthVo.setEquipLevel((String) listResult.get(i).get("EquipLevel"));
+ healthVo.setEquipKey((String) listResult.get(i).get("EquipKey"));
+ healthVo.setMeasureDate((String) listResult.get(i).get("MeasureDate"));
+ healthVo.setLongitude(list.get(j).getLongitude());
+ healthVo.setLatitude(list.get(j).getLatitude());
+ healthVo.setAltitude(list.get(j).getAltitude());
+ healthVo.setDeptId(list.get(j).getDeptId());
+ healthVos.add(healthVo);
+ 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;
+ }
+ }
+ }
+ }
+ }
+ //鐢ㄩ�楀彿鍒嗛殧瀛楃鍚庣殑size涓烘渶澶х殑缁撴瀯灞傛暟
+ String[] ancestorsArray = longest.split(",");
+ int max = ancestorsArray.length;
+ //鑾峰彇閮ㄩ棬灞傜骇
+ List<SysDept> sysDepts = sysDeptService.all();
+ List<TreeSelectWell> tree = sysDeptService.wellTree(sysDepts);
+ //寰幆鏁版嵁鎸傚湪鍒伴儴闂ㄥ眰绾т笅
+ for (int i = 0; i < healthVos.size(); i++) {
+ HealthVo healthVo = healthVos.get(i);
+ Long deptId = healthVo.getDeptId();
+ //寰幆鏍戠粨鏋�
+ for (int j = 0; j < tree.size(); j++) {
+ //濡傛灉绗竴灞傚尮閰嶈祴鍊�
+ if(deptId.equals(tree.get(j).getId())){
+ tree.get(j).getWell().add(healthVo);
+ break;
+ }else {
+ //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗簩灞�
+ if(tree.get(j).getChildren().size()>0){
+ for (int k = 0; k < tree.get(j).getChildren().size(); k++) {
+ //濡傛灉绗簩灞傚尮閰�
+ if(deptId.equals(tree.get(j).getChildren().get(k).getId())){
+ tree.get(j).getChildren().get(k).getWell().add(healthVo);
+ break;
+ }else {
+ //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗笁灞�
+ if(tree.get(j).getChildren().get(k).getChildren().size()>0){
+ for (int l = 0; l < tree.get(j).getChildren().get(k).getChildren().size(); l++) {
+ //濡傛灉绗笁灞傚尮閰�
+ if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getId())){
+ tree.get(j).getChildren().get(k).getChildren().get(l).getWell().add(healthVo);
+ break;
+ }else {
+ //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗洓灞�
+ if(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().size()>0){
+ for (int m = 0; m < tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().size(); m++) {
+ //濡傛灉绗洓灞傚尮閰�
+ if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getId())){
+ tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getWell().add(healthVo);
+ break;
+ }else {
+ //涓嶅尮閰嶄笖children澶т簬0鏌ヨ绗簲灞�
+ if(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().size()>0){
+ for (int n = 0; n < tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().size(); n++) {
+ //濡傛灉绗簲灞傚尮閰�
+ if(deptId.equals(tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().get(n).getId())){
+ tree.get(j).getChildren().get(k).getChildren().get(l).getChildren().get(m).getChildren().get(n).getWell().add(healthVo);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ 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("鑾峰彇璁惧鍒楄〃")
@@ -70,7 +237,7 @@
}
@PreAuthorize("@ss.hasPermi('sy:syCar:getMeasureByEquipName')")
- @ApiOperation("鑾峰彇鏌愪釜娌逛簳娴嬬偣鍒楄〃")
+ @ApiOperation("鏍规嵁name鑾峰彇鏌愪釜娌逛簳娴嬬偣鍒楄〃")
@GetMapping("getMeasureByEquipName")
public Results getMeasureByEquipName(String equipNumber){
String url = configService.getHealth();
@@ -272,36 +439,90 @@
}
@PreAuthorize("@ss.hasPermi('sy:syCar:getMeasureByEquipKey')")
- @ApiOperation("鑾峰彇鏌愪釜娌逛簳娴嬬偣鍒楄〃")
+ @ApiOperation("鏍规嵁key鑾峰彇鏌愪釜娌逛簳娴嬬偣鍒楄〃")
@GetMapping("getMeasureByEquipKey")
- public Results getMeasureByEquipKey(GetFMTrendParam getFMTrendParam){
+ public Results getMeasureByEquipKey(String equipKey){
+ JSONObject j = new JSONObject();
String url = configService.getHealth();
-
- 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"));
+ j.put("listResult", list);
+ }
+ return Results.succeed(j);
}
@PreAuthorize("@ss.hasPermi('sy:syCar:GetPartsAlertLeve')")
- @ApiOperation("鑾峰彇鐐�")
- @GetMapping("GetPartsAlertLeve")
- public Results GetPartsAlertLeve(){
+ @ApiOperation("鑾峰彇ID鑾峰彇鐐逛綅")
+ @GetMapping("GetPartsAlertLevel")
+ public Results GetPartsAlertLevel(Integer id){
List<SysConfig> sysConfigs = configService.getAccPwd();
- String acc = null,pwd = null,hu = null;
+ 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())){
- hu = sysConfig.getConfigValue();
+ url = sysConfig.getConfigValue();
}
if("eqHealthAccount".equals(sysConfig.getConfigKey())){
- acc = sysConfig.getConfigValue();
+ account = sysConfig.getConfigValue();
}
if("eqHealthPassword".equals(sysConfig.getConfigKey())){
- pwd = sysConfig.getConfigValue();
+ password = sysConfig.getConfigValue();
}
}
- Map<String, Object> loginResult = EquipmentsHealthClient.getToken(hu, acc, pwd);
+ 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 = hu + "/RoadFlowApi/ZX/MeasureData/GetPartsAlertLeve";
- Map<String, Object> map = EquipmentsHealthClient.GetPartsAlertLeve(GetPartsAlertLeveUrl, 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);
+ }
}
--
Gitblit v1.9.3