Procházet zdrojové kódy

替换数据查询目录下所有页面控件导出功能为实际按钮

刘桐 před 1 dnem
rodič
revize
ac9770d772
27 změnil soubory, kde provedl 1317 přidání a 16216 odebrání
  1. 0 16188
      ipp-ap/package-lock.json
  2. 2 2
      ipp-ap/public/index.html
  3. 1 1
      ipp-ap/src/const/crud/inverterstatusdata.js
  4. 1 1
      ipp-ap/src/const/crud/nwp.js
  5. 1 1
      ipp-ap/src/const/crud/weatherstationstatusdata.js
  6. 1 1
      ipp-ap/src/const/crud/windtowerstatusdata.js
  7. 1 1
      ipp-ap/src/const/crud/windturbinestatusdata.js
  8. 20 0
      ipp-ap/src/views/idp/data/inverterstatusdata/index.vue
  9. 20 0
      ipp-ap/src/views/idp/data/nwp/index.vue
  10. 20 0
      ipp-ap/src/views/idp/data/weatherstationstatusdata/index.vue
  11. 22 0
      ipp-ap/src/views/idp/data/windtowerstatusdata/index.vue
  12. 24 0
      ipp-ap/src/views/idp/data/windturbinestatusdata/index.vue
  13. 112 5
      ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/InverterStatusDataController.java
  14. 154 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/NwpController.java
  15. 100 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WeatherStationStatusDataController.java
  16. 121 5
      ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WindTowerStatusDataController.java
  17. 126 6
      ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WindTurbineStatusDataController.java
  18. 4 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/InverterStatusDataService.java
  19. 4 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/NwpService.java
  20. 3 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WeatherStationStatusDataService.java
  21. 2 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WindTowerStatusDataService.java
  22. 4 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WindTurbineStatusDataService.java
  23. 114 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/InverterStatusDataServiceImpl.java
  24. 111 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/NwpServiceImpl.java
  25. 108 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WeatherStationStatusDataServiceImpl.java
  26. 116 0
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WindTowerStatusDataServiceImpl.java
  27. 125 1
      ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WindTurbineStatusDataServiceImpl.java

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 16188
ipp-ap/package-lock.json


+ 2 - 2
ipp-ap/public/index.html

@@ -12,8 +12,8 @@
   <link rel="stylesheet" href="<%= BASE_URL %>cdn/animate/3.5.2/animate.css">
   <link rel="stylesheet" href="<%= BASE_URL %>cdn/avue/avue.css">
   <link rel="icon" href="<%= BASE_URL %>favicon.ico">
-<!--  <script src="https://cdn.staticfile.org/FileSaver.js/2014-11-29/FileSaver.min.js"></script>-->
-<!--  <script src="https://cdn.staticfile.org/xlsx/0.18.2/xlsx.full.min.js"></script>-->
+  <script src="https://cdn.staticfile.org/FileSaver.js/2014-11-29/FileSaver.min.js"></script>
+  <script src="https://cdn.staticfile.org/xlsx/0.18.2/xlsx.full.min.js"></script>
   <title>ipp 集中功率预测</title>
 </head>
 

+ 1 - 1
ipp-ap/src/const/crud/inverterstatusdata.js

