ConfigMapper.xml 8.8 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.css.simulation.resource.model.mapper.ConfigMapper" >
  4. <resultMap id="ConfigVOMap" type="api.common.pojo.vo.model.ConfigVO">
  5. <id column="ID" property="id" jdbcType="VARCHAR" />
  6. </resultMap>
  7. <resultMap id="ConfigSensorVOMap" type="api.common.pojo.vo.model.ConfigSensorVO">
  8. <id column="ID" property="id" jdbcType="VARCHAR" />
  9. </resultMap>
  10. <select id="getConfigPageList" parameterType="api.common.pojo.param.model.ConfigPageParam" resultMap="ConfigVOMap">
  11. select
  12. c.id,
  13. c.config_code,
  14. c.config_name,
  15. c.description as configDescription,
  16. v.id as vehicleId,
  17. v.vehicle_name,
  18. v.description as vehicleDescription,
  19. c.share
  20. from model_config c
  21. LEFT JOIN model_vehicle v on c.vehicle_id = v.id
  22. WHERE c.is_deleted = '0' and c.share = #{share,jdbcType=VARCHAR}
  23. <if test="configCode != null and configCode != ''">
  24. and c.config_code like CONCAT('%',#{configCode,jdbcType=VARCHAR},'%')
  25. </if>
  26. <if test="configName != null and configName != ''">
  27. and c.config_name like CONCAT('%',#{configName,jdbcType=VARCHAR},'%')
  28. </if>
  29. <if test="configDescription != null and configDescription != ''">
  30. and c.description like CONCAT('%',#{configDescription,jdbcType=VARCHAR},'%')
  31. </if>
  32. <if test="vehicleName != null and vehicleName != ''">
  33. and v.vehicle_name like CONCAT('%',#{vehicleName,jdbcType=VARCHAR},'%')
  34. </if>
  35. <if test="vehicleDescription != null and vehicleDescription != ''">
  36. and v.description like CONCAT('%',#{vehicleDescription,jdbcType=VARCHAR},'%')
  37. </if>
  38. <if test="share != null and share != ''">
  39. and c.share = #{share,jdbcType=VARCHAR}
  40. </if>
  41. <if test="createUserId != null and createUserId != ''">
  42. and c.create_user_id = #{createUserId,jdbcType=VARCHAR}
  43. </if>
  44. order by c.create_time desc
  45. </select>
  46. <select id="getConfigInfo" parameterType="api.common.pojo.vo.model.ConfigVO" resultMap="ConfigVOMap">
  47. SELECT
  48. c.id,
  49. c.config_code,
  50. c.config_name,
  51. c.description as configDescription,
  52. c.vehicle_id,
  53. c.share,
  54. v.vehicle_name,
  55. v.description as vehicleDescription,
  56. v.vehicle_top_view
  57. FROM model_config c
  58. LEFT JOIN model_vehicle v ON v.id = c.vehicle_id
  59. WHERE c.is_deleted = '0'
  60. and c.id = #{id,jdbcType=VARCHAR}
  61. </select>
  62. <select id="getConfigSensors" parameterType="api.common.pojo.vo.model.ConfigVO" resultMap="ConfigSensorVOMap">
  63. <!--摄像头-->
  64. SELECT
  65. r.id,r.config_id,r.sensor_id,
  66. s.sensor_name, s.description as sensorDescription,
  67. r.sensor_type,
  68. r.sensor_x, r.sensor_y, r.sensor_z, r.sensor_h, r.sensor_p, r.sensor_r, r.sensor_port
  69. FROM relation_config_sensor r
  70. INNER JOIN model_sensor_camera s ON r.sensor_id = s.id
  71. WHERE r.is_deleted = '0' and r.config_id = #{id,jdbcType=VARCHAR}
  72. UNION
  73. <!--完美传感器-->
  74. SELECT
  75. r.id,r.config_id,r.sensor_id,
  76. s.sensor_name, s.description as sensorDescription,
  77. r.sensor_type,
  78. r.sensor_x, r.sensor_y, r.sensor_z, r.sensor_h, r.sensor_p, r.sensor_r, r.sensor_port
  79. FROM relation_config_sensor r
  80. INNER JOIN model_sensor_ogt s ON r.sensor_id = s.id
  81. WHERE r.is_deleted = '0' and r.config_id = #{id,jdbcType=VARCHAR}
  82. UNION
  83. <!--激光雷达-->
  84. SELECT
  85. r.id,r.config_id,r.sensor_id,
  86. s.sensor_name, s.description as sensorDescription,
  87. r.sensor_type,
  88. r.sensor_x, r.sensor_y, r.sensor_z, r.sensor_h, r.sensor_p, r.sensor_r, r.sensor_port
  89. FROM relation_config_sensor r
  90. INNER JOIN model_sensor_lidar s ON r.sensor_id = s.id
  91. WHERE r.is_deleted = '0' and r.config_id = #{id,jdbcType=VARCHAR}
  92. UNION
  93. <!--GPS-->
  94. SELECT
  95. r.id,r.config_id,r.sensor_id,
  96. s.sensor_name, s.description as sensorDescription,
  97. r.sensor_type,
  98. r.sensor_x, r.sensor_y, r.sensor_z, r.sensor_h, r.sensor_p, r.sensor_r, r.sensor_port
  99. FROM relation_config_sensor r
  100. INNER JOIN model_sensor_gps s ON r.sensor_id = s.id
  101. WHERE r.is_deleted = '0' and r.config_id = #{id,jdbcType=VARCHAR}
  102. </select>
  103. <select id="checkConfigName" parameterType="api.common.pojo.po.model.ConfigPO" resultMap="ConfigVOMap">
  104. select
  105. id
  106. from model_config
  107. where is_deleted = '0'
  108. and config_name = #{configName,jdbcType=VARCHAR}
  109. <if test="share != null and share != ''">
  110. and share = #{share,jdbcType=VARCHAR}
  111. </if>
  112. <if test="createUserId != null and createUserId != ''">
  113. and create_user_id = #{createUserId,jdbcType=VARCHAR}
  114. and id &lt;&gt; #{id,jdbcType=VARCHAR}
  115. </if>
  116. </select>
  117. <insert id="insertConfig" parameterType="api.common.pojo.po.model.ConfigPO">
  118. insert into model_config(
  119. id,
  120. config_code,
  121. config_name,
  122. description,
  123. vehicle_id,
  124. share,
  125. create_time,
  126. modify_time,
  127. create_user_id,
  128. modify_user_id,
  129. is_deleted
  130. )
  131. values(
  132. #{id,jdbcType=VARCHAR},
  133. #{configCode,jdbcType=VARCHAR},
  134. #{configName,jdbcType=VARCHAR},
  135. #{description,jdbcType=VARCHAR},
  136. #{vehicleId,jdbcType=VARCHAR},
  137. #{share,jdbcType=VARCHAR},
  138. #{createTime,jdbcType=TIMESTAMP},
  139. #{modifyTime,jdbcType=TIMESTAMP},
  140. #{createUserId,jdbcType=VARCHAR},
  141. #{modifyUserId,jdbcType=VARCHAR},
  142. #{isDeleted,jdbcType=VARCHAR}
  143. )
  144. </insert>
  145. <update id="updateConfig" parameterType="api.common.pojo.po.model.ConfigPO">
  146. update model_config set
  147. config_name = #{configName,jdbcType=VARCHAR},
  148. description = #{description,jdbcType=VARCHAR},
  149. vehicle_id = #{vehicleId,jdbcType=VARCHAR},
  150. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  151. modify_user_id = #{modifyUserId,jdbcType=VARCHAR}
  152. where id = #{id,jdbcType=VARCHAR}
  153. </update>
  154. <update id="delConfigSensors" parameterType="api.common.pojo.po.model.ConfigPO">
  155. update relation_config_sensor set
  156. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  157. modify_user_id = #{modifyUserId,jdbcType=VARCHAR},
  158. is_deleted = '1'
  159. where config_id = #{id,jdbcType=VARCHAR}
  160. </update>
  161. <insert id="insertConfigSensors">
  162. insert into relation_config_sensor(
  163. id,
  164. config_id,
  165. sensor_id,
  166. sensor_type,
  167. sensor_x,
  168. sensor_y,
  169. sensor_z,
  170. sensor_h,
  171. sensor_p,
  172. sensor_r,
  173. sensor_port,
  174. create_time,
  175. modify_time,
  176. create_user_id,
  177. modify_user_id,
  178. is_deleted
  179. ) values
  180. <foreach collection="list" item="item" separator=",">
  181. (
  182. #{item.id,jdbcType=VARCHAR},
  183. #{item.configId,jdbcType=VARCHAR},
  184. #{item.sensorId,jdbcType=VARCHAR},
  185. #{item.sensorType,jdbcType=VARCHAR},
  186. #{item.sensorX,jdbcType=DECIMAL},
  187. #{item.sensorY,jdbcType=DECIMAL},
  188. #{item.sensorZ,jdbcType=DECIMAL},
  189. #{item.sensorH,jdbcType=DECIMAL},
  190. #{item.sensorP,jdbcType=DECIMAL},
  191. #{item.sensorR,jdbcType=DECIMAL},
  192. #{item.sensorPort,jdbcType=INTEGER},
  193. #{item.createTime,jdbcType=TIMESTAMP},
  194. #{item.modifyTime,jdbcType=TIMESTAMP},
  195. #{item.createUserId,jdbcType=VARCHAR},
  196. #{item.modifyUserId,jdbcType=VARCHAR},
  197. #{item.isDeleted,jdbcType=VARCHAR}
  198. )
  199. </foreach>
  200. </insert>
  201. <update id="delConfigById" parameterType="api.common.pojo.po.model.ConfigPO">
  202. update model_config set
  203. modify_time = #{modifyTime,jdbcType=TIMESTAMP},
  204. modify_user_id = #{modifyUserId,jdbcType=VARCHAR},
  205. is_deleted = #{isDeleted,jdbcType=VARCHAR}
  206. where id = #{id,jdbcType=VARCHAR}
  207. </update>
  208. <select id="getConfigTotal" parameterType="java.lang.String" resultType="java.lang.Integer">
  209. select COUNT(1) from model_config where is_deleted = '0' and share = '0' and create_user_id = #{createUserId,jdbcType=VARCHAR}
  210. </select>
  211. </mapper>