BmDeptPlanMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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.ruoyi.system.mapper.project.BmDeptPlanMapper">
  6. <resultMap type="BmDeptPlan" id="BmDeptPlanResult">
  7. <result property="id" column="id" />
  8. <result property="sysDeptId" column="sys_dept_id" />
  9. <result property="createBy" column="create_by" />
  10. <result property="createTime" column="create_time" />
  11. <result property="updateBy" column="update_by" />
  12. <result property="updateTime" column="update_time" />
  13. <result property="isDel" column="is_del" />
  14. <result property="year" column="year" />
  15. <result property="plan" column="plan" />
  16. <result property="targetSigningNum" column="target_signing_num" />
  17. <result property="targetContractAmount" column="target_contract_amount" />
  18. <result property="targetArrivalAmount" column="target_arrival_amount" />
  19. <result property="targetInvestmentNum" column="target_investment_num" />
  20. <result property="deptName" column="dept_name" />
  21. </resultMap>
  22. <sql id="selectBmDeptPlanVo">
  23. select id, sys_dept_id, create_by, create_time, update_by, update_time, is_del, year, plan, target_signing_num, target_contract_amount, target_arrival_amount, target_investment_num from bm_dept_Plan
  24. </sql>
  25. <select id="selectBmDeptPlanList" parameterType="BmDeptPlan" resultMap="BmDeptPlanResult">
  26. select p.id, p.sys_dept_id, p.create_by, p.create_time, p.update_by, p.update_time, p.is_del, p.year, p.plan, p.target_signing_num, p.target_contract_amount, p.target_arrival_amount, p.target_investment_num, d.dept_name
  27. from bm_dept_plan p
  28. left join sys_dept d on p.sys_dept_id = d.dept_id and p.is_del = '0'
  29. <where>
  30. <if test="sysDeptId != null "> and sys_dept_id = #{sysDeptId}</if>
  31. <if test="isDel != null "> and is_del = #{isDel}</if>
  32. <if test="year != null and year != ''"> and year = #{year}</if>
  33. <if test="plan != null "> and plan = #{plan}</if>
  34. <if test="targetSigningNum != null "> and target_signing_num = #{targetSigningNum}</if>
  35. <if test="targetContractAmount != null "> and target_contract_amount = #{targetContractAmount}</if>
  36. <if test="targetArrivalAmount != null "> and target_arrival_amount = #{targetArrivalAmount}</if>
  37. <if test="targetInvestmentNum != null "> and target_investment_num = #{targetInvestmentNum}</if>
  38. </where>
  39. order by p.create_time DESC
  40. </select>
  41. <select id="selectBmDeptPlanById" parameterType="Long" resultMap="BmDeptPlanResult">
  42. <include refid="selectBmDeptPlanVo"/>
  43. where id = #{id}
  44. </select>
  45. <insert id="insertBmDeptPlan" parameterType="BmDeptPlan" useGeneratedKeys="true" keyProperty="id">
  46. insert into bm_dept_plan
  47. <trim prefix="(" suffix=")" suffixOverrides=",">
  48. <if test="sysDeptId != null">sys_dept_id,</if>
  49. <if test="createBy != null">create_by,</if>
  50. <if test="createTime != null">create_time,</if>
  51. <if test="updateBy != null">update_by,</if>
  52. <if test="updateTime != null">update_time,</if>
  53. <if test="isDel != null">is_del,</if>
  54. <if test="year != null">year,</if>
  55. <if test="plan != null">plan,</if>
  56. <if test="targetSigningNum != null">target_signing_num,</if>
  57. <if test="targetContractAmount != null">target_contract_amount,</if>
  58. <if test="targetArrivalAmount != null">target_arrival_amount,</if>
  59. <if test="targetInvestmentNum != null">target_investment_num,</if>
  60. </trim>
  61. <trim prefix="values (" suffix=")" suffixOverrides=",">
  62. <if test="sysDeptId != null">#{sysDeptId},</if>
  63. <if test="createBy != null">#{createBy},</if>
  64. <if test="createTime != null">#{createTime},</if>
  65. <if test="updateBy != null">#{updateBy},</if>
  66. <if test="updateTime != null">#{updateTime},</if>
  67. <if test="isDel != null">#{isDel},</if>
  68. <if test="year != null">#{year},</if>
  69. <if test="plan != null">#{plan},</if>
  70. <if test="targetSigningNum != null">#{targetSigningNum},</if>
  71. <if test="targetContractAmount != null">#{targetContractAmount},</if>
  72. <if test="targetArrivalAmount != null">#{targetArrivalAmount},</if>
  73. <if test="targetInvestmentNum != null">#{targetInvestmentNum},</if>
  74. </trim>
  75. </insert>
  76. <update id="updateBmDeptPlan" parameterType="BmDeptPlan">
  77. update bm_dept_plan
  78. <trim prefix="SET" suffixOverrides=",">
  79. <if test="sysDeptId != null">sys_dept_id = #{sysDeptId},</if>
  80. <if test="createBy != null">create_by = #{createBy},</if>
  81. <if test="createTime != null">create_time = #{createTime},</if>
  82. <if test="updateBy != null">update_by = #{updateBy},</if>
  83. <if test="updateTime != null">update_time = #{updateTime},</if>
  84. <if test="isDel != null">is_del = #{isDel},</if>
  85. <if test="year != null">year = #{year},</if>
  86. <if test="plan != null">plan = #{plan},</if>
  87. <if test="targetSigningNum != null">target_signing_num = #{targetSigningNum},</if>
  88. <if test="targetContractAmount != null">target_contract_amount = #{targetContractAmount},</if>
  89. <if test="targetArrivalAmount != null">target_arrival_amount = #{targetArrivalAmount},</if>
  90. <if test="targetInvestmentNum != null">target_investment_num = #{targetInvestmentNum},</if>
  91. </trim>
  92. where id = #{id}
  93. </update>
  94. <delete id="deleteBmDeptPlanById" parameterType="Long">
  95. delete from bm_dept_plan where id = #{id}
  96. </delete>
  97. <delete id="deleteBmDeptPlanByIds" parameterType="String">
  98. delete from bm_dept_plan where id in
  99. <foreach item="id" collection="array" open="(" separator="," close=")">
  100. #{id}
  101. </foreach>
  102. </delete>
  103. <select id="selectUnitList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  104. SELECT
  105. ifnull(s1.dept_name,'') AS deptName,
  106. ifnull(s1.plan,0) AS targetInvestmentNum,
  107. ifnull(count( p.id ),0) AS successMission
  108. FROM
  109. (
  110. SELECT
  111. sd.dept_name,
  112. d.sys_dept_id,
  113. d.plan
  114. FROM
  115. sys_dept sd
  116. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id and d.is_del = '0' and sd.del_flag = '0'
  117. ) s1
  118. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id and p.is_del = '0'
  119. GROUP BY
  120. s1.sys_dept_id
  121. ORDER BY
  122. successMission DESC,
  123. targetInvestmentNum DESC
  124. </select>
  125. <select id="selectUnitAmountList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  126. SELECT
  127. sd.dept_name AS deptName,
  128. ifnull(d.target_arrival_amount,0) AS targetArrivalAmount,
  129. ifnull(s1.payForMoney,0) as payForMoney
  130. FROM
  131. sys_dept sd
  132. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id and sd.del_flag = '0'
  133. AND d.is_del = '0'
  134. LEFT JOIN (
  135. SELECT
  136. sum(s.payForMoney ) AS payForMoney,
  137. s.dept_id
  138. FROM
  139. (
  140. SELECT
  141. cp.pay_for_money AS payForMoney,
  142. p.dept_id
  143. FROM
  144. bm_project p
  145. LEFT JOIN bm_construction_pay cp ON cp.bm_project_id = p.id
  146. AND p.is_del = '0'
  147. ) s
  148. GROUP BY
  149. s.dept_id
  150. ) s1 ON s1.dept_id = d.sys_dept_id
  151. ORDER BY
  152. s1.payForMoney DESC,
  153. d.target_arrival_amount DESC
  154. </select>
  155. <select id="selectUnitClueList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  156. SELECT
  157. ifnull(s1.dept_name,'') AS deptName,
  158. ifnull(s1.plan,0) AS plan,
  159. ifnull(count( p.id ),0) AS successMission
  160. FROM
  161. (
  162. SELECT
  163. sd.dept_name,
  164. d.sys_dept_id,
  165. d.plan
  166. FROM
  167. sys_dept sd
  168. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id and d.is_del = '0' and sd.del_flag = '0'
  169. ) s1
  170. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id and p.is_del = '0'
  171. GROUP BY
  172. s1.sys_dept_id
  173. ORDER BY
  174. successMission DESC,
  175. plan DESC
  176. </select>
  177. <select id="selectTargetSigningList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  178. SELECT
  179. ifnull(s1.dept_name,'') AS deptName,
  180. ifnull(s1.target_signing_num,0) AS targetSigningNum,
  181. ifnull(count( p.id ),0) AS successMission
  182. FROM
  183. (
  184. SELECT
  185. sd.dept_name,
  186. d.sys_dept_id,
  187. d.target_signing_num
  188. FROM
  189. sys_dept sd
  190. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id and d.is_del = '0' and sd.del_flag = '0'
  191. ) s1
  192. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id and p.is_del = '0' and p.project_status &gt; 4
  193. GROUP BY
  194. s1.sys_dept_id
  195. ORDER BY
  196. successMission DESC,
  197. targetSigningNum DESC
  198. </select>
  199. <select id="selectTotAmtList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  200. SELECT
  201. d.dept_name as deptName,
  202. ifnull(dp.target_contract_amount,0) as targetContractAmount,
  203. ifnull(p.tot_amt,0) as totAmt
  204. FROM
  205. sys_dept d
  206. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  207. AND d.del_flag = '0' and p.is_del = '0'
  208. LEFT JOIN bm_dept_plan dp ON dp.sys_dept_id = d.dept_id
  209. GROUP BY d.dept_id
  210. </select>
  211. <select id="selectProjectUnitAmountEharts" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  212. SELECT
  213. sd.dept_name AS deptName,
  214. ifnull( s1.payForMoney, 0 ) AS payForMoney
  215. FROM
  216. sys_dept sd
  217. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id
  218. AND sd.del_flag = '0'
  219. AND d.is_del = '0'
  220. LEFT JOIN (
  221. SELECT
  222. sum( s.payForMoney ) AS payForMoney,
  223. s.dept_id
  224. FROM
  225. (
  226. SELECT
  227. cp.pay_for_money AS payForMoney,
  228. p.dept_id
  229. FROM
  230. bm_project p
  231. LEFT JOIN bm_construction_pay cp ON cp.bm_project_id = p.id
  232. AND p.is_del = '0' and year(cp.create_time) = #{year}
  233. ) s
  234. GROUP BY
  235. s.dept_id
  236. ) s1 ON s1.dept_id = d.sys_dept_id
  237. ORDER BY
  238. s1.payForMoney DESC
  239. </select>
  240. <select id="selectInvestmentList" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  241. SELECT
  242. d.dept_name AS deptName,
  243. ifnull( dp.target_investment_num, 0 ) AS targetInvestmentNum,
  244. ifnull( count(p.id), 0 ) AS successMission
  245. FROM
  246. sys_dept d
  247. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  248. AND d.del_flag = '0' and p.is_del = '0' and p.project_status &gt; 8
  249. LEFT JOIN bm_dept_plan dp ON dp.sys_dept_id = d.dept_id
  250. GROUP BY
  251. d.dept_id
  252. order by successMission DESC,
  253. targetInvestmentNum DESC
  254. </select>
  255. <select id="selectProjectInvestmentEharts" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  256. SELECT
  257. d.dept_name AS deptName,
  258. ifnull( count(p.id), 0 ) AS successMission
  259. FROM
  260. sys_dept d
  261. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  262. AND d.del_flag = '0' and p.is_del = '0' and p.project_status &gt; 8 and year(p.create_time) = #{year}
  263. LEFT JOIN bm_dept_plan dp ON dp.sys_dept_id = d.dept_id
  264. GROUP BY
  265. d.dept_id
  266. </select>
  267. </mapper>