diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/PushDataToLabsCareServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/PushDataToLabsCareServiceImpl.java index 13114e1..550840e 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/PushDataToLabsCareServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/PushDataToLabsCareServiceImpl.java @@ -93,7 +93,7 @@ public class PushDataToLabsCareServiceImpl implements PushDataToLabsCareService private final static String NON_INFRARED_GENERAL_QUALITATIVE_RECORD = "NonInfraredGeneralQualitativeRecord"; /** - * 做一个定时推送,对于推送失败的委托进行重新推送, 每天凌晨1点推送 + * 做一个定时推送,对于推送失败的委托进行重新推送, 每天凌晨2点推送 */ // @Scheduled(cron = "30 * * * * ?") // 测试 @Scheduled(cron = "0 0 2 * * ?") // 每天凌晨 2 点执行 diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java index c0f3d63..51b6f5f 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordSampleDataServiceImpl.java @@ -407,7 +407,7 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl } // 开启异步执行 // CompletableFuture.runAsync(() -> { - testRecordSampleDataList.forEach(item -> calculateInspectData(item.getId())); + calculateInspectData(testRecordSampleDataList.stream().map(TestRecordSampleData::getId).collect(Collectors.toList()), testRecord.getBusinessType()); // }).exceptionally(e -> { // log.error("计算保留时间以及相对误差出错!"); // e.printStackTrace(); @@ -1610,38 +1610,44 @@ public class TestRecordSampleDataServiceImpl extends ServiceImpl<TestRecordSampl /** * 更新计算数据,计算保留时间和保留时间误差 - * @param dataId 检验数据id + * + * @param dataIds 检验数据id列表 + * @param businessType 实验类型(业务类型) * @return */ - public Boolean calculateInspectData(String dataId) { - TestRecordSampleData testRecordSampleData = super.getById(dataId); - String compoundName = testRecordSampleData.getCompoundName(); - - TestRecordSampleData std = this.getOne(Wrappers.<TestRecordSampleData>lambdaQuery() - .eq(TestRecordSampleData::getCompoundName, compoundName) - .eq(TestRecordSampleData::getTestId, testRecordSampleData.getTestId()) - .eq(TestRecordSampleData::getSampleType, "STD")); - - if ( testRecordSampleData.getTargetRtTime() != null && std.getTargetRtTime() != null ) { - TestRecord testRecord = testRecordService.getById(testRecordSampleData.getTestId()); - if (testRecord.getBusinessType().equals(BusinessType.BOINT_CASE.getBusinessType())) { - testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getTargetRtTime())); - testRecordSampleData.setRtTimeWithinError( - processInspectDataService.setHairCaseRtTimeWithinError( - testRecordSampleData.getRtTimeError().doubleValue() - ) - ); - } else { + public Boolean calculateInspectData(List<String> dataIds, String businessType) { + // 获取所有需要操作的列表 + List<TestRecordSampleData> testRecordSampleDataList = super.listByIds(dataIds); + + // 筛选出标准物质检验数据,并根据compoundName转map + Map<String, TestRecordSampleData> stdTestDataMap = testRecordSampleDataList + .stream() + .filter(testRecordSampleData -> testRecordSampleData.getSampleType().equals(TestRecordSampleDataConstant.SAMPLE_TYPE_STD)) + .collect(Collectors.toMap(TestRecordSampleData::getCompoundName, Function.identity())); + + testRecordSampleDataList.forEach(testRecordSampleData -> { + TestRecordSampleData std = stdTestDataMap.get(testRecordSampleData.getCompoundName()); + + if ( std != null && testRecordSampleData.getTargetRtTime() != null && std.getTargetRtTime() != null ) { testRecordSampleData.setRtTimeError(processInspectDataService.getHairCaseRtTimeError(testRecordSampleData.getTargetRtTime(), std.getTargetRtTime())); - testRecordSampleData.setRtTimeWithinError( - processInspectDataService.getRtWithinErrorText( - Math.abs(testRecordSampleData.getRtTimeError().doubleValue()), - 1 - ) - ); + if (businessType.equals(BusinessType.BOINT_CASE.getBusinessType())) { + testRecordSampleData.setRtTimeWithinError( + processInspectDataService.setHairCaseRtTimeWithinError( + testRecordSampleData.getRtTimeError().doubleValue() + ) + ); + } else { + testRecordSampleData.setRtTimeWithinError( + processInspectDataService.getRtWithinErrorText( + Math.abs(testRecordSampleData.getRtTimeError().doubleValue()), + 1 + ) + ); + } } - } - return this.updateById(testRecordSampleData); + }); + + return this.updateBatchById(testRecordSampleDataList); } @Override