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