Browse Source

设备监测模块设备报表、运行状态统计 更新 报表代码(尚未完成,不影响运行)提交

jichaobo 4 years ago
parent
commit
05925ed623

+ 7 - 0
fiveep-controller/src/main/java/com/bizmatics/controller/web/RtAnalogDataController.java

@@ -75,6 +75,13 @@ public class RtAnalogDataController {
         return ApiResult.success(rtAnalogDataService.getHistoricalCurve(siteId,startTime,endTime,queryType));
     }
 
+    @GetMapping("/DataReportExport")
+    public ApiResult<String> export(@RequestParam Integer siteId,
+                                    @RequestParam(required = false) Date startTime,
+                                    @RequestParam(required = false) Date endTime,
+                                    @RequestParam(required = true) String queryType){
+        return ApiResult.success(rtAnalogDataService.DataReportExport(siteId,startTime,endTime,queryType));
+    }
 
 }
 

+ 5 - 0
fiveep-persistence/src/main/java/com/bizmatics/persistence/mapper/RtAnalogDataMapper.java

@@ -1,5 +1,6 @@
 package com.bizmatics.persistence.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.bizmatics.model.Device;
 import com.bizmatics.model.HtAnalogData;
 import com.bizmatics.model.RtAnalogData;
@@ -40,4 +41,8 @@ public interface RtAnalogDataMapper extends CrudMapper<RtAnalogData> {
     List<HtAnalogData> getDataReportDMap(@Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
     List<HtAnalogData> getDataReportMMap(@Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
 
+    Page<HtAnalogData> getDataReportMap1(Page<HtAnalogData> page, @Param("siteId")Integer siteId, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
+    Page<HtAnalogData> getDataReportDMap1(Page<HtAnalogData> page, @Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
+    Page<HtAnalogData> getDataReportMMap1(Page<HtAnalogData> page, @Param("deviceCode")List deviceCode, @Param("startTime") Date startTime, @Param("endTime")Date endTime);
+
 }

+ 317 - 0
fiveep-persistence/src/main/resources/mapper/mysql/RtAnalogDataMapper.xml

@@ -422,4 +422,321 @@
         ORDER BY
         t.dataTime
     </select>
+    <select id="getDataReportMap1" resultType="com.bizmatics.model.HtAnalogData">
+        select
+        *
+        from user_site as us
+        inner join device as d
+        on us.site_id = d.site_id
+        inner join ht_analog_data as rad
+        on d.device_code = rad.deviceName
+        <where>
+            and d.enable=1
+            <if test="siteId != null and siteId != 0">
+                and us.site_id = #{siteId}
+            </if>
+            <if test="startTime != null and endTime != null">
+                and rad.dataTime BETWEEN #{startTime} and #{endTime}
+            </if>
+        </where>
+    </select>
+    <select id="getDataReportDMap1" resultType="com.bizmatics.model.HtAnalogData">
+        SELECT
+        t.deviceName AS deviceName,
+        AVG(t.Busot) AS Busot,
+        AVG(t.COS) AS COS,
+        AVG(t.COSa) AS COSa,
+        AVG(t.COSb) AS COSb,
+        AVG(t.COSc) AS COSc,
+        AVG(t.Demand) AS Demand,
+        AVG(t.DevResetTimes) AS DevResetTimes,
+        AVG(t.DeviceTemp) AS DeviceTemp,
+        AVG(t.Epn) AS Epn,
+        AVG(t.Epn1) AS Epn1,
+        AVG(t.Epn2) AS Epn2,
+        AVG(t.Epn3) AS Epn3,
+        AVG(t.Epn4) AS Epn4,
+        AVG(t.Epp) AS Epp,
+        AVG(t.Epp1) AS Epp1,
+        AVG(t.Epp2) AS Epp2,
+        AVG(t.Epp3) AS Epp3,
+        AVG(t.Epp4) AS Epp4,
+        AVG(t.Eqn) AS Eqn,
+        AVG(t.Eqp) AS Eqp,
+        AVG(t.F) AS F,
+        AVG(t.I0) AS I0,
+        AVG(t.I2) AS I2,
+        AVG(t.IHa) AS IHa,
+        AVG(t.IHb) AS IHb,
+        AVG(t.IHc) AS IHc,
+        AVG(t.Ia) AS Ia,
+        AVG(t.Ib) AS Ib,
+        AVG(t.Ic) AS Ic,
+        AVG(t.Ir) AS Ir,
+        AVG(t.LastDayMD) AS LastDayMD,
+        AVG(t.LastDayMDt) AS LastDayMDt,
+        AVG(t.P) AS P,
+        AVG(t.Pa) AS Pa,
+        AVG(t.Pb) AS Pb,
+        AVG(t.Pc) AS Pc,
+        AVG(t.Q) AS Q,
+        AVG(t.Qa) AS Qa,
+        AVG(t.Qb) AS Qb,
+        AVG(t.Qc) AS Qc,
+        AVG(t.SignalIntensity) AS SignalIntensity,
+        AVG(t.T1) AS T1,
+        AVG(t.T2) AS T2,
+        AVG(t.T3) AS T3,
+        AVG(t.T4) AS T4,
+        AVG(t.THDUa) AS THDUa,
+        AVG(t.THDUb) AS THDUb,
+        AVG(t.THDUc) AS THDUc,
+        AVG(t.Ua) AS Ua,
+        AVG(t.Uab) AS Uab,
+        AVG(t.Ub) AS Ub,
+        AVG(t.Ubc) AS Ubc,
+        AVG(t.UblU0) AS UblU0,
+        AVG(t.UblU2) AS UblU2,
+        AVG(t.Uc) AS Uc,
+        AVG(t.Uca) AS Uca,
+        AVG(t.Udt) AS Udt,
+        AVG(t.Ul) AS Ul,
+        AVG(t.Upt) AS Upt,
+        AVG(t.Ust) AS Ust,
+        t.freezingTime AS freezingTime,
+        t.dataTime
+        FROM
+        (
+        SELECT
+        deviceName,
+        Busot,
+        COS,
+        COSa,
+        COSb,
+        COSc,
+        Demand,
+        DevResetTimes,
+        DeviceTemp,
+        Epn,
+        Epn1,
+        Epn2,
+        Epn3,
+        Epn4,
+        Epp,
+        Epp1,
+        Epp2,
+        Epp3,
+        Epp4,
+        Eqn,
+        Eqp,
+        F,
+        I0,
+        I2,
+        IHa,
+        IHb,
+        IHc,
+        Ia,
+        Ib,
+        Ic,
+        Ir,
+        LastDayMD,
+        LastDayMDt,
+        P,
+        Pa,
+        Pb,
+        Pc,
+        Q,
+        Qa,
+        Qb,
+        Qc,
+        SignalIntensity,
+        T1,
+        T2,
+        T3,
+        T4,
+        THDUa,
+        THDUb,
+        THDUc,
+        Ua,
+        Uab,
+        Ub,
+        Ubc,
+        UblU0,
+        UblU2,
+        Uc,
+        Uca,
+        Udt,
+        Ul,
+        Upt,
+        Ust,
+        freezingTime,
+        date_format(dataTime, '%Y-%m-%d') AS dataTime
+        FROM
+        ht_analog_data
+        <where>
+            and deviceName in
+            <foreach item="item"  collection="deviceCode" open="(" separator="," close=")">
+                #{item.deviceCode}
+            </foreach>
+            <if test="endTime != null and startTime != null">
+                and dataTime BETWEEN   #{startTime} and #{endTime}
+            </if>
+        </where>
+        ) t
+        GROUP BY
+        t.dataTime
+        ORDER BY
+        t.dataTime
+    </select>
+
+    <select id="getDataReportMMap1" resultType="com.bizmatics.model.HtAnalogData">
+        SELECT
+        t.deviceName AS deviceName,
+        AVG(t.Busot) AS Busot,
+        AVG(t.COS) AS COS,
+        AVG(t.COSa) AS COSa,
+        AVG(t.COSb) AS COSb,
+        AVG(t.COSc) AS COSc,
+        AVG(t.Demand) AS Demand,
+        AVG(t.DevResetTimes) AS DevResetTimes,
+        AVG(t.DeviceTemp) AS DeviceTemp,
+        AVG(t.Epn) AS Epn,
+        AVG(t.Epn1) AS Epn1,
+        AVG(t.Epn2) AS Epn2,
+        AVG(t.Epn3) AS Epn3,
+        AVG(t.Epn4) AS Epn4,
+        AVG(t.Epp) AS Epp,
+        AVG(t.Epp1) AS Epp1,
+        AVG(t.Epp2) AS Epp2,
+        AVG(t.Epp3) AS Epp3,
+        AVG(t.Epp4) AS Epp4,
+        AVG(t.Eqn) AS Eqn,
+        AVG(t.Eqp) AS Eqp,
+        AVG(t.F) AS F,
+        AVG(t.I0) AS I0,
+        AVG(t.I2) AS I2,
+        AVG(t.IHa) AS IHa,
+        AVG(t.IHb) AS IHb,
+        AVG(t.IHc) AS IHc,
+        AVG(t.Ia) AS Ia,
+        AVG(t.Ib) AS Ib,
+        AVG(t.Ic) AS Ic,
+        AVG(t.Ir) AS Ir,
+        AVG(t.LastDayMD) AS LastDayMD,
+        AVG(t.LastDayMDt) AS LastDayMDt,
+        AVG(t.P) AS P,
+        AVG(t.Pa) AS Pa,
+        AVG(t.Pb) AS Pb,
+        AVG(t.Pc) AS Pc,
+        AVG(t.Q) AS Q,
+        AVG(t.Qa) AS Qa,
+        AVG(t.Qb) AS Qb,
+        AVG(t.Qc) AS Qc,
+        AVG(t.SignalIntensity) AS SignalIntensity,
+        AVG(t.T1) AS T1,
+        AVG(t.T2) AS T2,
+        AVG(t.T3) AS T3,
+        AVG(t.T4) AS T4,
+        AVG(t.THDUa) AS THDUa,
+        AVG(t.THDUb) AS THDUb,
+        AVG(t.THDUc) AS THDUc,
+        AVG(t.Ua) AS Ua,
+        AVG(t.Uab) AS Uab,
+        AVG(t.Ub) AS Ub,
+        AVG(t.Ubc) AS Ubc,
+        AVG(t.UblU0) AS UblU0,
+        AVG(t.UblU2) AS UblU2,
+        AVG(t.Uc) AS Uc,
+        AVG(t.Uca) AS Uca,
+        AVG(t.Udt) AS Udt,
+        AVG(t.Ul) AS Ul,
+        AVG(t.Upt) AS Upt,
+        AVG(t.Ust) AS Ust,
+        t.freezingTime AS freezingTime,
+        t.dataTime
+        FROM
+        (
+        SELECT
+        deviceName,
+        Busot,
+        COS,
+        COSa,
+        COSb,
+        COSc,
+        Demand,
+        DevResetTimes,
+        DeviceTemp,
+        Epn,
+        Epn1,
+        Epn2,
+        Epn3,
+        Epn4,
+        Epp,
+        Epp1,
+        Epp2,
+        Epp3,
+        Epp4,
+        Eqn,
+        Eqp,
+        F,
+        I0,
+        I2,
+        IHa,
+        IHb,
+        IHc,
+        Ia,
+        Ib,
+        Ic,
+        Ir,
+        LastDayMD,
+        LastDayMDt,
+        P,
+        Pa,
+        Pb,
+        Pc,
+        Q,
+        Qa,
+        Qb,
+        Qc,
+        SignalIntensity,
+        T1,
+        T2,
+        T3,
+        T4,
+        THDUa,
+        THDUb,
+        THDUc,
+        Ua,
+        Uab,
+        Ub,
+        Ubc,
+        UblU0,
+        UblU2,
+        Uc,
+        Uca,
+        Udt,
+        Ul,
+        Upt,
+        Ust,
+        freezingTime,
+        date_format(dataTime, '%Y-%m-%d %H:00:00') AS dataTime
+        FROM
+        ht_analog_data
+        <where>
+            and deviceName in
+            <foreach item="item"  collection="deviceCode" open="(" separator="," close=")">
+                #{item.deviceCode}
+            </foreach>
+            <if test="endTime != null and startTime != null">
+                and dataTime BETWEEN   #{startTime} and #{endTime}
+            </if>
+        </where>
+        ) t
+        GROUP BY
+        t.dataTime
+        ORDER BY
+        t.dataTime
+    </select>
+
+
 </mapper>

+ 1 - 0
fiveep-service/src/main/java/com/bizmatics/service/RtAnalogDataService.java

@@ -42,5 +42,6 @@ public interface RtAnalogDataService extends CrudService<RtAnalogData> {
 
     List<Map<String,Object>> getDataReport(Integer siteId,Date startTime, Date endTime,String queryType);
     List<Map<String,Object>> getHistoricalCurve(Integer siteId,Date startTime, Date endTime,String queryType);
+    String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType);
 
 }

+ 154 - 89
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -1,8 +1,15 @@
 package com.bizmatics.service.impl;
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.bizmatics.common.core.exception.BusinessException;
+import com.bizmatics.common.core.util.BeanMapperUtils;
 import com.bizmatics.common.core.util.DateUtils;
+import com.bizmatics.common.core.util.FileUtils;
 import com.bizmatics.common.core.util.StringUtils;
+import com.bizmatics.common.spring.util.GlobalUtils;
 import com.bizmatics.model.*;
 import com.bizmatics.persistence.mapper.RtAnalogDataMapper;
 import com.bizmatics.service.RtAnalogDataService;
@@ -12,13 +19,16 @@ import com.bizmatics.service.UserSiteService;
 import com.bizmatics.service.util.Arith;
 import com.bizmatics.service.util.SessionLocal;
 import com.bizmatics.service.vo.RadCountVO;
+import com.bizmatics.service.vo.HtAnalogData1ExportVO;
 import org.apache.commons.lang3.ArrayUtils;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.configurationprocessor.json.JSONArray;
 import org.springframework.stereotype.Service;
 
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -261,13 +271,14 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 Map<String,Object> map8 = new HashMap<>();
                 Map<String,Object> map9 = new HashMap<>();
                 HtAnalogData rtAnalogData = (HtAnalogData)rtAnalogDataList.get(i);
-                if (days<=24){
-                    map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
-                }else if (days<360&&days>24){
-                    map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
-                }else if (days>=360){
-                    map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),DateUtils.PARSE_PATTERNS[8]));
-                }
+//                if (days<=24){
+//                    map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
+//                }else if (days<360&&days>24){
+//                    map.put("dataTime", DateUtils.format(rtAnalogData.getDataTime(),"MM-dd HH:mm"));
+//                }else if (days>=360){
+//                    map.put("dataTime",DateUtils.format(rtAnalogData.getDataTime(),DateUtils.PARSE_PATTERNS[8]));
+//                }
+                map.put("dataTime",rtAnalogData.getDataTime());
 
                 if (ArrayUtils.contains(result,"I")){
                     map1.put("Ia",rtAnalogData.getIa());
@@ -343,12 +354,12 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
             if (ArrayUtils.contains(result,"I")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("Ia");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("Ib");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("Ic");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("Ia");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("Ib");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("Ic");
                 }
                 mapIe1.put("name","A相电流");
                 mapIe1.put("arr",arre1);
@@ -361,24 +372,24 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe3);
             }else if (ArrayUtils.contains(result,"P")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("P");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("Q");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("Pa");
-                    arre4[i][1]=listdataTime.get(i).get("dataTime");
-                    arre4[i][0]=list4.get(i).get("Pb");
-                    arre5[i][1]=listdataTime.get(i).get("dataTime");
-                    arre5[i][0]=list5.get(i).get("Pc");
-                    arre6[i][1]=listdataTime.get(i).get("dataTime");
-                    arre6[i][0]=list6.get(i).get("Qa");
-                    arre7[i][1]=listdataTime.get(i).get("dataTime");
-                    arre7[i][0]=list7.get(i).get("Qb");
-                    arre8[i][1]=listdataTime.get(i).get("dataTime");
-                    arre8[i][0]=list8.get(i).get("Qc");
-                    arre9[i][1]=listdataTime.get(i).get("dataTime");
-                    arre9[i][0]=list9.get(i).get("Demand");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("P");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("Q");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("Pa");
+                    arre4[i][0]=listdataTime.get(i).get("dataTime");
+                    arre4[i][1]=list4.get(i).get("Pb");
+                    arre5[i][0]=listdataTime.get(i).get("dataTime");
+                    arre5[i][1]=list5.get(i).get("Pc");
+                    arre6[i][0]=listdataTime.get(i).get("dataTime");
+                    arre6[i][1]=list6.get(i).get("Qa");
+                    arre7[i][0]=listdataTime.get(i).get("dataTime");
+                    arre7[i][1]=list7.get(i).get("Qb");
+                    arre8[i][0]=listdataTime.get(i).get("dataTime");
+                    arre8[i][1]=list8.get(i).get("Qc");
+                    arre9[i][0]=listdataTime.get(i).get("dataTime");
+                    arre9[i][1]=list9.get(i).get("Demand");
                 }
                 mapIe1.put("name","总有功功率");
                 mapIe1.put("arr",arre1);
