DvrDiskMapper.xml 8.9 KB

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