瀏覽代碼

设备监测模块报表导出

jichaobo 4 年之前
父節點
當前提交
669d438582

+ 1 - 1
fiveep-controller/src/main/resources/application-dev.properties

@@ -1,7 +1,7 @@
 debug=true
 spring.main.lazy-initialization=false
 spring.main.allow-bean-definition-overriding=true
-temp.basedir=C:/Users/pc/Desktop
+temp.basedir=D:/dc
 # application
 server.port=8010
 # mybatis-plus

+ 5 - 1
fiveep-persistence/src/main/resources/mapper/mysql/RtAnalogDataMapper.xml

@@ -424,7 +424,7 @@
     </select>
     <select id="getDataReportMap1" resultType="com.bizmatics.model.HtAnalogData">
         select
-        *
+        rad.*
         from user_site as us
         inner join device as d
         on us.site_id = d.site_id
@@ -442,6 +442,7 @@
     </select>
     <select id="getDataReportDMap1" resultType="com.bizmatics.model.HtAnalogData">
         SELECT
+        t.id as id
         t.deviceName AS deviceName,
         AVG(t.Busot) AS Busot,
         AVG(t.COS) AS COS,
@@ -508,6 +509,7 @@
         FROM
         (
         SELECT
+        id,
         deviceName,
         Busot,
         COS,
@@ -591,6 +593,7 @@
 
     <select id="getDataReportMMap1" resultType="com.bizmatics.model.HtAnalogData">
         SELECT
+        t.id,
         t.deviceName AS deviceName,
         AVG(t.Busot) AS Busot,
         AVG(t.COS) AS COS,
@@ -657,6 +660,7 @@
         FROM
         (
         SELECT
+        id,
         deviceName,
         Busot,
         COS,

+ 60 - 3
fiveep-service/src/main/java/com/bizmatics/service/impl/RtAnalogDataServiceImpl.java

@@ -2,6 +2,7 @@ package com.bizmatics.service.impl;
 
 import cn.afterturn.easypoi.excel.ExcelExportUtil;
 import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.export.template.ExcelExportOfTemplateUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.bizmatics.common.core.exception.BusinessException;
@@ -19,7 +20,7 @@ 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 com.bizmatics.service.vo.HtAnalogDataExportVO;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -591,6 +592,14 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
 
     @Override
     public String DataReportExport(Integer siteId,Date startTime, Date endTime,String queryType){
+
+
+
+
+
+
+
+
         Integer userId = SessionLocal.getUserId();
         Workbook workbook = null;
         File file = null;
@@ -598,7 +607,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
         long days = diff / (1000 * 60 * 60);
         try {
             ExportParams params = new ExportParams(null, "数据报表");
-            workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogData1ExportVO.class,
+            workbook = ExcelExportUtil.exportBigExcel(params, HtAnalogDataExportVO.class,
                     (o, i) -> {
                         Page<HtAnalogData> page = new Page<>(i, 30);
                         if (days<=24){
@@ -611,7 +620,7 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
                             page = baseMapper.getDataReportDMap1(page,device_list,startTime, endTime);
                         }
 
-                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), HtAnalogData.class, HtAnalogData1ExportVO.class));
+                        return new ArrayList<>(BeanMapperUtils.mapList(page.getRecords(), HtAnalogData.class, HtAnalogDataExportVO.class));
                     },null);
             if (null != workbook) {
                 file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), String.format("%s-%s.xlsx", "数据报表", System.currentTimeMillis() + ""));
@@ -637,6 +646,54 @@ public class RtAnalogDataServiceImpl extends AbstractCrudService<RtAnalogDataMap
     }
 
 
+//    @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, HtAnalogDataExportVO.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, HtAnalogDataExportVO.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();
+//    }
+
+
 
 
 

+ 64 - 90
fiveep-service/src/main/java/com/bizmatics/service/vo/HtAnalogData1ExportVO.java → fiveep-service/src/main/java/com/bizmatics/service/vo/HtAnalogDataExportVO.java

