后台服务
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

KwMeterMapper.xml 5.8 KiB

2 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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.iformall.mapper.KwMeterMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.KwMeter">
  5. <id column="id" jdbcType="BIGINT" property="id"/>
  6. <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
  7. <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
  8. <result column="address" jdbcType="BIGINT" property="address"/>
  9. <result column="brand" jdbcType="VARCHAR" property="brand"/>
  10. <result column="place" jdbcType="VARCHAR" property="place"/>
  11. <result column="model" jdbcType="VARCHAR" property="model"/>
  12. <result column="last_online_time" jdbcType="TIMESTAMP" property="lastOnlineTime"/>
  13. <result column="total_power" jdbcType="INTEGER" property="totalPower"/>
  14. <result column="online_status" jdbcType="INTEGER" property="onlineStatus"/>
  15. <result column="config" jdbcType="VARCHAR" property="config"/>
  16. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  17. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  18. <result column="box_id" jdbcType="BIGINT" property="boxId"/>
  19. <result column="status" jdbcType="INTEGER" property="status"/>
  20. <result column="bind_status" jdbcType="INTEGER" property="bindStatus"/>
  21. <result column="merchant_name" jdbcType="VARCHAR" property="merchantName"/>
  22. <result column="merchant_id" jdbcType="BIGINT" property="merchantId"/>
  23. </resultMap>
  24. <sql id="allColumns">
  25. `kw_meter`.`id`,`kw_meter`.`tenant_id`,`kw_meter`.`parent_tenant_id`,`kw_meter`.`address`,`kw_meter`.`brand`,`kw_meter`.`model`,
  26. `kw_meter`.`place`,`kw_meter`.`last_online_time`,`kw_meter`.`total_power`,`kw_meter`.`online_status`,
  27. `kw_meter`.`config`,`kw_meter`.`create_time`,`kw_meter`.`update_time`,`kw_meter`.`box_id`,`kw_meter`.`status`,`kw_meter`.`bind_status`
  28. </sql>
  29. <sql id="dynamicWhereConditions">
  30. where 1 = 1
  31. <if test=" null != id ">
  32. and `kw_meter`.`id` = #{id}
  33. </if>
  34. <if test=" null != tenantId and '' != tenantId">
  35. and `kw_meter`.`tenant_id` = #{tenantId}
  36. </if>
  37. <if test=" null != parentTenantId and '' != parentTenantId">
  38. and `kw_meter`.`parent_tenant_id` = #{parentTenantId}
  39. </if>
  40. <if test=" null != address">
  41. and `kw_meter`.`address` like concat('%', #{address},'%')
  42. </if>
  43. <if test=" null != brand and '' != brand ">
  44. and `kw_meter`.`brand` like concat('%', #{brand},'%')
  45. </if>
  46. <if test=" null != place and '' != place ">
  47. and `kw_meter`.`place` like concat('%', #{place},'%')
  48. </if>
  49. <if test=" null != model ">
  50. and `kw_meter`.`model` = #{model}
  51. </if>
  52. <if test=" null != onlineStatus ">
  53. and `kw_meter`.`online_status` = #{onlineStatus}
  54. </if>
  55. <if test=" null != boxId ">
  56. and `kw_meter`.`box_id` = #{boxId}
  57. </if>
  58. <if test=" null != status ">
  59. and `kw_meter`.`status` = #{status}
  60. </if>
  61. <if test=" null != bindStatus ">
  62. and `kw_meter`.`bind_status` = #{bindStatus}
  63. </if>
  64. <if test=" null != merchantMeterStatus and 1 == merchantMeterStatus">
  65. and `kw_meter`.`id` not in (select meter_id from kw_merchant_meter where status = 0)
  66. </if>
  67. <if test=" null != merchantMeterStatus and 0 == merchantMeterStatus">
  68. and `kw_meter`.`id` in (select meter_id from kw_merchant_meter where status = 0)
  69. </if>
  70. <if test=" null != ids ">
  71. and `kw_meter`.id in
  72. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  73. #{idItem}
  74. </foreach>
  75. </if>
  76. <if test=" null != sortColumns">order by ${sortColumns}</if>
  77. </sql>
  78. <select id="findList" parameterType="com.iformall.domain.po.KwMeter" resultMap="BaseResultMap">
  79. select
  80. <include refid="allColumns"/>
  81. from kw_meter
  82. <include refid="dynamicWhereConditions"/>
  83. </select>
  84. <select id="findVoList" parameterType="com.iformall.domain.po.KwMeter" resultMap="BaseResultMap">
  85. select
  86. <include refid="allColumns"/>
  87. ,mm.merchant_id as merchant_id, m.name as merchant_name
  88. from kw_meter
  89. left join kw_merchant_meter mm on kw_meter.id = mm.meter_id and mm.status = 0
  90. left join wx_merchant m on m.id = mm.merchant_id
  91. <include refid="dynamicWhereConditions"/>
  92. </select>
  93. <update id="onlineBatch" parameterType="java.util.List" >
  94. update kw_meter
  95. set
  96. total_power=
  97. case
  98. <foreach collection="list" item="item" index="index">
  99. <if test="item.totalPower!=null">
  100. when id = #{item.id} then #{item.totalPower}
  101. </if>
  102. </foreach>
  103. end,
  104. online_status = 1,
  105. last_online_time = now()
  106. where id in
  107. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  108. #{item.id}
  109. </foreach>
  110. </update>
  111. <update id="offlineBatch" parameterType="com.iformall.domain.po.KwMeter" >
  112. update kw_meter
  113. set
  114. online_status = 0
  115. where id in
  116. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  117. #{idItem}
  118. </foreach>
  119. and online_status = 1
  120. </update>
  121. <update id="unbindBatch" parameterType="java.lang.Long">
  122. update kw_meter set bind_status = 1, box_id = 0
  123. where bind_status = 0
  124. and `box_id` = #{boxId}
  125. </update>
  126. <update id="unbind" parameterType="java.lang.Long">
  127. update kw_meter set bind_status = 1, box_id = 0
  128. where bind_status = 0
  129. and `id` = #{meterId}
  130. </update>
  131. <update id="bindBatch" parameterType="map">
  132. update kw_meter set bind_status = 0, box_id = #{boxId}
  133. where id in
  134. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  135. #{idItem}
  136. </foreach>
  137. </update>
  138. <update id="bind" parameterType="map">
  139. update kw_meter set bind_status = 0, box_id = #{boxId}
  140. where `id` = #{id}
  141. </update>
  142. <update id="offlineScan" parameterType="java.util.Date">
  143. update kw_meter set `online_status` = 0
  144. where `status` = 0
  145. and `online_status` = 1
  146. and `last_online_time` &lt; #{expiredTime}
  147. </update>
  148. </mapper>