learshaw 3 месяцев назад
Родитель
Сommit
9884f1ed66

+ 80 - 11
ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/EmsObjFlowRelController.java

@@ -9,21 +9,17 @@ import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.ems.domain.EmsObjFlowRel;
 import com.ruoyi.ems.service.IEmsObjFlowRelService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 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.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 能源设施能流关系Controller
- * 
+ *
  * @author ruoyi
  * @date 2024-07-10
  */
@@ -40,6 +36,7 @@ public class EmsObjFlowRelController extends BaseController
      */
     @RequiresPermissions("basecfg:flowrel:list")
     @GetMapping("/list")
+    @ApiOperation("查询能流关系列表")
     public TableDataInfo list(EmsObjFlowRel flowRel)
     {
         startPage();
@@ -52,6 +49,7 @@ public class EmsObjFlowRelController extends BaseController
      */
     @RequiresPermissions("basecfg:flowrel:query")
     @GetMapping(value = "/{id}")
+    @ApiOperation("获取能流关系详情")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
         return success(facsFlowRelService.selectFlowRelById(id));
@@ -63,6 +61,7 @@ public class EmsObjFlowRelController extends BaseController
     @RequiresPermissions("basecfg:flowrel:add")
     @Log(title = "能源设施能流关系", businessType = BusinessType.INSERT)
     @PostMapping
+    @ApiOperation("新增能流关系")
     public AjaxResult add(@RequestBody EmsObjFlowRel facsFlowRel)
     {
         return toAjax(facsFlowRelService.insertFlowRel(facsFlowRel));
@@ -74,6 +73,7 @@ public class EmsObjFlowRelController extends BaseController
     @RequiresPermissions("basecfg:flowrel:edit")
     @Log(title = "能源设施能流关系", businessType = BusinessType.UPDATE)
     @PutMapping
+    @ApiOperation("修改能流关系")
     public AjaxResult edit(@RequestBody EmsObjFlowRel flowRel)
     {
         return toAjax(facsFlowRelService.updateFlowRel(flowRel));
@@ -84,9 +84,78 @@ public class EmsObjFlowRelController extends BaseController
      */
     @RequiresPermissions("basecfg:flowrel:remove")
     @Log(title = "能源设施能流关系", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
+    @DeleteMapping("/{ids}")
+    @ApiOperation("删除能流关系")
     public AjaxResult remove(@PathVariable Long[] ids)
     {
         return toAjax(facsFlowRelService.deleteFlowRelByIds(ids));
     }
-}
+
+    /**
+     * 获取能流拓扑数据
+     */
+    @RequiresPermissions("basecfg:flowrel:list")
+    @GetMapping("/topology")
+    @ApiOperation("获取能流拓扑数据")
+    public AjaxResult getTopology(
+        @ApiParam("区域代码") @RequestParam(required = false) String areaCode,
+        @ApiParam("能源分类代码") @RequestParam(required = false) String emsClsCode)
+    {
+        Map<String, Object> topology = facsFlowRelService.getFlowTopology(areaCode, emsClsCode);
+        return success(topology);
+    }
+
+    /**
+     * 验证能流关系是否存在
+     */
+    @RequiresPermissions("basecfg:flowrel:query")
+    @PostMapping("/validate")
+    @ApiOperation("验证能流关系是否存在")
+    public AjaxResult validate(@RequestBody EmsObjFlowRel flowRel)
+    {
+        boolean exists = facsFlowRelService.checkFlowRelExists(flowRel);
+        return success(exists);
+    }
+
+    /**
+     * 获取上游能流(输入到该对象的能流)
+     */
+    @RequiresPermissions("basecfg:flowrel:list")
+    @GetMapping("/upstream")
+    @ApiOperation("获取上游能流")
+    public AjaxResult getUpstream(
+        @ApiParam("对象代码") @RequestParam String objCode,
+        @ApiParam("对象类型") @RequestParam Integer objType)
+    {
+        List<EmsObjFlowRel> list = facsFlowRelService.getUpstreamFlow(objCode, objType);
+        return success(list);
+    }
+
+    /**
+     * 获取下游能流(从该对象输出的能流)
+     */
+    @RequiresPermissions("basecfg:flowrel:list")
+    @GetMapping("/downstream")
+    @ApiOperation("获取下游能流")
+    public AjaxResult getDownstream(
+        @ApiParam("对象代码") @RequestParam String objCode,
+        @ApiParam("对象类型") @RequestParam Integer objType)
+    {
+        List<EmsObjFlowRel> list = facsFlowRelService.getDownstreamFlow(objCode, objType);
+        return success(list);
+    }
+
+    /**
+     * 获取指定能源类型的流动关系
+     */
+    @RequiresPermissions("basecfg:flowrel:list")
+    @GetMapping("/energytype")
+    @ApiOperation("按能源类型查询能流关系")
+    public AjaxResult getByEnergyType(
+        @ApiParam("能源分类代码") @RequestParam(required = false) String emsClsCode,
+        @ApiParam("区域代码") @RequestParam(required = false) String areaCode)
+    {
+        List<EmsObjFlowRel> list = facsFlowRelService.getFlowRelByEnergyType(emsClsCode, areaCode);
+        return success(list);
+    }
+}

+ 60 - 9
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsObjFlowRel.java

@@ -4,9 +4,11 @@ import com.huashe.common.domain.BaseEntity;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
+import java.math.BigDecimal;
+
 /**
  * 对象能流关系对象 adm_ems_flow_rel
- * 
+ *
  * @author ruoyi
  * @date 2024-07-10
  */
@@ -20,7 +22,7 @@ public class EmsObjFlowRel extends BaseEntity
     /** 能源输出对象 */
     private String exportObj;
 
-    /** 能源输出对象类型 */
+    /** 能源输出对象类型(1-设施 2-设备) */
     private Integer exportObjType;
 
     /** 能源输出对象名称 */
@@ -29,23 +31,33 @@ public class EmsObjFlowRel extends BaseEntity
     /** 能源流入对象 */
     private String inputObj;
 
-    /** 能源流入对象类型 */
+    /** 能源流入对象类型(1-设施 2-设备) */
     private Integer inputObjType;
 
     /** 能源流入对象名称 */
     private String inputObjName;
 
-    /** 能源流动介质 */
+    /** 能源流动介质代码 */
     private String emsCls;
 
     /** 能源流动介质名称 */
     private String emsClsName;
 
-    /**
-     * 能流描述
-     */
+    /** 能流描述 */
     private String flowDesc;
 
+    /** 流动容量/功率 */
+    private BigDecimal flowCapacity;
+
+    /** 容量单位 */
+    private String flowUnit;
+
+    /** 所属区域代码 */
+    private String areaCode;
+
+    /** 启用状态(0-禁用 1-启用) */
+    private Integer enableStatus;
+
     public Long getId() {
         return id;
     }
@@ -126,18 +138,57 @@ public class EmsObjFlowRel extends BaseEntity
         this.flowDesc = flowDesc;
     }
 
+    public BigDecimal getFlowCapacity() {
+        return flowCapacity;
+    }
+
+    public void setFlowCapacity(BigDecimal flowCapacity) {
+        this.flowCapacity = flowCapacity;
+    }
+
+    public String getFlowUnit() {
+        return flowUnit;
+    }
+
+    public void setFlowUnit(String flowUnit) {
+        this.flowUnit = flowUnit;
+    }
+
+    public String getAreaCode() {
+        return areaCode;
+    }
+
+    public void setAreaCode(String areaCode) {
+        this.areaCode = areaCode;
+    }
+
+    public Integer getEnableStatus() {
+        return enableStatus;
+    }
+
+    public void setEnableStatus(Integer enableStatus) {
+        this.enableStatus = enableStatus;
+    }
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
             .append("id", getId())
             .append("exportObj", getExportObj())
             .append("exportObjType", getExportObjType())
+            .append("exportObjName", getExportObjName())
             .append("inputObj", getInputObj())
             .append("inputObjType", getInputObjType())
+            .append("inputObjName", getInputObjName())
             .append("emsCls", getEmsCls())
+            .append("emsClsName", getEmsClsName())
             .append("flowDesc", getFlowDesc())
+            .append("flowCapacity", getFlowCapacity())
+            .append("flowUnit", getFlowUnit())
+            .append("areaCode", getAreaCode())
+            .append("enableStatus", getEnableStatus())
             .append("createTime", getCreateTime())
             .append("updateTime", getUpdateTime())
             .toString();
     }
