QwSopLogsMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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.QwSopLogsMapper">
  6. <resultMap type="QwSopLogs" id="QwSopLogsResult">
  7. <result property="id" column="id" />
  8. <result property="qwUserid" column="qw_userid" />
  9. <result property="externalUserId" column="external_user_id" />
  10. <result property="externalUserName" column="external_user_name" />
  11. <result property="logType" column="log_type" />
  12. <result property="contentJson" column="content_json" />
  13. <result property="sendStatus" column="send_status" />
  14. <result property="sendTime" column="send_time" jdbcType="VARCHAR" />
  15. <result property="realSendTime" column="real_send_time" jdbcType="VARCHAR" />
  16. <result property="companyId" column="company_id" />
  17. <result property="receivingStatus" column="receiving_status" />
  18. <result property="msgId" column="msg_id" />
  19. <result property="sendType" column="send_type" />
  20. <result property="sopId" column="sop_id" />
  21. <result property="remark" column="remark" />
  22. <result property="corpId" column="corp_id" />
  23. <result property="customerId" column="customer_id" />
  24. <result property="fsUserId" column="fs_user_id" />
  25. <result property="takeRecords" column="take_records" />
  26. <result property="sort" column="sort" />
  27. </resultMap>
  28. <sql id="selectQwSopLogsVo">
  29. select id,sop_id,customer_id, qw_userid,corp_id,external_user_id,external_user_name, log_type, content_json, send_status,receiving_status,msg_id, send_time, real_send_time, company_id, send_type,remark,fs_user_id,take_records from qw_sop_logs
  30. </sql>
  31. <select id="selectQwSopLogsListVO" parameterType="QwSopLogs" resultMap="QwSopLogsResult">
  32. <include refid="selectQwSopLogsVo"/>
  33. <where>
  34. <if test="qwUserid != null "> and qw_userid = #{qwUserid}</if>
  35. <if test="externalUserId != null and externalUserId != ''"> and external_user_id = #{externalUserId}</if>
  36. <if test="sendStatus != null "> and send_status = #{sendStatus}</if>
  37. <if test="corpId != null "> and corp_id = #{corpId}</if>
  38. </where>
  39. order by send_time desc
  40. </select>
  41. <select id="selectQwSopLogsList" parameterType="QwSopLogs" resultMap="QwSopLogsResult">
  42. <include refid="selectQwSopLogsVo"/>
  43. <where>
  44. <if test="qwUserid != null "> and qw_userid = #{qwUserid}</if>
  45. <if test="externalUserId != null and externalUserId != ''"> and external_user_id = #{externalUserId}</if>
  46. <if test="externalUserName != null and externalUserName != ''"> and external_user_name = #{externalUserName}</if>
  47. <if test="logType != null and logType != ''"> and log_type = #{logType}</if>
  48. <if test="contentJson != null and contentJson != ''"> and content_json = #{contentJson}</if>
  49. <if test="sendStatus != null "> and send_status = #{sendStatus}</if>
  50. <if test="sendTime != null "> and send_time = #{sendTime}</if>
  51. <if test="realSendTime != null "> and real_send_time = #{realSendTime}</if>
  52. <if test="companyId != null "> and company_id = #{companyId}</if>
  53. <if test="receivingStatus != null "> and receiving_status = #{receivingStatus}</if>
  54. <if test="msgId != null "> and msg_id = #{msgId}</if>
  55. <if test="corpId != null "> and corp_id = #{corpId}</if>
  56. <if test="sendType != null "> and send_type = #{sendType}</if>
  57. <if test="sopId != null "> and sop_id = #{sopId}</if>
  58. <if test="remark != null "> and remark = #{remark}</if>
  59. <if test="customerId != null "> and customer_id = #{customerId}</if>
  60. <if test="fsUserId != null "> and fs_user_id = #{fsUserId}</if>
  61. <if test="takeRecords != null "> and take_records = #{takeRecords}</if>
  62. </where>
  63. </select>
  64. <select id="selectQwSopLogsById" parameterType="String" resultMap="QwSopLogsResult">
  65. <include refid="selectQwSopLogsVo"/>
  66. where id = #{id} order by send_time
  67. </select>
  68. <insert id="insertQwSopLogs" parameterType="QwSopLogs" useGeneratedKeys="false">
  69. insert into qw_sop_logs
  70. <trim prefix="(" suffix=")" suffixOverrides=",">
  71. <if test="data.qwUserid != null">qw_userid,</if>
  72. <if test="data.externalUserId != null">external_user_id,</if>
  73. <if test="data.externalUserName != null">external_user_name,</if>
  74. <if test="data.logType != null">log_type,</if>
  75. <if test="data.contentJson != null">content_json,</if>
  76. <if test="data.sendStatus != null">send_status,</if>
  77. <if test="data.sendTime != null">send_time,</if>
  78. <if test="data.realSendTime != null">real_send_time,</if>
  79. <if test="data.sendType != null ">send_type,</if>
  80. <if test="data.companyId != null">company_id,</if>
  81. <if test="data.receivingStatus != null ">receiving_status,</if>
  82. <if test="data.msgId != null ">msg_id,</if>
  83. <if test="data.sopId != null ">sop_id,</if>
  84. <if test="data.remark != null ">remark,</if>
  85. <if test="data.corpId != null">corp_id,</if>
  86. <if test="data.customerId != null">customer_id,</if>
  87. <if test="data.fsUserId != null">fs_user_id,</if>
  88. <if test="data.takeRecords != null">take_records,</if>
  89. <if test="data.sort != null">sort,</if>
  90. </trim>
  91. <trim prefix="values (" suffix=")" suffixOverrides=",">
  92. <if test="data.qwUserid != null">#{data.qwUserid},</if>
  93. <if test="data.externalUserId != null">#{data.externalUserId},</if>
  94. <if test="data.externalUserName != null">#{data.externalUserName},</if>
  95. <if test="data.logType != null">#{data.logType},</if>
  96. <if test="data.contentJson != null">#{data.contentJson},</if>
  97. <if test="data.sendStatus != null">#{data.sendStatus},</if>
  98. <if test="data.sendTime != null">#{data.sendTime},</if>
  99. <if test="data.realSendTime != null">#{data.realSendTime},</if>
  100. <if test="data.sendType != null ">#{data.sendType},</if>
  101. <if test="data.companyId != null">#{data.companyId},</if>
  102. <if test="data.receivingStatus != null "> #{data.receivingStatus},</if>
  103. <if test="data.msgId != null ">#{data.msgId},</if>
  104. <if test="data.sopId != null ">#{data.sopId},</if>
  105. <if test="data.remark != null ">#{data.remark},</if>
  106. <if test="data.corpId != null">#{data.corpId},</if>
  107. <if test="data.customerId != null">#{data.customerId},</if>
  108. <if test="data.fsUserId != null">#{data.fsUserId},</if>
  109. <if test="data.takeRecords != null">#{data.takeRecords},</if>
  110. <if test="data.sort != null">#{data.sort},</if>
  111. </trim>
  112. </insert>
  113. <update id="updateQwSopLogs" parameterType="QwSopLogs" >
  114. update qw_sop_logs
  115. <trim prefix="SET" suffixOverrides=",">
  116. <if test="data.externalUserName != null">external_user_name = #{data.externalUserName},</if>
  117. <if test="data.logType != null">log_type = #{data.logType},</if>
  118. <if test="data.contentJson != null">content_json = #{data.contentJson},</if>
  119. <if test="data.sendStatus != null">send_status = #{data.sendStatus},</if>
  120. <if test="data.sendTime != null">send_time = #{data.sendTime},</if>
  121. <if test="data.realSendTime != null">real_send_time = #{data.realSendTime},</if>
  122. <if test="data.companyId != null">company_id = #{data.companyId},</if>
  123. <if test="data.receivingStatus != null ">receiving_status = #{data.receivingStatus},</if>
  124. <if test="data.msgId != null ">msg_id = #{data.msgId},</if>
  125. <if test="data.sendType != null ">send_type = #{data.sendType},</if>
  126. <if test="data.sopId != null ">sop_id = #{data.sopId},</if>
  127. <if test="data.customerId != null ">customer_id = #{data.customerId},</if>
  128. <if test="data.remark != null ">remark = #{data.remark},</if>
  129. <if test="data.fsUserId != null ">fs_user_id = #{data.fsUserId},</if>
  130. <if test="data.sort != null ">sort = #{data.sort},</if>
  131. </trim>
  132. where id = #{data.id}
  133. </update>
  134. <select id="selectQwSopLogsDoSendList" resultType="com.fs.sop.vo.QwSopLogsDoSendListTVO">
  135. <![CDATA[
  136. select ql.id as id,
  137. ql.qw_userid,
  138. ql.external_user_id,
  139. ql.external_user_name,
  140. qs.name,
  141. ql.content_json,
  142. ql.send_time,
  143. ql.fs_user_id,
  144. qs.expiry_time as expiryTime
  145. from qw_sop_logs ql
  146. INNER join qw_sop qs on qs.id = ql.sop_id
  147. where ql.qw_userid=#{qwUserId} and ql.corp_id=#{corpId}
  148. and ql.log_type = 2
  149. and ql.send_type = 2
  150. and ql.send_status = 3
  151. and ql.send_time <= now()
  152. order by ql.send_time desc
  153. limit 5
  154. ]]>
  155. </select>
  156. <select id="selectQwSopLogsListByQwSopId" parameterType="com.fs.sop.params.QwSopLogsParam" resultMap="QwSopLogsResult" >
  157. SELECT * FROM qw_sop_logs
  158. <where>
  159. <if test="map.sopId != null">sop_id = #{map.sopId}</if>
  160. <if test="map.corpId != null">AND corp_id = #{map.corpId}</if>
  161. <if test="map.sendType != null">AND send_type = #{map.sendType}</if>
  162. <if test="map.sendStatus != null">AND send_status = #{map.sendStatus}</if>
  163. <if test="map.receivingStatus != null">AND receiving_status = #{map.receivingStatus}</if>
  164. <if test="map.qwUserid != null and map.qwUserid !='' ">AND qw_userid = #{map.qwUserid}</if>
  165. <if test="map.externalUserName != null and map.externalUserName!= '' ">AND external_user_name = #{map.externalUserName}</if>
  166. <if test="map.scheduleStartTime != null">AND send_time &gt;= #{map.scheduleStartTime}</if>
  167. <if test="map.scheduleEndTime != null">AND send_time &lt;= #{map.scheduleEndTime}</if>
  168. </where>
  169. ORDER BY send_time desc
  170. </select>
  171. <update id="updateQwSopLogsByWatchLogType" >
  172. UPDATE qw_sop_logs
  173. SET
  174. send_status = 5,
  175. receiving_status = 4,
  176. remark = #{remark},
  177. real_send_time = NOW()
  178. WHERE
  179. id = #{id}
  180. </update>
  181. <update id="updateQwSopLogsBycollectIds" useGeneratedKeys="false" keyProperty="id" >
  182. UPDATE qw_sop_logs SET
  183. send_status = #{sendStatus},
  184. msg_id = #{msgId},
  185. real_send_time = NOW()
  186. WHERE id IN
  187. <foreach collection="collectIds" item="id" open="(" separator="," close=")">
  188. #{id}
  189. </foreach>
  190. </update>
  191. <delete id="deleteQwSopLogsById" parameterType="String">
  192. delete from qw_sop_logs where id = #{id}
  193. </delete>
  194. <delete id="deleteQwSopLogsByIds" parameterType="String">
  195. delete from qw_sop_logs
  196. where id in
  197. <foreach item="id" collection="array" open="(" separator="," close=")">
  198. #{id}
  199. </foreach>
  200. </delete>
  201. <update id="deleteQwSopLogsBySopID" parameterType="String">
  202. update qw_sop_logs
  203. SET send_status = 5, receiving_status = 2 , remark='已删除' where sop_id in
  204. <foreach item="id" collection="array" open="(" separator="," close=")">
  205. #{id}
  206. </foreach>
  207. </update>
  208. <update id="updateQwSopLogsBySendStatus">
  209. <![CDATA[
  210. update qw_sop_logs
  211. set
  212. send_status = 5,
  213. receiving_status = 4,
  214. remark = '已过期,不发送',
  215. real_send_time = NOW()
  216. WHERE
  217. send_status = '3'
  218. AND send_time <= NOW() - INTERVAL (
  219. SELECT expiry_time
  220. FROM qw_sop
  221. WHERE id IN (SELECT sop_id FROM qw_sop_logs WHERE send_status = '3')
  222. LIMIT 1
  223. ) HOUR
  224. ]]>
  225. </update>
  226. <select id="checkQwSopLogs" resultType="QwSopLogs" >
  227. <![CDATA[
  228. select * from qw_sop_logs where log_type=2 and send_status=3 and send_type=1 and send_time <= NOW()
  229. ]]>
  230. </select>
  231. <select id="selectSopLogsByCreateCorpMassSending" parameterType="String" resultType="QwSopLogs" >
  232. <![CDATA[
  233. select * from qw_sop_logs where log_type=2 and send_status=3 and send_type=1 and send_time >= #{date}
  234. ]]>
  235. </select>
  236. <select id="selectSopLogsByCreateCorpMassSendResult" resultType="QwSopLogs" >
  237. <![CDATA[
  238. SELECT
  239. *
  240. FROM
  241. qw_sop_logs
  242. WHERE
  243. log_type = 2
  244. AND send_type = 1
  245. AND send_status = 1
  246. AND receiving_status = 0
  247. AND msg_id IS NOT NULL
  248. AND DATE(send_time) = CURDATE();
  249. ]]>
  250. </select>
  251. <select id="qwSopLogsResult" resultType="QwSopLogs">
  252. <![CDATA[
  253. select * from qw_sop_logs
  254. where log_type=2
  255. and send_type=1
  256. and send_status=1
  257. and receiving_status=0
  258. AND send_time BETWEEN DATE_SUB(NOW(), INTERVAL 3 DAY) AND NOW()
  259. ]]>
  260. </select>
  261. <select id="getQwSopLogsByJsApiAll" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" resultType="com.fs.sop.vo.QwSopLogsDoSendListTVO">
  262. <![CDATA[
  263. select ql.id as id,
  264. ql.qw_userid,
  265. ql.external_user_id,
  266. ql.external_user_name,
  267. qs.name,
  268. ql.content_json,
  269. ql.send_time,
  270. ql.fs_user_id,
  271. ql.send_type,
  272. qs.expiry_time as expiryTime
  273. from qw_sop_logs ql
  274. left join qw_sop qs on qs.id = ql.sop_id
  275. where ql.qw_userid=#{data.qwUserId}
  276. and ql.corp_id=#{data.corpId}
  277. and ql.external_user_id =#{data.externalUserId}
  278. and ql.log_type = 2
  279. and ql.send_type != 1
  280. and ql.send_status = 3
  281. and ql.receiving_status = 0
  282. and ql.send_time <= now()
  283. order by ql.sort DESC ,ql.send_time asc
  284. LIMIT 3
  285. ]]>
  286. </select>
  287. <select id="getQwSopLogsByJsApi" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" resultType="com.fs.sop.vo.QwSopLogsDoSendListTVO">
  288. <![CDATA[
  289. select ql.id as id,
  290. ql.qw_userid,
  291. ql.external_user_id,
  292. ql.external_user_name,
  293. qs.name,
  294. ql.content_json,
  295. ql.send_time,
  296. ql.fs_user_id,
  297. qs.expiry_time as expiryTime
  298. from qw_sop_logs ql
  299. left join qw_sop qs on qs.id = ql.sop_id
  300. where ql.qw_userid=#{data.qwUserId}
  301. and ql.corp_id=#{data.corpId}
  302. and ql.external_user_id =#{data.externalUserId}
  303. and ql.log_type = 2
  304. and ql.send_type in (2,5)
  305. and ql.send_status = 3
  306. and ql.receiving_status = 0
  307. and ql.send_time <= now()
  308. order by ql.sort DESC ,ql.send_time asc
  309. ]]>
  310. </select>
  311. <select id="getQwSopLogsByJsApiOver" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" resultType="com.fs.sop.vo.QwSopLogsDoSendListTVO">
  312. <![CDATA[
  313. select ql.id as id,
  314. ql.qw_userid,
  315. ql.external_user_id,
  316. ql.external_user_name,
  317. ql.content_json,
  318. ql.send_time,
  319. ql.fs_user_id
  320. from qw_sop_logs ql
  321. where ql.qw_userid=#{data.qwUserId}
  322. and ql.corp_id=#{data.corpId}
  323. and ql.external_user_id =#{data.externalUserId}
  324. and ql.log_type = 2
  325. and ql.send_type = 3
  326. and ql.send_status = 3
  327. and ql.receiving_status = 0
  328. and ql.send_time <= now()
  329. order by ql.sort DESC ,ql.send_time asc
  330. ]]>
  331. </select>
  332. <select id="getExpiredMessagesByQwSopLogs" resultType="com.fs.sop.vo.QwSopLogsDoSendListTVO">
  333. <![CDATA[
  334. SELECT
  335. ql.id
  336. FROM
  337. qw_sop_logs ql
  338. LEFT JOIN qw_sop qs ON qs.id = ql.sop_id
  339. WHERE
  340. ql.log_type = 2
  341. AND ql.send_type IN (2, 5)
  342. AND ql.send_status = 3
  343. AND ql.receiving_status = 0
  344. AND ql.send_time <= now()
  345. AND (qs.expiry_time IS NOT NULL AND ql.send_time <= now() - interval qs.expiry_time hour)
  346. ORDER BY
  347. ql.sort DESC,
  348. ql.send_time asc;
  349. ]]>
  350. </select>
  351. <select id="getQwSopLogsByJsApiNext" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" resultType="QwSopLogs">
  352. <![CDATA[
  353. SELECT external_user_id,send_type
  354. FROM qw_sop_logs
  355. WHERE qw_userid = #{data.qwUserId}
  356. AND corp_id = #{data.corpId}
  357. AND external_user_id != #{data.externalUserId}
  358. AND log_type = 2
  359. AND send_status = 3
  360. AND send_type !=1
  361. AND receiving_status = 0
  362. AND send_time <= now()
  363. ORDER BY sort DESC,send_time ASC, rand()
  364. LIMIT 1
  365. ]]>
  366. </select>
  367. <delete id="deleteQwSopLogsByJsApi" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" >
  368. delete FROM qw_sop_logs
  369. where qw_userid = #{data.qwUserId}
  370. AND corp_id = #{data.corpId}
  371. AND external_user_id = #{data.externalUserId}
  372. </delete>
  373. <delete id="deleteQwSopLogsByRemoveSop" parameterType="String" >
  374. delete FROM qw_sop_logs
  375. where qw_userid = #{qwUserId}
  376. AND corp_id = #{corpId}
  377. AND sop_id = #{sopId}
  378. </delete>
  379. <delete id="deleteQwSopLogsByExternalUserIdList" parameterType="com.fs.sop.params.DeleteQwSopParam" >
  380. delete FROM qw_sop_logs
  381. where qw_userid = #{data.qwUserId}
  382. AND corp_id = #{data.corpId}
  383. AND external_user_id IN
  384. <foreach collection="data.externalUserIds" item="extId" open="(" separator="," close=")">
  385. #{extId}
  386. </foreach>
  387. </delete>
  388. <insert id="batchInsertQwSopLogsOneTouch" parameterType="java.util.List" useGeneratedKeys="false">
  389. INSERT INTO qw_sop_logs
  390. (
  391. qw_userid, external_user_id, external_user_name, log_type,
  392. content_json, send_status, send_time, real_send_time, send_type,
  393. company_id, receiving_status, msg_id, sop_id, remark,
  394. corp_id, customer_id, fs_user_id,sort
  395. )
  396. VALUES
  397. <foreach collection="qwSopLogs" item="log" separator=",">
  398. (
  399. #{log.qwUserid},
  400. #{log.externalUserId},
  401. #{log.externalUserName},
  402. #{log.logType},
  403. #{log.contentJson},
  404. #{log.sendStatus},
  405. #{log.sendTime},
  406. #{log.realSendTime},
  407. #{log.sendType},
  408. #{log.companyId},
  409. #{log.receivingStatus},
  410. #{log.msgId},
  411. #{log.sopId},
  412. #{log.remark},
  413. #{log.corpId},
  414. #{log.customerId},
  415. #{log.fsUserId},
  416. #{log.sort}
  417. )
  418. </foreach>
  419. </insert>
  420. <!-- 批量插入 QwSopLogs -->
  421. <insert id="batchInsertQwSopLogs" parameterType="java.util.List" useGeneratedKeys="false">
  422. INSERT INTO qw_sop_logs
  423. (
  424. qw_userid, external_user_id, external_user_name, log_type,
  425. content_json, send_status, send_time, real_send_time, send_type,
  426. company_id, receiving_status, msg_id, sop_id, remark,
  427. corp_id, customer_id, fs_user_id
  428. )
  429. VALUES
  430. <foreach collection="qwSopLogs" item="log" separator=",">
  431. (
  432. #{log.qwUserid},
  433. #{log.externalUserId},
  434. #{log.externalUserName},
  435. #{log.logType},
  436. #{log.contentJson},
  437. #{log.sendStatus},
  438. #{log.sendTime},
  439. #{log.realSendTime},
  440. #{log.sendType},
  441. #{log.companyId},
  442. #{log.receivingStatus},
  443. #{log.msgId},
  444. #{log.sopId},
  445. #{log.remark},
  446. #{log.corpId},
  447. #{log.customerId},
  448. #{log.fsUserId}
  449. )
  450. </foreach>
  451. </insert>
  452. <!-- 批量更新 QwSopLogs -->
  453. <update id="batchUpdateQwSopLogsByTakeRecordsList" parameterType="java.util.List" useGeneratedKeys="false">
  454. UPDATE qw_sop_logs
  455. SET take_records = 1
  456. WHERE id IN
  457. <foreach collection="data" item="log" open="(" separator="," close=")">
  458. #{log.id}
  459. </foreach>
  460. </update>
  461. <update id="updateQwSopLogsByDeleted" parameterType="com.fs.sop.params.GetQwSopLogsByJsApiParam" useGeneratedKeys="false">
  462. <![CDATA[
  463. UPDATE qw_sop_logs
  464. SET
  465. send_status = 5,
  466. receiving_status = 4,
  467. remark = '非外部联系人',
  468. real_send_time = NOW()
  469. WHERE qw_userid = #{data.qwUserId}
  470. AND corp_id = #{data.corpId}
  471. AND external_user_id = #{data.externalUserId}
  472. AND send_time <= now()
  473. ]]>
  474. </update>
  475. <!-- 批量更新 QwSopLogs -->
  476. <update id="batchUpdateQwSopLogsBySendTime" parameterType="java.util.List" useGeneratedKeys="false">
  477. UPDATE qw_sop_logs
  478. SET
  479. send_status = 5,
  480. receiving_status = 4,
  481. remark = '已过期,不发送',
  482. real_send_time = NOW()
  483. WHERE id IN
  484. <foreach collection="data" item="log" open="(" separator="," close=")">
  485. #{log.id}
  486. </foreach>
  487. </update>
  488. <select id="selectQwSopLogsByCancel" resultMap="QwSopLogsResult">
  489. <include refid="selectQwSopLogsVo"/>
  490. <![CDATA[
  491. WHERE send_type = 3
  492. AND send_status = 5
  493. AND receiving_status = 4
  494. AND remark = '已过期,不发送'
  495. AND real_send_time >= now() - INTERVAL 1 HOUR
  496. AND real_send_time < now()
  497. ]]>
  498. </select>
  499. <select id="selectQwSopLogsListByChatSopId" resultType="com.fs.sop.vo.QwSopLogsListCVO">
  500. SELECT * FROM qw_sop_logs
  501. <where>
  502. <if test="map.sopId != null">sop_id = #{map.sopId}</if>
  503. <if test="map.corpId != null">AND corp_id = #{map.corpId}</if>
  504. <if test="map.sendType != null">AND send_type = #{map.sendType}</if>
  505. <if test="map.sendStatus != null">AND send_status = #{map.sendStatus}</if>
  506. <if test="map.receivingStatus != null">AND receiving_status = #{map.receivingStatus}</if>
  507. <if test="map.qwUserid != null and map.qwUserid !='' ">AND qw_userid = #{map.qwUserid}</if>
  508. <if test="map.externalUserName != null and map.externalUserName!= '' ">AND external_user_name = #{map.externalUserName}</if>
  509. <if test="map.scheduleStartTime != null">AND send_time &gt;= #{map.scheduleStartTime}</if>
  510. <if test="map.scheduleEndTime != null">AND send_time &lt;= #{map.scheduleEndTime}</if>
  511. </where>
  512. ORDER BY send_time desc
  513. </select>
  514. <select id="selectQwSopLogsCountByQwUserId" resultType="java.lang.Long">
  515. select count(1) from qw_sop_logs
  516. <where>
  517. AND type = '0'
  518. AND send_status = '1'
  519. AND DATE(real_send_time) = #{previousDay}
  520. AND user_logs_id = #{periodId}
  521. <if test="data != null and data.size() > 0">
  522. AND qw_userid in
  523. <foreach collection="data" item="item" open="(" close=")" separator=",">
  524. #{item}
  525. </foreach>
  526. </if>
  527. </where>
  528. </select>
  529. <!-- 批量更新 QwSopLogs -->
  530. <update id="batchUpdateQwSopLogsByCancel" parameterType="java.util.List" useGeneratedKeys="false">
  531. UPDATE qw_sop_logs
  532. SET
  533. send_status = 3,
  534. receiving_status = 0,
  535. remark = null,
  536. real_send_time = null,
  537. send_time = DATE_ADD(now(), INTERVAL 30 MINUTE)
  538. WHERE id IN
  539. <foreach collection="data" item="log" open="(" separator="," close=")">
  540. #{log.id}
  541. </foreach>
  542. </update>
  543. <update id="batchUpdateQwSopLogsById" parameterType="java.util.List" useGeneratedKeys="false">
  544. UPDATE qw_sop_logs
  545. SET
  546. send_status = 5,
  547. remark = 'ai回复超时过期'
  548. WHERE id IN
  549. <foreach collection="data" item="log" open="(" separator="," close=")">
  550. #{log.id}
  551. </foreach>
  552. </update>
  553. <delete id="deleteQwSopLogsByDate" >
  554. <![CDATA[
  555. DELETE FROM qw_sop_logs WHERE DATE(send_time) < CURDATE() - INTERVAL 2 DAY;
  556. ]]>
  557. </delete>
  558. </mapper>