QwSopTempVoiceMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.sop.mapper.QwSopTempVoiceMapper">
  6. <resultMap type="QwSopTempVoice" id="QwSopTempVoiceResult">
  7. <result property="id" column="id" />
  8. <result property="companyUserId" column="company_user_id" />
  9. <result property="companyId" column="company_id" />
  10. <result property="tempId" column="temp_id" />
  11. <result property="ruleId" column="rule_id" />
  12. <result property="contentId" column="content_id" />
  13. <result property="voiceTxt" column="voice_txt" />
  14. <result property="voiceUrl" column="voice_url" />
  15. <result property="userVoiceUrl" column="user_voice_url" />
  16. <result property="recordType" column="record_type" />
  17. <result property="createTime" column="create_time" />
  18. </resultMap>
  19. <sql id="selectQwSopTempVoiceVo">
  20. select id,company_user_id, temp_id, rule_id, content_id, voice_txt, voice_url, create_time from qw_sop_temp_voice
  21. </sql>
  22. <select id="selectQwSopTempVoiceList" parameterType="QwSopTempVoice" resultMap="QwSopTempVoiceResult">
  23. <include refid="selectQwSopTempVoiceVo"/>
  24. <where>
  25. <if test="tempId != null and tempId != ''"> and temp_id = #{tempId}</if>
  26. <if test="ruleId != null "> and rule_id = #{ruleId}</if>
  27. <if test="contentId != null "> and content_id = #{contentId}</if>
  28. <if test="voiceTxt != null and voiceTxt != ''"> and voice_txt = #{voiceTxt}</if>
  29. <if test="voiceUrl != null and voiceUrl != ''"> and voice_url = #{voiceUrl}</if>
  30. </where>
  31. </select>
  32. <select id="selectQwSopTempVoiceById" parameterType="Long" resultMap="QwSopTempVoiceResult">
  33. select id,company_user_id,duration, temp_id, rule_id, content_id, voice_txt, voice_url,user_voice_url,record_type, create_time from qw_sop_temp_voice
  34. where id = #{id}
  35. </select>
  36. <select id="listVoice" resultType="com.fs.sop.domain.QwSopTempVoice">
  37. select * from qw_sop_temp_voice where temp_id = #{tempId} and company_user_id in
  38. <foreach collection="salesIds" item="item" separator="," open="(" close=")">#{item}</foreach>
  39. </select>
  40. <select id="getVoice" resultType="com.fs.sop.domain.QwSopTempVoice">
  41. select a.* from qw_sop_temp_voice a
  42. where a.company_user_id = #{companyUserId}
  43. and a.company_id = #{companyId}
  44. and a.temp_id = #{tempId}
  45. and a.rule_id = #{rulesId}
  46. </select>
  47. <select id="listVoiceTemp" resultType="com.fs.sop.domain.QwSopTempVoice">
  48. select * from qw_sop_temp_voice a where a.temp_id = #{tempId} and a.day_id =#{dayId}
  49. </select>
  50. <select id="getVoiceByText" resultType="com.fs.sop.domain.QwSopTempVoice">
  51. select a.* from qw_sop_temp_voice a
  52. where a.company_user_id = #{companyUserId}
  53. and a.voice_txt in <foreach collection="textList" item="txt" open="(" close=")" separator=",">#{txt}</foreach>
  54. </select>
  55. <select id="selectAllByUserIds" resultType="com.fs.sop.domain.QwSopTempVoice">
  56. select * from qw_sop_temp_voice a
  57. where a.company_user_id in <foreach collection="userIdList" open="(" separator="," close=")" item="item">#{item}</foreach>
  58. </select>
  59. <select id="selectQwSopTempVoiceByIdAndText" resultType="com.fs.sop.domain.QwSopTempVoice">
  60. select id,company_user_id companyUserId,voice_txt voiceTxt from qw_sop_temp_voice where id = #{id}
  61. and voice_txt = #{voiceTxt} and record_type in (0,1) limit 1
  62. </select>
  63. <select id="selectQwSopTempVoiceByIdAndUserVoiceUrl" resultType="com.fs.sop.domain.QwSopTempVoice" >
  64. select id,company_user_id companyUserId,voice_txt voiceTxt from qw_sop_temp_voice where id = #{id} and record_type in (0,1,2) limit 1
  65. </select>
  66. <select id="selectQwSopTempVoiceNewList" resultType="com.fs.sop.domain.QwSopTempVoice">
  67. select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
  68. user_voice_url userVoiceUrl from qw_sop_temp_voice
  69. <where>
  70. <if test="companyUserId != null"> and company_user_id = #{companyUserId}</if>
  71. <if test="recordType != null"> and record_type = #{recordType}</if>
  72. </where>
  73. order by update_time desc,id desc
  74. </select>
  75. <select id="selectQwSopTempVoiceByQwUserIds" resultMap="QwSopTempVoiceResult">
  76. select * from qw_sop_temp_voice where record_type = 0 and qw_user_id in
  77. <foreach item="qwUserId" collection="ids" open="(" separator="," close=")">
  78. #{qwUserId}
  79. </foreach>
  80. </select>
  81. <select id="selectQwSopTempVoiceByCompanyUserIdAndVoiceTxt" resultType="com.fs.sop.domain.QwSopTempVoice">
  82. select qw_user_id qwUserId,voice_url voiceUrl,voice_txt voiceTxt,user_voice_url userVoiceUrl,company_user_id companyUserId,
  83. record_type recordType,duration from qw_sop_temp_voice where company_user_id = #{companyUserId} and voice_txt = #{voiceTxt}
  84. </select>
  85. <select id="selectQwSopTempVoiceByCompanyUserIdAndQwUserId" resultType="com.fs.sop.domain.QwSopTempVoice">
  86. select id,company_user_id companyUserId,voice_url voiceUrl,voice_txt voiceTxt,duration
  87. from qw_sop_temp_voice
  88. where company_user_id = #{companyUserId} and qw_user_id = #{qwUserId}
  89. and voice_url is not null
  90. limit 1
  91. </select>
  92. <select id="selectQwSopTempVoiceListLimit" resultType="com.fs.sop.domain.QwSopTempVoice">
  93. select id,voice_txt voiceTxt,company_user_id companyUserId,voice_url voiceUrl,duration,record_type recordType,
  94. user_voice_url userVoiceUrl from qw_sop_temp_voice
  95. where record_type = #{recordType} and company_user_id is not null
  96. order by date_format(create_time,'%y%m%d') desc,company_user_id desc limit 10
  97. </select>
  98. <insert id="insertQwSopTempVoice" parameterType="QwSopTempVoice" useGeneratedKeys="true" keyProperty="id">
  99. insert into qw_sop_temp_voice
  100. <trim prefix="(" suffix=")" suffixOverrides=",">
  101. <if test="companyUserId != null">company_user_id,</if>
  102. <if test="qwUserId != null">qw_user_id,</if>
  103. <if test="companyId != null">company_id,</if>
  104. <if test="tempId != null">temp_id,</if>
  105. <if test="ruleId != null">rule_id,</if>
  106. <if test="contentId != null">content_id,</if>
  107. <if test="voiceTxt != null">voice_txt,</if>
  108. <if test="voiceUrl != null">voice_url,</if>
  109. <if test="userVoiceUrl != null">user_voice_url,</if>
  110. <if test="createTime != null">create_time,</if>
  111. <if test="duration != null">duration,</if>
  112. <if test="recordType != null">record_type,</if>
  113. </trim>
  114. <trim prefix="values (" suffix=")" suffixOverrides=",">
  115. <if test="companyUserId != null">#{companyUserId},</if>
  116. <if test="qwUserId != null">#{qwUserId},</if>
  117. <if test="companyId != null">#{companyId},</if>
  118. <if test="tempId != null">#{tempId},</if>
  119. <if test="ruleId != null">#{ruleId},</if>
  120. <if test="contentId != null">#{contentId},</if>
  121. <if test="voiceTxt != null">#{voiceTxt},</if>
  122. <if test="voiceUrl != null">#{voiceUrl},</if>
  123. <if test="userVoiceUrl != null">#{userVoiceUrl},</if>
  124. <if test="createTime != null">#{createTime},</if>
  125. <if test="duration != null">#{duration},</if>
  126. <if test="recordType != null">#{recordType},</if>
  127. </trim>
  128. </insert>
  129. <insert id="insertBatch">
  130. INSERT INTO qw_sop_temp_voice (temp_id, company_user_id, day_id, company_id, content_id, rule_id, voice_txt, voice_url,record_type, duration)
  131. VALUES
  132. <foreach collection="list" item="item" separator=",">
  133. (#{item.tempId}, #{item.companyUserId}, #{item.dayId}, #{item.companyId}, #{item.contentId}, #{item.ruleId}, #{item.voiceTxt}, #{item.voiceUrl}, #{item.recordType},#{item.duration})
  134. </foreach>
  135. </insert>
  136. <update id="updateQwSopTempVoice" parameterType="QwSopTempVoice">
  137. update qw_sop_temp_voice
  138. <trim prefix="SET" suffixOverrides=",">
  139. <if test="tempId != null">temp_id = #{tempId},</if>
  140. <if test="ruleId != null">rule_id = #{ruleId},</if>
  141. <if test="contentId != null">content_id = #{contentId},</if>
  142. <if test="voiceTxt != null">voice_txt = #{voiceTxt},</if>
  143. <if test="voiceUrl != null">voice_url = #{voiceUrl},</if>
  144. <if test="userVoiceUrl != null">user_voice_url = #{userVoiceUrl},</if>
  145. <if test="recordType != null">record_type = #{recordType},</if>
  146. <if test="createTime != null">create_time = #{createTime},</if>
  147. <if test="duration != null">duration = #{duration},</if>
  148. </trim>
  149. where id = #{id}
  150. </update>
  151. <delete id="deleteQwSopTempVoiceById" parameterType="Long">
  152. delete from qw_sop_temp_voice where id = #{id}
  153. </delete>
  154. <delete id="deleteQwSopTempVoiceByIds" parameterType="String">
  155. delete from qw_sop_temp_voice where id in
  156. <foreach item="id" collection="array" open="(" separator="," close=")">
  157. #{id}
  158. </foreach>
  159. </delete>
  160. <delete id="remove">
  161. delete from qw_sop_temp_voice a where a.temp_id = #{tempId} and a.day_id =#{dayId}
  162. </delete>
  163. <select id="convertSopVoiceEveryDay" resultType="com.fs.sop.domain.QwSopTempVoice">
  164. SELECT id,company_user_id,voice_txt
  165. FROM qw_sop_temp_voice
  166. WHERE voice_url IS NULL
  167. AND record_type = 0
  168. AND DATE(create_time) >= CURDATE() - INTERVAL 1 DAY
  169. </select>
  170. <update id="updateBatchWithDataSource">
  171. update qw_sop_temp_voice
  172. <trim prefix="SET" suffixOverrides=",">
  173. <trim prefix="voice_url = CASE id" suffix="END,">
  174. <foreach collection="list" item="item">
  175. WHEN #{item.id} THEN #{item.voiceUrl}
  176. </foreach>
  177. </trim>
  178. <trim prefix="duration = CASE id" suffix="END,">
  179. <foreach collection="list" item="item">
  180. WHEN #{item.id} THEN #{item.duration}
  181. </foreach>
  182. </trim>
  183. <trim prefix="user_voice_url = CASE id" suffix="END,">
  184. <foreach collection="list" item="item">
  185. WHEN #{item.id} THEN #{item.userVoiceUrl}
  186. </foreach>
  187. </trim>
  188. </trim>
  189. where id in
  190. <foreach collection="list" item="item" open="(" separator="," close=")">
  191. #{item.id}
  192. </foreach>
  193. </update>
  194. <select id="selectQwSopTempVoiceByCompanyUserId" resultType="com.fs.sop.domain.QwSopTempVoice">
  195. select id,voice_txt from qw_sop_temp_voice
  196. where company_user_id = #{companyUserId}
  197. and record_type =1
  198. <if test="keyword != null and keyword!='' "> and voice_txt like concat('%', #{keyword}, '%') </if>
  199. </select>
  200. <select id="selectQwSopTempVoiceBySidberList" parameterType="QwSopTempVoice" resultMap="QwSopTempVoiceResult">
  201. <include refid="selectQwSopTempVoiceVo"/>
  202. <where>
  203. 1=1
  204. and temp_id is null
  205. <if test="data.companyId != null "> and company_id = #{data.companyId}</if>
  206. <if test="data.recordType != null"> and record_type= #{data.recordType}</if>
  207. </where>
  208. GROUP BY company_id, voice_txt
  209. </select>
  210. <delete id="deleteQwSopTempVoiceByIdSidebar" parameterType="QwSopTempVoice">
  211. delete from qw_sop_temp_voice
  212. where
  213. temp_id is null and company_id=#{data.companyId} and voice_txt=#{data.voiceTxt}
  214. </delete>
  215. <insert id="insertOrUpdateBatch" parameterType="java.util.List">
  216. insert into qw_sop_temp_voice (
  217. company_user_id,
  218. company_id,
  219. voice_txt,
  220. record_type
  221. ) values
  222. <foreach collection="list" item="item" separator=",">
  223. (
  224. #{item.companyUserId},
  225. #{item.companyId},
  226. #{item.voiceTxt},
  227. #{item.recordType}
  228. )
  229. </foreach>
  230. ON DUPLICATE KEY UPDATE
  231. update_time = NOW()
  232. </insert>
  233. </mapper>