chen.cheng преди 3 месеца
родител
ревизия
deb47e68b2

+ 34 - 71
ems/ems-core/src/main/java/com/ruoyi/ems/domain/ElecExpendForecast.java

@@ -3,6 +3,8 @@ package com.ruoyi.ems.domain;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.huashe.common.annotation.Excel;
 import com.huashe.common.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
 import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 
@@ -10,102 +12,63 @@ import java.util.Date;
 
 /**
  * 电力消耗预测对象 adm_ems_elec_expend_forecast
- * 
+ *
  * @author ruoyi
  * @date 2024-08-12
  */
-public class ElecExpendForecast extends BaseEntity
-{
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class ElecExpendForecast extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 序号 */
+    /**
+     * 序号
+     */
     private Long id;
 
-    /** 园区代码 */
+    /**
+     * 园区代码
+     */
     @Excel(name = "园区代码")
     private String areaCode;
 
-    /** 对象代码 */
+    /**
+     * 对象代码
+     */
     @Excel(name = "对象代码")
     private String objCode;
 
-    /** 对象类型 */
+    private String objName;
+
+    /**
+     * 对象类型
+     */
     @Excel(name = "对象类型")
     private Integer objType;
 
-    /** 日期 */
+    /**
+     * 日期
+     */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date date;
 
-    /** 功率 (千瓦) */
+    /**
+     * 功率 (千瓦)
+     */
     @Excel(name = "功率 ")
     private Double elecUseQuantity;
 
-    public void setId(Long id) 
-    {
-        this.id = id;
-    }
-
-    public Long getId() 
-    {
-        return id;
-    }
-    public void setAreaCode(String areaCode) 
-    {
-        this.areaCode = areaCode;
-    }
-
-    public String getAreaCode() 
-    {
-        return areaCode;
-    }
-    public void setObjCode(String objCode) 
-    {
-        this.objCode = objCode;
-    }
-
-    public String getObjCode() 
-    {
-        return objCode;
-    }
-    public void setObjType(Integer objType) 
-    {
-        this.objType = objType;
-    }
-
-    public Integer getObjType() 
-    {
-        return objType;
-    }
-    public void setDate(Date date) 
-    {
-        this.date = date;
-    }
-
-    public Date getDate() 
-    {
-        return date;
-    }
-    public void setElecUseQuantity(Double elecUseQuantity) 
-    {
-        this.elecUseQuantity = elecUseQuantity;
-    }
-
-    public Double getElecUseQuantity() 
-    {
-        return elecUseQuantity;
-    }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("id", getId())
-            .append("areaCode", getAreaCode())
-            .append("objCode", getObjCode())
-            .append("objType", getObjType())
-            .append("date", getDate())
-            .append("elecUseQuantity", getElecUseQuantity())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("id", getId())
+                .append("areaCode", getAreaCode())
+                .append("objCode", getObjCode())
+                .append("objType", getObjType())
+                .append("date", getDate())
+                .append("elecUseQuantity", getElecUseQuantity())
+                .toString();
     }
 }

+ 4 - 1
ems/ems-core/src/main/java/com/ruoyi/ems/mapper/ElecLoadIndex15minMapper.java

@@ -30,7 +30,7 @@ public interface ElecLoadIndex15minMapper {
      * @return 电力负荷设施指标
      */
     ElecLoadIndex selectNewIndex(@Param("areaCode") String areaCode, @Param("objType") String objType,
-        @Param("objCode") String objCode);
+                                 @Param("objCode") String objCode);
 
     /**
      * 查询电力负荷设施指标列表
@@ -40,6 +40,9 @@ public interface ElecLoadIndex15minMapper {
      */
     List<ElecLoadIndex> selectIndexList(QueryMeter queryMeter);
 
