BroadcastMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.welampiot.dao.BroadcastDao">
  4. <select id="getDevListByBroadcastDTO" resultType="BroadcastDTO">
  5. select b.id,b.name,b.dev_id devId,b.address,b.online,b.vol,bi.name as proName,b.isPlay,
  6. lp.name as lampPoleName,lp.id as lampPoleId,b.type,b.install_date installDate,b.expiration_date expirationDate
  7. from broadcast b
  8. left join broadcast_item bi on bi.id = b.itemId
  9. left join lamp_pole lp on b.lamp_pole_id = lp.id
  10. left join broadcast_pro_list as BP on b.proId = BP.id
  11. where b.lamp_pole_id != 0
  12. <if test="areaId != 0">
  13. and lp.areaid = #{areaId}
  14. </if>
  15. <if test="sectionId != 0">
  16. and lp.sectionid = #{sectionId}
  17. </if>
  18. <if test="sectionList != null and !sectionList.isEmpty()">
  19. and lp.sectionid in
  20. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  21. #{dto}
  22. </foreach>
  23. </if>
  24. <choose>
  25. <when test="onlineState == 0">
  26. and b.online = 0
  27. </when>
  28. <when test="onlineState == 1">
  29. and b.online = 1
  30. </when>
  31. </choose>
  32. order by convert(lp.number using gbk) asc,
  33. convert(b.name using gbk) asc,b.id desc
  34. </select>
  35. <select id="getTotalBySectionList" resultType="Integer">
  36. select count(b.id) as total from broadcast b
  37. left join lamp_pole lp on b.lamp_pole_id = lp.id
  38. <if test="sectionList != null and !sectionList.isEmpty()">
  39. where lp.sectionid in
  40. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  41. #{dto}
  42. </foreach>
  43. </if>
  44. </select>
  45. <select id="getOnlineTotalBySectionList" resultType="Integer">
  46. select count(b.id) as total from broadcast b
  47. left join lamp_pole lp on b.lamp_pole_id = lp.id
  48. where b.online = 1
  49. <if test="sectionList != null and !sectionList.isEmpty()">
  50. and lp.sectionid in
  51. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  52. #{dto}
  53. </foreach>
  54. </if>
  55. </select>
  56. <select id="getUserIdByUserName" resultType="Integer">
  57. select u.id from user u
  58. where u.username = #{username}
  59. </select>
  60. <!-- 音乐列表 -->
  61. <select id="getProListByDTO" resultType="BroadcastProListDTO">
  62. select b.id,b.name,b.url
  63. from broadcast_pro_list b
  64. where b.userId = #{userId}
  65. </select>
  66. <!-- 节目列表 -->
  67. <select id="getItemListByDTO" resultType="BroadcastItemDTO">
  68. select b.id,b.name,b.proType,b.broadcastId,b.status,b.createTime,b1.name as broadcastStr
  69. from broadcast_item b left join broadcast b1 on b.broadcastId = b1.id
  70. left join lamp_pole lp on lp.id = b1.lamp_pole_id
  71. left join section s on lp.sectionid = s.id
  72. where b.userId = #{userId}
  73. <if test="devId != null and devId != 0">
  74. and b.broadcastId = #{devId}
  75. </if>
  76. </select>
  77. <delete id="deleteBroadcastById">
  78. delete
  79. from broadcast
  80. where id = #{id};
  81. </delete>
  82. <select id="getBroadcastById" resultType="BroadcastDTO">
  83. select b.lamp_pole_id as lampPoleId,lp.sectionid as sectionId,b.address,b.type,b.dev_id as devId,b.name,
  84. from broadcast b
  85. left join lamp_pole lp on lp.id = b.lamp_pole_id
  86. left join section s on lp.sectionid = s.id
  87. where b.id = #{id}
  88. </select>
  89. <select id="getBroadcastCountByLampPoleId" resultType="Integer">
  90. select count(*)
  91. from broadcast b
  92. where b.lamp_pole_id = #{lampPoleId}
  93. </select>
  94. <select id="getBroadcastDTOByLampPoleId" resultType="BroadcastDTO">
  95. select b.lamp_pole_id,lp.sectionid as sectionId,b.id,b.itemId as proId,
  96. b2.name as proName,b3.time,b.online
  97. from broadcast b
  98. left join lamp_pole lp on lp.id = b.lamp_pole_id
  99. left join broadcast_pro_list b3 on b3.id = b.proId
  100. left join broadcast_item b2 on b2.id = b.itemId
  101. left join section s on lp.sectionid = s.id
  102. where b.lamp_pole_id = #{lampPoleId}
  103. </select>
  104. <select id="checkBroadcastData" resultType="Integer">
  105. select count(*)
  106. from broadcast b
  107. where 1=1
  108. <if test="address != null and address != ''">
  109. and b.address = #{address}
  110. </if>
  111. <if test="lampPoleId != null and lampPoleId != 0">
  112. and b.lamp_pole_id != #{lampPoleId}
  113. </if>
  114. <if test="name != null and name != ''">
  115. and b.name = #{name}
  116. </if>
  117. <if test="id != null and id != 0">
  118. and b.id != #{id}
  119. </if>
  120. </select>
  121. <update id="updateLampPoleBroadcastData" parameterType="BroadcastDTO">
  122. update
  123. broadcast e
  124. set
  125. <if test="installDate != null and installDate != ''">e.install_date = #{installDate},</if>
  126. <if test="expirationDate != null and installDate != ''">e.expiration_date = #{expirationDate},</if>
  127. <if test="address != null and address != ''">e.address = #{address},</if>
  128. e.type = #{type},
  129. e.name = #{name}
  130. where 1=1
  131. <if test="lampPoleId != null and lampPoleId != 0">
  132. and e.lamp_pole_id = #{lampPoleId}
  133. </if>
  134. <if test="id != null and id != 0">
  135. and e.id = #{id}
  136. </if>
  137. </update>
  138. <update id="updateBroadcastById" parameterType="BroadcastDTO">
  139. update
  140. broadcast e
  141. set
  142. <if test="vol != null and vol != ''">e.vol = #{vol},</if>
  143. <if test="policyId != null and policyId != ''">e.policy_id = #{policyId},</if>
  144. <if test="itemId != null and itemId != ''">e.itemId = #{itemId},</if>
  145. e.id = #{id}
  146. where e.id = #{id}
  147. </update>
  148. <select id="getListByIds" resultType="com.welampiot.dto.BroadcastDTO" parameterType="String">
  149. select address,online,dev_id as devId,type,vol
  150. from broadcast b
  151. where id in (#{ids})
  152. </select>
  153. <select id="getOneDataByLampPoleId" parameterType="integer" resultType="BroadcastDTO">
  154. select isPlay,proId,itemId,id
  155. from broadcast
  156. where lamp_pole_id = #{lampPoleId} order by id desc
  157. </select>
  158. <select id="getData" resultType="BroadcastDTO">
  159. select a.id,a.online,a.isPlay,a.type,b.name as itemName,c.name as proName
  160. from broadcast a left join broadcast_item b on a.itemId = b.id
  161. left join broadcast_pro_list c on a.proId = c.id
  162. where a.lamp_pole_id = #{lampPoleId}
  163. </select>
  164. <select id="getCount" resultType="integer" parameterType="BroadcastDTO">
  165. select count(*) as total from broadcast b
  166. left join broadcast_item bi on bi.id = b.itemId
  167. left join lamp_pole lp on b.lamp_pole_id = lp.id
  168. left join broadcast_pro_list as BP on b.proId = BP.id
  169. where b.lamp_pole_id != 0
  170. <if test="areaId != 0">
  171. and lp.areaid = #{areaId}
  172. </if>
  173. <if test="sectionId != 0">
  174. and lp.sectionid = #{sectionId}
  175. </if>
  176. <if test="sectionList != null and !sectionList.isEmpty()">
  177. and lp.sectionid in
  178. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  179. #{dto}
  180. </foreach>
  181. </if>
  182. <choose>
  183. <when test="onlineState == 0">
  184. and b.online = 0
  185. </when>
  186. <when test="onlineState == 1">
  187. and b.online = 1
  188. </when>
  189. </choose>
  190. order by convert(lp.number using gbk) asc,
  191. convert(b.name using gbk) asc,b.id desc
  192. </select>
  193. <select id="getList" parameterType="BroadcastDTO" resultType="BroadcastDTO">
  194. select id,name,dev_id as devId,name,vol,address,lamp_pole_id as lampPoleId from broadcast
  195. <trim prefix="where" prefixOverrides="and|or">
  196. <if test="idList != null and id">
  197. id in
  198. <foreach collection="idList" item="item" open="(" close=")" separator=",">
  199. #{item}
  200. </foreach>
  201. </if>
  202. </trim>
  203. </select>
  204. </mapper>