LargeProjectMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.project.zcustom.mapper.unit.LargeProjectMapper">
  6. <resultMap type="com.project.zcustom.domain.addional.LargeProject" id="LargeProjectResult">
  7. <result property="id" column="id" />
  8. <result property="projectName" column="project_name" />
  9. <result property="appOrg" column="app_org" />
  10. <result property="appParentOrg" column="app_parent_org" />
  11. <result property="connectFlag" column="connect_flag" />
  12. <result property="delFlag" column="del_flag" />
  13. <result property="subdivision" column="subdivision" />
  14. <result property="createBy" column="create_by" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateBy" column="update_by" />
  17. <result property="updateTime" column="update_time" />
  18. </resultMap>
  19. <sql id="selectLargeProjectVo">
  20. select id, project_name, app_org, connect_flag, del_flag, create_by, create_time, update_by, update_time from large_plat_project
  21. </sql>
  22. <select id="selectLargeProjectList" parameterType="LargeProject" resultMap="LargeProjectResult">
  23. <include refid="selectLargeProjectVo"/>
  24. <where>
  25. <if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
  26. <if test="appOrg != null "> and app_org = #{appOrg}</if>
  27. <if test="connectFlag != null and connectFlag != ''"> and connect_flag = #{connectFlag}</if>
  28. </where>
  29. </select>
  30. <insert id="insertLargeProject" parameterType="LargeProject" useGeneratedKeys="true" keyProperty="id">
  31. insert into large_plat_project
  32. <trim prefix="(" suffix=")" suffixOverrides=",">
  33. <if test="projectName != null">project_name,</if>
  34. <if test="appOrg != null">app_org,</if>
  35. <if test="connectFlag != null">connect_flag,</if>
  36. <if test="delFlag != null">del_flag,</if>
  37. <if test="createBy != null">create_by,</if>
  38. <if test="createTime != null">create_time,</if>
  39. <if test="updateBy != null">update_by,</if>
  40. <if test="updateTime != null">update_time,</if>
  41. </trim>
  42. <trim prefix="values (" suffix=")" suffixOverrides=",">
  43. <if test="projectName != null">#{projectName},</if>
  44. <if test="appOrg != null">#{appOrg},</if>
  45. <if test="connectFlag != null">#{connectFlag},</if>
  46. <if test="delFlag != null">#{delFlag},</if>
  47. <if test="createBy != null">#{createBy},</if>
  48. <if test="createTime != null">#{createTime},</if>
  49. <if test="updateBy != null">#{updateBy},</if>
  50. <if test="updateTime != null">#{updateTime},</if>
  51. </trim>
  52. </insert>
  53. <update id="updateLargeProject" parameterType="LargeProject">
  54. update large_plat_project
  55. <trim prefix="SET" suffixOverrides=",">
  56. <if test="projectName != null">project_name = #{projectName},</if>
  57. <if test="appOrg != null">app_org = #{appOrg},</if>
  58. <if test="connectFlag != null">connect_flag = #{connectFlag},</if>
  59. <if test="delFlag != null">del_flag = #{delFlag},</if>
  60. <if test="createBy != null">create_by = #{createBy},</if>
  61. <if test="createTime != null">create_time = #{createTime},</if>
  62. <if test="updateBy != null">update_by = #{updateBy},</if>
  63. <if test="updateTime != null">update_time = #{updateTime},</if>
  64. </trim>
  65. where id = #{id}
  66. </update>
  67. <delete id="deleteLargeProjectById" parameterType="Long">
  68. delete from large_plat_project where id = #{id}
  69. </delete>
  70. <delete id="deleteLargeProjectByIds" parameterType="String">
  71. delete from large_plat_project where id in
  72. <foreach item="id" collection="array" open="(" separator="," close=")">
  73. #{id}
  74. </foreach>
  75. </delete>
  76. <delete id="reallyDeleteByWrapper">
  77. DELETE FROM large_plat_project ${ew.customSqlSegment}
  78. </delete>
  79. <select id="getProjectNum" parameterType="String" resultType="Long">
  80. SELECT
  81. count(*) AS num
  82. FROM
  83. large_plat_project a
  84. LEFT JOIN large_plat_app_org b ON a.app_org = b.app_org
  85. WHERE
  86. a.del_flag = '0'
  87. AND b.del_flag = '0'
  88. AND subdivision &lt;= 10
  89. <if test="appOrg != '10001'">AND ( b.app_parent_org = #{appOrg} OR b.app_org = #{appOrg} )</if>
  90. </select>
  91. <select id="getProjectNumX" parameterType="String" resultMap="LargeProjectResult">
  92. SELECT
  93. count(*) AS num,
  94. subdivision
  95. FROM
  96. large_plat_project a
  97. LEFT JOIN large_plat_app_org b ON a.app_org = b.app_org
  98. WHERE
  99. a.del_flag = '0'
  100. AND b.del_flag = '0'
  101. <if test="appOrg != '10001'">AND ( b.app_parent_org = #{appOrg} OR b.app_org = #{appOrg} )</if>
  102. AND subdivision &lt;= 10
  103. GROUP BY
  104. subdivision
  105. </select>
  106. <select id="getProjectNumY" parameterType="String" resultMap="LargeProjectResult">
  107. SELECT
  108. count(*) AS num,
  109. subdivision
  110. FROM
  111. large_plat_project a
  112. LEFT JOIN large_plat_app_org b ON a.app_org = b.app_org
  113. WHERE
  114. a.del_flag = '0'
  115. AND b.del_flag = '0'
  116. <if test="appOrg != '10001'">AND ( b.app_parent_org = #{appOrg} OR b.app_org = #{appOrg} )</if>
  117. AND subdivision >= 10
  118. GROUP BY
  119. subdivision
  120. </select>
  121. <select id="getProjectByAppOrg" parameterType="String" resultMap="LargeProjectResult">
  122. SELECT
  123. a.subdivision,
  124. b.app_org,
  125. a.project_name,
  126. a.abscissa,
  127. a.ordinate
  128. FROM
  129. large_plat_project a
  130. LEFT JOIN large_plat_app_org b ON a.app_org = b.app_org
  131. WHERE
  132. a.del_flag = '0'
  133. AND b.del_flag = '0'
  134. AND ( b.app_parent_org = #{appOrg} OR b.app_org = #{appOrg} )
  135. </select>
  136. <select id="getCameraNumList" parameterType="String" resultMap="LargeProjectResult">
  137. SELECT
  138. a.id,
  139. a.project_name,
  140. COUNT(
  141. IF
  142. ( a.del_flag = 0 AND b.del_flag = 0, 1, NULL )) AS cameraNum
  143. FROM
  144. large_plat_project a
  145. LEFT JOIN large_plat_camera b ON a.id = b.project_id
  146. WHERE a.del_flag = '0' AND a.app_org = #{appOrg}
  147. GROUP BY a.id
  148. </select>
  149. <select id="getProjectNumThisWeek" parameterType="String" resultType="int">
  150. SELECT
  151. COUNT(a.id)
  152. FROM
  153. large_plat_plan a
  154. LEFT JOIN large_plat_project b ON a.project_id = b.id
  155. LEFT JOIN large_plat_app_org c ON b.app_org = c.app_org
  156. WHERE
  157. a.del_flag = '0'
  158. AND b.del_flag = '0'
  159. AND c.del_flag = '0'
  160. AND ( c.app_parent_org = #{appOrg} OR c.app_org = #{appOrg} )
  161. AND (
  162. DATE( a.start_time ) BETWEEN DATE_SUB( CURDATE(), INTERVAL ( DAYOFWEEK( CURDATE()) - 2 ) DAY )
  163. AND DATE_ADD( CURDATE(), INTERVAL ( 8 - DAYOFWEEK( CURDATE())) DAY )
  164. OR DATE( a.end_time ) BETWEEN DATE_SUB( CURDATE(), INTERVAL ( DAYOFWEEK( CURDATE()) - 2 ) DAY )
  165. AND DATE_ADD( CURDATE(), INTERVAL ( 8 - DAYOFWEEK( CURDATE())) DAY ))
  166. </select>
  167. <select id="getProjectNumZ" parameterType="String" resultMap="LargeProjectResult">
  168. SELECT
  169. a.project_name,
  170. a.app_org,
  171. b.app_parent_org,
  172. CASE
  173. WHEN subdivision > 10 THEN
  174. 0 ELSE 1
  175. END AS subdivision
  176. FROM
  177. large_plat_project a
  178. LEFT JOIN large_plat_app_org b ON a.app_org = b.app_org
  179. WHERE
  180. a.del_flag = '0'
  181. AND b.del_flag = '0'
  182. </select>
  183. </mapper>