Commit 87082d62 by HKyoma

fix(report): 优化导出报表文件路径和日志打印

- 添加 Environment 注入用于读取配置属性
- 修改导出文件名变量,提升代码可读性
- 调整导出方法调用,不再重复生成文件名字符串
- 使用配置属性生成完整文件路径并记录日志
- 保留注释中各环境回调地址示例,便于环境识别和调试
1 parent 851a620c
...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer; import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
import org.springframework.core.task.TaskExecutor; import org.springframework.core.task.TaskExecutor;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
...@@ -46,6 +47,9 @@ public class DownloadReportController { ...@@ -46,6 +47,9 @@ public class DownloadReportController {
@Autowired @Autowired
private TaskExecutor taskExecutor; private TaskExecutor taskExecutor;
@Autowired
private Environment env;
@ApiOperation("下载报表") @ApiOperation("下载报表")
@ServiceMethod(method = "dj.riskmanage.api.report.excel.download", needInSession = NeedInSessionType.NO) @ServiceMethod(method = "dj.riskmanage.api.report.excel.download", needInSession = NeedInSessionType.NO)
// @PostMapping("/dj.riskmanage.api.report.excel.download/1.0.0") // @PostMapping("/dj.riskmanage.api.report.excel.download/1.0.0")
...@@ -56,12 +60,15 @@ public class DownloadReportController { ...@@ -56,12 +60,15 @@ public class DownloadReportController {
HashMap<String, String> dateMap = new HashMap<>(); HashMap<String, String> dateMap = new HashMap<>();
dateMap.put("titleDateStr", excels.getTitleDateStr()); dateMap.put("titleDateStr", excels.getTitleDateStr());
dateMap.put("dataRangeDateStr", excels.getDataRangeDateStr()); dateMap.put("dataRangeDateStr", excels.getDataRangeDateStr());
String url = EasyExcelUtil.exportExcelMuliLevel(excels.getDataList(), String fileName = "【鸿蒙】延保驻店能力定级测评表(" + excels.getDataRangeDateStr() + ")";
"【鸿蒙】延保驻店能力定级测评表(" + excels.getDataRangeDateStr() + ")", EasyExcelUtil.exportExcelMuliLevel(excels.getDataList(),
fileName,
dateMap, "", dateMap, "",
Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/excel/export/【鸿蒙】延保驻店能力定级测评表模板.xlsx"), Thread.currentThread().getContextClassLoader().getResourceAsStream("templates/excel/export/【鸿蒙】延保驻店能力定级测评表模板.xlsx"),
3); 3);
// 发送文件到大数据端 // 发送文件到大数据端
String url = env.getProperty("gop.excel.tem.path") + File.separator + fileName + ".xlsx";
log.info("发送文件到大数据端:{}", url);
this.syncSendMerchantDailyReportFile(url); this.syncSendMerchantDailyReportFile(url);
return RopResponse.success(url); return RopResponse.success(url);
} }
...@@ -73,11 +80,12 @@ public class DownloadReportController { ...@@ -73,11 +80,12 @@ public class DownloadReportController {
taskExecutor.execute(() -> { taskExecutor.execute(() -> {
try { try {
String url = OrePropertyConfigurer.getProperty("report.file.sync.url", String.class, "https://dj.glsx.com.cn/reportExport/importExcel"); String url = OrePropertyConfigurer.getProperty("report.file.sync.url", String.class, "https://dj.glsx.com.cn/reportExport/importExcel");
// String url = OrePropertyConfigurer.getProperty("report.file.sync.url", String.class, "http://192.168.1.206:8087/reportExport/importExcel");
// #报表回调-测试 // #报表回调-测试
// https://frontend.test.glsx.com.cn/reportExport/importExcel // https://frontend.test.glsx.com.cn/reportExport/importExcel
// #报表回调-预发布 // #报表回调-预发布
// https://dj.beta.glsx.com.cn/reportExport/importExcel // https://dj.beta.glsx.com.cn/reportExport/importExcel
//#报表回调-生产 // #报表回调-生产
// https://dj.glsx.com.cn/reportExport/importExcel // https://dj.glsx.com.cn/reportExport/importExcel
// #报表回调-本地 // #报表回调-本地
// http://192.168.1.206:8087/reportExport/importExcel // http://192.168.1.206:8087/reportExport/importExcel
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!