导入取消手机位数校验,外呼加入校验

This commit is contained in:
zhangheng 2025-03-17 15:12:47 +08:00
parent d82eff7f29
commit 540b4f89a3
2 changed files with 71 additions and 67 deletions

View File

@ -1,7 +1,6 @@
package com.xinelu.manage.service.patientinfo.impl; package com.xinelu.manage.service.patientinfo.impl;
import com.xinelu.common.annotation.DataScope; import com.xinelu.common.annotation.DataScope;
import com.xinelu.common.constant.HttpStatus;
import com.xinelu.common.constant.SignRecordServiceStatusConstants; import com.xinelu.common.constant.SignRecordServiceStatusConstants;
import com.xinelu.common.constant.VisitMethodConstants; import com.xinelu.common.constant.VisitMethodConstants;
import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.domain.AjaxResult;
@ -44,7 +43,6 @@ import com.xinelu.system.mapper.SysUserMapper;
import com.xinelu.system.service.ISysConfigService; import com.xinelu.system.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -370,19 +368,19 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
if (CollectionUtils.isEmpty(list) || list.size() == 0) { if (CollectionUtils.isEmpty(list) || list.size() == 0) {
return AjaxResult.error("导入数据列表不能为空!"); return AjaxResult.error("导入数据列表不能为空!");
} }
//如果存在 患者姓名或手机号或科室或就诊日期为空的情况直接返回 //如果存在 患者姓名或手机号或科室或就诊日期为空的情况直接返回暂时去除时间判断
List<PatientInfoImport> 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<PatientInfoImport> 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)) { if (CollectionUtils.isNotEmpty(collect)) {
return AjaxResult.error("用户信息不完整,科室名称、就诊时间、姓名、联系电话均不允许为空,请完善后重试;"); return AjaxResult.error("用户信息不完整,科室名称、就诊时间、姓名均不允许为空,请完善后重试;");
} }
//存在手机号格式不正确的情况直接返回 //存在手机号格式不正确的情况直接返回
List<PatientInfoImport> regexPhoneList = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).collect(Collectors.toList()); // List<PatientInfoImport> regexPhoneList = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(regexPhoneList)) { // if (CollectionUtils.isNotEmpty(regexPhoneList)) {
return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList); // return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList);
} // }
//导入重复过滤列表内患者信息自去重 //导入重复过滤列表内患者信息自去重
List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
//与数据库重复 //与数据库重复当天数据
List<PatientInfo> patientInfos_CurrentDay = new ArrayList<>(); List<PatientInfo> patientInfos_CurrentDay = new ArrayList<>();
List<ResidentInfo> residentInfos = residentInfoMapper.selectResidentInfoByPhoneList(list); List<ResidentInfo> residentInfos = residentInfoMapper.selectResidentInfoByPhoneList(list);
//如果要求自动去重同数据库中 当日已导入患者列表 比对如果患者姓名和手机号相同视为重复 //如果要求自动去重同数据库中 当日已导入患者列表 比对如果患者姓名和手机号相同视为重复
@ -425,8 +423,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
// continue; // 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<PatientInfo> collect1 = patientInfos_CurrentDay.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toList()); List<PatientInfo> 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) { if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) {
continue; continue;
@ -446,7 +444,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setDepartmentId(equalsDepartment.getId()); patientInfoImport.setDepartmentId(equalsDepartment.getId());
patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName()); patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName());
//同一手机号每月可最多拔打xx次 //同一手机号每月可最多拔打xx次
if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount)) { if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) {
List<PatientInfo> 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()); List<PatientInfo> 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) { if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) {
continue; continue;
@ -464,7 +462,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setDepartmentId(containsDepartment.getId()); patientInfoImport.setDepartmentId(containsDepartment.getId());
patientInfoImport.setDepartmentName(containsDepartment.getDepartmentName()); patientInfoImport.setDepartmentName(containsDepartment.getDepartmentName());
//同一手机号每月可最多拔打xx次 //同一手机号每月可最多拔打xx次
if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount)) { if (CollectionUtils.isNotEmpty(patientInfoList) && StringUtils.isNotBlank(aiobMaxCount) && org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) {
List<PatientInfo> 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()); List<PatientInfo> 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) { if (CollectionUtils.isNotEmpty(collect1) || collect1.size() != 0) {
continue; continue;
@ -525,6 +523,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
{ {
//设置导入记录ID //设置导入记录ID
item.setPatientInfoImportId(item.getId()); item.setPatientInfoImportId(item.getId());
if (org.apache.commons.lang3.StringUtils.isNotBlank(item.getPatientPhone())) {
//居民信息去重 //居民信息去重
if (residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName()) if (residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName())
&& residentInfo.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toSet()).size() == 0) { && residentInfo.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toSet()).size() == 0) {
@ -536,6 +535,9 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
item.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName()) item.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName())
&& residentInfo.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId()); && residentInfo.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId());
} }
} else {
patientInfoImportList_forResident.add(item);
}
} }
); );
if (patientInfoImportList_forResident.size() > 0) { if (patientInfoImportList_forResident.size() > 0) {
@ -547,7 +549,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImportList_forResident.forEach(item -> patientInfoImportList_forResident.forEach(item ->
{ {
patientInfoImportList.stream().filter(item2 -> item2.getPatientName().equals(item.getPatientName()) patientInfoImportList.stream().filter(item2 -> item2.getPatientName().equals(item.getPatientName())
&& item2.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()) && (item2.getPatientPhone() == null ? ' ' : item2.getPatientPhone()).equals((item.getPatientPhone() == null ? ' ' : item.getPatientPhone()))).findFirst().orElse(new PatientInfoImport())
.setResidentId(item.getId()); .setResidentId(item.getId());
} }
); );
@ -653,6 +655,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName()); patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName());
//居民信息去重 //居民信息去重
patientInfoImport.setPatientInfoImportId(patientInfoImport.getId()); patientInfoImport.setPatientInfoImportId(patientInfoImport.getId());
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientInfoImport.getPatientPhone())) {
List<ResidentInfo> collect = residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(patientInfoImport.getPatientName()) && residentInfo.getPatientPhone().equals(patientInfoImport.getPatientPhone())).collect(Collectors.toList()); 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) { if (CollectionUtils.isEmpty(collect) || collect.size() == 0) {
insertResidentInfo.add(patientInfoImport); insertResidentInfo.add(patientInfoImport);
@ -660,6 +663,9 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(patientInfoImport.getPatientName()) patientInfoImport.setResidentId(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(patientInfoImport.getPatientName())
&& residentInfo.getPatientPhone().equals(patientInfoImport.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId()); && residentInfo.getPatientPhone().equals(patientInfoImport.getPatientPhone())).findFirst().orElse(new ResidentInfo()).getId());
} }
} else {
insertResidentInfo.add(patientInfoImport);
}
} }
} }
//科室组装别名 //科室组装别名
@ -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); int residentCount = residentInfoMapper.insertResidentInfoList(insertResidentInfo);
if (residentCount <= 0) { if (residentCount <= 0) {
return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。"); return AjaxResult.error("已完成数据导入导入成功0条记录失败" + patientInfoImportVO.getCount() + "条记录。");
} }
insertResidentInfo.forEach(item -> { patientInfoImports.stream().filter(patientInfoImport -> patientInfoImport.getPatientName().equals(item.getPatientName()) insertResidentInfo.forEach(item -> {
&& patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()).setResidentId(item.getId()); 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());
} }
); );
} }

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
import com.xinelu.common.constant.AiobTaskTypeContant; import com.xinelu.common.constant.AiobTaskTypeContant;
import com.xinelu.common.enums.*; import com.xinelu.common.enums.*;
import com.xinelu.common.utils.StringUtils; 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.patientinfo.PatientInfo;
import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord;
import com.xinelu.manage.domain.scriptInfo.ScriptInfo; import com.xinelu.manage.domain.scriptInfo.ScriptInfo;
@ -74,6 +75,8 @@ public class UploadRobotPublishTask {
private PatientInfoMapper patientInfoMapper; private PatientInfoMapper patientInfoMapper;
@Resource @Resource
private LabelFieldContentMapper labelFieldContentMapper; private LabelFieldContentMapper labelFieldContentMapper;
@Resource
private RegexUtil regexUtil;
/** /**
* @description 创建百度智能外呼任务并导入客户名单 * @description 创建百度智能外呼任务并导入客户名单
@ -183,10 +186,7 @@ public class UploadRobotPublishTask {
scriptInfoTaskInfo.setAiobTaskType(AiobTaskTypeContant.BATCHTASK); scriptInfoTaskInfo.setAiobTaskType(AiobTaskTypeContant.BATCHTASK);
//进入拔打记录表用于后续重拨处理等判断)----有时间再优化为批量插入 //进入拔打记录表用于后续重拨处理等判断)----有时间再优化为批量插入
scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo); scriptInfoTaskInfoMapper.insertScriptInfoTaskInfo(scriptInfoTaskInfo);
}); });
//3开始组装本任务下的客户变量 //3开始组装本任务下的客户变量
// 客户名单list // 客户名单list
List<CustomerInfoDto> customerInfoList = new ArrayList<>(); List<CustomerInfoDto> customerInfoList = new ArrayList<>();
@ -196,6 +196,9 @@ public class UploadRobotPublishTask {
customerInfoDto.setExtJson(node.getId() + ""); customerInfoDto.setExtJson(node.getId() + "");
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId());
//校验手机号
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientInfo.getPatientPhone())) {
if (regexUtil.regexPhone(patientInfo.getPatientPhone())) {
customerInfoDto.setMobile(patientInfo.getPatientPhone()); customerInfoDto.setMobile(patientInfo.getPatientPhone());
// 查询患者画像信息 // 查询患者画像信息
List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId()); List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId());
@ -210,7 +213,8 @@ public class UploadRobotPublishTask {
} }
customerInfoDto.setVar(jsonObject); customerInfoDto.setVar(jsonObject);
customerInfoList.add(customerInfoDto); customerInfoList.add(customerInfoDto);
}
}
}); });
// 上传名单 // 上传名单
log.info("任务导入客户名单......"); log.info("任务导入客户名单......");
@ -235,16 +239,12 @@ public class UploadRobotPublishTask {
if (importTaskVo.getStatus()) { if (importTaskVo.getStatus()) {
signPatientManageRouteNode.setTaskIdExt(finalTaskId); signPatientManageRouteNode.setTaskIdExt(finalTaskId);
signPatientManageRouteNode.setId(Long.valueOf(importTaskVo.getExtJson())); signPatientManageRouteNode.setId(Long.valueOf(importTaskVo.getExtJson()));
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode); signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
} }
}); });
} }
} }
}); });
}); });
// 根据机器人id查询智能外呼系统的任务id // 根据机器人id查询智能外呼系统的任务id
log.info("百度智能外呼创建任务定时任务执行完成......"); log.info("百度智能外呼创建任务定时任务执行完成......");
@ -315,7 +315,7 @@ public class UploadRobotPublishTask {
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId()); SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId()); 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("创建任务......"); log.info("创建任务......");
ActualTimeTaskDto actualTimeTaskDto = new ActualTimeTaskDto(); ActualTimeTaskDto actualTimeTaskDto = new ActualTimeTaskDto();
actualTimeTaskDto.setRobotId(scriptInfo.getRobotPublishId()); actualTimeTaskDto.setRobotId(scriptInfo.getRobotPublishId());
@ -345,9 +345,6 @@ public class UploadRobotPublishTask {
signPatientManageRouteNode_DialStatus.setId(node.getId()); signPatientManageRouteNode_DialStatus.setId(node.getId());
signPatientManageRouteNode_DialStatus.setDialStatus(DialStatusEnum.DIALED.getInfo()); signPatientManageRouteNode_DialStatus.setDialStatus(DialStatusEnum.DIALED.getInfo());
signPatientManageRouteNodeMapper.updateDialStatusByNodeId(signPatientManageRouteNode_DialStatus); signPatientManageRouteNodeMapper.updateDialStatusByNodeId(signPatientManageRouteNode_DialStatus);
} }
} }
} }