@@ -409,14 +420,14 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe9);
             }else if (ArrayUtils.contains(result,"KWh")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("Epn");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("Epp");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("Eqn");
-                    arre4[i][1]=listdataTime.get(i).get("dataTime");
-                    arre4[i][0]=list4.get(i).get("Eqp");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("Epn");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("Epp");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("Eqn");
+                    arre4[i][0]=listdataTime.get(i).get("dataTime");
+                    arre4[i][1]=list4.get(i).get("Eqp");
                 }
                 mapIe1.put("name","负有功电度");
                 mapIe1.put("arr",arre1);
@@ -432,20 +443,20 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe4);
             }else if (ArrayUtils.contains(result,"V")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("Ua");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("Ub");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("Uc");
-                    arre4[i][1]=listdataTime.get(i).get("dataTime");
-                    arre4[i][0]=list4.get(i).get("Uab");
-                    arre5[i][1]=listdataTime.get(i).get("dataTime");
-                    arre5[i][0]=list5.get(i).get("Ubc");
-                    arre6[i][1]=listdataTime.get(i).get("dataTime");
-                    arre6[i][0]=list6.get(i).get("Uca");
-                    arre7[i][1]=listdataTime.get(i).get("dataTime");
-                    arre7[i][0]=list7.get(i).get("Ul");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("Ua");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("Ub");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("Uc");
+                    arre4[i][0]=listdataTime.get(i).get("dataTime");
+                    arre4[i][1]=list4.get(i).get("Uab");
+                    arre5[i][0]=listdataTime.get(i).get("dataTime");
+                    arre5[i][1]=list5.get(i).get("Ubc");
+                    arre6[i][0]=listdataTime.get(i).get("dataTime");
+                    arre6[i][1]=list6.get(i).get("Uca");
+                    arre7[i][0]=listdataTime.get(i).get("dataTime");
+                    arre7[i][1]=list7.get(i).get("Ul");
                 }
                 mapIe1.put("name","A相电压");
                 mapIe1.put("arr",arre1);
