lv.wenbin пре 1 година
родитељ
комит
cff1c9aee2

+ 66 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/CommonController.java

@@ -0,0 +1,66 @@
+/*
+ * 文 件 名:  DimTableController
+ * 版    权:  浩鲸云计算科技股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2024/7/30
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.ruoyi.ems.controller;
+
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.ems.domain.ElecValencyType;
+import com.ruoyi.ems.domain.EmsCls;
+import com.ruoyi.ems.domain.vo.TreeEntity;
+import com.ruoyi.ems.service.IElecValencyTypeService;
+import com.ruoyi.ems.service.IEmsClsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 公共数据接口
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2024/7/30]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+@RestController
+@RequestMapping("/common")
+public class CommonController extends BaseController {
+    @Autowired
+    private IElecValencyTypeService valencyTypeService;
+
+    @Autowired
+    private IEmsClsService emsClsService;
+
+    /**
+     * 电价分类
+     *
+     * @return 分类列表
+     */
+    @GetMapping(value = "/elecvalency/type")
+    public AjaxResult getElecValencyType() {
+        List<ElecValencyType> types = valencyTypeService.selectElecValencyTypeList(new ElecValencyType());
+        return success(types);
+    }
+
+    /**
+     * 电价分类
+     *
+     * @return 分类列表
+     */
+    @GetMapping(value = "/emscls/tree")
+    public AjaxResult getEmsClsTree() {
+        List<TreeEntity> types = emsClsService.selectEmsClsTreeList(new EmsCls());
+        return success(types);
+    }
+}

+ 0 - 16
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/ElecValencyController.java

@@ -8,9 +8,7 @@ import com.ruoyi.common.log.annotation.Log;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.ems.domain.ElecValencyConfig;
 import com.ruoyi.ems.domain.ElecValencyConfig;
-import com.ruoyi.ems.domain.ElecValencyType;
 import com.ruoyi.ems.service.IElecValencyConfigService;
 import com.ruoyi.ems.service.IElecValencyConfigService;
-import com.ruoyi.ems.service.IElecValencyTypeService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -36,9 +34,6 @@ public class ElecValencyController extends BaseController {
     @Autowired
     @Autowired
     private IElecValencyConfigService configService;
     private IElecValencyConfigService configService;
 
 
-    @Autowired
-    private IElecValencyTypeService valencyTypeService;
-
     /**
     /**
      * 查询电价配置列表
      * 查询电价配置列表
      */
      */
@@ -110,15 +105,4 @@ public class ElecValencyController extends BaseController {
         List<ElecValencyConfig> list = configService.selectElecValencyConfigList(new ElecValencyConfig());
         List<ElecValencyConfig> list = configService.selectElecValencyConfigList(new ElecValencyConfig());
         return success(list);
         return success(list);
     }
     }
-
-    /**
-     * 电价分类
-     *
-     * @return 分类列表
-     */
-    @GetMapping(value = "/type")
-    public AjaxResult getElecValencyType() {
-        List<ElecValencyType> types = valencyTypeService.selectElecValencyTypeList(new ElecValencyType());
-        return success(types);
-    }
 }
 }

+ 29 - 12
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/FacsController.java

@@ -1,26 +1,28 @@
 package com.ruoyi.ems.controller;
 package com.ruoyi.ems.controller;
 
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
+import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.ems.domain.EmsFacs;
 import com.ruoyi.ems.domain.EmsFacs;
 import com.ruoyi.ems.service.IEmsFacsService;
 import com.ruoyi.ems.service.IEmsFacsService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
