爱医声对接。

This commit is contained in:
haown 2024-08-21 17:58:34 +08:00
parent e480d521ef
commit 43432e3d2b
13 changed files with 563 additions and 8 deletions

View File

@ -13,22 +13,42 @@ public enum PhoneRedialTimesEnum {
/**
* 重拨一次
*/
REDIAL_ONCE("REDIAL_ONCE"),
REDIAL_ONCE("REDIAL_ONCE", 1),
/**
* 重拨二次
*/
REDIAL_TWICE("REDIAL_TWICE"),
REDIAL_TWICE("REDIAL_TWICE", 2),
/**
* 不重播
*/
NOT_REPLAY("NOT_REPLAY"),
NOT_REPLAY("NOT_REPLAY", 0),
;
final private String info;
PhoneRedialTimesEnum(String info) {
this.info = info;
}
final private Integer value;
PhoneRedialTimesEnum(String info, Integer value) {
this.info = info;
this.value = value;
}
public String getInfo() {
return info;
}
public Integer getValue() {
return value;
}
public static PhoneRedialTimesEnum getValueByInfo(String info) {
for (PhoneRedialTimesEnum phoneRedialTimesEnum : PhoneRedialTimesEnum.values()) {
if (info.equals(phoneRedialTimesEnum.getInfo())) {
return phoneRedialTimesEnum;
}
}
return PhoneRedialTimesEnum.NOT_REPLAY;
}
}

View File

@ -0,0 +1,51 @@
package com.xinelu.manage.controller.signpatientmanageroutenode;
import com.aliyuncs.exceptions.ClientException;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.domain.R;
import com.xinelu.manage.dto.signpatientmanageroutenode.TaskStatusDto;
import com.xinelu.manage.dto.signpatientmanageroutenode.UploadRobotPublishTaskDto;
import com.xinelu.manage.service.signpatientmanageroutenode.IRobotPublishService;
import io.swagger.annotations.Api;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description: 爱医声接口对接控制器
* @author: haown
* @create: 2024-08-16 10:48
**/
@Api(tags = "签约患者管理任务路径节点控制器")
@RestController
@RequestMapping("/api")
public class RobotPublishController {
@Resource
private IRobotPublishService robotPublishService;
/**
* 上传任务
* @param body
* @return
*/
@PostMapping("/uploadRobotPublishTask")
public R<String> uploadRobotPublishTask(@RequestBody(required = false) UploadRobotPublishTaskDto body) {
robotPublishService.uploadRobotPublishTask(body);
return R.ok();
}
@PostMapping("/push_robot_publish_task_status")
public AjaxResult push_robot_publish_task_status(@RequestBody(required = false) TaskStatusDto body) throws ClientException {
// TaskStatusDto(id=TK1824283980640428032IK4, yw_task_id=16, task_status=3)
robotPublishService.updateTaskStatus(body);
AjaxResult ajax = AjaxResult.success();
ajax.put("code", body);
ajax.put("msg", "xxxx");
System.out.println(body.toString());
return ajax;
}
}

View File