@@ -470,16 +481,16 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe7);
             }else if (ArrayUtils.contains(result,"C")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("T1");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("T2");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("T3");
-                    arre4[i][1]=listdataTime.get(i).get("dataTime");
-                    arre4[i][0]=list4.get(i).get("T4");
-                    arre5[i][1]=listdataTime.get(i).get("dataTime");
-                    arre5[i][0]=list5.get(i).get("DeviceTemp");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("T1");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("T2");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("T3");
+                    arre4[i][0]=listdataTime.get(i).get("dataTime");
+                    arre4[i][1]=list4.get(i).get("T4");
+                    arre5[i][0]=listdataTime.get(i).get("dataTime");
+                    arre5[i][1]=list5.get(i).get("DeviceTemp");
                 }
                 mapIe1.put("name","外接温度1");
                 mapIe1.put("arr",arre1);
@@ -498,22 +509,22 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe5);
             }else if (ArrayUtils.contains(result,"HZ")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("F");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("F");
                 }
                 mapIe1.put("name","频率");
                 mapIe1.put("arr",arre1);
                 list.add(mapIe1);
             }else if (ArrayUtils.contains(result,"PS")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("COSa");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("COSb");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("COSc");
-                    arre4[i][1]=listdataTime.get(i).get("dataTime");
-                    arre4[i][0]=list4.get(i).get("COS");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("COSa");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("COSb");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("COSc");
+                    arre4[i][0]=listdataTime.get(i).get("dataTime");
+                    arre4[i][1]=list4.get(i).get("COS");
                 }
                 mapIe1.put("name","A相功率因数");
                 mapIe1.put("arr",arre1);
