批量任务

This commit is contained in:
zhangheng 2026-04-29 22:33:39 +08:00
parent d7080dd8f3
commit 13e8b15117
11 changed files with 349 additions and 16 deletions

View File

@ -6,15 +6,15 @@ spring:
druid: druid:
# 主库数据源 # 主库数据源
master: master:
url: jdbc:mysql://127.0.0.1:3306/post-discharge-hkey?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true url: jdbc:mysql://8.131.93.145:54081/post-discharge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root username: root
password: Hk2y!@#$ password: 1qaz!@#$
hkhis: hkhis:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: true enabled: true
url: jdbc:mysql://127.0.0.1:3306/post-discharge-hkey?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true url: jdbc:mysql://8.131.93.145:54081/post-discharge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
username: root username: root
password: Hk2y!@#$ password: 1qaz!@#$
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
# 初始连接数 # 初始连接数
initialSize: 5 initialSize: 5

View File

@ -44,6 +44,14 @@ public class BatchSendTaskInfoController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
/**
* 查询批量推送任务信息列表
*/
@GetMapping("/batchSendTaskList")
public List<BatchSendTaskInfo> batchSendTaskList(BatchSendTaskInfo batchSendTaskInfo) {
return batchSendTaskInfoService.selectBatchSendTaskInfoList(batchSendTaskInfo);
}
/** /**
* 导出批量推送任务信息列表 * 导出批量推送任务信息列表
*/ */

View File

@ -0,0 +1,55 @@
package com.xinelu.manage.domain.textmessage;
import lombok.Data;
/**
* 对SendSms和SendBatchSms短信发送接口设置回执接收
*/
@Data
public class SmsReport {
/**
* 转发给运营商的时间
*/
private String send_time;
/**
* 收到运营商回执的时间
*/
private String report_time;
/**
* 是否发送成功取值true发送成功false发送失败
*/
private Boolean success;
/**
* 错误码信息描述
*/
private String err_msg;
/**
* 错误码
*/
private String err_code;
/**
* 短信接收号码
*/
private String phone_number;
/**
* 短信长度
*/
private String sms_size;
/**
* 发送回执ID即发送流水号
*/
private String biz_id;
/**
* 用发送短信SendSms接口时传的outId
*/
private String out_id;
}

View File

@ -0,0 +1,38 @@
package com.xinelu.manage.domain.textmessage;
import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import java.util.Date;
/**
* 阿里云回调服务数据库表
*/
@Data
public class TaskMessageBackEntity {
/**
* 主键
*/
private Integer id;
/**
* 回调数据
*/
private JSONArray messageBackData;
/**
* 已读状态0未读1已读
*/
private Integer readState;
/**
* 创建时间
*/
private Date createDate;
/**
* 修改时间
*/
private Date updateDate;
}

View File

@ -90,4 +90,12 @@ public interface ShortMessageSendRecordMapper {
* @return BillInfoDto * @return BillInfoDto
*/ */
List<BillInfoDto> selectShortMessageRecordByBillId(Long billId); List<BillInfoDto> selectShortMessageRecordByBillId(Long billId);
/**
* 批量新增短信发送结果记录
*
* @param shortMessageSendRecords 短信发送结果记录
* @return 结果
*/
int insertShortMessageSendRecords(List<ShortMessageSendRecord> shortMessageSendRecords);
} }

View File

