AcDevInfoMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.AcDevInfoDao">
  4. <select id="getAcDevListByVO" resultType="AcDevInfoDTO">
  5. select
  6. a.id,
  7. a.acAddress,
  8. a.deviceName,
  9. a.type,
  10. a.networkIP,
  11. a.createtime as createTime,
  12. s.name as section
  13. <choose>
  14. <when test="version == 0">
  15. ,gl.chinese_name as area
  16. </when>
  17. <when test="version == 1">
  18. ,gl.english_name as area
  19. </when>
  20. <otherwise>
  21. ,gl.ru_name as area
  22. </otherwise>
  23. </choose>
  24. from ac_dev_info a
  25. left join section s on a.sectionid = s.id
  26. left join global_location gl on s.pid = gl.id
  27. where 1=1
  28. <if test="sectionList != null and !sectionList.isEmpty()">
  29. and a.sectionid in
  30. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  31. #{item}
  32. </foreach>
  33. </if>
  34. <if test="areaId != null and areaId != 0">
  35. and a.areaid = #{areaId}
  36. </if>
  37. <if test="sectionId != null and sectionId != 0">
  38. and a.sectionid = #{sectionId}
  39. </if>
  40. <if test="keyword != null and keyword != ''">
  41. and (a.deviceName like '%${keyword}%' or a.acAddress like '%${keyword}%')
  42. </if>
  43. order by a.updatetime desc
  44. <if test="page >= 0 and count > 0">
  45. limit #{page},#{count}
  46. </if>
  47. </select>
  48. <select id="getAcDevTotal" resultType="Integer">
  49. select
  50. count(*)
  51. from ac_dev_info a
  52. left join section s on a.sectionid = s.id
  53. left join global_location gl on s.pid = gl.id
  54. where 1=1
  55. <if test="sectionList != null and !sectionList.isEmpty()">
  56. and a.sectionid in
  57. <foreach collection="sectionList" item="item" open="(" separator="," close=")">
  58. #{item}
  59. </foreach>
  60. </if>
  61. <if test="areaId != null and areaId != 0">
  62. and a.areaid = #{areaId}
  63. </if>
  64. <if test="sectionId != null and sectionId != 0">
  65. and a.sectionid = #{sectionId}
  66. </if>
  67. </select>
  68. <delete id="deleteAcDevData">
  69. delete
  70. from ac_dev_info
  71. where id in
  72. <foreach collection="ids" item="item" open="(" separator="," close=")">
  73. #{ids}
  74. </foreach>
  75. </delete>
  76. <insert id="addAcDevData" parameterType="AcDevInfoDTO" useGeneratedKeys="true" keyProperty="id">
  77. insert into ac_dev_info(deviceName,
  78. acAddress,
  79. type,
  80. <if test="networkIP != null and networkIP != ''">
  81. networkIP,
  82. </if>
  83. areaid,
  84. sectionid,
  85. latitude,
  86. longitude,
  87. createtime,
  88. updatetime)
  89. values (#{deviceName},
  90. #{acAddress},
  91. #{type},
  92. <if test="networkIP != null and networkIP != ''">
  93. #{networkIP},
  94. </if>
  95. #{areaId},
  96. #{sectionId},
  97. #{latitude},
  98. #{longitude},
  99. #{createTime},
  100. #{updateTime})
  101. </insert>
  102. <update id="updateAcDevData" parameterType="AcDevInfoDTO">
  103. update
  104. ac_dev_info a
  105. set
  106. a.deviceName = #{deviceName},
  107. a.acAddress = #{acAddress},
  108. a.type = #{type},
  109. <if test="networkIP != null and networkIP != ''">
  110. a.networkIP = #{networkIP},
  111. </if>
  112. a.areaid = #{areaId},
  113. a.sectionid = #{sectionId},
  114. a.longitude = #{longitude},
  115. a.latitude = #{latitude},
  116. a.updatetime = #{updateTime}
  117. where
  118. a.id = #{id}
  119. </update>
  120. <select id="checkAcDevData" resultType="Integer">
  121. select
  122. count(*)
  123. from ac_dev_info a
  124. where 1=1
  125. <if test="sectionId != null and sectionId != 0">
  126. and a.sectionid = #{sectionId}
  127. </if>
  128. <if test="deviceName != null and deviceName != ''">
  129. and a.deviceName = #{deviceName}
  130. </if>
  131. <if test="acAddress != null and acAddress != ''">
  132. and a.acAddress = #{acAddress}
  133. </if>
  134. <if test="id != null and id != ''">
  135. and a.id != #{id}
  136. </if>
  137. </select>
  138. <select id="getOneById" parameterType="Integer" resultType="AcDevInfoDTO">
  139. select id,acAddress,type,networkIP,access_token as accessToken,refresh_token as refreshToken,updatetime as updateTime
  140. from ac_dev_info where id = #{id}
  141. </select>
  142. <update id="updateByAcDevData" parameterType="AcDevInfoDTO">
  143. update
  144. ac_dev_info
  145. set
  146. access_token = #{accessToken},refresh_token = #{refreshToken},updatetime = #{updateTime}
  147. where
  148. id = #{id}
  149. </update>
  150. </mapper>