@@ -529,12 +540,12 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe4);
             }else if (ArrayUtils.contains(result,"RMS")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("IHa");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("IHb");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("IHc");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("IHa");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("IHb");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("IHc");
                 }
                 mapIe1.put("name","Ia总谐波电流");
                 mapIe1.put("arr",arre1);
@@ -547,20 +558,20 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                 list.add(mapIe3);
             }else if (ArrayUtils.contains(result,"DDB")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("SignalIntensity");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("SignalIntensity");
                 }
                 mapIe1.put("name","设备信号强度");
                 mapIe1.put("arr",arre1);
                 list.add(mapIe1);
             }else if (ArrayUtils.contains(result,"VT")){
                 for (int i = 0; i < listdataTime.size(); i++) {
-                    arre1[i][1]=listdataTime.get(i).get("dataTime");
-                    arre1[i][0]=list1.get(i).get("Upt");
-                    arre2[i][1]=listdataTime.get(i).get("dataTime");
-                    arre2[i][0]=list2.get(i).get("Udt");
-                    arre3[i][1]=listdataTime.get(i).get("dataTime");
-                    arre3[i][0]=list3.get(i).get("Ust");
+                    arre1[i][0]=listdataTime.get(i).get("dataTime");
+                    arre1[i][1]=list1.get(i).get("Upt");
+                    arre2[i][0]=listdataTime.get(i).get("dataTime");
+                    arre2[i][1]=list2.get(i).get("Udt");
+                    arre3[i][0]=listdataTime.get(i).get("dataTime");
+                    arre3[i][1]=list3.get(i).get("Ust");
                 }
                 mapIe1.put("name","电压暂升次数");
                 mapIe1.put("arr",arre1);
@@ -576,4 +587,58 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
         return list;
     }
