Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -31,6 +31,9 @@ public class BusinessSubSampleAnalysisGroupPageReqVO extends PageParam {
|
||||
@Schema(description = "样品状态", example = "1")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public class BusinessSubSampleAnalysisGroupRespVO {
|
||||
@ExcelProperty("样品状态")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
@ExcelProperty("收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
@@ -37,6 +37,9 @@ public class BusinessSubSampleAnalysisGroupSaveReqVO {
|
||||
@NotEmpty(message = "样品状态不能为空")
|
||||
private String sampleStatus;
|
||||
|
||||
@Schema(description = "是否送样")
|
||||
private Integer isSend;
|
||||
|
||||
@Schema(description = "收样人")
|
||||
private String sampleReceiver;
|
||||
|
||||
|
||||
@@ -64,6 +64,9 @@ public class BusinessSubSampleExtendRespVO extends BusinessSubSampleRespVO {
|
||||
@Schema(description = "分析部门名称")
|
||||
private String assayDepartmentName;
|
||||
|
||||
@Schema(description = "是否已送样")
|
||||
private Integer isSendSample;
|
||||
|
||||
@Schema(description = "是否打印")
|
||||
private Integer isPrint;
|
||||
|
||||
|
||||
@@ -145,6 +145,9 @@ public class BusinessSubSamplePageReqVO extends PageParam {
|
||||
@Schema(description = "分析部门状态")
|
||||
private String assayDepartmentStatus;
|
||||
|
||||
@Schema(description = "是否已送样")
|
||||
private Integer isSendSample;
|
||||
|
||||
@Schema(description = "样品流程节点KEY列表")
|
||||
private List<String> sampleFlowNodeKeyList;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zt.plat.module.qms.business.bus.dal.dataobject;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -109,4 +110,20 @@ public class BusinessAssayReportDataDO extends BusinessBaseDO {
|
||||
//样品创建时间
|
||||
@TableField(exist = false)
|
||||
private LocalDateTime baseSampleCreateTime;
|
||||
|
||||
//样品类型key
|
||||
@TableField(exist = false)
|
||||
private String sampleTypeKey;
|
||||
|
||||
//委托样品名称
|
||||
@TableField(exist = false)
|
||||
private String entrustSampleName;
|
||||
|
||||
//委托样品编号
|
||||
@TableField(exist = false)
|
||||
private String entrustSampleCode;
|
||||
|
||||
//委托明细排序
|
||||
@TableField(exist = false)
|
||||
private Integer entrustDetailSort;
|
||||
}
|
||||
@@ -63,6 +63,11 @@ public class BusinessSubSampleAnalysisGroupDO extends BusinessBaseDO {
|
||||
@TableField("SMP_STS")
|
||||
private String sampleStatus;
|
||||
/**
|
||||
* 是否送样
|
||||
*/
|
||||
@TableField("IS_SND")
|
||||
private Integer isSend;
|
||||
/**
|
||||
* 收样人
|
||||
*/
|
||||
@TableField("SMP_RCVR")
|
||||
|
||||
@@ -27,6 +27,7 @@ public interface BusinessSubSampleAnalysisGroupMapper extends BaseMapperX<Busine
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
|
||||
.likeIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getSampleStatus())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getIsSend, reqVO.getIsSend())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleReceiver, reqVO.getSampleReceiver())
|
||||
.betweenIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleReceiveTime, reqVO.getSampleReceiveTime())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSystemDepartmentCode, reqVO.getSystemDepartmentCode())
|
||||
|
||||
@@ -144,6 +144,7 @@ public interface BusinessSubSampleMapper extends BaseMapperX<BusinessSubSampleDO
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentId, reqVO.getAssayDepartmentId())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getAssayDepartmentName, reqVO.getAssayDepartmentName())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getSampleStatus, reqVO.getAssayDepartmentStatus())
|
||||
.eqIfPresent(BusinessSubSampleAnalysisGroupDO::getIsSend, reqVO.getIsSendSample())
|
||||
.orderByDesc(BusinessSubSampleDO::getSampleFlowNodeTime).orderByAsc(BusinessSubSampleDO::getSampleCode));
|
||||
}
|
||||
|
||||
|
||||
@@ -140,6 +140,16 @@ public class SampleSubProcessUpdateCmp extends NodeComponent {
|
||||
}
|
||||
sampleFlowContext.setBusinessSubSampleAnalysisGroupList(curDeptSubSampleAnalysisGroupDOList);
|
||||
}
|
||||
|
||||
//如果是班组送样,需要更新分析班组表
|
||||
if (QmsCommonConstant.FLOW_NODE_ANALYSIS_SEND.equals(currentSampleFlowKey)) {
|
||||
List<BusinessSubSampleAnalysisGroupDO> curDeptSubSampleAnalysisGroupDOList = businessSubSampleAnalysisGroupDOList.stream().filter(f -> f.getAssayDepartmentId().equals(loginUser.getVisitDeptId())).collect(Collectors.toList());
|
||||
for (BusinessSubSampleAnalysisGroupDO businessSubSampleAnalysisGroupDO : curDeptSubSampleAnalysisGroupDOList) {
|
||||
businessSubSampleAnalysisGroupDO.setIsSend(QmsCommonConstant.YES);
|
||||
}
|
||||
sampleFlowContext.setBusinessSubSampleAnalysisGroupList(curDeptSubSampleAnalysisGroupDOList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.zt.plat.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public interface BusinessSampleEntrustRegistrationService {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建委检登记业务
|
||||
*
|
||||
@@ -56,6 +58,8 @@ public interface BusinessSampleEntrustRegistrationService {
|
||||
*/
|
||||
BusinessSampleEntrustRegistrationDO getBusinessSampleEntrustRegistration(Long id);
|
||||
|
||||
List<BusinessSampleEntrustRegistrationDO> listByIds(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 获得委检登记业务分页
|
||||
*
|
||||
|
||||
@@ -89,6 +89,11 @@ public class BusinessSampleEntrustRegistrationServiceImpl implements BusinessSam
|
||||
return businessSampleEntrustRegistrationMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BusinessSampleEntrustRegistrationDO> listByIds(List<Long> ids) {
|
||||
return businessSampleEntrustRegistrationMapper.selectByIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BusinessSampleEntrustRegistrationExtendRespVO> getBusinessSampleEntrustRegistrationPage(BusinessSampleEntrustRegistrationPageReqVO pageReqVO) {
|
||||
return businessSampleEntrustRegistrationMapper.selectPage(pageReqVO);
|
||||
|
||||
@@ -189,58 +189,32 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
|
||||
//处理抬头数据
|
||||
|
||||
if("true".equals(editFlag)){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formData = vo.getFormData();
|
||||
JSONObject formDataJson = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(formData))
|
||||
formDataJson = JSONObject.parseObject(formData);
|
||||
List<ReportDocumentDataDO> dataList = reportDocumentDataService.listByMainDataId(id).getData();
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMain.getReportDocumentTypeId());
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
String defaultConclusion = "";
|
||||
if(!ObjectUtils.isEmpty(customConfig)){
|
||||
JSONObject config = JSONObject.parseObject(customConfig);
|
||||
defaultConclusion = config.getString("defaultConclusion");
|
||||
}
|
||||
formDataJson.put("conclusion", defaultConclusion);
|
||||
if(!dataList.isEmpty())
|
||||
formDataJson.put("sampleName", dataList.get(0).getSampleName());
|
||||
//处理检测标准
|
||||
String standard = assembleStandard(dataList);
|
||||
formDataJson.put("standard", standard);
|
||||
formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
vo.setFormData(formDataJson.toJSONString());
|
||||
// ReportDocumentMainSaveReqVO updateVO = new ReportDocumentMainSaveReqVO();
|
||||
// updateVO.setId(reportDocumentMain.getId());
|
||||
// updateVO.setFormData(formDataJson.toJSONString());
|
||||
// reportDocumentMainService.updateReportDocumentMain(updateVO);
|
||||
}
|
||||
// if("true".equals(editFlag)){
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String formData = vo.getFormData();
|
||||
// JSONObject formDataJson = new JSONObject();
|
||||
// if(!ObjectUtils.isEmpty(formData))
|
||||
// formDataJson = JSONObject.parseObject(formData);
|
||||
// List<ReportDocumentDataDO> dataList = reportDocumentDataService.listByMainDataId(id).getData();
|
||||
// ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMain.getReportDocumentTypeId());
|
||||
// String customConfig = typeDO.getCustomConfig();
|
||||
// String defaultConclusion = "";
|
||||
// if(!ObjectUtils.isEmpty(customConfig)){
|
||||
// JSONObject config = JSONObject.parseObject(customConfig);
|
||||
// defaultConclusion = config.getString("defaultConclusion");
|
||||
// }
|
||||
// formDataJson.put("conclusion", defaultConclusion);
|
||||
// if(!dataList.isEmpty())
|
||||
// formDataJson.put("sampleName", dataList.get(0).getSampleName());
|
||||
// //处理检测标准
|
||||
// String standard = assembleStandard(dataList);
|
||||
// formDataJson.put("standard", standard);
|
||||
// formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
// vo.setFormData(formDataJson.toJSONString());
|
||||
// }
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
private String assembleStandard(List<ReportDocumentDataDO> dataList){
|
||||
|
||||
Set<String> standardSet = new HashSet<>();
|
||||
for(ReportDocumentDataDO data : dataList){
|
||||
String content = data.getDocumentContent();
|
||||
if(ObjectUtils.isEmpty( content))
|
||||
continue;
|
||||
JSONObject json = JSONObject.parseObject(content);
|
||||
for(String key : json.keySet()){
|
||||
JSONObject obj = json.getJSONObject(key);
|
||||
String methodName = obj.getString("methodName");
|
||||
if(ObjectUtils.isEmpty(methodName))
|
||||
continue;
|
||||
standardSet.add(methodName);
|
||||
}
|
||||
}
|
||||
if(standardSet.isEmpty())
|
||||
return "";
|
||||
return String.join(",", standardSet);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得检测报告业务分页")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:query')")
|
||||
|
||||
@@ -43,4 +43,16 @@ public class ReportDocumentDataPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -56,6 +56,22 @@ public class ReportDocumentDataRespVO {
|
||||
@ExcelProperty("样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
@ExcelProperty("样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
@ExcelProperty("委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
@ExcelProperty("委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@ExcelProperty("排序")
|
||||
private Integer sort;
|
||||
|
||||
//==================扩展字段===========
|
||||
|
||||
@Schema(description = "样品创建时间")
|
||||
|
||||
@@ -40,4 +40,16 @@ public class ReportDocumentDataSaveReqVO {
|
||||
@Schema(description = "样品大类名称")
|
||||
private String baseSampleName;
|
||||
|
||||
@Schema(description = "样品类型key")
|
||||
private String sampleTypeKey;
|
||||
|
||||
@Schema(description = "委托样品名称")
|
||||
private String entrustSampleName;
|
||||
|
||||
@Schema(description = "委托样品编号")
|
||||
private String entrustSampleCode;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
}
|
||||
@@ -75,8 +75,26 @@ public class ReportDocumentDataDO extends BusinessBaseDO {
|
||||
@TableField("BSE_SMP_NAME")
|
||||
private String baseSampleName;
|
||||
|
||||
//样品类型key
|
||||
@TableField("SMP_TP_KY")
|
||||
private String sampleTypeKey;
|
||||
|
||||
/**
|
||||
* 委托样品名称
|
||||
*/
|
||||
@TableField("ENTT_SMP_NAME")
|
||||
private String entrustSampleName;
|
||||
/**
|
||||
* 委托样品编号
|
||||
*/
|
||||
@TableField("ENTT_SMP_CD")
|
||||
private String entrustSampleCode;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField("SRT")
|
||||
private Integer sort;
|
||||
//==================扩展字段===========
|
||||
|
||||
//样品创建时间
|
||||
|
||||
@@ -27,6 +27,7 @@ import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.e
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_DATA_NOT_EXISTS;
|
||||
import static com.zt.plat.module.qms.enums.ErrorCodeConstants.REPORT_DOCUMENT_TYPE_NOT_EXISTS;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_DYNAMIC;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_CALCULATED;
|
||||
import static com.zt.plat.module.qms.enums.QmsCommonConstant.FIELD_FIXED;
|
||||
|
||||
/**
|
||||
@@ -43,10 +44,6 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
private final String colPrefix = "col";
|
||||
private final String sampleCodeKey = "SMP_CD";
|
||||
private final String sampleNameKey = "SMP_NAME";
|
||||
private final String name_code_merge = "merge";
|
||||
private final String name_code_name = "name";
|
||||
private final String name_code_code = "code";
|
||||
private final String name_code_split = "split";
|
||||
private final String rangeKey = "minLimitValue";
|
||||
private final String emptyText = "以下为空白";
|
||||
|
||||
@@ -59,6 +56,11 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(typeDO == null || typeDO.getConfigReportTypeId() == null)
|
||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "报告配置为空,或未配置报表类型,请联系管理员处理!");
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
JSONObject configJson = JSONObject.parseObject(customConfig);
|
||||
String maxRowCountStr = configJson.getString("maxRowCount"); //最大行数
|
||||
Integer maxRowCount = 3;
|
||||
if(!ObjectUtils.isEmpty(maxRowCountStr))
|
||||
maxRowCount = Integer.parseInt(maxRowCountStr);
|
||||
//查询报表字段配置
|
||||
ConfigReportFieldPageReqVO fieldParam = new ConfigReportFieldPageReqVO();
|
||||
fieldParam.setConfigReportTypeId(typeDO.getConfigReportTypeId());
|
||||
@@ -67,6 +69,25 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(fieldListAll.isEmpty())
|
||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS.getCode(), "未配置报表字段,请联系管理员处理!");
|
||||
List<ReportDocumentDataDO> dataList = listByMainDataId(mainData.getId()).getData();
|
||||
|
||||
//拆分dataList,按样品分类key拆分
|
||||
List<List<ReportDocumentDataDO>> dataListGroup = new ArrayList<>();
|
||||
String[] sampleTypeKeys = new String[]{"inspectionAnalysisSample", "comprehensiveInspectionSample"}; //商检分析样、商检综合样
|
||||
for(String sampleTypeKey : sampleTypeKeys){
|
||||
List<ReportDocumentDataDO> dataListByKey = new ArrayList<>();
|
||||
for(ReportDocumentDataDO dataDO: dataList){
|
||||
if(sampleTypeKey.equals(dataDO.getSampleTypeKey())){
|
||||
dataListByKey.add(dataDO);
|
||||
}
|
||||
}
|
||||
if(!dataListByKey.isEmpty())
|
||||
dataListGroup.add(dataListByKey);
|
||||
}
|
||||
if(dataListGroup.isEmpty())
|
||||
dataListGroup.add(dataList);
|
||||
List<JSONObject> rowList = new ArrayList<>();
|
||||
for(int i = 0; i < dataListGroup.size(); i++){
|
||||
List<ReportDocumentDataDO> dataListByKey = dataListGroup.get(i);
|
||||
//处理字段,提取有数据的字段
|
||||
List<ConfigReportFieldDO> fieldList = new ArrayList<>();
|
||||
List<String> hasFields = new ArrayList<>();
|
||||
@@ -82,7 +103,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
for(ReportDocumentDataDO dataDO : dataListByKey){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
JSONObject dataJson = JSONObject.parseObject(documentContent);
|
||||
if(dataJson == null)
|
||||
@@ -95,10 +116,52 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
}
|
||||
}
|
||||
assembleStep1(rowList, fieldList, dataListByKey, customConfig, i); //处理后的组数对象
|
||||
}
|
||||
//处理空数据,填充/
|
||||
rowList = assembleEmpty(configJson, rowList);
|
||||
|
||||
//组装数据
|
||||
List<JSONObject> step1Arr = assembleStep1(fieldList, dataList, customConfig); //处理后的组数对象
|
||||
return CommonResult.success(step1Arr);
|
||||
//todo 处理数据分页
|
||||
|
||||
//以下为空白
|
||||
if(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", emptyText);
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
while(rowList.size() < maxRowCount){
|
||||
JSONObject t = new JSONObject();
|
||||
t.put(colPrefix + "01", " ");
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
return CommonResult.success(rowList);
|
||||
}
|
||||
|
||||
private List<JSONObject> assembleEmpty(JSONObject configJson, List<JSONObject> rowList){
|
||||
JSONArray fixedCol = configJson.getJSONArray("fixedCol"); //固定列,举例:["sampleName", "sampleCode"]
|
||||
if(fixedCol == null) fixedCol = new JSONArray();
|
||||
JSONArray fixedColRight = configJson.getJSONArray("fixedColRight"); //右侧固定列
|
||||
if(fixedColRight == null) fixedColRight = new JSONArray();
|
||||
String dynamicColCountStr = configJson.getString("dynamicColCount"); //动态列(检测项)数量
|
||||
Integer dynamicColCount = 0;
|
||||
Integer fixedColCount_left = 0;
|
||||
Integer fixedColCount_right = 0;
|
||||
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
|
||||
fixedColCount_left = fixedCol.size();
|
||||
fixedColCount_right = fixedColRight.size();
|
||||
|
||||
for(JSONObject row : rowList){
|
||||
if(" ".equals(row.getString(colPrefix + "01")))
|
||||
continue;
|
||||
int colIndex = 1;
|
||||
while(colIndex <= dynamicColCount){
|
||||
String colKey = colPrefix + parseNumToString(colIndex + fixedColCount_left, 2);
|
||||
if(!row.containsKey(colKey))
|
||||
row.put(colKey, "/");
|
||||
colIndex ++;
|
||||
}
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,19 +169,18 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
* @param fieldList 要显示的字段列表。固定字段在最前
|
||||
* @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())
|
||||
return new ArrayList<>();
|
||||
JSONObject jsonObject = JSONObject.parseObject(customConfig);
|
||||
Integer dynamicColCount = 3;
|
||||
Integer fixedColCount = 0;
|
||||
Integer maxRowCount = 3;
|
||||
Integer fixedColCount_left = 0;
|
||||
|
||||
String dynamicColCountStr = jsonObject.getString("dynamicColCount"); //动态列(检测项)数量
|
||||
// String fixedColCountStr = jsonObject.getString("fixedColCount"); //固定列(样品名称、样品编号等)数量
|
||||
JSONArray fixedCol = jsonObject.getJSONArray("fixedCol"); //固定列,举例:["sampleName", "sampleCode"]
|
||||
JSONArray fixedColShow = jsonObject.getJSONArray("fixedColShow"); //固定列,举例:["产品名称", "编 号"]
|
||||
String maxRowCountStr = jsonObject.getString("maxRowCount"); //最大行数
|
||||
// String nameCodeType = jsonObject.getString("nameCodeType"); //名称、编号处理方式:merge-合并, name-只显示名称, code-只显示编号, split-2列分开显示
|
||||
if(fixedCol == null) fixedCol = new JSONArray();
|
||||
JSONArray fixedColRight = jsonObject.getJSONArray("fixedColRight"); //右侧固定列
|
||||
if(fixedColRight == null) fixedColRight = new JSONArray();
|
||||
String hasRemark = jsonObject.getString("hasRemark"); //是否有备注
|
||||
String hasRange = jsonObject.getString("hasRange"); //是否有检出限
|
||||
String verticalFlag = jsonObject.getString("verticalFlag"); //vertical-纵表, 否则为横表
|
||||
@@ -130,106 +192,168 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
return assembleFixedFieldsData(fieldList, dataList, customConfig);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
|
||||
if(fixedCol != null) fixedColCount = fixedCol.size();
|
||||
|
||||
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 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);
|
||||
}
|
||||
|
||||
|
||||
fixedColCount_left = fixedCol.size();
|
||||
Integer colCountOneSample = fixedColCount_left + dynamicColCount; //每个样品要占的列数
|
||||
//=============处理表头============
|
||||
JSONObject t = new JSONObject();
|
||||
JSONObject r = new JSONObject(); //检出限
|
||||
int rowAssist = 1;
|
||||
int colIndex = fixedColCount + 1;
|
||||
boolean lastObjFlag = true;
|
||||
//取第一行数据,用来处理检出限
|
||||
JSONObject firstData = new JSONObject(); //取第一行数据,用于处理检出限
|
||||
if(dataLength > 0)
|
||||
firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent());
|
||||
JSONObject firstData = JSONObject.parseObject(dataList.get(0).getDocumentContent()); //取第一行数据,用于处理检出限
|
||||
if("1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
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 field = fieldDO.getField();
|
||||
if(FIELD_FIXED.equals(fieldType)){ //这里只处理动态列。固定列在 addTitleToRowList 处理
|
||||
if(FIELD_FIXED.equals(fieldType))
|
||||
continue;
|
||||
list.add(fieldDO);
|
||||
if(fieldIndex % dynamicColCount == 0){
|
||||
dynamicFieldListGroup.add(list);
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
fieldIndex ++;
|
||||
}
|
||||
if(!list.isEmpty())
|
||||
dynamicFieldListGroup.add(list);
|
||||
int colIndex = 1;
|
||||
for(int i = 0; i < dynamicFieldListGroup.size(); i++){
|
||||
List<ConfigReportFieldDO> dynamicFieldList = dynamicFieldListGroup.get(i);
|
||||
t = new JSONObject();
|
||||
r = new JSONObject();
|
||||
colIndex = fixedColCount_left + 1; //第二组以后,从固定列数开始
|
||||
for(ConfigReportFieldDO fieldDO : dynamicFieldList) {
|
||||
String field = fieldDO.getField();
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String colKey = parseNumToString(colIndex, 2);
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
//查询当前字段的检出限
|
||||
JSONObject fieldObj = firstData.getJSONObject( field);
|
||||
JSONObject fieldObj = firstData.getJSONObject(field);
|
||||
String rangeVal = "";
|
||||
if(fieldObj != null){
|
||||
if (fieldObj != null) {
|
||||
rangeVal = fieldObj.getString(rangeKey);
|
||||
}
|
||||
r.put(colPrefix + colKey, rangeVal);
|
||||
r.put(colPrefix + "01", "方法检出限");
|
||||
lastObjFlag = true;
|
||||
if(colIndex % colCountOneSample == 0){
|
||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
||||
if("1".equals(hasRange))
|
||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
||||
t = new JSONObject();
|
||||
r = new JSONObject();
|
||||
|
||||
if("1".equals(hasRemark)){
|
||||
colIndex ++;
|
||||
}
|
||||
//处理备注列
|
||||
if(i == 0 && groupIndex == 0 && "1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
}
|
||||
rowAssist++;
|
||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
||||
lastObjFlag = false;
|
||||
continue;
|
||||
if(i > 0 || groupIndex > 0){ //插入空行
|
||||
JSONObject emptyRow = new JSONObject();
|
||||
emptyRow.put(colPrefix + "01", " ");
|
||||
rowList.add(emptyRow);
|
||||
}
|
||||
colIndex++;
|
||||
addTitleToRowList(fixedCol, fixedColRight, dynamicColCount, t, rowList, fieldList);
|
||||
//插入样品数据
|
||||
addDataToRowList(fixedCol, fixedColRight, dynamicFieldList, dataList, rowList, fixedColCount_left, dynamicColCount, hasRemark);
|
||||
//检出限
|
||||
if("1".equals(hasRange)){
|
||||
rowList.add(r);
|
||||
}
|
||||
if(lastObjFlag){
|
||||
addTitleToRowList(fixedCol, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
||||
if("1".equals(hasRange))
|
||||
addRangeToRowList(rowAssist, r, dataLength, emptyRowCount, rowList);
|
||||
}
|
||||
return rowList;
|
||||
}
|
||||
|
||||
//=============处理数据============
|
||||
int dataIndex = 1;
|
||||
/**
|
||||
* @param
|
||||
*
|
||||
* */
|
||||
private void addTitleToRowList(JSONArray fixedCol, JSONArray fixedColRight, Integer dynamicColCount, JSONObject t, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
String colKey = "";
|
||||
//固定列-左
|
||||
for(int i=0;i<fixedCol.size();i++) {
|
||||
String col = fixedCol.getString(i);
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
colKey = "";
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if (FIELD_DYNAMIC.equals(fieldType) || FIELD_CALCULATED.equals(fieldType))
|
||||
continue;
|
||||
if("sampleNameCode".equals( col) && "SMP_NAME_CD".equals(field)
|
||||
|| "sampleName".equals( col) && "SMP_NAME".equals(field)
|
||||
|| "sampleCode".equals( col) && "SMP_CD".equals(field)
|
||||
|| "entrustSampleName".equals( col) && "ENTT_SMP_NAME".equals(field)
|
||||
|| "entrustSampleCode".equals( col) && "ENTT_SMP_CD".equals(field)
|
||||
|| "entrustSampleNameCode".equals( col) && "ENTT_SMP_NAME_CD".equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(colKey)){
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//固定列-右
|
||||
index = fixedCol.size() + dynamicColCount + 1;
|
||||
for(int i=0;i<fixedColRight.size();i++) {
|
||||
String col = fixedColRight.getString(i);
|
||||
for(ConfigReportFieldDO fieldDO : fieldList) {
|
||||
colKey = "";
|
||||
String fieldName = fieldDO.getFieldName();
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
String field = fieldDO.getField();
|
||||
if (FIELD_DYNAMIC.equals(fieldType) || FIELD_CALCULATED.equals(fieldType))
|
||||
continue;
|
||||
if("sampleNameCode".equals( col) && "SMP_NAME_CD".equals(field)
|
||||
|| "sampleName".equals( col) && "SMP_NAME".equals(field)
|
||||
|| "sampleCode".equals( col) && "SMP_CD".equals(field)
|
||||
|| "entrustSampleName".equals( col) && "ENTT_SMP_NAME".equals(field)
|
||||
|| "entrustSampleCode".equals( col) && "ENTT_SMP_CD".equals(field)
|
||||
|| "entrustSampleNameCode".equals( col) && "ENTT_SMP_NAME_CD".equals(field)){
|
||||
colKey = parseNumToString(index, 2);
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(colKey)){
|
||||
t.put(colPrefix + colKey, fieldName);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
|
||||
//添加行数据
|
||||
private void addDataToRowList(JSONArray fixedCol, JSONArray fixedColRight, List<ConfigReportFieldDO> fieldList, List<ReportDocumentDataDO> dataList, List<JSONObject> rowList, int fixedColCount, int dynamicColCount, String hasRemark){
|
||||
int colIndex = 0;
|
||||
JSONObject t = new JSONObject();
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
String externalContent = dataDO.getExternalContent();
|
||||
JSONObject s = JSONObject.parseObject(documentContent);
|
||||
JSONObject e = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(externalContent)){
|
||||
e = JSONObject.parseObject(externalContent);
|
||||
//判断样品是否有值,若无值则跳过
|
||||
boolean hasValue = false;
|
||||
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");
|
||||
colIndex = fixedColCount + 1;
|
||||
rowAssist = 1;
|
||||
t = new JSONObject();
|
||||
int colCountOneSample = fixedColCount + dynamicColCount;
|
||||
if("1".equals(hasRemark)){
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||
}
|
||||
@@ -249,109 +373,15 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(mathSymbol) && !"=".equals(mathSymbol))
|
||||
fieldValue = mathSymbol + fieldValue;
|
||||
if(ObjectUtils.isEmpty(fieldValue))
|
||||
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++;
|
||||
}
|
||||
if(lastObjFlag){
|
||||
addFixedDataToRowList(fixedCol, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
||||
}
|
||||
dataIndex ++;
|
||||
}
|
||||
|
||||
//==============以下为空白=================
|
||||
//实际使用行数小于总行数,显示“”以下为空白“
|
||||
if(dataLength < maxRowCount){
|
||||
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);
|
||||
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.set(rowIndex, t.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检出限
|
||||
* 如果是
|
||||
* */
|
||||
private void addRangeToRowList(Integer rowAssist, JSONObject r, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList){
|
||||
int rowIndex = (dataLength + emptyRowCount + 1 ) * (rowAssist);
|
||||
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);
|
||||
@@ -363,43 +393,50 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
else if("sampleNameCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
||||
}else if("entrustSampleName".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName());
|
||||
}else if("entrustSampleCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleCode());
|
||||
}else if("entrustSampleNameCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName() + " " + dataDO.getEntrustSampleCode());
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
//处理固定列-右
|
||||
index = fixedColRight.size() + dynamicColCount + 1;
|
||||
for(int i=0;i<fixedColRight.size();i++){
|
||||
String col = fixedColRight.getString(i);
|
||||
colKey = parseNumToString(index, 2);
|
||||
if("sampleName".equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName());
|
||||
}
|
||||
// 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());
|
||||
else if("sampleCode".equals(col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleCode());
|
||||
}
|
||||
else if("sampleNameCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getSampleName() + " " + dataDO.getSampleCode());
|
||||
}else if("entrustSampleName".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName());
|
||||
}else if("entrustSampleCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleCode());
|
||||
}else if("entrustSampleNameCode".equals( col)){
|
||||
t.put(colPrefix + colKey, dataDO.getEntrustSampleName() + " " + dataDO.getEntrustSampleCode());
|
||||
}
|
||||
index ++;
|
||||
}
|
||||
//添加入行数据
|
||||
rowList.add(t.clone());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检出限
|
||||
* 如果是
|
||||
* */
|
||||
private void addRangeToRowList(JSONObject r, List<JSONObject> rowList){
|
||||
rowList.add(r.clone());
|
||||
}
|
||||
|
||||
private String parseNumToString(int num, int len){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < len - String.valueOf(num).length(); i++){
|
||||
@@ -565,7 +602,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
public CommonResult<List<ReportDocumentDataDO>> listByMainDataId(Long mainDataId) {
|
||||
QueryWrapper<ReportDocumentDataDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("MAIN_ID", mainDataId);
|
||||
queryWrapper.orderByAsc("ID");
|
||||
queryWrapper.orderByAsc("SRT");
|
||||
List<ReportDocumentDataDO> list = reportDocumentDataMapper.selectList(queryWrapper);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public interface ReportDocumentMainCorrelationService {
|
||||
|
||||
void deleteByMainId(Long mainId);
|
||||
|
||||
void insertBatch(List<ReportDocumentMainCorrelationDO> list);
|
||||
|
||||
/**
|
||||
* 创建检测报告关系表
|
||||
*
|
||||
|
||||
@@ -59,6 +59,11 @@ public class ReportDocumentMainCorrelationServiceImpl implements ReportDocumentM
|
||||
reportDocumentMainCorrelationMapper.delete(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertBatch(List<ReportDocumentMainCorrelationDO> list) {
|
||||
reportDocumentMainCorrelationMapper.insertBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReportDocumentMainCorrelation(ReportDocumentMainCorrelationSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.zt.plat.module.qms.business.reportdoc.service;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import jakarta.validation.Valid;
|
||||
@@ -23,7 +24,7 @@ public interface ReportDocumentMainService {
|
||||
CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO);
|
||||
|
||||
//添加数据到报告-按表表数据
|
||||
CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id);
|
||||
CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id, List<BusinessSampleEntrustRegistrationDO> entrustList);
|
||||
|
||||
//移除数据
|
||||
CommonResult<String> execRemoveData(ReportDocumentMainSaveReqVO reqVO);
|
||||
|
||||
@@ -17,12 +17,15 @@ import com.zt.plat.module.qms.api.task.BMPCallbackInterface;
|
||||
import com.zt.plat.module.qms.api.task.dto.QmsBpmDTO;
|
||||
import com.zt.plat.module.qms.business.bus.controller.vo.BusinessAssayReportDataPageReqVO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessAssayReportDataDO;
|
||||
import com.zt.plat.module.qms.business.bus.dal.dataobject.BusinessSampleEntrustRegistrationDO;
|
||||
import com.zt.plat.module.qms.business.bus.service.BusinessAssayReportDataService;
|
||||
import com.zt.plat.module.qms.business.bus.service.BusinessSampleEntrustRegistrationService;
|
||||
import com.zt.plat.module.qms.business.config.dal.dataobject.ConfigUserSignatureDO;
|
||||
import com.zt.plat.module.qms.business.config.service.ConfigUserSignatureService;
|
||||
import com.zt.plat.module.qms.business.reportdoc.controller.vo.*;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentDataDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainCorrelationDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentTypeDO;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.mapper.ReportDocumentMainMapper;
|
||||
import com.zt.plat.module.qms.business.reportdoc.dal.dataobject.ReportDocumentMainDO;
|
||||
import com.zt.plat.module.qms.enums.QmsBpmConstant;
|
||||
@@ -35,10 +38,7 @@ import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@@ -62,7 +62,10 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
@Resource private BpmProcessInstanceApi bpmProcessInstanceApi;
|
||||
@Resource private BpmTaskApi bpmTaskApi;
|
||||
@Resource private ReportDocumentMainCorrelationService reportDocumentMainCorrelationService;
|
||||
@Resource private ReportDocumentTypeService reportDocumentTypeService;
|
||||
@Resource private ConfigUserSignatureService configUserSignatureService;
|
||||
@Resource private BusinessSampleEntrustRegistrationService businessSampleEntrustRegistrationService;
|
||||
|
||||
/***
|
||||
* 增加报表数据(按样品)
|
||||
* 传入:报告id、 报表数据ids
|
||||
@@ -93,14 +96,13 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
}
|
||||
if(isExist)
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "报表数据已在本报告使用,请勿重复添加");
|
||||
// List<BusinessAssayReportDataDO> assayReportDataList = businessAssayReportDataService.listByIds(addReportDataIdList);
|
||||
BusinessAssayReportDataPageReqVO reportDataQueryVo = new BusinessAssayReportDataPageReqVO();
|
||||
reportDataQueryVo.setIdList(addReportDataIdList);
|
||||
reportDataQueryVo.setPageNo(1);
|
||||
reportDataQueryVo.setPageSize(9999);
|
||||
PageResult<BusinessAssayReportDataDO> assayReportPage = businessAssayReportDataService.queryWaitingDataForReport( reportDataQueryVo);
|
||||
List<BusinessAssayReportDataDO> assayReportDataList = assayReportPage.getList();
|
||||
return execAddByBusinessAssayReportData(assayReportDataList, id);
|
||||
return execAddByBusinessAssayReportData(assayReportDataList, id, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,39 +110,44 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
public CommonResult<String> execAddDataByEntrust(ReportDocumentMainSaveReqVO reqVO) {
|
||||
Long id = reqVO.getId();
|
||||
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参数,请刷新后重试");
|
||||
List<ReportDocumentMainCorrelationDO> reportRelationList = reportDocumentMainCorrelationService.listByMainId(id);
|
||||
//todo 判断修改的场景。处理方法:删除reportRelation、ReportDocumentData
|
||||
List<Long> businessSampleEntrustRegistrationIdList = new ArrayList<>();
|
||||
String[] split = businessSampleEntrustRegistrationIds.split(",");
|
||||
for (String s : split) {
|
||||
Long aLong = Long.valueOf(s);
|
||||
businessSampleEntrustRegistrationIdList.add(aLong);
|
||||
}
|
||||
List<BusinessSampleEntrustRegistrationDO> entrustList = businessSampleEntrustRegistrationService.listByIds(businessSampleEntrustRegistrationIdList);
|
||||
BusinessAssayReportDataPageReqVO reportDataQueryVo = new BusinessAssayReportDataPageReqVO();
|
||||
reportDataQueryVo.setBusinessSampleEntrustRegistrationIdList(businessSampleEntrustRegistrationIdList);
|
||||
reportDataQueryVo.setPageNo(1);
|
||||
reportDataQueryVo.setPageSize(9999);
|
||||
PageResult<BusinessAssayReportDataDO> assayReportPage = businessAssayReportDataService.queryWaitingDataForReport( reportDataQueryVo);
|
||||
List<BusinessAssayReportDataDO> assayReportDataList = assayReportPage.getList();
|
||||
CommonResult<String> ret = execAddByBusinessAssayReportData(assayReportDataList, id);
|
||||
CommonResult<String> ret = execAddByBusinessAssayReportData(assayReportDataList, id, entrustList);
|
||||
if(!ret.isSuccess())
|
||||
return ret;
|
||||
//保存报告关系表
|
||||
List<ReportDocumentMainCorrelationDO> correlationList = new ArrayList<>();
|
||||
for(Long businessSampleEntrustRegistrationId : businessSampleEntrustRegistrationIdList){
|
||||
ReportDocumentMainCorrelationSaveReqVO correlationEntity = new ReportDocumentMainCorrelationSaveReqVO();
|
||||
ReportDocumentMainCorrelationDO correlationEntity = new ReportDocumentMainCorrelationDO();
|
||||
correlationEntity.setMainId( id);
|
||||
correlationEntity.setCorrelationId(businessSampleEntrustRegistrationId);
|
||||
correlationEntity.setCorrelationType(ReportDocumentMainCorrelationService.CorrelationType_entrust);
|
||||
reportDocumentMainCorrelationService.createReportDocumentMainCorrelation(correlationEntity);
|
||||
correlationList.add(correlationEntity);
|
||||
}
|
||||
if(!correlationList.isEmpty())
|
||||
reportDocumentMainCorrelationService.insertBatch(correlationList);
|
||||
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id){
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<String> execAddByBusinessAssayReportData(List<BusinessAssayReportDataDO> assayReportDataList, Long id, List<BusinessSampleEntrustRegistrationDO> entrustList){
|
||||
if(ObjectUtils.isEmpty(assayReportDataList))
|
||||
return error(REPORT_DOCUMENT_DATA_NOT_EXISTS.getCode(), "您选择的委托还没产生可编制报告的数据,请稍后重试!");
|
||||
List<ReportDocumentDataDO> insertList = new ArrayList<>();
|
||||
@@ -152,16 +159,75 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
reportDocumentDataDO.setSampleName(assayReportData.getSampleName());
|
||||
reportDocumentDataDO.setBaseSampleName(assayReportData.getBaseSampleName());
|
||||
reportDocumentDataDO.setDocumentContent(assayReportData.getAssayData());
|
||||
reportDocumentDataDO.setSampleTypeKey(assayReportData.getSampleTypeKey());
|
||||
reportDocumentDataDO.setEntrustSampleCode(assayReportData.getEntrustSampleCode());
|
||||
reportDocumentDataDO.setEntrustSampleName(assayReportData.getEntrustSampleName());
|
||||
reportDocumentDataDO.setSort(assayReportData.getEntrustDetailSort());
|
||||
insertList.add(reportDocumentDataDO);
|
||||
}
|
||||
if(!insertList.isEmpty())
|
||||
reportDocumentDataService.insertBatch(insertList);
|
||||
ReportDocumentMainDO reportDocumentMainDO = reportDocumentMainMapper.selectById(id);
|
||||
updateCommonField(reportDocumentMainDO);
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formData = reportDocumentMainDO.getFormData();
|
||||
JSONObject formDataJson = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(formData))
|
||||
formDataJson = JSONObject.parseObject(formData);
|
||||
ReportDocumentTypeDO typeDO = reportDocumentTypeService.getReportDocumentType(reportDocumentMainDO.getReportDocumentTypeId());
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
String defaultConclusion = "";
|
||||
if(!ObjectUtils.isEmpty(customConfig)){
|
||||
JSONObject config = JSONObject.parseObject(customConfig);
|
||||
defaultConclusion = config.getString("defaultConclusion");
|
||||
}
|
||||
formDataJson.put("conclusion", defaultConclusion);
|
||||
if(!assayReportDataList.isEmpty())
|
||||
formDataJson.put("sampleName", assayReportDataList.get(0).getSampleName());
|
||||
//处理检测标准
|
||||
String standard = assembleStandard(assayReportDataList);
|
||||
formDataJson.put("standard", standard);
|
||||
formDataJson.put("reportTime", sdf.format(new Date()));
|
||||
|
||||
//委托单号
|
||||
String entrustCode = "";
|
||||
if(!ObjectUtils.isEmpty(entrustList)){
|
||||
for(BusinessSampleEntrustRegistrationDO entrust : entrustList){
|
||||
entrustCode += entrust.getEntrustNumber() + ",";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!ObjectUtils.isEmpty(entrustCode))
|
||||
entrustCode = entrustCode.substring(0, entrustCode.length() - 1);
|
||||
formDataJson.put("entrustCode", entrustCode);
|
||||
|
||||
reportDocumentMainDO.setFormData(formDataJson.toJSONString());
|
||||
reportDocumentMainMapper.updateById(reportDocumentMainDO);
|
||||
return CommonResult.success("操作成功");
|
||||
}
|
||||
|
||||
//组装检测标准
|
||||
private String assembleStandard(List<BusinessAssayReportDataDO> dataList){
|
||||
Set<String> standardSet = new HashSet<>();
|
||||
for(BusinessAssayReportDataDO data : dataList){
|
||||
String content = data.getAssayData();
|
||||
if(ObjectUtils.isEmpty( content))
|
||||
continue;
|
||||
JSONObject json = JSONObject.parseObject(content);
|
||||
for(String key : json.keySet()){
|
||||
JSONObject obj = json.getJSONObject(key);
|
||||
String methodName = obj.getString("methodName");
|
||||
if(ObjectUtils.isEmpty(methodName))
|
||||
continue;
|
||||
standardSet.add(methodName);
|
||||
}
|
||||
}
|
||||
if(standardSet.isEmpty())
|
||||
return "";
|
||||
return String.join(",", standardSet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommonField(ReportDocumentMainDO reportDocumentMainDO) {
|
||||
if(reportDocumentMainDO == null)
|
||||
|
||||
@@ -30,9 +30,14 @@
|
||||
d.DELETED as deleted,
|
||||
s.CREATE_TIME as baseSampleCreateTime,
|
||||
s.SMP_NAME as sampleName,
|
||||
s.BSE_SMP_NAME as baseSampleName
|
||||
s.BSE_SMP_NAME as baseSampleName,
|
||||
ed.ENTT_SMP_NAME as entrustSampleName,
|
||||
ed.ENTT_SMP_CD as entrustSampleCode,
|
||||
ed.SRT as entrustDetailSort,
|
||||
(select KY from T_DIC_BSN dic where dic.id = s.DIC_BSN_ID) as sampleTypeKey
|
||||
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_SMP_ENTT_DTL ed on ed.BSN_BSE_SMP_ID = s.id
|
||||
<where>
|
||||
<if test="param.idList != null and param.idList.size > 0">
|
||||
and d.id in (
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
m.SYS_DEPT_CD as systemDepartmentCode,
|
||||
m.UPD_CNT as updateCount,
|
||||
m.RMK as remark,
|
||||
m.CREATE_TIME as createTime,
|
||||
es.name as configEntrustSourceName
|
||||
FROM T_BSN_SMP_ENTT_REG m
|
||||
left join T_CFG_ENTT_SRC es on m.CFG_ENTT_SRC_ID = es.id
|
||||
|
||||
Reference in New Issue
Block a user