AcceptPlanMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.assistant.AcceptPlanMapper">
  4. <resultMap id="BaseResultMap" type="com.bz.smart_city.entity.assistant.AcceptPlan">
  5. <!--@mbg.generated-->
  6. <id column="id" property="id" />
  7. <result column="site_id" property="siteId" />
  8. <result column="batch_no" property="batchNo" />
  9. <result column="accept_time" property="acceptTime" />
  10. <result column="accept_sponsor" property="acceptSponsor" />
  11. <result column="accept_confirm_user" property="acceptConfirmUser" />
  12. <result column="remark" property="remark" />
  13. <result column="is_finished" property="isFinished" />
  14. <result column="date_create" property="dateCreate" />
  15. <result column="date_update" property="dateUpdate" />
  16. <result column="create_by" property="createBy" />
  17. <result column="update_by" property="updateBy" />
  18. <result column="status" property="status" />
  19. <result column="customer_id" property="customerId" />
  20. </resultMap>
  21. <sql id="Base_Column_List">
  22. <!--@mbg.generated-->
  23. id, site_id,batch_no, accept_time, accept_sponsor, accept_confirm_user, remark, is_finished,
  24. date_create, date_update, create_by, update_by,status,customer_id
  25. </sql>
  26. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  27. <!--@mbg.generated-->
  28. select
  29. <include refid="Base_Column_List" />
  30. from sc_accept_plan
  31. where id = #{id}
  32. and status = 1
  33. </select>
  34. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.assistant.AcceptPlan" useGeneratedKeys="true">
  35. <!--@mbg.generated-->
  36. insert into sc_accept_plan (site_id,batch_no, accept_time, accept_sponsor, accept_confirm_user, remark,
  37. is_finished, date_create, date_update, create_by, update_by,status,customer_id)
  38. values (#{siteId},#{batchNo}, #{acceptTime}, #{acceptSponsor}, #{acceptConfirmUser}, #{remark},
  39. #{isFinished}, #{dateCreate}, #{dateUpdate}, #{createBy}, #{updateBy},#{status},#{customerId})
  40. </insert>
  41. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.bz.smart_city.entity.assistant.AcceptPlan" useGeneratedKeys="true">
  42. <!--@mbg.generated-->
  43. insert into sc_accept_plan
  44. <trim prefix="(" suffix=")" suffixOverrides=",">
  45. <if test="siteId != null">
  46. site_id,
  47. </if>
  48. <if test="batchNo != null">
  49. batch_no,
  50. </if>
  51. <if test="acceptTime != null">
  52. accept_time,
  53. </if>
  54. <if test="acceptSponsor != null">
  55. accept_sponsor,
  56. </if>
  57. <if test="acceptConfirmUser != null">
  58. accept_confirm_user,
  59. </if>
  60. <if test="remark != null">
  61. remark,
  62. </if>
  63. <if test="isFinished != null">
  64. is_finished,
  65. </if>
  66. <if test="dateCreate != null">
  67. date_create,
  68. </if>
  69. <if test="dateUpdate != null">
  70. date_update,
  71. </if>
  72. <if test="createBy != null">
  73. create_by,
  74. </if>
  75. <if test="updateBy != null">
  76. update_by,
  77. </if>
  78. </trim>
  79. <trim prefix="values (" suffix=")" suffixOverrides=",">
  80. <if test="siteId != null">
  81. #{siteId},
  82. </if>
  83. <if test="batchNo != null">
  84. #{batchNo},
  85. </if>
  86. <if test="acceptTime != null">
  87. #{acceptTime},
  88. </if>
  89. <if test="acceptSponsor != null">
  90. #{acceptSponsor},
  91. </if>
  92. <if test="acceptConfirmUser != null">
  93. #{acceptConfirmUser},
  94. </if>
  95. <if test="remark != null">
  96. #{remark},
  97. </if>
  98. <if test="isFinished != null">
  99. #{isFinished},
  100. </if>
  101. <if test="dateCreate != null">
  102. #{dateCreate},
  103. </if>
  104. <if test="dateUpdate != null">
  105. #{dateUpdate},
  106. </if>
  107. <if test="createBy != null">
  108. #{createBy},
  109. </if>
  110. <if test="updateBy != null">
  111. #{updateBy},
  112. </if>
  113. </trim>
  114. </insert>
  115. <update id="updateByPrimaryKeySelective" parameterType="com.bz.smart_city.entity.assistant.AcceptPlan">
  116. <!--@mbg.generated-->
  117. update sc_accept_plan
  118. <set>
  119. <if test="batchNo != null">
  120. batch_no = #{batchNo},
  121. </if>
  122. <if test="acceptTime != null">
  123. accept_time = #{acceptTime},
  124. </if>
  125. <if test="acceptSponsor != null">
  126. accept_sponsor = #{acceptSponsor},
  127. </if>
  128. <if test="acceptConfirmUser != null">
  129. accept_confirm_user = #{acceptConfirmUser},
  130. </if>
  131. <if test="remark != null">
  132. remark = #{remark},
  133. </if>
  134. <if test="isFinished != null">
  135. is_finished = #{isFinished},
  136. </if>
  137. <if test="dateCreate != null">
  138. date_create = #{dateCreate},
  139. </if>
  140. <if test="dateUpdate != null">
  141. date_update = #{dateUpdate},
  142. </if>
  143. <if test="createBy != null">
  144. create_by = #{createBy},
  145. </if>
  146. <if test="updateBy != null">
  147. update_by = #{updateBy},
  148. </if>
  149. <if test="status != null">
  150. status = #{status},
  151. </if>
  152. </set>
  153. where id = #{id}
  154. </update>
  155. <select id="queryAcceptPlanList" resultType="com.bz.smart_city.dto.assistant.AcceptPlanDTO">
  156. SELECT
  157. p.id,
  158. p.batch_no,
  159. p.accept_time,
  160. p.accept_sponsor,
  161. p.accept_confirm_user,
  162. p.remark,
  163. p.is_finished,
  164. p.customer_id,
  165. (select count(1) from sc_install_list l where l.accept_plan_id = p.id and l.`status` = 1) as meter_number,
  166. p.date_create,
  167. c.customer_name
  168. FROM
  169. sc_accept_plan p
  170. left join sc_customer c on (c.id = p.customer_id)
  171. WHERE
  172. p.status = 1
  173. <if test="siteId != null">
  174. and p.site_id = #{siteId}
  175. </if>
  176. <if test= "batchNo != null and batchNo != '' ">
  177. and batch_no like #{batchNo}
  178. </if>
  179. <if test="isFinished != null">
  180. and is_finished = #{isFinished}
  181. </if>
  182. <if test="customerId != null">
  183. and customer_id = #{customerId}
  184. </if>
  185. <if test="customers != null and customers.size() != 0">
  186. and customer_id in
  187. <foreach collection="customers" item="customer" open="(" separator="," close=")">
  188. #{customer.id}
  189. </foreach>
  190. </if>
  191. order by p.date_create desc
  192. </select>
  193. <select id="check" resultType="com.bz.smart_city.dto.assistant.InstallListDTO">
  194. SELECT
  195. t.id as id,
  196. t.install_time as install_time,
  197. t.device_no as device_no,
  198. t.electronic_no as electronic_no,
  199. t.new_meter_start as new_meter_start,
  200. ct.customer_name as customer_name,
  201. t.customer_id,
  202. c.`name` as community_name,
  203. b.community as community_id,
  204. b.`name` as building_name,
  205. t.building_id,
  206. t.door_no as door_no
  207. FROM
  208. sc_install_list t
  209. left join sc_building b on (t.building_id = b.id) and b.status = 1
  210. left join sc_community c on (c.id = b.community) and c.status = 1
  211. left join sc_customer ct on (t.customer_id = ct.id) and ct.status = 1
  212. WHERE
  213. t.is_installed = 1 and t.status = 1
  214. <if test="siteId != null">
  215. and t.site_id = #{siteId}
  216. </if> and t.accept_plan_id = #{acceptPlanId}
  217. </select>
  218. </mapper>