20250417 更新
1.解决更新后的计算问题
This commit is contained in:
@@ -37,13 +37,4 @@ public class TestRecordSampleDataExpandController {
|
||||
);
|
||||
}
|
||||
|
||||
@ApiOperation("更新扩展数据")
|
||||
@PutMapping("/update")
|
||||
public R<Boolean> update(@RequestBody TestSampleDataExpandDTO updateDTO) {
|
||||
if (StrUtil.isBlank(updateDTO.getId())) {
|
||||
return R.failed("扩展数据id不能为空!");
|
||||
}
|
||||
return R.ok(testRecordSampledataExpandService.updateBatchByDTO(Collections.singletonList(updateDTO), null));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TestSampleDataExpandConverter {
|
||||
testRecordSampleDataExpand.setTestDataId(dto.getTestDataId());
|
||||
testRecordSampleDataExpand.setPeakArea(dto.getPeakArea());
|
||||
testRecordSampleDataExpand.setFragmentRetTime(dto.getFragmentRetTime());
|
||||
testRecordSampleDataExpand.setQualitativeIonPair(dto.getQualitativeIonPair());
|
||||
testRecordSampleDataExpand.setIonAbundanceRatio(dto.getIonAbundanceRatio());
|
||||
return testRecordSampleDataExpand;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package digital.laboratory.platform.inspection.dto;
|
||||
|
||||
import digital.laboratory.platform.inspection.constant.TestRecordSampleDataConstant;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -26,6 +27,15 @@ public class TestSampleDataExpandDTO {
|
||||
@ApiModelProperty(value = "碎片保留时间(仅对 NPS 实验有用),求具体样本保留时间 = 碎片保留时间的平均值", example = "3.75")
|
||||
private BigDecimal fragmentRetTime;
|
||||
|
||||
@ApiModelProperty(value = "定性离子对,生物案件使用", example = "m/z 100 > 50")
|
||||
private String qualitativeIonPair;
|
||||
@ApiModelProperty(value = "离子丰度比,常规毒品案件使用", example = "50")
|
||||
private BigDecimal ionAbundanceRatio;
|
||||
|
||||
/************************************* 自定义setter *******************************************/
|
||||
public void setIonAbundanceRatio(String ionAbundanceRatio) {
|
||||
if (ionAbundanceRatio == null || ionAbundanceRatio.equals(TestRecordSampleDataConstant.INVALID_VALUE_STR)) {
|
||||
this.ionAbundanceRatio = null;
|
||||
} else {
|
||||
this.ionAbundanceRatio = new BigDecimal(ionAbundanceRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,9 @@ public interface TestRecordSampledataExpandService extends IService<TestRecordSa
|
||||
* 根据DTO去批量更新
|
||||
*
|
||||
* @param dtoList
|
||||
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||
* @param businessType 业务类型
|
||||
* @return
|
||||
*/
|
||||
Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId);
|
||||
Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId, String businessType);
|
||||
}
|
||||
|
||||
@@ -413,7 +413,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// });
|
||||
return testRecordSampledataExpandService.updateBatchByDTO(dtoList.stream().flatMap(dto -> dto.getExpandList().stream()).collect(Collectors.toList()), testRecord.getId());
|
||||
return testRecordSampledataExpandService.updateBatchByDTO(dtoList.stream().flatMap(dto -> dto.getExpandList().stream()).collect(Collectors.toList()), testRecord.getId(), testRecord.getBusinessType());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,17 +149,24 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
||||
* 根据DTO去批量更新
|
||||
*
|
||||
* @param dtoList
|
||||
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||
* @param businessType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId) {
|
||||
public Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId, String businessType) {
|
||||
List<TestRecordSampleDataExpand> expandList = TestSampleDataExpandConverter.dtoToEntityList(dtoList);
|
||||
if (super.updateBatchById(expandList)) {
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
boolean isNPSCase = businessType.equals(BusinessType.NPS_CASE.getBusinessType()); // 是否是常规毒品案件
|
||||
List<TestRecordSampleDataExpand> newExpandDatList = super.list(Wrappers.<TestRecordSampleDataExpand>lambdaQuery()
|
||||
.in(TestRecordSampleDataExpand::getId, expandList.stream().map(TestRecordSampleDataExpand::getId).collect(Collectors.toList()))
|
||||
.isNotNull(TestRecordSampleDataExpand::getPeakArea)
|
||||
.and(wrapper ->
|
||||
wrapper
|
||||
.isNotNull(isNPSCase ? TestRecordSampleDataExpand::getIonAbundanceRatio : TestRecordSampleDataExpand::getPeakArea)
|
||||
.or()
|
||||
.eq(TestRecordSampleDataExpand::getBasePeak, true)
|
||||
)
|
||||
);
|
||||
Map<String, List<TestRecordSampleDataExpand>> expandDataGroupByDataId = getexpandDataGroup(testId, newExpandDatList);
|
||||
|
||||
@@ -173,7 +180,6 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
||||
// 获取标准物质的扩展信息,1 先查询对应的实验数据 2 根据实验数据的实验id以及化合物以及类型获取标准物质的实验数据信息 3 根据标准物质实验数据id取对应的扩展数据
|
||||
TestRecordSampleData testRecordSampleData = testRecordSampleDataService.getById(key);
|
||||
boolean isSTDSample = testRecordSampleData.getSampleType().equals(TestRecordSampleDataConstant.SAMPLE_TYPE_STD);
|
||||
TestRecord testRecord = testRecordService.getById(testRecordSampleData.getTestId());
|
||||
List<TestRecordSampleDataExpand> stdDataExpandList = null;
|
||||
if (!isSTDSample) {
|
||||
TestRecordSampleData stdTestSampleData = testRecordSampleDataService.getOne(Wrappers.<TestRecordSampleData>lambdaQuery().eq(TestRecordSampleData::getTestId, testRecordSampleData.getTestId()).eq(TestRecordSampleData::getCompoundName, testRecordSampleData.getCompoundName()).eq(TestRecordSampleData::getSampleType, TestRecordSampleDataConstant.SAMPLE_TYPE_STD));
|
||||
@@ -181,7 +187,6 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
||||
}
|
||||
List<TestRecordSampleDataExpand> finalStdDataExpandList = stdDataExpandList;
|
||||
testRecordSampleData.setIsDetected(1); // 默认检出
|
||||
boolean isNPSCase = testRecord.getBusinessType().equals(BusinessType.NPS_CASE.getBusinessType()); // 是否是常规毒品案件
|
||||
value.forEach(sampleDataExpand -> {
|
||||
if (isNPSCase) {
|
||||
calculateIonAbundanceRatioNormal(finalStdDataExpandList, sampleDataExpand);
|
||||
@@ -192,20 +197,25 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
||||
!isSTDSample &&
|
||||
testRecordSampleData.getIsDetected().equals(1) &&
|
||||
(
|
||||
testRecordSampleData.getRtTimeWithinError().equals(TestRecordSampleDataConstant.NO)
|
||||
|| sampleDataExpand.getIonAbundanceRatioWithinError().equals(TestRecordSampleDataConstant.NO)
|
||||
Objects.equals(testRecordSampleData.getRtTimeWithinError(), TestRecordSampleDataConstant.NO)
|
||||
||
|
||||
Objects.equals(sampleDataExpand.getIonAbundanceRatioWithinError(), TestRecordSampleDataConstant.NO)
|
||||
|
||||
)
|
||||
) {
|
||||
testRecordSampleData.setIsDetected(0);
|
||||
}
|
||||
// calculateAfterResult.add(sampleDataExpand);
|
||||
});
|
||||
testRecordSampleData.setWhetherCheckOut(
|
||||
(testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT)
|
||||
+ testRecordSampleData.getCompoundCnName()
|
||||
);
|
||||
testRecordSampleDataService.updateById(testRecordSampleData);
|
||||
super.updateBatchById(value);
|
||||
if ((isNPSCase && value.size() == 4) || (!isNPSCase && value.size() == 2)) {
|
||||
// 只有扩展数据的丰度比和相对偏差填写完成才能判断是否检出, 其他情况不判断更新
|
||||
testRecordSampleData.setWhetherCheckOut(
|
||||
(testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT)
|
||||
+ testRecordSampleData.getCompoundCnName()
|
||||
);
|
||||
testRecordSampleDataService.updateById(testRecordSampleData);
|
||||
super.updateBatchById(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
// if (CollUtil.isNotEmpty(calculateAfterResult)) {
|
||||
@@ -231,7 +241,8 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
||||
private Map<String, List<TestRecordSampleDataExpand>> getexpandDataGroup(String testId, List<TestRecordSampleDataExpand> newExpandDatList) {
|
||||
List<String> stdTestDataIds = null;
|
||||
if (StrUtil.isNotBlank(testId)) {
|
||||
List<TestRecordSampleData> stdSampleDataList = testRecordSampleDataService.list(Wrappers.<TestRecordSampleData>lambdaQuery().eq(TestRecordSampleData::getTestId, testId).eq(TestRecordSampleData::getSampleType, TestRecordSampleDataConstant.SAMPLE_TYPE_STD));
|
||||
List<TestRecordSampleData> stdSampleDataList = testRecordSampleDataService.list(Wrappers.<TestRecordSampleData>lambdaQuery()
|
||||
.eq(TestRecordSampleData::getTestId, testId).eq(TestRecordSampleData::getSampleType, TestRecordSampleDataConstant.SAMPLE_TYPE_STD));
|
||||
stdTestDataIds = stdSampleDataList.stream().map(TestRecordSampleData::getId).collect(Collectors.toList());
|
||||
}
|
||||
Map<String, List<TestRecordSampleDataExpand>> expandDataGroupByDataId = newExpandDatList.stream().collect(Collectors.groupingBy(TestRecordSampleDataExpand::getTestDataId, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
@@ -79,7 +79,7 @@ public class TestRecordSampleDataExpandVO {
|
||||
if (getBasePeak()) {
|
||||
return TestRecordSampleDataConstant.INVALID_VALUE_STR;
|
||||
}
|
||||
return "±" + maxAllowedIonRatioDeviation;
|
||||
return maxAllowedIonRatioDeviation == null ? null : "±" + maxAllowedIonRatioDeviation;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,9 @@ public class TestRecordSampleDataVO {
|
||||
* @return
|
||||
*/
|
||||
public String getIonAbundanceRatioError() {
|
||||
if (sampleType.equals(TestRecordSampleDataConstant.SAMPLE_TYPE_STD)) {
|
||||
return TestRecordSampleDataConstant.INVALID_VALUE_STR;
|
||||
}
|
||||
return expandList != null && expandList.size() > 1 ? expandList.get(1).getIonAbundanceRatioError() : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user