浏览代码

+ 大屏首页接口对接

chen.cheng 1 月之前
父节点
当前提交
bea19f22ee

+ 13 - 0
ems/ems-cloud/ems-server/src/main/java/com/ruoyi/ems/controller/ElecStoreController.java

@@ -8,6 +8,7 @@ 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.ElecStoreH;
+import com.ruoyi.ems.domain.EmsElecStoreIndex;
 import com.ruoyi.ems.model.ElecStoreAnalyze;
 import com.ruoyi.ems.model.QueryMeter;
 import com.ruoyi.ems.service.IElecStoreService;
@@ -75,10 +76,22 @@ public class ElecStoreController extends BaseController {
         util.exportExcel(response, list, "储能计量-小时数据");
     }
 
+    @GetMapping("/sum/h/storage")
+    public AjaxResult selectStoreHByDataRange(ElecStoreH elecStoreH) {
+        return success(elecStoreService.selectStoreHByDataRange(elecStoreH));
+    }
+
+    @GetMapping("/sum/realtime/storage")
+    public AjaxResult selectStorageIndex(EmsElecStoreIndex elecStoreIndex) {
+        return success(elecStoreService.selectStorageIndex(elecStoreIndex));
+    }
+
+
     /**
      * 获取储能计量-小时详细信息
      */
     @GetMapping(value = "/hour/{id}")
+
     public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(elecStoreService.selectHourById(id));
     }

+ 99 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/domain/EmsElecStoreIndex.java

