CompanyVoiceRoboticCallLogSendmsgMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. from company_voice_robotic_call_log_sendmsg msg
  49. left join company_voice_robotic cvr on cvr.id = msg.robotic_id
  50. <where>
  51. <if test="roboticId != null">and robotic_id = #{roboticId}</if>
  52. <if test="callerId != null">and caller_id = #{callerId}</if>
  53. <if test="runTime != null">and run_time = #{runTime}</if>
  54. <if test="runParam != null and runParam != ''">and run_param = #{runParam}</if>
  55. <if test="result != null and result != ''">and result = #{result}</if>
  56. <if test="status != null">and status = #{status}</if>
  57. <if test="companyId != null">and company_id = #{companyId}</if>
  58. <if test="companyUserId != null">and company_user_id = #{companyUserId}</if>
  59. <if test="tempId != null">and temp_id = #{tempId}</if>
  60. <if test="cost != null">and cost = #{cost}</if>
  61. <if test="contentLen != null">and content_len = #{contentLen}</if>
  62. </where>
  63. group by robotic_id
  64. </select>
  65. <select id="selectCompanyVoiceRoboticCallLogSendmsgByLogId" parameterType="Long" resultMap="CompanyVoiceRoboticCallLogSendmsgResult">
  66. <include refid="selectCompanyVoiceRoboticCallLogSendmsgVo"/>
  67. where log_id = #{logId}
  68. </select>
  69. <insert id="insertCompanyVoiceRoboticCallLogSendmsg" parameterType="CompanyVoiceRoboticCallLogSendmsg" useGeneratedKeys="true" keyProperty="logId">
  70. insert into company_voice_robotic_call_log_sendmsg
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="roboticId != null">robotic_id,</if>
  73. <if test="callerId != null">caller_id,</if>
  74. <if test="runTime != null">run_time,</if>
  75. <if test="runParam != null">run_param,</if>
  76. <if test="result != null">result,</if>
  77. <if test="status != null">status,</if>
  78. <if test="createTime != null">create_time,</if>
  79. <if test="companyId != null">company_id,</if>
  80. <if test="companyUserId != null">company_user_id,</if>
  81. <if test="tempId != null">temp_id,</if>
  82. <if test="cost != null">cost,</if>
  83. <if test="contentLen != null">content_len,</if>
  84. </trim>
  85. <trim prefix="values (" suffix=")" suffixOverrides=",">
  86. <if test="roboticId != null">#{roboticId},</if>
  87. <if test="callerId != null">#{callerId},</if>
  88. <if test="runTime != null">#{runTime},</if>
  89. <if test="runParam != null">#{runParam},</if>
  90. <if test="result != null">#{result},</if>
  91. <if test="status != null">#{status},</if>
  92. <if test="createTime != null">#{createTime},</if>
  93. <if test="companyId != null">#{companyId},</if>
  94. <if test="companyUserId != null">#{companyUserId},</if>
  95. <if test="tempId != null">#{tempId},</if>
  96. <if test="cost != null">#{cost},</if>
  97. <if test="contentLen != null">#{contentLen},</if>
  98. </trim>
  99. </insert>
  100. <update id="updateCompanyVoiceRoboticCallLogSendmsg" parameterType="CompanyVoiceRoboticCallLogSendmsg">
  101. update company_voice_robotic_call_log_sendmsg
  102. <trim prefix="SET" suffixOverrides=",">
  103. <if test="roboticId != null">robotic_id = #{roboticId},</if>
  104. <if test="callerId != null">caller_id = #{callerId},</if>
  105. <if test="runTime != null">run_time = #{runTime},</if>
  106. <if test="runParam != null">run_param = #{runParam},</if>
  107. <if test="result != null">result = #{result},</if>
  108. <if test="status != null">status = #{status},</if>
  109. <if test="createTime != null">create_time = #{createTime},</if>
  110. <if test="companyId != null">company_id = #{companyId},</if>
  111. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  112. <if test="tempId != null">temp_id = #{tempId},</if>
  113. <if test="cost != null">cost = #{cost},</if>
  114. <if test="contentLen != null">content_len = #{contentLen},</if>
  115. </trim>
  116. where log_id = #{logId}
  117. </update>
  118. <delete id="deleteCompanyVoiceRoboticCallLogSendmsgByLogId" parameterType="Long">
  119. delete from company_voice_robotic_call_log_sendmsg where log_id = #{logId}
  120. </delete>
  121. <delete id="deleteCompanyVoiceRoboticCallLogSendmsgByLogIds" parameterType="String">
  122. delete from company_voice_robotic_call_log_sendmsg where log_id in
  123. <foreach item="logId" collection="array" open="(" separator="," close=")">
  124. #{logId}
  125. </foreach>
  126. </delete>
  127. <select id="listByCallerIdAndRoboticId" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogSendmsgVO" parameterType="CompanyVoiceRoboticCallLogSendmsg">
  128. SELECT
  129. t1.*,
  130. t2.company_name,
  131. t3.nick_name as companyUserName,
  132. t4.title as smsTempName,
  133. cc.phone
  134. FROM company_voice_robotic_call_log_sendmsg t1
  135. left join company_voice_robotic_callees cc on cc.id = t1.caller_id
  136. left join company t2 on t1.company_id = t2.company_id
  137. left join company_user t3 on t3.user_id = t1.company_user_id
  138. left join company_sms_temp t4 on t4.temp_id = t1.temp_id
  139. where 1=1
  140. <if test="roboticId != null">and t1.robotic_id = #{roboticId}</if>
  141. <if test="callerId != null">and t1.caller_id = #{callerId}</if>
  142. <if test="callerIds != null and callerIds.size() > 0">
  143. AND t1.caller_id IN
  144. <foreach collection='callerIds' item='item' open='(' separator=',' close=')'>
  145. #{item}
  146. </foreach>
  147. </if>
  148. <if test="phone != null and phone != ''">
  149. and cc.phone like concat('%', #{phone}, '%')
  150. </if>
  151. </select>
  152. <select id="selectCompanyVoiceRoboticCallLogSendMsgCount" resultType="com.fs.company.vo.CompanyVoiceRoboticCallLogCount">
  153. select
  154. count(1) as recordCount,
  155. sum(case when status = 2 then 1 else 0 end) as successRecordCount,
  156. sum(case when run_time &gt;= CURDATE() and run_time &lt; DATE_ADD(CURDATE(), INTERVAL 1 DAY) then 1 else 0 end) as todayCount,
  157. 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
  158. from company_voice_robotic_call_log_sendmsg msg
  159. </select>
  160. </mapper>