导入修改

This commit is contained in:
zhangheng 2024-12-31 17:05:33 +08:00
parent 35bd64d5cd
commit f88b28b243
2 changed files with 14 additions and 2 deletions

View File

@ -64,7 +64,9 @@ public class ImportDownloadController {
file = ResourceUtils.getFile("classpath:template/门诊患者信息导入表.xlsx"); file = ResourceUtils.getFile("classpath:template/门诊患者信息导入表.xlsx");
break; break;
case Constants.PATIENT_INFO_IMPORT: // 门诊患者 case Constants.PATIENT_INFO_IMPORT: // 门诊患者
//本地服务
//file = ResourceUtils.getFile("classpath:template/OutpatientFollowUpRecords.xlsx"); //file = ResourceUtils.getFile("classpath:template/OutpatientFollowUpRecords.xlsx");
//线上服务
Resource resource = new ClassPathResource("classpath:template/OutpatientFollowUpRecords.xlsx"); Resource resource = new ClassPathResource("classpath:template/OutpatientFollowUpRecords.xlsx");
String filePath= this.getClass().getClassLoader().getResource("classpath:template/OutpatientFollowUpRecords.xlsx").getFile(); String filePath= this.getClass().getClassLoader().getResource("classpath:template/OutpatientFollowUpRecords.xlsx").getFile();
file= new File(filePath); file= new File(filePath);

View File

@ -597,12 +597,23 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
if (CollectionUtils.isEmpty(patientInfoImports)) { if (CollectionUtils.isEmpty(patientInfoImports)) {
return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。"); return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。");
} }
List<PatientInfoImport> insertResidentInfo = new ArrayList<>();
List<ResidentInfo> residentInfos = residentInfoMapper.selectResidentInfoByPhoneList(patientInfoImports);
for (PatientInfoImport patientInfoImport : patientInfoImports) { for (PatientInfoImport patientInfoImport : patientInfoImports) {
if (StringUtils.isEmpty(patientInfoImport.getDepartmentName()) || Objects.isNull(patientInfoImport.getDepartmentId())) { 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()); 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()); Department equalsDepartment = departmentList.stream().filter(Objects::nonNull).filter(item -> item.getDepartmentName().equals(deptAliasVO.getDepartmentName())).findFirst().orElse(new Department());
patientInfoImport.setDepartmentId(equalsDepartment.getId()); patientInfoImport.setDepartmentId(equalsDepartment.getId());
patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName()); patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName());
//居民信息去重
patientInfoImport.setPatientInfoImportId(patientInfoImport.getId());
List<ResidentInfo> 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(insertResidentInfo);
int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImports);
if (residentCount <= 0) { if (residentCount <= 0) {
return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。"); return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。");
} }