From d3fa75d27b2169cc0fffe6b8f0079e49dfa8c85f Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 19 九月 2023 16:27:54 +0800
Subject: [PATCH] 优化日志
---
ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 102 insertions(+), 0 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 b1385a1..f2bc7f7 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,22 @@
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.ArdAlarmpointsWell;
+import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo;
+import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService;
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,6 +27,7 @@
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;
@@ -36,6 +46,98 @@
@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;
+ 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)){
+ String[] ancestorsArray = ancestors.split(",");
+ int max = ancestorsArray.length;
+ jsonObject.put("id",listResult.get(i).get("id"));
+ jsonObject.put("EquipName",listResult.get(i).get("EquipName"));
+ jsonObject.put("EquipNumber",listResult.get(i).get("EquipNumber"));
+ jsonObject.put("EquipLevel",listResult.get(i).get("EquipLevel"));
+ jsonObject.put("MeasureDate",listResult.get(i).get("MeasureDate"));
+ jsonObject.put("EquipKey",listResult.get(i).get("EquipKey"));
+ jsonObject.put("longitude",list.get(j).getLongitude());
+ jsonObject.put("latitude",list.get(j).getLatitude());
+ jsonObject.put("altitude",list.get(j).getAltitude());
+ jsonObject.put("deptId",list.get(j).getDeptId());
+ jsonObject.put("deptName",list.get(j).getDeptName());
+ jsonObject.put("parentId",list.get(j).getParentId());
+ jsonObject.put("ancestors",list.get(j).getAncestors());
+ jsonObject.put("tier",max);
+ jsonArray.add(jsonObject);
+ 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;
+ JSONObject j = new JSONObject();
+ j.put("count0",count0);
+ j.put("count1",count1);
+ j.put("count2",count2);
+ return Results.succeed(jsonArray);
+ } else {
+ //閿欒鎻愮ず
+ return Results.error((String) mapResult.get("errmsg"));
+ }
+ }
+
@PreAuthorize("@ss.hasPermi('sy:syCar:getEquipmentList')")
@ApiOperation("鑾峰彇璁惧鍒楄〃")
@GetMapping("getEquipmentList")
--
Gitblit v1.9.3