KwsProjectMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.KwsProjectMapper">
  4. <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsProject">
  5. <!--@mbg.generated-->
  6. <!--@Table kws_project-->
  7. <id column="id" jdbcType="BIGINT" property="id"/>
  8. <result column="name" jdbcType="VARCHAR" property="name"/>
  9. <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
  10. <result column="company_id" jdbcType="VARCHAR" property="companyId"/>
  11. <result column="mountain_name" jdbcType="VARCHAR" property="mountainName"/>
  12. <result column="platform_name" jdbcType="VARCHAR" property="platformName"/>
  13. <result column="platform_address" jdbcType="VARCHAR" property="platformAddress"/>
  14. <result column="design_company" jdbcType="VARCHAR" property="designCompany"/>
  15. <result column="design_contacts" jdbcType="VARCHAR" property="designContacts"/>
  16. <result column="design_phone" jdbcType="VARCHAR" property="designPhone"/>
  17. <result column="build_company" jdbcType="VARCHAR" property="buildCompany"/>
  18. <result column="build_contacts" jdbcType="VARCHAR" property="buildContacts"/>
  19. <result column="build_phone" jdbcType="VARCHAR" property="buildPhone"/>
  20. <result column="project_type" jdbcType="VARCHAR" property="projectType"/>
  21. <result column="project_no" jdbcType="VARCHAR" property="projectNo"/>
  22. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  23. <result column="status" jdbcType="TINYINT" property="status"/>
  24. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  25. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  26. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  27. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  28. <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
  29. </resultMap>
  30. <sql id="Base_Column_List">
  31. <!--@mbg.generated-->
  32. id,
  33. `name`,
  34. mountain_id,
  35. project_type,
  36. project_no,
  37. mountain_name,
  38. platform_name,
  39. platform_address,
  40. design_company,
  41. design_contacts,
  42. design_phone,
  43. build_company,
  44. build_contacts,
  45. build_phone,
  46. remark,
  47. `status`,
  48. create_by,
  49. create_time,
  50. update_by,
  51. update_time,
  52. del_flag,
  53. company_id
  54. </sql>
  55. <select id="selectByProjectParam" resultType="com.sckw.slope.detection.model.vo.ProjectVo">
  56. select
  57. <include refid="Base_Column_List">
  58. </include>
  59. from kws_project
  60. where del_flag = 0
  61. <if test="companyId != null and companyId != ''">
  62. and company_id = #{companyId,jdbcType=VARCHAR}
  63. </if>
  64. <if test="projectQueryDto.name != null and projectQueryDto.name != ''">
  65. and name like concat('%', #{projectQueryDto.name}, '%')
  66. </if>
  67. order by create_time desc
  68. </select>
  69. <select id="selectDeviceByProjectId" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  70. SELECT a.id AS projectId,
  71. a.`name` AS projectName,
  72. c.id AS id,
  73. c.`name` AS NAME,
  74. d.device_type AS deviceType,
  75. d.manufacturer AS manufacturer,
  76. d.`name` AS modelName,
  77. c.create_time AS createTime,
  78. e.part_name as partName
  79. FROM kws_project a
  80. LEFT JOIN kws_project_device b
  81. ON a.id = b.project_id and a.mountain_id = b.mountain_id
  82. LEFT JOIN kws_device c ON b.device_id = c.id and c.mountain_id = b.mountain_id
  83. LEFT JOIN kws_device_model d ON c.model_id = d.id and d.mountain_id = c.mountain_id
  84. LEFT JOIN kws_device_model_part e ON e.device_model_id = d.id and d.mountain_id = c.mountain_id
  85. WHERE a.del_flag = 0
  86. AND b.del_flag = 0
  87. AND c.del_flag = 0
  88. AND d.del_flag = 0
  89. <if test="mountainId != null and mountainId != ''">
  90. AND c.mountain_id = #{mountainId}
  91. </if>
  92. <if test="projectId != null and projectId != ''">
  93. AND a.id = #{projectId}
  94. </if>
  95. <if test="deviceId != null and deviceId != ''">
  96. AND c.id = #{deviceId}
  97. </if>
  98. <if test="type != null and type != ''">
  99. and e.part_name = #{type}
  100. </if>
  101. </select>
  102. <select id="selectDeviceList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  103. SELECT DISTINCT e.id AS deviceRelationId,
  104. e.device_id AS parentId,
  105. a.id AS projectId,
  106. a.`name` AS projectName,
  107. c.id AS id,
  108. c.`name` AS NAME,
  109. c.alias AS alias,
  110. d.device_type AS deviceType,
  111. d.manufacturer AS manufacturer,
  112. d.`name` AS deviceModelName,
  113. c.create_time AS createTime
  114. FROM kws_project a
  115. LEFT JOIN kws_project_device b
  116. ON a.id = b.project_id
  117. LEFT JOIN kws_device c ON b.device_id = c.id
  118. LEFT JOIN kws_device_model d ON c.model_id = d.id
  119. LEFT JOIN kws_device_relation e ON e.relate_device_id = c.id
  120. WHERE a.del_flag = 0
  121. AND b.del_flag = 0
  122. AND c.del_flag = 0
  123. AND d.del_flag = 0
  124. AND e.del_flag = 0
  125. <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
  126. AND a.id = #{deviceQuery.projectId}
  127. </if>
  128. <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
  129. and d.manufacturer like concat('%', #{deviceQuery.manufacturer}, '%')
  130. </if>
  131. <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
  132. and d.device_type like concat('%', #{deviceQuery.deviceType}, '%')
  133. </if>
  134. <if test="deviceQuery.deviceModel != null and deviceQuery.deviceModel != ''">
  135. and d.name like concat('%', #{deviceQuery.deviceModel}, '%')
  136. </if>
  137. <if test="deviceQuery.name != null and deviceQuery.name != ''">
  138. and c.name like concat('%', #{deviceQuery.name}, '%')
  139. </if>
  140. order by b.create_time desc
  141. </select>
  142. <select id="selectDeviceNotBindList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  143. SELECT a.id AS projectId,
  144. a.`name` AS projectName,
  145. c.id AS id,
  146. c.`status` as status,
  147. c.`name` AS NAME,
  148. d.device_type AS deviceType,
  149. d.manufacturer AS manufacturer,
  150. d.`name` AS deviceModelName,
  151. c.create_time AS createTime
  152. FROM kws_project a
  153. LEFT JOIN kws_device c ON a.mountain_id = c.mountain_id
  154. LEFT JOIN kws_device_model d ON c.model_id = d.id
  155. WHERE a.del_flag = 0
  156. AND c.del_flag = 0
  157. AND d.del_flag = 0
  158. AND c.relevance_level = 0
  159. AND c.id NOT in (SELECT DISTINCT a.relate_device_id
  160. FROM kws_device_relation a
  161. LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
  162. AND c.id NOT in (SELECT DISTINCT a.device_id
  163. FROM kws_device_relation a
  164. LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
  165. <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
  166. AND a.id = #{deviceQuery.projectId}
  167. </if>
  168. <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
  169. and d.manufacturer like concat('%', #{deviceQuery.manufacturer}, '%')
  170. </if>
  171. <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
  172. and d.device_type like concat('%', #{deviceQuery.deviceType}, '%')
  173. </if>
  174. <if test="deviceQuery.deviceModel != null and deviceQuery.deviceModel != ''">
  175. and d.name like concat('%', #{deviceQuery.deviceModel}, '%')
  176. </if>
  177. <if test="deviceQuery.name != null and deviceQuery.name != ''">
  178. and c.name like concat('%', #{deviceQuery.name}, '%')
  179. </if>
  180. </select>
  181. <select id="selectNotBindDeviceList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  182. SELECT a.id AS id,
  183. a.`status` AS STATUS,
  184. a.`name` AS NAME,
  185. a.create_time AS createTime,
  186. d.device_type AS deviceType,
  187. d.manufacturer AS manufacturer,
  188. d.`name` AS deviceModelName
  189. FROM kws_device a
  190. LEFT JOIN kws_device_model d ON d.id = a.model_id
  191. WHERE a.mountain_id = d.mountain_id
  192. and a.del_flag = 0
  193. AND a.del_flag = 0
  194. AND d.del_flag = 0
  195. AND a.relevance_level = 0
  196. <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
  197. and d.manufacturer like concat('%'
  198. , #{deviceQuery.manufacturer}
  199. , '%')
  200. </if>
  201. <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
  202. and d.device_type like concat('%'
  203. , #{deviceQuery.deviceType}
  204. , '%')
  205. </if>
  206. <if test="deviceQuery.deviceModel != null and deviceQuery.deviceModel != ''">
  207. and d.name like concat('%'
  208. , #{deviceQuery.deviceModel}
  209. , '%')
  210. </if>
  211. <if test="deviceQuery.name != null and deviceQuery.name != ''">
  212. and a.name like concat('%'
  213. , #{deviceQuery.name}
  214. , '%')
  215. </if>
  216. </select>
  217. <select id="selectListData" resultMap="BaseResultMap">
  218. select *
  219. from kws_project
  220. <where>
  221. <if test="ids != null and ids.size() > 0">
  222. and id in
  223. <foreach collection="ids" close=")" open="(" item="item" separator=",">
  224. #{item}
  225. </foreach>
  226. </if>
  227. <if test="delFlag != null">
  228. and del_flag = #{delFlag}
  229. </if>
  230. </where>
  231. </select>
  232. <select id="selectListByType" resultMap="BaseResultMap">
  233. select
  234. <include refid="Base_Column_List">
  235. </include>
  236. from kws_project
  237. <where>
  238. <if test="projectType != null and projectType != ''">
  239. </if>
  240. and project_type like concat(#{projectType}, '%')
  241. </where>
  242. </select>
  243. </mapper>