+
+    List<ElecLoadIndex> selectIndexDetailList(QueryMeter queryMeter);
+
     /**
      * 查询电力负荷设施指标(最大负荷)
      *

+ 12 - 0
ems/ems-core/src/main/java/com/ruoyi/ems/service/impl/ElecLoadIndexServiceImpl.java

@@ -44,6 +44,18 @@ public class ElecLoadIndexServiceImpl implements IElecLoadIndexService {
         return indexList;
     }
 
+//    @Override
+//    public List<ElecLoadIndex> selectMin15IndexDetailList(QueryMeter queryMeter) {
+//        List<ElecLoadIndex> indexList = index15minMapper.selectIndexList(queryMeter);
+//
+//        for (ElecLoadIndex index : indexList) {
+//            index.setS(PowerUtils.getSPower(index.getP(), index.getQ()));
+//            index.setPf(PowerUtils.getPF(index.getP(), index.getS()));
+//        }
+//
+//        return indexList;
+//    }
+
     @Override
     public ElecLoadIndex selectMin15IndexMaxLoad(QueryMeter queryMeter) {
         ElecLoadIndex index = index15minMapper.selectIndexMaxLoad(queryMeter);

+ 27 - 6
ems/ems-core/src/main/resources/mapper/ems/ElecExpendForecastMapper.xml

@@ -18,13 +18,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </sql>
 
     <select id="selectElecExpendForecastList" parameterType="com.ruoyi.ems.domain.ElecExpendForecast" resultMap="ElecExpendForecastResult">
-        <include refid="selectElecExpendForecastVo"/>
+        select
+        f.id,
+        f.area_code,
+        f.obj_code,
+        f.obj_type,
+        date,
+        elec_use_quantity,
+        COALESCE(a.area_name, fc.facs_name, d.device_name) AS obj_name
+        FROM
+        adm_ems_elec_expend_forecast f
+        LEFT JOIN
+        adm_area a ON
+        f.obj_code = a.area_code
+        AND f.obj_type = 1
+        LEFT JOIN
+        adm_ems_facs fc ON
+        f.obj_code = fc.facs_code
+        AND f.obj_type = 2
+        LEFT JOIN
+        adm_ems_device d ON
+        f.obj_code = d.device_code
+        AND f.obj_type = 3
         <where>
-            <if test="areaCode != null  and areaCode != ''"> and area_code = #{areaCode}</if>
-            <if test="objCode != null  and objCode != ''"> and obj_code = #{objCode}</if>
-            <if test="objType != null "> and obj_type = #{objType}</if>
-            <if test="date != null "> and date = #{date}</if>
-            <if test="elecUseQuantity != null "> and elec_use_quantity = #{elecUseQuantity}</if>
+            <if test="areaCode != null  and areaCode != ''">and f.area_code = #{areaCode}</if>
+            <if test="objCode != null  and objCode != ''">and f.obj_code = #{objCode}</if>
+            <if test="objType != null ">and f.obj_type = #{objType}</if>
+            <if test="date != null ">and f.date = #{date}</if>
+            <if test="elecUseQuantity != null ">and elec_use_quantity = #{elecUseQuantity}</if>
         </where>
     </select>
 

+ 82 - 33
ems/ems-core/src/main/resources/mapper/ems/ElecLoadIndex15minMapper.xml

@@ -39,45 +39,97 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectIndexList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="indexResult">
         select
+        i.obj_code,
+        i.obj_type,
+        COALESCE(a2.area_name,
+        f.facs_name,
+        d.device_name) AS obj_name,
+        f.facs_category,
+        f.facs_subcategory,
+        <if test="(facsCategory != null and facsCategory != '') or (facsSubCategory != null and facsSubCategory != '')">
+            <if test="objCode == null or objCode == ''">
+                fs.name as obj_name,
+            </if>
+        </if>
+        i.record_time,
+        i.`date`,
+        i.`time`,
+        i.`time_index`,
+        sum(i.ua) as ua,
+        sum(i.ub) as ub,
+        sum(i.uc) as uc,
+        sum(i.la) as la,
+        sum(i.lb) as lb,
+        sum(i.lc) as lc,
+        sum(i.p) as p,
+        sum(i.pa) as pa,
+        sum(i.pb) as pb,
+        sum(i.pc) as pc,
+        sum(i.q) as q,
+        sum(i.qa) as qa,
+        sum(i.qb) as qb,
+        sum(i.qc) as qc,
+        sum(i.pf) as pf
+        from adm_ems_elec_load_index_15min i
+        LEFT JOIN adm_ems_facs f ON i.`obj_code` = f.`facs_code`
+        LEFT JOIN dim_ems_facs_subcategory fs ON f.`facs_subcategory` = fs.`code`
+        LEFT JOIN adm_ems_device d ON i.`obj_code` = d.`device_code`
+        LEFT JOIN adm_area a2 ON i.`obj_code` = a2.`area_code`
+        <where>
+            <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and i.area_code = #{areaCode}</if>
+            <if test="objType != null">and i.obj_type = #{objType}</if>
+            <if test="objCode != null  and objCode != ''">and i.obj_code = #{objCode}</if>
+            <if test="facsCategory != null and facsCategory != ''">and fa.facs_category = #{facsCategory}</if>
+            <if test="facsSubCategory != null and facsSubCategory != ''">and fa.facs_subcategory = #{facsSubCategory}
+            </if>
+            <if test="startRecTime != null and startRecTime != '' and endRecTime != null and endRecTime !=''">
+                and i.`record_time` &gt;= #{startRecTime} and i.`record_time` &lt;= #{endRecTime}
+            </if>
+        </where>
+        GROUP BY i.`record_time`
+        ORDER BY i.`record_time` desc
+    </select>
+    <select id="selectIndexDetailList" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="indexResult">
+        select
         <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
-          i.area_code,
-          a.area_name,
-          a.short_name as area_short_name,
+            i.area_code,
+            a.area_name,
+            a.short_name as area_short_name,
         </if>
         <if test="objCode != null and objCode != ''">
-          i.obj_code,
-          CASE
+            i.obj_code,
+            CASE
             WHEN i.obj_type = 1 THEN a2.area_name
             WHEN i.obj_type = 2 THEN f.facs_name
             WHEN i.obj_type = 3 THEN d.device_name
-          END as obj_name,
+            END as obj_name,
         </if>
         <if test="(facsCategory != null and facsCategory != '') or (facsSubCategory != null and facsSubCategory != '')">
-          fa.facs_category,
-          fa.facs_subcategory,
-          <if test="objCode == null or objCode == ''">
-            fs.name as obj_name,
-          </if>
+            fa.facs_category,
+            fa.facs_subcategory,
+            <if test="objCode == null or objCode == ''">
+                fs.name as obj_name,
+            </if>
         </if>
-          i.record_time,
-          i.`date`,
-          i.`time`,
-          i.`time_index`,
-          sum(i.ua) as ua,
-          sum(i.ub) as ub,
-          sum(i.uc) as uc,
-          sum(i.la) as la,
-          sum(i.lb) as lb,
-          sum(i.lc) as lc,
-          sum(i.p) as p,
-          sum(i.pa) as pa,
-          sum(i.pb) as pb,
-          sum(i.pc) as pc,
-          sum(i.q) as q,
-          sum(i.qa) as qa,
-          sum(i.qb) as qb,
-          sum(i.qc) as qc,
-          sum(i.pf) as pf
+        i.record_time,
+        i.`date`,
+        i.`time`,
+        i.`time_index`,
+        sum(i.ua) as ua,
+        sum(i.ub) as ub,
+        sum(i.uc) as uc,
+        sum(i.la) as la,
+        sum(i.lb) as lb,
+        sum(i.lc) as lc,
+        sum(i.p) as p,
+        sum(i.pa) as pa,
+        sum(i.pb) as pb,
+        sum(i.pc) as pc,
+        sum(i.q) as q,
+        sum(i.qa) as qa,
+        sum(i.qb) as qb,
+        sum(i.qc) as qc,
+        sum(i.pf) as pf
         from adm_ems_elec_load_index_15min i
         <if test="areaCode != null and areaCode != '' and areaCode != '-1'">
             LEFT JOIN adm_area a ON i.`area_code` = a.`area_code`
@@ -103,10 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 and i.`record_time` &gt;= #{startRecTime} and i.`record_time` &lt;= #{endRecTime}
             </if>
         </where>
-        GROUP BY i.`record_time`
-        ORDER BY i.`record_time`
     </select>
-
     <select id="selectIndexMaxLoad" parameterType="com.ruoyi.ems.model.QueryMeter" resultMap="indexResult">
         SELECT
             MAX(t.total_p) AS p,