SmsMessageDao.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.example.nngkxxdp.dao.SmsMessageDao">
  4. <select id="countSmsMessageByUserid" resultType="int">
  5. select count(*)
  6. from sms_message
  7. where sendstatus = 0
  8. and deptname = #{deptname}
  9. </select>
  10. <select id="getTelephoneByDeptname" resultType="map">
  11. select u.id,
  12. u.nickname,
  13. d.main_leader,
  14. d.main_leader_phone,
  15. u.telephone,
  16. d.leaderperson,
  17. d.leaderphone,
  18. d.workperson,
  19. d.workphone,
  20. d.deptid,
  21. d.deptname
  22. from t_dept d,
  23. t_user u
  24. where d.deptname = #{deptname}
  25. and d.deptid = u.deptid limit 1
  26. </select>
  27. <insert id="addSmsMessage" useGeneratedKeys="true" keyProperty="id" parameterType="list">
  28. INSERT INTO sms_message (deptname, type, telephone, createtime, senduerid, sendstatus, columns, w_sms_id)
  29. VALUES
  30. <foreach collection="smsMessages" item="smsMessage" separator=",">
  31. (#{smsMessage.deptname},
  32. #{smsMessage.type},
  33. #{smsMessage.telephone},
  34. now(),
  35. #{smsMessage.senduerid},
  36. 0,
  37. #{smsMessage.columns},
  38. #{smsMessage.wSmsId}
  39. )
  40. </foreach>
  41. </insert>
  42. <update id="saveSendSuccess">
  43. update sms_message
  44. set
  45. sendstatus = 1,
  46. sendtime = now()
  47. where id in
  48. <foreach collection="ids" separator="," open="(" close=")" item="item">
  49. #{item}
  50. </foreach>
  51. </update>
  52. <select id="getAllNotSendSmsMessage" resultType="map">
  53. select id, telephone, columns
  54. from sms_message
  55. where sendstatus = 0
  56. limit ${limit}
  57. </select>
  58. <select id="getAllOfa" resultType="java.util.Map">
  59. select *
  60. from w_ofa
  61. order by update_time desc
  62. </select>
  63. <select id="getRegionAllOfa" resultType="java.util.Map">
  64. select *
  65. from w_ofa_other where w_area_type=#{type}
  66. order by update_time desc
  67. </select>
  68. <insert id="saveOfaSms" useGeneratedKeys="true">
  69. INSERT INTO w_ofa_sms(ofa_id, phone, type, send_time, is_success) VALUES
  70. <foreach collection="list" separator="," item="item">
  71. (#{item.ofaId}, #{item.phone}, #{item.type}, #{item.sendTime}, #{item.isSuccess})
  72. </foreach>
  73. </insert>
  74. <select id="getCountWechatSms" resultType="java.lang.Integer">
  75. SELECT COUNT(*)
  76. FROM w_ofa
  77. </select>
  78. <select id="getWechatSms" resultType="java.util.Map">
  79. SELECT b.*
  80. FROM (
  81. SELECT wo.*, DATE_FORMAT(wos.send_time, '%Y-%m-%d %H:%i') send_time
  82. FROM w_ofa wo
  83. LEFT JOIN w_ofa_sms wos ON wo.id = wos.ofa_id
  84. ORDER BY wos.send_time DESC LIMIT 999999999
  85. ) b
  86. GROUP BY b.id
  87. ORDER BY b.send_time DESC
  88. </select>
  89. <select id="getCountWechatSmsDetail" resultType="java.lang.Integer">
  90. SELECT COUNT(*)
  91. FROM w_ofa_sms
  92. WHERE ofa_id = #{id}
  93. </select>
  94. <select id="getWechatSmsDetail" resultType="java.util.Map">
  95. SELECT id, ofa_id, phone, type, is_success, DATE_FORMAT(send_time, '%Y-%m-%d %H:%i') send_time
  96. FROM w_ofa_sms
  97. WHERE ofa_id = #{id}
  98. ORDER BY send_time DESC
  99. LIMIT #{page}, #{limit}
  100. </select>
  101. <select id="getAllOfaList" resultType="java.util.Map">
  102. SELECT
  103. a.id,
  104. a.official_account,
  105. a.title,
  106. a.url,
  107. a.sort,
  108. DATE_FORMAT(a.create_time, '%Y-%m-%d') as create_time,
  109. a.cover
  110. FROM
  111. sort_article a
  112. WHERE
  113. official_account = #{official}
  114. ORDER BY
  115. create_time DESC limit #{num};
  116. </select>
  117. <select id="getRegionAllOfaList" resultType="java.util.Map">
  118. SELECT
  119. a.id,
  120. a.official_account,
  121. a.title,
  122. a.url,
  123. a.sort,
  124. DATE_FORMAT(a.create_time, '%Y-%m-%d') as create_time,
  125. a.cover
  126. FROM
  127. sort_article_other a
  128. WHERE
  129. official_account = #{official}
  130. ORDER BY
  131. create_time DESC limit #{num};
  132. </select>
  133. <select id="getCountOffocoalAccount" resultType="java.lang.Integer" parameterType="java.util.Map">
  134. SELECT COUNT(*)
  135. FROM sort_article
  136. WHERE official_account = #{name}
  137. <if test="title != null and title != ''">
  138. AND title LIKE CONCAT('%', #{title}, '%')
  139. </if>
  140. </select>
  141. <select id="getCountRegionOffocoalAccount" resultType="java.lang.Integer" parameterType="java.util.Map">
  142. SELECT COUNT(*)
  143. FROM sort_article_other
  144. WHERE official_account = #{name}
  145. </select>
  146. <select id="getOfficialAccountByPaging" resultType="java.util.Map" parameterType="java.util.Map">
  147. SELECT *, DATE_FORMAT(create_time, '%Y-%m-%d') AS nowTime
  148. FROM sort_article
  149. WHERE official_account = #{name}
  150. <if test="title != null and title != ''">
  151. AND title LIKE CONCAT('%', #{title}, '%')
  152. </if>
  153. ORDER BY create_time DESC
  154. LIMIT #{page}, #{limit}
  155. </select>
  156. <select id="getRegionOfficialAccountByPaging" resultType="java.util.Map" parameterType="java.util.Map">
  157. SELECT *, DATE_FORMAT(create_time, '%Y-%m-%d') AS nowTime
  158. FROM sort_article_other
  159. WHERE official_account = #{name}
  160. ORDER BY create_time DESC
  161. LIMIT #{page}, #{limit}
  162. </select>
  163. <select id="getAllJRTT" resultType="java.util.Map">
  164. SELECT a.*
  165. FROM (
  166. SELECT *
  167. FROM sort_article_headlines
  168. WHERE is_deleted = 0
  169. ORDER BY create_time DESC LIMIT 9999999
  170. ) a
  171. GROUP BY a.official_account
  172. ORDER BY a.create_time DESC
  173. </select>
  174. <!-- 文章未更新通知主要领导、分管领导、工作人员 -->
  175. <select id="getArticleFrequencyList" resultType="java.util.Map" parameterType="java.util.Map">
  176. select a.*,d.chnlidname,d.DOCRELTIME,c.frequency
  177. from (
  178. SELECT
  179. t.deptid,
  180. t.deptname,
  181. t.main_leader,
  182. t.main_leader_phone,
  183. t.leaderperson,
  184. t.leaderphone,
  185. t.workperson,
  186. t.workphone,
  187. p.chnlid
  188. FROM
  189. t_dept t
  190. LEFT JOIN t_dept_chnlid p ON t.deptid = p.deptid
  191. WHERE
  192. p.chnlid IS NOT NULL AND t.is_deleted=0 AND p.is_deleted=0
  193. ) a
  194. inner JOIN column_relation c ON a.CHNLID = c.CHNLID AND c.frequency > 0
  195. inner JOIN (
  196. SELECT
  197. CHNLID, chnlidname, MAX(DOCRELTIME) AS DOCRELTIME
  198. FROM save_hlw_interface_data
  199. GROUP BY CHNLID,chnlidname
  200. ) d ON d.CHNLID = a.chnlid
  201. where
  202. TIMESTAMPDIFF(
  203. DAY,
  204. DATE_FORMAT(d.DOCRELTIME, '%Y-%m-%d'),
  205. DATE_FORMAT(now(), '%Y-%m-%d')
  206. ) = c.frequency - #{day}
  207. ORDER BY d.DOCRELTIME DESC
  208. </select>
  209. <select id="getArticleFrequencyListNew" resultType="java.util.Map" parameterType="java.util.Map">
  210. select a.*,d.chnlidname,d.DOCRELTIME,c.frequency
  211. from (
  212. SELECT
  213. t.deptid,
  214. t.deptname,
  215. t.main_leader,
  216. t.main_leader_phone,
  217. t.leaderperson,
  218. t.leaderphone,
  219. t.workperson,
  220. t.workphone,
  221. p.chnlid
  222. FROM
  223. t_dept t
  224. LEFT JOIN t_dept_chnlid p ON t.deptid = p.deptid
  225. WHERE
  226. p.chnlid IS NOT NULL AND t.is_deleted=0 AND p.is_deleted=0
  227. ) a
  228. inner JOIN column_relation c ON a.CHNLID = c.CHNLID AND c.frequency > 0
  229. inner JOIN (
  230. SELECT
  231. column_id CHNLID, column_name chnlidname, MAX(article_date) AS DOCRELTIME
  232. FROM c_article
  233. GROUP BY column_id,column_name
  234. ) d ON d.CHNLID = a.chnlid
  235. where
  236. TIMESTAMPDIFF(
  237. DAY,
  238. DATE_FORMAT(d.DOCRELTIME, '%Y-%m-%d'),
  239. DATE_FORMAT(now(), '%Y-%m-%d')
  240. ) = c.frequency - #{day}
  241. ORDER BY d.DOCRELTIME DESC
  242. </select>
  243. <select id="getSortAticleAccount" resultType="java.lang.Integer">
  244. SELECT COUNT(*)
  245. FROM sort_article
  246. WHERE 1=1
  247. <if test="title != null and title != ''">
  248. AND title LIKE CONCAT('%', #{title}, '%')
  249. </if>
  250. </select>
  251. <select id="getSortAticleByTitlePage" resultType="java.util.Map">
  252. SELECT
  253. official_account,
  254. title,
  255. url,
  256. sort,
  257. create_time,
  258. cover
  259. FROM
  260. sort_article
  261. WHERE 1=1
  262. <if test="title != null and title != ''">
  263. AND title LIKE CONCAT('%', #{title}, '%')
  264. </if>
  265. ORDER BY create_time DESC
  266. LIMIT #{page}, #{limit}
  267. </select>
  268. <select id="getCountInstitution" resultType="java.lang.Integer">
  269. SELECT COUNT(*)
  270. FROM sort_article_institution
  271. WHERE official_account = #{name}
  272. </select>
  273. <select id="getInstitutionByPaging" resultType="java.util.Map">
  274. SELECT *, DATE_FORMAT(create_time, '%Y-%m-%d') AS nowTime
  275. FROM sort_article_institution
  276. WHERE official_account = #{name}
  277. ORDER BY create_time DESC
  278. LIMIT #{page}, #{limit}
  279. </select>
  280. <update id="updateWechatSms">
  281. UPDATE `w_ofa`
  282. SET
  283. <if test="leadName!=null and leadName !=''" >
  284. `lead_name` = #{leadName},
  285. </if>
  286. <if test="leadPhone!=null and leadPhone !=''" >
  287. `lead_phone` = #{leadPhone},
  288. </if>
  289. <if test="staffName!=null and staffName !=''" >
  290. `staff_name` = #{staffName},
  291. </if>
  292. <if test="staffPhone!=null and staffPhone !=''" >
  293. `staff_phone` = #{staffPhone},
  294. </if>
  295. update_time = now()
  296. WHERE `id` = #{id};
  297. </update>
  298. </mapper>