<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<mapper namespace="cn.gistack.alerts.sms.mapper.SmsRecordMapper">
|
|
<!--自定义分页列表查询-->
|
<select id="selectSmsRecordPage" resultType="cn.gistack.alerts.sms.vo.SmsRecordVO">
|
select * from sm_sms_record where 1=1 and is_deleted = 0
|
<if test="smsRecord.tel!=null and smsRecord.tel!=''">
|
and tel like concat(concat('%',#{smsRecord.tel}),'%')
|
</if>
|
<if test="smsRecord.content!=null and smsRecord.content!=''">
|
and content like concat(concat('%',#{smsRecord.content}),'%')
|
</if>
|
<if test="smsRecord.templateId!=null and smsRecord.templateId!=''">
|
and template_id like concat(concat('%',#{smsRecord.templateId}),'%')
|
</if>
|
<if test="smsRecord.resultId!=null">
|
and result_id = #{smsRecord.resultId}
|
</if>
|
order by id desc
|
</select>
|
|
<!--批量新增-->
|
<insert id="batchSaveSendRecord"
|
parameterType="cn.gistack.alerts.sms.entity.SmsRecord" useGeneratedKeys="true" keyProperty="id">
|
insert into sm_sms_record
|
(id,template_id,tel,content,response_status,response_msg,result_id,is_deleted,create_time)
|
<foreach collection="list" item="item" index="index" separator=",">
|
(
|
#{item.id},
|
#{item.templateId},
|
#{item.tel},
|
#{item.content},
|
#{item.responseStatus},
|
#{item.responseMsg},
|
#{item.resultId},
|
0,now()
|
)
|
</foreach>
|
</insert>
|
|
|
<!--站内信消息记录列表查询-->
|
<select id="msgPage" resultType="cn.gistack.alerts.sms.vo.SmsRecordVO">
|
select
|
smr.id,smr.content,smr.create_time,'发送成功' as responseMsg,smr.template_id,
|
a."name" as resName,
|
bu.name as userName,bu.phone as tel,
|
2 as type,
|
sar.rule_name as ruleName,sst.sms_type as smsType
|
from YWXT.sm_message_record smr
|
left join SJZT_MD."att_res_base" a on a."guid" = smr.res_guid
|
left join YWXT.blade_user bu on CAST(bu.id AS VARCHAR) = smr.recipient and bu.is_deleted = 0
|
left join YWXT.sm_alarm_rule sar on sar.id = smr.alarm_rule_id
|
left join YWXT.sm_sms_template sst on sst.template_id = smr.template_id and sst.is_deleted = 0
|
<where>
|
<if test="smsRecord.templateId!=null and smsRecord.templateId!=''">
|
and smr.template_id = #{smsRecord.templateId}
|
</if>
|
<if test="smsRecord.smsType!=null and smsRecord.smsType!=''">
|
and sst.sms_type = #{smsRecord.smsType}
|
</if>
|
<if test="smsRecord.tel!=null and smsRecord.tel!=''">
|
and bu.phone = #{smsRecord.tel}
|
</if>
|
<if test="smsRecord.content!=null and smsRecord.content!=''">
|
and smr.content like concat(concat('%',#{smsRecord.content}),'%')
|
</if>
|
<if test="smsRecord.userName!=null and smsRecord.userName!=''">
|
and bu.name like concat(concat('%',#{smsRecord.userName}),'%')
|
</if>
|
<if test="smsRecord.resName!=null and smsRecord.resName!=''">
|
and a."name" like concat(concat('%',#{smsRecord.resName}),'%')
|
</if>
|
<if test="smsRecord.startTime!=null and smsRecord.startTime!=''">
|
and DATE_FORMAT(smr.create_time,'%Y-%m-%d') >= #{smsRecord.startTime}
|
</if>
|
<if test="smsRecord.endTime!=null and smsRecord.endTime!=''">
|
and DATE_FORMAT(smr.create_time,'%Y-%m-%d') <= #{smsRecord.endTime}
|
</if>
|
<if test="list!=null and list.size()>0">
|
and smr.template_id in
|
<foreach collection="list" item="id" separator ="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
order by smr.id desc
|
</select>
|
|
<!--短信消息记录列表查询-->
|
<select id="smsPage" resultType="cn.gistack.alerts.sms.vo.SmsRecordVO">
|
select
|
ssr.id,ssr.tel,ssr.content,ssr.create_time,ssr.response_msg,ssr.template_id,
|
a."name" as resName,
|
bu.name as userName,
|
1 as type,
|
sar.rule_name as ruleName,sst.sms_type as smsType
|
from YWXT.sm_sms_record ssr
|
left join SJZT_MD."att_res_base" a on a."guid" = ssr.res_guid
|
left join YWXT.blade_user bu on bu.account = ssr.tel and bu.is_deleted = 0
|
left join YWXT.sm_alarm_rule sar on sar.id = ssr.alarm_rule_id
|
left join YWXT.sm_sms_template sst on sst.template_id = ssr.template_id and sst.is_deleted = 0
|
<where>
|
<if test="smsRecord.templateId!=null and smsRecord.templateId!=''">
|
and ssr.template_id = #{smsRecord.templateId}
|
</if>
|
<if test="smsRecord.smsType!=null and smsRecord.smsType!=''">
|
and sst.sms_type = #{smsRecord.smsType}
|
</if>
|
<if test="smsRecord.tel!=null and smsRecord.tel!=''">
|
and ssr.tel = #{smsRecord.tel}
|
</if>
|
<if test="smsRecord.content!=null and smsRecord.content!=''">
|
and ssr.content like concat(concat('%',#{smsRecord.content}),'%')
|
</if>
|
<if test="smsRecord.userName!=null and smsRecord.userName!=''">
|
and bu.name like concat(concat('%',#{smsRecord.userName}),'%')
|
</if>
|
<if test="smsRecord.resName!=null and smsRecord.resName!=''">
|
and a."name" like concat(concat('%',#{smsRecord.resName}),'%')
|
</if>
|
<if test="smsRecord.startTime!=null and smsRecord.startTime!=''">
|
and DATE_FORMAT(ssr.create_time,'%Y-%m-%d') >= #{smsRecord.startTime}
|
</if>
|
<if test="smsRecord.endTime!=null and smsRecord.endTime!=''">
|
and DATE_FORMAT(ssr.create_time,'%Y-%m-%d') <= #{smsRecord.endTime}
|
</if>
|
<if test="list!=null and list.size()>0">
|
and ssr.template_id in
|
<foreach collection="list" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
order by ssr.id desc
|
</select>
|
|
|
<!--短信和站内信消息记录列表查询-->
|
<select id="smsAndMsgPage" resultType="cn.gistack.alerts.sms.vo.SmsRecordVO">
|
(select
|
ssr.id,ssr.tel,ssr.content,ssr.create_time,ssr.response_msg,ssr.template_id,
|
a."name" as resName,
|
bu.name as userName,
|
1 as type,
|
sar.rule_name as ruleName,sst.sms_type as smsType
|
from YWXT.sm_sms_record ssr
|
left join SJZT_MD."att_res_base" a on a."guid" = ssr.res_guid
|
left join YWXT.blade_user bu on bu.account = ssr.tel and bu.is_deleted = 0
|
left join YWXT.sm_alarm_rule sar on sar.id = ssr.alarm_rule_id
|
left join YWXT.sm_sms_template sst on sst.template_id = ssr.template_id and sst.is_deleted = 0
|
<where>
|
<if test="smsRecord.templateId!=null and smsRecord.templateId!=''">
|
and ssr.template_id = #{smsRecord.templateId}
|
</if>
|
<if test="smsRecord.smsType!=null and smsRecord.smsType!=''">
|
and sst.sms_type = #{smsRecord.smsType}
|
</if>
|
<if test="smsRecord.tel!=null and smsRecord.tel!=''">
|
and ssr.tel = #{smsRecord.tel}
|
</if>
|
<if test="smsRecord.content!=null and smsRecord.content!=''">
|
and ssr.content like concat(concat('%',#{smsRecord.content}),'%')
|
</if>
|
<if test="smsRecord.userName!=null and smsRecord.userName!=''">
|
and bu.name like concat(concat('%',#{smsRecord.userName}),'%')
|
</if>
|
<if test="smsRecord.resName!=null and smsRecord.resName!=''">
|
and a."name" like concat(concat('%',#{smsRecord.resName}),'%')
|
</if>
|
<if test="smsRecord.startTime!=null and smsRecord.startTime!=''">
|
and DATE_FORMAT(ssr.create_time,'%Y-%m-%d') >= #{smsRecord.startTime}
|
</if>
|
<if test="smsRecord.endTime!=null and smsRecord.endTime!=''">
|
and DATE_FORMAT(ssr.create_time,'%Y-%m-%d') <= #{smsRecord.endTime}
|
</if>
|
<if test="list!=null and list.size()>0">
|
and ssr.template_id in
|
<foreach collection="list" item="id" separator="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
)
|
union all
|
(
|
select
|
smr.id,smr.content,smr.create_time,'发送成功' as responseMsg,smr.template_id,
|
a."name" as resName,
|
bu.name as userName,bu.phone as tel,
|
2 as type,
|
sar.rule_name as ruleName,sst.sms_type as smsType
|
from YWXT.sm_message_record smr
|
left join SJZT_MD."att_res_base" a on a."guid" = smr.res_guid
|
left join YWXT.blade_user bu on CAST(bu.id AS VARCHAR) = smr.recipient and bu.is_deleted = 0
|
left join YWXT.sm_alarm_rule sar on sar.id = smr.alarm_rule_id
|
left join YWXT.sm_sms_template sst on sst.template_id = smr.template_id and sst.is_deleted = 0
|
<where>
|
<if test="smsRecord.templateId!=null and smsRecord.templateId!=''">
|
and smr.template_id = #{smsRecord.templateId}
|
</if>
|
<if test="smsRecord.smsType!=null and smsRecord.smsType!=''">
|
and sst.sms_type = #{smsRecord.smsType}
|
</if>
|
<if test="smsRecord.tel!=null and smsRecord.tel!=''">
|
and bu.phone = #{smsRecord.tel}
|
</if>
|
<if test="smsRecord.content!=null and smsRecord.content!=''">
|
and smr.content like concat(concat('%',#{smsRecord.content}),'%')
|
</if>
|
<if test="smsRecord.userName!=null and smsRecord.userName!=''">
|
and bu.name like concat(concat('%',#{smsRecord.userName}),'%')
|
</if>
|
<if test="smsRecord.resName!=null and smsRecord.resName!=''">
|
and a."name" like concat(concat('%',#{smsRecord.resName}),'%')
|
</if>
|
<if test="smsRecord.startTime!=null and smsRecord.startTime!=''">
|
and DATE_FORMAT(smr.create_time,'%Y-%m-%d') >= #{smsRecord.startTime}
|
</if>
|
<if test="smsRecord.endTime!=null and smsRecord.endTime!=''">
|
and DATE_FORMAT(smr.create_time,'%Y-%m-%d') <= #{smsRecord.endTime}
|
</if>
|
<if test="list!=null and list.size()>0">
|
and smr.template_id in
|
<foreach collection="list" item="id" separator ="," open="(" close=")">
|
#{id}
|
</foreach>
|
</if>
|
</where>
|
)
|
</select>
|
|
</mapper>
|