ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellDeptVo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/HealthVo.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelectWell.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelectWellJson.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellDeptVo.java
@@ -52,7 +52,7 @@ private BigDecimal altitude; private Integer deptId; private Long deptId; private Integer parentId; ard-work/src/main/java/com/ruoyi/health/controller/HealthController.java
@@ -3,9 +3,11 @@ 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.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; @@ -55,6 +57,8 @@ @Autowired private ISysDeptService sysDeptService; @PreAuthorize("@ss.hasPermi('sy:syCar:getEquipmentListByUser')") @ApiOperation("æ ¹æ®æéè·å设å¤å表") @GetMapping("getEquipmentListByUser") @@ -80,8 +84,11 @@ 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"); @@ -94,23 +101,19 @@ 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); //è¿åè®¾å¤æ°æ® 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")){ @@ -127,11 +130,72 @@ //ç¨éå·åéå符åç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); //è·åé¨é¨å±çº§ 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")); ruoyi-common/src/main/java/com/ruoyi/common/core/domain/HealthVo.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,22 @@ package com.ruoyi.common.core.domain; import lombok.Data; import java.math.BigDecimal; @Data public class HealthVo { private Integer id; private String equipName; private String equipNumber; private String equipKey; private String equipLevel; private String measureDate; private Long deptId; private BigDecimal longitude; private BigDecimal latitude; private BigDecimal altitude; } ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelectWell.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,90 @@ package com.ruoyi.common.core.domain; import com.fasterxml.jackson.annotation.JsonInclude; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysMenu; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * Treeselectæ ç»æå®ä½ç±» * * @author ruoyi */ public class TreeSelectWell implements Serializable { private static final long serialVersionUID = 1L; /** èç¹ID */ private Long id; /** èç¹åç§° */ private String label; /** åèç¹ */ @JsonInclude(JsonInclude.Include.NON_EMPTY) private List<TreeSelectWell> children; public List<HealthVo> getWell() { return well; } public void setWell(List<HealthVo> well) { this.well = well; } private List<HealthVo> well = new ArrayList<>(); public TreeSelectWell() { } public TreeSelectWell(SysDept dept) { this.id = dept.getDeptId(); this.label = dept.getDeptName(); this.children = dept.getChildren().stream().map(TreeSelectWell::new).collect(Collectors.toList()); } public TreeSelectWell(SysMenu menu) { this.id = menu.getMenuId(); this.label = menu.getMenuName(); this.children = menu.getChildren().stream().map(TreeSelectWell::new).collect(Collectors.toList()); } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getLabel() { return label; } public void setLabel(String label) { this.label = label; } public List<TreeSelectWell> getChildren() { return children; } public void setChildren(List<TreeSelectWell> children) { this.children = children; } } ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelectWellJson.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,28 @@ package com.ruoyi.common.core.domain; import com.fasterxml.jackson.annotation.JsonInclude; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysMenu; import lombok.Data; import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; /** * Treeselectæ ç»æå®ä½ç±» * * @author ruoyi */ @Data public class TreeSelectWellJson implements Serializable { private static final long serialVersionUID = 1L; List<TreeSelectWell> wellList; int count0; int count1; int count2; } ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java
@@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -53,12 +54,14 @@ private String delFlag; /** ç¶é¨é¨åç§° */ @TableField(exist = false) private String parentName; /** åé¨é¨ */ @TableField(exist = false) private List<SysDept> children = new ArrayList<SysDept>(); @TableField(exist = false) private boolean disabled; public boolean isDisabled() { ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java
@@ -3,7 +3,9 @@ import java.util.List; import java.util.Map; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.TreeSelectWell; import com.ruoyi.common.core.domain.entity.SysDept; /** @@ -131,5 +133,13 @@ */ List<Long> deptIdBySub(Long deptId); List<SysDept> all(); /** * é¢çç»æçæ å½¢ * @param depts * @return */ List<TreeSelectWell> wellTree(List<SysDept> depts); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
@@ -4,6 +4,7 @@ import java.util.stream.Collectors; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.ruoyi.common.core.domain.TreeSelectWell; import org.springframework.stereotype.Service; import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; @@ -351,5 +352,16 @@ return deptList; } @Override public List<SysDept> all() { return deptMapper.selectList(null); } @Override public List<TreeSelectWell> wellTree(List<SysDept> depts) { List<SysDept> deptTrees = buildDeptTree(depts); return deptTrees.stream().map(TreeSelectWell::new).collect(Collectors.toList()); } }