IotSensorMapper.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.xunmei.iot.mapper.IotCommonSensorMapper">
  4. <select id="selectPageData" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
  5. select s.id, org_id, org_name,org_path, device_name, device_type, infos as info,device_code, state_update_time as updateTime,state
  6. from iot_sensor s
  7. where s.deleted=0
  8. <if test="request.orgId!= null">
  9. and s.org_id=#{request.orgId}
  10. </if>
  11. <if test="request.orgPath!= null">
  12. and s.org_path like CONCAT(#{request.orgPath}, '%')
  13. </if>
  14. <if test="request.deviceName != null and request.deviceName!= ''">
  15. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  16. </if>
  17. <if test="request.state!= null">
  18. and s.state = #{request.state}
  19. </if>
  20. <if test="request.deviceType!= null and request.deviceType!= ''">
  21. and s.device_type = #{request.deviceType}
  22. </if>
  23. <if test="request.startTime!= null">
  24. and s.state_update_time >=#{request.startTime}
  25. </if>
  26. <if test="request.endTime!= null">
  27. and s.state_update_time <![CDATA[<=]]> #{request.endTime}
  28. </if>
  29. </select>
  30. <select id="selectAppPageData" resultType="com.xunmei.iot.vo.sensor.SensorAppPageVo">
  31. select s.id,org_name, device_name, device_type, infos as info,device_code, state_update_time ,state
  32. from iot_sensor s
  33. where s.deleted=0
  34. <if test="request.orgId!= null">
  35. and s.org_id=#{request.orgId}
  36. </if>
  37. <if test="request.orgPath!= null">
  38. and s.org_path like CONCAT(#{request.orgPath}, '%')
  39. </if>
  40. <if test="request.state!= null">
  41. and s.state = #{request.state}
  42. </if>
  43. <if test="request.deviceType!= null and request.deviceType!= ''">
  44. and s.device_type = #{request.deviceType}
  45. </if>
  46. </select>
  47. <select id="stateStatistic" resultType="com.xunmei.iot.vo.sensor.SensorAppStateVo">
  48. SELECT sum(state=0) as normal,
  49. sum(state=1) as alarm
  50. from iot_sensor s
  51. where s.deleted=0
  52. <if test="request.orgId!= null">
  53. and s.org_id=#{request.orgId}
  54. </if>
  55. <if test="request.orgPath!= null">
  56. and s.org_path like CONCAT(#{request.orgPath}, '%')
  57. </if>
  58. <!-- <if test="request.deviceType!= null and request.deviceType!= ''">-->
  59. <!-- and s.device_type = #{request.deviceType}-->
  60. <!-- </if>-->
  61. </select>
  62. <select id="selectSensorLogDataPage" resultType="com.xunmei.iot.vo.sensor.SensorPageVo">
  63. select s.id, org_id, org_name, device_name, infos as info,device_code, update_time from
  64. iot_sensor_log s
  65. <where>
  66. <if test="request.orgId!= null">
  67. and s.org_id=#{request.orgId}
  68. </if>
  69. <if test="request.orgPath!= null">
  70. and s.org_path like CONCAT(#{request.orgPath}, '%')
  71. </if>
  72. <if test="request.deviceName != null and request.deviceName!= ''">
  73. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  74. </if>
  75. <if test="request.deviceCode != null and request.deviceCode!= ''">
  76. and s.device_code =#{request.deviceCode}
  77. </if>
  78. <if test="request.startTime!= null">
  79. and s.state_update_time >=#{request.startTime}
  80. </if>
  81. <if test="request.endTime!= null">
  82. and s.state_update_time <![CDATA[<=]]> #{request.endTime}
  83. </if>
  84. </where>
  85. order by s.create_time desc
  86. </select>
  87. <select id="selectByIds" resultType="com.xunmei.common.core.domain.iot.domain.IotSensor">
  88. SELECT
  89. org_id,
  90. CONCAT(b.affiliated_area,'-',b.affiliated_bank,'-',b.short_name) as org_name,
  91. device_name,
  92. infos AS info,
  93. device_code
  94. FROM
  95. iot_sensor a
  96. LEFT JOIN sys_org b ON a.org_id = b.id
  97. where device_code in
  98. <foreach collection="deviceIds" index="index" item="item" open="(" separator="," close=")">
  99. #{item}
  100. </foreach>
  101. </select>
  102. <select id="selectListData" resultType="com.xunmei.iot.vo.sensor.SensorExportVo">
  103. select org_name, device_name, device_type, infos as info,update_time,state
  104. from iot_sensor s
  105. where s.deleted=0
  106. <if test="request.orgId!= null">
  107. and s.org_id=#{request.orgId}
  108. </if>
  109. <if test="request.orgPath!= null">
  110. and s.org_path like CONCAT(#{request.orgPath}, '%')
  111. </if>
  112. <if test="request.deviceName != null and request.deviceName!= ''">
  113. and s.device_name like CONCAT('%',#{request.deviceName},'%')
  114. </if>
  115. <if test="request.state!= null">
  116. and s.state = #{request.state}
  117. </if>
  118. <if test="request.deviceType!= null">
  119. and s.device_type = #{request.deviceType}
  120. </if>
  121. <if test="request.startTime!= null">
  122. and s.state_update_time >=#{request.startTime}
  123. </if>
  124. <if test="request.endTime!= null">
  125. and s.state_update_time <![CDATA[<=]]> #{request.endTime}
  126. </if>
  127. </select>
  128. </mapper>