-import com.ruoyi.common.log.annotation.Log;
-import com.ruoyi.common.log.enums.BusinessType;
-import com.ruoyi.common.security.annotation.RequiresPermissions;
-import com.ruoyi.common.core.web.controller.BaseController;
-import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.web.page.TableDataInfo;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 
 
 /**
 /**
  * 能源设施/系统Controller
  * 能源设施/系统Controller
@@ -102,4 +104,19 @@ public class FacsController extends BaseController
     {
     {
         return toAjax(emsFacsService.deleteEmsFacsByIds(ids));
         return toAjax(emsFacsService.deleteEmsFacsByIds(ids));
     }
     }
+
+    /**
+     * 获取所有能源设施/系统列表
+     * @return 能源设施/系统列表
+     */
+    @GetMapping("/listall")
+    public AjaxResult listAll(@RequestParam(name = "refArea", required = false) String refArea) {
+        EmsFacs emsFacs = new EmsFacs();
+
+        if (StringUtils.isNotBlank(refArea)) {
+            emsFacs.setRefArea(refArea);
+        }
+
+        return success(emsFacsService.selectEmsFacsList(emsFacs));
+    }
 }
 }

+ 10 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/FacsTypeController.java

@@ -48,6 +48,16 @@ public class FacsTypeController extends BaseController
     }
     }
 
 
     /**
     /**
+     * 获取所有能源设施/系统分类
+     * @return 能源设施/系统分类列表
+     */
+    @GetMapping("/listall")
+    public AjaxResult listAll() {
+        List<EmsFacsType> list = emsFacsTypeService.selectFacsTypeList(new EmsFacsType());
+        return success(list);
+    }
+
+    /**
      * 导出能源设施/系统分类列表
      * 导出能源设施/系统分类列表
      */
      */
     @RequiresPermissions("basecfg:facstype:export")
     @RequiresPermissions("basecfg:facstype:export")

+ 15 - 9
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/EmsCls.java

@@ -1,15 +1,17 @@
 package com.ruoyi.ems.domain;
 package com.ruoyi.ems.domain;
 
 