+
+
+    @Override
+    public String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType){
+        Integer userId = SessionLocal.getUserId();
+        Workbook workbook = null;
+        File file = null;
+        long diff = endTime.getTime() - startTime.getTime();
+        long days = diff / (1000 * 60 * 60);
+        try {
+            ExportParams params = new ExportParams(null, "数据报表");
+            workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogData1ExportVO.class,
+                    (o, i) -> {
+                        Page<HtAnalogData> page = new Page<>(i, 30);
+                        if (days<=24){
+                            page = baseMapper.getDataReportMap1(page,siteId, startTime, endTime);
+                        }else if (days<360&&days>24){
+                            List<Device> device_list = baseMapper.getDeviceListMap(siteId);
+                            page = baseMapper.getDataReportMMap1(page,device_list,startTime, endTime);
+                        }else if (days>=360){
+                            List<Device> device_list = baseMapper.getDeviceListMap(siteId);
+                            page = baseMapper.getDataReportDMap1(page,device_list,startTime, endTime);
+                        }
+
+                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), HtAnalogData.class, HtAnalogData1ExportVO.class));
+                    },null);
+            if (null != workbook) {
+                file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", System.currentTimeMillis() + ""));
+                FileUtils.createFile(file.getAbsolutePath());
+                FileOutputStream allListingFileOutputStream = new FileOutputStream(file);
+                workbook.write(allListingFileOutputStream);
+            } else {
+                throw new BusinessException("表格数据为空");
+            }
+        } catch (Exception e) {
+            log.error("导出文件失败", e);
+            throw new BusinessException("导出文件失败");
+        } finally {
+            if (workbook != null) {
+                try {
+                    workbook.close();
+                } catch (IOException e) {
+                    log.error("===export spec=== 关闭workbook失败", e);
+                }
+            }
+        }
+        return file.getName();
+    }
+
+
+
+
+
+
 }

