后台服务
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

100 linhas
3.5 KiB

  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.KwBoxMapper">
  4. <resultMap id="BaseResultMap" type="com.iformall.domain.po.KwBox">
  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="imei" jdbcType="BIGINT" property="imei"/>
  9. <result column="iccid" jdbcType="VARCHAR" property="iccid"/>
  10. <result column="place" jdbcType="VARCHAR" property="place"/>
  11. <result column="fw_version" jdbcType="VARCHAR" property="fwVersion"/>
  12. <result column="hd_version" jdbcType="VARCHAR" property="hdVersion"/>
  13. <result column="register_status" jdbcType="INTEGER" property="registerStatus"/>
  14. <result column="online_status" jdbcType="INTEGER" property="onlineStatus"/>
  15. <result column="register_time" jdbcType="TIMESTAMP" property="registerTime"/>
  16. <result column="last_online_time" jdbcType="TIMESTAMP" property="lastOnlineTime"/>
  17. <result column="config" jdbcType="VARCHAR" property="config"/>
  18. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  19. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  20. <result column="com_key" jdbcType="VARCHAR" property="comKey"/>
  21. <result column="status" jdbcType="INTEGER" property="status"/>
  22. <result column="max_tag_num" jdbcType="INTEGER" property="maxTagNum"/>
  23. <result column="meterCount" jdbcType="INTEGER" property="meterCount"/>
  24. </resultMap>
  25. <sql id="allColumns">
  26. `id`,`tenant_id`,`parent_tenant_id`,`imei`,`iccid`,`place`,`fw_version`,`hd_version`,`register_status`,`online_status`,`register_time`,
  27. `last_online_time`,`config`,`create_time`,`update_time`,`com_key`,`status`,`max_tag_num`
  28. </sql>
  29. <sql id="dynamicWhereConditions">
  30. where 1 = 1
  31. <if test=" null != id ">
  32. and `id` = #{id}
  33. </if>
  34. <if test=" null != tenantId and '' != tenantId">
  35. and `tenant_id` = #{tenantId}
  36. </if>
  37. <if test=" null != parentTenantId and '' != parentTenantId">
  38. and `parent_tenant_id` = #{parentTenantId}
  39. </if>
  40. <if test=" null != imei ">
  41. and `imei` like concat('%', #{imei},'%')
  42. </if>
  43. <if test=" null != iccid ">
  44. and `iccid` = #{iccid}
  45. </if>
  46. <if test=" null != place and '' != place ">
  47. and `place` like concat('%', #{place},'%')
  48. </if>
  49. <if test=" null != registerStatus ">
  50. and `register_status` = #{registerStatus}
  51. </if>
  52. <if test=" null != onlineStatus ">
  53. and `online_status` = #{onlineStatus}
  54. </if>
  55. <if test=" null != status ">
  56. and `status` = #{status}
  57. </if>
  58. <if test=" null != ids ">
  59. and id in
  60. <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
  61. #{idItem}
  62. </foreach>
  63. </if>
  64. <if test=" null != sortColumns">order by ${sortColumns}</if>
  65. </sql>
  66. <select id="findList" parameterType="com.iformall.domain.po.KwBox" resultMap="BaseResultMap">
  67. select
  68. <include refid="allColumns"/>
  69. ,IFNULL(mc,0) as meterCount
  70. from kw_box left join (
  71. select box_id, count(box_id) as mc from kw_meter
  72. where `status` = 0
  73. and `bind_status` = 0
  74. group by box_id
  75. ) meter on meter.box_id = id
  76. <include refid="dynamicWhereConditions"/>
  77. </select>
  78. <update id="offlineScan" parameterType="java.util.Date">
  79. update kw_box set `online_status` = 0
  80. where `status` = 0
  81. and `online_status` = 1
  82. and `last_online_time` &lt; #{expiredTime}
  83. </update>
  84. </mapper>