diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordController.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordController.java index f5138b0..ac36954 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordController.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/controller/TestRecordController.java @@ -212,6 +212,7 @@ public class TestRecordController { } } + @ApiOperation("生成检验记录-贵阳禁毒") @GetMapping("/inspectionRecord") public R inspectionRecord(String entrustId) throws Exception { return testRecordService.inspectionRecord(entrustId); diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordService.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordService.java index 5c91f61..3f5690c 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordService.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/TestRecordService.java @@ -7,6 +7,7 @@ import digital.laboratory.platform.common.core.util.R; import digital.laboratory.platform.common.mybatis.security.service.DLPUser; import digital.laboratory.platform.inspection.dto.DeleteTestAtlasDTO; import digital.laboratory.platform.inspection.dto.TestRecordDto; +import digital.laboratory.platform.inspetion.api.entity.EntrustInfo; import digital.laboratory.platform.inspetion.api.entity.TestRecord; import digital.laboratory.platform.inspection.vo.ProcedureVo; import digital.laboratory.platform.inspetion.api.vo.TestRecordVo; @@ -90,5 +91,18 @@ public interface TestRecordService extends IService { */ R> queryTestRecordInfoByBusinessId(List businessIds); + /** + * 生成检验记录-贵阳禁毒 + * @param entrustId 委托id + * @return + * @throws Exception + */ R inspectionRecord(String entrustId) throws Exception; + + /** + * 根据业务id获取实验检验记录 + * @param businessId + * @return + */ + TestRecord getTestRecordByBusinessId(String businessId); } diff --git a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java index 924c3ee..faefc52 100644 --- a/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java +++ b/dlp-drugtesting-biz/src/main/java/digital/laboratory/platform/inspection/service/impl/TestRecordServiceImpl.java @@ -97,6 +97,20 @@ public class TestRecordServiceImpl extends ServiceImpl dataSolutionSampleDTOS = testRecordSampleDataMapper + .queryDataSolutionSampleDTOList(Wrappers.query() + .eq("si.business_id", businessId)); + TestRecord testRecord = super.getById(dataSolutionSampleDTOS.get(0).getTestId()); + return testRecord; + } + /** * 创建一个实验 * @@ -1527,6 +1541,12 @@ public class TestRecordServiceImpl extends ServiceImpl invivoRecord(EntrustInfo entrustInfo) throws Exception { - HashMap data = new HashMap<>(); + // 这里因为检验记录实体并未关联业务id, 只能先查询实验数据,在通过实验数据获取到检验记录信息 + TestRecord testRecord = getTestRecordByBusinessId(entrustInfo.getId()); - data.put("entrustDepartment", entrustInfo.getEntrustDepartment()); - data.put("deliver1Name", entrustInfo.getDeliver1Name()); - data.put("deliver2Name", entrustInfo.getDeliver2Name()); - data.put("year", entrustInfo.getAcceptDate().getYear()); - data.put("month", entrustInfo.getAcceptDate().getMonthValue()); - data.put("day", entrustInfo.getAcceptDate().getDayOfMonth()); + HashMap data = buildCommonInspectRecordDocMap(entrustInfo, testRecord); List sampleIdList = sampleInfoService.list(Wrappers.lambdaQuery() .eq(SampleInfo::getBusinessId, entrustInfo.getId())) .stream().map(SampleInfo::getId) .collect(Collectors.toList()); - TestRecord testRecord = new TestRecord(); - - for (String sampleId : sampleIdList) { - TestRecord record = this.getOne(Wrappers.lambdaQuery() - .like(TestRecord::getSampleTestList, sampleId)); - if (record != null) { - testRecord = record; - break; - } - } List instruments = testRecordInstrumentService.list(Wrappers.lambdaQuery() .in(TestRecordInstrument::getId, testRecord.getDeviceIdList())); @@ -1583,36 +1589,6 @@ public class TestRecordServiceImpl extends ServiceImpl references = testRecordReagentService.list(Wrappers.lambdaQuery() - .in(TestRecordReagent::getId, testRecord.getReagentConsumablesList()) - .eq(TestRecordReagent::getCategory, "标准物质")); - - if (references == null || references.size() == 0) { - data.put("referenceMaterialName", "未找到试剂耗材数据!"); - }else { - - String referenceMaterialName = references.stream() - .map(reagent -> "\u2611" + " " + reagent.getReagentConsumableName()) - .collect(Collectors.joining("\n")); - - data.put("referenceMaterialName", referenceMaterialName); - } - - - List reagents = testRecordReagentService.list(Wrappers.lambdaQuery() - .in(TestRecordReagent::getId, testRecord.getReagentConsumablesList()) - .eq(TestRecordReagent::getCategory, "试剂")); - - - - if (reagents == null || reagents.size() == 0) { - data.put("reagentConsumableName", "未找到试剂耗材数据!"); - } else { - String reagentConsumableName = reagents.stream() - .map(TestRecordReagent::getReagentConsumableName) - .collect(Collectors.joining("、")); - data.put("reagentConsumableName", reagentConsumableName); - } List hairDataDtos = (List) testRecordSampleDataService.getSampleTestDataByBusiness(entrustInfo.getId()); @@ -1759,4 +1735,82 @@ public class TestRecordServiceImpl extends ServiceImpl docMap = buildCommonDrugDocMap(entrustId); + } + + /** + * 构建常规毒品的检验记录数据 + * @return + */ + private Map buildCommonDrugDocMap(String entrustId) { + EntrustInfo entrustInfo = entrustInfoService.getById(entrustId); + + // 这里因为检验记录实体并未关联业务id, 只能先查询实验数据,在通过实验数据获取到检验记录信息 + TestRecord testRecord = getTestRecordByBusinessId(entrustInfo.getId()); + + // 封装数据到map中 + Map docMap = buildCommonInspectRecordDocMap(entrustInfo, testRecord); + + return null; + } + + + + /** + * 构建通用的检验记录文档映射 + * + * @param entrustInfo 委托信息对象 + * @return 包含委托信息和检验记录信息的HashMap对象 + */ + private HashMap buildCommonInspectRecordDocMap(EntrustInfo entrustInfo, TestRecord testRecord) { + HashMap data = new HashMap<>(); + + data.put("entrustDepartment", entrustInfo.getEntrustDepartment()); + data.put("deliver1Name", entrustInfo.getDeliver1Name()); + data.put("deliver2Name", entrustInfo.getDeliver2Name()); + // 受理日期 + data.put("acceptYear", entrustInfo.getAcceptDate().getYear()); + data.put("acceptMonth", entrustInfo.getAcceptDate().getMonthValue()); + data.put("acceptDay", entrustInfo.getAcceptDate().getDayOfMonth()); + + // 检验日期 + data.put("inspectYear", testRecord.getTestStartDate().getYear()); + data.put("inspectMonth", testRecord.getTestStartDate().getMonthValue()); + data.put("inspectDay", testRecord.getTestStartDate().getDayOfMonth()); + + // 设置使用的标准物质和试剂 + List references = testRecordReagentService.list(Wrappers.lambdaQuery() + .in(TestRecordReagent::getId, testRecord.getReagentConsumablesList()) + .eq(TestRecordReagent::getCategory, "标准物质")); + + if (references == null || references.size() == 0) { + data.put("referenceMaterialName", "未找到试剂耗材数据!"); + }else { + + String referenceMaterialName = references.stream() + .map(reagent -> "\u2611" + " " + reagent.getReagentConsumableName()) + .collect(Collectors.joining("\n")); + + data.put("referenceMaterialName", referenceMaterialName); + } + + List reagents = testRecordReagentService.list(Wrappers.lambdaQuery() + .in(TestRecordReagent::getId, testRecord.getReagentConsumablesList()) + .eq(TestRecordReagent::getCategory, "试剂")); + + if (reagents == null || reagents.size() == 0) { + data.put("reagentConsumableName", "未找到试剂耗材数据!"); + } else { + String reagentConsumableName = reagents.stream() + .map(TestRecordReagent::getReagentConsumableName) + .collect(Collectors.joining("、")); + data.put("reagentConsumableName", reagentConsumableName); + } + return data; + } }