电话短信导出
This commit is contained in:
parent
0833adb705
commit
5dc6b50d78
@ -67,6 +67,9 @@ public class ShortMessageSendRecord extends BaseEntity {
|
||||
@ApiModelProperty(value = "消息模板id")
|
||||
private String messageTemplateId;
|
||||
|
||||
@Excel(name = "模板")
|
||||
private String template;
|
||||
|
||||
/**
|
||||
* 消息内容
|
||||
*/
|
||||
|
||||
@ -103,7 +103,7 @@ public class PhoneDialRecordServiceImpl implements IPhoneDialRecordService {
|
||||
if (Objects.nonNull(pushCount.getTotal()) && pushCount.getTotal() != 0) {
|
||||
pushCount.setSuccessRate(new BigDecimal(pushCount.getSuccess()).divide(new BigDecimal(pushCount.getTotal()), 4, RoundingMode.HALF_UP));
|
||||
}
|
||||
if (Objects.isNull(pushCount.getTotal()) || pushCount.getTotal() == 0){
|
||||
if (Objects.isNull(pushCount.getTotal()) || pushCount.getTotal() == 0) {
|
||||
pushCount.setSuccessRate(BigDecimal.ZERO);
|
||||
}
|
||||
return AjaxResult.success(pushCount);
|
||||
|
||||
@ -114,7 +114,8 @@ public class ProjectResultServiceImpl implements IProjectResultService {
|
||||
projectGroup.setGroupCode(projectResultStatisticDto.getGroupCode());
|
||||
List<ProjectGroup> groupList = projectGroupMapper.selectProjectGroupList(projectGroup);
|
||||
if (CollectionUtils.isEmpty(groupList)) {
|
||||
throw new ServiceException("未找到该检测项目");
|
||||
//throw new ServiceException("未找到该检测项目");
|
||||
return new ProjectResultStatisticVo();
|
||||
}
|
||||
projectResultStatisticDto.setGroupId(groupList.get(0).getId());
|
||||
}
|
||||
@ -124,12 +125,14 @@ public class ProjectResultServiceImpl implements IProjectResultService {
|
||||
projectQuery.setProjectCode(projectResultStatisticDto.getProjectCode());
|
||||
List<Project> projectList = projectMapper.selectProjectList(projectQuery);
|
||||
if (CollectionUtils.isEmpty(projectList)) {
|
||||
throw new ServiceException("未找到该检测项目");
|
||||
//throw new ServiceException("未找到该检测项目");
|
||||
return new ProjectResultStatisticVo();
|
||||
}
|
||||
projectResultStatisticDto.setProjectId(projectList.get(0).getId());
|
||||
}
|
||||
if (projectResultStatisticDto.getPatientId() == null) {
|
||||
throw new ServiceException("数据格式错误");
|
||||
//throw new ServiceException("数据格式错误");
|
||||
return new ProjectResultStatisticVo();
|
||||
}
|
||||
List<String> measureTimeList = new ArrayList<>();
|
||||
Map<String, List<String>> valueMap = new HashMap<>();
|
||||
|
||||
@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -122,4 +124,22 @@ public class BillPhoneDialVo {
|
||||
*/
|
||||
@ApiModelProperty(value = "关联账单名称")
|
||||
private Long billName;
|
||||
|
||||
/**
|
||||
* 关联账单名称
|
||||
*/
|
||||
@ApiModelProperty(value = "推送结果状态")
|
||||
private String errorStatus;
|
||||
|
||||
/**
|
||||
* 关联账单名称
|
||||
*/
|
||||
@ApiModelProperty(value = "推送结果状态码")
|
||||
private String errorCode;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate dialTimeStart;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate dialTimeEnd;
|
||||
}
|
||||
@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@ -111,4 +113,10 @@ public class ShortMessageSendRecordVo {
|
||||
*/
|
||||
@ApiModelProperty(value = "关联账单名称")
|
||||
private String billName;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate sendTimeStart;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private LocalDate sendTimeEnd;
|
||||
}
|
||||
|
||||
@ -120,6 +120,8 @@
|
||||
record.phone_expense,
|
||||
record.phone_unit_price,
|
||||
record.bill_id,
|
||||
record.error_status,
|
||||
record.error_code,
|
||||
patient.patient_name,
|
||||
bill.bill_name
|
||||
from phone_dial_record record
|
||||
@ -127,13 +129,14 @@
|
||||
left join bill_info bill ON record.bill_id = bill.id
|
||||
where 1 = 1
|
||||
<if test="patientName != null and patientName != ''">
|
||||
and patient.patient_name = #{patientName}
|
||||
and patient.patient_name LIKE CONCAT(#{patientName}, '%')
|
||||
</if>
|
||||
<if test="patientPhone != null and patientPhone != ''">
|
||||
and record.patient_phone = #{patientPhone}
|
||||
and record.patient_phone LIKE CONCAT(#{patientPhone}, '%')
|
||||
</if>
|
||||
<if test="dialTime != null ">
|
||||
and record.dial_time = #{dialTime}
|
||||
<if test="dialTimeStart != null and dialTimeEnd != null">
|
||||
and record.dial_time >= #{dialTimeStart}
|
||||
and record.dial_time < #{dialTimeEnd}
|
||||
</if>
|
||||
<if test="phoneTemplateId != null and phoneTemplateId != ''">
|
||||
and record.phone_template_id = #{phoneTemplateId}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper">
|
||||
|
||||
<resultMap type="ShortMessageSendRecord" id="ShortMessageSendRecordResult">
|
||||
<resultMap type="com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord" id="ShortMessageSendRecordResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="patientId" column="patient_id"/>
|
||||
<result property="manageRouteNodeId" column="manage_route_node_id"/>
|
||||
@ -25,6 +25,7 @@
|
||||
<result property="messageUnitPrice" column="message_unit_price"/>
|
||||
<result property="messageExpense" column="message_expense"/>
|
||||
<result property="billId" column="bill_id"/>
|
||||
<result property="template" column="template"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectShortMessageSendRecordVo">
|
||||
@ -114,19 +115,22 @@
|
||||
record.message_expense,
|
||||
record.bill_id,
|
||||
patient.patient_name,
|
||||
bill.bill_name
|
||||
bill.bill_name,
|
||||
text.text_message_name as template
|
||||
from short_message_send_record record
|
||||
left join patient_info patient on patient.id = record.patient_id
|
||||
left join bill_info bill ON record.bill_id = bill.id
|
||||
left join text_message text ON text.text_message_id = record.message_template_id
|
||||
where 1 = 1
|
||||
<if test="patientName != null and patientName != ''">
|
||||
and patient.patient_name = #{patientName}
|
||||
and patient.patient_name LIKE CONCAT(#{patientName}, '%')
|
||||
</if>
|
||||
<if test="patientPhone != null and patientPhone != ''">
|
||||
and record.patient_phone = #{patientPhone}
|
||||
and record.patient_phone LIKE CONCAT(#{patientPhone}, '%')
|
||||
</if>
|
||||
<if test="sendTime != null ">
|
||||
and record.send_time = #{sendTime}
|
||||
<if test="sendTimeStart != null and sendTimeEnd != null">
|
||||
and record.send_time >= #{sendTimeStart}
|
||||
and record.send_time < #{sendTimeEnd}
|
||||
</if>
|
||||
<if test="messageTemplateId != null">
|
||||
and record.message_template_id = #{messageTemplateId}
|
||||
@ -138,8 +142,30 @@
|
||||
|
||||
<select id="selectShortMessageSendRecordById" parameterType="Long"
|
||||
resultMap="ShortMessageSendRecordResult">
|
||||
<include refid="selectShortMessageSendRecordVo"/>
|
||||
where id = #{id}
|
||||
select record.id,
|
||||
record.patient_id,
|
||||
record.manage_route_node_id,
|
||||
record.patient_phone,
|
||||
record.send_time,
|
||||
record.message_template_id,
|
||||
record.message_node_content,
|
||||
record.error_code,
|
||||
record.error_status,
|
||||
record.err_msg,
|
||||
record.create_by,
|
||||
record.create_time,
|
||||
record.update_by,
|
||||
record.update_time,
|
||||
record.message_type,
|
||||
record.message_length,
|
||||
record.message_quantity,
|
||||
record.message_unit_price,
|
||||
record.message_expense,
|
||||
record.bill_id,
|
||||
text.text_message_name as template
|
||||
from short_message_send_record record
|
||||
left join text_message text ON text.text_message_id = record.message_template_id
|
||||
where record.id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertShortMessageSendRecord" parameterType="ShortMessageSendRecord" useGeneratedKeys="true"
|
||||
|
||||
@ -2,6 +2,7 @@ package com.xinelu.quartz.controller;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.xinelu.common.core.domain.entity.SysDictData;
|
||||
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
|
||||
import com.xinelu.manage.domain.textmessage.SmsReport;
|
||||
import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMapper;
|
||||
@ -9,6 +10,7 @@ import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMap
|
||||
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
|
||||
import com.xinelu.quartz.service.SendTextMessageService;
|
||||
import com.xinelu.quartz.task.SendTextMessageTask;
|
||||
import com.xinelu.system.service.ISysDictTypeService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -40,6 +43,8 @@ public class SendTextMessageController {
|
||||
private SendTextMessageTask sendTextMessageTask;
|
||||
@Resource
|
||||
private SignPatientManageRouteMapper signPatientManageRouteMapper;
|
||||
@Resource
|
||||
private ISysDictTypeService iSysDictTypeService;
|
||||
|
||||
/**
|
||||
* 手动执行短信发送定时任务
|
||||
@ -66,8 +71,16 @@ public class SendTextMessageController {
|
||||
if (Objects.isNull(signPatientManageRoute.getId())){
|
||||
return retObj;
|
||||
}
|
||||
BigDecimal price = BigDecimal.valueOf(0.00);
|
||||
List<SysDictData> sysDictDataList = iSysDictTypeService.selectDictDataByType("unit_price");
|
||||
if (CollectionUtils.isNotEmpty(sysDictDataList)){
|
||||
SysDictData message = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictLabel().equals("message")).findFirst().orElse(new SysDictData());
|
||||
if (Objects.nonNull(message.getDictValue())){
|
||||
price = new BigDecimal(message.getDictValue());
|
||||
}
|
||||
}
|
||||
List<ShortMessageSendRecord> shortMessageSendRecords = new ArrayList<>();
|
||||
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords, signPatientManageRoute);
|
||||
JSONObject jsonObject = sendTextMessageService.taskTextMessageSendBack(data, shortMessageSendRecords, signPatientManageRoute, price);
|
||||
if (CollectionUtils.isNotEmpty(shortMessageSendRecords)) {
|
||||
shortMessageSendRecordMapper.insertShortMessageSendRecords(shortMessageSendRecords);
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.xinelu.manage.domain.textmessage.SmsReport;
|
||||
import com.xinelu.manage.domain.textmessage.TaskMessageBackEntity;
|
||||
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -29,7 +30,7 @@ public interface SendTextMessageService {
|
||||
* @param data 任务单通电话回调传输data
|
||||
* @return JSONObject
|
||||
*/
|
||||
JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, SignPatientManageRouteVO signPatientManageRoute);
|
||||
JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, SignPatientManageRouteVO signPatientManageRoute, BigDecimal price);
|
||||
|
||||
Integer updateReadState(Integer readState, List<Integer> ids);
|
||||
|
||||
|
||||
@ -248,7 +248,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, SignPatientManageRouteVO signPatientManageRouteVO) {
|
||||
public JSONObject taskTextMessageSendBack(SmsReport data, List<ShortMessageSendRecord> shortMessageSendRecords, SignPatientManageRouteVO signPatientManageRouteVO, BigDecimal price) {
|
||||
JSONObject retObj = new JSONObject();
|
||||
retObj.fluentPut("code", 0).fluentPut("msg", "成功");
|
||||
List<SignPatientManageRouteNode> signPatientManageRouteNodes = signPatientManageRouteNodeMapper.selectNodeByRouteId(signPatientManageRouteVO.getId());
|
||||
@ -286,7 +286,7 @@ public class SendTextMessageServiceImpl implements SendTextMessageService {
|
||||
shortMessageSendRecord.setMessageType("COMMON");
|
||||
if (StringUtils.isNotBlank(data.getSms_size())){
|
||||
shortMessageSendRecord.setMessageQuantity(Long.valueOf(data.getSms_size()));
|
||||
shortMessageSendRecord.setMessageUnitPrice(new BigDecimal("0.1"));
|
||||
shortMessageSendRecord.setMessageUnitPrice(price);
|
||||
}
|
||||
shortMessageSendRecord.setCreateBy("system");
|
||||
shortMessageSendRecord.setCreateTime(LocalDateTime.now());
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xinelu.quartz.task;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.xinelu.common.core.domain.entity.SysDictData;
|
||||
import com.xinelu.manage.domain.shortmessagesendrecord.ShortMessageSendRecord;
|
||||
import com.xinelu.manage.domain.textmessage.SmsReport;
|
||||
import com.xinelu.manage.domain.textmessage.TaskMessageBackEntity;
|
||||
@ -10,6 +11,7 @@ import com.xinelu.manage.mapper.shortmessagesendrecord.ShortMessageSendRecordMap
|
||||
import com.xinelu.manage.mapper.signpatientmanageroute.SignPatientManageRouteMapper;
|
||||
import com.xinelu.manage.vo.signpatientmanageroute.SignPatientManageRouteVO;
|
||||
import com.xinelu.quartz.service.SendTextMessageService;
|
||||
import com.xinelu.system.service.ISysDictTypeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -17,6 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@ -37,6 +40,8 @@ public class SendTextMessageTask {
|
||||
private ShortMessageSendRecordMapper shortMessageSendRecordMapper;
|
||||
@Resource
|
||||
private SignPatientManageRouteMapper signPatientManageRouteMapper;
|
||||
@Resource
|
||||
private ISysDictTypeService iSysDictTypeService;
|
||||
|
||||
/**
|
||||
* 签约患者管理任务路径节点短信发送定时任务
|
||||
@ -46,6 +51,7 @@ public class SendTextMessageTask {
|
||||
sendTextMessageService.sendTextMessageSendTask();
|
||||
log.info("完成订阅签约患者管理任务路径节点推送定时任务......");
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void smsReportBack() {
|
||||
log.info("开始执行同步短信回调数据定时任务......");
|
||||
@ -79,16 +85,24 @@ public class SendTextMessageTask {
|
||||
log.info("短信数据缺少任务信息!");
|
||||
return;
|
||||
}
|
||||
BigDecimal price = BigDecimal.valueOf(0.00);
|
||||
List<SysDictData> sysDictDataList = iSysDictTypeService.selectDictDataByType("unit_price");
|
||||
if (CollectionUtils.isNotEmpty(sysDictDataList)){
|
||||
SysDictData message = sysDictDataList.stream().filter(Objects::nonNull).filter(item -> item.getDictLabel().equals("message")).findFirst().orElse(new SysDictData());
|
||||
if (Objects.nonNull(message.getDictValue())){
|
||||
price = new BigDecimal(message.getDictValue());
|
||||
}
|
||||
}
|
||||
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()) && item.getBatchSendTaskRecordId().equals(Long.parseLong(smsReport.getOut_id())))
|
||||
.findFirst().orElse(new SignPatientManageRouteVO());
|
||||
if (StringUtils.isBlank(signPatientManageRoute.getPhone()) || Objects.isNull(signPatientManageRoute.getId())){
|
||||
if (StringUtils.isBlank(signPatientManageRoute.getPhone()) || Objects.isNull(signPatientManageRoute.getId())) {
|
||||
continue;
|
||||
}
|
||||
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords, signPatientManageRoute);
|
||||
sendTextMessageService.taskTextMessageSendBack(smsReport, shortMessageSendRecords, signPatientManageRoute, price);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(shortMessageSendRecords) && shortMessageSendRecords.size() > 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user