@ -210,7 +210,8 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
if (StringUtils.isNotBlank(batchSendTaskInfo.getPhysicalExaminationSummary())) { if (StringUtils.isNotBlank(batchSendTaskInfo.getPhysicalExaminationSummary())) {
String[] strings = BracketExtractor.extractToArray(batchSendTaskInfo.getPhysicalExaminationSummary()); String[] strings = BracketExtractor.extractToArray(batchSendTaskInfo.getPhysicalExaminationSummary());
stringList.addAll(Arrays.asList(strings)); stringList.addAll(Arrays.asList(strings));
batchSendTaskInfo.setPhysicalExaminationLabel(Arrays.toString(strings)); String result = Arrays.toString(strings).replaceAll("^\\[|\\]$", "");
batchSendTaskInfo.setPhysicalExaminationLabel(result);
if (batchSendTaskInfo.getPhysicalExaminationSummary().length() > 999) { if (batchSendTaskInfo.getPhysicalExaminationSummary().length() > 999) {
batchSendTaskInfo.setPhysicalExaminationSummary(batchSendTaskInfo.getPhysicalExaminationSummary().substring(0, 999)); batchSendTaskInfo.setPhysicalExaminationSummary(batchSendTaskInfo.getPhysicalExaminationSummary().substring(0, 999));
} }

View File

@ -348,4 +348,46 @@
left join text_message message on record.message_template_id = message.id left join text_message message on record.message_template_id = message.id
where record.bill_id = #{billId} where record.bill_id = #{billId}
</select> </select>
<insert id="insertShortMessageSendRecords">
insert into sign_patient_manage_route(
patient_id,
manage_route_node_id,
patient_phone,
send_time,
message_template_id,
message_node_content,
error_code,
error_status,
create_by,
create_time,
message_type,
message_length,
message_quantity,
message_unit_price,
message_expense,
bill_id
)
values
<foreach item="ShortMessageSendRecord" index="index" collection="list" separator=",">
(
#{ShortMessageSendRecord.patientId},
#{ShortMessageSendRecord.manageRouteNodeId},
#{ShortMessageSendRecord.patientPhone},
#{ShortMessageSendRecord.sendTime},
#{ShortMessageSendRecord.messageTemplateId},
#{ShortMessageSendRecord.messageNodeContent},
#{ShortMessageSendRecord.errorCode},
#{ShortMessageSendRecord.errorStatus},
#{ShortMessageSendRecord.createBy},
#{ShortMessageSendRecord.errorStatus},
#{ShortMessageSendRecord.createTime},
#{ShortMessageSendRecord.messageLength},
#{ShortMessageSendRecord.messageQuantity},
#{ShortMessageSendRecord.messageUnitPrice},
#{ShortMessageSendRecord.messageExpense},
#{ShortMessageSendRecord.billId}
)
</foreach>
</insert>
</mapper> </mapper>

View File

@ -1,12 +1,23 @@
package com.xinelu.quartz.controller; package com.xinelu.quartz.controller;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
import com.xinelu.manage.domain.textmessage.SmsReport;
import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper;
import com.xinelu.quartz.service.SendTextMessageService;
import com.xinelu.quartz.task.SendTextMessageTask; import com.xinelu.quartz.task.SendTextMessageTask;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/** /**
* @Description 短信相关定时任务 * @Description 短信相关定时任务
@ -19,6 +30,10 @@ public class SendTextMessageController {
@Resource @Resource
private SendTextMessageTask textMessageTask; private SendTextMessageTask textMessageTask;
@Resource
private SendTextMessageService sendTextMessageService;
@Resource
private ShortMessageSendRecordMapper shortMessageSendRecordMapper;
/** /**
* 手动执行短信发送定时任务 * 手动执行短信发送定时任务
@ -27,4 +42,19 @@ public class SendTextMessageController {
public void textMessageSend() throws ClientException { public void textMessageSend() throws ClientException {
textMessageTask.automaticSendTextMessageTask(); textMessageTask.automaticSendTextMessageTask();
} }
@PostMapping("/textMessageSendBask")
public JSONObject textMessageSendBask(SmsReport data) {
JSONObject retObj = new JSONObject();
retObj.fluentPut("code", 0).fluentPut("msg", "成功");
if (Objects.isNull(data) || StringUtils.isBlank(data.getPhone_number())){
return retObj;
}
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords);
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
}
return jsonObject;
}
} }

View File

@ -1,6 +1,12 @@
package com.xinelu.quartz.service; package com.xinelu.quartz.service;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
import com.xinelu.manage.domain.textmessage.SmsReport;
import com.xinelu.manage.domain.textmessage.TaskMessageBackEntity;
import java.util.List;
/** /**
* @Description 短信发送定时任务业务层 * @Description 短信发送定时任务业务层
@ -13,4 +19,18 @@ public interface SendTextMessageService {
* 签约患者管理任务路径节点短信发送定时任务 * 签约患者管理任务路径节点短信发送定时任务
*/ */
void sendTextMessageSendTask() throws ClientException; void sendTextMessageSendTask() throws ClientException;
List<TaskMessageBackEntity> taskMessageBack(TaskMessageBackEntity taskMessageBackEntity);
/**
* 任务执行回调方法
*
* @param data 任务单通电话回调传输data
* @return JSONObject
*/
JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords);
Integer updateReadState(Integer readState, Integer id);
Integer deleteData();
} }

