KwsProjectMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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="remark" jdbcType="VARCHAR" property="remark"/>
  21. <result column="status" jdbcType="TINYINT" property="status"/>
  22. <result column="create_by" jdbcType="BIGINT" property="createBy"/>
  23. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  24. <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
  25. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  26. <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
  27. </resultMap>
  28. <sql id="Base_Column_List">
  29. <!--@mbg.generated-->
  30. id,
  31. `name`,
  32. mountain_id,
  33. mountain_name,
  34. platform_name,
  35. platform_address,
  36. design_company,
  37. design_contacts,
  38. design_phone,
  39. build_company,
  40. build_contacts,
  41. build_phone,
  42. remark,
  43. `status`,
  44. create_by,
  45. create_time,
  46. update_by,
  47. update_time,
  48. del_flag,
  49. company_id
  50. </sql>
  51. <select id="selectByProjectParam" resultType="com.sckw.slope.detection.model.vo.ProjectVo">
  52. select
  53. <include refid="Base_Column_List">
  54. </include>
  55. from kws_project
  56. where del_flag = 0
  57. <if test="companyId != null and companyId != ''">
  58. and company_id = #{companyId,jdbcType=VARCHAR}
  59. </if>
  60. <if test="projectQueryDto.name != null and projectQueryDto.name != ''">
  61. and name like concat('%', #{projectQueryDto.name}, '%')
  62. </if>
  63. </select>
  64. <select id="selectDeviceByProjectId" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  65. SELECT a.id AS projectId,
  66. a.`name` AS projectName,
  67. c.id AS id,
  68. c.`name` AS NAME,
  69. d.device_type AS deviceType,
  70. d.manufacturer AS manufacturer,
  71. d.`name` AS modelName,
  72. c.create_time AS createTime
  73. FROM kws_project a
  74. LEFT JOIN kws_project_device b ON a.id = b.project_id
  75. LEFT JOIN kws_device c ON b.device_id = c.id
  76. LEFT JOIN kws_device_model d ON c.model_id = d.id
  77. WHERE a.del_flag = 0
  78. AND b.del_flag = 0
  79. AND c.del_flag = 0
  80. AND d.del_flag = 0
  81. AND a.id = #{projectId,jdbcType=BIGINT}
  82. </select>
  83. <select id="selectDeviceList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  84. SELECT a.id AS projectId,
  85. a.`name` AS projectName,
  86. c.id AS id,
  87. c.`name` AS NAME,
  88. d.device_type AS deviceType,
  89. d.manufacturer AS manufacturer,
  90. d.`name` AS modelName,
  91. c.create_time AS createTime
  92. FROM kws_project a
  93. LEFT JOIN kws_project_device b ON a.id = b.project_id
  94. LEFT JOIN kws_device c ON b.device_id = c.id
  95. LEFT JOIN kws_device_model d ON c.model_id = d.id
  96. WHERE a.del_flag = 0
  97. AND b.del_flag = 0
  98. AND c.del_flag = 0
  99. AND d.del_flag = 0
  100. <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
  101. AND a.id = #{deviceQuery.projectId}
  102. </if>
  103. <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
  104. and d.manufacturer like concat('%', #{deviceQuery.manufacturer}, '%')
  105. </if>
  106. <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
  107. and d.device_type like concat('%', #{deviceQuery.deviceType}, '%')
  108. </if>
  109. <if test="deviceQuery.name != null and deviceQuery.name != ''">
  110. and d.name like concat('%', #{deviceQuery.name}, '%')
  111. </if>
  112. </select>
  113. <select id="selectDeviceNotBindList" resultType="com.sckw.slope.detection.model.vo.ProjectDeviceVO">
  114. SELECT a.id AS projectId,
  115. a.`name` AS projectName,
  116. c.id AS id,
  117. c.`status` as status,
  118. c.`name` AS NAME,
  119. d.device_type AS deviceType,
  120. d.manufacturer AS manufacturer,
  121. d.`name` AS modelName,
  122. c.create_time AS createTime
  123. FROM kws_project a
  124. LEFT JOIN kws_device c ON a.mountain_id = c.mountain_id
  125. LEFT JOIN kws_device_model d ON c.model_id = d.id
  126. WHERE a.del_flag = 0
  127. AND c.del_flag = 0
  128. AND d.del_flag = 0
  129. AND c.id NOT in (SELECT DISTINCT a.relate_device_id
  130. FROM kws_device_relation a
  131. LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
  132. AND c.id NOT in (SELECT DISTINCT a.device_id
  133. FROM kws_device_relation a
  134. LEFT JOIN kws_project b ON a.mountain_id = b.mountain_id)
  135. <if test="deviceQuery.projectId != null and deviceQuery.projectId != ''">
  136. AND a.id = #{deviceQuery.projectId}
  137. </if>
  138. <if test="deviceQuery.manufacturer != null and deviceQuery.manufacturer != ''">
  139. and d.manufacturer like concat('%', #{deviceQuery.manufacturer}, '%')
  140. </if>
  141. <if test="deviceQuery.deviceType != null and deviceQuery.deviceType != ''">
  142. and d.device_type like concat('%', #{deviceQuery.deviceType}, '%')
  143. </if>
  144. <if test="deviceQuery.name != null and deviceQuery.name != ''">
  145. and d.name like concat('%', #{deviceQuery.name}, '%')
  146. </if>
  147. </select>
  148. </mapper>