CompanyVoiceRoboticCallLogSendmsgMapper.xml 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.company.mapper.CompanyVoiceRoboticCallLogSendmsgMapper">
  6. <resultMap type="CompanyVoiceRoboticCallLogSendmsg" id="CompanyVoiceRoboticCallLogSendmsgResult">
  7. <result property="logId" column="log_id" />
  8. <result property="roboticId" column="robotic_id" />
  9. <result property="callerId" column="caller_id" />
  10. <result property="runTime" column="run_time" />
  11. <result property="runParam" column="run_param" />
  12. <result property="result" column="result" />
  13. <result property="status" column="status" />
  14. <result property="createTime" column="create_time" />
  15. <result property="companyId" column="company_id" />
  16. <result property="companyUserId" column="company_user_id" />
  17. <result property="tempId" column="temp_id" />
  18. <result property="cost" column="cost" />
  19. <result property="contentLen" column="content_len" />
  20. </resultMap>
  21. <sql id="selectCompanyVoiceRoboticCallLogSendmsgVo">
  22. select log_id, robotic_id, caller_id, run_time, run_param, result, status, create_time, company_id, company_user_id, temp_id, cost, content_len from company_voice_robotic_call_log_sendmsg
  23. </sql>
  24. <select id="selectCompanyVoiceRoboticCallLogSendmsgList" parameterType="CompanyVoiceRoboticCallLogSendmsg" resultMap="CompanyVoiceRoboticCallLogSendmsgResult">
  25. <include refid="selectCompanyVoiceRoboticCallLogSendmsgVo"/>
  26. <where>
  27. <if test="roboticId != null "> and robotic_id = #{roboticId}</if>
  28. <if test="callerId != null "> and caller_id = #{callerId}</if>
  29. <if test="runTime != null "> and run_time = #{runTime}</if>
  30. <if test="runParam != null and runParam != ''"> and run_param = #{runParam}</if>
  31. <if test="result != null and result != ''"> and result = #{result}</if>
  32. <if test="status != null "> and status = #{status}</if>
  33. <if test="companyId != null "> and company_id = #{companyId}</if>
  34. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  35. <if test="tempId != null "> and temp_id = #{tempId}</if>
  36. <if test="cost != null "> and cost = #{cost}</if>
  37. <if test="contentLen != null "> and content_len = #{contentLen}</if>
  38. </where>
  39. </select>
  40. <select id="selectCompanyVoiceRoboticCallLogSendmsgGroupList" parameterType="CompanyVoiceRoboticCallLogSendmsg" resultType="com.fs.company.domain.CompanyVoiceRoboticCallLogSendmsg">
  41. select
  42. robotic_id,
  43. cvr.name,
  44. count(1) as totalRecordCount,
  45. sum(case when status = 1 then 1 else 0 end) as runningCount,
  46. sum(case when status = 2 then 1 else 0 end) as successCount,
  47. sum(case when status = 3 then 1 else 0 end) as failCount,
  48. concat(round(ifnull(sum(case when cc.is_send_msg = 1 then 1 else 0 end) * 100.0 / nullif(count(1), 0),0),2),'%') as successRate
  49. from company_voice_robotic_call_log_sendmsg msg
  50. inner join company_voice_robotic cvr on cvr.id = msg.robotic_id
  51. left join company_voice_robotic_callees cc on cc.id = msg.caller_id
  52. <where>
  53. <if test="roboticId != null">and robotic_id = #{roboticId}</if>
  54. <if test="callerId != null">and caller_id = #{callerId}</if>
  55. <if test="runTime != null">and run_time = #{runTime}</if>
  56. <if test="runParam != null and runParam != ''">and run_param = #{runParam}</if>
  57. <if test="result != null and result != ''">and result = #{result}</if>
  58. <if test="status != null">and status = #{status}</if>
  59. <if test="companyId != null">and company_id = #{companyId}</if>
  60. <if test="companyUserId != null">and company_user_id = #{companyUserId}</if>
  61. <if test="tempId != null">and temp_id = #{tempId}</if>
  62. <if test="cost != null">and cost = #{cost}</if>
  63. <if test="contentLen != null">and content_len = #{contentLen}</if>
  64. </where>
  65. group by robotic_id
  66. </select>
  67. <select id="selectCompanyVoiceRoboticCallLogSendmsgByLogId" parameterType="Long" resultMap="CompanyVoiceRoboticCallLogSendmsgResult">
  68. <include refid="selectCompanyVoiceRoboticCallLogSendmsgVo"/>
  69. where log_id = #{logId}
  70. </select>
  71. <insert id="insertCompanyVoiceRoboticCallLogSendmsg" parameterType="CompanyVoiceRoboticCallLogSendmsg" useGeneratedKeys="true" keyProperty="logId">
  72. insert into company_voice_robotic_call_log_sendmsg
  73. <trim prefix="(" suffix=")" suffixOverrides=",">
  74. <if test="roboticId != null">robotic_id,</if>
  75. <if test="callerId != null">caller_id,</if>
  76. <if test="runTime != null">run_time,</if>
  77. <if test="runParam != null">run_param,</if>
  78. <if test="result != null">result,</if>
  79. <if test="status != null">status,</if>
  80. <if test="createTime != null">create_time,</if>
  81. <if test="companyId != null">company_id,</if>
  82. <if test="companyUserId != null">company_user_id,</if>
  83. <if test="tempId != null">temp_id,</if>
  84. <if test="cost != null">cost,</if>
  85. <if test="contentLen != null">content_len,</if>
  86. </trim>
  87. <trim prefix="values (" suffix=")" suffixOverrides=",">
  88. <if test="roboticId != null">#{roboticId},</if>
  89. <if test="callerId != null">#{callerId},</if>
  90. <if test="runTime != null">#{runTime},</if>
  91. <if test="runParam != null">#{runParam},</if>
  92. <if test="result != null">#{result},</if>
  93. <if test="status != null">#{status},</if>
  94. <if test="createTime != null">#{createTime},</if>
  95. <if test="companyId != null">#{companyId},</if>
  96. <if test="companyUserId != null">#{companyUserId},</if>
  97. <if test="tempId != null">#{tempId},</if>
  98. <if test="cost != null">#{cost},</if>
  99. <if test="contentLen != null">#{contentLen},</if>
  100. </trim>
  101. </insert>
  102. <update id="updateCompanyVoiceRoboticCallLogSendmsg" parameterType="CompanyVoiceRoboticCallLogSendmsg">
  103. update company_voice_robotic_call_log_sendmsg
  104. <trim prefix="SET" suffixOverrides=",">
  105. <if test="roboticId != null">robotic_id = #{roboticId},</if>
  106. <if test="callerId != null">caller_id = #{callerId},</if>
  107. <if test="runTime != null">run_time = #{runTime},</if>
  108. <if test="runParam != null">run_param = #{runParam},</if>
  109. <if test="result != null">result = #{result},</if>
  110. <if test="status != null">status = #{status},</if>
  111. <if test="createTime != null">create_time = #{createTime},</if>
  112. <if test="companyId != null">company_id = #{companyId},</if>
  113. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  114. <if test="tempId != null">temp_id = #{tempId},</if>
  115. <if test="cost != null">cost = #{cost},</if>
  116. <if test="contentLen != null">content_len = #{contentLen},</if>
  117. </trim>
  118. where log_id = #{logId}
  119. </update>
  120. <delete id="deleteCompanyVoiceRoboticCallLogSendmsgByLogId" parameterType="Long">
  121. delete from company_voice_robotic_call_log_sendmsg where log_id = #{logId}
  122. </delete>
  123. <delete id="deleteCompanyVoiceRoboticCallLogSendmsgByLogIds" parameterType="String">
  124. delete from company_voice_robotic_call_log_sendmsg where log_id in
  125. <foreach item="logId" collection="array" open="(" separator="," close=")">
  126. #{logId}
  127. </foreach>
  128. </delete>
  129. <select id="listByCallerIdAndRoboticId" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogSendmsgVO" parameterType="CompanyVoiceRoboticCallLogSendmsg">
  130. SELECT
  131. t1.*,
  132. t2.company_name,
  133. t3.nick_name as companyUserName,
  134. t4.title as smsTempName,
  135. cc.phone,
  136. cvr.name as robotic_name
  137. FROM company_voice_robotic_call_log_sendmsg t1
  138. left join company_voice_robotic_callees cc on cc.id = t1.caller_id
  139. left join company t2 on t1.company_id = t2.company_id
  140. left join company_user t3 on t3.user_id = t1.company_user_id
  141. left join company_sms_temp t4 on t4.temp_id = t1.temp_id
  142. left join company_voice_robotic cvr on cvr.id = t1.robotic_id
  143. where 1=1
  144. <if test="roboticId != null">and t1.robotic_id = #{roboticId}</if>
  145. <if test="callerId != null">and t1.caller_id = #{callerId}</if>
  146. <if test="callerIds != null and callerIds.size() > 0">
  147. AND t1.caller_id IN
  148. <foreach collection='callerIds' item='item' open='(' separator=',' close=')'>
  149. #{item}
  150. </foreach>
  151. </if>
  152. <if test="phone != null and phone != ''">
  153. and cc.phone like concat('%', #{phone}, '%')
  154. </if>
  155. </select>
  156. <select id="selectCompanyVoiceRoboticCallLogSendMsgCount" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogCount">
  157. select
  158. count(1) as recordCount,
  159. sum(case when status = 2 then 1 else 0 end) as successRecordCount,
  160. sum(case when run_time &gt;= CURDATE() and run_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY) then 1 else 0 end) as todayCount,
  161. sum(case when status = 2 and run_time &gt;= CURDATE() and run_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY) then 1 else 0 end) as todaySuccessCount
  162. from company_voice_robotic_call_log_sendmsg msg
  163. inner join company_voice_robotic cvr on cvr.id = msg.robotic_id
  164. </select>
  165. </mapper>