20250417 更新

1.解决更新后的计算问题
master
陈江保 2 days ago
parent 43b58ed5ec
commit b609d9c71a
  1. 9
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordSampleDataExpandController.java
  2. 2
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/convert/TestSampleDataExpandConverter.java
  3. 14
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/dto/TestSampleDataExpandDTO.java
  4. 5
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordSampledataExpandService.java
  5. 2
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java
  6. 39
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampledataExpandServiceImpl.java
  7. 2
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/vo/TestRecordSampleDataExpandVO.java
  8. 3
      dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/vo/TestRecordSampleDataVO.java

@ -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.setTestDataId(dto.getTestDataId());
testRecordSampleDataExpand.setPeakArea(dto.getPeakArea()); testRecordSampleDataExpand.setPeakArea(dto.getPeakArea());
testRecordSampleDataExpand.setFragmentRetTime(dto.getFragmentRetTime()); testRecordSampleDataExpand.setFragmentRetTime(dto.getFragmentRetTime());
testRecordSampleDataExpand.setQualitativeIonPair(dto.getQualitativeIonPair()); testRecordSampleDataExpand.setIonAbundanceRatio(dto.getIonAbundanceRatio());
return testRecordSampleDataExpand; return testRecordSampleDataExpand;
} }

@ -1,5 +1,6 @@
package digital.laboratory.platform.inspection.dto; package digital.laboratory.platform.inspection.dto;
import digital.laboratory.platform.inspection.constant.TestRecordSampleDataConstant;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@ -26,6 +27,15 @@ public class TestSampleDataExpandDTO {
@ApiModelProperty(value = "碎片保留时间(仅对 NPS 实验有用),求具体样本保留时间 = 碎片保留时间的平均值", example = "3.75") @ApiModelProperty(value = "碎片保留时间(仅对 NPS 实验有用),求具体样本保留时间 = 碎片保留时间的平均值", example = "3.75")
private BigDecimal fragmentRetTime; private BigDecimal fragmentRetTime;
@ApiModelProperty(value = "定性离子对,生物案件使用", example = "m/z 100 > 50") @ApiModelProperty(value = "离子丰度比,常规毒品案件使用", example = "50")
private String qualitativeIonPair; 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去批量更新 * 根据DTO去批量更新
* *
* @param dtoList * @param dtoList
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的则应该先计算标准品的避免计算样本检测的空指针异常 * @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的则应该先计算标准品的避免计算样本检测的空指针异常
* @param businessType 业务类型
* @return * @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(); // e.printStackTrace();
// return null; // 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; return false;
} }

