fix:报告数据组装

This commit is contained in:
FCL
2025-12-25 14:20:13 +08:00
parent b8bf7a3d9d
commit f9f87648af

View File

@@ -96,7 +96,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
if(!dataListByKey.isEmpty())
dataListGroup.add(dataListByKey);
}
if(dataListGroup.isEmpty())
if(dataListGroup.isEmpty() && !dataList.isEmpty())
dataListGroup.add(dataList);
JSONArray rowList = new JSONArray();
for(int i = 0; i < dataListGroup.size(); i++){
@@ -141,7 +141,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
}
}
//以下为空白
if(rowList.size() < maxRowCount){
if(rowList.size() < maxRowCount && !rowList.isEmpty()){
JSONObject t = new JSONObject();
t.put(colPrefix + "01", emptyText);
putEmptyData(t, 2,10);
@@ -199,7 +199,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
int rowLength = rowList.size();
if(rowLength <= maxRowCount){
pageRowList.add(rowList);
return pageRowList;
return assemblePageResult(mainData, pageRowList, maxRowCount);
}
JSONArray remainingRows = new JSONArray();
remainingRows.addAll(rowList);
@@ -244,18 +244,20 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
if(pageRow.size() < maxRowCount){
JSONObject t = new JSONObject();
t.put(colPrefix + "01", emptyText);
putEmptyData(t, 2,10);
pageRow.add(t.clone());
}
/*
return assemblePageResult(mainData, pageRowList, maxRowCount);
}
/*
* 修改数据结构
[
{
[{
"headerData": {},
"tableList": [{},]
},
]
},]
* */
private JSONArray assemblePageResult(ReportDocumentMainDO mainData, JSONArray pageRowList, Integer maxRowCount){
JSONArray result = new JSONArray();
String formData = mainData.getFormData();
String signatureData = mainData.getDocumentSignature();
@@ -266,6 +268,13 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
formDataJson = JSONObject.parseObject(formData);
if(!ObjectUtils.isEmpty(signatureJsonStr))
hasSignatureData = true;
//在最后一页填充空行
JSONArray pageRow = pageRowList.getJSONArray(pageRowList.size() - 1);
while(pageRow.size() < maxRowCount){
JSONObject t = new JSONObject();
putEmptyData(t, 1,10);
pageRow.add(t.clone());
}
for(int i=0;i<pageRowList.size();i++){
JSONArray rows = pageRowList.getJSONArray(i);
JSONObject resultData = new JSONObject();
@@ -287,6 +296,8 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
}
private JSONArray assembleEmpty(JSONObject configJson, JSONArray rowList){
if(rowList.isEmpty())
return rowList;
JSONArray fixedCol = configJson.getJSONArray("fixedCol"); //固定列,举例:["SMP_NAME", "SMP_CD"]
if(fixedCol == null) fixedCol = new JSONArray();
JSONArray fixedColRight = configJson.getJSONArray("fixedColRight"); //右侧固定列