fix:报告纵表细节调整

This commit is contained in:
FCL
2025-12-09 15:46:00 +08:00
parent 920292cfac
commit 9f4369bcb2

View File

@@ -64,6 +64,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "报告配置为空,或未配置报表类型,请联系管理员处理!"); return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "报告配置为空,或未配置报表类型,请联系管理员处理!");
String customConfig = typeDO.getCustomConfig(); String customConfig = typeDO.getCustomConfig();
JSONObject configJson = JSONObject.parseObject(customConfig); JSONObject configJson = JSONObject.parseObject(customConfig);
String verticalFlag = configJson.getString("verticalFlag");
String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数 String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数
Integer maxRowCount = 3; Integer maxRowCount = 3;
if(!ObjectUtils.isEmpty(maxRowCountStr)) if(!ObjectUtils.isEmpty(maxRowCountStr))
@@ -125,15 +126,16 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
} }
assembleStep1(rowList, fieldList, dataListByKey, customConfig, i); //处理后的组数对象 assembleStep1(rowList, fieldList, dataListByKey, customConfig, i); //处理后的组数对象
} }
//处理空数据,填充/ if(!"1".equals(verticalFlag)){
rowList = assembleEmpty(configJson, rowList); //处理空数据,填充/
rowList = assembleEmpty(configJson, rowList);
//处理数据分页 //处理数据分页
if("1".equals(pageFlag)){ if("1".equals(pageFlag)){
JSONArray pageRowList = assemblePageRowList(rowList, configJson); JSONArray pageRowList = assemblePageRowList(rowList, configJson);
return CommonResult.success(pageRowList); return CommonResult.success(pageRowList);
}
} }
//以下为空白 //以下为空白
if(rowList.size() < maxRowCount){ if(rowList.size() < maxRowCount){
JSONObject t = new JSONObject(); JSONObject t = new JSONObject();
@@ -260,10 +262,10 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表 String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表
String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项则以检测项作为数据Key String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项则以检测项作为数据Key
if("1".equals(verticalFlag)){ //纵表 if("1".equals(verticalFlag)){ //纵表
return assembleVerticalData(fieldList, dataList, customConfig); return assembleVerticalData(rowList, fieldList, dataList, customConfig);
} }
if(!ObjectUtils.isEmpty(fixedFields)){ //固定列 if(!ObjectUtils.isEmpty(fixedFields)){ //固定列
return assembleFixedFieldsData(fieldList, dataList, customConfig); return assembleFixedFieldsData(rowList, fieldList, dataList, customConfig);
} }
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr); if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
fixedColCount_left = fixedCol.size(); fixedColCount_left = fixedCol.size();
@@ -517,7 +519,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
/** /**
* 组装固定检测项的数据以检测项作为数据Key * 组装固定检测项的数据以检测项作为数据Key
* */ * */
private JSONArray assembleFixedFieldsData(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){ private JSONArray assembleFixedFieldsData(JSONArray rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
JSONObject jsonObject = JSONObject.parseObject(customConfig); JSONObject jsonObject = JSONObject.parseObject(customConfig);
Integer maxRowCount = 3; Integer maxRowCount = 3;
@@ -527,8 +529,6 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项则以检测项作为数据Key String fixedFields = jsonObject.getString("fixedFields"); //固定检测项。如果固定检测项则以检测项作为数据Key
JSONArray fixedFieldsArray = JSONArray.parseArray(fixedFields); JSONArray fixedFieldsArray = JSONArray.parseArray(fixedFields);
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr); if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
JSONArray rowList = new JSONArray();
for(int i = 0; i < maxRowCount; i++){ for(int i = 0; i < maxRowCount; i++){
JSONObject row = new JSONObject(); JSONObject row = new JSONObject();
row.put("sampleNameCode", " "); row.put("sampleNameCode", " ");
@@ -589,17 +589,15 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
* 组装纵表数据 * 组装纵表数据
* 第1列固定为元素 第2列方法检出限%);第三列开始为各个样品 * 第1列固定为元素 第2列方法检出限%);第三列开始为各个样品
* */ * */
private JSONArray assembleVerticalData(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){ private JSONArray assembleVerticalData(JSONArray rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
JSONObject jsonObject = JSONObject.parseObject(customConfig); JSONObject jsonObject = JSONObject.parseObject(customConfig);
Integer dynamicColCount = 3; Integer dynamicColCount = 3;
Integer fixedColCount = 2; Integer fixedColCount = 1;
Integer maxRowCount = 3; Integer maxRowCount = 20;
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
String fixedColCountStr = jsonObject.getString("fixedColCount"); //固定列(样品名称、样品编号等)数量
String maxRowCountStr = jsonObject.getString("maxRowCount"); //最大行数
String nameCodeType = jsonObject.getString("nameCodeType"); //名称、编号处理方式merge-合并, name-只显示名称, code-只显示编号, split-2列分开显示
String hasRemark = jsonObject.getString("hasRemark"); //是否有备注 String hasRemark = jsonObject.getString("hasRemark"); //是否有备注
String hasRange = jsonObject.getString("hasRange"); //是否有检出限 String hasRange = jsonObject.getString("hasRange"); //是否有检出限
if("1".equals(hasRange))
fixedColCount ++;
//取数据第一行,用于处理方法检出限 //取数据第一行,用于处理方法检出限
String content = ""; String content = "";
if(!ObjectUtils.isEmpty(dataList)) if(!ObjectUtils.isEmpty(dataList))
@@ -608,11 +606,14 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
if(!ObjectUtils.isEmpty(content)){ if(!ObjectUtils.isEmpty(content)){
firstData = JSONObject.parseObject(content); firstData = JSONObject.parseObject(content);
} }
JSONArray rowList = new JSONArray();
//处理第一行-样品编号 //处理第一行-样品编号
int colIndex = fixedColCount + 1; int colIndex = fixedColCount + 1;
int rowIndex = 1; int rowIndex = 1;
JSONObject t = new JSONObject(); JSONObject t = new JSONObject();
t.put(colPrefix + "01", "元素");
if("1".equals(hasRange)){
t.put(colPrefix + "02", "方法检出限");
}
for(ReportDocumentDataDO dataDO : dataList){ for(ReportDocumentDataDO dataDO : dataList){
String colKey = parseNumToString(colIndex, 2); String colKey = parseNumToString(colIndex, 2);
t.put(colPrefix + colKey, dataDO.getSampleCode()); t.put(colPrefix + colKey, dataDO.getSampleCode());