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

Loading…
Cancel
Save