lv.wenbin 9 months ago
parent
commit
3dcde3bb83

+ 8 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/ElecUseHController.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
 
+import com.ruoyi.ems.domain.vo.ElecUseSta;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -52,7 +53,13 @@ public class ElecUseHController extends BaseController {
 
     @GetMapping("/sumBySubCategory")
     public AjaxResult sumBySubCategory(ElecUseH elecUseH) {
-        List<ElecUseH> list = elecUseHService.getSumBySubCategory(elecUseH);
+        List<ElecUseSta> list = elecUseHService.getSumBySubCategory(elecUseH);
+        return success(list);
+    }
+
+    @GetMapping("/sumByFacs")
+    public AjaxResult sumByFacs(ElecUseH elecUseH) {
+        List<ElecUseSta> list = elecUseHService.getSumBySubCategory(elecUseH);
         return success(list);
     }
 

+ 4 - 4
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/domain/ElecUseH.java

@@ -66,8 +66,8 @@ public class ElecUseH extends BaseEntity
 
 
     /** 用电量 单位:kW-h(千瓦时) */
-    @Excel(name = "用电量 单位:kW-h", readConverterExp = "千=瓦时")
-    private Long elecQuantity;
+    @Excel(name = "用电量 单位:kW·h")
+    private Double elecQuantity;
 
     public Long getId() {
         return id;
@@ -173,11 +173,11 @@ public class ElecUseH extends BaseEntity
         this.timeIndex = timeIndex;
     }
 
-    public Long getElecQuantity() {
+    public Double getElecQuantity() {
         return elecQuantity;
     }
 
-    public void setElecQuantity(Long elecQuantity) {
+    public void setElecQuantity(Double elecQuantity) {
         this.elecQuantity = elecQuantity;
     }
 

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

@@ -0,0 +1,76 @@
+/*
+ * 文 件 名:  ElecUseSta
+ * 版    权:  浩鲸云计算科技股份有限公司
+ * 描    述:  <描述>
+ * 修 改 人:  lvwenbin
+ * 修改时间:  2024/10/10
+ * 跟踪单号:  <跟踪单号>
+ * 修改单号:  <修改单号>
+ * 修改内容:  <修改内容>
+ */
+package com.ruoyi.ems.domain.vo;
+
+import java.util.List;
+
+/**
+ * 用电量统计
+ * <功能详细描述>
+ *
+ * @author lvwenbin
+ * @version [版本号, 2024/10/10]
+ * @see [相关类/方法]
+ * @since [产品/模块版本]
+ */
+public class ElecUseSta {
+    /**
+     * 对象代码
+     */
+    private String objCode;
+
+    /**
+     * 对象名称
+     */
+    private String objName;
+
+    /**
+     * 用电量
+     */
+    private Double elecQuantity;
+
+    /**
+     * 用电分项
+     */
+    private List<ElecUseSta> subentry;
+
+    public String getObjCode() {
+        return objCode;
+    }
+
+    public void setObjCode(String objCode) {
+        this.objCode = objCode;
+    }
+
+    public String getObjName() {
+        return objName;
+    }
+
+    public void setObjName(String objName) {
+        this.objName = objName;
+    }
+
+    public Double getElecQuantity() {
+        return elecQuantity;
+    }
+
+    public void setElecQuantity(Double elecQuantity) {
+        this.elecQuantity = elecQuantity;
+    }
+
+    public List<ElecUseSta> getSubentry() {
+        return subentry;
+    }
+
+    public void setSubentry(List<ElecUseSta> subentry) {
+        this.subentry = subentry;
+    }
+}

+ 16 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/ElecUseHMapper.java

@@ -3,6 +3,7 @@ package com.ruoyi.ems.mapper;
 import java.util.List;
 import java.util.Map;
 
+import com.ruoyi.ems.domain.vo.ElecUseSta;
 import org.apache.ibatis.annotations.MapKey;
 import org.apache.ibatis.annotations.Param;
 
@@ -33,7 +34,21 @@ public interface ElecUseHMapper {
 
     List<ElecUseH> selectElecUseHListSum(ElecUseH elecUseH);
 
-    List<ElecUseH> selectSumBySubCategory(ElecUseH elecUseH);
+    /**
+     * 根据设施子类合并统计
+     *
+     * @param elecUseH 条件
+     * @return 结果
+     */
+    List<ElecUseSta> selectSumBySubCategory(ElecUseH elecUseH);
+
+    /**
+     * 根据设施子类合并统计
+     *
+     * @param elecUseH 条件
+     * @return 结果
+     */
+    List<ElecUseSta> selectSumByFacs(ElecUseH elecUseH);
 
     /**
      * 新增用能计量-小时

+ 4 - 1
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IElecUseHService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.ruoyi.ems.domain.ElecUseH;
+import com.ruoyi.ems.domain.vo.ElecUseSta;
 
 /**
  * 用能计量-小时Service接口
@@ -35,7 +36,9 @@ public interface IElecUseHService {
      */
     List<ElecUseH> getElecUseHListSum(ElecUseH elecUseH);
 
-    List<ElecUseH> getSumBySubCategory(ElecUseH elecUseH);
+    List<ElecUseSta> getSumBySubCategory(ElecUseH elecUseH);
+
+    List<ElecUseSta> getSumByFacs(ElecUseH elecUseH);
 
     /**
      * 新增用能计量-小时

+ 20 - 2
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/ElecUseHServiceImpl.java

@@ -1,9 +1,12 @@
 package com.ruoyi.ems.service.impl;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
+import com.ruoyi.ems.domain.vo.ElecUseSta;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -58,8 +61,23 @@ public class ElecUseHServiceImpl implements IElecUseHService {
     }
 
     @Override
-    public List<ElecUseH> getSumBySubCategory(ElecUseH elecUseH) {
-        return elecUseHMapper.selectSumBySubCategory(elecUseH);
+    public List<ElecUseSta> getSumBySubCategory(ElecUseH elecUseH) {
+        List<ElecUseSta> retList = elecUseHMapper.selectSumBySubCategory(elecUseH);
+
+        if (CollectionUtils.isNotEmpty(retList)) {
+            for (ElecUseSta staObj : retList) {
+                elecUseH.setFacsSubCategory(staObj.getObjCode());
+                List<ElecUseSta> subentryList = elecUseHMapper.selectSumByFacs(elecUseH);
+                staObj.setSubentry(subentryList);
+            }
+        }
+
+        return retList;
+    }
+
+    @Override
+    public List<ElecUseSta> getSumByFacs(ElecUseH elecUseH) {
+        return elecUseHMapper.selectSumByFacs(elecUseH);
     }
 
     /**

+ 25 - 1
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/ElecUseHMapper.xml

@@ -19,6 +19,12 @@
         <result property="elecQuantity" column="elec_quantity"/>
     </resultMap>
 
+    <resultMap type="com.ruoyi.ems.domain.vo.ElecUseSta" id="elecUseResult">
+        <result property="objCode" column="obj_code"/>
+        <result property="objName" column="obj_name"/>
+        <result property="elecQuantity" column="elec_quantity"/>
+    </resultMap>
+
     <sql id="selectElecUseHVo">
         select u.id,
                u.area_code,
@@ -123,7 +129,7 @@
             u.`time_index`
     </select>
 
-    <select id="selectSumBySubCategory" parameterType="com.ruoyi.ems.domain.ElecUseH" resultMap="elecUseHResult">
+    <select id="selectSumBySubCategory" parameterType="com.ruoyi.ems.domain.ElecUseH" resultMap="elecUseResult">
         select
           sc.`code` as obj_code, sc.`name` as obj_name, sum(t.elec_quantity) as elec_quantity
         from dim_ems_facs_subcategory sc
@@ -136,6 +142,7 @@
             <where>
               f.facs_category = 'Z'
               and u.obj_type = 1
+              <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and f.ref_area = #{areaCode}</if>
               <if test="startRecTime != null  and startRecTime != '' and endRecTime != null and endRecTime !=''">
                   and u.record_time &gt;= #{startRecTime} and u.record_time &lt;= #{endRecTime}
               </if>
@@ -146,6 +153,23 @@
         GROUP BY sc.`code`, sc.`name`;
     </select>
 
+    <select id="selectSumByFacs" parameterType="com.ruoyi.ems.domain.ElecUseH" resultMap="elecUseResult">
+        select
+          f.facs_code as obj_code, f.facs_name as obj_name, sum(u.elec_quantity) as elec_quantity
+        from
+          adm_ems_facs f
+          left join adm_ems_obj_use_h u on f.facs_code = u.obj_code
+        <where>
+            and u.obj_type = 1
+            <if test="areaCode != null and areaCode != '' and areaCode != '-1'">and u.area_code = #{areaCode}</if>
+            <if test="facsSubCategory != null and facsSubCategory != ''">and f.facs_subcategory = #{facsSubCategory}</if>
+            <if test="startRecTime != null  and startRecTime != '' and endRecTime != null and endRecTime !=''">
+                and u.record_time &gt;= #{startRecTime} and u.record_time &lt;= #{endRecTime}
+            </if>
+        </where>
+        GROUP BY f.facs_code, f.facs_name
+    </select>
+
     <select id="selectElecUseHById" parameterType="Long" resultMap="elecUseHResult">
         <include refid="selectElecUseHVo"/>
         where u.`id` = #{id}