@@ -11,37 +11,11 @@ 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;
-
+public class HtAnalogDataExportVO {
     /**
      * 伍继电力test_183消费组模拟量数据表ID
      */
-    private Integer id;
+    private String id;
 
     /**
      * 阿里云平台设备名称
@@ -53,371 +27,371 @@ public class HtAnalogData1ExportVO {
      * 母线停电次数
      */
     @Excel(name = "母线停电次数", height = 6, width = 20)
-    private Integer Busot;
+    private String busot;
 
     /**
      * 三相功率因数
      */
     @Excel(name = "三相功率因数", height = 6, width = 20)
-    private Double cos;
+    private String cos;
 
     /**
      * A相功率因数
      */
     @Excel(name = "A相功率因数", height = 6, width = 20)
-    private Double COSa;
+    private String COSa;
 
     /**
      * B相功率因数
      */
     @Excel(name = "B相功率因数", height = 6, width = 20)
-    private Double COSb;
+    private String COSb;
 
     /**
      * C相功率因数
      */
     @Excel(name = "C相功率因数", height = 6, width = 20)
-    private Double COSc;
+    private String COSc;
 
     /**
      * 实时有功需量
      */
     @Excel(name = "实时有功需量", height = 6, width = 20)
-    private Double Demand;
+    private String demand;
 
     /**
      * 设备复位次数
      */
     @Excel(name = "设备复位次数", height = 6, width = 20)
-    private Integer DevResetTimes;
+    private String devResetTimes;
 
     /**
      * 设备温度
      */
     @Excel(name = "设备温度", height = 6, width = 20)
-    private Double DeviceTemp;
+    private String deviceTemp;
 
     /**
      * 三相反向有功电度
      */
     @Excel(name = "三相反向有功电度", height = 6, width = 20)
-    private Double Epn;
+    private String epn;
 
     /**
      * 尖段反向有功电度
      */
     @Excel(name = "尖段反向有功电度", height = 6, width = 20)
-    private Double Epn1;
+    private String epn1;
 
     /**
      * 峰段反向有功电度
      */
     @Excel(name = "峰段反向有功电度", height = 6, width = 20)
-    private Double Epn2;
+    private String epn2;
 
     /**
      * 平段反向有功电度
      */
     @Excel(name = "平段反向有功电度", height = 6, width = 20)
-    private Double Epn3;
+    private String epn3;
 
     /**
      * 谷段反向有功电度
      */
     @Excel(name = "谷段反向有功电度", height = 6, width = 20)
-    private Double Epn4;
+    private String epn4;
 
     /**
      * 三相正向有功电度
      */
     @Excel(name = "三相正向有功电度", height = 6, width = 20)
-    private Double Epp;
+    private String epp;
 
     /**
      * 尖段正向有功电度
      */
     @Excel(name = "尖段正向有功电度", height = 6, width = 20)
-    private Double Epp1;
+    private String epp1;
 
     /**
      * 峰段正向有功电度
      */
     @Excel(name = "峰段正向有功电度", height = 6, width = 20)
-    private Double Epp2;
+    private String epp2;
 
     /**
      * 平段正向有功电度
      */
     @Excel(name = "平段正向有功电度", height = 6, width = 20)
-    private Double Epp3;
+    private String epp3;
 
     /**
      * 谷段正向有功电度
      */
     @Excel(name = "谷段正向有功电度", height = 6, width = 20)
-    private Double Epp4;
+    private String epp4;
 
     /**
      * 三相反向无功电度
      */
     @Excel(name = "三相反向无功电度", height = 6, width = 20)
-    private Double Eqn;
+    private String eqn;
 
     /**
      * 三相正向无功电度
      */
     @Excel(name = "三相正向无功电度", height = 6, width = 20)
-    private Double Eqp;
+    private String eqp;
 
     /**
      * 频率
      */
     @Excel(name = "频率", height = 6, width = 20)
-    private Double f;
+    private String f;
 
     /**
      * 零序电流
      */
     @Excel(name = "零序电流", height = 6, width = 20)
-    private Double i0;
+    private String i0;
 
     /**
      * 负序电流
      */
     @Excel(name = "负序电流", height = 6, width = 20)
-    private Double i2;
+    private String i2;
 
     /**
      * A相总谐波电流
      */
     @Excel(name = "A相总谐波电流", height = 6, width = 20)
-    private Double IHa;
+    private String IHa;
 
     /**
      * B相总谐波电流
      */
     @Excel(name = "B相总谐波电流", height = 6, width = 20)
-    private Double IHb;
+    private String IHb;
 
     /**
      * C相总谐波电流
      */
     @Excel(name = "C相总谐波电流", height = 6, width = 20)
-    private Double IHc;
+    private String IHc;
 
     /**
      * A相电流
      */
     @Excel(name = "A相电流", height = 6, width = 20)
-    private Double Ia;
+    private String ia;
 
     /**
      * B相电流
      */
     @Excel(name = "B相电流", height = 6, width = 20)
-    private Double Ib;
+    private String ib;
 
     /**
      * C相电流
      */
     @Excel(name = "C相电流", height = 6, width = 20)
-    private Double Ic;
+    private String ic;
 
     /**
      * 剩余电流
      */
     @Excel(name = "剩余电流", height = 6, width = 20)
-    private Double Ir;
+    private String ir;
 
     /**
      * 昨日有功最大需量
      */
     @Excel(name = "昨日有功最大需量", height = 6, width = 20)
-    private Double LastDayMD;
+    private String lastDayMD;
 
     /**
      * 昨日有功最大需量发生时间
      */
     @Excel(name = "昨日有功最大需量发生时间", height = 6, width = 20)
-    private Double LastDayMDt;
+    private String lastDayMDt;
 
     /**
      * 三相总有功功率
      */
     @Excel(name = "三相总有功功率", height = 6, width = 20)
-    private Double p;
+    private String p;
 
     /**
      * A相有功功率
      */
     @Excel(name = "A相有功功率", height = 6, width = 20)
-    private Double Pa;
+    private String pa;
 
     /**
      * B相有功功率
      */
     @Excel(name = "B相有功功率", height = 6, width = 20)
-    private Double Pb;
+    private String pb;
 
     /**
      * C相有功功率
      */
     @Excel(name = "C相有功功率", height = 6, width = 20)
-    private Double Pc;
+    private String pc;
 
     /**
      * 三相总无功功率
      */
     @Excel(name = "三相总无功功率", height = 6, width = 20)
-    private Double q;
+    private String q;
 
     /**
      * A相无功功率
      */
     @Excel(name = "A相无功功率", height = 6, width = 20)
-    private Double Qa;
+    private String qa;
 
     /**
      * B相无功功率
      */
     @Excel(name = "B相无功功率", height = 6, width = 20)
-    private Double Qb;
+    private String qb;
 
     /**
      * C相无功功率
      */
     @Excel(name = "C相无功功率", height = 6, width = 20)
-    private Double Qc;
+    private String qc;
 
     /**
      * 信号强度
      */
     @Excel(name = "信号强度", height = 6, width = 20)
-    private Double SignalIntensity;
+    private String signalIntensity;
 
     /**
      * 第1路温度
      */
     @Excel(name = "第1路温度", height = 6, width = 20)
-    private Double t1;
+    private String t1;
 
     /**
      * 第2路温度
      */
     @Excel(name = "第2路温度", height = 6, width = 20)
-    private Double t2;
+    private String t2;
 
     /**
      * 第3路温度
      */
     @Excel(name = "第3路温度", height = 6, width = 20)
-    private Double t3;
+    private String t3;
 
     /**
      * 第4路温度
      */
     @Excel(name = "第4路温度", height = 6, width = 20)
-    private Double t4;
+    private String t4;
 
     /**
      * A相电压THD
      */
     @Excel(name = "A相电压THD", height = 6, width = 20)
-    private Double THDUa;
+    private String THDUa;
 
     /**
      * B相电压THD
      */
     @Excel(name = "B相电压THD", height = 6, width = 20)
-    private Double THDUb;
+    private String THDUb;
 
     /**
      * C相电压THD
      */
     @Excel(name = "C相电压THD", height = 6, width = 20)
-    private Double THDUc;
+    private String THDUc;
 
     /**
      * A相电压
      */
     @Excel(name = "A相电流", height = 6, width = 20)
-    private Double Ua;
+    private String ua;
 
     /**
      * AB线电压
      */
     @Excel(name = "AB线电压", height = 6, width = 20)
-    private Double Uab;
+    private String uab;
 
     /**
      * B相电压
      */
     @Excel(name = "B相电压", height = 6, width = 20)
-    private Double Ub;
+    private String ub;
 
     /**
      * BC线电压
      */
     @Excel(name = "BC线电压", height = 6, width = 20)
-    private Double Ubc;
+    private String ubc;
 
     /**
      * 零序电压不平衡度
      */
     @Excel(name = "零序电压不平衡度", height = 6, width = 20)
-    private Double UblU0;
+    private String ublU0;
 
     /**
      * 负序电压不平衡度
      */
     @Excel(name = "负序电压不平衡度", height = 6, width = 20)
-    private Double UblU2;
+    private String ublU2;
 
     /**
      * C相电压
      */
     @Excel(name = "C相电压", height = 6, width = 20)
-    private Double Uc;
+    private String uc;
 
     /**
      * CA线电压
      */
     @Excel(name = "CA线电压", height = 6, width = 20)
-    private Double Uca;
+    private String uca;
 
     /**
      * 电压暂降次数
      */
     @Excel(name = "电压暂降次数", height = 6, width = 20)
-    private Integer Udt;
+    private String udt;
 
     /**
      * 线路侧电压
      */
     @Excel(name = "线路侧电压", height = 6, width = 20)
-    private Double Ul;
+    private String ul;
 
     /**
      * 电压暂升次数
      */
     @Excel(name = "电压暂升次数", height = 6, width = 20)
-    private Integer Upt;
+    private String upt;
 
     /**
      * 电压短时中断次数
      */
     @Excel(name = "电压短时中断次数", height = 6, width = 20)
-    private Integer Ust;
+    private String ust;
 
     /**
      * 冻结时间
      */
     @Excel(name = "上报时间", height = 6, width = 20)
-    private LocalDate freezingTime;
+    private String freezingTime;
 
     /**
      * 上报时间
      */
     @Excel(name = "上报时间", height = 6, width = 20)
-    private LocalDateTime dataTime;
+    private String dataTime;
 }