feat:报告数据算法逻辑调整
This commit is contained in:
@@ -109,4 +109,8 @@ public class BusinessAssayReportDataDO extends BusinessBaseDO {
|
|||||||
//样品创建时间
|
//样品创建时间
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private LocalDateTime baseSampleCreateTime;
|
private LocalDateTime baseSampleCreateTime;
|
||||||
|
|
||||||
|
//样品类型key
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String sampleTypeKey;
|
||||||
}
|
}
|
||||||
@@ -43,4 +43,7 @@ public class ReportDocumentDataPageReqVO extends PageParam {
|
|||||||
|
|
||||||
@Schema(description = "样品大类名称")
|
@Schema(description = "样品大类名称")
|
||||||
private String baseSampleName;
|
private String baseSampleName;
|
||||||
|
|
||||||
|
@Schema(description = "样品类型key")
|
||||||
|
private String sampleTypeKey;
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,10 @@ public class ReportDocumentDataRespVO {
|
|||||||
@ExcelProperty("样品大类名称")
|
@ExcelProperty("样品大类名称")
|
||||||
private String baseSampleName;
|
private String baseSampleName;
|
||||||
|
|
||||||
|
@Schema(description = "样品类型key")
|
||||||
|
@ExcelProperty("样品类型key")
|
||||||
|
private String sampleTypeKey;
|
||||||
|
|
||||||
//==================扩展字段===========
|
//==================扩展字段===========
|
||||||
|
|
||||||
@Schema(description = "样品创建时间")
|
@Schema(description = "样品创建时间")
|
||||||
|
|||||||
@@ -40,4 +40,7 @@ public class ReportDocumentDataSaveReqVO {
|
|||||||
@Schema(description = "样品大类名称")
|
@Schema(description = "样品大类名称")
|
||||||
private String baseSampleName;
|
private String baseSampleName;
|
||||||
|
|
||||||
|
@Schema(description = "样品类型key")
|
||||||
|
private String sampleTypeKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,9 @@ public class ReportDocumentDataDO extends BusinessBaseDO {
|
|||||||
@TableField("BSE_SMP_NAME")
|
@TableField("BSE_SMP_NAME")
|
||||||
private String baseSampleName;
|
private String baseSampleName;
|
||||||
|
|
||||||
|
//样品类型key
|
||||||
|
@TableField("SMP_TP_KY")
|
||||||
|
private String sampleTypeKey;
|
||||||
|
|
||||||
//==================扩展字段===========
|
//==================扩展字段===========
|
||||||
|
|
||||||
|
|||||||
@@ -67,38 +67,66 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
|||||||
if(fieldListAll.isEmpty())
|
if(fieldListAll.isEmpty())
|
||||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "未配置报表字段,请联系管理员处理!");
|
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "未配置报表字段,请联系管理员处理!");
|
||||||
List<ReportDocumentDataDO> dataList = listByMainDataId(mainData.getId()).getData();
|
List<ReportDocumentDataDO> dataList = listByMainDataId(mainData.getId()).getData();
|
||||||
//处理字段,提取有数据的字段
|
|
||||||
List<ConfigReportFieldDO> fieldList = new ArrayList<>();
|
//拆分dataList,按样品分类key拆分
|
||||||
List<String> hasFields = new ArrayList<>();
|
List<List<ReportDocumentDataDO>> dataListGroup = new ArrayList<>();
|
||||||
for(ConfigReportFieldDO fieldDO : fieldListAll){
|
String[] sampleTypeKeys = new String[]{"inspectionAnalysisSample", "comprehensiveInspectionSample"}; //商检分析样、商检综合样
|
||||||
String field = fieldDO.getField();
|
for(String sampleTypeKey : sampleTypeKeys){
|
||||||
String fieldName = fieldDO.getFieldName();
|
List<ReportDocumentDataDO> dataListByKey = new ArrayList<>();
|
||||||
String fieldType = fieldDO.getFieldType();
|
for(ReportDocumentDataDO dataDO: dataList){
|
||||||
//先处理固定列
|
if(sampleTypeKey.equals(dataDO.getSampleTypeKey())){
|
||||||
if(FIELD_FIXED.equals(fieldType)){
|
dataListByKey.add(dataDO);
|
||||||
if(!hasFields.contains( field)){
|
|
||||||
fieldList.add(fieldDO);
|
|
||||||
hasFields.add(field);
|
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
for(ReportDocumentDataDO dataDO : dataList){
|
dataListGroup.add(dataListByKey);
|
||||||
String documentContent = dataDO.getDocumentContent();
|
}
|
||||||
JSONObject dataJson = JSONObject.parseObject(documentContent);
|
if(dataListGroup.isEmpty())
|
||||||
if(dataJson == null)
|
dataListGroup.add(dataList);
|
||||||
continue;
|
List<JSONObject> rowList = new ArrayList<>();
|
||||||
if(dataJson.containsKey(field)){
|
for(int i = 0; i < dataListGroup.size(); i++){
|
||||||
if(!hasFields.contains( fieldName)){
|
List<ReportDocumentDataDO> dataListByKey = dataListGroup.get(i);
|
||||||
|
//处理字段,提取有数据的字段
|
||||||
|
List<ConfigReportFieldDO> fieldList = new ArrayList<>();
|
||||||
|
List<String> hasFields = new ArrayList<>();
|
||||||
|
for(ConfigReportFieldDO fieldDO : fieldListAll){
|
||||||
|
String field = fieldDO.getField();
|
||||||
|
String fieldName = fieldDO.getFieldName();
|
||||||
|
String fieldType = fieldDO.getFieldType();
|
||||||
|
//先处理固定列
|
||||||
|
if(FIELD_FIXED.equals(fieldType)){
|
||||||
|
if(!hasFields.contains( field)){
|
||||||
fieldList.add(fieldDO);
|
fieldList.add(fieldDO);
|
||||||
hasFields.add(fieldName);
|
hasFields.add(field);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(ReportDocumentDataDO dataDO : dataListByKey){
|
||||||
|
String documentContent = dataDO.getDocumentContent();
|
||||||
|
JSONObject dataJson = JSONObject.parseObject(documentContent);
|
||||||
|
if(dataJson == null)
|
||||||
|
continue;
|
||||||
|
if(dataJson.containsKey(field)){
|
||||||
|
if(!hasFields.contains( fieldName)){
|
||||||
|
fieldList.add(fieldDO);
|
||||||
|
hasFields.add(fieldName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assembleStep1(rowList, fieldList, dataListByKey, customConfig, i); //处理后的组数对象
|
||||||
}
|
}
|
||||||
|
|
||||||
//组装数据
|
//todo 处理数据分页
|
||||||
List<JSONObject> step1Arr = assembleStep1(fieldList, dataList, customConfig); //处理后的组数对象
|
|
||||||
return CommonResult.success(step1Arr);
|
//todo 以下为空白
|
||||||
|
// JSONObject t = new JSONObject();
|
||||||
|
// t.put(colPrefix + "01", emptyText);
|
||||||
|
// rowList.add(t.clone());
|
||||||
|
|
||||||
|
//todo 检出限
|
||||||
|
|
||||||
|
|
||||||
|
return CommonResult.success(rowList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -106,7 +134,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
|||||||
* @param fieldList 要显示的字段列表。固定字段在最前
|
* @param fieldList 要显示的字段列表。固定字段在最前
|
||||||
* @param customConfig 报告配置项
|
* @param customConfig 报告配置项
|
||||||
* */
|
* */
|
||||||
private List<JSONObject> assembleStep1(List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig){
|
private List<JSONObject> assembleStep1(List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, String customConfig, int groupIndex){
|
||||||
if(dataList.isEmpty())
|
if(dataList.isEmpty())
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
||||||
@@ -114,11 +142,8 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
|||||||
Integer fixedColCount = 0;
|
Integer fixedColCount = 0;
|
||||||
Integer maxRowCount = 3;
|
Integer maxRowCount = 3;
|
||||||
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
|
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
|
||||||
// String fixedColCountStr = jsonObject.getString("fixedColCount"); //固定列(样品名称、样品编号等)数量
|
|
||||||
JSONArray fixedCol = jsonObject.getJSONArray("fixedCol"); //固定列,举例:["sampleName", "sampleCode"]
|
JSONArray fixedCol = jsonObject.getJSONArray("fixedCol"); //固定列,举例:["sampleName", "sampleCode"]
|
||||||
JSONArray fixedColShow = jsonObject.getJSONArray("fixedColShow"); //固定列,举例:["产品名称", "编 号"]
|
|
||||||
String maxRowCountStr = jsonObject.getString("maxRowCount"); //最大行数
|
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"); //是否有检出限
|
||||||
String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表
|
String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表
|
||||||
@@ -133,102 +158,146 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
|||||||
if(fixedCol != null) fixedColCount = fixedCol.size();
|
if(fixedCol != null) fixedColCount = fixedCol.size();
|
||||||
|
|
||||||
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
if(!ObjectUtils.isEmpty(maxRowCountStr)) maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||||
Integer eleCount = 0; //元素数量,即元素列总数
|
|
||||||
|
|
||||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
|
||||||
String fieldType = fieldDO.getFieldType();
|
|
||||||
if(FIELD_DYNAMIC.equals(fieldType))
|
|
||||||
eleCount ++;
|
|
||||||
}
|
|
||||||
Integer rowCountOneSample = eleCount / dynamicColCount + (eleCount % dynamicColCount == 0 ? 0 : 1); //每个样品要占的行数
|
|
||||||
Integer colCountOneSample = fixedColCount + dynamicColCount; //每个样品要占的列数
|
Integer colCountOneSample = fixedColCount + dynamicColCount; //每个样品要占的列数
|
||||||
Integer dataLength = dataList.size();
|
Integer dataLength = dataList.size();
|
||||||
Integer emptyRowCount = dataLength < maxRowCount ? 1 : 0; //空行数
|
|
||||||
// Integer allRowCount = 1 + dataLength + emptyRowCount + 1; //标题 + 样品数 + 空行
|
|
||||||
|
|
||||||
if("1".equals(hasRange))
|
|
||||||
emptyRowCount ++;
|
|
||||||
|
|
||||||
// if(rowCountOneSample > 1){
|
|
||||||
// allRowCount = (1 + dataLength + emptyRowCount + 9) * rowCountOneSample + emptyRowCount; //(标题 + 样品数 + 空行) * 但样品行数 + 末尾行
|
|
||||||
// }
|
|
||||||
List<JSONObject> rowList = new ArrayList<>();
|
|
||||||
for(int i = 0; i < maxRowCount; i++){
|
|
||||||
JSONObject row = new JSONObject();
|
|
||||||
row.put("col01", " ");
|
|
||||||
rowList.add( row);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//=============处理表头============
|
//=============处理表头============
|
||||||
JSONObject t = new JSONObject();
|
JSONObject t = new JSONObject();
|
||||||
JSONObject r = new JSONObject(); //检出限
|
JSONObject r = new JSONObject(); //检出限
|
||||||
int rowAssist = 1;
|
|
||||||
int colIndex = fixedColCount + 1;
|
|
||||||
boolean lastObjFlag = true;
|
|
||||||
//取第一行数据,用来处理检出限
|
//取第一行数据,用来处理检出限
|
||||||
JSONObject firstData = new JSONObject(); //取第一行数据,用于处理检出限
|
JSONObject firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent()); //取第一行数据,用于处理检出限
|
||||||
if(dataLength > 0)
|
|
||||||
firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent());
|
|
||||||
if("1".equals(hasRemark)){
|
if("1".equals(hasRemark)){
|
||||||
//在最后一列增加备注
|
//在最后一列增加备注
|
||||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||||
}
|
}
|
||||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
//取fieldList的动态字段,并分组
|
||||||
|
List<List<ConfigReportFieldDO>> dynamicFieldListGroup = new ArrayList<>();
|
||||||
|
int fieldIndex = 1;
|
||||||
|
List<ConfigReportFieldDO> list = new ArrayList<>();
|
||||||
|
for(int i = 0; i < fieldList.size(); i++){
|
||||||
|
ConfigReportFieldDO fieldDO = fieldList.get(i);
|
||||||
String fieldType = fieldDO.getFieldType();
|
String fieldType = fieldDO.getFieldType();
|
||||||
String field = fieldDO.getField();
|
if(FIELD_FIXED.equals(fieldType))
|
||||||
if(FIELD_FIXED.equals(fieldType)){ //这里只处理动态列。固定列在 addTitleToRowList 处理
|
|
||||||
continue;
|
continue;
|
||||||
|
list.add(fieldDO);
|
||||||
|
if(fieldIndex % dynamicColCount == 0){
|
||||||
|
dynamicFieldListGroup.add(list);
|
||||||
|
list = new ArrayList<>();
|
||||||
}
|
}
|
||||||
String fieldName = fieldDO.getFieldName();
|
fieldIndex ++;
|
||||||
String colKey = parseNumToString(colIndex, 2);
|
}
|
||||||
t.put(colPrefix + colKey, fieldName);
|
int colIndex = 1;
|
||||||
//查询当前字段的检出限
|
for(int i = 0; i < dynamicFieldListGroup.size(); i++){
|
||||||
JSONObject fieldObj = firstData.getJSONObject( field);
|
List<ConfigReportFieldDO> dynamicFieldList = dynamicFieldListGroup.get(i);
|
||||||
String rangeVal = "";
|
t = new JSONObject();
|
||||||
if(fieldObj != null){
|
r = new JSONObject();
|
||||||
rangeVal = fieldObj.getString(rangeKey);
|
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
||||||
}
|
for(ConfigReportFieldDO fieldDO : dynamicFieldList) {
|
||||||
r.put(colPrefix + colKey, rangeVal);
|
String field = fieldDO.getField();
|
||||||
r.put(colPrefix + "01", "方法检出限");
|
String fieldName = fieldDO.getFieldName();
|
||||||
lastObjFlag = true;
|
String colKey = parseNumToString(colIndex, 2);
|
||||||
if(colIndex % colCountOneSample == 0){
|
t.put(colPrefix + colKey, fieldName);
|
||||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
//查询当前字段的检出限
|
||||||
if("1".equals(hasRange))
|
JSONObject fieldObj = firstData.getJSONObject(field);
|
||||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
String rangeVal = "";
|
||||||
t = new JSONObject();
|
if (fieldObj != null) {
|
||||||
r = new JSONObject();
|
rangeVal = fieldObj.getString(rangeKey);
|
||||||
|
|
||||||
if("1".equals(hasRemark)){
|
|
||||||
//在最后一列增加备注
|
|
||||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
|
||||||
}
|
}
|
||||||
rowAssist++;
|
r.put(colPrefix + colKey, rangeVal);
|
||||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
r.put(colPrefix + "01", "方法检出限");
|
||||||
lastObjFlag = false;
|
colIndex ++;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
colIndex++;
|
//处理备注列
|
||||||
|
if(i == 0 && groupIndex == 0 && "1".equals(hasRemark)){
|
||||||
|
//在最后一列增加备注
|
||||||
|
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||||
|
}
|
||||||
|
if(i > 0 || groupIndex > 0){ //插入空行
|
||||||
|
JSONObject emptyRow = new JSONObject();
|
||||||
|
emptyRow.put(colPrefix + "01", " ");
|
||||||
|
rowList.add(emptyRow);
|
||||||
|
}
|
||||||
|
addTitleToRowList(fixedCol, t, rowList, fieldList);
|
||||||
|
//插入样品数据
|
||||||
|
addDataToRowList(fixedCol, dynamicFieldList, dataList, rowList, fixedColCount, colCountOneSample, hasRemark);
|
||||||
}
|
}
|
||||||
if(lastObjFlag){
|
//todo 方法检出限
|
||||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
if("1".equals(hasRange)){
|
||||||
if("1".equals(hasRange))
|
rowList.add(r);
|
||||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
}
|
||||||
|
return rowList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param
|
||||||
|
*
|
||||||
|
* */
|
||||||
|
private void addTitleToRowList(JSONArray fixedCol, JSONObject t, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||||
|
// int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + 1; //(标题 + 数据行 + 空行)
|
||||||
|
//处理固定列
|
||||||
|
//todo 来样名称、来样编号、来样名称编号
|
||||||
|
int index = 1;
|
||||||
|
String colKey = "";
|
||||||
|
for(int i=0;i<fixedCol.size();i++) {
|
||||||
|
String col = fixedCol.getString(i);
|
||||||
|
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||||
|
String fieldName = fieldDO.getFieldName();
|
||||||
|
String fieldType = fieldDO.getFieldType();
|
||||||
|
String field = fieldDO.getField();
|
||||||
|
if (FIELD_DYNAMIC.equals(fieldType))
|
||||||
|
continue;
|
||||||
|
if("sampleNameCode".equals( col) && "SMP_NAME_CD".equals(field)){
|
||||||
|
colKey = parseNumToString(index, 2);
|
||||||
|
t.put(colPrefix + colKey, fieldName);
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if("sampleName".equals( col) && "SMP_NAME".equals(field)){
|
||||||
|
colKey = parseNumToString(index, 2);
|
||||||
|
t.put(colPrefix + colKey, fieldName);
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if("sampleCode".equals( col) && "SMP_CD".equals(field)){
|
||||||
|
colKey = parseNumToString(index, 2);
|
||||||
|
t.put(colPrefix + colKey, fieldName);
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============处理数据============
|
rowList.add(t.clone());
|
||||||
int dataIndex = 1;
|
}
|
||||||
|
|
||||||
|
//添加行数据
|
||||||
|
private void addDataToRowList(JSONArray fixedCol, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, List<JSONObject> rowList, int fixedColCount, int colCountOneSample, String hasRemark){
|
||||||
|
int colIndex = 0;
|
||||||
|
JSONObject t = new JSONObject();
|
||||||
for(ReportDocumentDataDO dataDO : dataList){
|
for(ReportDocumentDataDO dataDO : dataList){
|
||||||
String documentContent = dataDO.getDocumentContent();
|
String documentContent = dataDO.getDocumentContent();
|
||||||
String externalContent = dataDO.getExternalContent();
|
String externalContent = dataDO.getExternalContent();
|
||||||
JSONObject s = JSONObject.parseObject(documentContent);
|
JSONObject s = JSONObject.parseObject(documentContent);
|
||||||
JSONObject e = new JSONObject();
|
//判断样品是否有值,若无值则跳过
|
||||||
if(!ObjectUtils.isEmpty(externalContent)){
|
boolean hasValue = false;
|
||||||
e = JSONObject.parseObject(externalContent);
|
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||||
|
String fieldType = fieldDO.getFieldType();
|
||||||
|
if (FIELD_FIXED.equals(fieldType)) //这里只处理动态列。固定列在 addDataToRowList 处理
|
||||||
|
continue;
|
||||||
|
String field = fieldDO.getField();
|
||||||
|
JSONObject fieldObj = s.getJSONObject(field);
|
||||||
|
String fieldValue = "";
|
||||||
|
if (fieldObj != null)
|
||||||
|
fieldValue = fieldObj.getString("fieldValue");
|
||||||
|
if(!ObjectUtils.isEmpty(fieldValue))
|
||||||
|
hasValue = true;
|
||||||
}
|
}
|
||||||
|
if(!hasValue)
|
||||||
|
continue;
|
||||||
|
JSONObject e = new JSONObject();
|
||||||
|
if(!ObjectUtils.isEmpty(externalContent))
|
||||||
|
e = JSONObject.parseObject(externalContent);
|
||||||
String remark = e.getString("remark");
|
String remark = e.getString("remark");
|
||||||
colIndex = fixedColCount + 1;
|
colIndex = fixedColCount + 1;
|
||||||
rowAssist = 1;
|
|
||||||
t = new JSONObject();
|
t = new JSONObject();
|
||||||
if("1".equals(hasRemark)){
|
if("1".equals(hasRemark)){
|
||||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||||
@@ -249,157 +318,47 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
|||||||
}
|
}
|
||||||
if(!ObjectUtils.isEmpty(mathSymbol) && !"=".equals(mathSymbol))
|
if(!ObjectUtils.isEmpty(mathSymbol) && !"=".equals(mathSymbol))
|
||||||
fieldValue = mathSymbol + fieldValue;
|
fieldValue = mathSymbol + fieldValue;
|
||||||
|
if(ObjectUtils.isEmpty(fieldValue))
|
||||||
|
fieldValue = "/";
|
||||||
t.put(colPrefix + colKey, fieldValue);
|
t.put(colPrefix + colKey, fieldValue);
|
||||||
lastObjFlag = true;
|
|
||||||
if(colIndex % colCountOneSample == 0){
|
|
||||||
addFixedDataToRowList(fixedCol, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
|
||||||
t = new JSONObject();
|
|
||||||
if("1".equals(hasRemark)){
|
|
||||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
|
||||||
}
|
|
||||||
rowAssist++;
|
|
||||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
|
||||||
lastObjFlag = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
colIndex++;
|
colIndex++;
|
||||||
}
|
}
|
||||||
if(lastObjFlag){
|
//处理固定列
|
||||||
addFixedDataToRowList(fixedCol, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
t.put("id", dataDO.getId());
|
||||||
}
|
//处理固定列
|
||||||
dataIndex ++;
|
int index = 1;
|
||||||
}
|
//处理固定列
|
||||||
|
String colKey = "";
|
||||||
//==============以下为空白=================
|
if(fixedCol != null && !fixedCol.isEmpty()){
|
||||||
//实际使用行数小于总行数,显示“”以下为空白“
|
for(int i=0;i<fixedCol.size();i++){
|
||||||
if(dataLength < maxRowCount){
|
String col = fixedCol.getString(i);
|
||||||
String colKey = colPrefix + "01";
|
|
||||||
t = new JSONObject();
|
|
||||||
t.put(colKey, emptyText);
|
|
||||||
int rowIndex = (dataLength + emptyRowCount) * (rowAssist) + 2;
|
|
||||||
if(rowAssist == 1)
|
|
||||||
rowIndex = dataLength + emptyRowCount;
|
|
||||||
if(rowCountOneSample == 1)
|
|
||||||
rowIndex = dataLength + 2;
|
|
||||||
rowList.set(rowIndex, t.clone());
|
|
||||||
}
|
|
||||||
//前面的计数是从1开始,移除第一个元素
|
|
||||||
if(!rowList.isEmpty())
|
|
||||||
rowList.remove(0);
|
|
||||||
return rowList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
private void addTitleToRowList(JSONArray fixedCol, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
|
||||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + 1; //(标题 + 数据行 + 空行)
|
|
||||||
//处理固定列
|
|
||||||
int index = 1;
|
|
||||||
String colKey = "";
|
|
||||||
for(int i=0;i<fixedCol.size();i++) {
|
|
||||||
String col = fixedCol.getString(i);
|
|
||||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
|
||||||
String fieldName = fieldDO.getFieldName();
|
|
||||||
String fieldType = fieldDO.getFieldType();
|
|
||||||
String field = fieldDO.getField();
|
|
||||||
if (FIELD_DYNAMIC.equals(fieldType))
|
|
||||||
continue;
|
|
||||||
if("sampleNameCode".equals( col) && "SMP_NAME_CD".equals(field)){
|
|
||||||
// String sampleNameCode = "样品名称及编号";
|
|
||||||
// String sampleNameCode = fieldName;
|
|
||||||
colKey = parseNumToString(index, 2);
|
colKey = parseNumToString(index, 2);
|
||||||
t.put(colPrefix + colKey, fieldName);
|
if("sampleName".equals(col)){
|
||||||
index++;
|
t.put(colPrefix + colKey, dataDO.getSampleName());
|
||||||
continue;
|
}
|
||||||
}
|
else if("sampleCode".equals(col)){
|
||||||
if("sampleName".equals( col) && "SMP_NAME".equals(field)){
|
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||||
colKey = parseNumToString(index, 2);
|
}
|
||||||
t.put(colPrefix + colKey, fieldName);
|
else if("sampleNameCode".equals( col)){
|
||||||
index++;
|
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
||||||
continue;
|
}
|
||||||
}
|
//todo 来样名称、来样编号、来样名称编号
|
||||||
if("sampleCode".equals( col) && "SMP_CD".equals(field)){
|
index ++;
|
||||||
colKey = parseNumToString(index, 2);
|
|
||||||
t.put(colPrefix + colKey, fieldName);
|
|
||||||
index++;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//添加入行数据
|
||||||
|
rowList.add(t.clone());
|
||||||
}
|
}
|
||||||
rowList.set(rowIndex, t.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理检出限
|
* 处理检出限
|
||||||
* 如果是
|
* 如果是
|
||||||
* */
|
* */
|
||||||
private void addRangeToRowList(Integer rowAssist, JSONObject r, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList){
|
private void addRangeToRowList(JSONObject r, List<JSONObject> rowList){
|
||||||
int rowIndex = (dataLength + emptyRowCount + 1 ) * (rowAssist);
|
rowList.add(r.clone());
|
||||||
rowList.set(rowIndex, r.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加固定列的数据
|
|
||||||
* */
|
|
||||||
private void addFixedDataToRowList(JSONArray fixedCol, ReportDocumentDataDO dataDO, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, Integer dataIndex, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
|
||||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + dataIndex + 1; //(标题 + 数据行 + 空行)
|
|
||||||
t.put("id", dataDO.getId());
|
|
||||||
//处理固定列
|
|
||||||
int index = 1;
|
|
||||||
//处理固定列
|
|
||||||
String colKey = "";
|
|
||||||
if(fixedCol != null && !fixedCol.isEmpty()){
|
|
||||||
for(int i=0;i<fixedCol.size();i++){
|
|
||||||
String col = fixedCol.getString(i);
|
|
||||||
colKey = parseNumToString(index, 2);
|
|
||||||
if("sampleName".equals(col)){
|
|
||||||
t.put(colPrefix + colKey, dataDO.getSampleName());
|
|
||||||
}
|
|
||||||
else if("sampleCode".equals(col)){
|
|
||||||
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
|
||||||
}
|
|
||||||
else if("sampleNameCode".equals( col)){
|
|
||||||
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
|
||||||
}
|
|
||||||
index ++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(name_code_merge.equals(nameCodeType)){
|
|
||||||
// String merge = dataDO.getSampleName() + " " + dataDO.getSampleCode();
|
|
||||||
// t.put(colPrefix + colKey, merge);
|
|
||||||
// rowList.set(rowIndex, t.clone());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if(name_code_name.equals(nameCodeType)){
|
|
||||||
// t.put(colPrefix + colKey, dataDO.getSampleName());
|
|
||||||
// rowList.set(rowIndex, t.clone());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if(name_code_code.equals(nameCodeType)){
|
|
||||||
// t.put(colPrefix + colKey, dataDO.getSampleCode());
|
|
||||||
// rowList.set(rowIndex, t.clone());
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// for(ConfigReportFieldDO fieldDO : fieldList){
|
|
||||||
// String fieldName = fieldDO.getFieldName();
|
|
||||||
// String fieldType = fieldDO.getFieldType();
|
|
||||||
// String field = fieldDO.getField();
|
|
||||||
// if(FIELD_FIXED.equals(fieldType)){
|
|
||||||
// colKey = parseNumToString(index, 2);
|
|
||||||
// String val = "";
|
|
||||||
// if(sampleNameKey.equals( field))
|
|
||||||
// val = dataDO.getSampleName();
|
|
||||||
// else if(sampleCodeKey.equals( field))
|
|
||||||
// val = dataDO.getSampleCode();
|
|
||||||
// t.put(colPrefix + colKey, val);
|
|
||||||
// index++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
rowList.set(rowIndex, t.clone());
|
|
||||||
}
|
|
||||||
private String parseNumToString(int num, int len){
|
private String parseNumToString(int num, int len){
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for(int i = 0; i < len - String.valueOf(num).length(); i++){
|
for(int i = 0; i < len - String.valueOf(num).length(); i++){
|
||||||
|
|||||||
@@ -108,7 +108,9 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
|||||||
public CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO) {
|
public CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO) {
|
||||||
Long id = reqVO.getId();
|
Long id = reqVO.getId();
|
||||||
String businessSampleEntrustRegistrationIds = reqVO.getBusinessSampleEntrustRegistrationIds();
|
String businessSampleEntrustRegistrationIds = reqVO.getBusinessSampleEntrustRegistrationIds();
|
||||||
if(ObjectUtils.isEmpty(businessSampleEntrustRegistrationIds) || id == null)
|
if(id == null)
|
||||||
|
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "缺少id参数,请刷新后重试");
|
||||||
|
if(ObjectUtils.isEmpty(businessSampleEntrustRegistrationIds))
|
||||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "缺少businessSampleEntrustRegistrationIds参数,请刷新后重试");
|
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "缺少businessSampleEntrustRegistrationIds参数,请刷新后重试");
|
||||||
List<ReportDocumentMainCorrelationDO> reportRelationList = reportDocumentMainCorrelationService.listByMainId(id);
|
List<ReportDocumentMainCorrelationDO> reportRelationList = reportDocumentMainCorrelationService.listByMainId(id);
|
||||||
//todo 判断修改的场景。处理方法:删除reportRelation、ReportDocumentData
|
//todo 判断修改的场景。处理方法:删除reportRelation、ReportDocumentData
|
||||||
@@ -152,6 +154,7 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
|||||||
reportDocumentDataDO.setSampleName(assayReportData.getSampleName());
|
reportDocumentDataDO.setSampleName(assayReportData.getSampleName());
|
||||||
reportDocumentDataDO.setBaseSampleName(assayReportData.getBaseSampleName());
|
reportDocumentDataDO.setBaseSampleName(assayReportData.getBaseSampleName());
|
||||||
reportDocumentDataDO.setDocumentContent(assayReportData.getAssayData());
|
reportDocumentDataDO.setDocumentContent(assayReportData.getAssayData());
|
||||||
|
reportDocumentDataDO.setSampleTypeKey(assayReportData.getSampleTypeKey());
|
||||||
insertList.add(reportDocumentDataDO);
|
insertList.add(reportDocumentDataDO);
|
||||||
}
|
}
|
||||||
if(!insertList.isEmpty())
|
if(!insertList.isEmpty())
|
||||||
|
|||||||
@@ -30,7 +30,8 @@
|
|||||||
d.DELETED as deleted,
|
d.DELETED as deleted,
|
||||||
s.CREATE_TIME as baseSampleCreateTime,
|
s.CREATE_TIME as baseSampleCreateTime,
|
||||||
s.SMP_NAME as sampleName,
|
s.SMP_NAME as sampleName,
|
||||||
s.BSE_SMP_NAME as baseSampleName
|
s.BSE_SMP_NAME as baseSampleName,
|
||||||
|
(select KY from T_DIC_BSN dic where dic.id = s.DIC_BSN_ID) as sampleTypeKey
|
||||||
FROM T_BSN_ASY_RPT_DAT d
|
FROM T_BSN_ASY_RPT_DAT d
|
||||||
inner join T_BSN_BSE_SMP s on d.BSN_BSE_SMP_ID = s.id
|
inner join T_BSN_BSE_SMP s on d.BSN_BSE_SMP_ID = s.id
|
||||||
<where>
|
<where>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
m.SYS_DEPT_CD as systemDepartmentCode,
|
m.SYS_DEPT_CD as systemDepartmentCode,
|
||||||
m.UPD_CNT as updateCount,
|
m.UPD_CNT as updateCount,
|
||||||
m.RMK as remark,
|
m.RMK as remark,
|
||||||
|
m.CREATE_TIME as createTime,
|
||||||
es.name as configEntrustSourceName
|
es.name as configEntrustSourceName
|
||||||
FROM T_BSN_SMP_ENTT_REG m
|
FROM T_BSN_SMP_ENTT_REG m
|
||||||
left join T_CFG_ENTT_SRC es on m.CFG_ENTT_SRC_ID = es.id
|
left join T_CFG_ENTT_SRC es on m.CFG_ENTT_SRC_ID = es.id
|
||||||
|
|||||||
Reference in New Issue
Block a user