@@ -7,7 +7,7 @@ export const tableOption = {
   "align": "center",
   "searchMenuSpan": 6,
   title: "逆变器数据 ",
-  excelBtn: true,
+  excelBtn: false,
   menu: false,
   addBtn: false,
   editBtn: false,

+ 1 - 1
ipp-ap/src/const/crud/nwp.js

@@ -8,7 +8,7 @@ export const tableOption = {
   "align": "center",
   "searchMenuSpan": 6,
   title: "NWP数据 ",
-  excelBtn: true,
+  excelBtn: false,
   menu: false,
   addBtn: false,
   editBtn: false,

+ 1 - 1
ipp-ap/src/const/crud/weatherstationstatusdata.js

@@ -9,7 +9,7 @@ export const tableOption = {
   editBtn: false,
   menu: false,
   title: "气象站数据 ",
-  excelBtn: true,
+  excelBtn: false,
   "menuAlign": "center",
   "align": "center",
   "searchMenuSpan": 6,

+ 1 - 1
ipp-ap/src/const/crud/windtowerstatusdata.js

@@ -5,7 +5,7 @@ export const tableOption = {
   "indexLabel": "序号",
   "stripe": true,
   title: "测风塔数据 ",
-  excelBtn: true,
+  excelBtn: false,
   addBtn: false,
   delBtn: false,
   editBtn: false,

+ 1 - 1
ipp-ap/src/const/crud/windturbinestatusdata.js

@@ -6,7 +6,7 @@ export const tableOption = {
   "menuAlign": "center",
   "align": "center",
   "searchMenuSpan": 6,
-  excelBtn: true,
+  excelBtn: false,
   menu: false,
   addBtn: false,
   editBtn: false,

+ 20 - 0
ipp-ap/src/views/idp/data/inverterstatusdata/index.vue

@@ -63,6 +63,7 @@
       &nbsp;
       <div class="timeQuery" style="display: inline-block">
         <el-button size="small" :loading="loading" @click="dateQuery">查询</el-button>
+        <el-button size="small" :loading="loading" @click="exportDataEvent">导出</el-button>
       </div>
     </div>
     <basic-container>
@@ -128,6 +129,25 @@ export default {
     this.getAllInverterInfo()
   },
   methods: {
+    exportDataEvent(){
+      if(this.startTime == null){
+        this.$message.error("请选择开始时间")
+      }
+      if(this.endTime == null){
+        this.$message.error("请选择结束时间")
+      }
+      if(this.equipmentId == null){
+        this.$message.error("请选择设备")
+      }
+      this.$axios.get("/inverterstatusdata/exportDataEvent/" + this.stationCode + "/" + this.startTime + "/" + this.endTime + '/' + this.equipmentId,{
+        responseType:'blob'
+      }).then((response) => {
+        this.loading = false;
+      }).catch((error) =>{
+        this.loading = false;
+        this.$message.error("导出失败"+error)
+      })
+    },
     getGridOnloadData() {
       const param = new URLSearchParams()
       param.append('currentPage', this.page.currentPage)

+ 20 - 0
ipp-ap/src/views/idp/data/nwp/index.vue

@@ -67,6 +67,7 @@
       &nbsp;
       <div class="timeQuery" style="display: inline-block">
         <el-button size="small" :loading="tableLoading" @click="queryNWPDataByStationCode">查询</el-button>
+        <el-button size="small" :loading="tableLoading" @click="exportDataEvent">导出</el-button>
       </div>
     </div>
     <basic-container>
@@ -124,6 +125,25 @@ export default {
     }
   },
   methods: {
+    exportDataEvent(){
+      if(this.startTime == null){
+        this.$message.error("请选择开始时间")
+      }
+      if(this.endTime == null){
+        this.$message.error("请选择结束时间")
+      }
+      if(this.stationCode == null){
+        this.$message.error("请选择场站")
+      }
+      this.$axios.get("/nwp/exportDataEvent" + "/" + this.startTime + "/" + this.endTime + "/" + this.stationCode,{
+        responseType:'blob'
+      }).then((response) => {
+        this.loading = false
+      }).catch((error) => {
+        this.loading = false
+        this.$message.error("导出失败"+error)
+      })
+    },
     getManufactor(val) {
       this.forecastManufactorList = []
       this.forecastManufactor = []

+ 20 - 0
ipp-ap/src/views/idp/data/weatherstationstatusdata/index.vue

@@ -66,6 +66,7 @@
       &nbsp;
       <div class="timeQuery" style="display: inline-block">
         <el-button size="small" :loading="loading" @click="queryWeatherStationStatusDataForCharts">查询</el-button>
+        <el-button size="small" :loading="loading" @click="exportDataEvent">导出</el-button>
       </div>
     </div>
     <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
@@ -150,6 +151,25 @@ export default {
     this.wsChart = null
   },
   methods: {
+    exportDataEvent(){
+      if(this.startTime == null){
+        this.$message.error("请选择开始时间")
+      }
+      if(this.endTime == null){
+        this.$message.error("请选择结束时间")
+      }
+      if(this.equipmentId == null){
+        this.$message.error("请选择设备")
+      }
+      this.$axios.get("/weatherstationstatusdata/exportDataEvent/" + this.stationCode + "/" + this.startTime + "/" + this.endTime + '/' + this.equipmentId ,{
+        responseType:'blob'
+      }).then((response) => {
+        this.loading = false
+      }).catch((error) =>{
+        this.loading = false
+        this.$message.error("导出失败"+error)
+      })
+    },
     draw(timeaxis, radiationData) {
       var globalR = []
       var directR = []

+ 22 - 0
ipp-ap/src/views/idp/data/windtowerstatusdata/index.vue

@@ -66,6 +66,7 @@
       &nbsp;
       <div class="timeQuery" style="display: inline-block">
         <el-button size="small" :loading="loading" @click="queryWindTowerStatusDataForCharts">查询</el-button>
+        <el-button size="small" :loading="loading" @click="exportDataEvent">导出</el-button>
       </div>
     </div>
     <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
@@ -727,6 +728,27 @@ export default {
     this.wsChart = null
   },
   methods: {
+    exportDataEvent() {
+      if (this.startTime==null){
+        this.$message.warning('请选择开始时间')
+        return
+      }
+      if (this.endTime==null){
+        this.$message.warning('请选择结束时间')
+        return
+      }
+      if (this.equipmentId === '' || this.equipmentId == null) {
+        return alert("请选择所属设备")
+      }
+      this.$axios.get("/windtowerstatusdata/exportDataEvent/" + this.stationCode + "/" + this.startTime + "/" + this.endTime + '/' + this.equipmentId, {
+        responseType: 'blob'// 用于解决中文乱码
+      }).then((response) => {
+        this.loading = false
+      }).catch((error) => {
+        this.loading = false
+        this.$message.error('导出失败' + error)
+      })
+    },
     wdDraw(wdData) {
       // console.log(wdData, this.thFormat)
       this.chart = echarts.init(document.getElementById('echarts'))

+ 24 - 0
ipp-ap/src/views/idp/data/windturbinestatusdata/index.vue

@@ -63,6 +63,7 @@
       &nbsp;
       <div class="timeQuery" style="display: inline-block">
         <el-button size="small" :loading="loading" @click="dateQuery">查询</el-button>
+        <el-button size="small" :loading="loading" @click="exportDataEvent">导出</el-button>
       </div>
     </div>
     <basic-container>
@@ -123,6 +124,29 @@ export default {
     this.getStationCode()
   },
   methods: {
+    exportDataEvent(){
+      if(this.startTime == null){
+        this.$message.error("请输入开始时间")
+      }
+      if(this.endTime == null){
+        this.$message.error("请输入结束时间")
+      }
+      if(this.equipmentId == null){
+        this.$message.error("请选择设备")
+      }
+      this.$axios.get("/windturbinestatusdata/exportDataEvent/" + this.stationCode + "/" + this.startTime + "/" + this.endTime + '/' + this.equipmentId,
+        {
+          responseType:"blob"
+        }
+      ).then((response) => {
+        this.loading = false
+      }
+      ).catch((error) =>
+      {this.loading = false;
+       this.$message.error("导出失败")
+      }
+      )
+    },
     getGridOnloadData() {
       const param = new URLSearchParams()
       param.append('currentPage', this.page.currentPage)

+ 112 - 5
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/InverterStatusDataController.java

@@ -1,8 +1,12 @@
 package com.jiayue.ipp.idp.controller;
 
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jiayue.ipp.common.data.entity.ElectricField;
 import com.jiayue.ipp.common.data.entity.InverterStatusData;
 import com.jiayue.ipp.idp.service.InverterStatusDataService;
 import com.jiayue.ipp.idp.util.R;
@@ -10,12 +14,16 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.core.parameters.P;
+import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.prefs.AbstractPreferences;
 
 
 /**
@@ -64,4 +72,103 @@ public class InverterStatusDataController {
         page.setMaxLimit((long) -1);
         return R.ok(inverterStatusDataService.page(page, inverterStatusDataService.getByStationCodeAndEquipmentIdAndTimeBetween(stationCode, equipmentId, new Date(startTime), new Date(endTime))));
     }
+
+    @GetMapping("/exportDataEvent/{stationCode}/{startTime}/{endTime}/{equipmentId}")
+    public R exportDataEvent(
+            @PathVariable("stationCode") String stationCode,
+            @PathVariable("startTime") Long startTime,
+            @PathVariable("endTime") Long endTime,
+            @PathVariable("equipmentId") String equipmentId,
+            HttpServletResponse response
+
+    ){
+        try {
+            Map<String, List> dataMap = inverterStatusDataService.getCompositeData(stationCode,new Date(startTime),new Date(endTime),equipmentId);
+
+            List<String> headers = Arrays.asList(
+                    "所属场站", "设备名称", "设备ID", "状态", "时间",
+                    "有功(KW)", "无功(KVar)", "电压", "电流",
+                    "当日发电量", "累积发电量", "当日并网小时数"
+            );
+
+            List<List<?>> excelData = new ArrayList<>();
+            excelData.add(headers);
+
+            List<?> stationNameList = dataMap.get("stationName");       // 所属场站名称
+            List<?> equipmentNameList = dataMap.get("equipmentName");   // 设备名称
+            List<?> equipmentIdList = dataMap.get("equipmentId");       // 设备ID
+            List<?> statusList = dataMap.get("status");                 // 状态
+            List<?> timeList = dataMap.get("time");                     // 时间
+            List<?> activePowerList = dataMap.get("activePower");       // 有功
+            List<?> reactivePowerList = dataMap.get("reactivePower");   // 无功
+            List<?> voltageList = dataMap.get("voltage");               // 电压
+            List<?> electricalCurrentList = dataMap.get("electricalCurrent"); // 电流
+            List<?> dayElectricQuantityList = dataMap.get("dayElectricQuantity"); // 当日发电量
+            List<?> cumulativeEnergyList = dataMap.get("cumulativeGeneratedEnergy"); // 累积发电量
+            List<?> gridHoursList = dataMap.get("dayGridConnectedHours"); // 当日并网小时数
+
+            // 确定数据总行数(以场站名称列表为准,避免空指针)
+            int rowCount = stationNameList != null ? stationNameList.size() : 0;
+
+            for (int i = 0; i < rowCount; i++) {
+                List<Object> row = new ArrayList<>();
+                row.add(getSafeValue(stationNameList, i));         // 所属场站
+                row.add(getSafeValue(equipmentNameList, i));       // 设备名称
+                row.add(getSafeValue(equipmentIdList, i));         // 设备ID
+                // 状态值为1代表运行,2代表待机,3代表停用,4代表故障
+                Object statusValue = getSafeValue(statusList,i);
+                String status = statusValue.toString();
+                if ("1".equals(status)){
+                    status = "运行";
+                }else if ("2".equals(status)){
+                    status = "待机";
+                }else if ("3".equals(status)){
+                    status = "停用";
+                }else if ("4".equals(status)){
+                    status = "故障";
+                }
+                row.add(status);              // 状态(1-运行/2-待机/3-停用/4-故障)
+                row.add(getSafeValue(timeList, i));                // 时间(已格式化)
+                row.add(getSafeValue(activePowerList, i));         // 有功(KW)
+                row.add(getSafeValue(reactivePowerList, i));       // 无功(KVar)
+                row.add(getSafeValue(voltageList, i));             // 电压
+                row.add(getSafeValue(electricalCurrentList, i));   // 电流
+                row.add(getSafeValue(dayElectricQuantityList, i)); // 当日发电量
+                row.add(getSafeValue(cumulativeEnergyList, i));    // 累积发电量
+                row.add(getSafeValue(gridHoursList, i));           // 当日并网小时数
+
+                excelData.add(row);
+            }
+
+
+            ExcelWriter writer = ExcelUtil.getWriter(true);
+            writer.renameSheet(0,"逆变器数据");
+            writer.write(excelData,true);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String fileName = "逆变器数据_" + sdf.format(startTime) + "至" + sdf.format(endTime) + ".xlsx";
+            response.setContentType("application/x-msdownload;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+            ServletOutputStream outputStream = response.getOutputStream();
+            writer.flush(outputStream,true);
+            writer.close();
+            IoUtil.close(outputStream);
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return R.ok();
+    }
+
+    private Object getSafeValue(List<?> list , int index){
+        if (list == null || index <0 || index > list.size()){
+            return "";
+        }
+        Object value = list.get(index);
+        if (value instanceof BigDecimal){
+            return ((BigDecimal) value).stripTrailingZeros();
+        }
+
+        return value == null ? "" : value;
+    }
 }

+ 154 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/NwpController.java

@@ -1,5 +1,8 @@
 package com.jiayue.ipp.idp.controller;
 
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -10,9 +13,15 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.parameters.P;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 
 /**
@@ -109,4 +118,148 @@ public class NwpController {
         return R.ok(nwpService.removeById(id));
     }
 
+    /**
+     * 导出
+     */
+    @GetMapping("/exportDataEvent/{startTime}/{endTime}/{stationCode}")
+    public R exportDataEvent(
+            @PathVariable("startTime") Long startTime,
+            @PathVariable("endTime") Long endTime,
+            @PathVariable("stationCode") String stationCode,
+            HttpServletResponse response
+    ){
+        try {
+            Map<String, List> dataMap = nwpService.getCompositeData(stationCode, new Date(startTime), new Date(endTime));
+
+            List<String> headers = Arrays.asList(
+                    "所属场站", "预测时间", "温度", "湿度", "气压", "短波辐射", "直辐射", "散辐射",
+                    "10米风速", "30米风速", "50米风速", "70米风速", "80米风速", "90米风速", "100米风速", "110米风速", "120米风速", "130米风速", "140米风速", "150米风速", "170米风速",
+                    "10米风向", "30米风向", "50米风向", "70米风向", "80米风向", "90米风向", "100米风向", "110米风向", "120米风向", "130米风向", "140米风向", "150米风向", "170米风向",
+                    "降水总量"
+            );
+
+            List<List<?>> excelData = new ArrayList<>();
+            excelData.add(headers); // 添加表头
+
+            // 3. 从 dataMap 中获取各字段数据列表
+            List<?> stationNameList = dataMap.get("stationName"); // 所属场站名称列表
+            List<?> preTimeList = dataMap.get("preTime"); // 预测时间列表
+            List<?> tList = dataMap.get("t"); // 温度列表
+            List<?> rhList = dataMap.get("rh"); // 湿度列表
+            List<?> pressureList = dataMap.get("pressure"); // 气压列表
+            List<?> swrList = dataMap.get("swr"); // 短波辐射列表
+            List<?> directRadiationList = dataMap.get("directRadiation"); // 直辐射列表
+            List<?> diffuseRadiationList = dataMap.get("diffuseRadiation"); // 散辐射列表
+
+            List<?> ws10List = dataMap.get("ws10"); // 10米风速列表
+            List<?> ws30List = dataMap.get("ws30"); // 30米风速列表
+            List<?> ws50List = dataMap.get("ws50"); // 50米风速列表
+            List<?> ws70List = dataMap.get("ws70"); // 70米风速列表
+            List<?> ws80List = dataMap.get("ws80"); // 80米风速列表
+            List<?> ws90List = dataMap.get("ws90"); // 90米风速列表
+            List<?> ws100List = dataMap.get("ws100"); // 100米风速列表
+            List<?> ws110List = dataMap.get("ws110"); // 110米风速列表
+            List<?> ws120List = dataMap.get("ws120"); // 120米风速列表
+            List<?> ws130List = dataMap.get("ws130"); // 130米风速列表
+            List<?> ws140List = dataMap.get("ws140"); // 140米风速列表
+            List<?> ws150List = dataMap.get("ws150"); // 150米风速列表
+            List<?> ws170List = dataMap.get("ws170"); // 170米风速列表
+
+            List<?> wd10List = dataMap.get("wd10"); // 10米风向列表
+            List<?> wd30List = dataMap.get("wd30"); // 30米风向列表
+            List<?> wd50List = dataMap.get("wd50"); // 50米风向列表
+            List<?> wd70List = dataMap.get("wd70"); // 70米风向列表
+            List<?> wd80List = dataMap.get("wd80"); // 80米风向列表
+            List<?> wd90List = dataMap.get("wd90"); // 90米风向列表
+            List<?> wd100List = dataMap.get("wd100"); // 100米风向列表
+            List<?> wd110List = dataMap.get("wd110"); // 110米风向列表
+            List<?> wd120List = dataMap.get("wd120"); // 120米风向列表
+            List<?> wd130List = dataMap.get("wd130"); // 130米风向列表
+            List<?> wd140List = dataMap.get("wd140"); // 140米风向列表
+            List<?> wd150List = dataMap.get("wd150"); // 150米风向列表
+            List<?> wd170List = dataMap.get("wd170"); // 170米风向列表
+
+            List<?> tprList = dataMap.get("tpr"); // 降水总量列表
+
+            // 4. 确定数据总行数
+            int rowCount = stationNameList != null ? stationNameList.size() : 0;
+
+            // 5. 逐行填充数据
+            for (int i = 0; i < rowCount; i++) {
+                List<Object> row = new ArrayList<>();
+                row.add(getSafeValue(stationNameList, i)); // 所属场站
+                row.add(getSafeValue(preTimeList, i)); // 预测时间
+                row.add(getSafeValue(tList, i)); // 温度
+                row.add(getSafeValue(rhList, i)); // 湿度
+                row.add(getSafeValue(pressureList, i)); // 气压
+                row.add(getSafeValue(swrList, i)); // 短波辐射
+                row.add(getSafeValue(directRadiationList, i)); // 直辐射
+                row.add(getSafeValue(diffuseRadiationList, i)); // 散辐射
+
+                row.add(getSafeValue(ws10List, i)); // 10米风速
+                row.add(getSafeValue(ws30List, i)); // 30米风速
+                row.add(getSafeValue(ws50List, i)); // 50米风速
+                row.add(getSafeValue(ws70List, i)); // 70米风速
+                row.add(getSafeValue(ws80List, i)); // 80米风速
+                row.add(getSafeValue(ws90List, i)); // 90米风速
+                row.add(getSafeValue(ws100List, i)); // 100米风速
+                row.add(getSafeValue(ws110List, i)); // 110米风速
+                row.add(getSafeValue(ws120List, i)); // 120米风速
+                row.add(getSafeValue(ws130List, i)); // 130米风速
+                row.add(getSafeValue(ws140List, i)); // 140米风速
+                row.add(getSafeValue(ws150List, i)); // 150米风速
+                row.add(getSafeValue(ws170List, i)); // 170米风速
+
+                row.add(getSafeValue(wd10List, i)); // 10米风向
+                row.add(getSafeValue(wd30List, i)); // 30米风向
+                row.add(getSafeValue(wd50List, i)); // 50米风向
+                row.add(getSafeValue(wd70List, i)); // 70米风向
+                row.add(getSafeValue(wd80List, i)); // 80米风向
+                row.add(getSafeValue(wd90List, i)); // 90米风向
+                row.add(getSafeValue(wd100List, i)); // 100米风向
+                row.add(getSafeValue(wd110List, i)); // 110米风向
+                row.add(getSafeValue(wd120List, i)); // 120米风向
+                row.add(getSafeValue(wd130List, i)); // 130米风向
+                row.add(getSafeValue(wd140List, i)); // 140米风向
+                row.add(getSafeValue(wd150List, i)); // 150米风向
+                row.add(getSafeValue(wd170List, i)); // 170米风向
+
+                row.add(getSafeValue(tprList, i)); // 降水总量
+
+                excelData.add(row);
+            }
+
+            ExcelWriter writer = ExcelUtil.getWriter(true);
+            writer.renameSheet(0,"nwp数据");
+            writer.write(excelData,true);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String fileName = "NWP数据_" + sdf.format(startTime) + "至" + sdf.format(endTime) + ".xlsx";
+            response.setContentType("application/x-msdownload;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+
+            ServletOutputStream outputStream = response.getOutputStream();
+            writer.flush(outputStream);
+            writer.close();
+            IoUtil.close(outputStream);
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+        return R.ok();
+    }
+
+    private Object getSafeValue(List<?> list , int index){
+        if (list == null || index <0 || index >= list.size()){
+            return "";
+        }
+
+        Object value = list.get(index);
+        if (value instanceof BigDecimal){
+            return ((BigDecimal) value).stripTrailingZeros();
+        }
+
+        return value == null ? "" : value;
+    }
+
 }

+ 100 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WeatherStationStatusDataController.java

@@ -1,5 +1,8 @@
 package com.jiayue.ipp.idp.controller;
 
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -12,7 +15,12 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 
 /**
@@ -104,4 +112,95 @@ public class WeatherStationStatusDataController {
         page.setMaxLimit((long) -1);
         return R.ok(weatherStationStatusDataService.page(page, weatherStationStatusDataService.getPageByStationCodeAndeTimeBetweenAndEquipmentId(stationCode, new Date(startTime), new Date(endTime), equipmentId)));
     }
+
+    @GetMapping("/exportDataEvent/{stationCode}/{startTime}/{endTime}/{equipmentId}")
+    public R exportDataEvent(
+            @PathVariable("stationCode") String stationCode,
+            @PathVariable("startTime") Long startTime,
+            @PathVariable("endTime") Long endTime,
+            @PathVariable("equipmentId") String equipmentId,
+            HttpServletResponse response
+    ){
+        try {
+            Map<String , List> dataMap = weatherStationStatusDataService.getCompositeData(stationCode,new Date(startTime),new Date(endTime),equipmentId);
+            List<String> headers = Arrays.asList(
+                    "所属场站", "设备名称", "设备ID", "时间",
+                    "总辐射(W/㎡)", "直接辐射(W/㎡)", "散射辐射(W/㎡)",
+                    "环境温度(℃)", "气压(KPa)", "湿度(%)",
+                    "光伏电池板温度(℃)", "风速(m/s)", "风向(°)"
+            );
+
+            // 3. 初始化Excel数据容器并添加表头
+            List<List<?>> excelData = new ArrayList<>();
+            excelData.add(headers);
+
+            // 4. 从数据映射中获取各字段列表
+            List<?> stationNameList = dataMap.get("stationName");       // 所属场站名称
+            List<?> equipmentNameList = dataMap.get("equipmentName");   // 设备名称
+            List<?> equipmentIdList = dataMap.get("equipmentId");       // 设备ID
+            List<?> timeList = dataMap.get("time");                     // 时间
+            List<?> globalRList = dataMap.get("globalR");               // 总辐射
+            List<?> directRList = dataMap.get("directR");               // 直接辐射
+            List<?> diffuseRList = dataMap.get("diffuseR");             // 散射辐射
+            List<?> airTList = dataMap.get("airT");                     // 环境温度
+            List<?> pList = dataMap.get("p");                           // 气压
+            List<?> rhList = dataMap.get("rh");                         // 湿度
+            List<?> cellTList = dataMap.get("cellT");                   // 光伏电池板温度
+            List<?> wsList = dataMap.get("ws");                         // 风速
+            List<?> wdList = dataMap.get("wd");                         // 风向
+
+            // 5. 确定数据总行数(以设备ID列表为准)
+            int rowCount = equipmentIdList != null ? equipmentIdList.size() : 0;
+
+            // 6. 逐行填充数据
+            for (int i = 0; i < rowCount; i++) {
+                List<Object> row = new ArrayList<>();
+                row.add(getSafeValue(stationNameList, i));       // 所属场站
+                row.add(getSafeValue(equipmentNameList, i));     // 设备名称
+                row.add(getSafeValue(equipmentIdList, i));       // 设备ID
+                row.add(getSafeValue(timeList, i));              // 时间
+                row.add(getSafeValue(globalRList, i));           // 总辐射(W/㎡)
+                row.add(getSafeValue(directRList, i));           // 直接辐射(W/㎡)
+                row.add(getSafeValue(diffuseRList, i));          // 散射辐射(W/㎡)
+                row.add(getSafeValue(airTList, i));              // 环境温度(℃)
+                row.add(getSafeValue(pList, i));                 // 气压(KPa)
+                row.add(getSafeValue(rhList, i));                // 湿度(%)
+                row.add(getSafeValue(cellTList, i));             // 光伏电池板温度(℃)
+                row.add(getSafeValue(wsList, i));                // 风速(m/s)
+                row.add(getSafeValue(wdList, i));                // 风向(°)
+
+                excelData.add(row);
+            }
+
+
+            ExcelWriter writer = ExcelUtil.getWriter(true);
+            writer.renameSheet(0,"气象站数据");
+            writer.write(excelData,true);
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String fileName = "气象站数据_" + sdf.format(startTime) + "至" + sdf.format(endTime) + ".xlsx";
+            response.setContentType("application/x-msdownload;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+
+            ServletOutputStream out = response.getOutputStream();
+            writer.flush(out , true);
+            writer.close();
+            IoUtil.close(out);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return  R.ok();
+    }
+
+    private Object getSafeValue(List<?> list, int index) {
+        if (list == null || index < 0 || index >= list.size()) {
+            return ""; // 空值仍返回空字符串
+        }
+        Object value = list.get(index);
+        // 对BigDecimal做去尾零处理
+        if (value instanceof BigDecimal) {
+            return ((BigDecimal) value).stripTrailingZeros();
+        }
+        return value == null ? "" : value;
+    }
 }

+ 121 - 5
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WindTowerStatusDataController.java

@@ -1,5 +1,9 @@
 package com.jiayue.ipp.idp.controller;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,14 +12,17 @@ import com.jiayue.ipp.idp.service.WindTowerStatusDataService;
 import com.jiayue.ipp.idp.util.R;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.undertow.util.HeaderValues;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 
 /**
@@ -62,4 +69,113 @@ public class WindTowerStatusDataController {
         page.setMaxLimit((long) -1);
         return R.ok(windTowerStatusDataService.page(page, windTowerStatusDataService.getByBetweenTimeAndEquipmentIdAndStationCode(new Date(startTime), new Date(endTime), equipmentId, stationCode)));
     }
+
+
+    /**
+     * 导出功能
+     * @param stationCode
+     * @param startTime
+     * @param endTime
+     * @param equipmentId
+     * @param response
+     * @return
+     */
+    @GetMapping("/exportDataEvent/{stationCode}/{startTime}/{endTime}/{equipmentId}")
+    public R exportDataEvent(
+            @PathVariable("stationCode") String stationCode,
+            @PathVariable("startTime") Long startTime,
+            @PathVariable("endTime") Long endTime,
+            @PathVariable("equipmentId") String equipmentId,
+            HttpServletResponse response
+    ) {
+        try {
+            Map<String, List> dataMap = windTowerStatusDataService.getCompositeData(stationCode,new Date(startTime),new Date(endTime),equipmentId);
+            List<String> headers = Arrays.asList(
+                    "所属场站", "设备名称", "时间",
+                    "温度瞬时值(℃)", "湿度瞬时值(%RH)", "气压瞬时值(hPa)",
+                    "10米风速瞬时值(m/s)", "10米风向瞬时值(°)", "30米风速瞬时值(m/s)",
+                    "30米风向瞬时值(°)", "50米风速瞬时值(m/s)", "50米风向瞬时值(°)",
+                    "70米风速瞬时值(m/s)", "70米风向瞬时值(°)", "轮毂高度风速瞬时值(m/s)", "轮毂高度风向瞬时值(°)"
+            );
+
+            // 获取字段表头对应数据
+            List<List<?>> excelData = new ArrayList<>();
+            excelData.add(headers);
+            List<?> stationNameList = dataMap.get("stationName");
+            List<?> equipmentNameList = dataMap.get("equipmentName");
+            List<?> timeList = dataMap.get("time");
+            List<?> tInstList = dataMap.get("tInst");
+            List<?> rhInstList = dataMap.get("rhInst");
+            List<?> paInstList = dataMap.get("paInst");
+            List<?> wsInst10List = dataMap.get("wsInst10");
+            List<?> wdInst10List = dataMap.get("wdInst10");
+            List<?> wsInst30List = dataMap.get("wsInst30");
+            List<?> wdInst30List = dataMap.get("wdInst30");
+            List<?> wsInst50List = dataMap.get("wsInst50");
+            List<?> wdInst50List = dataMap.get("wdInst50");
+            List<?> wsInst70List = dataMap.get("wsInst70");
+            List<?> wdInst70List = dataMap.get("wdInst70");
+            List<?> wsInstHubHeightList = dataMap.get("wsInstHubHeight");
+            List<?> wdInstHubHeightList = dataMap.get("wdInstHubHeight");
+
+            // 逐行填充数据
+            int rowCount = stationNameList != null ? stationNameList.size() : 0;
+            for (int i = 0; i < rowCount; i++) {
+                List<Object> row = new ArrayList<>();
+                row.add(getSafeValue(stationNameList, i));
+                row.add(getSafeValue(equipmentNameList, i));
+                row.add(getSafeValue(timeList, i));
+                row.add(getSafeValue(tInstList, i));
+                row.add(getSafeValue(rhInstList, i));
+                row.add(getSafeValue(paInstList, i));
+                row.add(getSafeValue(wsInst10List, i));
+                row.add(getSafeValue(wdInst10List, i));
+                row.add(getSafeValue(wsInst30List, i));
+                row.add(getSafeValue(wdInst30List, i));
+                row.add(getSafeValue(wsInst50List, i));
+                row.add(getSafeValue(wdInst50List, i));
+                row.add(getSafeValue(wsInst70List, i));
+                row.add(getSafeValue(wdInst70List, i));
+                row.add(getSafeValue(wsInstHubHeightList, i));
+                row.add(getSafeValue(wdInstHubHeightList, i));
+                excelData.add(row);
+            }
+
+            // 生成excel文件
+            ExcelWriter writer = ExcelUtil.getWriter(true);
+            writer.renameSheet(0, "测风塔数据");
+            writer.write(excelData, true);
+
+            // 响应头处理
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String fileName = "测风塔数据_" + sdf.format(startTime) + "至" + sdf.format(endTime) + ".xlsx";
+            response.setContentType("application/x-msdownload;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+
+            // 输出流处理
+            ServletOutputStream out = response.getOutputStream();
+            writer.flush(out, true);
+            writer.close();
+            IoUtil.close(out);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        return R.ok();
+    }
+
+    // 安全获取值
+    private Object getSafeValue(List<?> list, int index) {
+        if (list == null || index < 0 || index >= list.size()) {
+            return ""; // 空值仍返回空字符串
+        }
+        Object value = list.get(index);
+        // 对BigDecimal做去尾零处理
+        if (value instanceof BigDecimal) {
+            return ((BigDecimal) value).stripTrailingZeros();
+        }
+        return value == null ? "" : value;
+    }
+
 }

+ 126 - 6
ipp-idp/src/main/java/com/jiayue/ipp/idp/controller/WindTurbineStatusDataController.java

@@ -1,5 +1,8 @@
 package com.jiayue.ipp.idp.controller;
 
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,13 +11,18 @@ import com.jiayue.ipp.idp.service.WindTurbineStatusDataService;
 import com.jiayue.ipp.idp.util.R;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import jdk.internal.dynalink.linker.LinkerServices;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
 
-import java.util.Date;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 
 /**
@@ -28,7 +36,7 @@ import java.util.Date;
 @RequestMapping("/windturbinestatusdata")
 @Api(value = "windturbinestatusdata", tags = "idp_wind_turbine_status_data管理")
 public class WindTurbineStatusDataController {
-
+    @Autowired
     private final WindTurbineStatusDataService windTurbineStatusDataService;
 
     /**
@@ -58,4 +66,116 @@ public class WindTurbineStatusDataController {
         page.setMaxLimit((long) -1);
         return R.ok(windTurbineStatusDataService.page(page, windTurbineStatusDataService.getByStationCodeAndEquipmentIdAndTimeBetween(stationCode, equipmentId, new Date(startTime), new Date(endTime))));
     }
+
+    @GetMapping("/exportDataEvent/{stationCode}/{startTime}/{endTime}/{equipmentId}")
+    public R exportDataEvent(
+            @PathVariable("stationCode") String stationCode,
+            @PathVariable("startTime") Long startTime,
+            @PathVariable("endTime") Long endTime,
+            @PathVariable("equipmentId") String equipmentId,
+            HttpServletResponse response
+    ) {
+        try {
+            // 调用 Service 获取数据
+            Map<String, List> dataMap = windTurbineStatusDataService.getCompositeData(
+                    stationCode, new Date(startTime), new Date(endTime), equipmentId);
+
+            // 定义 Excel 表头,与图片中的字段顺序一致
+            List<String> headers = Arrays.asList(
+                    "所属场站", "设备名称", "状态", "时间",
+                    "有功(KW)", "无功(KVar)", "电压(V)", "电流(A)",
+                    "转速(rpm)", "风速(m/s)", "风向(°)", "环境温度(℃)", "桨距角(°)"
+            );
+
+            List<List<?>> excelData = new ArrayList<>();
+            excelData.add(headers); // 添加表头
+
+            // 从 dataMap 中获取各字段数据列表
+            List<?> stationNameList = dataMap.get("stationName");
+            List<?> equipmentNameList = dataMap.get("equipmentName");
+            List<?> statusList = dataMap.get("status");
+            List<?> timeList = dataMap.get("time");
+            List<?> activePowerList = dataMap.get("activePower");
+            List<?> reactivePowerList = dataMap.get("reactivePower");
+            List<?> voltageList = dataMap.get("voltage");
+            List<?> electricalCurrentList = dataMap.get("electricalCurrent");
+            List<?> windWheelRatedSpeedList = dataMap.get("windWheelRatedSpeed");
+            List<?> wsList = dataMap.get("ws");
+            List<?> wdList = dataMap.get("wd");
+            List<?> tList = dataMap.get("t");
+            List<?> pitchAngleList = dataMap.get("pitchAngle");
+
+            // 确定数据总行数
+            int rowCount = stationNameList != null ? stationNameList.size() : 0;
+
+            // 逐行填充数据
+            for (int i = 0; i < rowCount; i++) {
+                List<Object> row = new ArrayList<>();
+                row.add(getSafeValue(stationNameList, i)); // 所属场站
+                row.add(getSafeValue(equipmentNameList, i)); // 设备名称
+
+                Object safeValue = getSafeValue(statusList, i);
+                String status = "";
+                try {
+                    Integer intStatus = Integer.parseInt(safeValue.toString());
+                    if (intStatus == 1){
+                        status = "运行";
+                    }else if (intStatus == 2){
+                        status = "待机";
+                    }else if (intStatus == 3){
+                        status = "停用";
+                    }else if (intStatus == 4){
+                        status = "故障";
+                    }
+                } catch (NumberFormatException e) {
+                    e.printStackTrace();
+                }
+                row.add(status); // 状态
+                row.add(getSafeValue(timeList, i)); // 时间
+                row.add(getSafeValue(activePowerList, i)); // 有功(KW)
+                row.add(getSafeValue(reactivePowerList, i)); // 无功(KVar)
+                row.add(getSafeValue(voltageList, i)); // 电压(V)
+                row.add(getSafeValue(electricalCurrentList, i)); // 电流(A)
+                row.add(getSafeValue(windWheelRatedSpeedList, i)); // 转速(rpm)
+                row.add(getSafeValue(wsList, i)); // 风速(m/s)
+                row.add(getSafeValue(wdList, i)); // 风向(°)
+                row.add(getSafeValue(tList, i)); // 环境温度(℃)
+                row.add(getSafeValue(pitchAngleList, i)); // 桨距角(°)
+                excelData.add(row);
+            }
+
+            // 生成 Excel 并导出
+            ExcelWriter writer = ExcelUtil.getWriter(true);
+            writer.renameSheet(0, "风机数据");
+            writer.write(excelData, true);
+
+            // 设置响应头,触发下载
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            String fileName = "风机数据" + sdf.format(startTime) + "至" + sdf.format(endTime) + ".xlsx";
+            response.setContentType("application/x-msdownload;charset=utf-8");
+            response.setHeader("Content-disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8"));
+
+            // 写出数据并关闭资源
+            ServletOutputStream out = response.getOutputStream();
+            writer.flush(out, true);
+            writer.close();
+            IoUtil.close(out);
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return R.ok();
+    }
+
+    // 安全获取列表中的值,避免空指针和索引越界
+    private Object getSafeValue(List<?> list, int index) {
+        if (list == null || index < 0 || index >= list.size()) {
+            return "";
+        }
+        Object value = list.get(index);
+        if (value instanceof BigDecimal) {
+            return ((BigDecimal) value).stripTrailingZeros();
+        }
+        return value == null ? "" : value;
+    }
 }

+ 4 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/InverterStatusDataService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.jiayue.ipp.common.data.entity.InverterStatusData;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * 逆变器数据业务层接口
@@ -14,4 +16,6 @@ import java.util.Date;
  */
 public interface InverterStatusDataService extends IService<InverterStatusData> {
     QueryWrapper<InverterStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime);
+
+    Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId);
 }

+ 4 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/NwpService.java

@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.jiayue.ipp.common.data.entity.Nwp;
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * idp_nwp
@@ -14,4 +16,6 @@ import java.util.Date;
  */
 public interface NwpService extends IService<Nwp> {
     QueryWrapper<Nwp> getPageByStationCodeAndeTimeBetween(String stationCode, Date startTime, Date endTime,String forecastManufactor);
+
+    Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime);
 }

+ 3 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WeatherStationStatusDataService.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.jiayue.ipp.common.data.entity.WeatherStationStatusData;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 
 
@@ -18,4 +19,6 @@ public interface WeatherStationStatusDataService extends IService<WeatherStation
     Map<String, Object> findByStationCodeAndeTimeBetweenAndEquipmentId(String stationCode, Date startTime, Date endTime, String equipmentId);
 
     QueryWrapper<WeatherStationStatusData> getPageByStationCodeAndeTimeBetweenAndEquipmentId(String stationCode, Date startTime, Date endTime, String equipmentId);
+
+    Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId);
 }

+ 2 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WindTowerStatusDataService.java

@@ -20,4 +20,6 @@ public interface WindTowerStatusDataService extends IService<WindTowerStatusData
     QueryWrapper<WindTowerStatusData> getByBetweenTimeAndEquipmentIdAndStationCode(Date startTime, Date endTime, String equipmentId, String stationCode);
 
     Map<String, Object> queryCharts(String stationCode, Date startTime, Date endTime, String equipmentId) throws Exception;
+
+    Map<String ,List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId);
 }

+ 4 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/WindTurbineStatusDataService.java

@@ -6,6 +6,8 @@ import com.jiayue.ipp.common.data.entity.WindTurbineStatusData;
 
 
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * idp_wind_turbine_status_data
@@ -15,4 +17,6 @@ import java.util.Date;
  */
 public interface WindTurbineStatusDataService extends IService<WindTurbineStatusData> {
     QueryWrapper<WindTurbineStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime);
+
+    Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId);
 }

+ 114 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/InverterStatusDataServiceImpl.java

@@ -2,12 +2,23 @@ package com.jiayue.ipp.idp.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipp.common.data.entity.ElectricField;
+import com.jiayue.ipp.common.data.entity.InverterInfo;
 import com.jiayue.ipp.common.data.entity.InverterStatusData;
 import com.jiayue.ipp.idp.mapper.InverterStatusDataMapper;
+import com.jiayue.ipp.idp.service.ElectricFieldService;
+import com.jiayue.ipp.idp.service.InverterInfoService;
 import com.jiayue.ipp.idp.service.InverterStatusDataService;
+import lombok.AllArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
+import javax.persistence.criteria.CriteriaBuilder;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * idp_inverter_status_data
@@ -17,6 +28,13 @@ import java.util.Date;
  */
 @Service
 public class InverterStatusDataServiceImpl extends ServiceImpl<InverterStatusDataMapper, InverterStatusData> implements InverterStatusDataService {
+    @Autowired
+    private InverterStatusDataMapper inverterStatusDataMapper;
+    @Autowired
+    private InverterInfoService inverterInfoService;
+    @Autowired
+    private ElectricFieldService electricFieldService;
+
     @Override
     public QueryWrapper<InverterStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime) {
         QueryWrapper<InverterStatusData> wrapper = new QueryWrapper<>();
@@ -32,4 +50,99 @@ public class InverterStatusDataServiceImpl extends ServiceImpl<InverterStatusDat
         }
         return wrapper;
     }
+
+    @Override
+    public Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId) {
+        Map<String , List> resultMap = new HashMap<>();
+
+        QueryWrapper<InverterStatusData> wrapper = getByStationCodeAndEquipmentIdAndTimeBetween(stationCode,equipmentId,startTime,endTime);
+        List<InverterStatusData> dataList = inverterStatusDataMapper.selectList(wrapper);
+        Collections.sort(dataList,Comparator.comparing(InverterStatusData::getTime));
+
+        Map<String,String> equimentNameMap = new HashMap<>();
+        Set<String> eqIdSet = dataList.stream()
+                .map(InverterStatusData::getEquipmentId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        if (! eqIdSet.isEmpty()){
+            List<InverterInfo> allEqList = inverterInfoService.list();
+            List<InverterInfo> eqList = allEqList.stream()
+                    .filter(eq -> eqIdSet.contains(eq.getEquipmentNo()))
+                    .collect(Collectors.toList());
+            for (InverterInfo eq : eqList) {
+                equimentNameMap.put(eq.getEquipmentNo(),eq.getName());
+            }
+        }
+
+        Map<String,String> stationNameMap = new HashMap<>();
+        if (stationCode != null && !stationCode.isEmpty()){
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            if (electricField != null){
+                String stationName = electricField.getName();
+                stationNameMap.put(stationCode ,stationName);
+            }
+        }
+
+        List<String> exportColumns = Arrays.asList(
+                "stationCode",                // 所属场站(父类 BaseDataEntity 中字段)
+                "equipmentId",                // 设备主键ID
+                "status",                     // 状态(1运行、2待机、3停用、4故障)
+                "time",                       // 时间
+                "activePower",                // 有功(KW)
+                "reactivePower",              // 无功(KVar)
+                "voltage",                    // 电压
+                "electricalCurrent",          // 电流
+                "dayElectricQuantity",        // 当日发电量
+                "cumulativeGeneratedEnergy",  // 累积发电量
+                "dayGridConnectedHours"       // 当日并网小时数
+        );
+        for (String column : exportColumns) {
+            resultMap.put(column,new ArrayList());
+        }
+        resultMap.put("equipmentName",new ArrayList());
+        resultMap.put("stationName",new ArrayList());
+
+        for (InverterStatusData data : dataList) {
+            String stationName = stationNameMap.getOrDefault(stationCode,stationCode);
+            resultMap.get("stationName").add(stationName);
+
+            String eqId = data.getEquipmentId();
+            String eqName = equimentNameMap.getOrDefault(eqId,eqId);
+            resultMap.get("equipmentName").add(eqName);
+
+            for (String column : exportColumns) {
+                try {
+                    Field field = getField(InverterStatusData.class , column);
+                    field.setAccessible(true);
+                    Object value = field.get(data);
+
+                    if ("time".equals(column) && value instanceof  Date){
+                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        value = sdf.format((Date) value);
+                    }else if (value instanceof BigDecimal){
+                        BigDecimal num = (BigDecimal) value;
+                        value = num.stripTrailingZeros();
+                    }
+                    resultMap.get(column).add(value == null ? "":value);
+
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+
+            }
+
+        }
+
+        return resultMap;
+    }
+
+    private Field getField(Class<?> clazz , String fieldName) throws NoSuchFieldException {
+        try {
+            return clazz.getDeclaredField(fieldName);
+        }catch (Exception e){
+            Class<?> superClass = clazz.getSuperclass();
+            if (superClass == null) throw e;
+            return getField(superClass,fieldName);
+        }
+    }
 }

+ 111 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/NwpServiceImpl.java

@@ -3,12 +3,18 @@ package com.jiayue.ipp.idp.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import
         com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipp.common.data.entity.ElectricField;
 import com.jiayue.ipp.common.data.entity.Nwp;
 import com.jiayue.ipp.idp.mapper.NwpMapper;
+import com.jiayue.ipp.idp.service.ElectricFieldService;
 import com.jiayue.ipp.idp.service.NwpService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 /**
  * idp_nwp
@@ -19,6 +25,10 @@ import java.util.Date;
 @Service
 public class NwpServiceImpl extends ServiceImpl<NwpMapper, Nwp> implements NwpService {
 
+    @Autowired
+    private NwpMapper nwpMapper;
+    @Autowired
+    private ElectricFieldService electricFieldService;
 
     @Override
     public QueryWrapper<Nwp> getPageByStationCodeAndeTimeBetween(String stationCode, Date startTime, Date endTime,String forecastManufactor) {
@@ -35,4 +45,104 @@ public class NwpServiceImpl extends ServiceImpl<NwpMapper, Nwp> implements NwpSe
         }
         return wrapper;
     }
+
+    @Override
+    public Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime) {
+
+        //最终返回结果集
+        Map<String, List> resultMap = new HashMap<>();
+        //获取符合条件的nwp数据集 按时间排序
+        QueryWrapper<Nwp> nwpQueryWrapper = getPageByStationCodeAndeTimeBetween(stationCode,startTime,endTime,null);
+        List<Nwp> nwpList = nwpMapper.selectList(nwpQueryWrapper);
+        Collections.sort(nwpList , Comparator.comparing(Nwp :: getPreTime));
+
+        Map<String,String> stationNameMap = new HashMap<>();
+        if (stationCode != null && !stationCode.isEmpty()){
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            if (electricField != null){
+                stationNameMap.put(stationCode,electricField.getName());
+            }
+        }
+
+        List<String> exportColumns = Arrays.asList(
+                "stationCode",          // 所属场站(父类NotLogicBaseEntity中字段,对应“所属场站”)
+                "preTime",              // 预测时间(对应“预测时间”)
+                "t",                    // 温度(对应“温度”)
+                "rh",                   // 湿度(对应“湿度”)
+                "pressure",             // 气压(对应“气压”)
+                "swr",                  // 短波辐射(对应“短波辐射”)
+                "directRadiation",      // 直辐射(对应“直辐射”)
+                "diffuseRadiation",     // 散辐射(对应“散辐射”)
+                "ws10",                 // 10米风速(对应“10米风速”)
+                "ws30",                 // 30米风速(对应“30米风速”)
+                "ws50",                 // 50米风速(对应“50米风速”)
+                "ws70",                 // 70米风速(对应“70米风速”)
+                "ws80",                 // 80米风速(对应“80米风速”)
+                "ws90",                 // 90米风速(对应“90米风速”)
+                "ws100",                // 100米风速(对应“100米风速”)
+                "ws110",                // 110米风速(对应“110米风速”)
+                "ws120",                // 120米风速(对应“120米风速”)
+                "ws130",                // 130米风速(对应“130米风速”)
+                "ws140",                // 140米风速(对应“140米风速”)
+                "ws150",                // 150米风速(对应“150米风速”)
+                "ws170",                // 170米风速(对应“170米风速”)
+                "wd10",                 // 10米风向(对应“10米风向”)
+                "wd30",                 // 30米风向(对应“30米风向”)
+                "wd50",                 // 50米风向(对应“50米风向”)
+                "wd70",                 // 70米风向(对应“70米风向”)
+                "wd80",                 // 80米风向(对应“80米风向”)
+                "wd90",                 // 90米风向(对应“90米风向”)
+                "wd100",                // 100米风向(对应“100米风向”)
+                "wd110",                // 110米风向(对应“110米风向”)
+                "wd120",                // 120米风向(对应“120米风向”)
+                "wd130",                // 130米风向(对应“130米风向”)
+                "wd140",                // 140米风向(对应“140米风向”)
+                "wd150",                // 150米风向(对应“150米风向”)
+                "wd170",                // 170米风向(对应“170米风向”)
+                "tpr"                   // 降水总量(对应“降水总量”)
+        );
+        for (String column : exportColumns) {
+            resultMap.put(column,new ArrayList());
+        }
+        resultMap.put("stationName",new ArrayList());
+
+        for (Nwp nwp : nwpList) {
+            String stationName = stationNameMap.getOrDefault(stationCode,stationCode);
+            resultMap.get("stationName").add(stationName);
+            for (String column : exportColumns) {
+                try {
+                    Field field = getField(Nwp.class , column);
+                    field.setAccessible(true);
+                    Object value = field.get(nwp);
+
+                    if ("preTime".equals(column) && value instanceof Date){
+                        value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
+                    }else if (value instanceof BigDecimal){
+                        BigDecimal num = (BigDecimal) value;
+                        value = num.stripTrailingZeros();
+                    }
+
+                    resultMap.get(column).add(value == null ? "":value);
+                }catch (Exception e){
+                    e.printStackTrace();
+                    resultMap.get(column).add("");
+                }
+            }
+        }
+
+
+
+
+        return resultMap;
+    }
+
+    public Field getField(Class<?> clazz , String filedName) throws NoSuchFieldException{
+        try {
+            return clazz.getDeclaredField(filedName);
+        }catch (Exception e){
+            Class superClass = clazz.getSuperclass();
+            if (superClass == null)throw e;
+            return getField(superClass , filedName);
+        }
+    }
 }

+ 108 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WeatherStationStatusDataServiceImpl.java

@@ -2,12 +2,20 @@ package com.jiayue.ipp.idp.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipp.common.data.entity.ElectricField;
+import com.jiayue.ipp.common.data.entity.WeatherStationInfo;
 import com.jiayue.ipp.common.data.entity.WeatherStationStatusData;
 import com.jiayue.ipp.idp.mapper.WeatherStationStatusDataMapper;
+import com.jiayue.ipp.idp.service.ElectricFieldService;
+import com.jiayue.ipp.idp.service.WeatherStationInfoService;
 import com.jiayue.ipp.idp.service.WeatherStationStatusDataService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.print.attribute.standard.PageRanges;
+import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.nio.file.Watchable;
 import java.text.SimpleDateFormat;
 import java.time.ZoneOffset;
 import java.util.*;
@@ -22,6 +30,12 @@ import java.util.stream.Collectors;
 @Service
 public class WeatherStationStatusDataServiceImpl extends ServiceImpl<WeatherStationStatusDataMapper, WeatherStationStatusData> implements WeatherStationStatusDataService {
 
+    @Autowired
+    private ElectricFieldService electricFieldService;
+    @Autowired
+    private WeatherStationStatusDataMapper weatherStationStatusDataMapper;
+    @Autowired
+    private WeatherStationInfoService weatherStationInfoService;
     public QueryWrapper<WeatherStationStatusData> getPageByStationCodeAndeTimeBetweenAndEquipmentId(String stationCode, Date startTime, Date endTime, String equipmentId) {
         QueryWrapper<WeatherStationStatusData> wrapper = new QueryWrapper<>();
 
@@ -37,6 +51,100 @@ public class WeatherStationStatusDataServiceImpl extends ServiceImpl<WeatherStat
         return wrapper;
     }
 
+    @Override
+    public Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId) {
+        Map<String,List> resultMap = new HashMap<>();
+        List<WeatherStationStatusData> dataList = getByStationCodeAndTimeAndEndTimeAndEquipmentId(stationCode , startTime , endTime , equipmentId);
+        Collections.sort(dataList , Comparator.comparing(WeatherStationStatusData::getTime));
+
+        Set<String> eqIdSet = dataList.stream()
+                .map(WeatherStationStatusData::getEquipmentId)
+                .filter(Objects :: nonNull)
+                .collect(Collectors.toSet());
+        Map<String,String> equipmentNameMap = new HashMap<>();
+        if (!eqIdSet.isEmpty()){
+            List<WeatherStationInfo> allList = weatherStationInfoService.list();
+            List<WeatherStationInfo> eqList = allList.stream()
+                    .filter(eq -> eqIdSet.contains(eq.getEquipmentNo()))
+                    .collect(Collectors.toList());
+
+            for (WeatherStationInfo eq : eqList) {
+                equipmentNameMap.put(eq.getEquipmentNo(),eq.getName());
+            }
+        }
+
+        Map<String , String> stationNameMap = new HashMap<>();
+        if (stationCode != null){
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            if (electricField!=null){
+                String stationName = electricField.getName();
+                stationNameMap.put(stationCode,stationName);
+            }
+        }
+
+        List<String> exportColumns = Arrays.asList(
+                "stationCode",          // 所属场站(父类 BaseDataEntity 中字段)
+                "equipmentId",          // 设备主键ID
+                "time",                 // 时间
+                "globalR",              // 总辐射(W/㎡)
+                "directR",              // 直接辐射(W/㎡)
+                "diffuseR",             // 散射辐射(W/㎡)
+                "airT",                 // 环境温度(℃)
+                "p",                    // 气压(KPa)
+                "rh",                   // 湿度(%)
+                "cellT",                // 光伏电池板温度(℃)
+                "ws",                   // 风速(m/s)
+                "wd"                    // 风向(°)
+        );
+        for (String column : exportColumns) {
+            resultMap.put(column , new ArrayList());
+        }
+        resultMap.put("equipmentName" , new ArrayList());
+        resultMap.put("stationName" , new ArrayList());
+        for (WeatherStationStatusData data : dataList) {
+            String eqId = data.getEquipmentId();
+            String eqName = equipmentNameMap.getOrDefault(eqId , eqId);
+            resultMap.get("equipmentName").add(eqName);
+
+            String stationName = stationNameMap.getOrDefault(data.getStationCode() , data.getStationCode());
+            resultMap.get("stationName").add(stationName);
+
+            for (String column : exportColumns) {
+                try {
+                    Field field = getfield(WeatherStationStatusData.class , column);
+                    field.setAccessible(true);
+                    Object value = field.get(data);
+
+                    if ("time".equals(value) && value instanceof Date){
+                        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        value = simpleDateFormat.format((Date) value);
+                    }else if (value instanceof BigDecimal){
+                        BigDecimal num = (BigDecimal) value;
+                        value = num.stripTrailingZeros();
+                    }
+
+                    resultMap.get(column).add(value == null ? "":value);
+
+                }catch (Exception e){
+                    resultMap.get(column).add("");
+                }
+
+            }
+        }
+
+        return resultMap;
+    }
+
+    private Field getfield(Class<?> clazz , String fieldName) throws NoSuchFieldException {
+        try {
+            return clazz.getDeclaredField(fieldName);
+        }catch (Exception e){
+            Class superClass = clazz.getSuperclass();
+            if (superClass == null)throw e;
+            return getfield(superClass , fieldName);
+        }
+    }
+
     public List<WeatherStationStatusData> getByStationCodeAndTimeAndEndTimeAndEquipmentId(String stationCode, Date startTime, Date endTime, String equipmentId) {
         QueryWrapper<WeatherStationStatusData> wrapper = new QueryWrapper<>();
         if (stationCode != null && !stationCode.equals("")) {

+ 116 - 0
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WindTowerStatusDataServiceImpl.java

@@ -3,10 +3,14 @@ package com.jiayue.ipp.idp.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipp.common.data.entity.ElectricField;
+import com.jiayue.ipp.common.data.entity.WindTowerInfo;
 import com.jiayue.ipp.common.data.entity.WindTowerStatusData;
 import com.jiayue.ipp.common.data.entity.an.ParsingCftInfo;
 import com.jiayue.ipp.idp.mapper.WindTowerStatusDataMapper;
 import com.jiayue.ipp.idp.mapper.an.ParsingCftInfoMapper;
+import com.jiayue.ipp.idp.service.ElectricFieldService;
+import com.jiayue.ipp.idp.service.WindTowerInfoService;
 import com.jiayue.ipp.idp.service.WindTowerStatusDataService;
 import com.jiayue.ipp.idp.service.an.ParsingCftInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -32,6 +36,10 @@ public class WindTowerStatusDataServiceImpl extends ServiceImpl<WindTowerStatusD
 //    private final EquipmentAttributeService equipmentAttributeService;
     @Autowired
     ParsingCftInfoMapper parsingCftInfoMapper;
+    @Autowired
+    ElectricFieldService electricFieldService;
+    @Autowired
+    WindTowerInfoService windTowerInfoService;
 
 
     @Override
@@ -359,6 +367,113 @@ public class WindTowerStatusDataServiceImpl extends ServiceImpl<WindTowerStatusD
         return map;
     }
 
+    /**
+     * 导出指定数据
+     *
+     * @return Map<String, List>
+     */
+    public Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId) {
+        //将符合的测风塔数据按时间排序
+        List<WindTowerStatusData> dataList = getByStationCodeBetweenTimeAndEquipmentId(stationCode, startTime, endTime, equipmentId);
+        Collections.sort(dataList, Comparator.comparing(WindTowerStatusData::getTime));
+
+        Map<String, String> equipmentNameMap = new HashMap<>();
+        //去重去null
+        Set<String> eqIdSet = dataList.stream()
+                .map(WindTowerStatusData::getEquipmentId)
+                .filter(Objects::nonNull)
+                .collect(Collectors.toSet());
+        //获取全部测风塔 过滤符合的设备编号 进行编号与设备名称的映射
+        if (!eqIdSet.isEmpty()) {
+            List<WindTowerInfo> allEqList = windTowerInfoService.list();
+            List<WindTowerInfo> eqList = allEqList.stream()
+                    .filter(eq -> eqIdSet.contains(eq.getEquipmentNo()))
+                    .collect(Collectors.toList());
+
+            for (WindTowerInfo eq : eqList) {
+                equipmentNameMap.put(eq.getEquipmentNo(), eq.getName());
+            }
+        }
+        //场站编号与场站名称的映射
+        Map<String, String> stationNameMap = new HashMap<>();
+        if (stationCode != null && !stationCode.isEmpty()) {
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            if (electricField != null) {
+                stationNameMap.put(stationCode, electricField.getName());
+            }
+        }
+
+        //根据实体类填充列表字段名
+        List<String> exportColumns = Arrays.asList(
+                "stationCode", "equipmentId", "time",
+                "tInst",
+                "rhInst", "paInst",
+                "wsInst10", "wdInst10", "wsInst30",
+                "wdInst30", "wsInst50", "wdInst50",
+                "wsInst70", "wdInst70", "wsInstHubHeight", "wdInstHubHeight"
+        );
+
+        // 初始化结果Map 为每个字段赋予list 额外处理场站名称与设备名称
+        Map<String, List> resultMap = new HashMap<>();
+        for (String column : exportColumns) {
+            resultMap.put(column, new ArrayList<>());
+        }
+        resultMap.put("stationName", new ArrayList<>());
+        resultMap.put("equipmentName", new ArrayList<>());
+
+        //遍历测风塔数据 填充设备名称与场站名称 填充不到则填充id值
+        for (WindTowerStatusData data : dataList) {
+            String eqId = data.getEquipmentId();
+            String eqName = equipmentNameMap.getOrDefault(eqId, eqId);
+            resultMap.get("equipmentName").add(eqName);
+
+            String stationName = stationNameMap.getOrDefault(data.getStationCode(), data.getStationCode());
+            resultMap.get("stationName").add(stationName);
+
+            // 处理每个字段 填充结果集
+            for (String column : exportColumns) {
+                try {
+                    // 反射递归获取字段对象与字段值
+                    Field field = getField(WindTowerStatusData.class, column);
+                    field.setAccessible(true);
+                    Object value = field.get(data);
+
+                    // 处理时间格式与小数除零格式
+                    if ("time".equals(column) && value instanceof Date) {
+                        value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
+                    }
+                    else if (value instanceof BigDecimal) {
+                    BigDecimal num = (BigDecimal) value;
+                    value = num.stripTrailingZeros();
+                    }
+
+                    // 对各字段填充数据 空填充空串
+                    resultMap.get(column).add(value == null ? "" : value);
+                } catch (Exception e) {
+                    resultMap.get(column).add("");
+                }
+            }
+        }
+
+        return resultMap;
+    }
+
+    // 递归获取父类字段的工具方法 要类加载文件 和 字段名
+    private Field getField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
+        try {
+            //已找到字段名直接返回字段对象
+            return clazz.getDeclaredField(fieldName);
+        } catch (NoSuchFieldException e) {
+            //未找到从父类获取
+            Class<?> superClass = clazz.getSuperclass();
+            //父类也没有则抛异常
+            if (superClass == null) throw e;
+            return getField(superClass, fieldName);
+        }
+    }
+
+
+
 //    public List<String> getTableHead(String stationCode, List<TunnelGatherDataPoint> tunnelGatherDataPointList) {
 //        List<String> allAttributeName = new ArrayList<>();
 //        List<EquipmentAttribute> byEquipmentType = equipmentAttributeService.getByEquipmentType("WINDTOWER");
@@ -411,4 +526,5 @@ public class WindTowerStatusDataServiceImpl extends ServiceImpl<WindTowerStatusD
 //        return mapList;
 //    }
 
+
 }

+ 125 - 1
ipp-idp/src/main/java/com/jiayue/ipp/idp/service/impl/WindTurbineStatusDataServiceImpl.java

@@ -2,12 +2,25 @@ package com.jiayue.ipp.idp.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jiayue.ipp.common.data.entity.ElectricField;
+import com.jiayue.ipp.common.data.entity.WindTurbineInfo;
 import com.jiayue.ipp.common.data.entity.WindTurbineStatusData;
 import com.jiayue.ipp.idp.mapper.WindTurbineStatusDataMapper;
+import com.jiayue.ipp.idp.service.ElectricFieldService;
+import com.jiayue.ipp.idp.service.WindTurbineInfoService;
 import com.jiayue.ipp.idp.service.WindTurbineStatusDataService;
+import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
+import io.swagger.annotations.ApiOperation;
+import jdk.nashorn.internal.ir.annotations.Ignore;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
+import javax.xml.soap.SAAJResult;
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 风机数据业务层实现类
@@ -17,6 +30,12 @@ import java.util.Date;
  */
 @Service
 public class WindTurbineStatusDataServiceImpl extends ServiceImpl<WindTurbineStatusDataMapper, WindTurbineStatusData> implements WindTurbineStatusDataService {
+    @Autowired
+    private WindTurbineStatusDataMapper windTurbineStatusDataMapper;
+    @Autowired
+    private WindTurbineInfoService windTurbineInfoService;
+    @Autowired
+    private ElectricFieldService electricFieldService;
     @Override
     public QueryWrapper<WindTurbineStatusData> getByStationCodeAndEquipmentIdAndTimeBetween(String stationCode, String equipmentId, Date startTime, Date endTime) {
         QueryWrapper<WindTurbineStatusData> wrapper = new QueryWrapper<>();
@@ -32,4 +51,109 @@ public class WindTurbineStatusDataServiceImpl extends ServiceImpl<WindTurbineSta
         }
         return wrapper;
     }
+
+    @Override
+    public Map<String, List> getCompositeData(String stationCode, Date startTime, Date endTime, String equipmentId) {
+        QueryWrapper<WindTurbineStatusData> wrapper = new QueryWrapper<>();
+        wrapper = getByStationCodeAndEquipmentIdAndTimeBetween(stationCode,equipmentId,startTime,endTime);
+        List<WindTurbineStatusData> dataList = windTurbineStatusDataMapper.selectList(wrapper);
+        Collections.sort(dataList , Comparator.comparing(WindTurbineStatusData::getTime));
+
+        Set<String> eqIdset = dataList.stream()
+                .map(WindTurbineStatusData :: getEquipmentId)
+                .filter(Objects :: nonNull)
+                .collect(Collectors.toSet());
+        Map<String, String> eqMap = new HashMap<>();
+        if ( !eqIdset.isEmpty()){
+            List<WindTurbineInfo> allEqList = windTurbineInfoService.list();
+            List<WindTurbineInfo> eqList = allEqList.stream()
+                    .filter(eq -> eqIdset.contains(eq.getEquipmentNo()))
+                    .collect(Collectors.toList());
+            for (WindTurbineInfo eq : eqList) {
+                eqMap.put(eq.getEquipmentNo() , eq.getName());
+            }
+        }
+        Map<String, String> stationNameMap = new HashMap<>();
+        if (stationCode!=null && !stationCode.isEmpty()){
+            ElectricField electricField = electricFieldService.findByStationCode(stationCode);
+            if (electricField != null){
+                stationNameMap.put(stationCode , electricField.getName());
+            }
+        }
+
+        List<String> exportColumns = Arrays.asList(
+                "stationCode",          // 场站编码(父类NotLogicBaseEntity中字段)
+                "equipmentId",          // 设备主键ID(风机设备编号)
+                "time",                 // 数据时间(核心时间维度)
+                "status",               // 风机状态(1=运行,2=待机,3=停用,4=故障)
+                "activePower",          // 有功(KW)
+                "reactivePower",        // 无功(KVar)
+                "powerFactor",          // 功率因数
+                "voltage",              // 电压(V)
+                "electricalCurrent",    // 电流(A)
+                "dayElectricQuantity",  // 当日发电量(kW·h)
+                "dayGridConnectedHours",// 当日并网小时
+                "cumulativeGeneratedEnergy", // 累积发电量(MW·h)
+                "windWheelRatedSpeed",  // 转速(rpm)
+                "ws",                   // 风速(m/s)
+                "wd",                   // 风向(°)
+                "t",                    // 温度(℃)
+                "pitchAngle"            // 桨距角(°)
+        );
+
+        Map<String , List> resultMap = new HashMap<>();
+        for (String column : exportColumns) {
+            resultMap.put(column , new ArrayList());
+        }
+        resultMap.put("stationName" , new ArrayList());
+        resultMap.put("equipmentName" , new ArrayList());
+
+        for (WindTurbineStatusData data : dataList) {
+            String eqId = data.getEquipmentId();
+            String eqName = eqMap.getOrDefault(eqId , eqId);
+            resultMap.get("equipmentName").add(eqName);
+
+            String stationName = stationNameMap.getOrDefault(data.getStationCode() , data.getStationCode());
+            resultMap.get("stationName").add(stationName);
+
+            for (String column : exportColumns) {
+                try {
+                    Field field = getField(WindTurbineStatusData.class , column);
+                    field.setAccessible(true);
+                    Object value = field.get(data);
+
+                    if ("time".equals(column) && value instanceof Date){
+                        value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) value);
+                    }
+                    else if (value instanceof BigDecimal){
+                        BigDecimal num = (BigDecimal) value;
+                        value = num.stripTrailingZeros();
+                    }
+
+                    resultMap.get(column).add(value == null ? "" : value);
+
+                }catch (Exception e){
+                    resultMap.get(column).add("");
+                }
+            }
+        }
+
+        return resultMap;
+    }
+
+    // 递归获取父类字段的工具方法 要类加载文件 和 字段名
+    //已找到字段名直接返回字段对象
+    //未找到从父类获取
+    //父类也没有则抛异常
+    public Field getField(Class<?> clazz , String filedName) throws NoSuchFieldException{
+        try {
+            return clazz.getDeclaredField(filedName);
+        }catch (NoSuchFieldException e){
+            Class<?> superClass = clazz.getSuperclass();
+            if (superClass == null){
+                throw e;
+            }
+            return getField(superClass , filedName);
+        }
+    }
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů