KwsDeviceModelPartMapper.xml 7.7 KB

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