1.报告微调

This commit is contained in:
2026-01-12 16:49:42 +08:00
parent a7c69f7c43
commit 27bac7288c
4 changed files with 31 additions and 13 deletions

View File

@@ -49,7 +49,7 @@ public class AreaHarmonicReportController extends BaseController {
*/ */
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/areaHarmonicReport") @PostMapping("/areaHarmonicReport")
@ApiOperation("区域稳态报告") @ApiOperation("导出区域稳态报告")
public void areaHarmonicReport(@RequestBody AreaHarmReportParam areaHarmReportParam, HttpServletResponse response) { public void areaHarmonicReport(@RequestBody AreaHarmReportParam areaHarmReportParam, HttpServletResponse response) {
TimeInterval timeInterval = new TimeInterval(); TimeInterval timeInterval = new TimeInterval();
String methodDescribe = getMethodDescribe("areaHarmonicReport"); String methodDescribe = getMethodDescribe("areaHarmonicReport");

View File

@@ -184,7 +184,6 @@ public class ExportModelController extends BaseController {
param.setStartTime(DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss")); param.setStartTime(DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss"));
LocalDateTime parse = LocalDateTimeUtil.parse(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"), DatePattern.NORM_DATETIME_PATTERN); LocalDateTime parse = LocalDateTimeUtil.parse(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"), DatePattern.NORM_DATETIME_PATTERN);
if(LocalDateTime.now().isBefore(parse)){ if(LocalDateTime.now().isBefore(parse)){
param.setEndTime(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); param.setEndTime(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN));
endDate = DateUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); endDate = DateUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN));

View File

@@ -49,7 +49,7 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
// 常量定义 // 常量定义
private static final String REPORT_TEMPLATE_PATH = "file/areaReportTemplate.docx"; private static final String REPORT_TEMPLATE_PATH = "file/areaReportTemplate.docx";
private static final String DEFAULT_PROVIDER_DEPT = "中国电力技术研究院"; private static final String DEFAULT_PROVIDER_DEPT = "云网能源(曲靖)有限责任公司";
private static final String NO_DATA_PLACEHOLDER = ""; private static final String NO_DATA_PLACEHOLDER = "";
private static final String UNKNOWN_VALUE = "/"; private static final String UNKNOWN_VALUE = "/";
@@ -90,6 +90,8 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
// 3. 生成Word报告 // 3. 生成Word报告
generateWordReport(reportData, tableList, response); generateWordReport(reportData, tableList, response);
} catch (BusinessException e){
throw e;
}catch (Exception e) { }catch (Exception e) {
log.error("区域谐波报告生成失败,参数: {}", areaHarmReportParam, e); log.error("区域谐波报告生成失败,参数: {}", areaHarmReportParam, e);
throw new BusinessException(CommonResponseEnum.FAIL,"报告生成失败"); throw new BusinessException(CommonResponseEnum.FAIL,"报告生成失败");
@@ -106,10 +108,12 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
Dept dept = getDeptInfo(param.getDeptId()); Dept dept = getDeptInfo(param.getDeptId());
reportData.put("$deptName$", dept.getName()); reportData.put("$deptName$", dept.getName());
reportData.put("$provideDept$", DEFAULT_PROVIDER_DEPT); reportData.put("$provideDept$", DEFAULT_PROVIDER_DEPT);
reportData.put("$TitleTime$", DateUtil.format(new DateTime(), DatePattern.CHINESE_DATE_PATTERN));
DateTime now = DateTime.now();
reportData.put("$TitleTime$", DateUtil.format(now, DatePattern.CHINESE_DATE_PATTERN));
// 时间范围 // 时间范围
String timeRange = formatTimeRange(param.getStartTime(), param.getEndTime()); String timeRange = formatTimeRange(param.getStartTime(), param.getEndTime(),now);
reportData.put("$reportRangeTime$", timeRange); reportData.put("$reportRangeTime$", timeRange);
return reportData; return reportData;
@@ -126,6 +130,9 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
// 1. 台账表格 // 1. 台账表格
List<String[]> ledgerTable = buildLedgerTable(param.getDeptId()); List<String[]> ledgerTable = buildLedgerTable(param.getDeptId());
if(CollUtil.isEmpty(ledgerTable)){
throw new BusinessException(CommonResponseEnum.FAIL,"当前部门不存在在运监测点");
}
tableList.add(ledgerTable); tableList.add(ledgerTable);
// 添加空行(保持原有结构) // 添加空行(保持原有结构)
@@ -152,6 +159,8 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
// 计算并设置指标数据到临时存储,稍后合并 // 计算并设置指标数据到临时存储,稍后合并
calculateAndStoreIndicatorData(reportData, validData, monitorNameMap); calculateAndStoreIndicatorData(reportData, validData, monitorNameMap);
}else {
throw new BusinessException(CommonResponseEnum.FAIL,"时间范围内数据为空");
} }
} }
@@ -691,16 +700,26 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
/** /**
* 工具方法:格式化时间范围 * 工具方法:格式化时间范围
*/ */
private String formatTimeRange(String startTime, String endTime) { private String formatTimeRange(String startTime, String endTime,DateTime now) {
try { try {
String start = DateUtil.format( String start = DateUtil.format(
DateUtil.beginOfDay(DateUtil.parse(startTime)), DateUtil.beginOfDay(DateUtil.parse(startTime)),
DatePattern.NORM_DATETIME_PATTERN DatePattern.CHINESE_DATE_TIME_PATTERN
);
String end = DateUtil.format(
DateUtil.endOfDay(DateUtil.parse(endTime)),
DatePattern.NORM_DATETIME_PATTERN
); );
DateTime dateTime = DateUtil.endOfDay(DateUtil.parse(endTime));
String end;
if(now.isBefore(dateTime)){
end = DateUtil.format(
now,
DatePattern.CHINESE_DATE_TIME_PATTERN);
}else {
end = DateUtil.format(
dateTime,
DatePattern.CHINESE_DATE_TIME_PATTERN);
}
return start + "-" + end; return start + "-" + end;
} catch (Exception e) { } catch (Exception e) {
log.error("格式化时间范围失败", e); log.error("格式化时间范围失败", e);