SystemScenePackageMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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.scene.mapper.SystemScenePackageMapper">
  4. <insert id="saveSystemScenePackage" parameterType="api.common.pojo.po.scene.SystemScenePackagePO">
  5. insert into simulation.system_scene_package
  6. (id,package_name,scene_describe,
  7. create_user_id,create_time,modify_user_id,modify_time,
  8. is_deleted)
  9. values (#{id,jdbcType=VARCHAR},#{packageName,jdbcType=VARCHAR},#{sceneDescribe},
  10. #{createUserId,jdbcType=VARCHAR},#{createTime},#{modifyUserId,jdbcType=VARCHAR},#{modifyTime},
  11. #{isDeleted,jdbcType=VARCHAR})
  12. </insert>
  13. <select id="querySystemScenePackageList" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  14. resultType="api.common.pojo.vo.scene.SystemScenePackageVO">
  15. select
  16. t.id,
  17. t.package_name,
  18. t.userCount,t.scene_describe,t.create_time,
  19. SUM(CASE WHEN s.scene_type = '1' THEN 1 ELSE 0 END) as zrCount,
  20. SUM(CASE WHEN s.scene_type = '2' THEN 1 ELSE 0 END) as bzCount,
  21. SUM(CASE WHEN s.scene_type = '3' THEN 1 ELSE 0 END) as jtCount,
  22. SUM(CASE WHEN s.scene_type = '4' THEN 1 ELSE 0 END) as fhCount,
  23. SUM(1) as totalCount
  24. FROM (
  25. select
  26. p.*,
  27. COUNT(u.id) as userCount
  28. FROM system_scene_package p
  29. left JOIN system_user_scene u on p.id = u.package_id and u.is_deleted = '0' and p.is_deleted = '0'
  30. <where>
  31. <if test="userId != null and userId != ''">
  32. and u.user_id = #{userId,jdbcType=VARCHAR}
  33. </if>
  34. </where>
  35. GROUP BY p.id
  36. ) t
  37. JOIN system_scene_package_sublist s on t.id = s.scene_and_package
  38. <where>
  39. s.is_deleted='0' and t.is_deleted='0'
  40. <if test="packageName != null and packageName != ''">
  41. and t.package_name like CONCAT('%',#{packageName,jdbcType=VARCHAR},'%')
  42. </if>
  43. <if test="yearMax != null and yearMax != ''">
  44. and #{yearMax,jdbcType=VARCHAR} &gt; t.create_time and #{yearMin,jdbcType=VARCHAR} &lt; t.create_time
  45. </if>
  46. <if test="packageNames != null and packageNames.length>0">
  47. and t.package_name in
  48. <foreach collection="packageNames" item="item" index="index"
  49. separator="," open="(" close=")">
  50. #{item}
  51. </foreach>
  52. </if>
  53. </where>
  54. GROUP BY t.id order by create_time desc
  55. </select>
  56. <select id="queryPackageByUserIdList" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  57. resultType="api.common.pojo.vo.scene.SystemScenePackageVO">
  58. select a.*,GROUP_CONCAT(DISTINCT(p.package_name)) as package_name from (select u.id user_id,s.is_deleted ,username userName, company,s.package_id,s.modify_time
  59. from system_user u left join system_user_scene s
  60. on u.id=s.user_id where u.is_deleted = '0' and u.role_code ='2') a
  61. left join system_scene_package p on a.package_id = p.id AND p.is_deleted = '0' and a.is_deleted='0'
  62. <where>
  63. 1=1
  64. <if test="userName != null and userName != ''">
  65. and a.userName like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
  66. </if>
  67. <if test="yearMax != null and yearMax != ''">
  68. and #{yearMax,jdbcType=VARCHAR} &gt; a.modify_time and #{yearMin,jdbcType=VARCHAR} &lt; a.modify_time
  69. </if>
  70. </where>
  71. GROUP BY a.user_id
  72. ORDER BY a.modify_time DESC
  73. </select>
  74. <select id="querySystemScenePackageById" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  75. resultType="api.common.pojo.po.scene.SystemScenePackagePO">
  76. select
  77. id,package_name,scene_describe,
  78. create_user_id,create_time,modify_user_id,modify_time
  79. from system_scene_package
  80. where id =#{id}
  81. </select>
  82. <select id="queryPackageByUserId" parameterType="api.common.pojo.param.scene.SystemScenePackageParam" resultType="java.util.Map">
  83. select a.userName,a.company,a.modify_time modifyTime,a.user_id userId,GROUP_CONCAT(DISTINCT(p.package_name)) as packageNames from (select u.id user_id,username userName, company,s.package_id,s.modify_time
  84. from system_user u left join system_user_scene s
  85. on u.id=s.user_id and u.is_deleted = '0' and s.is_deleted = '0') a
  86. left join system_scene_package p on a.package_id = p.id AND p.is_deleted = '0'
  87. <where>
  88. 1=1
  89. <if test="userName != null and userName != ''">
  90. and a.userName=#{userName}
  91. </if>
  92. </where>
  93. GROUP BY a.user_id
  94. ORDER BY a.modify_time DESC
  95. </select>
  96. <update id="deleteSystemScenePackage" parameterType="api.common.pojo.po.scene.SystemScenePackagePO">
  97. update simulation.system_scene_package
  98. <set>
  99. <if test="isDeleted != null and isDeleted!=''">
  100. is_deleted = #{isDeleted,jdbcType=VARCHAR},
  101. </if>
  102. <if test="modifyUserId != null and modifyUserId!=''">
  103. modify_user_id = #{modifyUserId,jdbcType=VARCHAR},
  104. </if>
  105. <if test="modifyTime != null">
  106. modify_time = #{modifyTime},
  107. </if>
  108. </set>
  109. where id = #{id,jdbcType=VARCHAR}
  110. </update>
  111. <update id="updateSystemScenePackage" parameterType="api.common.pojo.po.scene.SystemScenePackagePO">
  112. update simulation.system_scene_package
  113. set package_name=#{packageName},scene_describe=#{sceneDescribe},
  114. modify_time=#{modifyTime}, modify_user_id=#{modifyUserId}
  115. where id = #{id,jdbcType=VARCHAR}
  116. </update>
  117. <select id="querySceneNum" parameterType="java.lang.String" resultType="java.lang.Integer">
  118. SELECT SUM(num) FROM
  119. (SELECT
  120. COUNT(DISTINCT c.scene_name) AS num
  121. FROM system_user_scene a
  122. JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
  123. JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
  124. JOIN scene_natural d ON d.natural_name = c.scene_name AND d.is_deleted = '0'
  125. WHERE a.user_id = #{userId}
  126. UNION ALL
  127. SELECT
  128. COUNT(DISTINCT c.scene_name) AS num
  129. FROM system_user_scene a
  130. JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
  131. JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
  132. JOIN scene_accident d ON d.scene_name = c.scene_name AND d.is_deleted = '0'
  133. WHERE a.user_id = #{userId}
  134. UNION ALL
  135. SELECT
  136. COUNT(DISTINCT c.scene_name) AS num
  137. FROM system_user_scene a
  138. JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
  139. JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
  140. JOIN scene_standards_regulations d ON d.scene_name = c.scene_name AND d.is_deleted = '0'
  141. WHERE a.user_id = #{userId}
  142. UNION ALL
  143. SELECT
  144. COUNT(DISTINCT c.scene_name) AS num
  145. FROM system_user_scene a
  146. JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
  147. JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
  148. JOIN scene_general_template d ON d.scene_id = c.scene_name AND d.is_deleted = '0'
  149. WHERE a.user_id = #{userId}) AS t
  150. </select>
  151. <select id="queryScenePackageByPackageName" parameterType="api.common.pojo.po.scene.SystemScenePackageNewPO"
  152. resultType="java.lang.String">
  153. select
  154. id
  155. from system_scene_package
  156. <where>
  157. is_deleted = '0'
  158. <if test="packageName != null and packageName != ''">
  159. and package_name=#{packageName}
  160. </if>
  161. <if test="id != null and id != ''">
  162. and id!=#{id}
  163. </if>
  164. </where>
  165. </select>
  166. <select id="querySystemScenePackageListByTJ" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  167. resultType="java.util.Map">
  168. SELECT
  169. c.scene_type, COUNT(DISTINCT c.scene_name ) aaa
  170. FROM
  171. system_user_scene a
  172. LEFT JOIN system_scene_package b ON a.package_id = b.id AND b.is_deleted = '0'
  173. JOIN system_scene_package_sublist c ON b.id = c.scene_and_package AND c.is_deleted = '0'
  174. <where>
  175. a.is_deleted='0'
  176. <if test="packageNames != null and packageNames.length>0">
  177. and b.package_name in
  178. <foreach collection="packageNames" item="item" index="index"
  179. separator="," open="(" close=")">
  180. #{item}
  181. </foreach>
  182. </if>
  183. </where>
  184. group by c.scene_type
  185. </select>
  186. <select id="querySceneNaturalListByTJ" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  187. resultType="java.lang.String">
  188. select DISTINCT(a.scene_name) scene_name
  189. FROM system_scene_package_sublist a join scene_natural s on a.scene_name=s.natural_name join system_scene_package b on a.scene_and_package=b.id
  190. where
  191. a.is_deleted='0' and s.is_deleted='0' and b.is_deleted='0' and a.scene_type='1'
  192. and b.package_name in
  193. <foreach collection="packageNames" item="item" index="index"
  194. separator="," open="(" close=")">
  195. #{item}
  196. </foreach>
  197. </select>
  198. <select id="querySceneStandardsRegulationsListByTJ" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  199. resultType="java.lang.String">
  200. select DISTINCT(a.scene_name) scene_name
  201. FROM system_scene_package_sublist a join scene_standards_regulations s on a.scene_name=s.scene_name join system_scene_package b on a.scene_and_package=b.id
  202. where
  203. a.is_deleted='0' and s.is_deleted='0' and b.is_deleted='0' and a.scene_type='2'
  204. and b.package_name in
  205. <foreach collection="packageNames" item="item" index="index"
  206. separator="," open="(" close=")">
  207. #{item}
  208. </foreach>
  209. </select>
  210. <select id="querySceneAccidentListByTJ" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  211. resultType="java.lang.String">
  212. select DISTINCT(a.scene_name) scene_name
  213. FROM system_scene_package_sublist a join scene_accident s on a.scene_name=s.scene_name join system_scene_package b on a.scene_and_package=b.id
  214. where
  215. a.is_deleted='0' and s.is_deleted='0' and b.is_deleted='0' and a.scene_type='3'
  216. and b.package_name in
  217. <foreach collection="packageNames" item="item" index="index"
  218. separator="," open="(" close=")">
  219. #{item}
  220. </foreach>
  221. </select>
  222. <select id="querySceneGeneralTemplateListByTJ" parameterType="api.common.pojo.param.scene.SystemScenePackageParam"
  223. resultType="java.lang.String">
  224. select DISTINCT(a.scene_name) scene_name
  225. FROM system_scene_package_sublist a join scene_general_template s on a.scene_name=s.scene_id join system_scene_package b on a.scene_and_package=b.id
  226. where
  227. a.is_deleted='0' and s.is_deleted='0' and b.is_deleted='0' and a.scene_type='4'
  228. and b.package_name in
  229. <foreach collection="packageNames" item="item" index="index"
  230. separator="," open="(" close=")">
  231. #{item}
  232. </foreach>
  233. </select>
  234. </mapper>