Browse Source

指标查询接口改造

lv.wenbin 10 months ago
parent
commit
c838726796
17 changed files with 858 additions and 366 deletions
  1. 30 2
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/DeviceController.java
  2. 58 45
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/ElecLoadIndexController.java
  3. 250 81
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/ElecLoadIndex.java
  4. 38 16
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryDevice.java
  5. 26 0
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryIndex.java
  6. 39 19
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/ElecLoadIndexMapper.java
  7. 26 2
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsDeviceMapper.java
  8. 37 18
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IElecLoadIndexService.java
  9. 24 1
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsDeviceService.java
  10. 1 1
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/AdmOpAlarmServiceImpl.java
  11. 33 28
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/ElecLoadIndexServiceImpl.java
  12. 69 64
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsDeviceServiceImpl.java
  13. 1 1
      ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java
  14. 119 54
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/ElecLoadIndexMapper.xml
  15. 51 8
      ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsDeviceMapper.xml
  16. 34 20
      ems-cloud/sql/ems_init_data.sql
  17. 22 6
      ems-cloud/sql/ems_server.sql

+ 30 - 2
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/DeviceController.java

@@ -62,11 +62,38 @@ public class DeviceController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo list(QueryDevice queryDevice) {
         startPage();
-        List<EmsDevice> list = deviceService.selectEmsDeviceList(queryDevice);
+        List<EmsDevice> list = deviceService.selectDetailList(queryDevice);
         return getDataTable(list);
     }
 
     /**
+     * 查询能源设备列表
+     */
+    @GetMapping("/getByCondition")
+    public AjaxResult getByCondition(QueryDevice queryDevice) {
+        List<EmsDevice> list = deviceService.selectList(queryDevice);
+        return success(list);
+    }
+
+    /**
+     * 查询能源设备列表
+     */
+    @GetMapping("/getByFlowRel")
+    public AjaxResult getByFlowRel(QueryDevice queryDevice) {
+        List<EmsDevice> list = deviceService.selectByFlowRel(queryDevice);
+        return success(list);
+    }
+
+    /**
+     * 查询能源设备列表
+     */
+    @GetMapping("/getDetail")
+    public AjaxResult getDetail(@RequestParam(value = "deviceCode") String deviceCode) {
+        EmsDevice device = deviceService.selectDetailByCode(deviceCode);
+        return success(device);
+    }
+
+    /**
      * 递归查询 区域/建筑/区块 下的设备(分页)
      */
     @RequiresPermissions("basecfg:device:list")