@ -83,6 +83,16 @@ public class PatientTaskExecuteRecord extends BaseEntity {
@Excel(name = "任务内容电话外呼PHONE_OUTBOUND问卷量表QUESTIONNAIRE_SCALE宣教文章PROPAGANDA_ARTICLE文字提醒TEXT_REMIND")
private String taskNodeType;
/**
* 执行结果记录(电话反馈)
*/
private String executeResult;
/**
* 默认已接通CONNECTED未接通:NOTCONNECTED
*/
private String phoneConnectStatus;
/**
* 任务执行时间格式yyyy-MM-dd HH:mm:ss
*/

View File

@ -0,0 +1,56 @@
package com.xinelu.manage.dto.signpatientmanageroutenode;
import com.alibaba.fastjson2.JSONObject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description: 爱医声任务对象
* @author: haown
* @create: 2024-08-15 16:13
**/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class RobotTaskDto {
/**
* 远程业务任务iD
*/
private String yw_task_id;
private String user_name;
private String user_tel;
private Boolean task_status_push_on;
private String task_status_push_url;
private String task_status_push_label;
private JSONObject tel_line;
/**
* 开始日期
*/
private String start_date_format;
/**
* 结束日期
*/
private String end_date_format;
/**
* 任务开始时间
*/
private String start_time_format;
/**
* 任务结束时间
*/
private String end_time_format;
}

View File

@ -0,0 +1,25 @@
package com.xinelu.manage.dto.signpatientmanageroutenode;
import lombok.Data;
/**
* @description: 爱医声任务状态结果传输对象
* @author: haown
* @create: 2024-08-16 10:52
**/
@Data
public class TaskStatusDto {
/**
* 本地任务ID
*/
private String id;
/**
* 远程业务层任务ID(爱医声平台任务id)
*/
private String yw_task_id;
/**
* 任务状态
*/
private String task_status;
}

View File

@ -0,0 +1,24 @@
package com.xinelu.manage.dto.signpatientmanageroutenode;
import com.alibaba.fastjson2.JSONObject;
import java.util.List;
import lombok.Data;
/**
* @description: 爱医声上传任务接口传输对象
* @author: haown
* @create: 2024-08-15 15:46
**/
@Data
public class UploadRobotPublishTaskDto {
/**
* 爱医声平台机器人ID
*/
private String robot_publish_id;
/**
* 任务列表
*/
List<JSONObject> tasks;
}

View File

@ -2,14 +2,17 @@ package com.xinelu.manage.service.signpatientmanageroute;
import com.aliyuncs.exceptions.ClientException;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.exception.ServiceException;
import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
import com.xinelu.manage.dto.manualfollowup.ManualFollowUpDTO;
import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitResultDTO;
import com.xinelu.manage.dto.smssend.SmsInfoDTO;
import com.xinelu.manage.vo.manualfollowup.ManualFollowUpVO;
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
import com.xinelu.manage.vo.signpatientmanageroutenode.SignPatientManageNodeAuditVo;
import com.xinelu.manage.vo.signpatientrecord.SignPatientRecordSelectVo;
import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteAuditVo;
import java.time.LocalDateTime;
import java.util.List;
/**
@ -115,4 +118,8 @@ public interface ISignPatientManageRouteService {
* @Date 2024-08-01 14:48
*/
List<SignPatientRecordSelectVo> getRecordList(Long patientId);
Boolean sendSms(SmsInfoDTO smsInfoDTO) throws ClientException, ServiceException;
void shortMessageSendRecordExtracted(PatientQuestionSubmitResultDTO dto, LocalDateTime time, Boolean b);
}

View File

