短信回执修改
This commit is contained in:
parent
058af30d73
commit
984990f864
@ -123,4 +123,12 @@ public interface ShortMessageSendRecordMapper {
|
||||
* @return int
|
||||
*/
|
||||
int updateShortMessageSendRecordByIds(@Param("ids") List<Long> ids , @Param("billId") Long billId);
|
||||
|
||||
/**
|
||||
* 根据任务明细id查询短信推送记录
|
||||
*
|
||||
* @param nodeId 任务明细id
|
||||
* @return int
|
||||
*/
|
||||
int selectSendRecordCountByNodeId(Long nodeId);
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.xinelu.manage.vo.manualfollowup.ManualFollowPatientVO;
|
||||
import com.xinelu.manage.vo.manualfollowup.ManualFollowUpVO;
|
||||
import com.xinelu.manage.vo.signpatientmanageroute.PhonePush;
|
||||
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -157,5 +158,11 @@ public interface SignPatientManageRouteMapper {
|
||||
*/
|
||||
int insertBatch(List<SignPatientManageRoute> signPatientManageRoutes);
|
||||
|
||||
List<SignPatientManageRouteVO> selectRouteByBatchSendTaskRecordId(List<Long> batchSendTaskRecordId);
|
||||
/**
|
||||
* 根据推送任务id查询手机号信息
|
||||
*
|
||||
* @param batchSendTaskRecordId 推送任务id
|
||||
* @return SignPatientManageRouteVO
|
||||
*/
|
||||
List<SignPatientManageRouteVO> selectRouteByBatchSendTaskRecordId(@Param("batchSendTaskRecordId") List<Long> batchSendTaskRecordId);
|
||||
}
|
||||
|
||||
@ -61,6 +61,7 @@ import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -228,6 +229,10 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
|
||||
for (BatchSendTaskInfo batchSendTaskInfo : list) {
|
||||
batchSendTaskInfo.setSn(sn);
|
||||
batchSendTaskInfo.setHospitalAgencyId(agency.getId());
|
||||
//剔除空白字符(空格、制表符、换行符、回车等)
|
||||
if (StringUtils.isNotBlank(batchSendTaskInfo.getPatientPhone())) {
|
||||
batchSendTaskInfo.setPatientPhone(batchSendTaskInfo.getPatientPhone().replaceAll("\\s+", ""));
|
||||
}
|
||||
batchSendTaskInfo.setHospitalAgencyName(agency.getAgencyName());
|
||||
batchSendTaskInfo.setImportName(importName);
|
||||
batchSendTaskInfo.setCreateTime(LocalDateTime.now());
|
||||
@ -286,6 +291,21 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
|
||||
@Override
|
||||
public AjaxResult batchSend(BatchSendTaskRecordDto batchSendTaskRecordDto) throws ClientException, IllegalAccessException {
|
||||
log.info("开始创建批量推送任务---------------");
|
||||
if (CollectionUtils.isEmpty(batchSendTaskRecordDto.getList())) {
|
||||
return new AjaxResult();
|
||||
}
|
||||
int start = batchSendTaskRecordDto.getList().size();
|
||||
batchSendTaskRecordDto.setList(new ArrayList<>(batchSendTaskRecordDto.getList().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(item -> StringUtils.isNotEmpty(item.getPatientName())
|
||||
&& StringUtils.isNotEmpty(item.getPatientPhone()))
|
||||
.collect(Collectors.toMap(
|
||||
BatchSendTaskInfo::getPatientPhone, // 按手机号去重,也可按其他字段
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing.getId() > replacement.getId() ? existing : replacement
|
||||
))
|
||||
.values()));
|
||||
int end = batchSendTaskRecordDto.getList().size();
|
||||
//新增批量推送任务记录
|
||||
BatchSendTaskRecordInfo batchSendTaskRecordInfo = new BatchSendTaskRecordInfo();
|
||||
batchSendTaskRecordInfo.setBatchTaskName(batchSendTaskRecordDto.getManageRouteName());
|
||||
@ -516,8 +536,13 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
|
||||
importTaskDto.setCustomerInfoList(customerInfoList);
|
||||
aiobService.importTask(importTaskDto);
|
||||
//根据机器人id查询智能外呼系统的任务id
|
||||
log.info("创建批量电话推送任务执行完成......");
|
||||
return AjaxResult.success("创建批量电话推送任务执行完成");
|
||||
int filteredCount = start - end;
|
||||
String message = "创建批量电话推送任务执行完成,共计" + start + "条任务";
|
||||
if (filteredCount > 0) {
|
||||
message += ",过滤重复手机号" + filteredCount + "条";
|
||||
}
|
||||
log.info(message);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
if (batchSendTaskRecordDto.getBatchTaskSource().equals(BillSourceEnum.MESSAGE.getInfo())) {
|
||||
log.info("创建批量短信推送任务---------------");
|
||||
@ -542,8 +567,13 @@ public class BatchSendTaskInfoServiceImpl implements IBatchSendTaskInfoService {
|
||||
if (!aBoolean) {
|
||||
return AjaxResult.error("短信上传失败");
|
||||
}
|
||||
log.info("创建批量短信推送任务执行完成......");
|
||||
return AjaxResult.success("短信上传成功");
|
||||
int filteredCount = start - end;
|
||||
String message = "创建批量短信推送任务执行完成,共计" + start + "条任务";
|
||||
if (filteredCount > 0) {
|
||||
message += ",过滤重复手机号" + filteredCount + "条";
|
||||
}
|
||||
log.info(message);
|
||||
return AjaxResult.success(message);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -430,4 +430,10 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectSendRecordCountByNodeId" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from short_message_send_record
|
||||
where manage_route_node_id = #{nodeId}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -784,7 +784,8 @@
|
||||
|
||||
<select id="selectRouteByBatchSendTaskRecordId" resultType="com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO">
|
||||
select spmr.id,
|
||||
bsti.patient_phone phone
|
||||
spmr.batch_send_task_record_id,
|
||||
TRIM(bsti.patient_phone) phone
|
||||
from sign_patient_manage_route spmr
|
||||
LEFT JOIN batch_send_task_info bsti on spmr.batch_send_task_id = bsti.id
|
||||
<where>
|
||||
|
||||
@ -257,8 +257,11 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
}
|
||||
SignPatientManageRouteNode signPatientManageRouteNode = signPatientManageRouteNodes.stream().filter(Objects::nonNull).findFirst().orElse(new SignPatientManageRouteNode());
|
||||
if (Objects.isNull(signPatientManageRouteNode) || signPatientManageRouteNode.getNodeExecuteStatus().equals(NodeExecuteStatusEnum.EXECUTED.getInfo())) {
|
||||
int count = shortMessageSendRecordMapper.selectSendRecordCountByNodeId(signPatientManageRouteNode.getId());
|
||||
if (count > 0) {
|
||||
return retObj;
|
||||
}
|
||||
}
|
||||
ShortMessageSendRecord shortMessageSendRecord = new ShortMessageSendRecord();
|
||||
if (ObjectUtils.isNotEmpty(signPatientManageRouteNode) && signPatientManageRouteNode.getMessagePushSign() == 1) {
|
||||
if (data.getSuccess()) {
|
||||
@ -281,11 +284,15 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
shortMessageSendRecord.setMessageTemplateId(signPatientManageRouteNode.getMessageTemplateCode());
|
||||
shortMessageSendRecord.setMessageNodeContent(signPatientManageRouteNode.getMessageNodeContent());
|
||||
shortMessageSendRecord.setMessageType("COMMON");
|
||||
if (StringUtils.isNotBlank(data.getSms_size())){
|
||||
shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size()));
|
||||
shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1"));
|
||||
}
|
||||
shortMessageSendRecord.setCreateBy("system");
|
||||
shortMessageSendRecord.setCreateTime(LocalDateTime.now());
|
||||
if (Objects.nonNull(shortMessageSendRecord.getMessageUnitPrice()) && Objects.nonNull(shortMessageSendRecord.getMessageQuantity())){
|
||||
shortMessageSendRecord.setMessageExpense(shortMessageSendRecord.getMessageUnitPrice().multiply(new BigDecimal(shortMessageSendRecord.getMessageQuantity())));
|
||||
}
|
||||
shortMessageSendRecords.add(shortMessageSendRecord);
|
||||
signPatientManageRouteNodeMapper.updateSignPatientManageRouteNode(signPatientManageRouteNode);
|
||||
}
|
||||
@ -294,7 +301,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
|
||||
@Override
|
||||
public Integer updateReadState(Integer readState, List<Integer> ids) {
|
||||
log.info("修改短信回调数据已读状态--id:{}", ids);
|
||||
log.info("开始修改短信回调数据已读状态");
|
||||
JSONObject TaskCallbackUpdateDto = new JSONObject();
|
||||
TaskCallbackUpdateDto.fluentPut("ids", ids.toString()).fluentPut("readState", readState);
|
||||
HttpEntity<JSONObject> requestEntity = new HttpEntity<>(TaskCallbackUpdateDto);
|
||||
|
||||
@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
@ -45,7 +46,7 @@ public class SendTextMessageTask {
|
||||
sendTextMessageService.sendTextMessageSendTask();
|
||||
log.info("完成订阅签约患者管理任务路径节点推送定时任务......");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void smsReportBack() {
|
||||
log.info("开始执行同步短信回调数据定时任务......");
|
||||
TaskMessageBackEntity taskMessageBackEntity = new TaskMessageBackEntity();
|
||||
@ -81,7 +82,9 @@ public class SendTextMessageTask {
|
||||
List<SignPatientManageRouteVO> signPatientManageRoutes = signPatientManageRouteMapper.selectRouteByBatchSendTaskRecordId(outIds);
|
||||
for (SmsReport smsReport : smsReports) {
|
||||
// 回调数据解析
|
||||
SignPatientManageRouteVO signPatientManageRoute = signPatientManageRoutes.stream().filter(Objects::nonNull).filter(item -> smsReport.getPhone_number().equals(item.getPhone())).findFirst().orElse(new SignPatientManageRouteVO());
|
||||
SignPatientManageRouteVO signPatientManageRoute = signPatientManageRoutes.stream().filter(Objects::nonNull)
|
||||
.filter(item -> smsReport.getPhone_number().equals(item.getPhone()) && item.getBatchSendTaskRecordId().equals(Long.parseLong(smsReport.getOut_id())))
|
||||
.findFirst().orElse(new SignPatientManageRouteVO());
|
||||
if (StringUtils.isBlank(signPatientManageRoute.getPhone()) || Objects.isNull(signPatientManageRoute.getId())){
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user