TranshInfoMapper.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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.TranshInfoDao">
  4. <select id="getTotalBySectionList" resultType="Integer">
  5. select count(t.id) as total from transh_info t
  6. <if test="sectionList != null and !sectionList.isEmpty()">
  7. where t.sectionid in
  8. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  9. #{dto}
  10. </foreach>
  11. </if>
  12. </select>
  13. <select id="getOnlineTotalBySectionList" resultType="Integer">
  14. select count(t.id) as onlineTotal from transh_info t
  15. where t.online = 1
  16. <if test="sectionList != null and !sectionList.isEmpty()">
  17. and t.sectionid in
  18. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  19. #{dto}
  20. </foreach>
  21. </if>
  22. </select>
  23. <select id="getAlarmTotalBySectionList" resultType="Integer">
  24. select count(t.id) as alarmTotal from transh_info t
  25. where t.online = 1 and (t.full = 1 or t.state = 1)
  26. <if test="sectionList != null and !sectionList.isEmpty()">
  27. and t.sectionid in
  28. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  29. #{dto}
  30. </foreach>
  31. </if>
  32. </select>
  33. <select id="getNormalTotalBySectionList" resultType="Integer">
  34. select count(t.id) as normalTotal from transh_info t
  35. where t.full = 0 and t.state = 0 and t.online = 1
  36. <if test="sectionList != null and !sectionList.isEmpty()">
  37. and t.sectionid in
  38. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  39. #{dto}
  40. </foreach>
  41. </if>
  42. </select>
  43. <select id="getTranshListByDTO" resultType="TranshInfoDTO">
  44. select t.id,t.name,t.areaid as areaId,t.sectionid as sectionId,t.address,
  45. t.online,t.rssi,t.rsrp as rsRp,t.snr,t.distance,t.state,t.angle,
  46. t.longitude,t.latitude,t.batt as batT,t.temperature,t.updateTime,
  47. t.createTime,t.full,t.deviceId,s.name as section,
  48. g.english_name englishName,g.ru_name ruName,g.chinese_name chineseName,
  49. p.chinese_name as chCity,p.english_name as enCity,p.ru_name as ruCity,s.timezone
  50. from transh_info t left join section s on t.sectionid = s.id
  51. left join global_location g on t.areaid = g.id
  52. left join global_location p on g.pid = p.id
  53. where 1=1 <if test="sectionList != null and !sectionList.isEmpty()">
  54. and t.sectionid in
  55. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  56. #{dto}
  57. </foreach>
  58. </if>
  59. <if test="keywords != null and keywords != ''">
  60. and (t.name like '%${keywords}%' or t.address like '%${keywords}%')
  61. </if>
  62. order by convert(t.name using gbk) asc,t.id desc
  63. <if test="page >= 0 and count > 0">
  64. limit #{page},#{count}
  65. </if>
  66. </select>
  67. <select id="getHistoryListByDTO" resultType="TranshInfoDTO">
  68. select t.rssi,t.rsrp as rsRp,t.snr,t.distance,t.angle,t.state,t.batt as batT,
  69. t.temperature,t.online,t.full,t.updateTime,s.timezone
  70. from transh_info t left join section s on t.sectionid = s.id
  71. where t.id = #{id}
  72. <if test="sectionList != null and !sectionList.isEmpty()">
  73. and t.sectionid in
  74. <foreach collection="sectionList" item="dto" open="(" separator="," close=")">
  75. #{dto}
  76. </foreach>
  77. </if>
  78. <if test="page >= 0 and count > 0">
  79. limit #{page},#{count}
  80. </if>
  81. </select>
  82. <select id="findByDTO" resultType="Integer">
  83. select count(*)
  84. from transh_info t
  85. where 1=1
  86. <if test="sectionId != null">
  87. and t.sectionid = #{sectionId}
  88. </if>
  89. <if test="name != null">
  90. and t.name = #{name}
  91. </if>
  92. <if test="address != null">
  93. and t.address = #{address}
  94. </if>
  95. </select>
  96. <select id="checkDataByDTO" resultType="Integer" parameterType="com.welampiot.dto.TranshInfoDTO">
  97. select count(*) from transh_info t
  98. where 1=1
  99. <if test="sectionId != null">
  100. and t.sectionid = #{sectionId}
  101. </if>
  102. <if test="name != null">
  103. and t.name = #{name}
  104. </if>
  105. <if test="address != null">
  106. and t.address = #{address}
  107. </if>
  108. <if test="id != null">
  109. and t.id != #{id}
  110. </if>
  111. limit 1
  112. </select>
  113. <insert id="addTranshDataByDTO" parameterType="com.welampiot.dto.TranshInfoDTO" useGeneratedKeys="true" keyProperty="id">
  114. insert into transh_info(areaid, sectionid, address, name, longitude, latitude)
  115. values
  116. (#{areaId}, #{sectionId}, #{address}, #{name}, #{longitude}, #{latitude})
  117. </insert>
  118. <update id="updateTranshDataByTranshId" parameterType="com.welampiot.dto.TranshInfoDTO">
  119. update transh_info
  120. set
  121. areaid = #{areaId},
  122. sectionid = #{sectionId},
  123. name = #{name},
  124. address = #{address},
  125. longitude = #{longitude},
  126. latitude = #{latitude}
  127. where id = #{id}
  128. </update>
  129. <delete id="deleteTrashDevById">
  130. delete from transh_info where id = #{id}
  131. </delete>
  132. <delete id="deleteTrashDevLogById">
  133. delete from transh_info_log where transh_id = #{id}
  134. </delete>
  135. </mapper>