CcCallPhoneMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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.ruoyi.aicall.mapper.CcCallPhoneMapper">
  6. <resultMap type="CcCallPhone" id="CcCallPhoneResult">
  7. <result property="id" column="id" />
  8. <result property="batchId" column="batch_id" />
  9. <result property="telephone" column="telephone" />
  10. <result property="custName" column="cust_name" />
  11. <result property="createtime" column="createtime" />
  12. <result property="callstatus" column="callstatus" />
  13. <result property="calloutTime" column="callout_time" />
  14. <result property="callcount" column="callcount" />
  15. <result property="callEndTime" column="call_end_time" />
  16. <result property="timeLen" column="time_len" />
  17. <result property="validTimeLen" column="valid_time_len" />
  18. <result property="uuid" column="uuid" />
  19. <result property="connectedTime" column="connected_time" />
  20. <result property="hangupCause" column="hangup_cause" />
  21. <result property="answeredTime" column="answered_time" />
  22. <result property="dialogue" column="dialogue" />
  23. <result property="wavfile" column="wavfile" />
  24. <result property="recordServerUrl" column="record_server_url" />
  25. <result property="bizJson" column="biz_json" />
  26. <result property="dialogueCount" column="dialogue_count" />
  27. <result property="acdOpnum" column="acd_opnum" />
  28. <result property="acdQueueTime" column="dialogue_count" />
  29. <result property="acdWaitTime" column="dialogue_count" />
  30. <result property="ttsText" column="tts_text" />
  31. <result property="intent" column="intent" />
  32. <result property="asrSeconds" column="asr_seconds" />
  33. <result property="ttsTimes" column="tts_times" />
  34. <result property="ttsFlowTokens" column="tts_flow_tokens" />
  35. <result property="inputTokens" column="input_tokens" />
  36. <result property="outputTokens" column="output_tokens" />
  37. <result property="totalCost" column="total_cost" />
  38. <result property="billingStatus" column="billing_status" />
  39. <result property="callerNumber" column="caller_number" />
  40. <result property="ivrDtmfDigits" column="ivr_dtmf_digits" />
  41. <result property="manualAnsweredTime" column="manual_answered_time" />
  42. <result property="manualAnsweredTimeLen" column="manual_answered_time_len" />
  43. </resultMap>
  44. <sql id="selectCcCallPhoneVo">
  45. select id, batch_id, telephone, cust_name, createtime, callstatus, callout_time,
  46. callcount, call_end_time, time_len, valid_time_len, uuid, connected_time,
  47. hangup_cause, answered_time, dialogue, wavfile, record_server_url, biz_json,
  48. dialogue_count, acd_opnum, acd_queue_time, acd_wait_time, tts_text, intent,
  49. asr_seconds, tts_times, tts_flow_tokens, input_tokens, output_tokens,
  50. total_cost, billing_status, caller_number, ivr_dtmf_digits, manual_answered_time, manual_answered_time_len from cc_call_phone
  51. </sql>
  52. <select id="selectCcCallPhoneList" parameterType="CcCallPhone" resultMap="CcCallPhoneResult">
  53. <include refid="selectCcCallPhoneVo"/>
  54. <where>
  55. <if test="uuid != null and uuid != '' "> and uuid = #{uuid}</if>
  56. <if test="batchId != null "> and batch_id = #{batchId}</if>
  57. <if test="telephone != null and telephone != ''"> and telephone = #{telephone}</if>
  58. <if test="custName != null and custName != ''"> and cust_name = #{custName}</if>
  59. <if test="callstatus != null "> and callstatus = #{callstatus}</if>
  60. <if test="params.calloutTimeStart != null and params.calloutTimeStart != ''"><!-- 开始时间检索 -->
  61. AND callout_time &gt;= #{params.calloutTimeStart}
  62. </if>
  63. <if test="params.calloutTimeEnd != null and params.calloutTimeEnd != ''"><!-- 结束时间检索 -->
  64. AND callout_time &lt;= #{params.calloutTimeEnd}
  65. </if>
  66. <if test="params.callEndTimeStart != null and params.callEndTimeStart != ''"><!-- 开始时间检索 -->
  67. AND call_end_time &gt;= #{params.callEndTimeStart}
  68. </if>
  69. <if test="params.callEndTimeEnd != null and params.callEndTimeEnd != ''"><!-- 结束时间检索 -->
  70. AND call_end_time &lt;= #{params.callEndTimeEnd}
  71. </if>
  72. <if test="params.timeLenStart != null and params.timeLenStart != ''"><!-- 开始时间检索 -->
  73. AND time_len &gt;= #{params.timeLenStart}
  74. </if>
  75. <if test="params.timeLenEnd != null and params.timeLenEnd != ''"><!-- 结束时间检索 -->
  76. AND time_len &lt;= #{params.timeLenEnd}
  77. </if>
  78. <if test="params.connectedTimeStart != null and params.connectedTimeStart != ''"><!-- 开始时间检索 -->
  79. AND connected_time &gt;= #{params.connectedTimeStart}
  80. </if>
  81. <if test="params.connectedTimeEnd != null and params.connectedTimeEnd != ''"><!-- 结束时间检索 -->
  82. AND connected_time &lt;= #{connectedTimeEnd}
  83. </if>
  84. <if test="params.answeredTimeStart != null and params.answeredTimeStart != ''"><!-- 开始时间检索 -->
  85. AND answered_time &gt;= #{params.answeredTimeStart}
  86. </if>
  87. <if test="params.answeredTimeEnd != null and params.answeredTimeEnd != ''"><!-- 结束时间检索 -->
  88. AND answered_time &lt;= #{params.answeredTimeEnd}
  89. </if>
  90. <if test="batchId != null and batchId != ''">
  91. AND batch_id = #{batchId}
  92. </if>
  93. <if test="intent != null and intent != ''">
  94. AND intent = #{intent}
  95. </if>
  96. <if test="billingStatus != null ">
  97. and billing_status = #{billingStatus}
  98. </if>
  99. <if test="callerNumber != null and callerNumber != '' ">
  100. and caller_number = #{callerNumber}
  101. </if>
  102. AND callstatus >= 3 AND call_end_time > 0
  103. </where>
  104. order by call_end_time desc
  105. </select>
  106. <select id="getCustIntentionList" parameterType="CcCallPhone" resultMap="CcCallPhoneResult">
  107. <include refid="selectCcCallPhoneVo"/>
  108. where intent = '' AND callstatus >= 3 AND call_end_time > 0 limit 100
  109. </select>
  110. <select id="selectCcCallPhoneById" parameterType="String" resultMap="CcCallPhoneResult">
  111. <include refid="selectCcCallPhoneVo"/>
  112. where id = #{id}
  113. </select>
  114. <insert id="insertCcCallPhone" parameterType="CcCallPhone">
  115. insert into cc_call_phone
  116. <trim prefix="(" suffix=")" suffixOverrides=",">
  117. <if test="id != null">id,</if>
  118. <if test="batchId != null">batch_id,</if>
  119. <if test="telephone != null and telephone != ''">telephone,</if>
  120. <if test="custName != null and custName != ''">cust_name,</if>
  121. <if test="createtime != null">createtime,</if>
  122. <if test="callstatus != null">callstatus,</if>
  123. <if test="calloutTime != null">callout_time,</if>
  124. <if test="callcount != null">callcount,</if>
  125. <if test="callEndTime != null">call_end_time,</if>
  126. <if test="timeLen != null">time_len,</if>
  127. <if test="validTimeLen != null">valid_time_len,</if>
  128. <if test="uuid != null and uuid != ''">uuid,</if>
  129. <if test="connectedTime != null">connected_time,</if>
  130. <if test="hangupCause != null and hangupCause != ''">hangup_cause,</if>
  131. <if test="answeredTime != null">answered_time,</if>
  132. <if test="dialogue != null">dialogue,</if>
  133. <if test="wavfile != null and wavfile != ''">wavfile,</if>
  134. <if test="recordServerUrl != null and recordServerUrl != ''">record_server_url,</if>
  135. <if test="bizJson != null and bizJson != ''">biz_json,</if>
  136. <if test="dialogueCount != null">dialogue_count,</if>
  137. <if test="acdOpnum != null and acdOpnum != ''">acd_opnum,</if>
  138. <if test="acdQueueTime != null">acd_queue_time,</if>
  139. <if test="acdWaitTime != null">acd_wait_time,</if>
  140. <if test="ttsText != null">tts_text,</if>
  141. <if test="intent != null">intent,</if>
  142. </trim>
  143. <trim prefix="values (" suffix=")" suffixOverrides=",">
  144. <if test="id != null">#{id},</if>
  145. <if test="batchId != null">#{batchId},</if>
  146. <if test="telephone != null and telephone != ''">#{telephone},</if>
  147. <if test="custName != null and custName != ''">#{cust_name},</if>
  148. <if test="createtime != null">#{createtime},</if>
  149. <if test="callstatus != null">#{callstatus},</if>
  150. <if test="calloutTime != null">#{calloutTime},</if>
  151. <if test="callcount != null">#{callcount},</if>
  152. <if test="callEndTime != null">#{callEndTime},</if>
  153. <if test="timeLen != null">#{timeLen},</if>
  154. <if test="validTimeLen != null">#{validTimeLen},</if>
  155. <if test="uuid != null and uuid != ''">#{uuid},</if>
  156. <if test="connectedTime != null">#{connectedTime},</if>
  157. <if test="hangupCause != null and hangupCause != ''">#{hangupCause},</if>
  158. <if test="answeredTime != null">#{answeredTime},</if>
  159. <if test="dialogue != null">#{dialogue},</if>
  160. <if test="wavfile != null and wavfile != ''">#{wavfile},</if>
  161. <if test="recordServerUrl != null and recordServerUrl != ''">#{recordServerUrl},</if>
  162. <if test="bizJson != null and bizJson != ''">#{bizJson},</if>
  163. <if test="dialogueCount != null">#{dialogueCount},</if>
  164. <if test="acdOpnum != null and acdOpnum != ''">#{acdOpnum},</if>
  165. <if test="acdQueueTime != null">#{acdQueueTime},</if>
  166. <if test="acdWaitTime != null">#{acdWaitTime},</if>
  167. <if test="ttsText != null">#{ttsText},</if>
  168. <if test="intent != null">#{intent},</if>
  169. </trim>
  170. </insert>
  171. <update id="updateCcCallPhone" parameterType="CcCallPhone">
  172. update cc_call_phone
  173. <trim prefix="SET" suffixOverrides=",">
  174. <if test="batchId != null">batch_id = #{batchId},</if>
  175. <if test="telephone != null and telephone != ''">telephone = #{telephone},</if>
  176. <if test="custName != null and custName != ''">cust_name = #{custName},</if>
  177. <if test="createtime != null">createtime = #{createtime},</if>
  178. <if test="callstatus != null">callstatus = #{callstatus},</if>
  179. <if test="calloutTime != null">callout_time = #{calloutTime},</if>
  180. <if test="callcount != null">callcount = #{callcount},</if>
  181. <if test="callEndTime != null">call_end_time = #{callEndTime},</if>
  182. <if test="timeLen != null">time_len = #{timeLen},</if>
  183. <if test="validTimeLen != null">valid_time_len = #{validTimeLen},</if>
  184. <if test="uuid != null and uuid != ''">uuid = #{uuid},</if>
  185. <if test="connectedTime != null">connected_time = #{connectedTime},</if>
  186. <if test="hangupCause != null and hangupCause != ''">hangup_cause = #{hangupCause},</if>
  187. <if test="answeredTime != null">answered_time = #{answeredTime},</if>
  188. <if test="dialogue != null">dialogue = #{dialogue},</if>
  189. <if test="wavfile != null and wavfile != ''">wavfile = #{wavfile},</if>
  190. <if test="recordServerUrl != null and recordServerUrl != ''">record_server_url = #{recordServerUrl},</if>
  191. <if test="bizJson != null and bizJson != ''">biz_json = #{bizJson},</if>
  192. <if test="dialogueCount != null">dialogue_count = #{dialogueCount},</if>
  193. <if test="acdOpnum != null and acdOpnum != ''">acd_opnum = #{acdOpnum},</if>
  194. <if test="acdQueueTime != null">acd_queue_time = #{acdQueueTime},</if>
  195. <if test="acdWaitTime != null">acd_wait_time = #{acdWaitTime},</if>
  196. <if test="ttsText != null">tts_text = #{ttsText},</if>
  197. <if test="intent != null">intent = #{intent},</if>
  198. </trim>
  199. where id = #{id}
  200. </update>
  201. <delete id="deleteCcCallPhoneById" parameterType="String">
  202. delete from cc_call_phone where id = #{id}
  203. </delete>
  204. <delete id="deleteCcCallPhoneByIds" parameterType="String">
  205. delete from cc_call_phone where id in
  206. <foreach item="id" collection="array" open="(" separator="," close=")">
  207. #{id}
  208. </foreach>
  209. </delete>
  210. <select id="statByBatchId" parameterType="Long" resultType="com.ruoyi.aicall.model.CallTaskStatModel">
  211. SELECT batch_id AS batchId,
  212. COUNT(1) AS phoneCount,
  213. SUM(CASE WHEN callout_time > 0 THEN 1 ELSE 0 END) AS callCount,
  214. SUM(CASE WHEN answered_time > 0 THEN 1 ELSE 0 END) AS connectCount
  215. FROM cc_call_phone
  216. WHERE batch_id = #{batchId}
  217. </select>
  218. <insert id="batchInsertCcCallPhone" parameterType="java.util.List">
  219. INSERT INTO cc_call_phone (
  220. id, batch_id, telephone, cust_name, createtime, callstatus,
  221. callout_time, callcount, call_end_time, time_len, valid_time_len,
  222. uuid, connected_time, hangup_cause,
  223. answered_time, dialogue, wavfile, record_server_url, biz_json,
  224. dialogue_count,acd_opnum,acd_queue_time,acd_wait_time,
  225. tts_text, intent
  226. )
  227. VALUES
  228. <foreach collection="list" item="item" separator=",">
  229. (
  230. #{item.id}, #{item.batchId}, #{item.telephone}, #{item.custName},
  231. #{item.createtime}, #{item.callstatus}, #{item.calloutTime},
  232. #{item.callcount}, #{item.callEndTime}, #{item.timeLen},
  233. #{item.validTimeLen}, #{item.uuid},
  234. #{item.connectedTime}, #{item.hangupCause},
  235. #{item.answeredTime}, #{item.dialogue}, #{item.wavfile},
  236. #{item.recordServerUrl}, #{item.bizJson}, #{item.dialogueCount},
  237. #{item.acdOpnum}, #{item.acdQueueTime}, #{item.acdWaitTime},
  238. #{item.ttsText}, #{item.intent}
  239. )
  240. </foreach>
  241. </insert>
  242. <update id="updateIntentionByIds">
  243. UPDATE cc_call_phone
  244. SET intent = #{intention}
  245. WHERE id IN
  246. <foreach collection="phoneIds" item="id" open="(" separator="," close=")">
  247. #{id}
  248. </foreach>
  249. </update>
  250. <select id="selectNoHangupCalls" parameterType="Long" resultMap="CcCallPhoneResult">
  251. <include refid="selectCcCallPhoneVo"/>
  252. <where>
  253. AND batch_id = #{batchId}
  254. AND callstatus >= 2
  255. AND call_end_time = 0
  256. </where>
  257. order by call_end_time desc
  258. </select>
  259. <insert id="bakCallPhoneByBatchId" parameterType="Long">
  260. insert into his_cc_call_phone select * from cc_call_phone where batch_id = #{batchId}
  261. </insert>
  262. <delete id="delCallPhoneByBatchId" parameterType="Long">
  263. delete from cc_call_phone where batch_id = #{batchId}
  264. </delete>
  265. <select id="isDuplicateEntry" resultType="java.lang.String">
  266. SELECT DISTINCT telephone FROM cc_call_phone
  267. WHERE batch_id = #{batchId} AND callstatus = 0
  268. AND telephone IN
  269. <foreach collection="phoneList" item="phone" open="(" separator="," close=")">
  270. #{phone.phoneNum}
  271. </foreach>
  272. </select>
  273. </mapper>