From 39a88b3fd870ad8a65f356561b42d465c4f2fc42 Mon Sep 17 00:00:00 2001 From: aijinhui <aijinhui> Date: 星期二, 26 九月 2023 09:35:28 +0800 Subject: [PATCH] 设备健康列表 --- ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | 484 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 473 insertions(+), 11 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 fa34022..6637e42 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,8 +1,25 @@ 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; @@ -13,9 +30,10 @@ 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; +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.*; /** * @author Administrator @@ -28,18 +46,166 @@ @Autowired ISysConfigService configService; - @PreAuthorize("@ss.hasPermi('sy:syCar:getSDKCarPositionByRight')") + @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鎴栬�呭綋鍓嶅強鎵�灞炰笅绾х殑鎵�鏈塪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); + //绛夌骇 + 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); + //寰幆鏌ヨ鍑鸿鐢ㄦ埛鐨勬墍鏈変笂绾D + 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++) { + //璁惧鐨勯儴闂↖D + 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)); + //寰幆鏈�缁圠ist鍒ゆ柇鏄惁鏈夎鏁版嵁鐨勭埗绾э紝濡傛灉娌℃湁灏卞~杩涘幓 + 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) && id==null){ + 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.error("鏌ヨ澶辫触锛�"); + return Results.succeed("娌℃湁璁惧淇℃伅"); } Map<String, Object> mapResult = (Map<String, Object>) JSON.parse((String) result); if ((int) mapResult.get("code") == 200) { @@ -48,11 +214,11 @@ 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姝e父 1娉ㄦ剰 2涓ラ噸 - String measureDate = (String) mapTemp.get("MeasureDate"); //鏈�杩戜竴娆℃祴閲忔椂闂� +// 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姝e父 1娉ㄦ剰 2涓ラ噸 +// String measureDate = (String) mapTemp.get("MeasureDate"); //鏈�杩戜竴娆℃祴閲忔椂闂� j.put(id + "", mapTemp); } } else { @@ -62,4 +228,300 @@ } 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姝e父 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); + } } -- Gitblit v1.9.3