短信回调修改

This commit is contained in:
zhangheng 2026-05-13 00:38:18 +08:00
parent eeaba3916b
commit 7232359aa5
6 changed files with 22 additions and 12 deletions

View File

@ -355,10 +355,10 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
SignPatientManageRouteNode signPatientManageRouteNode = new SignPatientManageRouteNode(); SignPatientManageRouteNode signPatientManageRouteNode = new SignPatientManageRouteNode();
signPatientManageRouteNode.setManageRouteName(batchSendTaskRecordDto.getManageRouteName()); signPatientManageRouteNode.setManageRouteName(batchSendTaskRecordDto.getManageRouteName());
signPatientManageRouteNode.setSn(batchTaskNumber); signPatientManageRouteNode.setSn(batchTaskNumber);
signPatientManageRouteNode.setDialStatus(DialStatusEnum.NODIALED.getInfo());
signPatientManageRouteNode.setTaskExcuteType(TaskExcuteTypeEnum.BATCH_TASK.getInfo()); signPatientManageRouteNode.setTaskExcuteType(TaskExcuteTypeEnum.BATCH_TASK.getInfo());
signPatientManageRouteNode.setNodePlanTime(batchSendTaskRecordDto.getNodePlanTime()); signPatientManageRouteNode.setNodePlanTime(batchSendTaskRecordDto.getNodePlanTime());
if (batchSendTaskRecordDto.getBatchTaskSource().equals(BillSourceEnum.TELEPHONE.getInfo())) { if (batchSendTaskRecordDto.getBatchTaskSource().equals(BillSourceEnum.TELEPHONE.getInfo())) {
signPatientManageRouteNode.setDialStatus(DialStatusEnum.NODIALED.getInfo());
signPatientManageRouteNode.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo()); signPatientManageRouteNode.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo());
signPatientManageRouteNode.setPhonePushSign(1); signPatientManageRouteNode.setPhonePushSign(1);
signPatientManageRouteNode.setScriptInfoId(Objects.isNull(batchSendTaskRecordDto.getScriptInfoId()) ? null : batchSendTaskRecordDto.getScriptInfoId()); signPatientManageRouteNode.setScriptInfoId(Objects.isNull(batchSendTaskRecordDto.getScriptInfoId()) ? null : batchSendTaskRecordDto.getScriptInfoId());

View File

@ -350,7 +350,7 @@
</select> </select>
<insert id="insertShortMessageSendRecords"> <insert id="insertShortMessageSendRecords">
insert into sign_patient_manage_route( insert into short_message_send_record(
patient_id, patient_id,
manage_route_node_id, manage_route_node_id,
patient_phone, patient_phone,
@ -380,8 +380,8 @@
#{ShortMessageSendRecord.errorCode}, #{ShortMessageSendRecord.errorCode},
#{ShortMessageSendRecord.errorStatus}, #{ShortMessageSendRecord.errorStatus},
#{ShortMessageSendRecord.createBy}, #{ShortMessageSendRecord.createBy},
#{ShortMessageSendRecord.errorStatus},
#{ShortMessageSendRecord.createTime}, #{ShortMessageSendRecord.createTime},
#{ShortMessageSendRecord.messageType},
#{ShortMessageSendRecord.messageLength}, #{ShortMessageSendRecord.messageLength},
#{ShortMessageSendRecord.messageQuantity}, #{ShortMessageSendRecord.messageQuantity},
#{ShortMessageSendRecord.messageUnitPrice}, #{ShortMessageSendRecord.messageUnitPrice},

View File

@ -53,7 +53,7 @@ public class SendTextMessageController {
return retObj; return retObj;
} }
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>(); List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords, null); JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords);
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) { if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords); shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
} }

View File

@ -28,7 +28,7 @@ public interface SendTextMessageService {
* @param data 任务单通电话回调传输data * @param data 任务单通电话回调传输data
* @return JSONObject * @return JSONObject
*/ */
JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, List<Integer> ids); JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords);
Integer updateReadState(Integer readState, List<Integer> ids); Integer updateReadState(Integer readState, List<Integer> ids);

View File