@@ -106,6 +133,7 @@ public class DeviceController extends BaseController {
 
     /**
      * 根据设施获取设备树结构
+     *
      * @param areaCode 区域code
      * @return 树结构
      */
@@ -126,7 +154,7 @@ public class DeviceController extends BaseController {
     @Log(title = "能源设备", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
     public void export(HttpServletResponse response, QueryDevice queryDevice) {
-        List<EmsDevice> list = deviceService.selectEmsDeviceList(queryDevice);
+        List<EmsDevice> list = deviceService.selectDetailList(queryDevice);
         ExcelUtil<EmsDevice> util = new ExcelUtil<EmsDevice>(EmsDevice.class);
         util.exportExcel(response, list, "能源设备数据");
     }

+ 58 - 45
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/ElecLoadIndexController.java

@@ -1,63 +1,84 @@
 package com.ruoyi.ems.controller;
 
-import java.util.List;
-import javax.servlet.http.HttpServletResponse;
-
+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.ems.domain.ElecLoadIndex;
+import com.ruoyi.ems.domain.vo.QueryIndex;
+import com.ruoyi.ems.service.IElecLoadIndexService;
 import io.swagger.annotations.Api;
 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.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 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.ems.domain.ElecLoadIndex;
-import com.ruoyi.ems.service.IElecLoadIndexService;
-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
- * 
+ *
  * @author ruoyi
  * @date 2024-08-09
  */
 @RestController
-@RequestMapping("/loadIndex")
-@Api(value = "ElecLoadIndexController", description = "电力负荷设施指标数据接口")
-public class ElecLoadIndexController extends BaseController
-{
+@RequestMapping("/object/loadIndex")
+@Api(value = "ElecLoadIndexController", description = "电力负荷指标数据接口")
+public class ElecLoadIndexController extends BaseController {
     @Autowired
-    private IElecLoadIndexService emsElecLoadIndexService;
+    private IElecLoadIndexService indexService;
 
     /**
      * 查询电力负荷设施指标列表
      */
-    @RequiresPermissions("ems:loadIndex:list")
     @GetMapping("/list")
-    public TableDataInfo list(ElecLoadIndex admEmsElecLoadIndex)
-    {
+    public TableDataInfo list(ElecLoadIndex index) {
         startPage();
-        List<ElecLoadIndex> list = emsElecLoadIndexService.selectElecLoadIndexList(admEmsElecLoadIndex);
+        List<ElecLoadIndex> list = indexService.selectIndexList(index);
         return getDataTable(list);
     }
 
     /**
+     * 查询最新电力负荷设施指标
+     *
+     * @param areaCode 区域代码
+     * @param objType  对象类型
+     * @param objCode  对象代码
+     * @return 电力负荷设施指标
+     */
+    @GetMapping("/getNewIndex")
+    public AjaxResult getNewIndex(@RequestParam(name = "areaCode") String areaCode,
+        @RequestParam(name = "objType") String objType, @RequestParam(name = "objCode") String objCode) {
+        return success(indexService.selectNewIndex(areaCode, objType, objCode));
+    }
+
+    /**
+     * 根据时间查询电力负荷设施指标
+     *
+     * @param queryIndex 参数
+     * @return 电力负荷设施指标集合
+     */
+    @GetMapping("/getByTime")
+    public AjaxResult getByTime(QueryIndex queryIndex) {
+        return success(indexService.selectByTime(queryIndex));
+    }
+
+    /**
      * 导出电力负荷设施指标列表
      */
-    @RequiresPermissions("ems:loadIndex:export")
     @Log(title = "电力负荷设施指标", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ElecLoadIndex admEmsElecLoadIndex)
-    {
-        List<ElecLoadIndex> list = emsElecLoadIndexService.selectElecLoadIndexList(admEmsElecLoadIndex);
+    public void export(HttpServletResponse response, ElecLoadIndex index) {
+        List<ElecLoadIndex> list = indexService.selectIndexList(index);
         ExcelUtil<ElecLoadIndex> util = new ExcelUtil<ElecLoadIndex>(ElecLoadIndex.class);
         util.exportExcel(response, list, "电力负荷设施指标数据");
     }
@@ -65,43 +86,35 @@ public class ElecLoadIndexController extends BaseController
     /**
      * 获取电力负荷设施指标详细信息
      */
-    @RequiresPermissions("ems:loadIndex:query")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
-        return success(emsElecLoadIndexService.selectElecLoadIndexById(id));
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
+        return success(indexService.selectIndexById(id));
     }
 
     /**
      * 新增电力负荷设施指标
      */
-    @RequiresPermissions("ems:loadIndex:add")
     @Log(title = "电力负荷设施指标", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ElecLoadIndex admEmsElecLoadIndex)
-    {
-        return toAjax(emsElecLoadIndexService.insertElecLoadIndex(admEmsElecLoadIndex));
+    public AjaxResult add(@RequestBody ElecLoadIndex index) {
+        return toAjax(indexService.insertIndex(index));
     }
 
     /**
      * 修改电力负荷设施指标
      */
-    @RequiresPermissions("ems:loadIndex:edit")
     @Log(title = "电力负荷设施指标", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody ElecLoadIndex admEmsElecLoadIndex)
-    {
-        return toAjax(emsElecLoadIndexService.updateElecLoadIndex(admEmsElecLoadIndex));
+    public AjaxResult edit(@RequestBody ElecLoadIndex index) {
+        return toAjax(indexService.updateIndex(index));
     }
 
     /**
      * 删除电力负荷设施指标
      */
-    @RequiresPermissions("ems:loadIndex:remove")
     @Log(title = "电力负荷设施指标", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
-        return toAjax(emsElecLoadIndexService.deleteElecLoadIndexByIds(ids));
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
+        return toAjax(indexService.deleteIndexByIds(ids));
     }
 }

+ 250 - 81
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/ElecLoadIndex.java

@@ -1,158 +1,327 @@
 package com.ruoyi.ems.domain;
 
+import java.sql.Time;
 import java.util.Date;
-
+import com.fasterxml.jackson.annotation.JsonFormat;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.core.annotation.Excel;
 import com.ruoyi.common.core.web.domain.BaseEntity;
 
 /**
  * 电力负荷设施指标对象 adm_ems_elec_load_index
- *
+ * 
  * @author ruoyi
- * @date 2024-08-09
+ * @date 2024-09-27
  */
-public class ElecLoadIndex extends BaseEntity {
+public class ElecLoadIndex extends BaseEntity
+{
     private static final long serialVersionUID = 1L;
 
-    /**
-     * 序号
-     */
+    /** 序号 */
     private Long id;
 
-    /**
-     * 园区代码
-     */
+    /** 园区代码 */
     @Excel(name = "园区代码")
     private String areaCode;
 
-    /**
-     * 设施代码
-     */
-    @Excel(name = "设施代码")
-    private String facsCode;
+    /** 对象类型 */
+    @Excel(name = "对象类型")
+    private Long objType;
 
-    @Excel(name = "园区名称")
-    private String areaName;
+    /** 对象编码 */
+    @Excel(name = "对象编码")
+    private String objCode;
 
-    @Excel(name = "设施名称")
-    private String facsName;
+    /** 记录时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "记录时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date recordTime;
 
-    /**
-     * 日期
-     */
+    /** 日期 yyyy-MM-dd */
     @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "日期 yyyy-MM-dd", width = 30, dateFormat = "yyyy-MM-dd")
     private Date date;
 
-    /**
-     * 时间
-     */
-    private Date time;
-
-    /**
-     * 电压 (千伏)
-     */
-    @Excel(name = "电压 ")
-    private Double voltage;
-
-    /**
-     * 电流 (安培)
-     */
-    @Excel(name = "电流 ")
-    private Double amperage;
-
-    /**
-     * 功率 (千瓦)
-     */
-    @Excel(name = "功率 ")
-    private Double power;
+    /** 时间 HH:mm:ss */
+    @JsonFormat(pattern = "HH:mm:ss")
+    @Excel(name = "时间 HH:mm:ss", width = 30, dateFormat = "yyyy-MM-dd")
+    private Time time;
+
+    /** 事件序列 */
+    @Excel(name = "事件序列")
+    private Integer timeIndex;
+
+    /** 电压 单位:V(伏) */
+    @Excel(name = "A相电压")
+    private Double ua;
+
+    /** 电压 单位:V(伏) */
+    @Excel(name = "B相电压")
+    private Double ub;
+
+    /** 电压 单位:V(伏) */
+    @Excel(name = "C相电压")
+    private Double uc;
+
+    /** 电流 单位:A(伏) */
+    @Excel(name = "A相电流")
+    private Double la;
+
+    /** 电流 单位:A(伏) */
+    @Excel(name = "B相电流")
+    private Double lb;
+
+    /** 电流 单位:A(伏) */
+    @Excel(name = "C相电流")
+    private Double lc;
+
+    /** 有功总功率 */
+    @Excel(name = "有功总功率")
+    private Double p;
+
+    /** A相有功功率 */
+    @Excel(name = "A相有功功率")
+    private Double pa;
+
+    /** B相有功功率 */
+    @Excel(name = "B相有功功率")
+    private Double pb;
+
+    /** C相有功功率 */
+    @Excel(name = "C相有功功率")
+    private Double pc;
+
+    /** 无功总功率 */
+    @Excel(name = "无功总功率")
+    private Double q;
+
+    /** A相无功总功率 */
+    @Excel(name = "A相无功总功率")
+    private Double qa;
+
+    /** B相无功总功率 */
+    @Excel(name = "B相无功总功率")
+    private Double qb;
+
+    /** C相无功总功率 */
+    @Excel(name = "C相无功总功率")
+    private Double qc;
+
+    /** 功率因素 */
+    @Excel(name = "功率因素")
+    private Double pf;
+
+    public Long getId() {
+        return id;
+    }
 
     public void setId(Long id) {
         this.id = id;
     }
 
-    public Long getId() {
-        return id;
+    public String getAreaCode() {
+        return areaCode;
     }
 
     public void setAreaCode(String areaCode) {
         this.areaCode = areaCode;
     }
 
-    public String getAreaCode() {
-        return areaCode;
+    public Long getObjType() {
+        return objType;
     }
 
-    public void setFacsCode(String facsCode) {
-        this.facsCode = facsCode;
+    public void setObjType(Long objType) {
+        this.objType = objType;
     }
 
-    public String getFacsCode() {
-        return facsCode;
+    public String getObjCode() {
+        return objCode;
     }
 
-    public void setDate(Date date) {
-        this.date = date;
+    public void setObjCode(String objCode) {
+        this.objCode = objCode;
+    }
+
+    public Date getRecordTime() {
+        return recordTime;
+    }
+
+    public void setRecordTime(Date recordTime) {
+        this.recordTime = recordTime;
     }
 
     public Date getDate() {
         return date;
     }
 
-    public void setTime(Date time) {
-        this.time = time;
+    public void setDate(Date date) {
+        this.date = date;
     }
 
-    public Date getTime() {
+    public Time getTime() {
         return time;
     }
 
-    public void setVoltage(Double voltage) {
-        this.voltage = voltage;
+    public void setTime(Time time) {
+        this.time = time;
+    }
+
+    public Integer getTimeIndex() {
+        return timeIndex;
+    }
+
+    public void setTimeIndex(Integer timeIndex) {
+        this.timeIndex = timeIndex;
+    }
+
+    public Double getUa() {
+        return ua;
+    }
+
+    public void setUa(Double ua) {
+        this.ua = ua;
+    }
+
+    public Double getUb() {
+        return ub;
+    }
+
+    public void setUb(Double ub) {
+        this.ub = ub;
+    }
+
+    public Double getUc() {
+        return uc;
+    }
+
+    public void setUc(Double uc) {
+        this.uc = uc;
+    }
+
+    public Double getLa() {
+        return la;
+    }
+
+    public void setLa(Double la) {
+        this.la = la;
+    }
+
+    public Double getLb() {
+        return lb;
+    }
+
+    public void setLb(Double lb) {
+        this.lb = lb;
+    }
+
+    public Double getLc() {
+        return lc;
+    }
+
+    public void setLc(Double lc) {
+        this.lc = lc;
+    }
+
+    public Double getP() {
+        return p;
+    }
+
+    public void setP(Double p) {
+        this.p = p;
+    }
+
+    public Double getPa() {
+        return pa;
+    }
+
+    public void setPa(Double pa) {
+        this.pa = pa;
+    }
+
+    public Double getPb() {
+        return pb;
+    }
+
+    public void setPb(Double pb) {
+        this.pb = pb;
+    }
+
+    public Double getPc() {
+        return pc;
+    }
+
+    public void setPc(Double pc) {
+        this.pc = pc;
+    }
+
+    public Double getQ() {
+        return q;
     }
 
-    public Double getVoltage() {
-        return voltage;
+    public void setQ(Double q) {
+        this.q = q;
     }
 
-    public void setAmperage(Double amperage) {
-        this.amperage = amperage;
+    public Double getQa() {
+        return qa;
     }
 
-    public Double getAmperage() {
-        return amperage;
+    public void setQa(Double qa) {
+        this.qa = qa;
     }
 
-    public void setPower(Double power) {
-        this.power = power;
+    public Double getQb() {
+        return qb;
     }
 
-    public Double getPower() {
-        return power;
+    public void setQb(Double qb) {
+        this.qb = qb;
     }
 
-    public String getAreaName() {
-        return areaName;
+    public Double getQc() {
+        return qc;
     }
 
-    public void setAreaName(String areaName) {
-        this.areaName = areaName;
+    public void setQc(Double qc) {
+        this.qc = qc;
     }
 
-    public String getFacsName() {
-        return facsName;
+    public Double getPf() {
+        return pf;
     }
 
-    public void setFacsName(String facsName) {
-        this.facsName = facsName;
+    public void setPf(Double pf) {
+        this.pf = pf;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("id", getId()).append("areaCode", getAreaCode()).append("facsCode", getFacsCode()).append("date", getDate()).append("time", getTime()).append("voltage", getVoltage()).append("amperage", getAmperage()).append("power", getPower()).toString();
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("areaCode", getAreaCode())
+            .append("objType", getObjType())
+            .append("objCode", getObjCode())
+            .append("recordTime", getRecordTime())
+            .append("date", getDate())
+            .append("time", getTime())
+            .append("timeIndex", getTimeIndex())
+            .append("ua", getUa())
+            .append("ub", getUb())
+            .append("uc", getUc())
+            .append("la", getLa())
+            .append("lb", getLb())
+            .append("lc", getLc())
+            .append("p", getP())
+            .append("pa", getPa())
+            .append("pb", getPb())
+            .append("pc", getPc())
+            .append("q", getQ())
+            .append("qa", getQa())
+            .append("qb", getQb())
+            .append("qc", getQc())
+            .append("pf", getPf())
+            .toString();
     }
 }

+ 38 - 16
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryDevice.java

@@ -10,6 +10,8 @@
  */
 package com.ruoyi.ems.domain.vo;
 
+import io.swagger.models.auth.In;
+
 import java.util.List;
 
 /**
@@ -53,6 +55,10 @@ public class QueryDevice {
     /** 所属子系统 */
     private String subsystemCode;
 
+    private Integer upstreamObjType;
+
+    private String upstreamObjCode;
+
     private List<String> buildingCodes;
 
     private List<String> zoningCodes;
@@ -65,14 +71,6 @@ public class QueryDevice {
         this.deviceCode = deviceCode;
     }
 
-    public String getDeviceCategory() {
-        return deviceCategory;
-    }
-
-    public void setDeviceCategory(String deviceCategory) {
-        this.deviceCategory = deviceCategory;
-    }
-
     public String getDeviceName() {
         return deviceName;
     }
@@ -81,6 +79,14 @@ public class QueryDevice {
         this.deviceName = deviceName;
     }
 
+    public String getDeviceCategory() {
+        return deviceCategory;
+    }
+
+    public void setDeviceCategory(String deviceCategory) {
+        this.deviceCategory = deviceCategory;
+    }
+
     public String getDeviceSubCategory() {
         return deviceSubCategory;
     }
@@ -129,6 +135,14 @@ public class QueryDevice {
         this.psCode = psCode;
     }
 
+    public Long getDeviceStatus() {
+        return deviceStatus;
+    }
+
+    public void setDeviceStatus(Long deviceStatus) {
+        this.deviceStatus = deviceStatus;
+    }
+
     public String getSubsystemCode() {
         return subsystemCode;
     }
@@ -137,6 +151,22 @@ public class QueryDevice {
         this.subsystemCode = subsystemCode;
     }
 
+    public Integer getUpstreamObjType() {
+        return upstreamObjType;
+    }
+
+    public void setUpstreamObjType(Integer upstreamObjType) {
+        this.upstreamObjType = upstreamObjType;
+    }
+
+    public String getUpstreamObjCode() {
+        return upstreamObjCode;
+    }
+
+    public void setUpstreamObjCode(String upstreamObjCode) {
+        this.upstreamObjCode = upstreamObjCode;
+    }
+
     public List<String> getBuildingCodes() {
         return buildingCodes;
     }
@@ -152,12 +182,4 @@ public class QueryDevice {
     public void setZoningCodes(List<String> zoningCodes) {
         this.zoningCodes = zoningCodes;
     }
-
-    public Long getDeviceStatus() {
-        return deviceStatus;
-    }
-
-    public void setDeviceStatus(Long deviceStatus) {
-        this.deviceStatus = deviceStatus;
-    }
 }

+ 26 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/vo/QueryIndex.java

@@ -26,6 +26,16 @@ public class QueryIndex {
     private String areaCode;
 
     /**
+     * 对象类型
+     */
+    private String objType;
+
+    /**
+     * 对象编码
+     */
+    private String objCode;
+
+    /**
      * 开始时间
      */
     private String startTime;
@@ -43,6 +53,22 @@ public class QueryIndex {
         this.areaCode = areaCode;
     }
 
+    public String getObjType() {
+        return objType;
+    }
+
+    public void setObjType(String objType) {
+        this.objType = objType;
+    }
+
+    public String getObjCode() {
+        return objCode;
+    }
+
+    public void setObjCode(String objCode) {
+        this.objCode = objCode;
+    }
+
     public String getStartTime() {
         return startTime;
     }

+ 39 - 19
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/ElecLoadIndexMapper.java

@@ -1,61 +1,81 @@
 package com.ruoyi.ems.mapper;
 
 import java.util.List;
+
 import com.ruoyi.ems.domain.ElecLoadIndex;
+import com.ruoyi.ems.domain.vo.QueryIndex;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 电力负荷设施指标Mapper接口
- * 
+ *
  * @author ruoyi
- * @date 2024-08-09
+ * @date 2024-09-27
  */
-public interface ElecLoadIndexMapper
-{
+public interface ElecLoadIndexMapper {
     /**
      * 查询电力负荷设施指标
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 电力负荷设施指标
      */
-     ElecLoadIndex selectElecLoadIndexById(Long id);
+    ElecLoadIndex selectIndexById(Long id);
+
+    /**
+     * 查询最新电力负荷设施指标
+     * @param areaCode 区域代码
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 电力负荷设施指标
+     */
+    ElecLoadIndex selectNewIndex(@Param("areaCode") String areaCode, @Param("objType") String objType,
+        @Param("objCode") String objCode);
+
+    /**
+     * 根据时间查询电力负荷设施指标
+     *
+     * @param queryIndex 参数
+     * @return 电力负荷设施指标集合
+     */
+    List<ElecLoadIndex> selectByTime(QueryIndex queryIndex);
 
     /**
      * 查询电力负荷设施指标列表
-     * 
-     * @param elecLoadIndex 电力负荷设施指标
+     *
+     * @param loadIndex 电力负荷设施指标
      * @return 电力负荷设施指标集合
      */
-     List<ElecLoadIndex> selectElecLoadIndexList(ElecLoadIndex elecLoadIndex);
+    List<ElecLoadIndex> selectIndexList(ElecLoadIndex loadIndex);
 
     /**
      * 新增电力负荷设施指标
-     * 
-     * @param elecLoadIndex 电力负荷设施指标
+     *
+     * @param loadIndex 电力负荷设施指标
      * @return 结果
      */
-     int insertElecLoadIndex(ElecLoadIndex elecLoadIndex);
+    int insertIndex(ElecLoadIndex loadIndex);
 
     /**
      * 修改电力负荷设施指标
-     * 
-     * @param elecLoadIndex 电力负荷设施指标
+     *
+     * @param loadIndex 电力负荷设施指标
      * @return 结果
      */
-     int updateElecLoadIndex(ElecLoadIndex elecLoadIndex);
+    int updateIndex(ElecLoadIndex loadIndex);
 
     /**
      * 删除电力负荷设施指标
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 结果
      */
-     int deleteElecLoadIndexById(Long id);
+    int deleteIndexById(Long id);
 
     /**
      * 批量删除电力负荷设施指标
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
-     int deleteElecLoadIndexByIds(Long[] ids);
+    int deleteIndexByIds(Long[] ids);
 }

+ 26 - 2
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/EmsDeviceMapper.java

@@ -29,7 +29,31 @@ public interface EmsDeviceMapper {
      * @param code 能源设备编码
      * @return 能源设备
      */
-    EmsDevice selectEmsDeviceByCode(String code);
+    EmsDevice selectDeviceByCode(String code);
+
+    /**
+     * 查询能源设备
+     *
+     * @param code 能源设备编码
+     * @return 能源设备
+     */
+    EmsDevice selectDetailByCode(String code);
+
+    /**
+     * 查询能源设备列表
+     *
+     * @param emsDevice 能源设备
+     * @return 能源设备集合
+     */
+    List<EmsDevice> selectDeviceList(QueryDevice emsDevice);
+
+    /**
+     * 查询能源设备列表
+     *
+     * @param emsDevice 能源设备
+     * @return 能源设备集合
+     */
+    List<EmsDevice> selectByFlowRel(QueryDevice emsDevice);
 
     /**
      * 查询能源设备列表
@@ -37,7 +61,7 @@ public interface EmsDeviceMapper {
      * @param emsDevice 能源设备
      * @return 能源设备集合
      */
-    List<EmsDevice> selectEmsDeviceList(QueryDevice emsDevice);
+    List<EmsDevice> selectDetailList(QueryDevice emsDevice);
 
     /**
      * 根据区域树递归查询设备

+ 37 - 18
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IElecLoadIndexService.java

@@ -1,61 +1,80 @@
 package com.ruoyi.ems.service;
 
 import java.util.List;
+
 import com.ruoyi.ems.domain.ElecLoadIndex;
+import com.ruoyi.ems.domain.vo.QueryIndex;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 电力负荷设施指标Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-09
  */
-public interface IElecLoadIndexService
-{
+public interface IElecLoadIndexService {
     /**
      * 查询电力负荷设施指标
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 电力负荷设施指标
      */
-     ElecLoadIndex selectElecLoadIndexById(Long id);
+    ElecLoadIndex selectIndexById(Long id);
+
+    /**
+     * 查询最新电力负荷设施指标
+     * @param areaCode 区域代码
+     * @param objType 对象类型
+     * @param objCode 对象代码
+     * @return 电力负荷设施指标
+     */
+    ElecLoadIndex selectNewIndex(String areaCode, String objType, String objCode);
+
+    /**
+     * 根据时间查询电力负荷设施指标
+     *
+     * @param queryIndex 参数
+     * @return 电力负荷设施指标集合
+     */
+    List<ElecLoadIndex> selectByTime(QueryIndex queryIndex);
 
     /**
      * 查询电力负荷设施指标列表
-     * 
-     * @param emsElecLoadIndex 电力负荷设施指标
+     *
+     * @param index 电力负荷设施指标
      * @return 电力负荷设施指标集合
      */
-     List<ElecLoadIndex> selectElecLoadIndexList(ElecLoadIndex emsElecLoadIndex);
+    List<ElecLoadIndex> selectIndexList(ElecLoadIndex index);
 
     /**
      * 新增电力负荷设施指标
-     * 
-     * @param emsElecLoadIndex 电力负荷设施指标
+     *
+     * @param index 电力负荷设施指标
      * @return 结果
      */
-     int insertElecLoadIndex(ElecLoadIndex emsElecLoadIndex);
+    int insertIndex(ElecLoadIndex index);
 
     /**
      * 修改电力负荷设施指标
-     * 
-     * @param emsElecLoadIndex 电力负荷设施指标
+     *
+     * @param index 电力负荷设施指标
      * @return 结果
      */
-     int updateElecLoadIndex(ElecLoadIndex emsElecLoadIndex);
+    int updateIndex(ElecLoadIndex index);
 
     /**
      * 批量删除电力负荷设施指标
-     * 
+     *
      * @param ids 需要删除的电力负荷设施指标主键集合
      * @return 结果
      */
-     int deleteElecLoadIndexByIds(Long[] ids);
+    int deleteIndexByIds(Long[] ids);
 
     /**
      * 删除电力负荷设施指标信息
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 结果
      */
-     int deleteElecLoadIndexById(Long id);
+    int deleteIndexById(Long id);
 }

+ 24 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IEmsDeviceService.java

@@ -30,12 +30,27 @@ public interface IEmsDeviceService {
     EmsDevice selectByCode(String code);
 
     /**
+     * 查询能源设备
+     * @param code 设备编码
+     * @return 能源设备
+     */
+    EmsDevice selectDetailByCode(String code);
+
+    /**
+     * 查询能源设备列表
+     *
+     * @param queryDevice 能源设备
+     * @return 能源设备集合
+     */
+    List<EmsDevice> selectList(QueryDevice queryDevice);
+
+    /**
      * 查询能源设备列表
      *
      * @param queryDevice 能源设备
      * @return 能源设备集合
      */
-    List<EmsDevice> selectEmsDeviceList(QueryDevice queryDevice);
+    List<EmsDevice> selectDetailList(QueryDevice queryDevice);
 
     /**
      * 查询能源设备列表
@@ -46,6 +61,14 @@ public interface IEmsDeviceService {
     List<EmsDevice> selectByAreaTree(QueryDevice queryDevice);
 
     /**
+     * 查询能源设备列表
+     *
+     * @param emsDevice 能源设备
+     * @return 能源设备集合
+     */
+    List<EmsDevice> selectByFlowRel(QueryDevice emsDevice);
+
+    /**
      * 根据设施获取设备树结构
      * @param queryDevice 查询参数
      * @return 设备树结构

+ 1 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/AdmOpAlarmServiceImpl.java

@@ -176,7 +176,7 @@ public class AdmOpAlarmServiceImpl implements IAdmOpAlarmService {
             return emsFacs.getFacsName();
         }
         if (ObjType.DEVICE.getCode().equals(objType)) {
-            EmsDevice emsDevice = emsDeviceMapper.selectEmsDeviceByCode(objCode);
+            EmsDevice emsDevice = emsDeviceMapper.selectDeviceByCode(objCode);
             if (ObjectUtils.isEmpty(emsDevice)) {
                 return StringUtils.EMPTY;
             }

+ 33 - 28
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/ElecLoadIndexServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.ems.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.ems.domain.vo.QueryIndex;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.ems.mapper.ElecLoadIndexMapper;
@@ -9,85 +11,88 @@ import com.ruoyi.ems.service.IElecLoadIndexService;
 
 /**
  * 电力负荷设施指标Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2024-08-09
  */
 @Service
-public class ElecLoadIndexServiceImpl implements IElecLoadIndexService
-{
+public class ElecLoadIndexServiceImpl implements IElecLoadIndexService {
     @Autowired
-    private ElecLoadIndexMapper elecLoadIndexMapper;
+    private ElecLoadIndexMapper indexMapper;
 
     /**
      * 查询电力负荷设施指标
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 电力负荷设施指标
      */
     @Override
-    public ElecLoadIndex selectElecLoadIndexById(Long id)
-    {
-        return elecLoadIndexMapper.selectElecLoadIndexById(id);
+    public ElecLoadIndex selectIndexById(Long id) {
+        return indexMapper.selectIndexById(id);
+    }
+
+    @Override
+    public ElecLoadIndex selectNewIndex(String areaCode, String objType, String objCode) {
+        return indexMapper.selectNewIndex(areaCode, objType, objCode);
+    }
+
+    @Override
+    public List<ElecLoadIndex> selectByTime(QueryIndex queryIndex) {
+        return indexMapper.selectByTime(queryIndex);
     }
 
     /**
      * 查询电力负荷设施指标列表
-     * 
+     *
      * @param admEmsElecLoadIndex 电力负荷设施指标
      * @return 电力负荷设施指标
      */
     @Override
-    public List<ElecLoadIndex> selectElecLoadIndexList(ElecLoadIndex admEmsElecLoadIndex)
-    {
-        return elecLoadIndexMapper.selectElecLoadIndexList(admEmsElecLoadIndex);
+    public List<ElecLoadIndex> selectIndexList(ElecLoadIndex admEmsElecLoadIndex) {
+        return indexMapper.selectIndexList(admEmsElecLoadIndex);
     }
 
     /**
      * 新增电力负荷设施指标
-     * 
+     *
      * @param admEmsElecLoadIndex 电力负荷设施指标
      * @return 结果
      */
     @Override
-    public int insertElecLoadIndex(ElecLoadIndex admEmsElecLoadIndex)
-    {
-        return elecLoadIndexMapper.insertElecLoadIndex(admEmsElecLoadIndex);
+    public int insertIndex(ElecLoadIndex admEmsElecLoadIndex) {
+        return indexMapper.insertIndex(admEmsElecLoadIndex);
     }
 
     /**
      * 修改电力负荷设施指标
-     * 
+     *
      * @param admEmsElecLoadIndex 电力负荷设施指标
      * @return 结果
      */
     @Override
-    public int updateElecLoadIndex(ElecLoadIndex admEmsElecLoadIndex)
-    {
-        return elecLoadIndexMapper.updateElecLoadIndex(admEmsElecLoadIndex);
+    public int updateIndex(ElecLoadIndex admEmsElecLoadIndex) {
+        return indexMapper.updateIndex(admEmsElecLoadIndex);
     }
 
     /**
      * 批量删除电力负荷设施指标
-     * 
+     *
      * @param ids 需要删除的电力负荷设施指标主键
      * @return 结果
      */
     @Override
-    public int deleteElecLoadIndexByIds(Long[] ids)
-    {
-        return elecLoadIndexMapper.deleteElecLoadIndexByIds(ids);
+    public int deleteIndexByIds(Long[] ids) {
+        return indexMapper.deleteIndexByIds(ids);
     }
 
     /**
      * 删除电力负荷设施指标信息
-     * 
+     *
      * @param id 电力负荷设施指标主键
      * @return 结果
      */
     @Override
-    public int deleteElecLoadIndexById(Long id)
-    {
-        return elecLoadIndexMapper.deleteElecLoadIndexById(id);
+    public int deleteIndexById(Long id) {
+        return indexMapper.deleteIndexById(id);
     }
 }

+ 69 - 64
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/EmsDeviceServiceImpl.java

@@ -69,41 +69,30 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
 
     @Override
     public EmsDevice selectByCode(String code) {
-        EmsDevice emsDevice = emsDeviceMapper.selectEmsDeviceByCode(code);
+        return emsDeviceMapper.selectDeviceByCode(code);
+    }
 
-        if (null != emsDevice) {
-            fillAreaName(emsDevice);
+    @Override
+    public EmsDevice selectDetailByCode(String code) {
+        EmsDevice device = emsDeviceMapper.selectDetailByCode(code);
+
+        if (null != device) {
+            fillAreaName(device);
+            fillAttribute(device);
         }
 
-        return emsDevice;
+        return device;
     }
 
-    /**
-     * 查询能源设备列表
-     *
-     * @param queryDevice 查询条件
-     * @return 能源设备
-     */
     @Override
-    public List<EmsDevice> selectEmsDeviceList(QueryDevice queryDevice) {
-        List<EmsDevice> list = emsDeviceMapper.selectEmsDeviceList(queryDevice);
-
-        if (CollectionUtils.isNotEmpty(list)) {
-            List<Area> areas = areaService.selectAreaList(new Area());
-            Map<String, Area> areaMap = areas.stream()
-                .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
-            List<AreaBuilding> buildings = buildingService.selectAreaBuildingList(new AreaBuilding());
-            Map<String, AreaBuilding> buildingMap = buildings.stream()
-                .collect(Collectors.toMap(AreaBuilding::getBldgCode, Function.identity()));
-            List<AreaBuildingZoning> zonings = zoningService.selectAreaBuildingZoningList(new AreaBuildingZoning());
-            Map<String, AreaBuildingZoning> zoningMap = zonings.stream()
-                .collect(Collectors.toMap(AreaBuildingZoning::getZoningCode, Function.identity()));
-
-            for (EmsDevice device : list) {
-                fillAreaName(device, areaMap, buildingMap, zoningMap);
-            }
-        }
+    public List<EmsDevice> selectList(QueryDevice queryDevice) {
+        return emsDeviceMapper.selectDeviceList(queryDevice);
+    }
 
+    @Override
+    public List<EmsDevice> selectDetailList(QueryDevice queryDevice) {
+        List<EmsDevice> list = emsDeviceMapper.selectDetailList(queryDevice);
+        fillFieldBath(list);
         return list;
     }
 
@@ -116,26 +105,15 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
     @Override
     public List<EmsDevice> selectByAreaTree(QueryDevice queryDevice) {
         List<EmsDevice> list = emsDeviceMapper.selectByAreaTree(queryDevice);
-
-        if (CollectionUtils.isNotEmpty(list)) {
-            List<Area> areas = areaService.selectAreaList(new Area());
-            Map<String, Area> areaMap = areas.stream()
-                .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
-            List<AreaBuilding> buildings = buildingService.selectAreaBuildingList(new AreaBuilding());
-            Map<String, AreaBuilding> buildingMap = buildings.stream()
-                .collect(Collectors.toMap(AreaBuilding::getBldgCode, Function.identity()));
-            List<AreaBuildingZoning> zonings = zoningService.selectAreaBuildingZoningList(new AreaBuildingZoning());
-            Map<String, AreaBuildingZoning> zoningMap = zonings.stream()
-                .collect(Collectors.toMap(AreaBuildingZoning::getZoningCode, Function.identity()));
-
-            for (EmsDevice device : list) {
-                fillAreaName(device, areaMap, buildingMap, zoningMap);
-            }
-        }
-
+        fillFieldBath(list);
         return list;
     }
 
+    @Override
+    public List<EmsDevice> selectByFlowRel(QueryDevice emsDevice) {
+       return emsDeviceMapper.selectByFlowRel(emsDevice);
+    }
+
     /**
      * 根据设施获取设备树结构
      *
@@ -196,7 +174,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             List<TreeEntity> subList = new ArrayList<>();
 
             queryParam.setRefFacs(facs.getFacsCode());
-            List<EmsDevice> devices = emsDeviceMapper.selectEmsDeviceList(queryParam);
+            List<EmsDevice> devices = emsDeviceMapper.selectDeviceList(queryParam);
 
             for (EmsDevice device : devices) {
                 hasSub = true;
@@ -290,9 +268,43 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         return emsDeviceMapper.deleteEmsDeviceById(id);
     }
 
-    public void fillAreaName(EmsDevice emsDevice) {
+    @Override
+    public List<Map<String, Object>> cntDeviceStatus(String areaCode) {
+        return emsDeviceMapper.cntDeviceStatus(areaCode);
+    }
+
+    @Override
+    public List<Map<String, Object>> calcDeviceOnlineSummary(String areaCode) {
+        return emsDeviceMapper.calcDeviceOnlineSummary(areaCode);
+    }
+
+    /**
+     * 批量填充字段
+     *
+     * @param list 能源设备列表
+     */
+    private void fillFieldBath(List<EmsDevice> list) {
+        if (CollectionUtils.isNotEmpty(list)) {
+            List<Area> areas = areaService.selectAreaList(new Area());
+            Map<String, Area> areaMap = areas.stream()
+                .collect(Collectors.toMap(Area::getAreaCode, Function.identity()));
+            List<AreaBuilding> buildings = buildingService.selectAreaBuildingList(new AreaBuilding());
+            Map<String, AreaBuilding> buildingMap = buildings.stream()
+                .collect(Collectors.toMap(AreaBuilding::getBldgCode, Function.identity()));
+            List<AreaBuildingZoning> zonings = zoningService.selectAreaBuildingZoningList(new AreaBuildingZoning());
+            Map<String, AreaBuildingZoning> zoningMap = zonings.stream()
+                .collect(Collectors.toMap(AreaBuildingZoning::getZoningCode, Function.identity()));
+
+            for (EmsDevice device : list) {
+                fillAreaName(device, areaMap, buildingMap, zoningMap);
+            }
+        }
+    }
+
+    private void fillAreaName(EmsDevice emsDevice, Map<String, Area> areaMap, Map<String, AreaBuilding> buildingMap,
+        Map<String, AreaBuildingZoning> zoningMap) {
         if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Area.name())) {
-            Area area = areaService.selectAreaByCode(emsDevice.getRefArea());
+            Area area = areaMap.get(emsDevice.getRefArea());
 
             if (null != area) {
                 emsDevice.setRefAreaName(area.getAreaName());
@@ -304,7 +316,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             }
         }
         else if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Building.name())) {
-            AreaBuilding building = buildingService.selectAreaBuildingByCode(emsDevice.getRefArea());
+            AreaBuilding building = buildingMap.get(emsDevice.getRefArea());
 
             if (null != building) {
                 emsDevice.setRefAreaName(building.getBldgName());
@@ -316,12 +328,12 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             }
         }
         else if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Zoning.name())) {
-            AreaBuildingZoning zoning = zoningService.selectAreaBuildingZoningByCode(emsDevice.getRefArea());
+            AreaBuildingZoning zoning = zoningMap.get(emsDevice.getRefArea());
 
             if (null != zoning) {
                 emsDevice.setRefAreaName(zoning.getZoningName());
 
-                AreaBuilding building = buildingService.selectAreaBuildingByCode(zoning.getBldgCode());
+                AreaBuilding building = buildingMap.get(zoning.getBldgCode());
 
                 if (null != building) {
                     emsDevice.setAreaPath(
@@ -337,10 +349,9 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         }
     }
 
-    public void fillAreaName(EmsDevice emsDevice, Map<String, Area> areaMap, Map<String, AreaBuilding> buildingMap,
-        Map<String, AreaBuildingZoning> zoningMap) {
+    private void fillAreaName(EmsDevice emsDevice) {
         if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Area.name())) {
-            Area area = areaMap.get(emsDevice.getRefArea());
+            Area area = areaService.selectAreaByCode(emsDevice.getRefArea());
 
             if (null != area) {
                 emsDevice.setRefAreaName(area.getAreaName());
@@ -352,7 +363,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             }
         }
         else if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Building.name())) {
-            AreaBuilding building = buildingMap.get(emsDevice.getRefArea());
+            AreaBuilding building = buildingService.selectAreaBuildingByCode(emsDevice.getRefArea());
 
             if (null != building) {
                 emsDevice.setRefAreaName(building.getBldgName());
@@ -364,12 +375,12 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
             }
         }
         else if (StringUtils.equals(emsDevice.getAreaType(), AreaTier.Zoning.name())) {
-            AreaBuildingZoning zoning = zoningMap.get(emsDevice.getRefArea());
+            AreaBuildingZoning zoning = zoningService.selectAreaBuildingZoningByCode(emsDevice.getRefArea());
 
             if (null != zoning) {
                 emsDevice.setRefAreaName(zoning.getZoningName());
 
-                AreaBuilding building = buildingMap.get(zoning.getBldgCode());
+                AreaBuilding building = buildingService.selectAreaBuildingByCode(zoning.getBldgCode());
 
                 if (null != building) {
                     emsDevice.setAreaPath(
@@ -385,13 +396,7 @@ public class EmsDeviceServiceImpl implements IEmsDeviceService {
         }
     }
 
-    @Override
-    public List<Map<String, Object>> cntDeviceStatus(String areaCode) {
-        return emsDeviceMapper.cntDeviceStatus(areaCode);
-    }
+    private void fillAttribute(EmsDevice device) {
 
-    @Override
-    public List<Map<String, Object>> calcDeviceOnlineSummary(String areaCode) {
-        return emsDeviceMapper.calcDeviceOnlineSummary(areaCode);
     }
 }

+ 1 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/MeterDeviceServiceImpl.java

@@ -170,7 +170,7 @@ public class MeterDeviceServiceImpl implements IMeterDeviceService {
                 }
             }
             else if (MeterObjSubType.METER_DEVICE.getType() == meterDevice.getObjSubType()) {
-                EmsDevice device = deviceService.selectByCode(meterDevice.getObjCode());
+                EmsDevice device = deviceService.selectDetailByCode(meterDevice.getObjCode());
                 if (device != null) {
                     meterDevice.setObjName(device.getAreaPath() + "/" + device.getDeviceName());
                 }

+ 119 - 54
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/ElecLoadIndexMapper.xml

@@ -3,97 +3,162 @@
 PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ems.mapper.ElecLoadIndexMapper">
-
-    <resultMap type="com.ruoyi.ems.domain.ElecLoadIndex" id="ElecLoadIndexResult">
+    
+    <resultMap type="com.ruoyi.ems.domain.ElecLoadIndex" id="indexResult">
         <result property="id"    column="id"    />
         <result property="areaCode"    column="area_code"    />
-        <result property="facsCode"    column="facs_code"    />
+        <result property="objType"    column="obj_type"    />
+        <result property="objCode"    column="obj_code"    />
+        <result property="recordTime"    column="record_time"    />
         <result property="date"    column="date"    />
         <result property="time"    column="time"    />
-        <result property="voltage"    column="voltage"    />
-        <result property="amperage"    column="amperage"    />
-        <result property="power"    column="power"    />
+        <result property="timeIndex"    column="time_index"    />
+        <result property="ua"    column="ua"    />
+        <result property="ub"    column="ub"    />
+        <result property="uc"    column="uc"    />
+        <result property="la"    column="la"    />
+        <result property="lb"    column="lb"    />
+        <result property="lc"    column="lc"    />
+        <result property="p"    column="p"    />
+        <result property="pa"    column="pa"    />
+        <result property="pb"    column="pb"    />
+        <result property="pc"    column="pc"    />
+        <result property="q"    column="q"    />
+        <result property="qa"    column="qa"    />
+        <result property="qb"    column="qb"    />
+        <result property="qc"    column="qc"    />
+        <result property="pf"    column="pf"    />
     </resultMap>
 
-    <sql id="selectElecLoadIndexVo">
-        SELECT
-            loadIndex.id,
-            loadIndex.area_code,
-            loadIndex.facs_code,
-            area.area_name,
-            facs.facs_name,
-            DATE,
-            TIME,
-            voltage,
-            amperage,
-            power
-        FROM
-            adm_ems_elec_load_index loadIndex
-            INNER JOIN adm_ems_facs facs ON loadIndex.facs_code = facs.facs_code
-            INNER JOIN adm_service_area area ON loadIndex.area_code = area.area_code
+    <sql id="selectIndexVo">
+        select id, area_code, obj_type, obj_code, record_time, `date`, `time`, time_index, ua, ub, uc, la, lb, lc, p, pa, pb, pc, q, qa, qb, qc, pf from adm_ems_elec_load_index
     </sql>
 
-    <select id="selectElecLoadIndexList" parameterType="com.ruoyi.ems.domain.ElecLoadIndex" resultType="com.ruoyi.ems.domain.ElecLoadIndex">
-        <include refid="selectElecLoadIndexVo"/>
-        <where>
+    <select id="selectIndexList" parameterType="com.ruoyi.ems.domain.ElecLoadIndex" resultMap="indexResult">
+        <include refid="selectIndexVo"/>
+        <where>  
             <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
-            <if test="facsCode != null  and facsCode != ''"> and facs_code = #{facsCode}</if>
-            <if test="date != null "> and date = #{date}</if>
-            <if test="voltage != null "> and voltage = #{voltage}</if>
-            <if test="amperage != null "> and amperage = #{amperage}</if>
-            <if test="power != null "> and power = #{power}</if>
+            <if test="objType != null "> and obj_type = #{objType}</if>
+            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
+            <if test="recordTime != null "> and record_time = #{recordTime}</if>
+            <if test="date != null "> and `date` = #{date}</if>
+            <if test="time != null "> and `time` = #{time}</if>
+            <if test="timeIndex != null "> and time_index = #{timeIndex}</if>
         </where>
     </select>
 
-    <select id="selectElecLoadIndexById" parameterType="Long" resultMap="ElecLoadIndexResult">
-        <include refid="selectElecLoadIndexVo"/>
+    <select id="selectByTime" parameterType="com.ruoyi.ems.domain.vo.QueryIndex" resultMap="indexResult">
+        <include refid="selectIndexVo"/>
+        <where>
+            <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
+            <if test="objType != null "> and obj_type = #{objType}</if>
+            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
+            <if test="startTime != null  and startTime != ''"> and record_time >= #{startTime}</if>
+            <if test="endTime != null  and endTime != ''"> and record_time = #{endTime}</if>
+        </where>
+    </select>
+    
+    <select id="selectIndexById" parameterType="Long" resultMap="indexResult">
+        <include refid="selectIndexVo"/>
         where id = #{id}
     </select>
 
-    <insert id="insertElecLoadIndex" parameterType="com.ruoyi.ems.domain.ElecLoadIndex" useGeneratedKeys="true" keyProperty="id">
+    <select id="selectNewIndex" resultMap="indexResult">
+        <include refid="selectIndexVo"/>
+        where area_code = #{areaCode} and obj_type = #{objType} and obj_code = #{objCode}
+        order by record_time
+        desc limit 1
+    </select>
+        
+    <insert id="insertIndex" parameterType="com.ruoyi.ems.domain.ElecLoadIndex" useGeneratedKeys="true" keyProperty="id">
         insert into adm_ems_elec_load_index
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="areaCode != null and areaCode != ''">area_code,</if>
-            <if test="facsCode != null and facsCode != ''">facs_code,</if>
-            <if test="date != null">date,</if>
-            <if test="time != null">time,</if>
-            <if test="voltage != null">voltage,</if>
-            <if test="amperage != null">amperage,</if>
-            <if test="power != null">power,</if>
+            <if test="objType != null">obj_type,</if>
+            <if test="objCode != null and objCode != ''">obj_code,</if>
+            <if test="recordTime != null">record_time,</if>
+            <if test="date != null">`date`,</if>
+            <if test="time != null">`time`,</if>
+            <if test="timeIndex != null">time_index,</if>
+            <if test="ua != null">ua,</if>
+            <if test="ub != null">ub,</if>
+            <if test="uc != null">uc,</if>
+            <if test="la != null">la,</if>
+            <if test="lb != null">lb,</if>
+            <if test="lc != null">lc,</if>
+            <if test="p != null">p,</if>
+            <if test="pa != null">pa,</if>
+            <if test="pb != null">pb,</if>
+            <if test="pc != null">pc,</if>
+            <if test="q != null">q,</if>
+            <if test="qa != null">qa,</if>
+            <if test="qb != null">qb,</if>
+            <if test="qc != null">qc,</if>
+            <if test="pf != null">pf,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
-            <if test="facsCode != null and facsCode != ''">#{facsCode},</if>
+            <if test="objType != null">#{objType},</if>
+            <if test="objCode != null and objCode != ''">#{objCode},</if>
+            <if test="recordTime != null">#{recordTime},</if>
             <if test="date != null">#{date},</if>
             <if test="time != null">#{time},</if>
-            <if test="voltage != null">#{voltage},</if>
-            <if test="amperage != null">#{amperage},</if>
-            <if test="power != null">#{power},</if>
+            <if test="timeIndex != null">#{timeIndex},</if>
+            <if test="ua != null">#{ua},</if>
+            <if test="ub != null">#{ub},</if>
+            <if test="uc != null">#{uc},</if>
+            <if test="la != null">#{la},</if>
+            <if test="lb != null">#{lb},</if>
+            <if test="lc != null">#{lc},</if>
+            <if test="p != null">#{p},</if>
+            <if test="pa != null">#{pa},</if>
+            <if test="pb != null">#{pb},</if>
+            <if test="pc != null">#{pc},</if>
+            <if test="q != null">#{q},</if>
+            <if test="qa != null">#{qa},</if>
+            <if test="qb != null">#{qb},</if>
+            <if test="qc != null">#{qc},</if>
+            <if test="pf != null">#{pf},</if>
          </trim>
     </insert>
 
-    <update id="updateElecLoadIndex" parameterType="com.ruoyi.ems.domain.ElecLoadIndex">
+    <update id="updateIndex" parameterType="com.ruoyi.ems.domain.ElecLoadIndex">
         update adm_ems_elec_load_index
         <trim prefix="SET" suffixOverrides=",">
             <if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if>
-            <if test="facsCode != null and facsCode != ''">facs_code = #{facsCode},</if>
-            <if test="date != null">date = #{date},</if>
-            <if test="time != null">time = #{time},</if>
-            <if test="voltage != null">voltage = #{voltage},</if>
-            <if test="amperage != null">amperage = #{amperage},</if>
-            <if test="power != null">power = #{power},</if>
+            <if test="objType != null">obj_type = #{objType},</if>
+            <if test="objCode != null and objCode != ''">obj_code = #{objCode},</if>
+            <if test="recordTime != null">record_time = #{recordTime},</if>
+            <if test="date != null">`date` = #{date},</if>
+            <if test="time != null">`time` = #{time},</if>
+            <if test="timeIndex != null">time_index = #{timeIndex},</if>
+            <if test="ua != null">ua = #{ua},</if>
+            <if test="ub != null">ub = #{ub},</if>
+            <if test="uc != null">uc = #{uc},</if>
+            <if test="la != null">la = #{la},</if>
+            <if test="lb != null">lb = #{lb},</if>
+            <if test="lc != null">lc = #{lc},</if>
+            <if test="p != null">p = #{p},</if>
+            <if test="pa != null">pa = #{pa},</if>
+            <if test="pb != null">pb = #{pb},</if>
+            <if test="pc != null">pc = #{pc},</if>
+            <if test="q != null">q = #{q},</if>
+            <if test="qa != null">qa = #{qa},</if>
+            <if test="qb != null">qb = #{qb},</if>
+            <if test="qc != null">qc = #{qc},</if>
+            <if test="pf != null">pf = #{pf},</if>
         </trim>
         where id = #{id}
     </update>
 
-    <delete id="deleteElecLoadIndexById" parameterType="Long">
+    <delete id="deleteIndexById" parameterType="Long">
         delete from adm_ems_elec_load_index where id = #{id}
     </delete>
 
-    <delete id="deleteElecLoadIndexByIds" parameterType="String">
-        delete from adm_ems_elec_load_index where id in
+    <delete id="deleteIndexByIds" parameterType="String">
+        delete from adm_ems_elec_load_index where id in 
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+</mapper>

+ 51 - 8
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/EmsDeviceMapper.xml

@@ -28,9 +28,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateTime"          column="update_time"    />
     </resultMap>
 
-    <sql id="selectEmsDeviceVo">
+    <sql id="selectDeviceVo">
         select
-            d.`id`, d.`device_code`, d.`device_name`, d.`device_category`, d.`device_status`, d.`area_type`, d.`ref_area`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, d.`create_time`, d.`update_time`,
+            d.`id`, d.`device_code`, d.`device_name`, d.`device_category`, d.`device_brand`, d.`device_spec`, d.`location`, d.`device_status`, d.`area_type`, d.`ref_area`, d.`area_ancestors`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, d.`create_time`, d.`update_time`
+        from adm_ems_device d
+    </sql>
+
+    <sql id="selectDetailDeviceVo">
+        select
+            d.`id`, d.`device_code`, d.`device_name`, d.`device_category`, d.`device_brand`, d.`device_spec`, d.`location`, d.`device_status`, d.`area_type`, d.`ref_area`, d.`area_ancestors`, d.`device_model`, d.`ref_facs`, d.`subsystem_code`, d.`ps_code`, d.`create_time`, d.`update_time`,
             sc.`name` as device_category_name,
             dp.`ps_name`,
             s.`system_name` as subsystem_name,
@@ -42,12 +48,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             LEFT JOIN adm_ems_facs f ON d.`ref_facs` = f.`facs_code`
     </sql>
 
-    <select id="selectEmsDeviceList" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
-        <include refid="selectEmsDeviceVo"/>
+    <select id="selectDeviceList" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
+        <include refid="selectDeviceVo"/>
+        <where>
+            <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
+            <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
+            <if test="deviceSubCategory != null and deviceSubCategory !=''"> and d.`device_category` = #{deviceSubCategory}</if>
+            <if test="deviceStatus != null "> and d.`device_status` = #{deviceStatus}</if>
+            <if test="areaType != null and areaType != ''"> and d.`area_type` = #{areaType}</if>
+            <if test="refArea != null  and refArea != ''"> and d.`ref_area` = #{refArea}</if>
+            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
+            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
+            <if test="deviceModel != null  and deviceModel != ''"> and d.`device_model` = #{device_model}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
+        </where>
+    </select>
+
+    <select id="selectByFlowRel" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
+        <include refid="selectDeviceVo"/>
+        LEFT JOIN adm_ems_flow_rel rel ON d.`device_code` = rel.`input_obj`
+        <where>
+            <if test="areaType != null and areaType != ''"> and d.`area_type` = #{areaType}</if>
+            <if test="refArea != null  and refArea != ''"> and d.`ref_area` = #{refArea}</if>
+            <if test="deviceSubCategory != null and deviceSubCategory !=''"> and d.`device_category` = #{deviceSubCategory}</if>
+            <if test="psCode != null  and psCode != ''"> and d.`ps_code` = #{psCode}</if>
+            <if test="subsystemCode != null  and subsystemCode != ''"> and d.`subsystem_code` = #{subsystemCode}</if>
+            <if test="refFacs != null  and refFacs != ''"> and d.`ref_facs` = #{refFacs}</if>
+            <if test="upstreamObjType != null"> and rel.`export_obj_type` = #{upstreamObjType}</if>
+            <if test="upstreamObjCode != null  and upstreamObjCode != ''"> and rel.`export_obj` = #{upstreamObjCode}</if>
+        </where>
+    </select>
+
+    <select id="selectDetailList" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
+        <include refid="selectDetailDeviceVo"/>
         <where>
             <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
             <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
             <if test="deviceCategory != null and deviceCategory !=''"> and sc.`parent_code` = #{deviceCategory}</if>
+            <if test="deviceSubCategory != null and deviceSubCategory !=''"> and d.`device_category` = #{deviceSubCategory}</if>
             <if test="deviceStatus != null "> and d.`device_status` = #{deviceStatus}</if>
             <if test="areaType != null and areaType != ''"> and d.`area_type` = #{areaType}</if>
             <if test="refArea != null  and refArea != ''"> and d.`ref_area` = #{refArea}</if>
@@ -60,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <!-- 递归查询 区域/建筑/区块 下的设备 -->
     <select id="selectByAreaTree" parameterType="com.ruoyi.ems.domain.vo.QueryDevice" resultMap="EmsDeviceResult">
-        <include refid="selectEmsDeviceVo"/>
+        <include refid="selectDetailDeviceVo"/>
         <where>
             <if test="deviceCode != null  and deviceCode != ''"> and d.`device_code` = #{deviceCode}</if>
             <if test="deviceName != null  and deviceName != ''"> and d.`device_name` like concat('%', #{deviceName}, '%')</if>
@@ -102,12 +140,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectEmsDeviceById" parameterType="Long" resultMap="EmsDeviceResult">
-        <include refid="selectEmsDeviceVo"/>
+        <include refid="selectDeviceVo"/>
         where d.`id` = #{id}
     </select>
 
-    <select id="selectEmsDeviceByCode" parameterType="java.lang.String" resultMap="EmsDeviceResult">
-        <include refid="selectEmsDeviceVo"/>
+    <select id="selectDeviceByCode" parameterType="java.lang.String" resultMap="EmsDeviceResult">
+        <include refid="selectDeviceVo"/>
+        where d.`device_code` = #{code}
+    </select>
+
+    <select id="selectDetailByCode" parameterType="java.lang.String" resultMap="EmsDeviceResult">
+        <include refid="selectDetailDeviceVo"/>
         where d.`device_code` = #{code}
     </select>
 

+ 34 - 20
ems-cloud/sql/ems_init_data.sql

@@ -122,23 +122,32 @@ INSERT INTO `adm_ems_facs` (`facs_code`, `facs_name`, `facs_category`, `facs_sub
 
 -- 对象模型表
 INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_W2', '国网设施模型', 1);
-INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_E501', '北区光伏设施模型', 1);
-INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_E502', '南区光伏设施模型', 1);
-INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_E503', '主路光伏设施模型', 1);
-INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_C101', '北区储能模型', 1);
-INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_C102', '南区储能模型', 1);
+INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_E5', '光伏设施模型', 1);
+INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_C1', '储能模型', 1);
+INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_W2_T', '变压器设备模型', 2);
 INSERT INTO `adm_ems_obj_model` (`model_code`, `model_name`, `obj_type`) VALUES ('M_Z010', '照明设备模型', 2);
 
-
 -- 对象属性DEMO数据
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2',    'voltageLevel',      '电压等级', 'kV');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E501',  'installedCapacity', '装机容量', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E502',  'installedCapacity', '装机容量', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E503',  'installedCapacity', '装机容量', 'kw');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_C101',  'storageCapacity',   '储能容量', 'kW-h');
-INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_C102',  'storageCapacity',   '储能容量', 'kW-h');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2', 'frequency', '频率', 'Hz');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2', 'voltageLevel', '电压等级', 'kV');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2_T', 'ratedCapacity', '额定容量', 'kVA');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2_T', 'ratedVoltage', '额定电压', 'kV');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2_T', 'ratedFrequency', '额定频率', 'Hz');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_W2_T', 'phaseNumber', '相数', '相');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_E5',  'installedCapacity', '装机容量', 'kw');
+INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_C1',  'storageCapacity',   '储能容量', 'kW-h');
 INSERT INTO `adm_ems_obj_attr` (`model_code`, `attr_key`, `attr_name`, `attr_unit`) VALUES ('M_Z010',  'power',   '功率', 'kW-h');
 
+-- 对象属性DEMO数据
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedCapacity', '1000', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedVoltage', '10', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'ratedFrequency', '50', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-B-T-1001', 2, 'phaseNumber', '3', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-N-T-1002', 2, 'ratedCapacity', '1000', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-N-T-1002', 2, 'ratedVoltage', '10', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-N-T-1002', 2, 'ratedFrequency', '50', 'M_W2_T');
+INSERT INTO `adm_ems_obj_attr_value` (`obj_code`, `obj_type`, `attr_key`, `attr_value`, `model_code`) VALUES ('D-N-T-1002', 2, 'phaseNumber', '3', 'M_W2_T');
+
 -- 对象能力DEMO数据
 INSERT INTO `adm_ems_obj_ability` (`model_code`, `ability_key`, `ability_name`, `ability_desc`, `ability_param`) VALUES ('M_W2', 'checkLine', '线路检测', '执行xx方法进行测试', '{\"enable\":\"1\"}');
 
@@ -260,8 +269,8 @@ INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-002', '光伏板2',      'E5', null, null, null, '1', 'Building', 'S30K140-S30K150', '321283124S3003,S30K140-S30K150', null, 'E503', null, 'SYS_GF');
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ( 'E503-K140-K150-003', '光伏板3',      'E5', null, null, null, '1', 'Building', 'S30K150-S30K180', '321283124S3003,S30K150-S30K180', null, 'E503', null, 'SYS_GF');
 
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-T-1001', '变压器', 'W2', '西门子', 'T221123', '北区', 1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'T', null);
-INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-T-1002', '变压器', 'W2', '西门子', 'T221212', '南区', 1, 'Area', '321283124S3002', '321283124S3002', null, 'W201', 'T', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-T-1001', '变压器', 'W2', '西门子', 'T221123', '北区', 1, 'Area', '321283124S3001', '321283124S3001', 'M_W2_T', 'W201', 'T', null);
+INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-T-1002', '变压器', 'W2', '西门子', 'T221212', '南区', 1, 'Area', '321283124S3002', '321283124S3002', 'M_W2_T', 'W201', 'T', null);
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1001', '配电柜', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-B-1002', '配电柜', 'W2', '安科瑞', 'DX2121021', '广场配电柜',   1, 'Area', '321283124S3001', '321283124S3001', null, 'W201', 'AP', null);
 INSERT INTO `adm_ems_device` (`device_code`, `device_name`, `device_category`, `device_brand`, `device_spec`, `location`, `device_status`, `area_type`, `ref_area`, `area_ancestors`, `device_model`, `ref_facs`, `ps_code`, `subsystem_code`) VALUES ('D-N-1001', '配电柜', 'W2', '安科瑞', 'DX2121021', '综合楼配电间', 1, 'Area', '321283124S3002', '321283124S3002', null, 'W202', 'AP', null);
@@ -341,12 +350,12 @@ insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','N-11
 insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','N-118','Area_00');
 insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','N-119','Area_00');
 
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-CD','Area_00');
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-DKC','Area_00');
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-HC','Area_00');
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-WXP','Area_00');
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-WZA','Area_00');
-insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3','321283124S3002_CW-XK','Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-CD',  'Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-DKC', 'Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-HC',  'Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-WXP', 'Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-WZA', 'Area_00');
+insert into adm_obj_tag_rel (`tag_type`,`obj_code`,`tag_code`) VALUES ('3', '321283124S3002_CW-XK',  'Area_00');
 
 -- 服务区用电属性数据
 INSERT INTO adm_area_elec_attr (`area_code`, `price_code`, `req_capacity_flag`, `trans_capacity`, `req_quantity`) VALUES ('321283124S3001', '4001', 1, 630, NULL);
@@ -726,6 +735,11 @@ INSERT INTO `adm_ems_facs_use_h` (`area_code`, `facs_code`, `device_code`, `reco
 INSERT INTO `adm_ems_facs_use_h` (`area_code`, `facs_code`, `device_code`, `record_time`, `date`, `time`, `time_index`, `elec_quantity`) VALUES ('321283124S3001', 'Z101', NULL, '2024-09-01 23:00:00', '2024-09-01', '23:00:00', 24, 13);
 
 
+-- 电力负荷数据
+INSERT INTO `adm_ems_elec_load_index` (`area_code`, `obj_type`, `obj_code`, `record_time`, `date`, `time`, `time_index`, `ua`, `ub`, `uc`, `la`, `lb`, `lc`, `p`, `pa`, `pb`, `pc`, `q`, `qa`, `qb`, `qc`, `pf`) VALUES ('321283124S3001', 2, 'D-B-1001', '2024-09-27 00:00:00', '2024-09-27', '00:00:00', 1, 380, 380, 380, 27, 2.1, 2.8, 5120, 2121, 2145, 2247, 321, 101, 121, 121, 7.5);
+INSERT INTO `adm_ems_elec_load_index` (`area_code`, `obj_type`, `obj_code`, `record_time`, `date`, `time`, `time_index`, `ua`, `ub`, `uc`, `la`, `lb`, `lc`, `p`, `pa`, `pb`, `pc`, `q`, `qa`, `qb`, `qc`, `pf`) VALUES ('321283124S3001', 2, 'D-B-1001', '2024-09-27 00:05:00', '2024-09-27', '00:00:00', 2, 380, 380, 380, 27, 2.1, 2.8, 5220, 1821, 2345, 2047, 200, 151, 178, 144, 6.5);
+
+
 -- 台账数据
 INSERT INTO `adm_ems_device_rbook` (`record_code`, `obj_type`, `obj_code`, `obj_name`, `record_time`, `ins_location`, `maintain_title`, `maintain_content`, `maintain_person`) VALUES ('TZ-20240901001', 1, 'W201', '北区-电网', '2024-09-01 10:32:00', '北区-广场', '北区广场变压器维护', '执行例行维护', '李大航');
 INSERT INTO `adm_ems_device_rbook` (`record_code`, `obj_type`, `obj_code`, `obj_name`, `record_time`, `ins_location`, `maintain_title`, `maintain_content`, `maintain_person`) VALUES ('TZ-20240901002', 2, 'Z010-R101-001', '北区-开水炉', '2024-09-10 17:34:56', '北区/综合楼/一楼开水间', '开水炉除垢', '执行开水炉除垢', '王凯');

+ 22 - 6
ems-cloud/sql/ems_server.sql

@@ -1197,14 +1197,30 @@ drop table if exists adm_ems_elec_load_index;
 create table adm_ems_elec_load_index (
   `id`                        bigint(20)      not null auto_increment      comment '序号',
   `area_code`                 varchar(16)     not null                     comment '园区代码',
-  `facs_code`                 varchar(16)     not null                     comment '设施代码',
+  `obj_type`                  int             not null                     comment '对象类型',
+  `obj_code`                  varchar(64)     not null                     comment '对象编码',
+  `record_time`               timestamp       not null                     comment '记录时间',
   `date`                      date            not null                     comment '日期 yyyy-MM-dd',
-  `time`                      datetime        not null                     comment '时间 yyyy-MM-dd HH:mm:ss',
-  `voltage`                   double          default null                 comment '电压 单位:kV(千伏)',
-  `electricity`               double          default null                 comment '电流 单位:A(安培)',
-  `power`                     double          default null                 comment '功率 单位:kW(千瓦)',
+  `time`                      time            not null                     comment '时间 HH:mm:ss',
+  `time_index`                int             not null                     comment '事件序列',
+  `ua`                        double          default null                 comment '电压 单位:V(伏)',
+  `ub`                        double          default null                 comment '电压 单位:V(伏)',
+  `uc`                        double          default null                 comment '电压 单位:V(伏)',
+  `la`                        double          default null                 comment '电流 单位:A(伏)',
+  `lb`                        double          default null                 comment '电流 单位:A(伏)',
+  `lc`                        double          default null                 comment '电流 单位:A(伏)',
+  `p`                         double          default null                 comment '有功总功率',
+  `pa`                        double          default null                 comment 'A相有功功率',
+  `pb`                        double          default null                 comment 'B相有功功率',
+  `pc`                        double          default null                 comment 'C相有功功率',
+  `q`                         double          default null                 comment '无功总功率',
+  `qa`                        double          default null                 comment 'A相无功总功率',
+  `qb`                        double          default null                 comment 'B相无功总功率',
+  `qc`                        double          default null                 comment 'C相无功总功率',
+  `pf`                        double          default null                 comment '功率因素',
   primary key (`id`),
-  unique key ux_ems_elec_load_index(`facs_code`, `time`)
+  unique key ux_ems_elec_load_index(`area_code`, `obj_type`, `obj_code`, `record_time`),
+  key ux_ems_elec_load_index_date(`date`)
 ) engine=innodb auto_increment=1 comment = '电力负荷设施指标表';