SysDeviceMapper.xml 9.8 KB

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