diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/constant/TestRecordSampleDataConstant.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/constant/TestRecordSampleDataConstant.java index abc190d..7935bd7 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/constant/TestRecordSampleDataConstant.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/constant/TestRecordSampleDataConstant.java @@ -59,4 +59,12 @@ public interface TestRecordSampleDataConstant { String COMPOUND_BASIC_PEAK = "compound_basic_peak"; + /*************************************************** 无效值的常量 ******************************************************************************************/ + + Double INVALID_VALUE = -999d; + + // 判断当前值是否是无效值 + static boolean isInvalidValue(Double value) { + return value != null && INVALID_VALUE.equals(value); + } } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java index 01f4f23..8212ef0 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.apache.ibatis.exceptions.TooManyResultsException; import org.springframework.security.oauth2.provider.OAuth2Authentication; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -48,6 +49,7 @@ public class TestRecordSampleDataController { //解析数据文件 @PostMapping("/parseTestData") + @Transactional(rollbackFor = Exception.class) @ApiOperation(value = "上传检验数据文件", notes = "上传检验数据文件") @ApiImplicitParams({ @ApiImplicitParam(name = "fileTypeCode", value = "上传的文件格式,10001 岛津 | 10002 沃特斯毛发案件 | 20002 沃特斯任务 | 20001 沃特斯毛发任务", required = true), @@ -58,35 +60,29 @@ public class TestRecordSampleDataController { @RequestParam("testId") String testId) { try { testRecordSampleDataService.validateTestStatus(testId); + // 先删除这个实验id有关的数据在插入下新数据 + testRecordSampleDataService.delete(testId); switch (BusinessType.getBusinessTypeByType(fileTypeCode)) { case SCREENING_EVENT: case NPS_CASE: { List retDataList = TestDataFileUtil.analysisNpsDataFile(file);//NPS文件解析 - // 先删除这个实验id有关的数据在插入下新数据 - testRecordSampleDataService.remove(Wrappers.lambdaQuery().eq(TestRecordSampleData::getTestId, testId)); Boolean saveTestDataFromNps = testRecordSampleDataService.saveTestDataFromNps(retDataList, testId); return saveTestDataFromNps ? R.ok(true, "上传数据成功") : R.failed(false, "上传数据失败!"); } case BOINT_CASE: { Map> hairCompoundDataMap = TestDataFileUtil.analysisWtsDataFile(file, 1);//毛发案件文件解析 /毛发任务文件解析 - // 先删除这个实验id有关的数据在插入下新数据 - testRecordSampleDataService.remove(Wrappers.lambdaQuery().eq(TestRecordSampleData::getTestId, testId)); Boolean saveTestDataHairCase = testRecordSampleDataService.saveTestDataHairCase(hairCompoundDataMap, testId); return saveTestDataHairCase ? R.ok(true, "上传数据成功") : R.failed(false, "上传数据失败!"); } case SEWAGE_JOB: { // /污水任务文件解析 Map> sewageCompoundDataMap = TestDataFileUtil.analysisWtsDataFile(file, 2);//毛发案件文件解析 /毛发任务文件解析 - // 先删除这个实验id有关的数据在插入下新数据 - testRecordSampleDataService.remove(Wrappers.lambdaQuery().eq(TestRecordSampleData::getTestId, testId)); Boolean saveTestDataHairCase = testRecordSampleDataService.saveTestDataHairSewageTask(sewageCompoundDataMap, testId, fileTypeCode); return saveTestDataHairCase ? R.ok(true, "上传数据成功") : R.failed(false, "上传数据失败!"); } case BOINT_JOB: { // /毛发任务文件解析 Map> hairCompoundDataMap = TestDataFileUtil.analysisWtsDataFile(file, 1);//毛发案件文件解析 /毛发任务文件解析 - // 先删除这个实验id有关的数据在插入下新数据 - testRecordSampleDataService.remove(Wrappers.lambdaQuery().eq(TestRecordSampleData::getTestId, testId)); Boolean saveTestDataHairCase = testRecordSampleDataService.saveTestDataHairSewageTask(hairCompoundDataMap, testId, fileTypeCode); return saveTestDataHairCase ? R.ok(true, "上传数据成功") : R.failed(false, "上传数据失败!"); } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/dto/HairSewageDataDto.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/dto/HairSewageDataDto.java index b9e1ba5..4662026 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/dto/HairSewageDataDto.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/dto/HairSewageDataDto.java @@ -50,7 +50,7 @@ public class HairSewageDataDto extends BaseCaseDataDto { private double rtTimeError;//保留时间相对偏差 @ApiModelProperty("模板保留时间相对误差(%)") - private String tmpRtTimeError;//保留时间相对偏差 + private String tmpRtTimeError;// @ApiModelProperty("保留时间是否在误差范围内, 是否符合") private String rtTimeWithinError;//保留时间是否在误差范围内 @@ -62,25 +62,25 @@ public class HairSewageDataDto extends BaseCaseDataDto { private String qualitativeIonPairDown; @ApiModelProperty("峰面积-上") - private double peakAreaUp; + private Double peakAreaUp; @ApiModelProperty("模板峰面积-上") private String tmpPeakAreaUp; @ApiModelProperty("峰面积-下") - private double peakAreaDown; + private Double peakAreaDown; @ApiModelProperty("模板峰面积-下") private String tmpPeakAreaDown; @ApiModelProperty("离子丰度比") - private double ionAbundanceRatio; + private Double ionAbundanceRatio; @ApiModelProperty("模板离子丰度比") private String tmpIonAbundanceRatio; @ApiModelProperty("离子丰度比相对偏差(%)") - private double ionAbundanceRatioWithinError; + private Double ionAbundanceRatioWithinError; @ApiModelProperty("模板离子丰度比相对偏差(%)") private String tmpIonAbundanceRatioWithinError; diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java index 47beed0..e7667a4 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java @@ -1,73 +1,109 @@ package digital.laboratory.platform.inspection.entity; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import digital.laboratory.platform.common.mybatis.base.BaseEntity; import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** - * @author xy - * @version 1.0 - * @title TestRecordSampleSolution - * @description 实验结果数据 - * @create 2023/12/20 11:36 + * 样本检验数据 + * @TableName b_test_record_sampledata */ @Data -@TableName(value = "b_test_record_sampledata", autoResultMap = true) +@TableName(value ="b_test_record_sampledata", autoResultMap = true) @ApiModel(value = "实验中样本检测结果数据", description = "实验中样本检测结果数据") public class TestRecordSampleData extends BaseEntity { + /** + * 主键标识 + */ + @TableId(value = "ID", type = IdType.ASSIGN_ID) private String id; - private String testId;//实验ID,记录是哪次实验做的这个检材 - - @ApiModelProperty("数据从机器中导出的唯一标识, 目前只有生物样本案件需要") - private String name;//数据从机器中导出的唯一标识 - - private String sampleNo;//样本编号 - - private String compoundName;//检测的化合物(目标化合物) - - private String stdConcentration;//标准品的浓度 - - private String sampleConcentration;//样本的浓度 ng/mL - - private String rtTimeWithinError;//保留时间是否在误差范围 ±1 以内 - - private Double targetRtTime;//目标物保留时间 - - private Double stdRtTime;//标准物保留时间 - - private int isDetected;//是否检出目标化合物 - - private String sampleType;//样本类型- QC(质控) STD(标准品) Analyte(待测样品) - - private String dataJson;//实验数据-原始数据,以JSON的形式来存储该样本的实验数据 - - private String dataResultJson;//检验数据结果 - - private String compoundCnName;//检测的化合物的中文名字 - - private Double mainArea;//主要产物峰面积 - - private Double minorArea;//次要产物峰面积 - - @ApiModelProperty("任务数据审核状态, 状态:\n" + - "0 待审核,\n" + - "1 已审核,\n" + - "2 已审批, \n" + - "3 已上传 \n" + - "上传到大数据平台(仅针对任务数据, 其他业务类型的数据默认0)") + /** + * 数据从机器中导出的唯一标识 + */ + private String name; + + /** + * 样本编号 + */ + private String sampleNo; + + /** + * 实验ID + */ + private String testId; + + /** + * 标准品浓度 + */ + private String stdConcentration; + + /** + * 样品浓度 + */ + private String sampleConcentration; + + /** + * 化合物名称 + */ + private String compoundName; + + /** + * 保留时间是否在误差范围内,缴获物(-1~1), 生物样本(-2.5~2.5) + */ + private String rtTimeWithinError; + + /** + * 保留时间相对误差(%) + */ + private Double rtTimeError; + + /** + * 检材保留时间(min) + */ + private Double targetRtTime; + + /** + * 标准品保留时间(min) + */ + private Double stdRtTime; + + /** + * 是否检出该物质 1检出 0 未检出 + */ + private Integer isDetected; + + /** + * 样本类型- QC(质控) STD(标准品) Analyte(待测样品) + */ + private String sampleType; + + /** + * 检验数据json + */ + private String dataJson; + + /** + * 检验结果数据json + */ + private String dataResultJson; + + /** + * 状态: + * 0 待审核, + * 1 已审核, + * 2 已审批, + * 3 已上传 + * 上传到大数据平台(仅针对任务数据, 其他业务类型的数据默认0) + */ private Integer status; - private String getDetectedResult() { - if (isDetected == 1) { - return "检出" + compoundName; - } else { - return "未检出" + compoundName; - } - - } - + /** + * 检测的化合物的中文名字 + */ + private String compoundCnName; } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleDataExpand.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleDataExpand.java new file mode 100644 index 0000000..4a33f64 --- /dev/null +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleDataExpand.java @@ -0,0 +1,53 @@ +package digital.laboratory.platform.inspection.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import digital.laboratory.platform.common.mybatis.base.BaseEntity; +import java.math.BigDecimal; +import lombok.Data; + +/** + * 样本检验数据的扩展信息 + * @TableName b_test_record_sampledata_expand + */ +@Data +@TableName(value ="b_test_record_sampledata_expand") +public class TestRecordSampleDataExpand extends BaseEntity { + /** + * 主键标识 + */ + @TableId(value = "exp_id", type = IdType.ASSIGN_ID) + private String id; + + /** + * 关联的实验数据id(一个实验数据可能关联着多个扩展数据) + */ + private String testDataId; + + /** + * 峰面积 + */ + private BigDecimal peakArea; + + /** + * 是否是基峰, 1 是 | 0 不是 + */ + private Boolean basePeak; + + /** + * 离子丰度比 | 峰面积之比 + */ + private BigDecimal ionAbundanceRatio; + + /** + * 离子丰度比相对偏差(%)| 计算离子丰度比 相对偏差 (目标物离子丰度比 - 标准物离子丰度比) / 标准物质离子丰度比 * 100 + */ + private BigDecimal ionAbundanceRatioError; + + /** + * 离子丰度比偏差是否在误差范围内 + */ + private String ionAbundanceRatioWithinError; + +} diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/mapper/TestRecordSampledataExpandMapper.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/mapper/TestRecordSampledataExpandMapper.java new file mode 100644 index 0000000..48d47e5 --- /dev/null +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/mapper/TestRecordSampledataExpandMapper.java @@ -0,0 +1,20 @@ +package digital.laboratory.platform.inspection.mapper; + +import digital.laboratory.platform.inspection.entity.TestRecordSampleDataExpand; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author ChenJiangBao +* @description 针对表【b_test_record_sampledata_expand(样本检验数据的扩展信息)】的数据库操作Mapper +* @createDate 2025-03-19 14:58:17 +* @Entity generator.entity.TestRecordSampledataExpand +*/ +@Mapper +public interface TestRecordSampledataExpandMapper extends BaseMapper { + +} + + + + diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java index b1fb9d0..05cdc8c 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampleDataService.java @@ -33,8 +33,6 @@ public interface TestRecordSampleDataService extends IService testRecordSampleDataList); Boolean saveTestDataFromNps(List npsDataFileStructList,String testId); @@ -163,6 +161,12 @@ public interface TestRecordSampleDataService extends IService getStdSampleTestDataByTestId(String testId); diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampledataExpandService.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampledataExpandService.java new file mode 100644 index 0000000..c227654 --- /dev/null +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampledataExpandService.java @@ -0,0 +1,33 @@ +package digital.laboratory.platform.inspection.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import digital.laboratory.platform.inspection.dto.HairSewageDataDto; +import digital.laboratory.platform.inspection.dto.NPSCaseTestDataDto; +import digital.laboratory.platform.inspection.entity.TestRecordSampleDataExpand; + +import java.util.Collection; + +/** +* @author ChenJiangBao +* @description 针对表【b_test_record_sampledata_expand(样本检验数据的扩展信息)】的数据库操作Service +* @createDate 2025-03-19 14:58:17 +*/ +public interface TestRecordSampledataExpandService extends IService { + + /** + * 封装处理毛发案件、任务等检验扩展数据信息 + * @param hairSewageDataDto + * @param testDataId + * @return + */ + Collection saveHairSewageInspectExpData(HairSewageDataDto hairSewageDataDto, String testDataId); + + /** + * 封装处理nps案件检验扩展数据信息 + * + * @param npsCaseTestDataDto + * @param testDataId + * @return + */ + Collection saveNPSInspectExpData(NPSCaseTestDataDto npsCaseTestDataDto, String testDataId); +} diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java index 0b17015..7437990 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java @@ -90,6 +90,9 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl testRecordSampleDataList) { - return super.saveBatch(testRecordSampleDataList); + public void delete(String testId) { + // 删除检验数据前,先删除扩展数据 + boolean remove = testRecordSampledataExpandService.remove(Wrappers.lambdaQuery() + .inSql(TestRecordSampleDataExpand::getTestDataId, String.format("SELECT id FROM b_test_record_sampledata WHERE test_id = %s", testId)) + ); + if (remove) { + super.remove(Wrappers.lambdaQuery().eq(TestRecordSampleData::getTestId, testId)); + } } //获取检验记录中的样品信息数据 @@ -291,56 +303,6 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl finish = new AtomicReference<>(false); // 为了能在lambda中使用 - dataGroupBySampleNoMap.forEach((k, v) -> { - // 组装列表数据 - JSONObject dataObject = new JSONObject(); - dataObject.put("sampleNo", k); - int size = v.size(); // 防止频繁调用方法 - for (int i = 0; i < size; i++) { - TaskTestDataDTO taskTestDataDTO = v.get(i); - String compoundKey = "compound" + (i + 1); - if (!finish.get()) { - // 组装自定义列表头部 - JSONObject object = new JSONObject(); - if (i == 0) { - JSONObject sampleNoObject = new JSONObject(); - sampleNoObject.put(TestRecordSampleDataConstant.LABEL, "溶液编号"); - sampleNoObject.put(TestRecordSampleDataConstant.PROP, "sampleNo"); - sampleNoObject.put("fixed", true); - JSONObject name = new JSONObject(); - name.put(TestRecordSampleDataConstant.PROP, "taskName"); - name.put(TestRecordSampleDataConstant.LABEL, "案件/任务名称"); - JSONObject business = new JSONObject(); - business.put(TestRecordSampleDataConstant.PROP, "businessTypeName"); - business.put(TestRecordSampleDataConstant.LABEL, "业务类型"); - JSONObject status = new JSONObject(); - status.put(TestRecordSampleDataConstant.PROP, "statusName"); - status.put(TestRecordSampleDataConstant.LABEL, "状态"); - - headerArray.add(name); - headerArray.add(business); - headerArray.add(status); - headerArray.add(sampleNoObject); - } - object.put(TestRecordSampleDataConstant.PROP, compoundKey); - object.put(TestRecordSampleDataConstant.LABEL, "化合物" + (i + 1) + "(" + taskTestDataDTO.getCompoundName() + ")"); - headerArray.add(object); - } - // 把化合物组装导对象里 - dataObject.put("taskName", taskTestDataDTO.getTaskName()); - dataObject.put("businessTypeName", BusinessType.getBusinessTypeName(taskTestDataDTO.getBusinessType())); - dataObject.put("status", taskTestDataDTO.getStatus()); - dataObject.put("statusName", TaskTestDataStatus.getStatusNameByCode(taskTestDataDTO.getStatus())); - dataObject.put(compoundKey, taskTestDataDTO.getSampleConcentration()); - if (i == size - 1) { - finish.set(true); - } - } - dataArray.add(dataObject); - }); -*/ // 手动分页 map.put("header", headerArray); map.put("page", getPageData(dataArray, pageDTO.getCurrent(), pageDTO.getSize())); @@ -861,7 +823,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl npsDataFileStructList, String testId) { // try { - List testRecordSampleDataList = buildSampleDataFromNps(npsDataFileStructList, testId);//构造实验数据 + buildSampleDataFromNps(npsDataFileStructList, testId);//构造实验数据 testRecordService.update(Wrappers.lambdaUpdate().eq(TestRecord::getId, testId).set(TestRecord::getStatus, 2)); return true; // } catch (Exception err) { @@ -941,9 +903,9 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl upMap = new HashMap<>(); @@ -999,43 +961,15 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl generateTestRecordSampleData(List hairCaseDataDtoList) { -// -// List persistenceSampleDataList = new ArrayList<>(); -// hairCaseDataDtoList.forEach(item->{ -// TestRecordSampleData testRecordSampleData = new TestRecordSampleData(); -// testRecordSampleData.setId(IdWorker.get32UUID()); -// testRecordSampleData.setTestId(item.getTestId()); -// testRecordSampleData.setSampleNo(item.getSampleNo()); -// testRecordSampleData.setSampleConcentration(item.getTargetConcentration()); -// testRecordSampleData.setStdConcentration(item.getStdConcentration()); -// testRecordSampleData.setCompoundName(item.getCompoundName()); -// testRecordSampleData.setTargetRtTime(item.getTargetRtTime());//检材保留时间 -// testRecordSampleData.setStdRtTime(item.getStdRtTime());//标准品保留时间 -// testRecordSampleData.setRtTimeWithinError(item.getRtTimeWithinError()); -// String dataJsonStr=JSONUtil.toJsonStr(item.getTestSampleDataList()); -// String dataResultJsonStr=JSONUtil.toJsonStr(item); -// testRecordSampleData.setDataJson(dataJsonStr); -// testRecordSampleData.setDataResultJson(dataResultJsonStr); -// persistenceSampleDataList.add(testRecordSampleData); -// }); -// return persistenceSampleDataList; -// } - /** * 计算相对误差喝离子丰度比相对误差,并判断是否符合 * @@ -1076,7 +1010,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl genPersistenceSampleData(List npsCaseTestDataDtoList) { + public List genPersistenceSampleData(List npsCaseTestDataDtoList) { List persistenceSampleDataList = Collections.synchronizedList(new ArrayList<>()); + List dataExpandList = Collections.synchronizedList(new ArrayList<>()); npsCaseTestDataDtoList.parallelStream().forEach(item -> { TestRecordSampleData testRecordSampleData = new TestRecordSampleData(); - testRecordSampleData.setId(IdWorker.get32UUID()); + testRecordSampleData.setId(IdWorker.getIdStr()); testRecordSampleData.setTestId(item.getTestId()); // testRecordSampleData.setSampleNo(item.getSampleId()); if (item instanceof HairSewageDataDto) { - testRecordSampleData.setName(((HairSewageDataDto) item).getSampleName()); - testRecordSampleData.setSampleNo(((HairSewageDataDto) item).getSampleNo()); + HairSewageDataDto hairSewageDataDto = (HairSewageDataDto) item; + testRecordSampleData.setName(hairSewageDataDto.getSampleName()); + testRecordSampleData.setSampleNo(hairSewageDataDto.getSampleNo()); + dataExpandList.addAll(testRecordSampledataExpandService.saveHairSewageInspectExpData(hairSewageDataDto, testRecordSampleData.getId())); } else if (item instanceof NPSCaseTestDataDto) { NPSCaseTestDataDto npsCaseTestDataDto = (NPSCaseTestDataDto) item; testRecordSampleData.setName(npsCaseTestDataDto.getSampleName()); testRecordSampleData.setSampleNo(npsCaseTestDataDto.getSampleNo()); + dataExpandList.addAll(testRecordSampledataExpandService.saveNPSInspectExpData(npsCaseTestDataDto, testRecordSampleData.getId())); } testRecordSampleData.setSampleConcentration(item.getTargetConcentration()); testRecordSampleData.setStdConcentration(item.getStdConcentration()); @@ -1326,6 +1264,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl + implements TestRecordSampledataExpandService{ + + /** + * 封装处理毛发案件、任务等检验扩展数据信息 + * @param hairSewageDataDto + * @param testDataId + * @return + */ + public Collection saveHairSewageInspectExpData(HairSewageDataDto hairSewageDataDto, String testDataId) { + List hairSewageInspectExpDataList = new ArrayList<>(); + + // 设置基峰的扩展数据 + if (!TestRecordSampleDataConstant.isInvalidValue(hairSewageDataDto.getPeakAreaUp())) { + hairSewageInspectExpDataList.add(createTestRecordSampleDataExpand(testDataId, Boolean.TRUE, + hairSewageDataDto.getPeakAreaUp(), null, null, null, null)); + } + + if (!TestRecordSampleDataConstant.isInvalidValue(hairSewageDataDto.getPeakAreaDown())) { + hairSewageInspectExpDataList.add(createTestRecordSampleDataExpand(testDataId, Boolean.FALSE, + hairSewageDataDto.getPeakAreaDown(), hairSewageDataDto.getIonAbundanceRatio(), + hairSewageDataDto.getIonAbundanceRatioWithinError(), hairSewageDataDto.getWhetherCheckOut(), null)); + } + + return hairSewageInspectExpDataList; + } + + /** + * 封装处理nps案件检验扩展数据信息 + * + * @param npsCaseTestDataDto + * @param testDataId + * @return + */ + @Override + public Collection saveNPSInspectExpData(NPSCaseTestDataDto npsCaseTestDataDto, String testDataId) { + // 检验数据 + List npsTestSampleDataList = npsCaseTestDataDto.getTestSampleDataList(); + + List testRecordSampleDataExpandList = npsTestSampleDataList.stream().map(item -> { + return createTestRecordSampleDataExpand( + testDataId, + item.getIsBasePeak() == 1 ? Boolean.TRUE : Boolean.FALSE, + item.getArea(), + item.getAbundanceRatio(), + item.getAbundanceRatioError(), + item.getWithinError(), + null + ); + }).collect(Collectors.toList()); + + return testRecordSampleDataExpandList; + } + + + /** + * 根据提供的参数创建一个TestRecordSampleDataExpand对象。 + * + * @param testDataId 测试数据ID + * @param isBasePeak 是否为基本峰 + * @param peakArea 峰面积 + * @param ionAbundanceRatio 离子丰度比 + * @param ionAbundanceRatioError 离子丰度比误差 + * @param ionAbundanceRatioWithinError 离子丰度比是否在误差范围内 + * @param someOtherValue 其他值 + * @return 创建的TestRecordSampleDataExpand对象 + */ + private TestRecordSampleDataExpand createTestRecordSampleDataExpand( + String testDataId, + Boolean isBasePeak, + Double peakArea, + Double ionAbundanceRatio, + Double ionAbundanceRatioError, + String ionAbundanceRatioWithinError, + Double someOtherValue + ) { + TestRecordSampleDataExpand testRecordSampleDataExpand = new TestRecordSampleDataExpand(); + testRecordSampleDataExpand.setTestDataId(testDataId); + testRecordSampleDataExpand.setId(IdWorker.getIdStr()); + testRecordSampleDataExpand.setBasePeak(isBasePeak); + testRecordSampleDataExpand.setPeakArea(BigDecimal.valueOf(peakArea)); // 注意: BigDecimal.valueOf(double) + + if (ionAbundanceRatio != null) { + testRecordSampleDataExpand.setIonAbundanceRatio(BigDecimal.valueOf(ionAbundanceRatio)); + } + + if (ionAbundanceRatioError != null) { + testRecordSampleDataExpand.setIonAbundanceRatioError(BigDecimal.valueOf(ionAbundanceRatioError)); + } + + if (ionAbundanceRatioWithinError != null) { + testRecordSampleDataExpand.setIonAbundanceRatioWithinError(ionAbundanceRatioWithinError); + } + + // 如果有其他需要设置的值,可以继续扩展 + if (someOtherValue != null) { + // 处理其他值的设置逻辑 + } + + return testRecordSampleDataExpand; + } + +} diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java index c10a298..f925218 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java @@ -852,17 +852,17 @@ public class TestRecordServiceImpl extends ServiceImpl - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + id,name,sample_no, + test_id,std_concentration,sample_concentration, + compound_name,rt_time_within_error,rt_time_error, + target_rt_time,std_rt_time,is_detected, + sample_type,data_json,data_result_json, + status,create_time,create_by, + update_time,update_by,compound_cn_name + SELECT T.id, diff --git a/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampledataExpandMapper.xml b/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampledataExpandMapper.xml new file mode 100644 index 0000000..a5eef77 --- /dev/null +++ b/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampledataExpandMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + exp_id,test_data_id,peak_area, + base_peak,ion_abundance_ratio,ion_abundance_ratio_error, + ion_abundance_ratio_within_error,create_by,create_time, + update_by,update_time + +