修改自定义报表处理没有模板情况,使用默认模板

This commit is contained in:
cdf
2026-05-18 16:13:28 +08:00
parent e6332f1c51
commit e5ffa2ec29
2 changed files with 13 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@@ -579,10 +579,18 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig())); jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList); parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
} catch (Exception e) { } catch (Exception e) {
if (e instanceof BusinessException) { // 自定义报表防止没有默认模板从resource目录加载默认模板
throw new BusinessException(e.getMessage()); String defaultTemplatePath = "file/default_excel_report.json";
} else { InputStream defaultStream = getClass().getClassLoader().getResourceAsStream(defaultTemplatePath);
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON); if (defaultStream == null) {
if (e instanceof BusinessException) {
throw new BusinessException(e.getMessage());
} else {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
}else {
jsonArray = new JSONArray(new JSONTokener(defaultStream, new JSONConfig()));
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
} }
} }
//查询不分相别的指标 //查询不分相别的指标