From 540b4f89a316a616a22d261c20226dd2fd94066d Mon Sep 17 00:00:00 2001 From: zhangheng <3226558941@qq.com> Date: Mon, 17 Mar 2025 15:12:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=8F=96=E6=B6=88=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E4=BD=8D=E6=95=B0=E6=A0=A1=E9=AA=8C=EF=BC=8C=E5=A4=96?= =?UTF-8?q?=E5=91=BC=E5=8A=A0=E5=85=A5=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PatientInfoServiceImpl.java | 91 ++++++++++--------- .../quartz/task/UploadRobotPublishTask.java | 47 +++++----- 2 files changed, 71 insertions(+), 67 deletions(-) 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 7fb950ac..31369da5 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 @@ -1,7 +1,6 @@ package com.xinelu.manage.service.patientinfo.impl; import com.xinelu.common.annotation.DataScope; -import com.xinelu.common.constant.HttpStatus; import com.xinelu.common.constant.SignRecordServiceStatusConstants; import com.xinelu.common.constant.VisitMethodConstants; import com.xinelu.common.core.domain.AjaxResult; @@ -44,7 +43,6 @@ import com.xinelu.system.mapper.SysUserMapper; import com.xinelu.system.service.ISysConfigService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -370,19 +368,19 @@ public class PatientInfoServiceImpl implements IPatientInfoService { if (CollectionUtils.isEmpty(list) || list.size() == 0) { return AjaxResult.error("导入数据列表不能为空!"); } - //如果存在 患者姓名或手机号或科室或就诊日期为空的情况,直接返回; - List collect = list.stream().filter(Objects::nonNull).filter(item -> StringUtils.isEmpty(item.getPatientName()) || StringUtils.isEmpty(item.getPatientPhone()) || StringUtils.isEmpty(item.getDeptAlias()) || Objects.isNull(item.getVisitDate())).collect(Collectors.toList()); + //如果存在 患者姓名或手机号或科室或就诊日期为空的情况,直接返回;(暂时去除时间判断) + List collect = list.stream().filter(Objects::nonNull).filter(item -> StringUtils.isEmpty(item.getPatientName()) || StringUtils.isEmpty(item.getDeptAlias()) || Objects.isNull(item.getVisitDate())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect)) { - return AjaxResult.error("用户信息不完整,科室名称、就诊时间、姓名、联系电话均不允许为空,请完善后重试;"); + return AjaxResult.error("用户信息不完整,科室名称、就诊时间、姓名均不允许为空,请完善后重试;"); } //存在手机号格式不正确的情况,直接返回 - List regexPhoneList = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(regexPhoneList)) { - return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList); - } +// List regexPhoneList = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).collect(Collectors.toList()); +// if (CollectionUtils.isNotEmpty(regexPhoneList)) { +// return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList); +// } //导入重复过滤,列表内患者信息自去重; List distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); - //与数据库重复 + //与数据库重复(当天数据) List patientInfos_CurrentDay = new ArrayList<>(); List residentInfos = residentInfoMapper.selectResidentInfoByPhoneList(list); //如果要求自动去重(同数据库中 当日已导入患者列表 比对,如果患者姓名和手机号相同,视为重复) @@ -425,8 +423,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService { // continue; // } // } - // 如果当日已有导入,则不再重复导入 - if (CollectionUtils.isNotEmpty(patientInfos_CurrentDay) && (Objects.isNull(isDistinct) || isDistinct == 1)) { + // 如果当日已有导入,则不再重复导入(导入数据存在手机号为空) + if (CollectionUtils.isNotEmpty(patientInfos_CurrentDay) && (Objects.isNull(isDistinct) || isDistinct == 1) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) { List collect1 = patientInfos_CurrentDay.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) { continue; @@ -446,7 +444,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService { patientInfoImport.setDepartmentId(equalsDepartment.getId()); patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName()); //同一手机号每月可最多拔打xx次 - if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount)) { + if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) { List collect1 = patientInfoList.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientPhone().equals(item.getPatientPhone()) && patientInfoImport.getDepartmentId().equals(item.getDepartmentId()) && item.getCountPhone() >= Long.parseLong(aiobMaxCount)).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) { continue; @@ -464,7 +462,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService { patientInfoImport.setDepartmentId(containsDepartment.getId()); patientInfoImport.setDepartmentName(containsDepartment.getDepartmentName()); //同一手机号每月可最多拔打xx次 - if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount)) { + if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) { List collect1 = patientInfoList.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientPhone().equals(item.getPatientPhone()) && patientInfoImport.getDepartmentId().equals(item.getDepartmentId()) && item.getCountPhone() >= Long.parseLong(aiobMaxCount)).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) { continue; @@ -520,11 +518,12 @@ public class PatientInfoServiceImpl implements IPatientInfoService { if (CollectionUtils.isNotEmpty(deptAliasVOS)) { return AjaxResult.error("科室名称不存在", patientInfoImportVO); } - //region 新增居民表 - patientInfoImportList.forEach(item -> - { - //设置导入记录ID - item.setPatientInfoImportId(item.getId()); + //region 新增居民表 + patientInfoImportList.forEach(item -> + { + //设置导入记录ID + item.setPatientInfoImportId(item.getId()); + if (org.apache.commons.lang3.StringUtils.isNotBlank(item.getPatientPhone())) { //居民信息去重 if (residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName()) && residentInfo.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toSet()).size() == 0) { @@ -536,23 +535,26 @@ public class PatientInfoServiceImpl implements IPatientInfoService { item.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName()) && residentInfo.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId()); } + } else { + patientInfoImportList_forResident.add(item); + } + } + ); + if (patientInfoImportList_forResident.size() > 0) { + int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImportList_forResident); + if (residentCount <= 0) { + log.info("居民表新增失败!"); + return AjaxResult.error("居民信息新增失败;"); + } + patientInfoImportList_forResident.forEach(item -> + { + patientInfoImportList.stream().filter(item2 -> item2.getPatientName().equals(item.getPatientName()) + && (item2.getPatientPhone() == null ? ' ' : item2.getPatientPhone()).equals((item.getPatientPhone() == null ? ' ' : item.getPatientPhone()))).findFirst().orElse(new PatientInfoImport()) + .setResidentId(item.getId()); } ); - if (patientInfoImportList_forResident.size() > 0) { - int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImportList_forResident); - if (residentCount <= 0) { - log.info("居民表新增失败!"); - return AjaxResult.error("居民信息新增失败;"); - } - patientInfoImportList_forResident.forEach(item -> - { - patientInfoImportList.stream().filter(item2 -> item2.getPatientName().equals(item.getPatientName()) - && item2.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()) - .setResidentId(item.getId()); - } - ); - } - //endregion + } + //endregion //设置为门诊患者 patientInfoImportList.forEach(item -> @@ -653,12 +655,16 @@ public class PatientInfoServiceImpl implements IPatientInfoService { 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) { + if (org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) { + 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()); + } + } else { 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()); } } } @@ -690,13 +696,14 @@ public class PatientInfoServiceImpl implements IPatientInfoService { } } //新增居民表 - if (CollectionUtils.isNotEmpty(insertResidentInfo) || insertResidentInfo.size() != 0){ + if (CollectionUtils.isNotEmpty(insertResidentInfo) || insertResidentInfo.size() != 0) { int residentCount = residentInfoMapper.insertResidentInfoList(insertResidentInfo); if (residentCount <= 0) { return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); } - insertResidentInfo.forEach(item -> { patientInfoImports.stream().filter(patientInfoImport -> patientInfoImport.getPatientName().equals(item.getPatientName()) - && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()).setResidentId(item.getId()); + insertResidentInfo.forEach(item -> { + patientInfoImports.stream().filter(patientInfoImport -> patientInfoImport.getPatientName().equals(item.getPatientName()) + && (patientInfoImport.getPatientPhone() == null ? ' ' : patientInfoImport.getPatientPhone()).equals((item.getPatientPhone() == null ? ' ' : item.getPatientPhone()))).findFirst().orElse(new PatientInfoImport()).setResidentId(item.getId()); } ); } diff --git a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java index 23277447..9e0a9001 100644 --- a/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java +++ b/postdischarge-quartz/src/main/java/com/xinelu/quartz/task/UploadRobotPublishTask.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.xinelu.common.constant.AiobTaskTypeContant; import com.xinelu.common.enums.*; import com.xinelu.common.utils.StringUtils; +import com.xinelu.common.utils.regex.RegexUtil; import com.xinelu.manage.domain.patientinfo.PatientInfo; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; import com.xinelu.manage.domain.scriptInfo.ScriptInfo; @@ -74,6 +75,8 @@ public class UploadRobotPublishTask { private PatientInfoMapper patientInfoMapper; @Resource private LabelFieldContentMapper labelFieldContentMapper; + @Resource + private RegexUtil regexUtil; /** * @description 创建百度智能外呼任务并导入客户名单 @@ -183,10 +186,7 @@ public class UploadRobotPublishTask { scriptInfoTaskInfo.setAiobTaskType(AiobTaskTypeContant.BATCHTASK); //进入拔打记录表(用于后续重拨处理等判断)----有时间再优化为批量插入 scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo); - }); - - //3、开始组装本任务下的客户变量 // 客户名单list List customerInfoList = new ArrayList<>(); @@ -196,21 +196,25 @@ public class UploadRobotPublishTask { customerInfoDto.setExtJson(node.getId() + ""); SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); - customerInfoDto.setMobile(patientInfo.getPatientPhone()); - // 查询患者画像信息 - List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId()); - // 处理变量 - JSONObject jsonObject = new JSONObject(); - if (StringUtils.isNotBlank(scriptInfo.getVariables())) { - List variables = Arrays.asList(scriptInfo.getVariables().split("\\|")); - variables.forEach(variable -> { - LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), variable.replaceAll("_", "").toUpperCase())).findFirst().orElse(null); - jsonObject.fluentPut(variable, ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); - }); + //校验手机号 + if (org.apache.commons.lang3.StringUtils.isNotBlank(patientInfo.getPatientPhone())) { + if (regexUtil.regexPhone(patientInfo.getPatientPhone())) { + customerInfoDto.setMobile(patientInfo.getPatientPhone()); + // 查询患者画像信息 + List labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId()); + // 处理变量 + JSONObject jsonObject = new JSONObject(); + if (StringUtils.isNotBlank(scriptInfo.getVariables())) { + List variables = Arrays.asList(scriptInfo.getVariables().split("\\|")); + variables.forEach(variable -> { + LabelFieldInfoContentVo labelFieldContent = labelFieldContentList.stream().filter(s -> Objects.equals(s.getFieldCode(), variable.replaceAll("_", "").toUpperCase())).findFirst().orElse(null); + jsonObject.fluentPut(variable, ObjectUtils.isEmpty(labelFieldContent) ? "" : labelFieldContent.getFieldValue()); + }); + } + customerInfoDto.setVar(jsonObject); + customerInfoList.add(customerInfoDto); + } } - customerInfoDto.setVar(jsonObject); - customerInfoList.add(customerInfoDto); - }); // 上传名单 log.info("任务导入客户名单......"); @@ -235,16 +239,12 @@ public class UploadRobotPublishTask { if (importTaskVo.getStatus()) { signPatientManageRouteNode.setTaskIdExt(finalTaskId); signPatientManageRouteNode.setId(Long.valueOf(importTaskVo.getExtJson())); - signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode); } }); } } - }); - - }); // 根据机器人id查询智能外呼系统的任务id log.info("百度智能外呼创建任务定时任务执行完成......"); @@ -315,7 +315,7 @@ public class UploadRobotPublishTask { SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); // 没有任务则创建任务 - if (ObjectUtils.isNotEmpty(scriptInfo)) { + if (ObjectUtils.isNotEmpty(scriptInfo) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfo.getPatientPhone()) && regexUtil.regexPhone(patientInfo.getPatientPhone())) { log.info("创建任务......"); ActualTimeTaskDto actualTimeTaskDto = new ActualTimeTaskDto(); actualTimeTaskDto.setRobotId(scriptInfo.getRobotPublishId()); @@ -345,9 +345,6 @@ public class UploadRobotPublishTask { signPatientManageRouteNode_DialStatus.setId(node.getId()); signPatientManageRouteNode_DialStatus.setDialStatus(DialStatusEnum.DIALED.getInfo()); signPatientManageRouteNodeMapper.updateDialStatusByNodeId(signPatientManageRouteNode_DialStatus); - - } } - }