From b8b988e5a91ba7b8d8b0eb90fadcea80989b65ff Mon Sep 17 00:00:00 2001 From: chen <2710907404@qq.com> Date: Wed, 26 Mar 2025 16:55:39 +0800 Subject: [PATCH] =?UTF-8?q?20250326=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/TestRecordSampleData.java | 26 +------ .../entity/TestRecordSampleDataExpand.java | 4 +- .../service/ProcessInspectDataService.java | 6 +- .../impl/InspectRecordServiceImpl.java | 33 +-------- .../impl/ProcessInspectDataServiceImpl.java | 12 ++-- .../impl/TestRecordSampleDataServiceImpl.java | 72 ++----------------- .../mapper/TestRecordSampleDataMapper.xml | 2 +- 7 files changed, 23 insertions(+), 132 deletions(-) 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 38659ae..b4144f7 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 @@ -8,6 +8,8 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.math.BigDecimal; + /** * 样本检验数据 * @TableName b_test_record_sampledata @@ -43,7 +45,7 @@ public class TestRecordSampleData extends BaseEntity { private String rtTimeWithinError; @ApiModelProperty(value = "保留时间相对误差(%)", example = "1.2") - private Double rtTimeError; + private BigDecimal rtTimeError; @ApiModelProperty(value = "检材保留时间(min)", example = "2.5") private Double targetRtTime; @@ -72,26 +74,4 @@ public class TestRecordSampleData extends BaseEntity { @ApiModelProperty("是否检出, 定性结果") private String whetherCheckOut; - public TestRecordSampleData() { - } - - public TestRecordSampleData(String id, String name, String sampleNo, String testId, String stdConcentration, String sampleConcentration, String compoundName, String rtTimeWithinError, Double rtTimeError, Double targetRtTime, Double stdRtTime, Integer isDetected, String sampleType, String dataJson, String dataResultJson, Integer status, String compoundCnName) { - this.id = id; - this.name = name; - this.sampleNo = sampleNo; - this.testId = testId; - this.stdConcentration = stdConcentration; - this.sampleConcentration = sampleConcentration; - this.compoundName = compoundName; - this.rtTimeWithinError = rtTimeWithinError; - this.rtTimeError = rtTimeError; - this.targetRtTime = targetRtTime; - this.stdRtTime = stdRtTime; - this.isDetected = isDetected; - this.sampleType = sampleType; - this.dataJson = dataJson; - this.dataResultJson = dataResultJson; - this.status = status; - this.compoundCnName = 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 index b6be4d6..00a15e8 100644 --- 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 @@ -1,13 +1,13 @@ package digital.laboratory.platform.inspection.entity; import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; 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; +import java.math.BigDecimal; + /** * 样本检验数据的扩展信息 * @TableName b_test_record_sampledata_expand diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/ProcessInspectDataService.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/ProcessInspectDataService.java index 2d7f092..caaa833 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/ProcessInspectDataService.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/ProcessInspectDataService.java @@ -46,11 +46,11 @@ public interface ProcessInspectDataService { /** * 计算保留时间的相对误差 * - * @param targetRtTime 目标物保留时间信息 - * @param stdRtTime 标准物保留时间信息 + * @param targetRtTime 目标物保留时间信息 + * @param stdRtTime 标准物保留时间信息 * @return */ - double getHairCaseRtTimeError(double targetRtTime, double stdRtTime); + BigDecimal getHairCaseRtTimeError(double targetRtTime, double stdRtTime); /** * 判断保留时间相对误差是否符合误差范围 diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java index e965ed2..9fbca66 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java @@ -11,6 +11,7 @@ import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy; import com.deepoove.poi.xwpf.NiceXWPFDocument; import digital.laboratory.platform.common.core.util.R; import digital.laboratory.platform.common.oss.service.OssFile; +import digital.laboratory.platform.inspection.dto.TestRecordSampleDataDocDTO; import digital.laboratory.platform.inspection.entity.TestRecordInstrument; import digital.laboratory.platform.inspection.entity.TestRecordReagent; import digital.laboratory.platform.inspection.entity.TestRecordSampleData; @@ -18,7 +19,6 @@ import digital.laboratory.platform.inspection.entity.TestRecordSampleDataExpand; import digital.laboratory.platform.inspection.enums.BusinessType; import digital.laboratory.platform.inspection.enums.TestRecordFileUrl; import digital.laboratory.platform.inspection.service.*; -import digital.laboratory.platform.inspection.dto.TestRecordSampleDataDocDTO; import digital.laboratory.platform.inspetion.api.entity.EntrustInfo; import digital.laboratory.platform.inspetion.api.entity.SampleInfo; import digital.laboratory.platform.inspetion.api.entity.TargetObject; @@ -572,35 +572,4 @@ public class InspectRecordServiceImpl implements InspectRecordService { // 8. 将最终的描述字符串添加到结果数据Map中,字段名为"detectionStr"返回结果 return String.join(";", finalSentences); } - - - public static void main(String[] args) { - List list = Arrays.asList( - new TestRecordSampleData("1", "Sample1", "2025-1-1", "T1", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 0, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("2", "Sample1", "2025-1-1", "T1", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 0, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("3", "Sample1", "2025-1-1", "T1", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 0, "Analyte", "{}", "{}", 1, "THC"), - - new TestRecordSampleData("4", "Sample2", "2025-1-2", "T2", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 0, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("5", "Sample2", "2025-1-2", "T2", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 1, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("6", "Sample2", "2025-1-2", "T2", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 0, "Analyte", "{}", "{}", 1, "THC"), - - new TestRecordSampleData("7", "Sample3", "2025-1-3", "T3", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 1, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("8", "Sample3", "2025-1-3", "T3", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 0, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("9", "Sample3", "2025-1-3", "T3", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 1, "Analyte", "{}", "{}", 1, "THC"), - - new TestRecordSampleData("10", "Sample4", "2025-1-4", "T4", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 0, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("11", "Sample4", "2025-1-4", "T4", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 0, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("12", "Sample4", "2025-1-4", "T4", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 0, "Analyte", "{}", "{}", 1, "THC"), - - new TestRecordSampleData("10", "Sample4", "2025-1-5", "T4", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 0, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("11", "Sample4", "2025-1-5", "T4", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 1, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("12", "Sample4", "2025-1-5", "T4", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 0, "Analyte", "{}", "{}", 1, "THC"), - - new TestRecordSampleData("10", "Sample4", "2025-1-6", "T4", "10", "5", "羟考酮", "0.5", 1.2, 5.5, 5.0, 1, "Analyte", "{}", "{}", 1, "Oxycodone"), - new TestRecordSampleData("11", "Sample4", "2025-1-6", "T4", "10", "4", "海洛因", "0.4", 1.1, 5.4, 5.0, 0, "Analyte", "{}", "{}", 1, "Heroin"), - new TestRecordSampleData("12", "Sample4", "2025-1-6", "T4", "10", "3", "四氢大麻酚", "0.6", 1.3, 5.6, 5.0, 0, "Analyte", "{}", "{}", 1, "THC")); - - String detectionStr = new InspectRecordServiceImpl().buildInspectOpinion(list); - System.out.println(detectionStr); - } } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/ProcessInspectDataServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/ProcessInspectDataServiceImpl.java index 87ab0ac..9bbd364 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/ProcessInspectDataServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/ProcessInspectDataServiceImpl.java @@ -102,8 +102,8 @@ public class ProcessInspectDataServiceImpl implements ProcessInspectDataService public void calculateHairCaseRtTimeError(HairSewageDataDto hairSewageDataDto, HairSewageDataDto hairSewageDataDtoStd) { if ( !TestRecordSampleDataConstant.isInvalidValue(hairSewageDataDto.getTargetRtTime()) ) { // 计算保留时间的相对误差 - double rtTimeError = getHairCaseRtTimeError(hairSewageDataDto.getTargetRtTime(), hairSewageDataDtoStd.getStdRtTime()); - hairSewageDataDto.setRtTimeError(rtTimeError); + BigDecimal rtTimeError = getHairCaseRtTimeError(hairSewageDataDto.getTargetRtTime(), hairSewageDataDtoStd.getStdRtTime()); + hairSewageDataDto.setRtTimeError(rtTimeError.doubleValue()); // 判断保留时间相对误差是否符合误差范围 hairSewageDataDto.setRtTimeWithinError(setHairCaseRtTimeWithinError(hairSewageDataDto.getRtTimeError())); } else { @@ -115,13 +115,13 @@ public class ProcessInspectDataServiceImpl implements ProcessInspectDataService /** * 计算保留时间的相对误差 * - * @param targetRtTime 目标物保留时间信息 - * @param stdRtTime 标准物保留时间信息 + * @param targetRtTime 目标物保留时间信息 + * @param stdRtTime 标准物保留时间信息 * @return */ @Override - public double getHairCaseRtTimeError(double targetRtTime, double stdRtTime) { - return (targetRtTime - stdRtTime) / stdRtTime * 100; + public BigDecimal getHairCaseRtTimeError(double targetRtTime, double stdRtTime) { + return BigDecimal.valueOf((targetRtTime - stdRtTime) / stdRtTime * 100); } /** 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 5141c93..3e8cb2f 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 @@ -245,8 +245,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl getSampleTestDataByTestId(String testId, String type) { List list = baseMapper.queryTestRecordSampleDataVOList(Wrappers.lambdaQuery() .eq(TestRecordSampleData::getTestId, testId) - .orderByDesc(TestRecordSampleData::getCompoundName) - .last("ORDER BY SUBSTRING_INDEX(name, '-', -1) + 0")); + .last("ORDER BY compound_name, SUBSTRING_INDEX(name, '-', -1) + 0")); // List retList = new ArrayList<>(); // switch (BusinessType.getBusinessTypeByType(type)) { // case SCREENING_EVENT: @@ -425,9 +424,9 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl testRecordSampleDataList = TestRecordSampleDataConverter.dtoToEntityList(dtoList); if (super.updateBatchById(testRecordSampleDataList)) { // 开启异步执行 - CompletableFuture.runAsync(() -> { +// CompletableFuture.runAsync(() -> { testRecordSampleDataList.forEach(item -> calculateInspectData(item.getId())); - }); +// }); return testRecordSampledataExpandService.updateBatchByDTO(dtoList.stream().flatMap(dto -> dto.getExpandList().stream()).collect(Collectors.toList())); } return false; @@ -1654,17 +1653,17 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpllambdaUpdate() - .eq(TestRecordSampleData::getId, oldInfo.getId()) - .set(!oldInfo.getCompoundName().equals(compoundName), TestRecordSampleData::getCompoundName, compoundName) - .set(sampleName != null && !sampleName.equals(oldInfo.getName()), TestRecordSampleData::getName, sampleName) - .set(TestRecordSampleData::getTargetRtTime, targetRtTime) - .set(TestRecordSampleData::getRtTimeError, rtTimeError) - .set(TestRecordSampleData::getSampleConcentration, targetConcentration) -// .set(TestRecordSampleData::getDataResultJson, jsonStr) // 现在数据提取到了表字段,不在处理json数据 - .set(StringUtils.isNotBlank(compoundCnName), TestRecordSampleData::getCompoundCnName, compoundCnName)); - } else { - oldInfo = new TestRecordSampleData(); - oldInfo.setSampleNo(sampleNo); - oldInfo.setCompoundName(compoundName); - oldInfo.setSampleConcentration(targetConcentration); - oldInfo.setRtTimeError(rtTimeError); - oldInfo.setTargetRtTime(targetRtTime); - oldInfo.setTestId(testId); -// oldInfo.setDataResultJson(jsonStr); // 现在数据提取到了表字段,不在处理json数据 - if (sampleNo.startsWith(StdSolutionNum.QC_SOLUTION.getPrefix())) { - oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_QC); - } else if (sampleNo.startsWith(StdSolutionNum.MIXED_SOLUTION.getPrefix()) || sampleNo.startsWith(StdSolutionNum.SIMPLE_SOLUTION.getPrefix())) { - oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_STD); - } else { - oldInfo.setSampleType(TestRecordSampleDataConstant.SAMPLE_TYPE_ANALYTE); - } - - success = this.save(oldInfo); - } - if (success) { - String dataId = oldInfo.getId(); - CompletableFuture.runAsync(() -> calculateInspectData(dataId)); - return super.getById(dataId); - } - return null; - } } diff --git a/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampleDataMapper.xml b/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampleDataMapper.xml index 327de4f..a2aea17 100644 --- a/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampleDataMapper.xml +++ b/dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampleDataMapper.xml @@ -37,7 +37,7 @@ - +