20250327 更新
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ public class TestRecordSampleDataExpandController {
|
|||||||
if (StrUtil.isBlank(updateDTO.getId())) {
|
if (StrUtil.isBlank(updateDTO.getId())) {
|
||||||
return R.failed("扩展数据id不能为空!");
|
return R.failed("扩展数据id不能为空!");
|
||||||
}
|
}
|
||||||
return R.ok(testRecordSampledataExpandService.updateBatchByDTO(Collections.singletonList(updateDTO)));
|
return R.ok(testRecordSampledataExpandService.updateBatchByDTO(Collections.singletonList(updateDTO), null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -47,7 +47,8 @@ public interface TestRecordSampledataExpandService extends IService<TestRecordSa
|
|||||||
* 根据DTO去批量更新
|
* 根据DTO去批量更新
|
||||||
*
|
*
|
||||||
* @param dtoList
|
* @param dtoList
|
||||||
|
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList);
|
Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-8
@@ -211,6 +211,13 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
|||||||
// extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
// extractedSampleTestData(testRecordSampleDataList, retList, HairSewageDataDto.class);
|
||||||
// }
|
// }
|
||||||
//// List<?> collect = TypeCasting(retList);
|
//// List<?> collect = TypeCasting(retList);
|
||||||
|
/**
|
||||||
|
* 根据测试ID和扩展数据列表获取分组后的扩展数据。
|
||||||
|
*
|
||||||
|
* @param testId 测试ID
|
||||||
|
* @param newExpandDatList 新的扩展数据列表
|
||||||
|
* @return 分组后的扩展数据
|
||||||
|
*/
|
||||||
return testRecordSampleDataList;
|
return testRecordSampleDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -414,7 +421,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改导入的实验数据
|
* 修改导入的实验数据, 如果testId不为空, 则会根据标准物质进行排序,先计算标准物质的
|
||||||
*
|
*
|
||||||
* @param dtoList
|
* @param dtoList
|
||||||
* @return
|
* @return
|
||||||
@@ -428,14 +435,14 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl
|
|||||||
testRecordService.update(Wrappers.<TestRecord>lambdaUpdate().eq(TestRecord::getId, dtoList.get(0).getTestId()).set(TestRecord::getStatus, 2));
|
testRecordService.update(Wrappers.<TestRecord>lambdaUpdate().eq(TestRecord::getId, dtoList.get(0).getTestId()).set(TestRecord::getStatus, 2));
|
||||||
}
|
}
|
||||||
// 开启异步执行
|
// 开启异步执行
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
testRecordSampleDataList.forEach(item -> calculateInspectData(item.getId()));
|
testRecordSampleDataList.forEach(item -> calculateInspectData(item.getId()));
|
||||||
}).exceptionally(e -> {
|
// }).exceptionally(e -> {
|
||||||
log.error("计算保留时间以及相对误差出错!");
|
// log.error("计算保留时间以及相对误差出错!");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return null;
|
// return null;
|
||||||
});
|
// });
|
||||||
return testRecordSampledataExpandService.updateBatchByDTO(dtoList.stream().flatMap(dto -> dto.getExpandList().stream()).collect(Collectors.toList()));
|
return testRecordSampledataExpandService.updateBatchByDTO(dtoList.stream().flatMap(dto -> dto.getExpandList().stream()).collect(Collectors.toList()), testRecord.getId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-18
@@ -26,10 +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.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -154,19 +151,21 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
* 根据DTO去批量更新
|
* 根据DTO去批量更新
|
||||||
*
|
*
|
||||||
* @param dtoList
|
* @param dtoList
|
||||||
|
* @param testId 这里实验id之所以需要是因为如果当前更新的也有标准品的,则应该先计算标准品的,避免计算样本检测的空指针异常
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList) {
|
public Boolean updateBatchByDTO(List<TestSampleDataExpandDTO> dtoList, String testId) {
|
||||||
List<TestRecordSampleDataExpand> expandList = TestSampleDataExpandConverter.dtoToEntityList(dtoList);
|
List<TestRecordSampleDataExpand> expandList = TestSampleDataExpandConverter.dtoToEntityList(dtoList);
|
||||||
if (super.updateBatchById(expandList)) {
|
if (super.updateBatchById(expandList)) {
|
||||||
CompletableFuture.runAsync(() -> {
|
// CompletableFuture.runAsync(() -> {
|
||||||
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)
|
.isNotNull(TestRecordSampleDataExpand::getPeakArea)
|
||||||
);
|
);
|
||||||
Map<String, List<TestRecordSampleDataExpand>> expandDataGroupByDataId = newExpandDatList.stream().collect(Collectors.groupingBy(TestRecordSampleDataExpand::getTestDataId));
|
Map<String, List<TestRecordSampleDataExpand>> expandDataGroupByDataId = getexpandDataGroup(testId, newExpandDatList);
|
||||||
List<TestRecordSampleDataExpand> calculateAfterResult = new ArrayList<>();
|
|
||||||
|
// List<TestRecordSampleDataExpand> calculateAfterResult = new ArrayList<>();
|
||||||
expandDataGroupByDataId.forEach((key, value) -> {
|
expandDataGroupByDataId.forEach((key, value) -> {
|
||||||
log.info("Key: " + key + ", Value Size: " + value.size());
|
log.info("Key: " + key + ", Value Size: " + value.size());
|
||||||
// 查询对应的基峰数据是否存在
|
// 查询对应的基峰数据是否存在
|
||||||
@@ -189,29 +188,64 @@ public class TestRecordSampledataExpandServiceImpl extends ServiceImpl<TestRecor
|
|||||||
if (!isSTDSample && testRecordSampleData.getIsDetected().equals(1) && sampleDataExpand.getIonAbundanceRatioWithinError().equals(TestRecordSampleDataConstant.NO)) {
|
if (!isSTDSample && testRecordSampleData.getIsDetected().equals(1) && sampleDataExpand.getIonAbundanceRatioWithinError().equals(TestRecordSampleDataConstant.NO)) {
|
||||||
testRecordSampleData.setIsDetected(0);
|
testRecordSampleData.setIsDetected(0);
|
||||||
}
|
}
|
||||||
calculateAfterResult.add(sampleDataExpand);
|
// calculateAfterResult.add(sampleDataExpand);
|
||||||
});
|
});
|
||||||
testRecordSampleData.setWhetherCheckOut(
|
testRecordSampleData.setWhetherCheckOut(
|
||||||
(testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT)
|
(testRecordSampleData.getIsDetected().equals(1) ? TestRecordSampleDataConstant.CHECK_OUT : TestRecordSampleDataConstant.NOT_CHECK_OUT)
|
||||||
+ testRecordSampleData.getCompoundCnName()
|
+ testRecordSampleData.getCompoundCnName()
|
||||||
);
|
);
|
||||||
testRecordSampleDataService.updateById(testRecordSampleData);
|
testRecordSampleDataService.updateById(testRecordSampleData);
|
||||||
|
super.updateBatchById(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
if (CollUtil.isNotEmpty(calculateAfterResult)) {
|
|
||||||
super.updateBatchById(calculateAfterResult);
|
|
||||||
}
|
|
||||||
}).exceptionally(e -> {
|
|
||||||
log.error("离子丰度比相关计算出错!");
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
|
// if (CollUtil.isNotEmpty(calculateAfterResult)) {
|
||||||
|
// super.updateBatchById(calculateAfterResult);
|
||||||
|
// }
|
||||||
|
// }).exceptionally(e -> {
|
||||||
|
// log.error("离子丰度比相关计算出错!");
|
||||||
|
// e.printStackTrace();
|
||||||
|
// return null;
|
||||||
|
// });
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据测试ID和新的扩展数据列表,获取按数据ID分组的扩展数据, 如果testId不为空, 则会根据标准物质进行排序,先计算标准物质的
|
||||||
|
*
|
||||||
|
* @param testId 测试ID
|
||||||
|
* @param newExpandDatList 新的扩展数据列表
|
||||||
|
* @return 按数据ID分组的扩展数据
|
||||||
|
*/
|
||||||
|
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));
|
||||||
|
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()));
|
||||||
|
if (stdTestDataIds != null && !stdTestDataIds.isEmpty()) {
|
||||||
|
Map<String, List<TestRecordSampleDataExpand>> sortedMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
// 先按 stdTestDataIds 的顺序放入
|
||||||
|
for (String stdTestDataId : stdTestDataIds) {
|
||||||
|
if (expandDataGroupByDataId.containsKey(stdTestDataId)) {
|
||||||
|
sortedMap.put(stdTestDataId, expandDataGroupByDataId.get(stdTestDataId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 再放入剩余的 key(不在 stdTestDataIds 里的)
|
||||||
|
expandDataGroupByDataId.entrySet().stream()
|
||||||
|
.filter(entry -> !sortedMap.containsKey(entry.getKey()))
|
||||||
|
.forEach(entry -> sortedMap.put(entry.getKey(), entry.getValue()));
|
||||||
|
|
||||||
|
// 替换原 map
|
||||||
|
expandDataGroupByDataId = sortedMap;
|
||||||
|
}
|
||||||
|
return expandDataGroupByDataId;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算离子丰度比
|
* 计算离子丰度比
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user