DvrDiskMapper.xml 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.IotDvrDiskMapper">
  4. <resultMap id="selectHostPageMap" type="com.xunmei.iot.vo.dvrDisk.DvrDiskPageVo">
  5. <result column="id" property="id"/>
  6. <result column="equipmentCode" property="equipmentCode"/>
  7. <result column="equipmentName" property="equipmentName"/>
  8. <result column="ip" property="ip"/>
  9. <result column="orgId" property="orgId"/>
  10. <result column="orgName" property="orgName"/>
  11. <result column="netState" property="netState"/>
  12. <!-- <result column="status" property="status"/>-->
  13. <!-- <result column="alarmTime" property="alarmTime"/>-->
  14. <!-- <result column="detailInfo" property="detailInfo"-->
  15. <!-- typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>-->
  16. <collection property="diskInfos" column="equipmentCode=equipmentCode"
  17. select="selectDiskInfo">
  18. <result column="id" property="id"/>
  19. <result column="org_id" property="orgId"/>
  20. <result column="host_code" property="hostCode"/>
  21. <result column="disk_index" property="diskIndex"/>
  22. <result column="disk_name" property="diskName"/>
  23. <result column="total" property="total"/>
  24. <result column="available" property="available"/>
  25. </collection>
  26. </resultMap>
  27. <resultMap id="selectAppHostPageMap" type="com.xunmei.iot.vo.dvrDisk.DvrDiskAppPageVo">
  28. <result column="equipmentCode" property="equipmentCode"/>
  29. <result column="equipmentName" property="equipmentName"/>
  30. <result column="check_time" property="stateUpdateTime"/>
  31. <result column="orgName" property="orgName"/>
  32. <result column="state" property="state"/>
  33. <collection property="diskInfos" column="equipmentCode=equipmentCode,state=state"
  34. select="selectDiskInfo">
  35. <result column="id" property="id"/>
  36. <result column="org_id" property="orgId"/>
  37. <result column="host_code" property="hostCode"/>
  38. <result column="disk_index" property="diskIndex"/>
  39. <result column="disk_name" property="diskName"/>
  40. <result column="total" property="total"/>
  41. <result column="available" property="available"/>
  42. <result column="state" property="state"/>
  43. </collection>
  44. </resultMap>
  45. <select id="selectHostPage" resultMap="selectHostPageMap">
  46. SELECT
  47. d.id,
  48. d.equipment_code AS equipmentCode,
  49. d.equipment_name AS equipmentName,
  50. d.net_address as ip,
  51. d.org_name AS orgName,
  52. d.producer as brand,
  53. dd.state as netState
  54. <!-- dhd.check_status AS `status`,-->
  55. <!-- dhd.check_time AS alarmTime,-->
  56. <!-- dhd.detail_info as detailInfo-->
  57. FROM
  58. iot_device d
  59. left join iot_device_detection dd on d.equipment_code =dd.equipment_code
  60. <!-- LEFT JOIN iot_dvr_hard_disk_detection dhd ON d.equipment_code = dhd.equipment_code-->
  61. WHERE
  62. d.category_id=#{pageDto.categoryId}
  63. <if test="pageDto.checkSub==true">
  64. and d.org_path like concat(#{orgPath},"%")
  65. </if>
  66. <if test="pageDto.checkSub==false">
  67. and d.org_id = #{pageDto.orgId}
  68. </if>
  69. <if test="pageDto.hostName!=null and pageDto.hostName!=''">
  70. and d.equipment_name like concat('%', #{pageDto.hostName},'%')
  71. </if>
  72. <if test="pageDto.netState!=null">
  73. and dd.state=#{pageDto.netState}
  74. </if>
  75. <!-- <if test="pageDto.status !=null">-->
  76. <!-- and dhd.`status` = #{pageDto.status}-->
  77. <!-- </if>-->
  78. <!-- <if test="pageDto.alarmStartTime !=null">-->
  79. <!-- and dhd.alarm_time >= #{pageDto.alarmStartTime}-->
  80. <!-- </if>-->
  81. <!-- <if test="pageDto.alarmEndTime !=null">-->
  82. <!-- and #{pageDto.alarmEndTime}>= dhd.`alarm_time`-->
  83. <!-- </if>-->
  84. and d.deleted=0
  85. </select>
  86. <select id="selectDiskInfo" resultType="com.xunmei.common.core.domain.iot.domain.IotDvrDisk">
  87. select id,
  88. available,
  89. `disk_index`,
  90. `disk_name`,
  91. `total`,
  92. `host_code`,
  93. `org_id`,
  94. state
  95. from iot_dvr_disk
  96. where host_code = #{equipmentCode}
  97. and deleted=0
  98. <if test="state==0 or state==1">
  99. and state=#{state}
  100. </if>
  101. <if test="state==2">
  102. and state is null
  103. </if>
  104. </select>
  105. <select id="getRecordAlarmHistoryList"
  106. resultType="com.xunmei.iot.vo.dvrDisk.DvrDiskAlarmHistoryPageVo">
  107. SELECT
  108. r.id,
  109. r.org_id AS orgId,
  110. r.org_name AS orgName,
  111. r.device_name AS deviceName,
  112. r.alarm_status as status,
  113. r.alarm_type AS alarmType,
  114. r.alarm_start_time AS alarmStartTime,
  115. r.alarm_end_time AS alarmEndTime,
  116. r.alarm_detail as alarmDetail
  117. FROM
  118. t_host_alarm_record r
  119. where r.device_type=3713671510851584 AND r.assets_type=3713670431768576
  120. <if test="pageDto.deviceId != null">
  121. and r.device_id = #{pageDto.deviceId}
  122. </if>
  123. <if test="pageDto.status != null">
  124. and r.alarm_status = #{pageDto.status}
  125. </if>
  126. <if test="pageDto.diskName != null">
  127. and r.alarm_detail like concat('%"',#{pageDto.diskName},'"%')
  128. </if>
  129. <if test="pageDto.alarmCode != null">
  130. and r.alarm_code= #{pageDto.alarmCode}
  131. </if>
  132. <if test="pageDto.alarmStartTime != null and pageDto.alarmEndTime != null">
  133. and ((r.alarm_start_time is not null and r.alarm_end_time is not null and
  134. r.alarm_end_time>=#{pageDto.alarmStartTime} and #{pageDto.alarmEndTime}>=r.alarm_start_time)
  135. or (r.alarm_end_time is null and r.alarm_start_time>= #{pageDto.alarmStartTime} and
  136. #{pageDto.alarmEndTime}>=r.alarm_start_time )
  137. or (r.alarm_start_time is null and r.alarm_end_time>= #{pageDto.alarmStartTime} and
  138. #{pageDto.alarmEndTime}>=r.alarm_end_time)
  139. )
  140. </if>
  141. order by r.alarm_start_time desc
  142. </select>
  143. <select id="diskStatistic" resultType="com.xunmei.iot.vo.dvrDisk.DvrDiskStatisticVo">
  144. SELECT count(0) AS dvrTotal,
  145. SUM(dd.count) AS diskTotal,
  146. SUM(dd.exceptionCount) as diskExceptionCount
  147. FROM iot_device d
  148. LEFT JOIN (SELECT host_code,count(0) as count,SUM(if(state=1,1,0)) as exceptionCount from iot_dvr_disk WHERE
  149. deleted=0 ) dd on dd.host_code =d.equipment_code
  150. where d.deleted=0 and d.category_id=#{pageDto.categoryId}
  151. <if test="pageDto.checkSub==true">
  152. and d.org_path like concat(#{orgPath},"%")
  153. </if>
  154. <if test="pageDto.checkSub==false">
  155. and d.org_id = #{pageDto.orgId}
  156. </if>
  157. </select>
  158. <select id="selectAppHostPage" resultMap="selectAppHostPageMap">
  159. SELECT
  160. d.id,
  161. d.equipment_code AS equipmentCode,
  162. d.equipment_name AS equipmentName,
  163. d.org_name AS orgName,
  164. dd.check_time,
  165. #{pageDto.state} as state
  166. FROM
  167. iot_device d
  168. left join iot_dvr_hard_disk_detection dd on d.equipment_code=dd.equipment_code
  169. WHERE
  170. d.category_id=#{pageDto.categoryId} and d.deleted=0
  171. <if test="pageDto.checkSub==true">
  172. and d.org_path like concat(#{orgPath},"%")
  173. </if>
  174. <if test="pageDto.checkSub==false">
  175. and d.org_id = #{pageDto.orgId}
  176. </if>
  177. <if test="pageDto.state==0 or pageDto.state==1">
  178. and d.equipment_code in (select host_code from iot_dvr_disk where deleted=0 and state=#{pageDto.state}
  179. <if test="pageDto.checkSub==true">
  180. and org_path like concat(#{orgPath},"%")
  181. </if>
  182. <if test="pageDto.checkSub==false">
  183. and org_id = #{pageDto.orgId}
  184. </if>
  185. )
  186. </if>
  187. <if test="pageDto.state==2">
  188. and (dd.check_status=1 or dd.check_status is null)
  189. </if>
  190. </select>
  191. </mapper>