SysDeviceMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.xunmei.system.mapper.SysDeviceMapper">
  6. <resultMap type="com.xunmei.system.api.domain.SysDevice" id="SysDeviceResult">
  7. <result property="id" column="id"/>
  8. <result property="orgId" column="org_id"/>
  9. <result property="orgName" column="org_name"/>
  10. <result property="deviceName" column="device_name"/>
  11. <result property="assetType" column="asset_type"/>
  12. <result property="deviceType" column="device_type"/>
  13. <result property="deviceBrand" column="device_brand"/>
  14. <result property="checkTime" column="check_time"/>
  15. <result property="maintenanceTerm" column="maintenance_term"/>
  16. <result property="createTime" column="create_time"/>
  17. <result property="updateTime" column="update_time"/>
  18. <result property="createBy" column="create_by"/>
  19. <result property="updateBy" column="update_by"/>
  20. <result property="delFlag" column="del_flag"/>
  21. <result property="hostId" column="host_id"/>
  22. <result property="channel" column="channel"/>
  23. </resultMap>
  24. <sql id="selectSysDeviceVo">
  25. select id,
  26. org_id,
  27. org_name,
  28. device_name,
  29. asset_type,
  30. device_type,
  31. device_brand,
  32. check_time,
  33. maintenance_term,
  34. create_time,
  35. update_time,
  36. create_by,
  37. update_by,
  38. del_flag,
  39. host_id,
  40. channel
  41. from sys_device
  42. </sql>
  43. <select id="selectSysDeviceList" parameterType="com.xunmei.system.api.domain.SysDevice"
  44. resultMap="SysDeviceResult">
  45. <include refid="selectSysDeviceVo"/>
  46. <where>
  47. <if test="orgId != null ">
  48. and org_id = #{orgId}
  49. </if>
  50. <if test="orgName != null and orgName != ''">
  51. and org_name like concat('%', #{orgName}, '%')
  52. </if>
  53. <if test="deviceName != null and deviceName != ''">
  54. and device_name like concat('%', #{deviceName}, '%')
  55. </if>
  56. <if test="assetType != null and assetType != ''">
  57. and asset_type = #{assetType}
  58. </if>
  59. <if test="deviceType != null and deviceType != ''">
  60. and device_type = #{deviceType}
  61. </if>
  62. <if test="deviceBrand != null and deviceBrand != ''">
  63. and device_brand = #{deviceBrand}
  64. </if>
  65. <if test="checkTime != null ">
  66. and check_time = #{checkTime}
  67. </if>
  68. <if test="maintenanceTerm != null and maintenanceTerm != ''">
  69. and maintenance_term = #{maintenanceTerm}
  70. </if>
  71. <if test="hostId != null ">
  72. and host_id = #{hostId}
  73. </if>
  74. <if test="channel != null ">
  75. and channel = #{channel}
  76. </if>
  77. </where>
  78. </select>
  79. <select id="selectSysDeviceById" parameterType="Long"
  80. resultMap="SysDeviceResult">
  81. <include refid="selectSysDeviceVo"/>
  82. where id = #{id}
  83. </select>
  84. <select id="getHostByOrgId" resultType="com.xunmei.system.api.domain.SysDevice">
  85. <include refid="selectSysDeviceVo"/>
  86. WHERE
  87. org_id =#{orgId} and del_flag='0' and device_type='0'
  88. </select>
  89. <select id="findList" resultType="com.xunmei.system.api.domain.SysDevice">
  90. select * from sys_device
  91. <where>
  92. <if test="request.assetType!=null">
  93. and asset_type=#{request.assetType}
  94. </if>
  95. <if test="request.deviceType!=null">
  96. and device_type=#{request.deviceType}
  97. </if>
  98. <if test="request.checkSub==true">
  99. and org_id in (select id from sys_org where path like concat((select path from sys_org where id
  100. =#{request.orgId},'%')))
  101. </if>
  102. <if test="request.checkSub!=true">
  103. and org_id=#{request.orgId}
  104. </if>
  105. </where>
  106. </select>
  107. <select id="selectVideoChannelByMonitorId" resultType="java.lang.Long">
  108. SELECT video_channel
  109. FROM core_monitoring_task_registration_monitor
  110. WHERE task_registration_id = #{monitorId}
  111. </select>
  112. <select id="getAccessByVideo" resultType="com.xunmei.system.vo.area.AccessType">
  113. SELECT cmtmi.situation AS situation,
  114. COUNT(cmtrm.id) AS num
  115. FROM core_monitoring_retrieval_task cmrt
  116. LEFT JOIN core_monitoring_task_registration cmtr ON cmrt.id = cmtr.task_id
  117. LEFT JOIN core_monitoring_task_registration_monitor cmtrm ON cmtrm.task_registration_id = cmtr.id
  118. LEFT JOIN core_monitoring_task_monitor_info cmtmi ON cmtmi.task_monitor_id = cmtrm.id
  119. WHERE cmtmi.situation IS NOT NULL
  120. AND cmtrm.video_channel = #{videoId}
  121. and cmrt.id = #{taskId}
  122. GROUP BY cmtmi.situation
  123. </select>
  124. <select id="selectByHostNameAndOrgId" resultType="com.xunmei.system.api.domain.SysDevice">
  125. SELECT *
  126. FROM sys_device
  127. WHERE org_id = #{orgId}
  128. AND device_name = #{hostName}
  129. </select>
  130. <!-- <select id="getAccessByVideo" resultType="java.util.Map">-->
  131. <!-- SELECT cmtmi.situation AS situation,-->
  132. <!-- COUNT(cmtrm.id) AS num-->
  133. <!-- FROM core_monitoring_retrieval_task cmrt-->
  134. <!-- LEFT JOIN core_monitoring_task_registration cmtr ON cmrt.id = cmtr.task_id-->
  135. <!-- LEFT JOIN core_monitoring_task_registration_monitor cmtrm ON cmtrm.task_registration_id = cmtr.id-->
  136. <!-- LEFT JOIN core_monitoring_task_monitor_info cmtmi ON cmtmi.task_monitor_id = cmtrm.id-->
  137. <!-- WHERE 1 = 1-->
  138. <!-- AND cmtrm.video_channel = #{videoId}-->
  139. <!-- and cmrt.id = #{taskId}-->
  140. <!-- AND cmtmi.situation IS NOT NULL-->
  141. <!-- GROUP BY cmtmi.situation-->
  142. <!-- </select>-->
  143. <insert id="insertSysDevice" parameterType="com.xunmei.system.api.domain.SysDevice">
  144. insert into sys_device
  145. <trim prefix="(" suffix=")" suffixOverrides=",">
  146. <if test="id != null">
  147. id,
  148. </if>
  149. <if test="orgId != null">
  150. org_id,
  151. </if>
  152. <if test="orgName != null">
  153. org_name,
  154. </if>
  155. <if test="deviceName != null">
  156. device_name,
  157. </if>
  158. <if test="assetType != null">
  159. asset_type,
  160. </if>
  161. <if test="deviceType != null">
  162. device_type,
  163. </if>
  164. <if test="deviceBrand != null">
  165. device_brand,
  166. </if>
  167. <if test="checkTime != null">
  168. check_time,
  169. </if>
  170. <if test="maintenanceTerm != null">
  171. maintenance_term,
  172. </if>
  173. <if test="createTime != null">
  174. create_time,
  175. </if>
  176. <if test="updateTime != null">
  177. update_time,
  178. </if>
  179. <if test="createBy != null">
  180. create_by,
  181. </if>
  182. <if test="updateBy != null">
  183. update_by,
  184. </if>
  185. <if test="delFlag != null">
  186. del_flag,
  187. </if>
  188. <if test="hostId != null">
  189. host_id,
  190. </if>
  191. <if test="channel != null">
  192. channel,
  193. </if>
  194. </trim>
  195. <trim prefix="values (" suffix=")" suffixOverrides=",">
  196. <if test="id != null">
  197. #{id},
  198. </if>
  199. <if test="orgId != null">
  200. #{orgId},
  201. </if>
  202. <if test="orgName != null">
  203. #{orgName},
  204. </if>
  205. <if test="deviceName != null">
  206. #{deviceName},
  207. </if>
  208. <if test="assetType != null">
  209. #{assetType},
  210. </if>
  211. <if test="deviceType != null">
  212. #{deviceType},
  213. </if>
  214. <if test="deviceBrand != null">
  215. #{deviceBrand},
  216. </if>
  217. <if test="checkTime != null">
  218. #{checkTime},
  219. </if>
  220. <if test="maintenanceTerm != null">
  221. #{maintenanceTerm},
  222. </if>
  223. <if test="createTime != null">
  224. #{createTime},
  225. </if>
  226. <if test="updateTime != null">
  227. #{updateTime},
  228. </if>
  229. <if test="createBy != null">
  230. #{createBy},
  231. </if>
  232. <if test="updateBy != null">
  233. #{updateBy},
  234. </if>
  235. <if test="delFlag != null">
  236. #{delFlag},
  237. </if>
  238. <if test="hostId != null">
  239. #{hostId},
  240. </if>
  241. <if test="channel != null">
  242. #{channel},
  243. </if>
  244. </trim>
  245. </insert>
  246. <update id="updateSysDevice" parameterType="com.xunmei.system.api.domain.SysDevice">
  247. update sys_device
  248. <trim prefix="SET" suffixOverrides=",">
  249. <if test="orgId != null">
  250. org_id =
  251. #{orgId},
  252. </if>
  253. <if test="orgName != null">
  254. org_name =
  255. #{orgName},
  256. </if>
  257. <if test="deviceName != null">
  258. device_name =
  259. #{deviceName},
  260. </if>
  261. <if test="assetType != null">
  262. asset_type =
  263. #{assetType},
  264. </if>
  265. <if test="deviceType != null">
  266. device_type =
  267. #{deviceType},
  268. </if>
  269. <if test="deviceBrand != null">
  270. device_brand =
  271. #{deviceBrand},
  272. </if>
  273. <if test="checkTime != null">
  274. check_time =
  275. #{checkTime},
  276. </if>
  277. <if test="maintenanceTerm != null">
  278. maintenance_term =
  279. #{maintenanceTerm},
  280. </if>
  281. <if test="createTime != null">
  282. create_time =
  283. #{createTime},
  284. </if>
  285. <if test="updateTime != null">
  286. update_time =
  287. #{updateTime},
  288. </if>
  289. <if test="createBy != null">
  290. create_by =
  291. #{createBy},
  292. </if>
  293. <if test="updateBy != null">
  294. update_by =
  295. #{updateBy},
  296. </if>
  297. <if test="delFlag != null">
  298. del_flag =
  299. #{delFlag},
  300. </if>
  301. <if test="hostId != null">
  302. host_id =
  303. #{hostId},
  304. </if>
  305. <if test="channel != null">
  306. channel =
  307. #{channel},
  308. </if>
  309. </trim>
  310. where id = #{id}
  311. </update>
  312. <delete id="deleteSysDeviceById" parameterType="Long">
  313. delete
  314. from sys_device
  315. where id = #{id}
  316. </delete>
  317. <delete id="deleteSysDeviceByIds" parameterType="String">
  318. delete from sys_device where id in
  319. <foreach item="id" collection="array" open="(" separator="," close=")">
  320. #{id}
  321. </foreach>
  322. </delete>
  323. </mapper>