20250414 更新
1.在检验扩展数据表添加字段离子丰度比最大允许相对偏差 2.根据委托类型拆分计算方法
This commit is contained in:
@@ -65,4 +65,9 @@ public class TestRecordSampleDataExpand extends BaseEntity {
|
|||||||
* 定性离子对,生物案件使用
|
* 定性离子对,生物案件使用
|
||||||
*/
|
*/
|
||||||
private String qualitativeIonPair;
|
private String qualitativeIonPair;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 离子丰度比最大允许相对偏差, 存入的是数值,但是默认是正负符合,如10,实际上指的是+10或-10
|
||||||
|
*/
|
||||||
|
private BigDecimal maxAllowedIonRatioDeviation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -85,8 +86,7 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
// 检验数据
|
// 检验数据
|
||||||
List<NPSTestDetailDataStruct> npsTestSampleDataList = npsCaseTestDataDto.getTestSampleDataList();
|
List<NPSTestDetailDataStruct> npsTestSampleDataList = npsCaseTestDataDto.getTestSampleDataList();
|
||||||
|
|
||||||
List<TestRecordSampleDataExpand> testRecordSampleDataExpandList = npsTestSampleDataList.stream().map(item -> {
|
List<TestRecordSampleDataExpand> testRecordSampleDataExpandList = npsTestSampleDataList.stream().map(item -> createTestRecordSampleDataExpand(
|
||||||
return createTestRecordSampleDataExpand(
|
|
||||||
testDataId,
|
testDataId,
|
||||||
item.getIsBasePeak() == 1 ? Boolean.TRUE : Boolean.FALSE,
|
item.getIsBasePeak() == 1 ? Boolean.TRUE : Boolean.FALSE,
|
||||||
item.getArea(),
|
item.getArea(),
|
||||||
@@ -96,8 +96,7 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
item.getRetTime(),
|
item.getRetTime(),
|
||||||
item.getMass(),
|
item.getMass(),
|
||||||
null, null
|
null, null
|
||||||
);
|
)).collect(Collectors.toList());
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return testRecordSampleDataExpandList;
|
return testRecordSampleDataExpandList;
|
||||||
}
|
}
|
||||||
@@ -182,8 +181,13 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
}
|
}
|
||||||
List<TestRecordSampleDataExpand> finalStdDataExpandList = stdDataExpandList;
|
List<TestRecordSampleDataExpand> finalStdDataExpandList = stdDataExpandList;
|
||||||
testRecordSampleData.setIsDetected(1); // 默认检出
|
testRecordSampleData.setIsDetected(1); // 默认检出
|
||||||
|
boolean isNPSCase = testRecord.getBusinessType().equals(BusinessType.NPS_CASE.getBusinessType()); // 是否是常规毒品案件
|
||||||
value.forEach(sampleDataExpand -> {
|
value.forEach(sampleDataExpand -> {
|
||||||
calculateIonAbundanceRatio(basePeakData, testRecord, finalStdDataExpandList, sampleDataExpand);
|
if (isNPSCase) {
|
||||||
|
calculateIonAbundanceRatioNormal(finalStdDataExpandList, sampleDataExpand);
|
||||||
|
} else {
|
||||||
|
calculateIonAbundanceRatioBiology(basePeakData, finalStdDataExpandList, sampleDataExpand);
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!isSTDSample &&
|
!isSTDSample &&
|
||||||
testRecordSampleData.getIsDetected().equals(1) &&
|
testRecordSampleData.getIsDetected().equals(1) &&
|
||||||
@@ -253,47 +257,67 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算离子丰度比
|
* 计算离子丰度比(生物样本)
|
||||||
*
|
*
|
||||||
* @param basePeakData 基准峰数据
|
* @param basePeakData 基准峰数据
|
||||||
* @param testRecord 测试记录
|
|
||||||
* @param finalStdDataExpandList 最终标准数据扩展列表
|
* @param finalStdDataExpandList 最终标准数据扩展列表
|
||||||
* @param sampleDataExpand 样本数据扩展
|
* @param sampleDataExpand 样本数据扩展
|
||||||
*/
|
*/
|
||||||
private void calculateIonAbundanceRatio(TestRecordSampleDataExpand basePeakData, TestRecord testRecord, List<TestRecordSampleDataExpand> finalStdDataExpandList, TestRecordSampleDataExpand sampleDataExpand) {
|
private void calculateIonAbundanceRatioBiology(TestRecordSampleDataExpand basePeakData, List<TestRecordSampleDataExpand> finalStdDataExpandList, TestRecordSampleDataExpand sampleDataExpand) {
|
||||||
if (sampleDataExpand.getPeakArea() != null && basePeakData.getPeakArea() != null) {
|
if (sampleDataExpand.getPeakArea() != null && basePeakData.getPeakArea() != null) {
|
||||||
sampleDataExpand.setIonAbundanceRatio(sampleDataExpand.getPeakArea().divide(basePeakData.getPeakArea(), 5, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)));
|
sampleDataExpand.setIonAbundanceRatio(sampleDataExpand.getPeakArea().divide(basePeakData.getPeakArea(), 5, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
|
||||||
if (CollUtil.isNotEmpty(finalStdDataExpandList)) {
|
if (CollUtil.isNotEmpty(finalStdDataExpandList)) {
|
||||||
finalStdDataExpandList.forEach(stdDataExpand -> {
|
finalStdDataExpandList.forEach(stdDataExpand -> {
|
||||||
boolean matched = false; // 匹配对应的标准物质数据
|
if (stdDataExpand.getQualitativeIonPair().equals(sampleDataExpand.getQualitativeIonPair())) {
|
||||||
boolean isNPSCase = testRecord.getBusinessType().equals(BusinessType.NPS_CASE.getBusinessType()); // 是否是常规毒品案件
|
|
||||||
if (isNPSCase) {
|
|
||||||
matched = stdDataExpand.getMassToChargeRatio().equals(sampleDataExpand.getMassToChargeRatio());
|
|
||||||
} else {
|
|
||||||
matched = stdDataExpand.getQualitativeIonPair().equals(sampleDataExpand.getQualitativeIonPair());
|
|
||||||
}
|
|
||||||
if (matched) {
|
|
||||||
BigDecimal ionAbundanceRatioError = sampleDataExpand.getIonAbundanceRatio()
|
BigDecimal ionAbundanceRatioError = sampleDataExpand.getIonAbundanceRatio()
|
||||||
.subtract(stdDataExpand.getIonAbundanceRatio())
|
.subtract(stdDataExpand.getIonAbundanceRatio())
|
||||||
.divide(stdDataExpand.getIonAbundanceRatio(), 5, BigDecimal.ROUND_HALF_UP)
|
.divide(stdDataExpand.getIonAbundanceRatio(), 5, RoundingMode.HALF_UP)
|
||||||
.multiply(BigDecimal.valueOf(100));
|
.multiply(BigDecimal.valueOf(100));
|
||||||
sampleDataExpand.setIonAbundanceRatioError(ionAbundanceRatioError);
|
sampleDataExpand.setIonAbundanceRatioError(ionAbundanceRatioError);
|
||||||
if (isNPSCase) {
|
sampleDataExpand.setMaxAllowedIonRatioDeviation(
|
||||||
|
BigDecimal.valueOf(
|
||||||
|
processInspectDataService.getHairCaseIonAbundanceRatioWithinErrorRange(stdDataExpand.getIonAbundanceRatio().doubleValue())
|
||||||
|
)
|
||||||
|
);
|
||||||
|
sampleDataExpand.setIonAbundanceRatioWithinError(
|
||||||
|
processInspectDataService.calculateHairCaseIonAbundanceRatioWithinError(
|
||||||
|
ionAbundanceRatioError.doubleValue(),
|
||||||
|
sampleDataExpand.getMaxAllowedIonRatioDeviation().doubleValue()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
log.warn("没有找到匹配的标准物质检验数据!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算离子丰度比 (常规毒品)
|
||||||
|
*
|
||||||
|
* @param finalStdDataExpandList 最终标准数据扩展列表
|
||||||
|
* @param sampleDataExpand 样本数据扩展
|
||||||
|
*/
|
||||||
|
private void calculateIonAbundanceRatioNormal(List<TestRecordSampleDataExpand> finalStdDataExpandList, TestRecordSampleDataExpand sampleDataExpand) {
|
||||||
|
// 常规毒品的不需要去填写峰面积,直接填丰度比的值
|
||||||
|
if ( sampleDataExpand.getIonAbundanceRatio() != null) {
|
||||||
|
if (CollUtil.isNotEmpty(finalStdDataExpandList)) {
|
||||||
|
finalStdDataExpandList.forEach(stdDataExpand -> {
|
||||||
|
if (stdDataExpand.getMassToChargeRatio().equals(sampleDataExpand.getMassToChargeRatio())) {
|
||||||
|
BigDecimal ionAbundanceRatioError = sampleDataExpand.getIonAbundanceRatio()
|
||||||
|
.subtract(stdDataExpand.getIonAbundanceRatio())
|
||||||
|
.divide(stdDataExpand.getIonAbundanceRatio(), 5, RoundingMode.HALF_UP)
|
||||||
|
.multiply(BigDecimal.valueOf(100));
|
||||||
|
sampleDataExpand.setIonAbundanceRatioError(ionAbundanceRatioError);
|
||||||
|
sampleDataExpand.setMaxAllowedIonRatioDeviation(processInspectDataService.getErrorRange(stdDataExpand.getIonAbundanceRatio()));
|
||||||
// 取绝对值的原因是简化逻辑,不然需要判断正负值的范围
|
// 取绝对值的原因是简化逻辑,不然需要判断正负值的范围
|
||||||
sampleDataExpand.setIonAbundanceRatioWithinError(
|
sampleDataExpand.setIonAbundanceRatioWithinError(
|
||||||
processInspectDataService.getWithinErrorText(
|
processInspectDataService.getWithinErrorText(
|
||||||
ionAbundanceRatioError.abs(),
|
ionAbundanceRatioError.abs(),
|
||||||
processInspectDataService.getErrorRange(stdDataExpand.getIonAbundanceRatio())
|
sampleDataExpand.getMaxAllowedIonRatioDeviation()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
sampleDataExpand.setIonAbundanceRatioWithinError(
|
|
||||||
processInspectDataService.calculateHairCaseIonAbundanceRatioWithinError(
|
|
||||||
ionAbundanceRatioError.doubleValue(),
|
|
||||||
stdDataExpand.getIonAbundanceRatio().doubleValue()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
log.warn("没有找到匹配的标准物质检验数据!");
|
log.warn("没有找到匹配的标准物质检验数据!");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ public class TestRecordSampleDataExpandVO {
|
|||||||
@ApiModelProperty(value = "定性离子对,生物案件使用", example = "C6H12O6")
|
@ApiModelProperty(value = "定性离子对,生物案件使用", example = "C6H12O6")
|
||||||
private String qualitativeIonPair;
|
private String qualitativeIonPair;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "离子丰度比最大允许相对偏差, 存入的是数值,但是默认是正负符合,如10,实际上指的是+10或-10")
|
||||||
|
private BigDecimal maxAllowedIonRatioDeviation;
|
||||||
|
|
||||||
/************************ 处理需要特定格式返回的字段 **************************/
|
/************************ 处理需要特定格式返回的字段 **************************/
|
||||||
|
|
||||||
public String getIonAbundanceRatio() {
|
public String getIonAbundanceRatio() {
|
||||||
@@ -71,5 +74,12 @@ public class TestRecordSampleDataExpandVO {
|
|||||||
}
|
}
|
||||||
return ionAbundanceRatioWithinError;
|
return ionAbundanceRatioWithinError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMaxAllowedIonRatioDeviation() {
|
||||||
|
if (getBasePeak()) {
|
||||||
|
return TestRecordSampleDataConstant.INVALID_VALUE_STR;
|
||||||
|
}
|
||||||
|
return "±" + maxAllowedIonRatioDeviation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<result property="fragmentRetTime" column="fragment_ret_time" jdbcType="DECIMAL"/>
|
<result property="fragmentRetTime" column="fragment_ret_time" jdbcType="DECIMAL"/>
|
||||||
<result property="massToChargeRatio" column="mass_to_charge_ratio" jdbcType="DECIMAL"/>
|
<result property="massToChargeRatio" column="mass_to_charge_ratio" jdbcType="DECIMAL"/>
|
||||||
<result property="qualitativeIonPair" column="qualitative_ion_pair" jdbcType="VARCHAR"/>
|
<result property="qualitativeIonPair" column="qualitative_ion_pair" jdbcType="VARCHAR"/>
|
||||||
|
<result property="maxAllowedIonRatioDeviation" column="max_allowed_ion_ratio_deviation" jdbcType="DECIMAL"/>
|
||||||
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
|
||||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||||
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
<result property="fragmentRetTime" column="fragment_ret_time" jdbcType="DECIMAL"/>
|
<result property="fragmentRetTime" column="fragment_ret_time" jdbcType="DECIMAL"/>
|
||||||
<result property="massToChargeRatio" column="mass_to_charge_ratio" jdbcType="DECIMAL"/>
|
<result property="massToChargeRatio" column="mass_to_charge_ratio" jdbcType="DECIMAL"/>
|
||||||
<result property="qualitativeIonPair" column="qualitative_ion_pair" jdbcType="VARCHAR"/>
|
<result property="qualitativeIonPair" column="qualitative_ion_pair" jdbcType="VARCHAR"/>
|
||||||
|
<result property="maxAllowedIonRatioDeviation" column="max_allowed_ion_ratio_deviation" jdbcType="DECIMAL"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
@@ -45,6 +47,7 @@
|
|||||||
exp.ion_abundance_ratio_within_error,
|
exp.ion_abundance_ratio_within_error,
|
||||||
exp.mass_to_charge_ratio,
|
exp.mass_to_charge_ratio,
|
||||||
exp.qualitative_ion_pair,
|
exp.qualitative_ion_pair,
|
||||||
|
exp.max_allowed_ion_ratio_deviation,
|
||||||
exp.create_by,
|
exp.create_by,
|
||||||
exp.create_time,
|
exp.create_time,
|
||||||
exp.update_by,
|
exp.update_by,
|
||||||
|
|||||||
Reference in New Issue
Block a user