fix: reports

This commit is contained in:
RB 2024-03-05 15:07:20 +08:00
parent 5e1dc802eb
commit 184f653fce
6 changed files with 22 additions and 13 deletions

2
@rbv

@ -1 +1 @@
Subproject commit b268f9ed1e9a891ded25bbeca4130153b1764782
Subproject commit f07527b06b21bee5e2bf6b927b733903178c1954

View file

@ -217,6 +217,7 @@ public class DataReportManager implements ConfigManager {
else if (fileName.endsWith(".doc")) name += ".doc";
else if (fileName.endsWith(".xlsx")) name += ".xlsx";
else if (fileName.endsWith(".xls")) name += ".xls";
else if (fileName.endsWith(".csv")) name += ".csv";
break;
}
}

View file

@ -81,7 +81,8 @@ import static com.rebuild.core.service.datareport.TemplateExtractor33.NROW_PREFI
@Slf4j
public class EasyExcelGenerator extends SetUser {
final protected static String MDATA_KEY = ".";
final protected static String DKEY_RECORD_MAIN = ".";
final protected static String DKEY_LIST = DKEY_RECORD_MAIN + "36LIST";
protected File templateFile;
protected Integer writeSheetAt = null;
@ -110,10 +111,11 @@ public class EasyExcelGenerator extends SetUser {
Map<String, List<Map<String, Object>>> datas = buildData();
if (datas.isEmpty()) throw new DefinedException(Language.L("暂无数据"));
// 记录模板-主记录
Map<String, Object> main = null;
if (datas.containsKey(MDATA_KEY)) {
main = datas.get(MDATA_KEY).get(0);
datas.remove(MDATA_KEY);
if (datas.containsKey(DKEY_RECORD_MAIN)) {
main = datas.get(DKEY_RECORD_MAIN).get(0);
datas.remove(DKEY_RECORD_MAIN);
}
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
@ -124,10 +126,10 @@ public class EasyExcelGenerator extends SetUser {
.registerWriteHandler(new FormulaCellWriteHandler())
.build();
// 一个列表
// 一个列表/列表模板
if (datas.size() == 1) {
Object o = datas.values().iterator().next();
excelWriter.fill(o, fillConfig, writeSheet);
Object datas35 = datas.values().iterator().next();
excelWriter.fill(datas35, fillConfig, writeSheet);
}
// fix: v3.6 多个列表
else if (datas.size() > 1) {
@ -253,7 +255,7 @@ public class EasyExcelGenerator extends SetUser {
Assert.notNull(record, "No record found : " + recordId);
Map<String, Object> d = buildData(record, varsMapOfMain);
datas.put(MDATA_KEY, Collections.singletonList(d));
datas.put(DKEY_RECORD_MAIN, Collections.singletonList(d));
}
// 明细
@ -274,7 +276,7 @@ public class EasyExcelGenerator extends SetUser {
detailList.add(buildData(c, varsMapOfDetail));
phNumber++;
}
datas.put(MDATA_KEY + "detail", detailList);
datas.put(DKEY_RECORD_MAIN + "detail", detailList);
}
// 审批
@ -293,7 +295,7 @@ public class EasyExcelGenerator extends SetUser {
approvalList.add(buildData(c, varsMapOfApproval));
phNumber++;
}
datas.put(MDATA_KEY + "approval", approvalList);
datas.put(DKEY_RECORD_MAIN + "approval", approvalList);
}
return datas;

View file

@ -155,7 +155,7 @@ public class EasyExcelGenerator33 extends EasyExcelGenerator {
Assert.notNull(record, "No record found : " + recordId);
Map<String, Object> d = buildData(record, varsMapOfMain);
datas.put(MDATA_KEY, Collections.singletonList(d));
datas.put(DKEY_RECORD_MAIN, Collections.singletonList(d));
mdataHolder = d;
}

View file

@ -97,7 +97,7 @@ public class EasyExcelListGenerator extends EasyExcelGenerator {
if (varsMap.containsKey(PH__CURRENTDATETIME)) phValues.put(PH__CURRENTDATETIME, getPhValue(PH__CURRENTDATETIME));
Map<String, List<Map<String, Object>>> datasMap = new HashMap<>();
datasMap.put(MDATA_KEY, datas);
datasMap.put(DKEY_LIST, datas);
return datasMap;
}

View file

@ -11,15 +11,21 @@
.mdi-monitor::before {
margin-left: -1px;
}
.badge.badge-info {
color: #555;
}
.badge.badge-info.excel {
background-color: #0f9d58;
background-color: #caead8;
}
.badge.badge-info.word {
background-color: #307cf1;
background-color: #d2e0f4;
}
.badge.badge-info.html5 {
background-color: #f16529;
background-color: #e44d26;
background-color: #f6dbd4;
}
</style>
</head>