+import com.ruoyi.common.core.web.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.commons.lang3.builder.ToStringStyle;
-import com.ruoyi.common.core.annotation.Excel;
-import com.ruoyi.common.core.web.domain.BaseEntity;
+
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
 /**
  * 能源分类对象 dim_gb_ems_cls
  * 能源分类对象 dim_gb_ems_cls
  * 
  * 
  * @author ruoyi
  * @author ruoyi
- * @date 2024-07-10
+ * @date 2024-07-30
  */
  */
 public class EmsCls extends BaseEntity
 public class EmsCls extends BaseEntity
 {
 {
@@ -19,29 +21,25 @@ public class EmsCls extends BaseEntity
     private Long id;
     private Long id;
 
 
     /** 能源代码 */
     /** 能源代码 */
-    @Excel(name = "能源代码")
     private String code;
     private String code;
 
 
     /** 能源种类 */
     /** 能源种类 */
-    @Excel(name = "能源种类")
     private String name;
     private String name;
 
 
     /** 说明 */
     /** 说明 */
-    @Excel(name = "说明")
     private String desc;
     private String desc;
 
 
     /** 分类层级 1-大类,2-中类,3-小类 */
     /** 分类层级 1-大类,2-中类,3-小类 */
-    @Excel(name = "分类层级 1-大类,2-中类,3-小类")
     private Long level;
     private Long level;
 
 
     /** 父类代码 */
     /** 父类代码 */
-    @Excel(name = "父类代码")
     private String parentCode;
     private String parentCode;
 
 
     /** 数据版本 */
     /** 数据版本 */
-    @Excel(name = "数据版本")
     private String version;
     private String version;
 
 
+    private List<EmsCls> children = new ArrayList<EmsCls>();
+
     public void setId(Long id) 
     public void setId(Long id) 
     {
     {
         this.id = id;
         this.id = id;
@@ -106,6 +104,14 @@ public class EmsCls extends BaseEntity
         return version;
         return version;
     }
     }
 
 
+    public List<EmsCls> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<EmsCls> children) {
+        this.children = children;
+    }
+
     @Override
     @Override
     public String toString() {
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 25 - 25
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/TreeEntity.java

@@ -14,11 +14,10 @@ import com.fasterxml.jackson.annotation.JsonInclude;
 import com.ruoyi.ems.domain.Area;
 import com.ruoyi.ems.domain.Area;
 import com.ruoyi.ems.domain.AreaBuilding;
 import com.ruoyi.ems.domain.AreaBuilding;
 import com.ruoyi.ems.domain.AreaBuildingZoning;
 import com.ruoyi.ems.domain.AreaBuildingZoning;
+import com.ruoyi.ems.domain.EmsCls;
 import com.ruoyi.ems.domain.common.AreaTier;
 import com.ruoyi.ems.domain.common.AreaTier;
-import com.ruoyi.system.api.domain.SysDept;
 
 
 import java.util.List;
 import java.util.List;
-import java.util.stream.Collectors;
 
 
 /**
 /**
  * <一句话功能简述>
  * <一句话功能简述>
@@ -30,61 +29,64 @@ import java.util.stream.Collectors;
  * @since [产品/模块版本]
  * @since [产品/模块版本]
  */
  */
 public class TreeEntity {
 public class TreeEntity {
-    /** 节点ID */
+    /**
+     * 节点ID
+     */
     private String id;
     private String id;
 
 
-    /** 节点名称 */
+    /**
+     * 节点名称
+     */
     private String label;
     private String label;
 
 
     private String tier;
     private String tier;
 
 
-    /** 子节点 */
+    /**
+     * 子节点
+     */
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     private List<TreeEntity> children;
     private List<TreeEntity> children;
 
 
-    public TreeEntity()
-    {
+    public TreeEntity() {
 
 
     }
     }
 
 
-    public TreeEntity(Area area)
-    {
+    public TreeEntity(Area area) {
         this.id = area.getAreaCode();
         this.id = area.getAreaCode();
         this.label = area.getAreaName();
         this.label = area.getAreaName();
         this.tier = AreaTier.Area.name();
         this.tier = AreaTier.Area.name();
     }
     }
 
 
-    public TreeEntity(AreaBuilding building)
-    {
+    public TreeEntity(AreaBuilding building) {
         this.id = building.getBldgCode();
         this.id = building.getBldgCode();
         this.label = building.getBldgName();
         this.label = building.getBldgName();
         this.tier = AreaTier.Building.name();
         this.tier = AreaTier.Building.name();
     }
     }
 
 
-    public TreeEntity(AreaBuildingZoning buildingZoning)
-    {
+    public TreeEntity(AreaBuildingZoning buildingZoning) {
         this.id = buildingZoning.getZoningCode();
         this.id = buildingZoning.getZoningCode();
         this.label = buildingZoning.getZoningName();
         this.label = buildingZoning.getZoningName();
         this.tier = AreaTier.Zoning.name();
         this.tier = AreaTier.Zoning.name();
     }
     }
 
 
-    public String getId()
-    {
+    public TreeEntity(EmsCls emsCls) {
+        this.id = emsCls.getCode();
+        this.label = emsCls.getName();
+    }
+
+    public String getId() {
         return id;
         return id;
     }
     }
 
 
-    public void setId(String id)
-    {
+    public void setId(String id) {
         this.id = id;
         this.id = id;
     }
     }
 
 
-    public String getLabel()
-    {
+    public String getLabel() {
         return label;
         return label;
     }
     }
 
 
-    public void setLabel(String label)
-    {
+    public void setLabel(String label) {
         this.label = label;
         this.label = label;
     }
     }
 
 
@@ -96,13 +98,11 @@ public class TreeEntity {
         this.tier = tier;
         this.tier = tier;
     }
     }
 
 
-    public List<TreeEntity> getChildren()
-    {
+    public List<TreeEntity> getChildren() {
         return children;
         return children;
     }
     }
 
 
-    public void setChildren(List<TreeEntity> children)
-    {
+    public void setChildren(List<TreeEntity> children) {
         this.children = children;
         this.children = children;
     }
     }
 }
 }

+ 13 - 13
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsClsMapper.java

@@ -1,19 +1,19 @@
 package com.ruoyi.ems.mapper;
 package com.ruoyi.ems.mapper;
 
 
-import java.util.List;
 import com.ruoyi.ems.domain.EmsCls;
 import com.ruoyi.ems.domain.EmsCls;
 
 
+import java.util.List;
+
 /**
 /**
  * 能源分类Mapper接口
  * 能源分类Mapper接口
- * 
+ *
  * @author ruoyi
  * @author ruoyi
- * @date 2024-07-10
+ * @date 2024-07-30
  */
  */
-public interface EmsClsMapper
-{
+public interface EmsClsMapper {
     /**
     /**
      * 查询能源分类
      * 查询能源分类
-     * 
+     *
      * @param id 能源分类主键
      * @param id 能源分类主键
      * @return 能源分类
      * @return 能源分类
      */
      */
@@ -21,7 +21,7 @@ public interface EmsClsMapper
 
 
     /**
     /**
      * 查询能源分类列表
      * 查询能源分类列表
-     * 
+     *
      * @param emsCls 能源分类
      * @param emsCls 能源分类
      * @return 能源分类集合
      * @return 能源分类集合
      */
      */
@@ -29,7 +29,7 @@ public interface EmsClsMapper
 
 
     /**
     /**
      * 新增能源分类
      * 新增能源分类
-     * 
+     *
      * @param emsCls 能源分类
      * @param emsCls 能源分类
      * @return 结果
      * @return 结果
      */
      */
@@ -37,15 +37,15 @@ public interface EmsClsMapper
 
 
     /**
     /**
      * 修改能源分类
      * 修改能源分类
-     * 
-     * @param emsCls 能源分类
+     *
+     * @param dimGbEmsCls 能源分类
      * @return 结果
      * @return 结果
      */
      */
-    int updateEmsCls(EmsCls emsCls);
+    int updateEmsCls(EmsCls dimGbEmsCls);
 
 
     /**
     /**
      * 删除能源分类
      * 删除能源分类
-     * 
+     *
      * @param id 能源分类主键
      * @param id 能源分类主键
      * @return 结果
      * @return 结果
      */
      */
@@ -53,7 +53,7 @@ public interface EmsClsMapper
 
 
     /**
     /**
      * 批量删除能源分类
      * 批量删除能源分类
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @param ids 需要删除的数据主键集合
      * @return 结果
      * @return 结果
      */
      */

+ 10 - 2
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsClsService.java

@@ -1,8 +1,9 @@
 package com.ruoyi.ems.service;
 package com.ruoyi.ems.service;
 
 
-import java.util.List;
-
 import com.ruoyi.ems.domain.EmsCls;
 import com.ruoyi.ems.domain.EmsCls;
+import com.ruoyi.ems.domain.vo.TreeEntity;
+
+import java.util.List;
 
 
 /**
 /**
  * 能源分类Service接口
  * 能源分类Service接口
@@ -28,6 +29,13 @@ public interface IEmsClsService {
     List<EmsCls> selectEmsClsList(EmsCls emsCls);
     List<EmsCls> selectEmsClsList(EmsCls emsCls);
 
 
     /**
     /**
+     * 能源分类树
+     * @param emsCls 条件
+     * @return 树
+     */
+    List<TreeEntity> selectEmsClsTreeList(EmsCls emsCls);
+
+    /**
      * 新增能源分类
      * 新增能源分类
      *
      *
      * @param emsCls 能源分类
      * @param emsCls 能源分类

+ 54 - 23
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsClsServiceImpl.java

@@ -1,94 +1,125 @@
 package com.ruoyi.ems.service.impl;
 package com.ruoyi.ems.service.impl;
 
 
-import java.util.List;
-
+import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.ems.domain.EmsCls;
 import com.ruoyi.ems.domain.EmsCls;
+import com.ruoyi.ems.domain.vo.TreeEntity;
 import com.ruoyi.ems.mapper.EmsClsMapper;
 import com.ruoyi.ems.mapper.EmsClsMapper;
 import com.ruoyi.ems.service.IEmsClsService;
 import com.ruoyi.ems.service.IEmsClsService;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
 /**
  * 能源分类Service业务层处理
  * 能源分类Service业务层处理
- * 
+ *
  * @author ruoyi
  * @author ruoyi
  * @date 2024-07-10
  * @date 2024-07-10
  */
  */
 @Service
 @Service
-public class EmsClsServiceImpl implements IEmsClsService
-{
+public class EmsClsServiceImpl implements IEmsClsService {
     @Autowired
     @Autowired
     private EmsClsMapper emsClsMapper;
     private EmsClsMapper emsClsMapper;
 
 
     /**
     /**
      * 查询能源分类
      * 查询能源分类
-     * 
+     *
      * @param id 能源分类主键
      * @param id 能源分类主键
      * @return 能源分类
      * @return 能源分类
      */
      */
     @Override
     @Override
-    public EmsCls selectEmsClsById(Long id)
-    {
+    public EmsCls selectEmsClsById(Long id) {
         return emsClsMapper.selectEmsClsById(id);
         return emsClsMapper.selectEmsClsById(id);
     }
     }
 
 
     /**
     /**
      * 查询能源分类列表
      * 查询能源分类列表
-     * 
+     *
      * @param emsCls 能源分类
      * @param emsCls 能源分类
      * @return 能源分类
      * @return 能源分类
      */
      */
     @Override
     @Override
-    public List<EmsCls> selectEmsClsList(EmsCls emsCls)
-    {
+    public List<EmsCls> selectEmsClsList(EmsCls emsCls) {
         return emsClsMapper.selectEmsClsList(emsCls);
         return emsClsMapper.selectEmsClsList(emsCls);
     }
     }
 
 
+    @Override
+    public List<TreeEntity> selectEmsClsTreeList(EmsCls emsCls) {
+        List<EmsCls> list = emsClsMapper.selectEmsClsList(emsCls);
+        return buildEmsClsTree(list);
+    }
+
     /**
     /**
      * 新增能源分类
      * 新增能源分类
-     * 
+     *
      * @param emsCls 能源分类
      * @param emsCls 能源分类
      * @return 结果
      * @return 结果
      */
      */
     @Override
     @Override
-    public int insertEmsCls(EmsCls emsCls)
-    {
+    public int insertEmsCls(EmsCls emsCls) {
         return emsClsMapper.insertEmsCls(emsCls);
         return emsClsMapper.insertEmsCls(emsCls);
     }
     }
 
 
     /**
     /**
      * 修改能源分类
      * 修改能源分类
-     * 
+     *
      * @param emsCls 能源分类
      * @param emsCls 能源分类
      * @return 结果
      * @return 结果
      */
      */
     @Override
     @Override
-    public int updateEmsCls(EmsCls emsCls)
-    {
+    public int updateEmsCls(EmsCls emsCls) {
         return emsClsMapper.updateEmsCls(emsCls);
         return emsClsMapper.updateEmsCls(emsCls);
     }
     }
 
 
     /**
     /**
      * 批量删除能源分类
      * 批量删除能源分类
-     * 
+     *
      * @param ids 需要删除的能源分类主键
      * @param ids 需要删除的能源分类主键
      * @return 结果
      * @return 结果
      */
      */
     @Override
     @Override
-    public int deleteEmsClsByIds(Long[] ids)
-    {
+    public int deleteEmsClsByIds(Long[] ids) {
         return emsClsMapper.deleteEmsClsByIds(ids);
         return emsClsMapper.deleteEmsClsByIds(ids);
     }
     }
 
 
     /**
     /**
      * 删除能源分类信息
      * 删除能源分类信息
-     * 
+     *
      * @param id 能源分类主键
      * @param id 能源分类主键
      * @return 结果
      * @return 结果
      */
      */
     @Override
     @Override
-    public int deleteEmsClsById(Long id)
-    {
+    public int deleteEmsClsById(Long id) {
         return emsClsMapper.deleteEmsClsById(id);
         return emsClsMapper.deleteEmsClsById(id);
     }
     }
+
+    public List<TreeEntity> buildEmsClsTree(List<EmsCls> list) {
+        Map<String, List<EmsCls>> groupedByParent = list.stream().collect(Collectors.groupingBy(EmsCls::getParentCode));
+        List<TreeEntity> retCols = buildEmsClsTreeSub("-1", groupedByParent);
+        retCols.sort(Comparator.comparing(TreeEntity::getId));
+        return retCols;
+    }
+
+    public List<TreeEntity> buildEmsClsTreeSub(String code, Map<String, List<EmsCls>> map) {
+        List<TreeEntity> retList = new ArrayList<>();
+        List<EmsCls> list = map.get(code);
+
+        if (CollectionUtils.isNotEmpty(list)) {
+            for (EmsCls item : list) {
+                TreeEntity tree = new TreeEntity(item);
+                tree.setChildren(buildEmsClsTreeSub(item.getCode(), map));
+                retList.add(tree);
+            }
+        }
+
+        return retList;
+    }
 }
 }

+ 19 - 19
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsClsMapper.xml

@@ -15,18 +15,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
     </resultMap>
 
 
     <sql id="selectEmsClsVo">
     <sql id="selectEmsClsVo">
-        select id, code, name, desc, level, parent_code, version from dim_gb_ems_cls
+        select `id`, `code`, `name`, `desc`, `level`, `parent_code`, `version` from dim_gb_ems_cls
     </sql>
     </sql>
 
 
     <select id="selectEmsClsList" parameterType="com.ruoyi.ems.domain.EmsCls" resultMap="EmsClsResult">
     <select id="selectEmsClsList" parameterType="com.ruoyi.ems.domain.EmsCls" resultMap="EmsClsResult">
         <include refid="selectEmsClsVo"/>
         <include refid="selectEmsClsVo"/>
         <where>  
         <where>  
-            <if test="code != null  and code != ''"> and code = #{code}</if>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="desc != null  and desc != ''"> and desc = #{desc}</if>
-            <if test="level != null "> and level = #{level}</if>
-            <if test="parentCode != null  and parentCode != ''"> and parent_code = #{parentCode}</if>
-            <if test="version != null  and version != ''"> and version = #{version}</if>
+            <if test="code != null  and code != ''"> and `code` = #{code}</if>
+            <if test="name != null  and name != ''"> and `name` like concat('%', #{name}, '%')</if>
+            <if test="desc != null  and desc != ''"> and `desc` = #{desc}</if>
+            <if test="level != null "> and `level` = #{level}</if>
+            <if test="parentCode != null  and parentCode != ''"> and `parent_code` = #{parentCode}</if>
+            <if test="version != null  and version != ''"> and `version` = #{version}</if>
         </where>
         </where>
     </select>
     </select>
     
     
@@ -38,12 +38,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertEmsCls" parameterType="com.ruoyi.ems.domain.EmsCls" useGeneratedKeys="true" keyProperty="id">
     <insert id="insertEmsCls" parameterType="com.ruoyi.ems.domain.EmsCls" useGeneratedKeys="true" keyProperty="id">
         insert into dim_gb_ems_cls
         insert into dim_gb_ems_cls
         <trim prefix="(" suffix=")" suffixOverrides=",">
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="code != null and code != ''">code,</if>
-            <if test="name != null and name != ''">name,</if>
-            <if test="desc != null">desc,</if>
-            <if test="level != null">level,</if>
-            <if test="parentCode != null">parent_code,</if>
-            <if test="version != null">version,</if>
+            <if test="code != null and code != ''">`code`,</if>
+            <if test="name != null and name != ''">`name`,</if>
+            <if test="desc != null">`desc`,</if>
+            <if test="level != null">`level`,</if>
+            <if test="parentCode != null">`parent_code`,</if>
+            <if test="version != null">`version`,</if>
          </trim>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="code != null and code != ''">#{code},</if>
             <if test="code != null and code != ''">#{code},</if>
@@ -58,12 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateEmsCls" parameterType="com.ruoyi.ems.domain.EmsCls">
     <update id="updateEmsCls" parameterType="com.ruoyi.ems.domain.EmsCls">
         update dim_gb_ems_cls
         update dim_gb_ems_cls
         <trim prefix="SET" suffixOverrides=",">
         <trim prefix="SET" suffixOverrides=",">
-            <if test="code != null and code != ''">code = #{code},</if>
-            <if test="name != null and name != ''">name = #{name},</if>
-            <if test="desc != null">desc = #{desc},</if>
-            <if test="level != null">level = #{level},</if>
-            <if test="parentCode != null">parent_code = #{parentCode},</if>
-            <if test="version != null">version = #{version},</if>
+            <if test="code != null and code != ''">`code` = #{code},</if>
+            <if test="name != null and name != ''">`name` = #{name},</if>
+            <if test="desc != null">`desc` = #{desc},</if>
+            <if test="level != null">`level` = #{level},</if>
+            <if test="parentCode != null">`parent_code` = #{parentCode},</if>
+            <if test="version != null">`version` = #{version},</if>
         </trim>
         </trim>
         where id = #{id}
         where id = #{id}
     </update>
     </update>

+ 2 - 2
ems-cloud/sql/ems_server.sql

@@ -727,11 +727,11 @@ create table sys_electrovalency_config (
 
 
 -- 单一制初始电价数据
 -- 单一制初始电价数据
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3001', 3, '不满1千伏', 0.7624, 1.5296, 1.2747, 0.7624, 0.3445, NULL, NULL);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3001', 3, '不满1千伏', 0.7624, 1.5296, 1.2747, 0.7624, 0.3445, NULL, NULL);
-INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3002', 3, '1-10(20)千伏', 0.7364, 1.4774, 1.2312, 0.7364, 0.3327, NULL, NULL);
+INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3002', 3, '1-10(20)千伏', 0.7364, 1.4774, 1.2312, 0.7364, 0.3327, NULL, NULL);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3003', 3, '35千伏', 0.7114, 1.4273, 1.1894, 0.7114, 0.3214, NULL, NULL);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('3003', 3, '35千伏', 0.7114, 1.4273, 1.1894, 0.7114, 0.3214, NULL, NULL);
 
 
 -- 两部制初始电价数据
 -- 两部制初始电价数据
-INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4001', 4, '1-10(20)千伏', 0.6587, 1.3592, 1.1327, 0.6587, 0.2757, 51.2, 32);
+INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4001', 4, '1-10(20)千伏', 0.6587, 1.3592, 1.1327, 0.6587, 0.2757, 51.2, 32);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4002', 4, '35千伏', 0.6337, 1.3076, 1.0897, 0.6337, 0.2652, 48, 30);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4002', 4, '35千伏', 0.6337, 1.3076, 1.0897, 0.6337, 0.2652, 48, 30);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4003', 4, '110千伏', 0.6087, 1.256, 1.0467, 0.6087, 0.2547, 44.8, 28);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4003', 4, '110千伏', 0.6087, 1.256, 1.0467, 0.6087, 0.2547, 44.8, 28);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4004', 4, '220千伏及以上', 0.5827, 1.2024, 1.002, 0.5827, 0.2439, 41.6, 26);
 INSERT INTO sys_electrovalency_config (`cfg_code`, `elec_type`, `voltage_level`, `degree_price`, `fs_peak_degree_price`, `fs_high_degree_price`, `fs_flat_degree_price`, `fs_low_degree_price`, `max_req_price`, `trans_capacity_price`) VALUES ('4004', 4, '220千伏及以上', 0.5827, 1.2024, 1.002, 0.5827, 0.2439, 41.6, 26);