fix:报告换行后,左侧固定列标题显示为空

This commit is contained in:
FCL
2026-02-28 14:38:59 +08:00
parent 4885f6877b
commit fc06217109

View File

@@ -173,6 +173,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
headerData = firstRow.clone();
rowList.remove(0);
}
putEmptyTitleToNotFirstRow(rowList);
resultData.put("headerData", headerData);
resultData.put("tableList", rowList);
String formData = mainData.getFormData();
@@ -306,6 +307,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
headerData = firstRow.clone();
rows.remove(0);
}
putEmptyTitleToNotFirstRow(rows);
resultData.put("headerData", headerData);
resultData.put("tableList", rows);
resultData.put("formData", formDataJson.clone());
@@ -317,6 +319,26 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
return result;
}
private void putEmptyTitleToNotFirstRow(JSONArray rows){
for(int i = 1; i < rows.size(); i++){
JSONObject t = rows.getJSONObject(i);
if(!rowTypeTitle.equals(t.getString(rowTypeKey))){
continue;
}
String fixedColKeys = t.getString("fixedColKeys");
if(ObjectUtils.isEmpty(fixedColKeys))
continue;
String[] keyV = fixedColKeys.split(",");
for(String s : keyV){
t.put(s, " ");
}
// t.put(colPrefix + "01", t.getString(colPrefix + "01"));
// t.put(colPrefix + "01", "");
}
}
private JSONArray assembleEmpty(JSONObject configJson, JSONArray rowList){
if(rowList.isEmpty())
return rowList;
@@ -440,7 +462,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
putEmptyData(emptyRow, 1,10);
rowList.add(emptyRow);
}
addTitleToRowList(fixedCol, fixedColRight, dynamicColCount, t, rowList, fieldList, i);
addTitleToRowList(fixedCol, fixedColRight, dynamicColCount, t, rowList, fieldList);
//插入样品数据
addDataToRowList(fixedCol, fixedColRight, dynamicFieldList, dataList, rowList, fixedColCount_left, dynamicColCount, hasRemark);
//检出限
@@ -455,12 +477,12 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
* @param
*
* */
private void addTitleToRowList(JSONArray fixedCol, JSONArray fixedColRight, Integer dynamicColCount, JSONObject t, JSONArray rowList, List<ConfigReportFieldDO> fieldList, Integer groupIndex){
private void addTitleToRowList(JSONArray fixedCol, JSONArray fixedColRight, Integer dynamicColCount, JSONObject t, JSONArray rowList, List<ConfigReportFieldDO> fieldList){
//处理固定列
int index = 1;
String colKey = "";
//固定列-左
String fixedColKeys = "";
for(int i=0;i<fixedCol.size();i++) {
String col = fixedCol.getString(i);
for(ConfigReportFieldDO fieldDO : fieldList) {
@@ -479,15 +501,15 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
colKey = parseNumToString(index, 2);
}
if(!ObjectUtils.isEmpty(colKey)){
if(groupIndex == 0) {
t.put(colPrefix + colKey, fieldName);
}else{
t.put(colPrefix + colKey, " ");
}
fixedColKeys += colPrefix + colKey + ",";
index++;
}
}
}
if(!ObjectUtils.isEmpty(fixedColKeys))
fixedColKeys = fixedColKeys.substring(0, fixedColKeys.length() - 1);
t.put("fixedColKeys", fixedColKeys);
//固定列-右
index = fixedCol.size() + dynamicColCount + 1;
for(int i=0;i<fixedColRight.size();i++) {