导入取消手机位数校验,外呼加入校验
This commit is contained in:
parent
d82eff7f29
commit
540b4f89a3
@ -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<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)) {
|
||||
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());
|
||||
if (CollectionUtils.isNotEmpty(regexPhoneList)) {
|
||||
return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList);
|
||||
}
|
||||
// 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)) {
|
||||
// return AjaxResult.error(HttpStatus.ERROR_TWO, "部分手机号格式不正确,请修改后重试;", regexPhoneList);
|
||||
// }
|
||||
//导入重复过滤,列表内患者信息自去重;
|
||||
List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
//与数据库重复
|
||||
//与数据库重复(当天数据)
|
||||
List<PatientInfo> patientInfos_CurrentDay = new ArrayList<>();
|
||||
List<ResidentInfo> 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<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) {
|
||||
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<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) {
|
||||
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<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) {
|
||||
continue;
|
||||
@ -525,6 +523,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
{
|
||||
//设置导入记录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,6 +535,9 @@ 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) {
|
||||
@ -547,7 +549,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
patientInfoImportList_forResident.forEach(item ->
|
||||
{
|
||||
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());
|
||||
}
|
||||
);
|
||||
@ -653,6 +655,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
patientInfoImport.setDepartmentName(equalsDepartment.getDepartmentName());
|
||||
//居民信息去重
|
||||
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());
|
||||
if (CollectionUtils.isEmpty(collect) || collect.size() == 0) {
|
||||
insertResidentInfo.add(patientInfoImport);
|
||||
@ -660,6 +663,9 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
//科室组装别名
|
||||
@ -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());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -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<CustomerInfoDto> customerInfoList = new ArrayList<>();
|
||||
@ -196,6 +196,9 @@ public class UploadRobotPublishTask {
|
||||
customerInfoDto.setExtJson(node.getId() + "");
|
||||
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
|
||||
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(signPatientManageRoute.getPatientId());
|
||||
//校验手机号
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(patientInfo.getPatientPhone())) {
|
||||
if (regexUtil.regexPhone(patientInfo.getPatientPhone())) {
|
||||
customerInfoDto.setMobile(patientInfo.getPatientPhone());
|
||||
// 查询患者画像信息
|
||||
List<LabelFieldInfoContentVo> labelFieldContentList = labelFieldContentMapper.selectByPatientId(patientInfo.getId());
|
||||
@ -210,7 +213,8 @@ public class UploadRobotPublishTask {
|
||||
}
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user