-}
+}

+ 46 - 1
ems/ems-core/src/main/java/com/ruoyi/ems/service/IEmsObjFlowRelService.java

@@ -3,6 +3,7 @@ package com.ruoyi.ems.service;
 import com.ruoyi.ems.domain.EmsObjFlowRel;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 能源设施能流关系Service接口
@@ -58,4 +59,48 @@ public interface IEmsObjFlowRelService {
      * @return 结果
      */
     int deleteFlowRelById(Long id);
-}
+
+    /**
+     * 获取能流拓扑数据
+     *
+     * @param areaCode 区域代码
+     * @param emsClsCode 能源分类代码
+     * @return 拓扑数据(包含nodes和edges)
+     */
+    Map<String, Object> getFlowTopology(String areaCode, String emsClsCode);
+
+    /**
+     * 检查能流关系是否存在
+     *
+     * @param flowRel 能流关系
+     * @return 是否存在
+     */
+    boolean checkFlowRelExists(EmsObjFlowRel flowRel);
+
+    /**
+     * 获取上游能流(输入到该对象的能流)
+     *
+     * @param objCode 对象代码
+     * @param objType 对象类型
+     * @return 能流关系列表
+     */
+    List<EmsObjFlowRel> getUpstreamFlow(String objCode, Integer objType);
+
+    /**
+     * 获取下游能流(从该对象输出的能流)
+     *
+     * @param objCode 对象代码
+     * @param objType 对象类型
+     * @return 能流关系列表
+     */
+    List<EmsObjFlowRel> getDownstreamFlow(String objCode, Integer objType);
+
+    /**
+     * 根据能源类型获取能流关系
+     *
+     * @param emsClsCode 能源分类代码
+     * @param areaCode 区域代码
+     * @return 能流关系列表
+     */
+    List<EmsObjFlowRel> getFlowRelByEnergyType(String emsClsCode, String areaCode);
+}

