短信回调修改
This commit is contained in:
parent
eeaba3916b
commit
7232359aa5
@ -355,10 +355,10 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
|
||||
SignPatientManageRouteNode signPatientManageRouteNode = new SignPatientManageRouteNode();
|
||||
signPatientManageRouteNode.setManageRouteName(batchSendTaskRecordDto.getManageRouteName());
|
||||
signPatientManageRouteNode.setSn(batchTaskNumber);
|
||||
signPatientManageRouteNode.setDialStatus(DialStatusEnum.NODIALED.getInfo());
|
||||
signPatientManageRouteNode.setTaskExcuteType(TaskExcuteTypeEnum.BATCH_TASK.getInfo());
|
||||
signPatientManageRouteNode.setNodePlanTime(batchSendTaskRecordDto.getNodePlanTime());
|
||||
if (batchSendTaskRecordDto.getBatchTaskSource().equals(BillSourceEnum.TELEPHONE.getInfo())) {
|
||||
signPatientManageRouteNode.setDialStatus(DialStatusEnum.NODIALED.getInfo());
|
||||
signPatientManageRouteNode.setTaskNodeType(TaskNodeTypeEnum.PHONE_OUTBOUND.getInfo());
|
||||
signPatientManageRouteNode.setPhonePushSign(1);
|
||||
signPatientManageRouteNode.setScriptInfoId(Objects.isNull(batchSendTaskRecordDto.getScriptInfoId()) ? null : batchSendTaskRecordDto.getScriptInfoId());
|
||||
|
||||
@ -350,7 +350,7 @@
|
||||
</select>
|
||||
|
||||
<insert id="insertShortMessageSendRecords">
|
||||
insert into sign_patient_manage_route(
|
||||
insert into short_message_send_record(
|
||||
patient_id,
|
||||
manage_route_node_id,
|
||||
patient_phone,
|
||||
@ -380,8 +380,8 @@
|
||||
#{ShortMessageSendRecord.errorCode},
|
||||
#{ShortMessageSendRecord.errorStatus},
|
||||
#{ShortMessageSendRecord.createBy},
|
||||
#{ShortMessageSendRecord.errorStatus},
|
||||
#{ShortMessageSendRecord.createTime},
|
||||
#{ShortMessageSendRecord.messageType},
|
||||
#{ShortMessageSendRecord.messageLength},
|
||||
#{ShortMessageSendRecord.messageQuantity},
|
||||
#{ShortMessageSendRecord.messageUnitPrice},
|
||||
|
||||
@ -53,7 +53,7 @@ public class SendTextMessageController {
|
||||
return retObj;
|
||||
}
|
||||
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
|
||||
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords, null);
|
||||
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords);
|
||||
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
|
||||
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public interface SendTextMessageService {
|
||||
* @param data 任务单通电话回调传输data
|
||||
* @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);
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -229,6 +230,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
List<TaskMessageBackEntity> taskMessageBackEntityList = new ArrayList<>();
|
||||
HttpEntity<JSONObject> requestEntity = new HttpEntity<>((JSONObject) JSON.toJSON(taskMessageBackEntity));
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
log.info("接口获取短信回调数据");
|
||||
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) {
|
||||
@ -240,11 +242,12 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
taskMessageBackEntityList = data.toJavaList(TaskMessageBackEntity.class);
|
||||
}
|
||||
}
|
||||
log.info("共短信回调数据" + taskMessageBackEntityList.size() + "条");
|
||||
return taskMessageBackEntityList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, List<Integer> ids) {
|
||||
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()));
|
||||
@ -266,16 +269,19 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
shortMessageSendRecord.setErrorStatus(ErrorStatusEnum.fail.getValue());
|
||||
shortMessageSendRecord.setErrorCode(1L);
|
||||
}
|
||||
shortMessageSendRecord.setSendTime(LocalDateTime.parse(data.getSend_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
shortMessageSendRecord.setManageRouteNodeId(signPatientManageRouteNode.getId());
|
||||
shortMessageSendRecord.setPatientPhone(data.getPhone_number());
|
||||
shortMessageSendRecord.setMessageTemplateId(shortMessageSendRecord.getMessageTemplateId());
|
||||
shortMessageSendRecord.setMessageTemplateId(signPatientManageRouteNode.getMessageTemplateCode());
|
||||
shortMessageSendRecord.setMessageNodeContent(signPatientManageRouteNode.getMessageNodeContent());
|
||||
shortMessageSendRecord.setMessageType("COMMON");
|
||||
shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size()));
|
||||
shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1"));
|
||||
shortMessageSendRecord.setCreateBy("system");
|
||||
shortMessageSendRecord.setCreateTime(LocalDateTime.now());
|
||||
shortMessageSendRecord.setMessageExpense(shortMessageSendRecord.getMessageUnitPrice().multiply(new BigDecimal(shortMessageSendRecord.getMessageQuantity())));
|
||||
shortMessageSendRecords.add(shortMessageSendRecord);
|
||||
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
|
||||
ids.add(Integer.valueOf(data.getOut_id()));
|
||||
}
|
||||
return retObj;
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ import org.springframework.stereotype.Component;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description 短信相关定时任务
|
||||
@ -45,7 +47,6 @@ public class SendTextMessageTask {
|
||||
taskMessageBackEntity.setReadState(0);
|
||||
List<TaskMessageBackEntity> taskMessageBackEntityList = sendTextMessageService.taskMessageBack(taskMessageBackEntity);
|
||||
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(taskMessageBackEntityList)) {
|
||||
// 回调数据提取
|
||||
List<SmsReport> smsReports = new ArrayList<>();
|
||||
@ -53,22 +54,25 @@ public class SendTextMessageTask {
|
||||
// JSONString 转 SmsReport
|
||||
smsReports.addAll(JSON.parseArray(entity.getMessageBackData().toString(), SmsReport.class));
|
||||
});
|
||||
log.info("短信数据提取完成共" + smsReports.size() + "条");
|
||||
if (CollectionUtils.isNotEmpty(smsReports)) {
|
||||
for (SmsReport smsReport : smsReports) {
|
||||
// 回调数据解析
|
||||
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords, ids);
|
||||
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
|
||||
log.info("新增短信发送记录" + shortMessageSendRecords.size() + "条");
|
||||
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)) {
|
||||
log.info("修改中站记录" + ids.size() + "条");
|
||||
sendTextMessageService.updateReadState(1, ids);
|
||||
}
|
||||
}
|
||||
log.info("完成同步百度外呼回调数据定时任务......");
|
||||
log.info("完成同步短信回调数据定时任务......");
|
||||
}
|
||||
|
||||
public void clearCallbackData() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user