@ -34,6 +34,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal; 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;
@ -229,6 +230,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
List<TaskMessageBackEntity> taskMessageBackEntityList = new ArrayList<>(); List<TaskMessageBackEntity> taskMessageBackEntityList = new ArrayList<>();
HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject) JSON.toJSON(taskMessageBackEntity)); HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject) JSON.toJSON(taskMessageBackEntity));
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
log.info("接口获取短信回调数据");
ResponseEntity<String> responseEntity = restTemplate.exchange(callBackUrl + "/getMessageBackList", HttpMethod.POST, requestEntity, String.class); ResponseEntity<String> responseEntity = restTemplate.exchange(callBackUrl + "/getMessageBackList", HttpMethod.POST, requestEntity, String.class);
JSONObject object = JSON.parseObject(responseEntity.getBody()); JSONObject object = JSON.parseObject(responseEntity.getBody());
if (object == null || object.getInteger("code") == null || object.getInteger("code") != 0) { if (object == null || object.getInteger("code") == null || object.getInteger("code") != 0) {
@ -240,11 +242,12 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
taskMessageBackEntityList = data.toJavaList(TaskMessageBackEntity.class); taskMessageBackEntityList = data.toJavaList(TaskMessageBackEntity.class);
} }
} }
log.info("共短信回调数据" + taskMessageBackEntityList.size() + "");
return taskMessageBackEntityList; return taskMessageBackEntityList;
} }
@Override @Override
public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, List<Integer> ids) { public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords) {
JSONObject retObj = new JSONObject(); JSONObject retObj = new JSONObject();
retObj.fluentPut("code", 0).fluentPut("msg", "成功"); retObj.fluentPut("code", 0).fluentPut("msg", "成功");
SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(Long.valueOf(data.getOut_id())); SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodeMapper.selectSignPatientManageRouteNodeById(Long.valueOf(data.getOut_id()));
@ -266,16 +269,19 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
shortMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue()); shortMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
shortMessageSendRecord.setErrorCode(1L); shortMessageSendRecord.setErrorCode(1L);
} }
shortMessageSendRecord.setSendTime(LocalDateTime.parse(data.getSend_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
shortMessageSendRecord.setManageRouteNodeId(signPatientManageRouteNode.getId()); shortMessageSendRecord.setManageRouteNodeId(signPatientManageRouteNode.getId());
shortMessageSendRecord.setPatientPhone(data.getPhone_number()); shortMessageSendRecord.setPatientPhone(data.getPhone_number());
shortMessageSendRecord.setMessageTemplateId(shortMessageSendRecord.getMessageTemplateId()); shortMessageSendRecord.setMessageTemplateId(signPatientManageRouteNode.getMessageTemplateCode());
shortMessageSendRecord.setMessageNodeContent(signPatientManageRouteNode.getMessageNodeContent()); shortMessageSendRecord.setMessageNodeContent(signPatientManageRouteNode.getMessageNodeContent());
shortMessageSendRecord.setMessageType("COMMON");
shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size())); shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size()));
shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1")); shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1"));
shortMessageSendRecord.setCreateBy("system");
shortMessageSendRecord.setCreateTime(LocalDateTime.now());
shortMessageSendRecord.setMessageExpense(shortMessageSendRecord.getMessageUnitPrice().multiply(new BigDecimal(shortMessageSendRecord.getMessageQuantity()))); shortMessageSendRecord.setMessageExpense(shortMessageSendRecord.getMessageUnitPrice().multiply(new BigDecimal(shortMessageSendRecord.getMessageQuantity())));
shortMessageSendRecords.add(shortMessageSendRecord); shortMessageSendRecords.add(shortMessageSendRecord);
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode); signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
ids.add(Integer.valueOf(data.getOut_id()));
} }
return retObj; return retObj;
} }

View File

@ -15,6 +15,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* @Description 短信相关定时任务 * @Description 短信相关定时任务
@ -45,7 +47,6 @@ public class SendTextMessageTask {
taskMessageBackEntity.setReadState(0); taskMessageBackEntity.setReadState(0);
List<TaskMessageBackEntity> taskMessageBackEntityList = sendTextMessageService.taskMessageBack(taskMessageBackEntity); List<TaskMessageBackEntity> taskMessageBackEntityList = sendTextMessageService.taskMessageBack(taskMessageBackEntity);
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>(); List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
List<Integer> ids = new ArrayList<>();
if (!CollectionUtils.isEmpty(taskMessageBackEntityList)) { if (!CollectionUtils.isEmpty(taskMessageBackEntityList)) {
// 回调数据提取 // 回调数据提取
List<SmsReport> smsReports = new ArrayList<>(); List<SmsReport> smsReports = new ArrayList<>();
@ -53,22 +54,25 @@ public class SendTextMessageTask {
// JSONString SmsReport // JSONString SmsReport
smsReports.addAll(JSON.parseArray(entity.getMessageBackData().toString(), SmsReport.class)); smsReports.addAll(JSON.parseArray(entity.getMessageBackData().toString(), SmsReport.class));
}); });
log.info("短信数据提取完成共" + smsReports.size() + "");
if (CollectionUtils.isNotEmpty(smsReports)) { if (CollectionUtils.isNotEmpty(smsReports)) {
for (SmsReport smsReport : smsReports) { for (SmsReport smsReport : smsReports) {
// 回调数据解析 // 回调数据解析
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords, ids); sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords);
} }
} }
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) { if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
log.info("新增短信发送记录" + shortMessageSendRecords.size() + "");
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords); shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
} }
//List<Integer> ids = taskMessageBackEntityList.stream().filter(Objects::nonNull).map(TaskMessageBackEntity::getId).collect(Collectors.toList()); List<Integer> ids = taskMessageBackEntityList.stream().filter(Objects::nonNull).map(TaskMessageBackEntity::getId).collect(Collectors.toList());
// 修改阿里云服务器回调数据已读状态 // 修改阿里云服务器回调数据已读状态
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
log.info("修改中站记录" + ids.size() + "");
sendTextMessageService.updateReadState(1, ids); sendTextMessageService.updateReadState(1, ids);
} }
} }
log.info("完成同步百度外呼回调数据定时任务......"); log.info("完成同步短信回调数据定时任务......");
} }
public void clearCallbackData() { public void clearCallbackData() {