@ -149,17 +149,24 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
* 根据DTO去批量更新 * 根据DTO去批量更新
* *
* @param dtoList * @param dtoList
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的则应该先计算标准品的避免计算样本检测的空指针异常 * @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的则应该先计算标准品的避免计算样本检测的空指针异常
* @param businessType
* @return * @return
*/ */
@Override @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); List<TestRecordSampleDataExpand> expandList = TestSampleDataExpandConverter.dtoToEntityList(dtoList);
if (super.updateBatchById(expandList)) { if (super.updateBatchById(expandList)) {
// CompletableFuture.runAsync(() -> { // CompletableFuture.runAsync(() -> {
boolean isNPSCase = businessType.equals(BusinessType.NPS_CASE.getBusinessType()); // 是否是常规毒品案件
List<TestRecordSampleDataExpand> newExpandDatList = super.list(Wrappers.<TestRecordSampleDataExpand>lambdaQuery() List<TestRecordSampleDataExpand> newExpandDatList = super.list(Wrappers.<TestRecordSampleDataExpand>lambdaQuery()
.in(TestRecordSampleDataExpand::getId, expandList.stream().map(TestRecordSampleDataExpand::getId).collect(Collectors.toList())) .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); Map<String, List<TestRecordSampleDataExpand>> expandDataGroupByDataId = getexpandDataGroup(testId, newExpandDatList);
@ -173,7 +180,6 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
// 获取标准物质的扩展信息,1 先查询对应的实验数据 2 根据实验数据的实验id以及化合物以及类型获取标准物质的实验数据信息 3 根据标准物质实验数据id取对应的扩展数据 // 获取标准物质的扩展信息,1 先查询对应的实验数据 2 根据实验数据的实验id以及化合物以及类型获取标准物质的实验数据信息 3 根据标准物质实验数据id取对应的扩展数据
TestRecordSampleData testRecordSampleData = testRecordSampleDataService.getById(key); TestRecordSampleData testRecordSampleData = testRecordSampleDataService.getById(key);
boolean isSTDSample = testRecordSampleData.getSampleType().equals(TestRecordSampleDataConstant.SAMPLE_TYPE_STD); boolean isSTDSample = testRecordSampleData.getSampleType().equals(TestRecordSampleDataConstant.SAMPLE_TYPE_STD);
TestRecord testRecord = testRecordService.getById(testRecordSampleData.getTestId());
List<TestRecordSampleDataExpand> stdDataExpandList = null; List<TestRecordSampleDataExpand> stdDataExpandList = null;
if (!isSTDSample) { 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)); 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; 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 -> {
if (isNPSCase) { if (isNPSCase) {
calculateIonAbundanceRatioNormal(finalStdDataExpandList, sampleDataExpand); calculateIonAbundanceRatioNormal(finalStdDataExpandList, sampleDataExpand);
@ -192,20 +197,25 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
!isSTDSample && !isSTDSample &&
testRecordSampleData.getIsDetected().equals(1) && testRecordSampleData.getIsDetected().equals(1) &&
( (
testRecordSampleData.getRtTimeWithinError().equals(TestRecordSampleDataConstant.NO) Objects.equals(testRecordSampleData.getRtTimeWithinError(), TestRecordSampleDataConstant.NO)
|| sampleDataExpand.getIonAbundanceRatioWithinError().equals(TestRecordSampleDataConstant.NO) ||
Objects.equals(sampleDataExpand.getIonAbundanceRatioWithinError(), TestRecordSampleDataConstant.NO)
) )
) { ) {
testRecordSampleData.setIsDetected(0); testRecordSampleData.setIsDetected(0);
} }
// calculateAfterResult.add(sampleDataExpand); // calculateAfterResult.add(sampleDataExpand);
}); });
testRecordSampleData.setWhetherCheckOut( if ((isNPSCase && value.size() == 4) || (!isNPSCase && value.size() == 2)) {
(testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT) // 只有扩展数据的丰度比和相对偏差填写完成才能判断是否检出, 其他情况不判断更新
+ testRecordSampleData.getCompoundCnName() testRecordSampleData.setWhetherCheckOut(
); (testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT)
testRecordSampleDataService.updateById(testRecordSampleData); + testRecordSampleData.getCompoundCnName()
super.updateBatchById(value); );
testRecordSampleDataService.updateById(testRecordSampleData);
super.updateBatchById(value);
}
} }
}); });
// if (CollUtil.isNotEmpty(calculateAfterResult)) { // 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) { private Map<String, List<TestRecordSampleDataExpand>> getexpandDataGroup(String testId, List<TestRecordSampleDataExpand> newExpandDatList) {
List<String> stdTestDataIds = null; List<String> stdTestDataIds = null;
if (StrUtil.isNotBlank(testId)) { 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()); 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())); 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()) { if (getBasePeak()) {
return TestRecordSampleDataConstant.INVALID_VALUE_STR; return TestRecordSampleDataConstant.INVALID_VALUE_STR;
} }
return "±" + maxAllowedIonRatioDeviation; return maxAllowedIonRatioDeviation == null ? null : "±" + maxAllowedIonRatioDeviation;
} }
} }

@ -102,6 +102,9 @@ public class TestRecordSampleDataVO {
* @return * @return
*/ */
public String getIonAbundanceRatioError() { 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; return expandList != null && expandList.size() > 1 ? expandList.get(1).getIonAbundanceRatioError() : null;
} }

Loading…
Cancel
Save