KwsDeviceModelPartMapper.xml 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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.sckw.slope.detection.dao.mysql.KwsDeviceModelPartMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsDeviceModelPart">
  5. <!--@mbg.generated-->
  6. <!--@Table kws_device_model_part-->
  7. <id column="id" jdbcType="BIGINT" property="id" />
  8. <result column="device_model_id" jdbcType="BIGINT" property="deviceModelId" />
  9. <result column="part_name" jdbcType="VARCHAR" property="partName" />
  10. <result column="status" jdbcType="TINYINT" property="status" />
  11. <result column="create_by" jdbcType="BIGINT" property="createBy" />
  12. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  13. <result column="update_by" jdbcType="BIGINT" property="updateBy" />
  14. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  15. <result column="del_flag" jdbcType="TINYINT" property="delFlag" />
  16. </resultMap>
  17. <sql id="Base_Column_List">
  18. <!--@mbg.generated-->
  19. id, device_model_id, part_name, `status`, create_by, create_time, update_by, update_time,
  20. del_flag
  21. </sql>
  22. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  23. <!--@mbg.generated-->
  24. select
  25. <include refid="Base_Column_List" />
  26. from kws_device_model_part
  27. where id = #{id,jdbcType=BIGINT}
  28. </select>
  29. <select id="selectByModelId" parameterType="java.lang.Long" resultType="com.sckw.slope.detection.model.vo.DevicePartModelVo">
  30. <!--@mbg.generated-->
  31. select
  32. <include refid="Base_Column_List" />
  33. from kws_device_model_part
  34. where del_flag=0
  35. <if test="deviceModelId != null">
  36. and device_model_id = #{deviceModelId,jdbcType=BIGINT}
  37. </if>
  38. order by part_name
  39. </select>
  40. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  41. <!--@mbg.generated-->
  42. delete from kws_device_model_part
  43. where id = #{id,jdbcType=BIGINT}
  44. </delete>
  45. <insert id="insert" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceModelPart">
  46. <!--@mbg.generated-->
  47. insert into kws_device_model_part (id, device_model_id, part_name,
  48. `status`, create_by, create_time,
  49. update_by, update_time, del_flag
  50. )
  51. values (#{id,jdbcType=BIGINT}, #{deviceModelId,jdbcType=BIGINT}, #{partName,jdbcType=VARCHAR},
  52. #{status,jdbcType=TINYINT}, #{createBy,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
  53. #{updateBy,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{delFlag,jdbcType=TINYINT}
  54. )
  55. </insert>
  56. <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceModelPart">
  57. <!--@mbg.generated-->
  58. insert into kws_device_model_part
  59. <trim prefix="(" suffix=")" suffixOverrides=",">
  60. <if test="id != null">
  61. id,
  62. </if>
  63. <if test="deviceModelId != null">
  64. device_model_id,
  65. </if>
  66. <if test="partName != null">
  67. part_name,
  68. </if>
  69. <if test="status != null">
  70. `status`,
  71. </if>
  72. <if test="createBy != null">
  73. create_by,
  74. </if>
  75. <if test="createTime != null">
  76. create_time,
  77. </if>
  78. <if test="updateBy != null">
  79. update_by,
  80. </if>
  81. <if test="updateTime != null">
  82. update_time,
  83. </if>
  84. <if test="delFlag != null">
  85. del_flag,
  86. </if>
  87. </trim>
  88. <trim prefix="values (" suffix=")" suffixOverrides=",">
  89. <if test="id != null">
  90. #{id,jdbcType=BIGINT},
  91. </if>
  92. <if test="deviceModelId != null">
  93. #{deviceModelId,jdbcType=BIGINT},
  94. </if>
  95. <if test="partName != null">
  96. #{partName,jdbcType=VARCHAR},
  97. </if>
  98. <if test="status != null">
  99. #{status,jdbcType=TINYINT},
  100. </if>
  101. <if test="createBy != null">
  102. #{createBy,jdbcType=BIGINT},
  103. </if>
  104. <if test="createTime != null">
  105. #{createTime,jdbcType=TIMESTAMP},
  106. </if>
  107. <if test="updateBy != null">
  108. #{updateBy,jdbcType=BIGINT},
  109. </if>
  110. <if test="updateTime != null">
  111. #{updateTime,jdbcType=TIMESTAMP},
  112. </if>
  113. <if test="delFlag != null">
  114. #{delFlag,jdbcType=TINYINT},
  115. </if>
  116. </trim>
  117. </insert>
  118. <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceModelPart">
  119. <!--@mbg.generated-->
  120. update kws_device_model_part
  121. <set>
  122. <if test="deviceModelId != null">
  123. device_model_id = #{deviceModelId,jdbcType=BIGINT},
  124. </if>
  125. <if test="partName != null">
  126. part_name = #{partName,jdbcType=VARCHAR},
  127. </if>
  128. <if test="status != null">
  129. `status` = #{status,jdbcType=TINYINT},
  130. </if>
  131. <if test="createBy != null">
  132. create_by = #{createBy,jdbcType=BIGINT},
  133. </if>
  134. <if test="createTime != null">
  135. create_time = #{createTime,jdbcType=TIMESTAMP},
  136. </if>
  137. <if test="updateBy != null">
  138. update_by = #{updateBy,jdbcType=BIGINT},
  139. </if>
  140. <if test="updateTime != null">
  141. update_time = #{updateTime,jdbcType=TIMESTAMP},
  142. </if>
  143. <if test="delFlag != null">
  144. del_flag = #{delFlag,jdbcType=TINYINT},
  145. </if>
  146. </set>
  147. where id = #{id,jdbcType=BIGINT}
  148. </update>
  149. <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsDeviceModelPart">
  150. <!--@mbg.generated-->
  151. update kws_device_model_part
  152. set device_model_id = #{deviceModelId,jdbcType=BIGINT},
  153. part_name = #{partName,jdbcType=VARCHAR},
  154. `status` = #{status,jdbcType=TINYINT},
  155. create_by = #{createBy,jdbcType=BIGINT},
  156. create_time = #{createTime,jdbcType=TIMESTAMP},
  157. update_by = #{updateBy,jdbcType=BIGINT},
  158. update_time = #{updateTime,jdbcType=TIMESTAMP},
  159. del_flag = #{delFlag,jdbcType=TINYINT}
  160. where id = #{id,jdbcType=BIGINT}
  161. </update>
  162. <select id="selectElementList" resultType="com.sckw.slope.detection.model.dto.DeviceElementDTO">
  163. SELECT b.id as deviceId,
  164. b.name,
  165. b.alias,
  166. d.device_model_id as deviceModelId,
  167. d.part_name as element
  168. FROM kws_project_device a
  169. LEFT JOIN kws_device b ON a.device_id = b.id
  170. LEFT JOIN kws_device_model c ON b.model_id = c.id
  171. LEFT JOIN kws_device_model_part d ON c.id = d.device_model_id
  172. WHERE a.del_flag = 0
  173. and b.del_flag = 0
  174. and c.del_flag = 0
  175. and d.del_flag = 0
  176. <if test="status != null and status.size() > 0">
  177. and b.status in
  178. <foreach collection="status" separator="," open="(" close=")" item="status">
  179. #{status}
  180. </foreach>
  181. </if>
  182. <if test="mountainId != null and mountainId != ''">
  183. and a.mountain_id = #{mountainId}
  184. </if>
  185. <if test="projectId != null and projectId != ''">
  186. and a.project_id = #{projectId}
  187. </if>
  188. <if test="deviceId != null and deviceId != ''">
  189. and b.id = #{deviceId}
  190. </if>
  191. </select>
  192. <select id="selectElementAllList" resultType="com.sckw.slope.detection.model.dto.DeviceElementDTO">
  193. SELECT a.id as deviceId,
  194. b.name,
  195. b.alias,
  196. e.phones as phones,
  197. d.device_model_id as deviceModelId,
  198. d.part_name as element,
  199. e.integration_id as integrationElement,
  200. e.update_name as updateName,
  201. e.update_time as updatTime,
  202. FROM kws_project_device a
  203. LEFT JOIN kws_device b ON a.device_id = b.id
  204. LEFT JOIN kws_device_model c ON b.model_id = c.id
  205. LEFT JOIN kws_device_model_part d ON c.id = d.device_model_id
  206. LEFT JOIN kws_threshold e ON b.id = e.device_id
  207. WHERE a.del_flag = 0
  208. and b.del_flag = 0
  209. and c.del_flag = 0
  210. and d.del_flag = 0
  211. and e.del_flag = 0
  212. <if test="status != null and status.size() > 0">
  213. and b.status in
  214. <foreach collection="status" separator="," open="(" close=")" item="status">
  215. #{status}
  216. </foreach>
  217. </if>
  218. and a.mountain_id = #{mountainId}
  219. and a.project_id = #{projectId}
  220. </select>
  221. </mapper>