@@ -0,0 +1,99 @@
+package com.ruoyi.ems.domain;
+
+import com.huashe.common.domain.BaseEntity;
+
+import java.util.Date;
+
+public class EmsElecStoreIndex extends BaseEntity {
+    private Long id;                    // 序号
+    private String areaCode;            // 园区代码
+    private String facsCode;            // 设施代码
+    private Date date;                  // 日期 yyyy-MM-dd
+    private Date time;                  // 时间 yyyy-MM-dd HH:mm:ss
+    private Double inputVoltage;        // 输入电压(kV)
+    private Double inputElectricity;    // 输入电流(A)
+    private Double outputVoltage;       // 输出电压(kV)
+    private Double outputElectricity;   // 输出电流(A)
+    private Double currentCapacity;     // 当前容量(kW·h)
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getAreaCode() {
+        return areaCode;
+    }
+
+    public void setAreaCode(String areaCode) {
+        this.areaCode = areaCode;
+    }
+
+    public String getFacsCode() {
+        return facsCode;
+    }
+
+    public void setFacsCode(String facsCode) {
+        this.facsCode = facsCode;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public Date getTime() {
+        return time;
+    }
+
+    public void setTime(Date time) {
+        this.time = time;
+    }
+
+    public Double getInputVoltage() {
+        return inputVoltage;
+    }
+
+    public void setInputVoltage(Double inputVoltage) {
+        this.inputVoltage = inputVoltage;
+    }
+
+    public Double getInputElectricity() {
+        return inputElectricity;
+    }
+
+    public void setInputElectricity(Double inputElectricity) {
+        this.inputElectricity = inputElectricity;
+    }
+
+    public Double getOutputVoltage() {
+        return outputVoltage;
+    }
+
+    public void setOutputVoltage(Double outputVoltage) {
+        this.outputVoltage = outputVoltage;
+    }
+
+    public Double getOutputElectricity() {
+        return outputElectricity;
+    }
+
+    public void setOutputElectricity(Double outputElectricity) {
+        this.outputElectricity = outputElectricity;
+    }
+
+    public Double getCurrentCapacity() {
+        return currentCapacity;
+    }
+
+    public void setCurrentCapacity(Double currentCapacity) {
+        this.currentCapacity = currentCapacity;
+    }
+}

+ 7 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/mapper/EmsElecStoreHMapper.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ems.mapper;
 
 import com.ruoyi.ems.domain.ElecStoreH;
+import com.ruoyi.ems.domain.EmsElecStoreIndex;
 import com.ruoyi.ems.model.ElecStoreSta;
 import com.ruoyi.ems.model.QueryMeter;
 import org.apache.ibatis.annotations.Param;
@@ -46,6 +47,12 @@ public interface EmsElecStoreHMapper {
      */
     List<ElecStoreH> selectStoreHList(ElecStoreH elecStoreH);
 
+
+    ElecStoreH selectStoreHByDataRange(ElecStoreH elecStoreH);
+
+    EmsElecStoreIndex selectStorageIndex(EmsElecStoreIndex emsElecStoreIndex);
+
+
     /**
      * 查询储能计量-日列表
      *

+ 5 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/service/IElecStoreService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ems.service;
 
 import com.ruoyi.ems.domain.ElecStoreH;
+import com.ruoyi.ems.domain.EmsElecStoreIndex;
 import com.ruoyi.ems.model.ElecStoreAnalyze;
 import com.ruoyi.ems.model.QueryMeter;
 
@@ -37,6 +38,10 @@ public interface IElecStoreService {
      */
     List<ElecStoreH> selectHourList(ElecStoreH elecStoreH);
 
+    ElecStoreH selectStoreHByDataRange(ElecStoreH elecStoreH);
+
+    EmsElecStoreIndex selectStorageIndex(EmsElecStoreIndex emsElecStoreIndex);
+
     /**
      * 查询储能计量-日列表
      *

+ 12 - 2
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/ElecStoreServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.ems.service.impl;
 
 import com.ruoyi.ems.domain.ElecStoreH;
+import com.ruoyi.ems.domain.EmsElecStoreIndex;
 import com.ruoyi.ems.mapper.EmsElecStoreHMapper;
 import com.ruoyi.ems.model.ElecStoreAnalyze;
 import com.ruoyi.ems.model.ElecStoreSta;
@@ -56,13 +57,22 @@ public class ElecStoreServiceImpl implements IElecStoreService {
     public List<ElecStoreH> selectHourList(ElecStoreH elecStoreH) {
         if (StringUtils.equals("-1", elecStoreH.getAreaCode())) {
             return elecStoreHMapper.selectStoreHAllArea(elecStoreH);
-        }
-        else {
+        } else {
             return elecStoreHMapper.selectStoreHList(elecStoreH);
         }
     }
 
     @Override
+    public ElecStoreH selectStoreHByDataRange(ElecStoreH elecStoreH) {
+        return elecStoreHMapper.selectStoreHByDataRange(elecStoreH);
+    }
+
+    @Override
+    public EmsElecStoreIndex selectStorageIndex(EmsElecStoreIndex emsElecStoreIndex) {
+        return elecStoreHMapper.selectStorageIndex(emsElecStoreIndex);
+    }
+
+    @Override
     public List<ElecStoreH> selectDayList(QueryMeter param) {
         return elecStoreHMapper.selectStoreDayList(param);
     }

+ 85 - 66
ems/ems-core/src/main/resources/mapper/ems/EmsElecStoreHMapper.xml

@@ -1,59 +1,57 @@
 <?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.EmsElecStoreHMapper">
 
     <resultMap type="com.ruoyi.ems.domain.ElecStoreH" id="StoreHResult">
-        <result property="id"    column="id"    />
-        <result property="areaCode"    column="area_code"    />
-        <result property="areaName"       column="area_name"    />
-        <result property="areaShortName"  column="area_short_name"    />
-        <result property="facsCode"    column="facs_code"    />
-        <result property="facsName"    column="facs_name"    />
-        <result property="recordTime"    column="record_time"    />
-        <result property="date"    column="date"    />
-        <result property="time"    column="time"    />
-        <result property="timeIndex"    column="time_index"    />
-        <result property="chargeElecQuantity"    column="charge_elec_quantity"    />
-        <result property="dischargeElecQuantity"    column="discharge_elec_quantity"    />
+        <result property="id" column="id"/>
+        <result property="areaCode" column="area_code"/>
+        <result property="areaName" column="area_name"/>
+        <result property="areaShortName" column="area_short_name"/>
+        <result property="facsCode" column="facs_code"/>
+        <result property="facsName" column="facs_name"/>
+        <result property="recordTime" column="record_time"/>
+        <result property="date" column="date"/>
+        <result property="time" column="time"/>
+        <result property="timeIndex" column="time_index"/>
+        <result property="chargeElecQuantity" column="charge_elec_quantity"/>
+        <result property="dischargeElecQuantity" column="discharge_elec_quantity"/>
     </resultMap>
 
     <resultMap type="com.ruoyi.ems.model.ElecStoreSta" id="StoreHSumResult">
-        <result property="time"    column="time"    />
-        <result property="timeIndex"    column="time_index"    />
-        <result property="chargeElecQuantity"    column="charge_elec_quantity"    />
-        <result property="dischargeElecQuantity"    column="discharge_elec_quantity"    />
+        <result property="time" column="time"/>
+        <result property="timeIndex" column="time_index"/>
+        <result property="chargeElecQuantity" column="charge_elec_quantity"/>
+        <result property="dischargeElecQuantity" column="discharge_elec_quantity"/>
     </resultMap>
 
     <sql id="selectStoreHVo">
-        SELECT
-            st.id,
-            st.area_code,
-            area.area_name,
-            area.short_name as area_short_name,
-            facs.facs_name,
-            st.facs_code,
-            st.`record_time`,
-            st.`date`,
-            st.`time`,
-            st.time_index,
-            st.charge_elec_quantity,
-            st.discharge_elec_quantity
-        FROM
-            adm_ems_elec_store_h st
-            LEFT JOIN adm_ems_facs facs ON st.facs_code = facs.facs_code
-            LEFT JOIN adm_area area ON st.area_code = area.area_code
+        SELECT st.id,
+               st.area_code,
+               area.area_name,
+               area.short_name as area_short_name,
+               facs.facs_name,
+               st.facs_code,
+               st.`record_time`,
+               st.`date`,
+               st.`time`,
+               st.time_index,
+               st.charge_elec_quantity,
+               st.discharge_elec_quantity
+        FROM adm_ems_elec_store_h st
+                 LEFT JOIN adm_ems_facs facs ON st.facs_code = facs.facs_code
+                 LEFT JOIN adm_area area ON st.area_code = area.area_code
     </sql>
 
     <select id="selectStoreHList" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
         <include refid="selectStoreHVo"/>
         <where>
-            <if test="areaCode != null  and areaCode != ''"> and st.area_code = #{areaCode}</if>
-            <if test="facsCode != null  and facsCode != ''"> and st.facs_code = #{facsCode}</if>
-            <if test="date != null "> and st.`date` = #{date}</if>
-            <if test="chargeElecQuantity != null "> and st.charge_elec_quantity = #{chargeElecQuantity}</if>
-            <if test="dischargeElecQuantity != null "> and st.discharge_elec_quantity = #{dischargeElecQuantity}</if>
+            <if test="areaCode != null  and areaCode != ''">and st.area_code = #{areaCode}</if>
+            <if test="facsCode != null  and facsCode != ''">and st.facs_code = #{facsCode}</if>
+            <if test="date != null ">and st.`date` = #{date}</if>
+            <if test="chargeElecQuantity != null ">and st.charge_elec_quantity = #{chargeElecQuantity}</if>
+            <if test="dischargeElecQuantity != null ">and st.discharge_elec_quantity = #{dischargeElecQuantity}</if>
             <if test="startRecTime != null  and startRecTime != '' and endRecTime != null and endRecTime !=''">
                 and st.`record_time` &gt;= #{startRecTime} and st.`record_time` &lt;= #{endRecTime}
             </if>
@@ -62,7 +60,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         st.`time` DESC,
         st.`time_index`
     </select>
-
+    <select id="selectStoreHByDataRange" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
+        SELECT
+        sum(st.charge_elec_quantity) charge_elec_quantity,
+        sum(st.discharge_elec_quantity) discharge_elec_quantity
+        FROM adm_ems_elec_store_h st
+        <where>
+            <if test="areaCode != null  and areaCode != ''  and areaCode != '-1'">and st.area_code = #{areaCode}</if>
+            <if test="startRecTime != null and startRecTime !='' ">and st.`date` like concat(#{startRecTime},'%')</if>
+        </where>
+    </select>
+    <select id="selectStorageIndex" resultType="EmsElecStoreIndex">
+        SELECT
+        SUM(aeesi.current_capacity) current_capacity
+        FROM (SELECT MAX(id) id
+        FROM adm_ems_elec_store_index storeIndex
+        <where>
+            <if test="areaCode != null  and areaCode != ''  and areaCode != '-1'">and storeIndex.area_code =
+                #{areaCode}
+            </if>
+            <if test="startRecTime != null and startRecTime !='' ">and storeIndex.`date` like concat(#{startRecTime},'%')</if>
+        </where>
+        group by facs_code) AS latest_records
+        inner join adm_ems_elec_store_index aeesi on latest_records.id = aeesi.id
+    </select>
     <select id="selectStoreHAllArea" parameterType="com.ruoyi.ems.domain.ElecStoreH" resultMap="StoreHResult">
         SELECT facCategory.`code` facs_code,
         facCategory.`name` facs_name,
@@ -90,15 +111,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectStoreDayList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="StoreHResult">
         SELECT
-            <if test="facsSubCategory != null and facsSubCategory !=''">
-              sc.`name` as facs_name,
-            </if>
-            <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
-              s.area_code,
-            </if>
-            s.`date`,
-            sum(COALESCE(s.`charge_elec_quantity`, 0)) charge_elec_quantity,
-            sum(COALESCE(s.`discharge_elec_quantity`, 0)) discharge_elec_quantity
+        <if test="facsSubCategory != null and facsSubCategory !=''">
+            sc.`name` as facs_name,
+        </if>
+        <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
+            s.area_code,
+        </if>
+        s.`date`,
+        sum(COALESCE(s.`charge_elec_quantity`, 0)) charge_elec_quantity,
+        sum(COALESCE(s.`discharge_elec_quantity`, 0)) discharge_elec_quantity
         FROM adm_ems_elec_store_h s
         <if test="facsSubCategory != null and facsSubCategory !=''">
             LEFT JOIN adm_ems_facs f ON s.`facs_code` = f.`facs_code`
@@ -125,24 +146,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <select id="selectStoreHSumDate" parameterType="java.lang.String" resultMap="StoreHSumResult">
-        SELECT
-            st.`date` as `time`,
-            sum(st.charge_elec_quantity) as charge_elec_quantity,
-            sum(st.discharge_elec_quantity) as discharge_elec_quantity
-        FROM
-            adm_ems_elec_store_h st
+        SELECT st.`date`                       as `time`,
+               sum(st.charge_elec_quantity)    as charge_elec_quantity,
+               sum(st.discharge_elec_quantity) as discharge_elec_quantity
+        FROM adm_ems_elec_store_h st
         where st.`date` = #{date}
         group by st.`date`
     </select>
 
     <select id="selectStoreHSumHour" parameterType="java.lang.String" resultMap="StoreHSumResult">
-        SELECT
-            st.`time`,
-            st.`time_index`,
-            sum(st.charge_elec_quantity) as charge_elec_quantity,
-            sum(st.discharge_elec_quantity) as discharge_elec_quantity
-        FROM
-            adm_ems_elec_store_h st
+        SELECT st.`time`,
+               st.`time_index`,
+               sum(st.charge_elec_quantity)    as charge_elec_quantity,
+               sum(st.discharge_elec_quantity) as discharge_elec_quantity
+        FROM adm_ems_elec_store_h st
         where st.`date` = #{date}
         group by st.`time`
     </select>
@@ -158,7 +175,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="timeIndex != null">time_index,</if>
             <if test="chargeElecQuantity != null">charge_elec_quantity,</if>
             <if test="dischargeElecQuantity != null">discharge_elec_quantity,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
             <if test="facsCode != null and facsCode != ''">#{facsCode},</if>
@@ -168,7 +185,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="timeIndex != null">#{timeIndex},</if>
             <if test="chargeElecQuantity != null">#{chargeElecQuantity},</if>
             <if test="dischargeElecQuantity != null">#{dischargeElecQuantity},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateStoreH" parameterType="com.ruoyi.ems.domain.ElecStoreH">
@@ -187,7 +204,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteStoreHById" parameterType="Long">
-        delete from adm_ems_elec_store_h where id = #{id}
+        delete
+        from adm_ems_elec_store_h
+        where id = #{id}
     </delete>
 
     <delete id="deleteStoreHByIds" parameterType="String">