20250326 更新

master
陈江保 6 days ago
parent 9d4f07512a
commit b8b988e5a9
  1. 26
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleData.java
  2. 4
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/entity/TestRecordSampleDataExpand.java
  3. 2
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/ProcessInspectDataService.java
  4. 33
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/InspectRecordServiceImpl.java
  5. 8
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/ProcessInspectDataServiceImpl.java
  6. 72
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java
  7. 2
      dlp-drugtesting-biz/src/main/resources/mapper/TestRecordSampleDataMapper.xml

@ -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;
}
}

@ -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

@ -50,7 +50,7 @@ public interface ProcessInspectDataService {
* @param stdRtTime 标准物保留时间信息
* @return
*/
double getHairCaseRtTimeError(double targetRtTime, double stdRtTime);
BigDecimal getHairCaseRtTimeError(double targetRtTime, double stdRtTime);
/**
* 判断保留时间相对误差是否符合误差范围

@ -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<TestRecordSampleData> 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);
}
}

@ -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 {
@ -120,8 +120,8 @@ public class ProcessInspectDataServiceImpl implements ProcessInspectDataService
* @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);
}
/**

@ -245,8 +245,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
public List<?> getSampleTestDataByTestId(String testId, String type) {
List<TestRecordSampleDataVO> list = baseMapper.queryTestRecordSampleDataVOList(Wrappers.<TestRecordSampleData>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<Object> retList = new ArrayList<>();
// switch (BusinessType.getBusinessTypeByType(type)) {
// case SCREENING_EVENT:
@ -425,9 +424,9 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
List<TestRecordSampleData> 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 ServiceImpl<TestRecordSampl
if ( testRecordSampleData.getTargetRtTime() != null && std.getTargetRtTime() != null ) {
TestRecord testRecord = testRecordService.getById(testRecordSampleData.getTestId());
if (testRecord.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) {
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getStdRtTime()));
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getTargetRtTime()));
testRecordSampleData.setRtTimeWithinError(
processInspectDataService.setHairCaseRtTimeWithinError(
testRecordSampleData.getRtTimeError()
testRecordSampleData.getRtTimeError().doubleValue()
)
);
} else {
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getStdRtTime()));
testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getTargetRtTime()));
testRecordSampleData.setRtTimeWithinError(
processInspectDataService.getRtWithinErrorText(
Math.abs(testRecordSampleData.getRtTimeError()),
Math.abs(testRecordSampleData.getRtTimeError().doubleValue()),
1
)
);
@ -1688,61 +1687,4 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
}
);
}
/**
* 更新或者保存实验数据
*
* @param oldInfo 未更新前的数据
* @param compoundName
* @param jsonStr DTO json String
* @param sampleNo
* @param testId
* @param sampleName
* @param targetRtTime
* @param rtTimeError
* @param targetConcentration
* @return
*/
private TestRecordSampleData saveOrUpdateTestData(TestRecordSampleData oldInfo,
String compoundName,
String jsonStr,
String sampleNo,
String testId, String sampleName, String compoundCnName, double targetRtTime, double rtTimeError, String targetConcentration) {
boolean success = false;
if (oldInfo != null) {
success = this.update(Wrappers.<TestRecordSampleData>lambdaUpdate()
.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;
}
}

@ -37,7 +37,7 @@
<result property="sampleConcentration" column="sample_concentration" jdbcType="VARCHAR"/>
<result property="compoundName" column="compound_name" jdbcType="VARCHAR"/>
<result property="rtTimeWithinError" column="rt_time_within_error" jdbcType="VARCHAR"/>
<result property="rtTimeError" column="rt_time_error" jdbcType="DOUBLE"/>
<result property="rtTimeError" column="rt_time_error" jdbcType="DECIMAL"/>
<result property="targetRtTime" column="target_rt_time" jdbcType="DOUBLE"/>
<result property="stdRtTime" column="std_rt_time" jdbcType="DOUBLE"/>
<result property="isDetected" column="is_detected" jdbcType="INTEGER"/>

Loading…
Cancel
Save