SysDeviceMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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="selectVideoChannelByMonitorId" resultType="java.lang.Long">
  90. SELECT video_channel
  91. FROM core_monitoring_task_registration_monitor
  92. WHERE task_registration_id = #{monitorId}
  93. </select>
  94. <select id="getAccessByVideo" resultType="com.xunmei.system.vo.area.AccessType">
  95. SELECT cmtmi.situation AS situation,
  96. COUNT(cmtrm.id) AS num
  97. FROM core_monitoring_retrieval_task cmrt
  98. LEFT JOIN core_monitoring_task_registration cmtr ON cmrt.id = cmtr.task_id
  99. LEFT JOIN core_monitoring_task_registration_monitor cmtrm ON cmtrm.task_registration_id = cmtr.id
  100. LEFT JOIN core_monitoring_task_monitor_info cmtmi ON cmtmi.task_monitor_id = cmtrm.id
  101. WHERE cmtmi.situation IS NOT NULL
  102. AND cmtrm.video_channel = #{videoId}
  103. and cmrt.id = #{taskId}
  104. GROUP BY cmtmi.situation
  105. </select>
  106. <select id="selectByHostNameAndOrgId" resultType="com.xunmei.system.api.domain.SysDevice">
  107. SELECT
  108. *
  109. FROM
  110. sys_device
  111. WHERE
  112. org_id = #{orgId}
  113. AND device_name = #{hostName}
  114. </select>
  115. <!-- <select id="getAccessByVideo" resultType="java.util.Map">-->
  116. <!-- SELECT cmtmi.situation AS situation,-->
  117. <!-- COUNT(cmtrm.id) AS num-->
  118. <!-- FROM core_monitoring_retrieval_task cmrt-->
  119. <!-- LEFT JOIN core_monitoring_task_registration cmtr ON cmrt.id = cmtr.task_id-->
  120. <!-- LEFT JOIN core_monitoring_task_registration_monitor cmtrm ON cmtrm.task_registration_id = cmtr.id-->
  121. <!-- LEFT JOIN core_monitoring_task_monitor_info cmtmi ON cmtmi.task_monitor_id = cmtrm.id-->
  122. <!-- WHERE 1 = 1-->
  123. <!-- AND cmtrm.video_channel = #{videoId}-->
  124. <!-- and cmrt.id = #{taskId}-->
  125. <!-- AND cmtmi.situation IS NOT NULL-->
  126. <!-- GROUP BY cmtmi.situation-->
  127. <!-- </select>-->
  128. <insert id="insertSysDevice" parameterType="com.xunmei.system.api.domain.SysDevice">
  129. insert into sys_device
  130. <trim prefix="(" suffix=")" suffixOverrides=",">
  131. <if test="id != null">id,
  132. </if>
  133. <if test="orgId != null">org_id,
  134. </if>
  135. <if test="orgName != null">org_name,
  136. </if>
  137. <if test="deviceName != null">device_name,
  138. </if>
  139. <if test="assetType != null">asset_type,
  140. </if>
  141. <if test="deviceType != null">device_type,
  142. </if>
  143. <if test="deviceBrand != null">device_brand,
  144. </if>
  145. <if test="checkTime != null">check_time,
  146. </if>
  147. <if test="maintenanceTerm != null">maintenance_term,
  148. </if>
  149. <if test="createTime != null">create_time,
  150. </if>
  151. <if test="updateTime != null">update_time,
  152. </if>
  153. <if test="createBy != null">create_by,
  154. </if>
  155. <if test="updateBy != null">update_by,
  156. </if>
  157. <if test="delFlag != null">del_flag,
  158. </if>
  159. <if test="hostId != null">host_id,
  160. </if>
  161. <if test="channel != null">channel,
  162. </if>
  163. </trim>
  164. <trim prefix="values (" suffix=")" suffixOverrides=",">
  165. <if test="id != null">#{id},
  166. </if>
  167. <if test="orgId != null">#{orgId},
  168. </if>
  169. <if test="orgName != null">#{orgName},
  170. </if>
  171. <if test="deviceName != null">#{deviceName},
  172. </if>
  173. <if test="assetType != null">#{assetType},
  174. </if>
  175. <if test="deviceType != null">#{deviceType},
  176. </if>
  177. <if test="deviceBrand != null">#{deviceBrand},
  178. </if>
  179. <if test="checkTime != null">#{checkTime},
  180. </if>
  181. <if test="maintenanceTerm != null">#{maintenanceTerm},
  182. </if>
  183. <if test="createTime != null">#{createTime},
  184. </if>
  185. <if test="updateTime != null">#{updateTime},
  186. </if>
  187. <if test="createBy != null">#{createBy},
  188. </if>
  189. <if test="updateBy != null">#{updateBy},
  190. </if>
  191. <if test="delFlag != null">#{delFlag},
  192. </if>
  193. <if test="hostId != null">#{hostId},
  194. </if>
  195. <if test="channel != null">#{channel},
  196. </if>
  197. </trim>
  198. </insert>
  199. <update id="updateSysDevice" parameterType="com.xunmei.system.api.domain.SysDevice">
  200. update sys_device
  201. <trim prefix="SET" suffixOverrides=",">
  202. <if test="orgId != null">org_id =
  203. #{orgId},
  204. </if>
  205. <if test="orgName != null">org_name =
  206. #{orgName},
  207. </if>
  208. <if test="deviceName != null">device_name =
  209. #{deviceName},
  210. </if>
  211. <if test="assetType != null">asset_type =
  212. #{assetType},
  213. </if>
  214. <if test="deviceType != null">device_type =
  215. #{deviceType},
  216. </if>
  217. <if test="deviceBrand != null">device_brand =
  218. #{deviceBrand},
  219. </if>
  220. <if test="checkTime != null">check_time =
  221. #{checkTime},
  222. </if>
  223. <if test="maintenanceTerm != null">maintenance_term =
  224. #{maintenanceTerm},
  225. </if>
  226. <if test="createTime != null">create_time =
  227. #{createTime},
  228. </if>
  229. <if test="updateTime != null">update_time =
  230. #{updateTime},
  231. </if>
  232. <if test="createBy != null">create_by =
  233. #{createBy},
  234. </if>
  235. <if test="updateBy != null">update_by =
  236. #{updateBy},
  237. </if>
  238. <if test="delFlag != null">del_flag =
  239. #{delFlag},
  240. </if>
  241. <if test="hostId != null">host_id =
  242. #{hostId},
  243. </if>
  244. <if test="channel != null">channel =
  245. #{channel},
  246. </if>
  247. </trim>
  248. where id = #{id}
  249. </update>
  250. <delete id="deleteSysDeviceById" parameterType="Long">
  251. delete
  252. from sys_device
  253. where id = #{id}
  254. </delete>
  255. <delete id="deleteSysDeviceByIds" parameterType="String">
  256. delete from sys_device where id in
  257. <foreach item="id" collection="array" open="(" separator="," close=")">
  258. #{id}
  259. </foreach>
  260. </delete>
  261. </mapper>