DvrDiskMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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,orgId=orgId"
  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="orgId" property="orgId"/>
  35. <result column="state" property="state"/>
  36. <collection property="diskInfos" column="equipmentCode=equipmentCode,state=state,orgId=orgId"
  37. select="selectDiskInfo">
  38. <result column="id" property="id"/>
  39. <result column="org_id" property="orgId"/>
  40. <result column="host_code" property="hostCode"/>
  41. <result column="disk_index" property="diskIndex"/>
  42. <result column="disk_name" property="diskName"/>
  43. <result column="total" property="total"/>
  44. <result column="available" property="available"/>
  45. <result column="state" property="state"/>
  46. </collection>
  47. </resultMap>
  48. <!-- <select id="selectHostPage" resultMap="selectHostPageMap">
  49. SELECT
  50. d.id,
  51. d.equipment_code AS equipmentCode,
  52. d.equipment_name AS equipmentName,
  53. d.net_address as ip,
  54. d.org_name AS orgName,
  55. o.affiliated_area,
  56. o.affiliated_bank,
  57. d.producer as brand,
  58. dd.state as netState
  59. &lt;!&ndash; dhd.check_status AS `status`,&ndash;&gt;
  60. &lt;!&ndash; dhd.check_time AS alarmTime,&ndash;&gt;
  61. &lt;!&ndash; dhd.detail_info as detailInfo&ndash;&gt;
  62. FROM
  63. iot_device d
  64. inner join sys_org o on d.org_id =o.id and o.deleted=0 and o.is_lock='0'
  65. left join iot_device_detection dd on d.equipment_code =dd.equipment_code
  66. &lt;!&ndash; LEFT JOIN iot_dvr_hard_disk_detection dhd ON d.equipment_code = dhd.equipment_code&ndash;&gt;
  67. WHERE
  68. d.category_id=#{pageDto.categoryId}
  69. <if test="pageDto.checkSub==true">
  70. and d.org_path like concat(#{orgPath},"%")
  71. </if>
  72. <if test="pageDto.checkSub==false">
  73. and d.org_id = #{pageDto.orgId}
  74. </if>
  75. <if test="pageDto.hostName!=null and pageDto.hostName!=''">
  76. and d.equipment_name like concat('%', #{pageDto.hostName},'%')
  77. </if>
  78. <if test="pageDto.netState!=null">
  79. and dd.state=#{pageDto.netState}
  80. </if>
  81. &lt;!&ndash; <if test="pageDto.status !=null">&ndash;&gt;
  82. &lt;!&ndash; and dhd.`status` = #{pageDto.status}&ndash;&gt;
  83. &lt;!&ndash; </if>&ndash;&gt;
  84. &lt;!&ndash; <if test="pageDto.alarmStartTime !=null">&ndash;&gt;
  85. &lt;!&ndash; and dhd.alarm_time >= #{pageDto.alarmStartTime}&ndash;&gt;
  86. &lt;!&ndash; </if>&ndash;&gt;
  87. &lt;!&ndash; <if test="pageDto.alarmEndTime !=null">&ndash;&gt;
  88. &lt;!&ndash; and #{pageDto.alarmEndTime}>= dhd.`alarm_time`&ndash;&gt;
  89. &lt;!&ndash; </if>&ndash;&gt;
  90. and d.deleted=0
  91. </select>-->
  92. <select id="selectHostPage" resultMap="selectHostPageMap">
  93. SELECT
  94. d.id,
  95. ie.net_address as ip,
  96. d.device_code AS equipmentCode,
  97. d.device_name AS equipmentName,
  98. d.org_name AS orgName,
  99. o.affiliated_area,
  100. o.affiliated_bank,
  101. d.device_product as brand,
  102. d.net_status as netState,
  103. d.org_id as orgId
  104. FROM
  105. iot_device_info d
  106. inner join sys_org o on d.org_id =o.id and o.deleted=0 and o.is_lock='0'
  107. left join iot_device_info_extend ie on d.id =ie.device_id
  108. WHERE d.device_type=1 and d.deleted=0
  109. <if test="pageDto.checkSub==true">
  110. and d.org_path like concat(#{orgPath},"%")
  111. </if>
  112. <if test="pageDto.checkSub==false">
  113. and d.org_id = #{pageDto.orgId}
  114. </if>
  115. <if test="pageDto.hostName!=null and pageDto.hostName!=''">
  116. and d.device_name like concat('%', #{pageDto.hostName},'%')
  117. </if>
  118. <if test="pageDto.netState!=null">
  119. and d.net_status=#{pageDto.netState}
  120. </if>
  121. <!-- <if test="pageDto.status !=null">-->
  122. <!-- and dhd.`status` = #{pageDto.status}-->
  123. <!-- </if>-->
  124. <!-- <if test="pageDto.alarmStartTime !=null">-->
  125. <!-- and dhd.alarm_time >= #{pageDto.alarmStartTime}-->
  126. <!-- </if>-->
  127. <!-- <if test="pageDto.alarmEndTime !=null">-->
  128. <!-- and #{pageDto.alarmEndTime}>= dhd.`alarm_time`-->
  129. <!-- </if>-->
  130. and d.deleted=0
  131. </select>
  132. <select id="selectDiskInfo" resultType="com.xunmei.common.core.domain.iot.domain.IotDvrDisk">
  133. select id,
  134. available,
  135. `disk_index`,
  136. `disk_name`,
  137. `total`,
  138. `host_code`,
  139. `org_id`,
  140. state
  141. from iot_dvr_disk
  142. where host_code = #{equipmentCode} and org_id =#{orgId}
  143. and deleted=0
  144. <if test="state==0 or state==1">
  145. and state=#{state}
  146. </if>
  147. <if test="state==2">
  148. and state is null
  149. </if>
  150. </select>
  151. <select id="getRecordAlarmHistoryList"
  152. resultType="com.xunmei.iot.vo.dvrDisk.DvrDiskAlarmHistoryPageVo">
  153. SELECT
  154. r.id,
  155. r.org_id AS orgId,
  156. r.org_name AS orgName,
  157. r.device_name AS deviceName,
  158. r.alarm_status as status,
  159. r.alarm_type AS alarmType,
  160. r.alarm_start_time AS alarmStartTime,
  161. r.alarm_end_time AS alarmEndTime,
  162. r.alarm_detail as alarmDetail
  163. FROM
  164. t_host_alarm_record r
  165. where r.device_type=3713671510851584 AND r.assets_type=3713670431768576
  166. <if test="pageDto.deviceId != null">
  167. and r.device_id = #{pageDto.deviceId}
  168. </if>
  169. <if test="pageDto.status != null">
  170. and r.alarm_status = #{pageDto.status}
  171. </if>
  172. <if test="pageDto.diskName != null">
  173. and r.alarm_detail like concat('%"',#{pageDto.diskName},'"%')
  174. </if>
  175. <if test="pageDto.alarmCode != null">
  176. and r.alarm_code= #{pageDto.alarmCode}
  177. </if>
  178. <if test="pageDto.alarmStartTime != null and pageDto.alarmEndTime != null">
  179. and ((r.alarm_start_time is not null and r.alarm_end_time is not null and
  180. r.alarm_end_time>=#{pageDto.alarmStartTime} and #{pageDto.alarmEndTime}>=r.alarm_start_time)
  181. or (r.alarm_end_time is null and r.alarm_start_time>= #{pageDto.alarmStartTime} and
  182. #{pageDto.alarmEndTime}>=r.alarm_start_time )
  183. or (r.alarm_start_time is null and r.alarm_end_time>= #{pageDto.alarmStartTime} and
  184. #{pageDto.alarmEndTime}>=r.alarm_end_time)
  185. )
  186. </if>
  187. order by r.alarm_start_time desc
  188. </select>
  189. <!--<select id="diskStatistic" resultType="com.xunmei.iot.vo.dvrDisk.DvrDiskStatisticVo">
  190. SELECT count(0) AS dvrTotal,
  191. SUM(dd.count) AS diskTotal,
  192. SUM(dd.exceptionCount) as diskExceptionCount
  193. FROM iot_device d
  194. LEFT JOIN (SELECT host_code,count(0) as count,SUM(if(state=1,1,0)) as exceptionCount from iot_dvr_disk WHERE
  195. deleted=0 group by host_code) dd on dd.host_code =d.equipment_code
  196. where d.deleted=0 and d.category_id=#{pageDto.categoryId}
  197. <if test="pageDto.checkSub==true">
  198. and d.org_path like concat(#{orgPath},"%")
  199. </if>
  200. <if test="pageDto.checkSub==false">
  201. and d.org_id = #{pageDto.orgId}
  202. </if>
  203. </select>-->
  204. <select id="diskStatistic" resultType="com.xunmei.iot.vo.dvrDisk.DvrDiskStatisticVo">
  205. SELECT count(0) AS dvrTotal,
  206. SUM(dd.count) AS diskTotal,
  207. SUM(dd.exceptionCount) as diskExceptionCount
  208. FROM iot_device_info d
  209. LEFT JOIN
  210. (SELECT org_id, host_code,count(0) as count,SUM(if(state=1,1,0)) as exceptionCount from iot_dvr_disk WHERE
  211. deleted=0
  212. <if test="pageDto.checkSub==true">
  213. and org_path like concat(#{orgPath},"%")
  214. </if>
  215. <if test="pageDto.checkSub==false">
  216. and org_id = #{pageDto.orgId}
  217. </if>
  218. group by org_id,host_code ) dd on dd.host_code =d.device_code and d.org_id=dd.org_id
  219. where d.deleted=0 and d.device_type=1
  220. <if test="pageDto.checkSub==true">
  221. and d.org_path like concat(#{orgPath},"%")
  222. </if>
  223. <if test="pageDto.checkSub==false">
  224. and d.org_id = #{pageDto.orgId}
  225. </if>
  226. </select>
  227. <select id="selectAppHostPage" resultMap="selectAppHostPageMap">
  228. SELECT
  229. d.id,d.org_id as orgId,
  230. d.device_code AS equipmentCode,
  231. d.device_name AS equipmentName,
  232. d.org_name AS orgName,
  233. dd.check_time,
  234. #{pageDto.state} as state
  235. FROM
  236. iot_device_info d
  237. left join iot_dvr_hard_disk_detection dd on d.device_code=dd.equipment_code
  238. WHERE
  239. d.device_type=1 and d.deleted=0
  240. <if test="pageDto.checkSub==true">
  241. and d.org_path like concat(#{orgPath},"%")
  242. </if>
  243. <if test="pageDto.checkSub==false">
  244. and d.org_id = #{pageDto.orgId}
  245. </if>
  246. <if test="pageDto.state==0 or pageDto.state==1">
  247. and d.device_code in (select host_code from iot_dvr_disk where deleted=0 and state=#{pageDto.state}
  248. <if test="pageDto.checkSub==true">
  249. and org_path like concat(#{orgPath},"%")
  250. </if>
  251. <if test="pageDto.checkSub==false">
  252. and org_id = #{pageDto.orgId}
  253. </if>
  254. group by host_code
  255. )
  256. </if>
  257. <if test="pageDto.state==2">
  258. and (dd.check_status=1 or dd.check_status is null)
  259. </if>
  260. </select>
  261. <select id="selectDiskCount" resultType="com.xunmei.common.core.domain.iot.domain.IotDvrDisk">
  262. select *
  263. from iot_dvr_disk d
  264. inner join sys_org o on o.id = d.org_id
  265. where o.deleted = 0
  266. and d.deleted = 0
  267. and o.path like concat(#{orgPath}, '%')
  268. </select>
  269. <select id="selectDiskBadge" resultType="java.lang.Integer">
  270. select sum( d.`state` = 1 ) AS count
  271. from iot_dvr_disk d inner join iot_server_info i on i.iot_code=d.iot_token
  272. <if test="orgPath!=null and orgPath != ''">
  273. inner join sys_org o on o.id = d.org_id
  274. </if>
  275. where
  276. d.deleted = 0
  277. and d.state =1
  278. <if test="orgPath!=null and orgPath != ''">
  279. and o.deleted = 0
  280. and o.is_lock=0
  281. and o.path like concat(#{orgPath}, '%')
  282. </if>
  283. <if test="orgId!=null">
  284. and d.org_id= #{orgId}
  285. </if>
  286. </select>
  287. </mapper>