+ 423 - 0
fiveep-service/src/main/java/com/bizmatics/service/vo/HtAnalogData1ExportVO.java

@@ -0,0 +1,423 @@
+package com.bizmatics.service.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+@Data
+public class HtAnalogData1ExportVO {
+
+//    private Integer id;
+//    /**
+//     * A相电流
+//     */
+//    @Excel(name = "A相电流", height = 6, width = 20)
+//    private Double Ia;
+//
+//    /**
+//     * B相电流
+//     */
+//    @Excel(name = "B相电流", height = 6, width = 20)
+//    private Double Ib;
+//
+//    /**
+//     * C相电流
+//     */
+//    @Excel(name = "C相电流", height = 6, width = 20)
+//    private Double Ic;
+
+//    /**
+//     * 上报时间
+//     */
+//    @Excel(name = "上报时间", height = 6, width = 20)
+//    private Date dataTime;
+
+    /**
+     * 伍继电力test_183消费组模拟量数据表ID
+     */
+    private Integer id;
+
+    /**
+     * 阿里云平台设备名称
+     */
+    @Excel(name = "阿里云平台设备名称", height = 6, width = 20)
+    private String deviceName;
+
+    /**
+     * 母线停电次数
+     */
+    @Excel(name = "母线停电次数", height = 6, width = 20)
+    private Integer Busot;
+
+    /**
+     * 三相功率因数
+     */
+    @Excel(name = "三相功率因数", height = 6, width = 20)
+    private Double cos;
+
+    /**
+     * A相功率因数
+     */
+    @Excel(name = "A相功率因数", height = 6, width = 20)
+    private Double COSa;
+
+    /**
+     * B相功率因数
+     */
+    @Excel(name = "B相功率因数", height = 6, width = 20)
+    private Double COSb;
+
+    /**
+     * C相功率因数
+     */
+    @Excel(name = "C相功率因数", height = 6, width = 20)
+    private Double COSc;
+
+    /**
+     * 实时有功需量
+     */
+    @Excel(name = "实时有功需量", height = 6, width = 20)
+    private Double Demand;
+
+    /**
+     * 设备复位次数
+     */
+    @Excel(name = "设备复位次数", height = 6, width = 20)
+    private Integer DevResetTimes;
+
+    /**
+     * 设备温度
+     */
+    @Excel(name = "设备温度", height = 6, width = 20)
+    private Double DeviceTemp;
+
+    /**
+     * 三相反向有功电度
+     */
+    @Excel(name = "三相反向有功电度", height = 6, width = 20)
+    private Double Epn;
+
+    /**
+     * 尖段反向有功电度
+     */
+    @Excel(name = "尖段反向有功电度", height = 6, width = 20)
+    private Double Epn1;
+
+    /**
+     * 峰段反向有功电度
+     */
+    @Excel(name = "峰段反向有功电度", height = 6, width = 20)
+    private Double Epn2;
+
+    /**
+     * 平段反向有功电度
+     */
+    @Excel(name = "平段反向有功电度", height = 6, width = 20)
+    private Double Epn3;
+
+    /**
+     * 谷段反向有功电度
+     */
+    @Excel(name = "谷段反向有功电度", height = 6, width = 20)
+    private Double Epn4;
+
+    /**
+     * 三相正向有功电度
+     */
+    @Excel(name = "三相正向有功电度", height = 6, width = 20)
+    private Double Epp;
+
+    /**
+     * 尖段正向有功电度
+     */
+    @Excel(name = "尖段正向有功电度", height = 6, width = 20)
+    private Double Epp1;
+
+    /**
+     * 峰段正向有功电度
+     */
+    @Excel(name = "峰段正向有功电度", height = 6, width = 20)
+    private Double Epp2;
+
+    /**
+     * 平段正向有功电度
+     */
+    @Excel(name = "平段正向有功电度", height = 6, width = 20)
+    private Double Epp3;
+
+    /**
+     * 谷段正向有功电度
+     */
+    @Excel(name = "谷段正向有功电度", height = 6, width = 20)
+    private Double Epp4;
+
+    /**
+     * 三相反向无功电度
+     */
+    @Excel(name = "三相反向无功电度", height = 6, width = 20)
+    private Double Eqn;
+
+    /**
+     * 三相正向无功电度
+     */
+    @Excel(name = "三相正向无功电度", height = 6, width = 20)
+    private Double Eqp;
+
+    /**
+     * 频率
+     */
+    @Excel(name = "频率", height = 6, width = 20)
+    private Double f;
+
+    /**
+     * 零序电流
+     */
+    @Excel(name = "零序电流", height = 6, width = 20)
+    private Double i0;
+
+    /**
+     * 负序电流
+     */
+    @Excel(name = "负序电流", height = 6, width = 20)
+    private Double i2;
+
+    /**
+     * A相总谐波电流
+     */
+    @Excel(name = "A相总谐波电流", height = 6, width = 20)
+    private Double IHa;
+
+    /**
+     * B相总谐波电流
+     */
+    @Excel(name = "B相总谐波电流", height = 6, width = 20)
+    private Double IHb;
+
+    /**
+     * C相总谐波电流
+     */
+    @Excel(name = "C相总谐波电流", height = 6, width = 20)
+    private Double IHc;
+
+    /**
+     * A相电流
+     */
+    @Excel(name = "A相电流", height = 6, width = 20)
+    private Double Ia;
+
+    /**
+     * B相电流
+     */
+    @Excel(name = "B相电流", height = 6, width = 20)
+    private Double Ib;
+
+    /**
+     * C相电流
+     */
+    @Excel(name = "C相电流", height = 6, width = 20)
+    private Double Ic;
+
+    /**
+     * 剩余电流
+     */
+    @Excel(name = "剩余电流", height = 6, width = 20)
+    private Double Ir;
+
+    /**
+     * 昨日有功最大需量
+     */
+    @Excel(name = "昨日有功最大需量", height = 6, width = 20)
+    private Double LastDayMD;
+
+    /**
+     * 昨日有功最大需量发生时间
+     */
+    @Excel(name = "昨日有功最大需量发生时间", height = 6, width = 20)
+    private Double LastDayMDt;
+
+    /**
+     * 三相总有功功率
+     */
+    @Excel(name = "三相总有功功率", height = 6, width = 20)
+    private Double p;
+
+    /**
+     * A相有功功率
+     */
+    @Excel(name = "A相有功功率", height = 6, width = 20)
+    private Double Pa;
+
+    /**
+     * B相有功功率
+     */
+    @Excel(name = "B相有功功率", height = 6, width = 20)
+    private Double Pb;
+
+    /**
+     * C相有功功率
+     */
+    @Excel(name = "C相有功功率", height = 6, width = 20)
+    private Double Pc;
+
+    /**
+     * 三相总无功功率
+     */
+    @Excel(name = "三相总无功功率", height = 6, width = 20)
+    private Double q;
+
+    /**
+     * A相无功功率
+     */
+    @Excel(name = "A相无功功率", height = 6, width = 20)
+    private Double Qa;
+
+    /**
+     * B相无功功率
+     */
+    @Excel(name = "B相无功功率", height = 6, width = 20)
+    private Double Qb;
+
+    /**
+     * C相无功功率
+     */
+    @Excel(name = "C相无功功率", height = 6, width = 20)
+    private Double Qc;
+
+    /**
+     * 信号强度
+     */
+    @Excel(name = "信号强度", height = 6, width = 20)
+    private Double SignalIntensity;
+
+    /**
+     * 第1路温度
+     */
+    @Excel(name = "第1路温度", height = 6, width = 20)
+    private Double t1;
+
+    /**
+     * 第2路温度
+     */
+    @Excel(name = "第2路温度", height = 6, width = 20)
+    private Double t2;
+
+    /**
+     * 第3路温度
+     */
+    @Excel(name = "第3路温度", height = 6, width = 20)
+    private Double t3;
+
+    /**
+     * 第4路温度
+     */
+    @Excel(name = "第4路温度", height = 6, width = 20)
+    private Double t4;
+
+    /**
+     * A相电压THD
+     */
+    @Excel(name = "A相电压THD", height = 6, width = 20)
+    private Double THDUa;
+
+    /**
+     * B相电压THD
+     */
+    @Excel(name = "B相电压THD", height = 6, width = 20)
+    private Double THDUb;
+
+    /**
+     * C相电压THD
+     */
+    @Excel(name = "C相电压THD", height = 6, width = 20)
+    private Double THDUc;
+
+    /**
+     * A相电压
+     */
+    @Excel(name = "A相电流", height = 6, width = 20)
+    private Double Ua;
+
+    /**
+     * AB线电压
+     */
+    @Excel(name = "AB线电压", height = 6, width = 20)
+    private Double Uab;
+
+    /**
+     * B相电压
+     */
+    @Excel(name = "B相电压", height = 6, width = 20)
+    private Double Ub;
+
+    /**
+     * BC线电压
+     */
+    @Excel(name = "BC线电压", height = 6, width = 20)
+    private Double Ubc;
+
+    /**
+     * 零序电压不平衡度
+     */
+    @Excel(name = "零序电压不平衡度", height = 6, width = 20)
+    private Double UblU0;
+
+    /**
+     * 负序电压不平衡度
+     */
+    @Excel(name = "负序电压不平衡度", height = 6, width = 20)
+    private Double UblU2;
+
+    /**
+     * C相电压
+     */
+    @Excel(name = "C相电压", height = 6, width = 20)
+    private Double Uc;
+
+    /**
+     * CA线电压
+     */
+    @Excel(name = "CA线电压", height = 6, width = 20)
+    private Double Uca;
+
+    /**
+     * 电压暂降次数
+     */
+    @Excel(name = "电压暂降次数", height = 6, width = 20)
+    private Integer Udt;
+
+    /**
+     * 线路侧电压
+     */
+    @Excel(name = "线路侧电压", height = 6, width = 20)
+    private Double Ul;
+
+    /**
+     * 电压暂升次数
+     */
+    @Excel(name = "电压暂升次数", height = 6, width = 20)
+    private Integer Upt;
+
+    /**
+     * 电压短时中断次数
+     */
+    @Excel(name = "电压短时中断次数", height = 6, width = 20)
+    private Integer Ust;
+
+    /**
+     * 冻结时间
+     */
+    @Excel(name = "上报时间", height = 6, width = 20)
+    private LocalDate freezingTime;
+
+    /**
+     * 上报时间
+     */
+    @Excel(name = "上报时间", height = 6, width = 20)
+    private LocalDateTime dataTime;
+}