+ 189 - 11
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/EmsObjFlowRelServiceImpl.java

@@ -6,8 +6,14 @@ import com.ruoyi.ems.mapper.EmsObjFlowRelMapper;
 import com.ruoyi.ems.service.IEmsObjFlowRelService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 能源设施能流关系Service业务层处理
@@ -34,35 +40,46 @@ public class EmsObjFlowRelServiceImpl implements IEmsObjFlowRelService {
     /**
      * 查询能源设施能流关系列表
      *
-     * @param FlowRel 能源设施能流关系
+     * @param flowRel 能源设施能流关系
      * @return 能源设施能流关系
      */
     @Override
-    public List<EmsObjFlowRel> selectFlowRelList(EmsObjFlowRel FlowRel) {
-        return flowRelMapper.selectFlowRelList(FlowRel);
+    public List<EmsObjFlowRel> selectFlowRelList(EmsObjFlowRel flowRel) {
+        return flowRelMapper.selectFlowRelList(flowRel);
     }
 
     /**
      * 新增能源设施能流关系
      *
-     * @param FlowRel 能源设施能流关系
+     * @param flowRel 能源设施能流关系
      * @return 结果
      */
     @Override
-    public int insertFlowRel(EmsObjFlowRel FlowRel) {
-        FlowRel.setCreateTime(DateUtils.getNowDate());
-        return flowRelMapper.insertFlowRel(FlowRel);
+    public int insertFlowRel(EmsObjFlowRel flowRel) {
+        // 检查是否已存在
+        if (checkFlowRelExists(flowRel)) {
+            throw new RuntimeException("该能流关系已存在");
+        }
+
+        flowRel.setCreateTime(DateUtils.getNowDate());
+        return flowRelMapper.insertFlowRel(flowRel);
     }
 
     /**
      * 修改能源设施能流关系
      *
-     * @param FlowRel 能源设施能流关系
+     * @param flowRel 能源设施能流关系
      * @return 结果
      */
     @Override
-    public int updateFlowRel(EmsObjFlowRel FlowRel) {
-        return flowRelMapper.updateFlowRel(FlowRel);
+    public int updateFlowRel(EmsObjFlowRel flowRel) {
+        // 检查是否已存在(排除自身)
+        if (checkFlowRelExists(flowRel)) {
+            throw new RuntimeException("该能流关系已存在");
+        }
+
+        flowRel.setUpdateTime(DateUtils.getNowDate());
+        return flowRelMapper.updateFlowRel(flowRel);
     }
 
     /**
@@ -86,4 +103,165 @@ public class EmsObjFlowRelServiceImpl implements IEmsObjFlowRelService {
     public int deleteFlowRelById(Long id) {
         return flowRelMapper.deleteFlowRelById(id);
     }
-}
+
+    /**
+     * 获取能流拓扑数据
+     *
+     * @param areaCode 区域代码
+     * @param emsClsCode 能源分类代码
+     * @return 拓扑数据(包含nodes和edges)
+     */
+    @Override
+    public Map<String, Object> getFlowTopology(String areaCode, String emsClsCode) {
+        Map<String, Object> result = new HashMap<>();
+
+        // 构建查询条件
+        EmsObjFlowRel queryParam = new EmsObjFlowRel();
+        if (StringUtils.hasText(areaCode)) {
+            queryParam.setAreaCode(areaCode);
+        }
+        if (StringUtils.hasText(emsClsCode)) {
+            queryParam.setEmsCls(emsClsCode);
+        }
+        queryParam.setEnableStatus(1); // 只查询启用的关系
+
+        // 查询能流关系列表
+        List<EmsObjFlowRel> flowRelList = flowRelMapper.selectFlowRelList(queryParam);
+
+        // 构建节点集合(使用Set去重,但需要保证equals和hashCode正确实现)
+        Map<String, Map<String, Object>> nodeMap = new LinkedHashMap<>();
+        List<Map<String, Object>> edges = new ArrayList<>();
+
+        for (EmsObjFlowRel flowRel : flowRelList) {
+            // 空值检查
+            if (flowRel.getExportObj() == null || flowRel.getInputObj() == null) {
+                continue;
+            }
+
+            // 添加输出节点
+            String exportNodeId = flowRel.getExportObjType() + "_" + flowRel.getExportObj();
+            if (!nodeMap.containsKey(exportNodeId)) {
+                Map<String, Object> exportNode = new HashMap<>();
+                exportNode.put("id", exportNodeId);
+                exportNode.put("label", flowRel.getExportObjName() != null ? flowRel.getExportObjName() : flowRel.getExportObj());
+                exportNode.put("type", flowRel.getExportObjType());
+                exportNode.put("code", flowRel.getExportObj());
+                nodeMap.put(exportNodeId, exportNode);
+            }
+
+            // 添加输入节点
+            String inputNodeId = flowRel.getInputObjType() + "_" + flowRel.getInputObj();
+            if (!nodeMap.containsKey(inputNodeId)) {
+                Map<String, Object> inputNode = new HashMap<>();
+                inputNode.put("id", inputNodeId);
+                inputNode.put("label", flowRel.getInputObjName() != null ? flowRel.getInputObjName() : flowRel.getInputObj());
+                inputNode.put("type", flowRel.getInputObjType());
+                inputNode.put("code", flowRel.getInputObj());
+                nodeMap.put(inputNodeId, inputNode);
+            }
+
+            // 添加边(能流关系)
+            Map<String, Object> edge = new HashMap<>();
+            edge.put("id", String.valueOf(flowRel.getId()));
+            edge.put("from", exportNodeId);
+            edge.put("to", inputNodeId);
+            edge.put("label", flowRel.getEmsClsName() != null ? flowRel.getEmsClsName() : "未知能源");
+
+            // 添加容量信息
+            if (flowRel.getFlowCapacity() != null) {
+                String capacity = flowRel.getFlowCapacity() +
+                    (flowRel.getFlowUnit() != null ? flowRel.getFlowUnit() : "kW");
+                edge.put("capacity", capacity);
+            }
+
+            edges.add(edge);
+        }
+
+        // 转换为List
+        List<Map<String, Object>> nodes = new ArrayList<>(nodeMap.values());
+
+        result.put("nodes", nodes);
+        result.put("edges", edges);
+
+        return result;
+    }
+
+    /**
+     * 检查能流关系是否存在
+     *
+     * @param flowRel 能流关系
+     * @return 是否存在
+     */
+    @Override
+    public boolean checkFlowRelExists(EmsObjFlowRel flowRel) {
+        EmsObjFlowRel queryParam = new EmsObjFlowRel();
+        queryParam.setExportObj(flowRel.getExportObj());
+        queryParam.setExportObjType(flowRel.getExportObjType());
+        queryParam.setInputObj(flowRel.getInputObj());
+        queryParam.setInputObjType(flowRel.getInputObjType());
+        queryParam.setEmsCls(flowRel.getEmsCls());
+
+        List<EmsObjFlowRel> list = flowRelMapper.selectFlowRelList(queryParam);
+
+        // 如果是编辑,排除自身
+        if (flowRel.getId() != null) {
+            list = list.stream()
+                .filter(item -> !item.getId().equals(flowRel.getId()))
+                .collect(Collectors.toList());
+        }
+
+        return !list.isEmpty();
+    }
+
+    /**
+     * 获取上游能流(输入到该对象的能流)
+     *
+     * @param objCode 对象代码
+     * @param objType 对象类型
+     * @return 能流关系列表
+     */
+    @Override
+    public List<EmsObjFlowRel> getUpstreamFlow(String objCode, Integer objType) {
+        EmsObjFlowRel queryParam = new EmsObjFlowRel();
+        queryParam.setInputObj(objCode);
+        queryParam.setInputObjType(objType);
+        queryParam.setEnableStatus(1);
+        return flowRelMapper.selectFlowRelList(queryParam);
+    }
+
+    /**
+     * 获取下游能流(从该对象输出的能流)
+     *
+     * @param objCode 对象代码
+     * @param objType 对象类型
+     * @return 能流关系列表
+     */
+    @Override
+    public List<EmsObjFlowRel> getDownstreamFlow(String objCode, Integer objType) {
+        EmsObjFlowRel queryParam = new EmsObjFlowRel();
+        queryParam.setExportObj(objCode);
+        queryParam.setExportObjType(objType);
+        queryParam.setEnableStatus(1);
+        return flowRelMapper.selectFlowRelList(queryParam);
+    }
+
+    /**
+     * 根据能源类型获取能流关系
+     *
+     * @param emsClsCode 能源分类代码
+     * @param areaCode 区域代码
+     * @return 能流关系列表
+     */
+    @Override
+    public List<EmsObjFlowRel> getFlowRelByEnergyType(String emsClsCode, String areaCode) {
+        EmsObjFlowRel queryParam = new EmsObjFlowRel();
+        if (StringUtils.hasText(emsClsCode)) {
+            queryParam.setEmsCls(emsClsCode);
+        }
+        if (StringUtils.hasText(areaCode)) {
+            queryParam.setAreaCode(areaCode);
+        }
+        queryParam.setEnableStatus(1);
+        return flowRelMapper.selectFlowRelList(queryParam);
+    }
+}

+ 78 - 29
ems/ems-core/src/main/resources/mapper/ems/EmsObjFlowRelMapper.xml

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ems.mapper.EmsObjFlowRelMapper">
-    
+
     <resultMap type="com.ruoyi.ems.domain.EmsObjFlowRel" id="flowRelResult">
-        <result property="id"    column="id"    />
+        <result property="id"              column="id"    />
         <result property="exportObj"       column="export_obj"    />
         <result property="exportObjName"   column="export_obj_name"    />
         <result property="exportObjType"   column="export_obj_type"    />
@@ -15,70 +15,119 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="emsCls"          column="ems_cls"    />
         <result property="emsClsName"      column="ems_cls_name" />
         <result property="flowDesc"        column="flow_desc"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="updateTime"    column="update_time"    />
+        <result property="flowCapacity"    column="flow_capacity"    />
+        <result property="flowUnit"        column="flow_unit"    />
+        <result property="areaCode"        column="area_code"    />
+        <result property="enableStatus"    column="enable_status"    />
+        <result property="createTime"      column="create_time"    />
+        <result property="updateTime"      column="update_time"    />
     </resultMap>
 
     <sql id="selectEmsFacsFlowRelVo">
         select
-            r.`id`, r.`export_obj`, r.`export_obj_type`, r.`input_obj`, r.`input_obj_type`, r.`ems_cls`, c.`name` as ems_cls_name, r.`flow_desc`, r.`create_time`, r.`update_time`,
+            r.`id`,
+            r.`export_obj`,
+            r.`export_obj_type`,
+            r.`input_obj`,
+            r.`input_obj_type`,
+            r.`ems_cls`,
+            c.`name` as ems_cls_name,
+            r.`flow_desc`,
+            r.`flow_capacity`,
+            r.`flow_unit`,
+            r.`area_code`,
+            r.`enable_status`,
+            r.`create_time`,
+            r.`update_time`,
             COALESCE(
-              (SELECT facs.facs_name FROM adm_ems_facs facs WHERE facs.facs_code = r.export_obj AND r.export_obj_type = 1),
-              (SELECT dev.device_name FROM adm_ems_device dev WHERE dev.device_code = r.export_obj AND r.export_obj_type = 2)
+                    (SELECT facs.facs_name FROM adm_ems_facs facs WHERE facs.facs_code = r.export_obj AND r.export_obj_type = 1),
+                    (SELECT dev.device_name FROM adm_ems_device dev WHERE dev.device_code = r.export_obj AND r.export_obj_type = 2)
             ) AS export_obj_name,
-		    COALESCE(
-              (SELECT facs.facs_name FROM adm_ems_facs facs WHERE facs.facs_code = r.input_obj AND r.input_obj_type = 1),
-              (SELECT dev.device_name FROM adm_ems_device dev WHERE dev.device_code = r.input_obj AND r.input_obj_type = 2)
+            COALESCE(
+                    (SELECT facs.facs_name FROM adm_ems_facs facs WHERE facs.facs_code = r.input_obj AND r.input_obj_type = 1),
+                    (SELECT dev.device_name FROM adm_ems_device dev WHERE dev.device_code = r.input_obj AND r.input_obj_type = 2)
             ) AS input_obj_name
         from adm_ems_flow_rel r
-            LEFT JOIN dim_gb_ems_cls c ON r.`ems_cls` = c.`code`
+                 LEFT JOIN dim_gb_ems_cls c ON r.`ems_cls` = c.`code`
     </sql>
 
     <select id="selectFlowRelList" parameterType="com.ruoyi.ems.domain.EmsObjFlowRel" resultMap="flowRelResult">
         <include refid="selectEmsFacsFlowRelVo"/>
-        <where>  
-            <if test="exportObj != null  and exportObj != ''"> and r.`export_obj` = #{exportObj}</if>
-            <if test="exportObjType != null"> and r.`export_obj_type` = #{exportObjType}</if>
-            <if test="inputObj != null  and inputObj != ''"> and r.`input_obj` = #{inputObj}</if>
-            <if test="inputObjType != null  and inputObjType != ''"> and r.`input_obj_type` = #{inputObjType}</if>
-            <if test="emsCls != null  and emsCls != ''"> and r.`ems_cls` = #{emsCls}</if>
+        <where>
+            <if test="exportObj != null and exportObj != ''">
+                and r.`export_obj` = #{exportObj}
+            </if>
+            <if test="exportObjType != null">
+                and r.`export_obj_type` = #{exportObjType}
+            </if>
+            <if test="inputObj != null and inputObj != ''">
+                and r.`input_obj` = #{inputObj}
+            </if>
+            <if test="inputObjType != null">
+                and r.`input_obj_type` = #{inputObjType}
+            </if>
+            <if test="emsCls != null and emsCls != ''">
+                and r.`ems_cls` = #{emsCls}
+            </if>
+            <if test="areaCode != null and areaCode != ''">
+                and r.`area_code` = #{areaCode}
+            </if>
+            <if test="enableStatus != null">
+                and r.`enable_status` = #{enableStatus}
+            </if>
         </where>
+        order by r.`create_time` desc
     </select>
-    
+
     <select id="selectFlowRelById" parameterType="Long" resultMap="flowRelResult">
         <include refid="selectEmsFacsFlowRelVo"/>
         where r.`id` = #{id}
     </select>
-        
+
     <insert id="insertFlowRel" parameterType="com.ruoyi.ems.domain.EmsObjFlowRel" useGeneratedKeys="true" keyProperty="id">
         insert into adm_ems_flow_rel
         <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="exportObj != null  and exportObj != ''">export_obj,</if>
+            <if test="exportObj != null and exportObj != ''">export_obj,</if>
             <if test="exportObjType != null">export_obj_type,</if>
-            <if test="inputObj != null  and inputObj != ''">input_obj,</if>
+            <if test="inputObj != null and inputObj != ''">input_obj,</if>
             <if test="inputObjType != null">input_obj_type,</if>
             <if test="emsCls != null and emsCls != ''">ems_cls,</if>
             <if test="flowDesc != null and flowDesc != ''">flow_desc,</if>
-         </trim>
+            <if test="flowCapacity != null">flow_capacity,</if>
+            <if test="flowUnit != null and flowUnit != ''">flow_unit,</if>
+            <if test="areaCode != null and areaCode != ''">area_code,</if>
+            <if test="enableStatus != null">enable_status,</if>
+            <if test="createTime != null">create_time,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test="exportObj != null  and exportObj != ''">#{exportObj},</if>
+            <if test="exportObj != null and exportObj != ''">#{exportObj},</if>
             <if test="exportObjType != null">#{exportObjType},</if>
-            <if test="inputObj != null  and inputObj != ''">#{inputObj},</if>
+            <if test="inputObj != null and inputObj != ''">#{inputObj},</if>
             <if test="inputObjType != null">#{inputObjType},</if>
             <if test="emsCls != null and emsCls != ''">#{emsCls},</if>
             <if test="flowDesc != null and flowDesc != ''">#{flowDesc},</if>
-         </trim>
+            <if test="flowCapacity != null">#{flowCapacity},</if>
+            <if test="flowUnit != null and flowUnit != ''">#{flowUnit},</if>
+            <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
+            <if test="enableStatus != null">#{enableStatus},</if>
+            <if test="createTime != null">#{createTime},</if>
+        </trim>
     </insert>
 
     <update id="updateFlowRel" parameterType="com.ruoyi.ems.domain.EmsObjFlowRel">
         update adm_ems_flow_rel
         <trim prefix="SET" suffixOverrides=",">
-            <if test="exportObj != null  and exportObj != ''">export_obj = #{exportObj},</if>
+            <if test="exportObj != null and exportObj != ''">export_obj = #{exportObj},</if>
             <if test="exportObjType != null">export_obj_type = #{exportObjType},</if>
-            <if test="inputObj != null  and inputObj != ''">input_obj = #{inputObj},</if>
+            <if test="inputObj != null and inputObj != ''">input_obj = #{inputObj},</if>
             <if test="inputObjType != null">input_obj_type = #{inputObjType},</if>
             <if test="emsCls != null and emsCls != ''">ems_cls = #{emsCls},</if>
             <if test="flowDesc != null and flowDesc != ''">flow_desc = #{flowDesc},</if>
+            <if test="flowCapacity != null">flow_capacity = #{flowCapacity},</if>
+            <if test="flowUnit != null and flowUnit != ''">flow_unit = #{flowUnit},</if>
+            <if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
+            <if test="enableStatus != null">enable_status = #{enableStatus},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
         </trim>
         where id = #{id}
     </update>

+ 22 - 31
ems/sql/ems_init_data_ctfwq.sql

@@ -253,36 +253,7 @@ INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `dev
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E5-ZX-INV-GF-5', '主线光伏逆变器5', 'Growatt-古瑞瓦特', '-', '1', '服务区主线', '321283124S3003', '321283124S3003', 'M_E5_DEV_PHOTOVOLTAIC_INVERTER', 'E503', NULL, 'SYS_GF');
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E5-ZX-INV-GF-6', '主线光伏逆变器6', 'Growatt-古瑞瓦特', '-', '1', '服务区主线', '321283124S3003', '321283124S3003', 'M_E5_DEV_PHOTOVOLTAIC_INVERTER', 'E503', NULL, 'SYS_GF');
 
-
--- mock设备
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-001', '光储设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-002', '光储设备2',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-003', '光储设备3',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-004', '光储设备4',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-005', '光储设备5',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-006', '光储设备6',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-007', '光储设备7',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-008', '光储设备8',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-EVSE-10001', '1号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-FW-01', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-EVSE-10002', '2号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-FW-01', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-EVSE-10003', '3号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-FW-01', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-EVSE-10004', '4号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-FW-01', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-EVSE-20001', '1号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-FW-02', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-EVSE-20002', '2号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-FW-02', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-EVSE-20003', '3号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-FW-02', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-EVSE-20004', '4号充电桩',    '特来电', 'TCDZ-DCO.7', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-FW-02', 'DC-EVSE', 'SYS_CD');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('ZHHM-01', '海绵设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-QT-01', NULL, 'SYS_ZHHM');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('ZHHM-02', '海绵设备2',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-QT-02', NULL, 'SYS_ZHHM');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('LGCY-01', '厨余垃圾设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-QT-01', NULL, 'SYS_LG');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('LGCY-02', '厨余垃圾设备2',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-QT-02', NULL, 'SYS_LG');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3001_99-ZHLD-001', '光伏板1','Canadian Solar', 'x1', '1', null, '321283124S300150', '321283124S3001', 'test', 'E501', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3001_99-CPD-001', '光伏板2', 'Canadian Solar', 'x1', '1', null, '321283124S300150', '321283124S3001', 'test', 'E501', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3002_99-ZHLD-001', '光伏板3','Canadian Solar', 'x1', '1', null, '321283124S300250', '321283124S3002', 'test', 'E502', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3002_99-CPD-001', '光伏板4', 'Canadian Solar', 'x1', '1', null, '321283124S300250', '321283124S3002', 'test', 'E502', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-001', '光伏板5',        'Canadian Solar', 'x1', '1', null, 'S30K140-S30K150', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-002', '光伏板6',        'Canadian Solar', 'x1', '1', null, 'S30K140-S30K150', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-003', '光伏板7',        'Canadian Solar', 'x1', '1', null, 'S30K150-S30K180', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
-
+-- BA设备
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'Z020-B-WT-1', '北区水箱', '-', '-', '1', '综合楼', '321283124S300101', '321283124S3001', 'M_Z020_DEV_BA_WT', 'Z-KT-01', NULL, 'SYS_BA');
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'Z020-N-WT-1', '南区水箱', '-', '-', '1', '综合楼', '321283124S300201', '321283124S3002', 'M_Z020_DEV_BA_WT', 'Z-KT-02', NULL, 'SYS_BA');
 
@@ -356,6 +327,27 @@ INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `dev
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'W2-N-CHARGING-PILE-0207', '(南)充电枪0207', '科士达', 'CDS1', '0', '南区广场', '321283124S300270', '321283124S3002', 'M_W2_DEV_CHARGING_PILE', 'Charge02', NULL, 'SYS_CD');
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'W2-N-CHARGING-PILE-0208', '(南)充电枪0208', '科士达', 'CDS1', '0', '南区广场', '321283124S300270', '321283124S3002', 'M_W2_DEV_CHARGING_PILE', 'Charge02', NULL, 'SYS_CD');
 
+-- mock设备
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-001', '光储设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-002', '光储设备2',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-003', '光储设备3',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-004', '光储设备4',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'C101', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-005', '光储设备5',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-006', '光储设备6',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-007', '光储设备7',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('GCZR-008', '光储设备8',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'C102', NULL, 'SYS_GCC');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('ZHHM-01', '海绵设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-QT-01', NULL, 'SYS_ZHHM');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('ZHHM-02', '海绵设备2',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-QT-02', NULL, 'SYS_ZHHM');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('LGCY-01', '厨余垃圾设备1',    'xxx', 'xxx', 1, '北区广场', '321283124S300104', '321283124S3001',  'test', 'Z-QT-01', NULL, 'SYS_LG');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('LGCY-02', '厨余垃圾设备2',    'xxx', 'xxx', 1, '南区广场', '321283124S300204', '321283124S3002',  'test', 'Z-QT-02', NULL, 'SYS_LG');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3001_99-ZHLD-001', '光伏板1','Canadian Solar', 'x1', '1', null, '321283124S300150', '321283124S3001', 'test', 'E501', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3001_99-CPD-001', '光伏板2', 'Canadian Solar', 'x1', '1', null, '321283124S300150', '321283124S3001', 'test', 'E501', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3002_99-ZHLD-001', '光伏板3','Canadian Solar', 'x1', '1', null, '321283124S300250', '321283124S3002', 'test', 'E502', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( '321283124S3002_99-CPD-001', '光伏板4', 'Canadian Solar', 'x1', '1', null, '321283124S300250', '321283124S3002', 'test', 'E502', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-001', '光伏板5',        'Canadian Solar', 'x1', '1', null, 'S30K140-S30K150', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-002', '光伏板6',        'Canadian Solar', 'x1', '1', null, 'S30K140-S30K150', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_brand`, `device_spec`, `device_status`, `location`, `location_ref`, `area_code`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-003', '光伏板7',        'Canadian Solar', 'x1', '1', null, 'S30K150-S30K180', '321283124S3003', 'test', 'E503', null, 'SYS_GF');
+
 -- 策略初始数据
 
 -- 策略参数数据
@@ -1638,7 +1630,6 @@ INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`,
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `param_definition`, `hidden_flag`) VALUES ('M_E5_DEV_PHOTOVOLTAIC_INVERTER', 'SyncAttr', '同步属性', '从API同步当前逆变器的实时数据', null, 1);
 
 
-
 -- 对象事件数据
 INSERT INTO `adm_ems_obj_event` (`model_code`, `event_key`, `event_type`, `event_name`, `event_desc`, `event_code`, `ext_event_code`) VALUES ('M_W4_SYS_BA', 'connect', 1, '连接恢复', '连接正常', 'M_W4_SYS_BA_00', NULL);
 INSERT INTO `adm_ems_obj_event` (`model_code`, `event_key`, `event_type`, `event_name`, `event_desc`, `event_code`, `ext_event_code`) VALUES ('M_W4_SYS_BA', 'disconnect', 1, '连接断开', '连接断开', 'M_W4_SYS_BA_01', NULL);

+ 24 - 15
ems/sql/ems_server.sql

@@ -863,21 +863,30 @@ create table adm_ems_subsystem  (
 -- ----------------------------
 -- 能源设施能流关系表
 -- ----------------------------
-drop table if exists adm_ems_flow_rel;
-create table adm_ems_flow_rel  (
-  `id`                bigint(20)      not null auto_increment      comment '序号',
-  `export_obj`        varchar(64)     not null                     comment '能源输出对象',
-  `export_obj_type`   int             not null                     comment '能源输出对象类型',
-  `input_obj`         varchar(64)     not null                     comment '能源流入对象',
-  `input_obj_type`    int             not null                     comment '能源输入对象类型',
-  `ems_cls`           varchar(16)     not null                     comment '能源流动介质',
-  `flow_desc`         varchar(256)    default null                 comment '能流描述',
-  `create_time`     datetime        default CURRENT_TIMESTAMP      comment '创建时间',
-  `update_time`     datetime        default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment '更新时间',
-  primary key (`id`),
-  unique key ux_ems_flow_rel_code(`export_obj`,`export_obj_type`,`input_obj`,`input_obj_type`,`ems_cls`),
-  key idx_ems_facs_flow_rel_code(`export_obj`,`input_obj`)
-) engine=innodb auto_increment=1 comment = '能流关系表';
+DROP TABLE IF EXISTS adm_ems_flow_rel;
+CREATE TABLE adm_ems_flow_rel  (
+    `id`                BIGINT(20)      NOT NULL AUTO_INCREMENT      COMMENT '序号',
+    `export_obj`        VARCHAR(64)     NOT NULL                     COMMENT '能源输出对象代码',
+    `export_obj_name`   VARCHAR(128)    DEFAULT NULL                 COMMENT '能源输出对象名称',
+    `export_obj_type`   INT             NOT NULL                     COMMENT '能源输出对象类型 1-设施 2-设备',
+    `input_obj`         VARCHAR(64)     NOT NULL                     COMMENT '能源流入对象代码',
+    `input_obj_name`    VARCHAR(128)    DEFAULT NULL                 COMMENT '能源流入对象名称',
+    `input_obj_type`    INT             NOT NULL                     COMMENT '能源输入对象类型 1-设施 2-设备',
+    `ems_cls`           VARCHAR(16)     NOT NULL                     COMMENT '能源流动介质代码',
+    `ems_cls_name`      VARCHAR(64)     DEFAULT NULL                 COMMENT '能源流动介质名称',
+    `flow_desc`         VARCHAR(256)    DEFAULT NULL                 COMMENT '能流描述',
+    `flow_capacity`     DECIMAL(10,2)   DEFAULT NULL                 COMMENT '流动容量/功率',
+    `flow_unit`         VARCHAR(16)     DEFAULT NULL                 COMMENT '容量单位',
+    `area_code`         VARCHAR(32)     DEFAULT NULL                 COMMENT '所属区域代码',
+    `enable_status`     INT             DEFAULT 1                    COMMENT '启用状态 0-禁用 1-启用',
+    `create_time`       DATETIME        DEFAULT CURRENT_TIMESTAMP    COMMENT '创建时间',
+    `update_time`       DATETIME        DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+    PRIMARY KEY (`id`),
+    UNIQUE KEY `ux_flow_rel` (`export_obj`, `export_obj_type`, `input_obj`, `input_obj_type`, `ems_cls`),
+    KEY `idx_export_obj` (`export_obj`, `export_obj_type`),
+    KEY `idx_input_obj` (`input_obj`, `input_obj_type`),
+    KEY `idx_area_code` (`area_code`)
+) ENGINE=INNODB AUTO_INCREMENT=1 COMMENT='能源流动关系表';
 
 
 -- ----------------------------