@ -426,7 +426,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
smsInfoDTO.setTemplateCode(dto.getPhoneMessageTemplateCode());
Boolean b = sendSms(smsInfoDTO);
//发送记录
ShortMessageSendRecordExtracted(dto, time, b);
shortMessageSendRecordExtracted(dto, time, b);
if (!b) {
log.info("短信发送失败");
} else {
@ -495,7 +495,8 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
* @param time 时间
* @param b 状态
*/
private void ShortMessageSendRecordExtracted(PatientQuestionSubmitResultDTO dto, LocalDateTime time, Boolean b) {
@Override
public void shortMessageSendRecordExtracted(PatientQuestionSubmitResultDTO dto, LocalDateTime time, Boolean b) {
ShortMessageSendRecord shortMessageSendRecord = new ShortMessageSendRecord();
shortMessageSendRecord.setPatientId(dto.getPatientId());
shortMessageSendRecord.setPatientPhone(dto.getPatientPhone());
@ -1051,6 +1052,7 @@ public class SignPatientManageRouteServiceImpl implements ISignPatientManageRout
/**
* 发送短信
*/
@Override
public Boolean sendSms(SmsInfoDTO smsInfoDTO) throws ClientException, ServiceException {
try {
// 短信发送参数非空性判断

View File

@ -0,0 +1,24 @@
package com.xinelu.manage.service.signpatientmanageroutenode;
import com.aliyuncs.exceptions.ClientException;
import com.xinelu.manage.dto.signpatientmanageroutenode.TaskStatusDto;
import com.xinelu.manage.dto.signpatientmanageroutenode.UploadRobotPublishTaskDto;
/**
* 爱医声接口对接Service接口
*
* @author haown
* @date 2024-08-15
*/
public interface IRobotPublishService {
/**
* @description 上传任务
* @param uploadRobotPublishTaskDto 爱医声上传任务接口传输对象
* @Author haown
* @Date 2024-8-16 9:18
*/
void uploadRobotPublishTask(UploadRobotPublishTaskDto uploadRobotPublishTaskDto);
int updateTaskStatus(TaskStatusDto body) throws ClientException;
}

View File

@ -0,0 +1,238 @@
package com.xinelu.manage.service.signpatientmanageroutenode.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.exceptions.ClientException;
import com.xinelu.common.config.AliYunSmsTwoConfig;
import com.xinelu.common.constant.PhoneMessageRemindConstants;
import com.xinelu.common.constant.TaskCreateTypeConstant;
import com.xinelu.common.constant.TaskStatisticsTypeConstants;
import com.xinelu.common.enums.NodeExecuteResultStatusEnum;
import com.xinelu.common.enums.NodeExecuteStatusEnum;
import com.xinelu.common.enums.PhoneRedialTimesEnum;
import com.xinelu.manage.domain.patienttaskexecuterecord.PatientTaskExecuteRecord;
import com.xinelu.manage.domain.phonedialrecord.PhoneDialRecord;
import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
import com.xinelu.manage.domain.textmessage.TextMessage;
import com.xinelu.manage.dto.patientquestionsubmitresult.PatientQuestionSubmitResultDTO;
import com.xinelu.manage.dto.signpatientmanageroutenode.TaskStatusDto;
import com.xinelu.manage.dto.signpatientmanageroutenode.UploadRobotPublishTaskDto;
import com.xinelu.manage.dto.smssend.SmsInfoDTO;
import com.xinelu.manage.mapper.patienttaskexecuterecord.PatientTaskExecuteRecordMapper;
import com.xinelu.manage.mapper.phonedialrecord.PhoneDialRecordMapper;
import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper;
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper;
import com.xinelu.manage.mapper.textmessage.TextMessageMapper;
import com.xinelu.manage.service.patienttaskstatistics.IPatientTaskStatisticsService;
import com.xinelu.manage.service.signpatientmanageroute.ISignPatientManageRouteService;
import com.xinelu.manage.service.signpatientmanageroutenode.IRobotPublishService;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
/**
* @description: 爱医生接口对接Service实现
* @author: haown
* @create: 2024-08-16 09:16
**/
@Slf4j
@Service
public class RobotPublishServiceImpl implements IRobotPublishService {
@Value("${aifuv-robots.url}")
private String url;
@Value("${aifuv-robots.secrectKey}")
private String secrectKey;
@Resource
private SignPatientRecordMapper signPatientRecordMapper;
@Resource
private SignPatientManageRouteMapper signPatientManageRouteMapper;
@Resource
private SignPatientManageRouteNodeMapper signPatientManageRouteNodeMapper;
@Resource
private PhoneDialRecordMapper phoneDialRecordMapper;
@Resource
private PatientTaskExecuteRecordMapper patientTaskExecuteRecordMapper;
@Resource
private IPatientTaskStatisticsService patientTaskStatisticsService;
@Resource
private AliYunSmsTwoConfig aliYunSmsTwoConfig;
@Resource
private ISignPatientManageRouteService signPatientManageRouteService;
@Resource
private TextMessageMapper textMessageMapper;
/**
* @description 上传任务
* @param uploadRobotPublishTaskDto 爱医声上传任务接口传输对象
* @Author haown
* @Date 2024-8-16 9:18
*/
@Override
public void uploadRobotPublishTask(UploadRobotPublishTaskDto uploadRobotPublishTaskDto) {
uploadRobotPublishTaskDto.setRobot_publish_id("RBP1820694580367073280uQ6");
JSONObject params = new JSONObject();
JSONObject telLine = new JSONObject();
JSONObject variables = new JSONObject();
variables.fluentPut("patient_name", "郝伟娜")
.fluentPut("department_name", "山东省立医院");
telLine.fluentPut("enable", "id")
.fluentPut("id", "TL1466655883911110656")
.fluentPut("gatewayaddress", "192.168.110.111");
params.fluentPut("yw_task_id", "18")
.fluentPut("user_name", "郝伟娜")
.fluentPut("user_tel", "15166940975")
.fluentPut("task_status_push_on", false)
.fluentPut("task_status_push_url", "http://8.131.93.145:54011/api/push_robot_publish_task_status")
.fluentPut("task_status_push_label", "VT01")
.fluentPut("tel_line", telLine)
.fluentPut("start_question_id", "QN1820702693098921984Yk2")
.fluentPut("start_date_format", "2024-08-16")
.fluentPut("end_date_format", "2024-08-16")
.fluentPut("invalid_date_format", new ArrayList<>())
.fluentPut("valid_date_format", new ArrayList<>())
.fluentPut("start_time_format", "00:00:00")
.fluentPut("end_time_format", "23:59:59")
.fluentPut("invalid_time_format", new ArrayList<>())
.fluentPut("valid_time_format", new ArrayList<>())
.fluentPut("variables", variables);
JSONObject task = new JSONObject();
task.fluentPut("params", params);
List<JSONObject> tasks = new ArrayList<>();
tasks.add(task);
uploadRobotPublishTaskDto.setTasks(tasks);
System.out.println((JSONObject)JSON.toJSON(uploadRobotPublishTaskDto));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject)JSON.toJSON(uploadRobotPublishTaskDto), headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(url + "api/upload_robot_publish_task/?secret_key=" + secrectKey, HttpMethod.POST, requestEntity, String.class);
System.out.println(responseEntity.getBody());
JSONObject.parseObject(responseEntity.getBody());
//{"code": 200, "res": {"tasks": [{"id": "TK1824283980640428032IK4", "yw_task_id": "16"}]}, "msg": "success"}
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateTaskStatus(TaskStatusDto body) throws ClientException {
// 是否发送短信标识
boolean needSendSms = false;
// 根据id查询任务
SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(Long.valueOf(body.getId()));
if (ObjectUtils.isNotEmpty(signPatientManageRouteNode)) {
// 标记任务执行状态
signPatientManageRouteNode.setNodeExecuteStatus(NodeExecuteStatusEnum.EXECUTED.getInfo());
// 获取电话已拨打次数
PhoneDialRecord phoneDialRecordQuery = new PhoneDialRecord();
phoneDialRecordQuery.setManageRouteNodeId(signPatientManageRouteNode.getId());
List<PhoneDialRecord> phoneDialRecordList = phoneDialRecordMapper.selectPhoneDialRecordList(phoneDialRecordQuery);
// 电话拨打未成功判断是否需要重拨电话拨打成功设置电话拨通情况为成功
if (!StringUtils.equals("2", body.getTask_status())) {
// 已经拨打的次数
int dialCount = CollectionUtils.isEmpty(phoneDialRecordList) ? 0 : phoneDialRecordList.size() + 1;
if (PhoneRedialTimesEnum.getValueByInfo(signPatientManageRouteNode.getPhoneRedialTimes()).getValue() > dialCount) {
// 需要重拨
} else {
// 不需要重拨设置电话拨通情况
signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo());
}
//电话短信提醒
if (StringUtils.equals(PhoneMessageRemindConstants.NOT_CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) {
// 发送短信
needSendSms = true;
}
} else {
signPatientManageRouteNode.setPhoneNodeExecuteResultStatus(NodeExecuteResultStatusEnum.SUCCESS.getInfo());
if (StringUtils.equals(PhoneMessageRemindConstants.CONNECTED_SEND_MESSAGE, signPatientManageRouteNode.getPhoneMessageRemind())) {
// 发送短信
needSendSms = true;
}
}
PatientTaskExecuteRecord patientTaskExecuteRecord = new PatientTaskExecuteRecord();
BeanUtils.copyProperties(signPatientManageRouteNode, patientTaskExecuteRecord);
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(signPatientManageRouteNode.getManageRouteId());
if (ObjectUtils.isNotEmpty(signPatientManageRoute)) {
patientTaskExecuteRecord.setPatientId(signPatientManageRoute.getPatientId());
patientTaskExecuteRecord.setPatientName(signPatientManageRoute.getPatientName());
// 就诊记录
SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signPatientManageRoute.getSignPatientRecordId());
if (ObjectUtils.isNotEmpty(signPatientRecord)) {
patientTaskExecuteRecord.setVisitRecordId(signPatientRecord.getPatientVisitRecordId());
}
// 发送短信
if (needSendSms) {
sendSms(signPatientManageRoute.getPatientId(), signPatientManageRouteNode);
}
}
// 增加任务执行记录
patientTaskExecuteRecord.setManageRouteNodeId(signPatientManageRouteNode.getId());
patientTaskExecuteRecord.setManageRouteNodeName(signPatientManageRouteNode.getRouteNodeName());
patientTaskExecuteRecord.setExecuteResult(body.getTask_status());
patientTaskExecuteRecord.setExecuteType(TaskCreateTypeConstant.MANUAL_MATCHE);
patientTaskExecuteRecord.setExecuteTime(LocalDateTime.now());
patientTaskExecuteRecord.setCreateTime(LocalDateTime.now());
// 修改任务统计表数据
if (patientTaskExecuteRecordMapper.insertPatientTaskExecuteRecord(patientTaskExecuteRecord) > 0) {
// 任务统计表修改
patientTaskStatisticsService.updateNum(signPatientManageRoute.getPatientId(), TaskStatisticsTypeConstants.TASK_EXECUTE_NUM, 1);
}
}
return 0;
}
public void sendSms(Long patientId, SignPatientManageRouteNode signPatientManageRouteNode) throws ClientException {
TextMessage textMessage = textMessageMapper.selectTextMessageById(signPatientManageRouteNode.getPhoneMessageTemplateId());
if (ObjectUtils.isNotEmpty(textMessage)) {
// 发送短信
SmsInfoDTO smsInfoDTO = new SmsInfoDTO();
String patientPhone = signPatientManageRouteMapper.selectPatientPhone(patientId);
smsInfoDTO.setPhoneNumbers(patientPhone);
smsInfoDTO.setSignName(aliYunSmsTwoConfig.getSignName());
smsInfoDTO.setTemplateCode(textMessage.getTextMessageId());
Boolean b = signPatientManageRouteService.sendSms(smsInfoDTO);
//发送记录
PatientQuestionSubmitResultDTO dto = new PatientQuestionSubmitResultDTO();
dto.setPatientId(patientId);
dto.setPatientPhone(patientPhone);
dto.setManageRouteNodeId(signPatientManageRouteNode.getId());
dto.setPhoneMessageTemplateCode(textMessage.getTextMessageId());
dto.setPhoneMessageTemplateContent(signPatientManageRouteNode.getPhoneMessageTemplateContent());
signPatientManageRouteService.shortMessageSendRecordExtracted(dto, LocalDateTime.now(), b);
if (!b) {
log.info("短信发送失败");
} else {
log.info("短信发送成功");
}
} else {
log.info("短信发送成功");
}
}
}

View File

@ -14,6 +14,7 @@ import com.xinelu.common.constant.VisitMethodConstants;
import com.xinelu.common.enums.MessageStatusEnum;
import com.xinelu.common.enums.NodeExecuteResultStatusEnum;
import com.xinelu.common.enums.NodeExecuteStatusEnum;
import com.xinelu.common.enums.PhoneDialMethodEnum;
import com.xinelu.common.enums.RouteCheckStatusEnum;
import com.xinelu.common.enums.RouteNodeNameEnum;
import com.xinelu.common.exception.ServiceException;
@ -1178,6 +1179,10 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
if (ObjectUtils.isNotEmpty(scriptInfo)) {
// 话术库json内容替换
manageRouteNode.setPhoneNodeContent(getFlowScheme(scriptInfo.getFlowScheme(), labelFieldContentList));
// 节点是否是AI电话
if (StringUtils.equals(PhoneDialMethodEnum.AI.getInfo(), manageRouteNode.getPhoneDialMethod())) {
}
}
break;
}
@ -1214,6 +1219,8 @@ public class SignPatientManageRouteNodeServiceImpl implements ISignPatientManage
.taskFinishNum(BigDecimal.ZERO)
.build());
}
// 任务上传至爱医生
}
private String replaceNodeContent(String nodeContent, List<PatientNodeParamsCurrent> paramsList) {

View File

@ -13,6 +13,8 @@
<result property="manageRouteName" column="manage_route_name"/>
<result property="manageRouteNodeName" column="manage_route_node_name"/>
<result property="taskNodeType" column="task_node_type"/>
<result property="executeResult" column="execute_result"/>
<result property="phoneConnectStatus" column="phone_connect_status"/>
<result property="executeTime" column="execute_time"/>
<result property="executePerson" column="execute_person"/>
<result property="executeType" column="execute_type"/>
@ -33,6 +35,8 @@
manage_route_name,
manage_route_node_name,
task_node_type,
execute_result,
phone_connect_status,
execute_time,
execute_person,
execute_type,
@ -98,6 +102,8 @@
pter.manage_route_name,
pter.manage_route_node_name,
pter.task_node_type,
pter.execute_result,
pter.phone_connect_status,
pter.execute_time,
pter.execute_person,
pter.execute_type,
@ -178,6 +184,10 @@
</if>
<if test="taskNodeType != null">task_node_type,
</if>
<if test="executeResult != null">execute_result,
</if>
<if test="phoneConnectStatus != null">phone_connect_status,
</if>
<if test="executeTime != null">execute_time,
</if>
<if test="executePerson != null">execute_person,
@ -212,6 +222,10 @@
</if>
<if test="taskNodeType != null">#{taskNodeType},
</if>
<if test="executeResult != null">#{executeResult},
</if>
<if test="phoneConnectStatus != null">#{phoneConnectStatus},
</if>
<if test="executeTime != null">#{executeTime},
</if>
<if test="executePerson != null">#{executePerson},
@ -260,6 +274,12 @@
<if test="taskNodeType != null">task_node_type =
#{taskNodeType},
</if>
<if test="executeResult != null">execute_result =
#{executeResult},
</if>
<if test="phoneConnectStatus != null">phone_connect_status =
#{phoneConnectStatus},
</if>
<if test="executeTime != null">execute_time =
#{executeTime},
</if>

View File

@ -0,0 +1,71 @@
package com.xinelu.quartz.task;
import com.xinelu.common.enums.NodeExecuteStatusEnum;
import com.xinelu.common.enums.PhoneDialMethodEnum;
import com.xinelu.common.enums.TaskNodeTypeEnum;
import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord;
import com.xinelu.manage.domain.signpatientmanageroute.SignPatientManageRoute;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
import com.xinelu.manage.dto.signpatientmanageroutenode.SignPatientManageRouteNodeDto;
import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper;
import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper;
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper;
import com.xinelu.manage.service.signpatientmanageroutenode.IRobotPublishService;
import com.xinelu.manage.service.signpatientmanageroutenode.ISignPatientManageRouteNodeService;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
/**
* @description: 爱医声上传任务定时任务
* @author: haown
* @create: 2024-08-19 13:58
**/
@Slf4j
@Component("UploadRobotPublishTask")
public class UploadRobotPublishTask {
@Resource
private SignPatientManageRouteNodeMapper signPatientManageRouteNodeMapper;
@Resource
private ISignPatientManageRouteNodeService signPatientManageRouteNodeService;
@Resource
private SignPatientManageRouteMapper signPatientManageRouteMapper;
@Resource
private SignPatientRecordMapper signPatientRecordMapper;
@Resource
private PatientVisitRecordMapper patientVisitRecordMapper;
@Resource
private IRobotPublishService robotPublishService;
public void uploadRobotPublishTask() {
log.info("开始执行爱医声上传任务定时任务......");
// 查找需要当天执行的AI打电话任务
SignPatientManageRouteNodeDto signPatientManageRouteNodeDto = new SignPatientManageRouteNodeDto();
signPatientManageRouteNodeDto.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo());
signPatientManageRouteNodeDto.setNodeExecuteStatus(NodeExecuteStatusEnum.UNEXECUTED.getInfo());
signPatientManageRouteNodeDto.setPhoneDialMethod(PhoneDialMethodEnum.AI.getInfo());
List<SignPatientManageRouteNode> nodeList = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeList(signPatientManageRouteNodeDto);
List<SignPatientManageRouteNode> executeNodeList = new ArrayList<>();
nodeList.forEach(node -> {
SignPatientManageRoute signPatientManageRoute = signPatientManageRouteMapper.selectSignPatientManageRouteById(node.getManageRouteId());
SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(signPatientManageRoute.getSignPatientRecordId());
PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.selectPatientVisitRecordById(signPatientRecord.getPatientVisitRecordId());
LocalDateTime executeTime = signPatientManageRouteNodeService.getExecuteTime(node.getExecuteTime(), node.getRouteNodeName(), node.getRouteNodeDay(), patientVisitRecord);
if (executeTime.toLocalDate().isBefore(LocalDate.now())) {
executeNodeList.add(node);
}
});
if (CollectionUtils.isNotEmpty(executeNodeList)) {
//robotPublishService.uploadRobotPublishTask(executeNodeList);
}
}
}