WarningLogMapper.xml 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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.bz.smart_city.dao.WarningLogMapper">
  4. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.WarningLog">
  5. <!--@mbg.generated-->
  6. <!--@Table sc_warning_log-->
  7. <id column="id" property="id" />
  8. <result column="client_user_id" property="clientUserId" />
  9. <result column="device_id" property="deviceId" />
  10. <result column="warning_type" property="warningType" />
  11. <result column="feedback_status" property="feedbackStatus" />
  12. <result column="feedback_content" property="feedbackContent" />
  13. <result column="status" property="status" />
  14. <result column="create_by" property="createBy" />
  15. <result column="date_create" property="dateCreate" />
  16. <result column="update_by" property="updateBy" />
  17. <result column="date_update" property="dateUpdate" />
  18. </resultMap>
  19. <sql id="Base_Column_List">
  20. <!--@mbg.generated-->
  21. id, client_user_id, device_id, warning_type, feedback_status, feedback_content, `status`,
  22. create_by, date_create, update_by, date_update
  23. </sql>
  24. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.WarningLog" useGeneratedKeys="true">
  25. <!--@mbg.generated-->
  26. insert into sc_warning_log
  27. <trim prefix="(" suffix=")" suffixOverrides=",">
  28. <if test="clientUserId != null">
  29. client_user_id,
  30. </if>
  31. <if test="deviceId != null">
  32. device_id,
  33. </if>
  34. <if test="warningType != null">
  35. warning_type,
  36. </if>
  37. <if test="feedbackStatus != null">
  38. feedback_status,
  39. </if>
  40. <if test="feedbackContent != null">
  41. feedback_content,
  42. </if>
  43. <if test="status != null">
  44. `status`,
  45. </if>
  46. <if test="createBy != null">
  47. create_by,
  48. </if>
  49. <if test="dateCreate != null">
  50. date_create,
  51. </if>
  52. <if test="updateBy != null">
  53. update_by,
  54. </if>
  55. <if test="dateUpdate != null">
  56. date_update,
  57. </if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="clientUserId != null">
  61. #{clientUserId},
  62. </if>
  63. <if test="deviceId != null">
  64. #{deviceId},
  65. </if>
  66. <if test="warningType != null">
  67. #{warningType},
  68. </if>
  69. <if test="feedbackStatus != null">
  70. #{feedbackStatus},
  71. </if>
  72. <if test="feedbackContent != null">
  73. #{feedbackContent},
  74. </if>
  75. <if test="status != null">
  76. #{status},
  77. </if>
  78. <if test="createBy != null">
  79. #{createBy},
  80. </if>
  81. <if test="dateCreate != null">
  82. #{dateCreate},
  83. </if>
  84. <if test="updateBy != null">
  85. #{updateBy},
  86. </if>
  87. <if test="dateUpdate != null">
  88. #{dateUpdate},
  89. </if>
  90. </trim>
  91. </insert>
  92. <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.WarningLog">
  93. <!--@mbg.generated-->
  94. update sc_warning_log
  95. <set>
  96. <if test="clientUserId != null">
  97. client_user_id = #{clientUserId},
  98. </if>
  99. <if test="deviceId != null">
  100. device_id = #{deviceId},
  101. </if>
  102. <if test="warningType != null">
  103. warning_type = #{warningType},
  104. </if>
  105. <if test="feedbackStatus != null">
  106. feedback_status = #{feedbackStatus},
  107. </if>
  108. <if test="feedbackContent != null">
  109. feedback_content = #{feedbackContent},
  110. </if>
  111. <if test="status != null">
  112. `status` = #{status},
  113. </if>
  114. <if test="createBy != null">
  115. create_by = #{createBy},
  116. </if>
  117. <if test="dateCreate != null">
  118. date_create = #{dateCreate},
  119. </if>
  120. <if test="updateBy != null">
  121. update_by = #{updateBy},
  122. </if>
  123. <if test="dateUpdate != null">
  124. date_update = #{dateUpdate},
  125. </if>
  126. </set>
  127. where id = #{id}
  128. </update>
  129. <select id="getList" resultType="com.bz.smart_city.dto.WarningLogDto">
  130. select
  131. swl.*,
  132. sd.device_no,
  133. sd.water_meter_no,
  134. sd.loc_desc,
  135. sdt1.equipment_type as equipment_type,
  136. sdt1.model as model,
  137. sdm1.name as manufacturer_name,
  138. sil.metercode meterCode,
  139. sgm.customer_no as account_number,
  140. sgm.customer_name as account_name,
  141. sgm.customer_phone as account_phone
  142. from sc_warning_log swl
  143. left join sc_device sd on(sd.id = swl.device_id)
  144. left join sc_install_list sil on sd.id=sil.device_id
  145. left join sc_building sb on(sb.id = sd.building_id)
  146. left join sc_device_type sdt1 on(sdt1.id = sd.device_type)
  147. left join sc_device_manufacturer sdm1 on(sdm1.id = sdt1.manufacturer_id)
  148. left join sc_grid_management sgm on(sgm.device_id = sil.device_id)
  149. <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
  150. where swl.status = 1 and sd.status = 1
  151. <if test="siteId != null"> and sd.site_id = #{siteId}</if>
  152. <if test="deviceId != null"> and sd.id = #{deviceId}</if>
  153. <if test="channelId != null"> and sd.sys_id = #{channelId}</if>
  154. <if test="deviceNo != null and deviceNo != ''"> and (
  155. sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%')
  156. )</if>
  157. <if test="warningType != null"> and swl.warning_type = #{warningType}</if>
  158. <if test="clientName != null and clientName != ''"> and (
  159. pba.name LIKE concat('%',#{clientName},'%') or pba.mobilephone LIKE concat('%',#{clientName},'%') or pba.accountnumber LIKE concat('%',#{clientName},'%')
  160. )</if>
  161. <if test="feedbackStatus != null"> and swl.feedback_status = #{feedbackStatus}</if>
  162. <if test="provinceId != null"> and sb.province = #{provinceId}</if>
  163. <if test="cityId != null"> and sb.city = #{cityId}</if>
  164. <if test="regionId != null"> and sb.region = #{regionId}</if>
  165. <if test="communityId != null"> and sb.community = #{communityId}</if>
  166. <if test="buildingId != null"> and sd.building_id = #{buildingId}</if>
  167. <if test="startDate != null"> and swl.date_create <![CDATA[ >= ]]> #{startDate}</if>
  168. <if test="endDate != null"> and swl.date_create <![CDATA[ <= ]]> #{endDate}</if>
  169. <if test="programItems != null and programItems.size() != 0"> and
  170. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  171. sdd.${item.dimensionCode} = #{item.dimensionValue}
  172. </foreach>
  173. </if>
  174. order by swl.date_create desc
  175. </select>
  176. <select id="getAreaList" resultType="com.bz.smart_city.dto.BuildingSelectInfoDto">
  177. select
  178. b.id,
  179. b.name,
  180. b.province,
  181. b.city,
  182. b.region,
  183. b.community,
  184. b.longitude,
  185. b.latitude,
  186. t1.device_count
  187. from sc_building b
  188. right join (
  189. select sd.building_id,count(1) as device_count
  190. from sc_warning_log swl
  191. left join sc_device sd on(sd.id = swl.device_id)
  192. left join pay_base_customerandmeterrela pbc on(pbc.watermeter_id = swl.device_id)
  193. left join pay_base_account pba on(pba.id = pbc.account_id)
  194. <if test="programItems != null and programItems.size() != 0">left join sc_device_dimension sdd on (sdd.device_id = sd.id and sdd.status = 1)</if>
  195. where swl.status = 1 and sd.status = 1
  196. <if test="siteId != null"> and sd.site_id = #{siteId}</if>
  197. <if test="channelId != null"> and sd.sys_id = #{channelId}</if>
  198. <if test="deviceNo != null and deviceNo != ''"> and (
  199. sd.device_no LIKE concat('%',#{deviceNo},'%') or sd.water_meter_no LIKE concat('%',#{deviceNo},'%')
  200. )</if>
  201. <if test="warningType != null"> and swl.warning_type = #{warningType}</if>
  202. <if test="clientName != null and clientName != ''"> and (
  203. pba.name LIKE concat('%',#{clientName},'%') or pba.mobilephone LIKE concat('%',#{clientName},'%') or pba.accountnumber LIKE concat('%',#{clientName},'%')
  204. )</if>
  205. <if test="feedbackStatus != null"> and swl.feedback_status = #{feedbackStatus}</if>
  206. <if test="startDate != null"> and swl.date_create <![CDATA[ >= ]]> #{startDate}</if>
  207. <if test="endDate != null"> and swl.date_create <![CDATA[ <= ]]> #{endDate}</if>
  208. <if test="programItems != null and programItems.size() != 0"> and
  209. <foreach collection="programItems" item="item" open="(" separator=" or " close=")">
  210. sdd.${item.dimensionCode} = #{item.dimensionValue}
  211. </foreach>
  212. </if>
  213. GROUP BY sd.building_id
  214. ) t1 on (t1.building_id = b.id)
  215. where b.status = 1
  216. </select>
  217. </mapper>