Ver Fonte

[26110501] 光伏上传率统计接口: POST uploadRate/list(手动分页, total=范围天数)与uploadRate/export(全量范围EasyExcel导出, 文件名光伏上传率统计_截止日.xlsx)

taosj há 20 horas atrás
pai
commit
8667b8a317

+ 41 - 0
forecast-backend-server/src/main/java/com/ufo/project/forecast/fileupload/controller/DataReportLogController.java

@@ -2,21 +2,30 @@ package com.ufo.project.forecast.fileupload.controller;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.util.List;
+import javax.servlet.http.HttpServletResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
+import com.alibaba.excel.EasyExcel;
 import com.ufo.base.common.utils.StringUtils;
+import com.ufo.base.framework.aspectj.lang.annotation.Log;
+import com.ufo.base.framework.aspectj.lang.enums.BusinessType;
 import com.ufo.base.framework.web.controller.BaseController;
 import com.ufo.base.framework.web.domain.AjaxResult;
 import com.ufo.base.framework.web.page.TableDataInfo;
 import com.ufo.project.forecast.fileupload.domain.DataReportLog;
+import com.ufo.project.forecast.fileupload.domain.vo.UploadRateStatQuery;
+import com.ufo.project.forecast.fileupload.domain.vo.UploadRateStatVO;
 import com.ufo.project.forecast.fileupload.service.IDataReportLogService;
 
 /**
@@ -79,4 +88,36 @@ public class DataReportLogController extends BaseController
             return AjaxResult.error("读取上报文件失败: " + path);
         }
     }
+
+    /**
+     * 光伏上传率统计查询(手动分页: total=范围内天数)
+     */
+    @PreAuthorize("@ss.hasPermi('fileupload:reportLog:uploadRate')")
+    @Log(title = "光伏上传率统计", businessType = BusinessType.OTHER)
+    @PostMapping("/uploadRate/list")
+    public TableDataInfo uploadRateList(@RequestBody UploadRateStatQuery query)
+    {
+        long total = dataReportLogService.uploadRateTotalDays(query);
+        List<UploadRateStatVO> rows = dataReportLogService.uploadRatePageList(query);
+        return new TableDataInfo(rows, (int) total);
+    }
+
+    /**
+     * 光伏上传率统计导出(全量日期范围)
+     */
+    @PreAuthorize("@ss.hasPermi('fileupload:reportLog:uploadRateExport')")
+    @Log(title = "光伏上传率统计", businessType = BusinessType.EXPORT)
+    @PostMapping("/uploadRate/export")
+    public void uploadRateExport(@RequestBody UploadRateStatQuery query, HttpServletResponse response) throws IOException
+    {
+        List<UploadRateStatVO> data = dataReportLogService.uploadRateExportList(query);
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        String fileName = URLEncoder.encode("光伏上传率统计_" + query.getEndTime().replace("-", "") + ".xlsx",
+                "UTF-8").replaceAll("\\+", "%20");
+        response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName);
+        EasyExcel.write(response.getOutputStream(), UploadRateStatVO.class)
+                .sheet("光伏上传率统计")
+                .doWrite(data);
+    }
 }