From f88b28b243f675ea6e622cc50461ecb7dac1fdc7 Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Tue, 31 Dec 2024 17:05:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../importdownload/ImportDownloadController.java | 2 ++ .../patientinfo/impl/PatientInfoServiceImpl.java | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java index 98916f9a..e6c2388c 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/importdownload/ImportDownloadController.java @@ -64,7 +64,9 @@ public class ImportDownloadController { file = ResourceUtils.getFile("classpath:template/门诊患者信息导入表.xlsx"); break; case Constants.PATIENT_INFO_IMPORT: // 门诊患者 + //本地服务 //file = ResourceUtils.getFile("classpath:template/OutpatientFollowUpRecords.xlsx"); + //线上服务 Resource resource = new ClassPathResource("classpath:template/OutpatientFollowUpRecords.xlsx"); String filePath= this.getClass().getClassLoader().getResource("classpath:template/OutpatientFollowUpRecords.xlsx").getFile(); file= new File(filePath); diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java index aef0153e..b6779ee1 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java @@ -597,12 +597,23 @@ public class PatientInfoServiceImpl implements IPatientInfoService { if (CollectionUtils.isEmpty(patientInfoImports)) { return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); } + List insertResidentInfo = new ArrayList<>(); + List residentInfos = residentInfoMapper.selectResidentInfoByPhoneList(patientInfoImports); for (PatientInfoImport patientInfoImport : patientInfoImports) { if (StringUtils.isEmpty(patientInfoImport.getDepartmentName()) || Objects.isNull(patientInfoImport.getDepartmentId())) { DeptAliasVO deptAliasVO = patientInfoImportVO.getDeptAliasVOS().stream().filter(Objects::nonNull).filter(item -> StringUtils.isNotBlank(item.getDepartmentName()) && StringUtils.isNotEmpty(item.getDeptAlias()) && patientInfoImport.getDeptAlias().equals(item.getDeptAlias())).findFirst().orElse(new DeptAliasVO()); Department equalsDepartment = departmentList.stream().filter(Objects::nonNull).filter(item -> item.getDepartmentName().equals(deptAliasVO.getDepartmentName())).findFirst().orElse(new Department()); patientInfoImport.setDepartmentId(equalsDepartment.getId()); patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName()); + //居民信息去重 + patientInfoImport.setPatientInfoImportId(patientInfoImport.getId()); + List collect = residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(patientInfoImport.getPatientName()) && residentInfo.getPatientPhone().equals(patientInfoImport.getPatientPhone())).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect) || collect.size() == 0) { + insertResidentInfo.add(patientInfoImport); + } else { //如果已存在 设置居民ID + patientInfoImport.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(patientInfoImport.getPatientName()) + && residentInfo.getPatientPhone().equals(patientInfoImport.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId()); + } } } //科室组装别名 @@ -633,8 +644,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService { } } //新增居民表 - patientInfoImports.forEach(item -> item.setPatientInfoImportId(item.getId())); - int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImports); + int residentCount = residentInfoMapper.insertResidentInfoList(insertResidentInfo); if (residentCount <= 0) { return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); }