View File

@ -1,10 +1,16 @@
package com.xinelu.quartz.service.impl; package com.xinelu.quartz.service.impl;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.xinelu.common.config.AliYunSmsTwoConfig; import com.xinelu.common.config.AliYunSmsTwoConfig;
import com.xinelu.common.config.PushMessageRestrictions; import com.xinelu.common.config.PushMessageRestrictions;
import com.xinelu.common.enums.*; import com.xinelu.common.enums.*;
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord; import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
import com.xinelu.manage.domain.signpatientmanageroutenode.SignPatientManageRouteNode;
import com.xinelu.manage.domain.textmessage.SmsReport;
import com.xinelu.manage.domain.textmessage.TaskMessageBackEntity;
import com.xinelu.manage.dto.smssend.SmsInfoDTO; import com.xinelu.manage.dto.smssend.SmsInfoDTO;
import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper; import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper;
import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper; import com.xinelu.manage.mapper.signpatientmanageroutenode.SignPatientManageRouteNodeMapper;
@ -15,12 +21,20 @@ import com.xinelu.mobile.utils.SmsSendUtils;
import com.xinelu.quartz.service.SendTextMessageService; import com.xinelu.quartz.service.SendTextMessageService;
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.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -44,8 +58,10 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
private PushMessageRestrictions pushMessageRestrictions; private PushMessageRestrictions pushMessageRestrictions;
@Resource @Resource
private ShortMessageSendRecordMapper shortMessageSendRecordMapper; private ShortMessageSendRecordMapper shortMessageSendRecordMapper;
@Resource @Resource
private IPatientTaskStatisticsService patientTaskStatisticsService; private IPatientTaskStatisticsService patientTaskStatisticsService;
@Value("${aiob.callBackUrl}")
private String callBackUrl;
/** /**
* 签约患者管理任务路径节点短信发送定时任务 * 签约患者管理任务路径节点短信发送定时任务
@ -87,7 +103,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
localDate = textMessage.getVisitDate().plusDays(textMessage.getRouteNodeDay()); localDate = textMessage.getVisitDate().plusDays(textMessage.getRouteNodeDay());
} }
//没有天数按执行时间处理NodePlanTime //没有天数按执行时间处理NodePlanTime
if (Objects.isNull(textMessage.getRouteNodeDay()) && Objects.nonNull(textMessage.getNodePlanTime())){ if (Objects.isNull(textMessage.getRouteNodeDay()) && Objects.nonNull(textMessage.getNodePlanTime())) {
localDate = textMessage.getNodePlanTime().toLocalDate();//新加的外呼立即执行没有getRouteNodeDay localDate = textMessage.getNodePlanTime().toLocalDate();//新加的外呼立即执行没有getRouteNodeDay
} }
if (Objects.isNull(localDate)) { if (Objects.isNull(localDate)) {
@ -102,7 +118,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
continue; continue;
} }
//没有天数按执行时间处理NodePlanTime //没有天数按执行时间处理NodePlanTime
if (Objects.isNull(textMessage.getRouteNodeDay()) && now.isBefore(textMessage.getNodePlanTime())){ if (Objects.isNull(textMessage.getRouteNodeDay()) && now.isBefore(textMessage.getNodePlanTime())) {
continue; continue;
} }
textMessage.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(textMessage.getRouteNodeName()).getName()); textMessage.setRouteNodeName(RouteNodeNameEnum.getNameByInfo(textMessage.getRouteNodeName()).getName());
@ -153,7 +169,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
//发送失败ids //发送失败ids
List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>(); List<Long> failSignPatientManageRouteNodeIds = new ArrayList<>();
Set<Long> patientIdSet = new HashSet<>(); Set<Long> patientIdSet = new HashSet<>();
if (CollectionUtils.isNotEmpty(messages)) { if (CollectionUtils.isNotEmpty(messages)) {
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
for (TextMessage message : messages) { for (TextMessage message : messages) {
@ -189,8 +205,8 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
} }
} }
shortMessageSendRecordMapper.insertShortMessageSendRecord(shortMessageSendRecord); shortMessageSendRecordMapper.insertShortMessageSendRecord(shortMessageSendRecord);
// 修改患者任务统计表 // 修改患者任务统计表
patientIdSet.add(message.getPatientId()); patientIdSet.add(message.getPatientId());
} }
//修改节点状态 //修改节点状态
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
@ -201,10 +217,87 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(failSignPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), null, NodeExecuteResultStatusEnum.FAILURE.getInfo(), null, now); signPatientManageRouteNodeMapper.updateNodeExecuteStatusByIds(failSignPatientManageRouteNodeIds, NodeExecuteStatusEnum.EXECUTED.getInfo(), null, NodeExecuteResultStatusEnum.FAILURE.getInfo(), null, now);
} }
// 患者任务统计表修改 // 患者任务统计表修改
if (CollectionUtils.isNotEmpty(patientIdSet)) { if (CollectionUtils.isNotEmpty(patientIdSet)) {
patientTaskStatisticsService.updateNum(new ArrayList<>(patientIdSet)); patientTaskStatisticsService.updateNum(new ArrayList<>(patientIdSet));
} }
} }
} }
@Override
public List<TaskMessageBackEntity> taskMessageBack(TaskMessageBackEntity taskMessageBackEntity) {
// 接口获取外呼回调数据app
List<TaskMessageBackEntity> taskMessageBackEntityList = new ArrayList<>();
HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject) JSON.toJSON(taskMessageBackEntityList));
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(callBackUrl + "/getMessageBackList", HttpMethod.POST, requestEntity, String.class);
JSONObject object = JSON.parseObject(responseEntity.getBody());
if (object == null || object.getInteger("code") == null || object.getInteger("code") != 0) {
return null;
}
if (object.containsKey("data")) {
JSONArray data = object.getJSONArray("data");
if (data != null && data.size() > 0) {
taskMessageBackEntityList = data.toJavaList(TaskMessageBackEntity.class);
}
}
return taskMessageBackEntityList;
}
@Override
public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords) {
JSONObject retObj = new JSONObject();
retObj.fluentPut("code", 0).fluentPut("msg", "成功");
SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(Long.valueOf(data.getOut_id()));
ShortMessageSendRecord shortMessageSendRecord = new ShortMessageSendRecord();
if (ObjectUtils.isNotEmpty(signPatientManageRouteNode) && signPatientManageRouteNode.getMessagePushSign() == 1) {
if (data.getSuccess()) {
// 标记任务执行状态
signPatientManageRouteNode.setNodeExecuteStatus(NodeExecuteStatusEnum.EXECUTED.getInfo());
signPatientManageRouteNode.setMessageNodeExecuteResultStatus(NodeExecuteResultStatusEnum.SUCCESS.getInfo());
signPatientManageRouteNode.setNodeFinishDate(LocalDateTime.parse(data.getReport_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
shortMessageSendRecord.setErrorStatus(ErrorStatusEnum.success.getValue());
shortMessageSendRecord.setErrorCode(0L);
} else {
// 标记任务执行状态
signPatientManageRouteNode.setNodeExecuteStatus(NodeExecuteStatusEnum.EXECUTED.getInfo());
signPatientManageRouteNode.setMessageNodeExecuteResultStatus(NodeExecuteResultStatusEnum.FAILURE.getInfo());
signPatientManageRouteNode.setNodeFinishDate(LocalDateTime.parse(data.getReport_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
shortMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
shortMessageSendRecord.setErrorCode(1L);
}
shortMessageSendRecord.setManageRouteNodeId(signPatientManageRouteNode.getId());
shortMessageSendRecord.setPatientPhone(data.getPhone_number());
shortMessageSendRecord.setMessageTemplateId(shortMessageSendRecord.getMessageTemplateId());
shortMessageSendRecord.setMessageNodeContent(signPatientManageRouteNode.getMessageNodeContent());
shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size()));
shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1"));
shortMessageSendRecord.setMessageExpense(shortMessageSendRecord.getMessageUnitPrice().multiply(new BigDecimal(shortMessageSendRecord.getMessageQuantity())));
shortMessageSendRecords.add(shortMessageSendRecord);
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
}
return retObj;
}
@Override
public Integer updateReadState(Integer readState, Integer id) {
log.info("修改短信回调数据已读状态--id{}", id);
JSONObject TaskCallbackUpdateDto = new JSONObject();
TaskCallbackUpdateDto.fluentPut("id", id).fluentPut("readState", readState);
HttpEntity<JSONObject> requestEntity = new HttpEntity<>(TaskCallbackUpdateDto);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> responseEntity = restTemplate.exchange(callBackUrl + "/updateMessageBackReadState", HttpMethod.POST, requestEntity, String.class);
JSONObject object = JSON.parseObject(responseEntity.getBody());
if (object == null || object.getInteger("code") == null || object.getInteger("code") != 0) {
log.info("修改百度外呼回调数据已读状态失败--id{},原因:{}", id, object.getString("message"));
return null;
}
log.info("修改百度外呼回调数据已读状态成功--id{}", id);
return 1;
}
@Override
public Integer deleteData() {
return null;
}
} }

View File

@ -1,12 +1,20 @@
package com.xinelu.quartz.task; package com.xinelu.quartz.task;
import com.alibaba.fastjson.JSON;
import com.aliyuncs.exceptions.ClientException; import com.aliyuncs.exceptions.ClientException;
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
import com.xinelu.manage.domain.textmessage.SmsReport;
import com.xinelu.manage.domain.textmessage.TaskMessageBackEntity;
import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper;
import com.xinelu.quartz.service.SendTextMessageService; import com.xinelu.quartz.service.SendTextMessageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/** /**
* @Description 短信相关定时任务 * @Description 短信相关定时任务
@ -19,6 +27,8 @@ public class SendTextMessageTask {
@Resource @Resource
private SendTextMessageService sendTextMessageService; private SendTextMessageService sendTextMessageService;
@Resource
private ShortMessageSendRecordMapper shortMessageSendRecordMapper;
/** /**
* 签约患者管理任务路径节点短信发送定时任务 * 签约患者管理任务路径节点短信发送定时任务
@ -28,4 +38,32 @@ public class SendTextMessageTask {
sendTextMessageService.sendTextMessageSendTask(); sendTextMessageService.sendTextMessageSendTask();
log.info("完成订阅签约患者管理任务路径节点推送定时任务......"); log.info("完成订阅签约患者管理任务路径节点推送定时任务......");
} }
public void smsReportBack() {
log.info("开始执行同步短信回调数据定时任务......");
TaskMessageBackEntity taskMessageBackEntity = new TaskMessageBackEntity();
taskMessageBackEntity.setReadState(0);
List<TaskMessageBackEntity> taskMessageBackEntityList = sendTextMessageService.taskMessageBack(taskMessageBackEntity);
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
if (!CollectionUtils.isEmpty(taskMessageBackEntityList)) {
// 回调数据解析
taskMessageBackEntityList.forEach(entity -> {
// JSONString TaskCallbackDataDto
SmsReport smsReport = JSON.parseObject(entity.getMessageBackData().toString(), SmsReport.class);
// 执行回调
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords);
// 修改阿里云服务器回调数据已读状态
sendTextMessageService.updateReadState(1, entity.getId());
});
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
}
log.info("完成同步百度外呼回调数据定时任务......");
}
public void clearCallbackData() {
log.info("开始执行清除过期的百度外呼回调数据定时任务......");
// 清除一个月前的数据
int count = sendTextMessageService.deleteData();
log.info("完成清除过期的百度外呼回调数据定时任务,共清除" + count + "条......");
}
} }