BmDeptPlanMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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="targetContractAmount" column="target_contract_amount" />
  16. <result property="targetArrivalAmount" column="target_arrival_amount" />
  17. <result property="remark" column="remark" />
  18. <result property="deptName" column="dept_name" />
  19. </resultMap>
  20. <sql id="selectBmDeptPlanVo">
  21. select id, sys_dept_id, create_by, create_time, update_by, update_time, is_del, year, target_contract_amount, target_arrival_amount, remark from bm_dept_Plan
  22. </sql>
  23. <select id="selectBmDeptPlanList" parameterType="BmDeptPlan" resultMap="BmDeptPlanResult">
  24. 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.target_contract_amount, p.target_arrival_amount, p.remark, d.dept_name
  25. from bm_dept_plan p
  26. left join sys_dept d on p.sys_dept_id = d.dept_id and p.is_del = '0'
  27. <where>
  28. is_del = '0'
  29. <if test="sysDeptId != null "> and sys_dept_id = #{sysDeptId}</if>
  30. <if test="year != null and year != ''"> and year = #{year}</if>
  31. <if test="targetContractAmount != null "> and target_contract_amount = #{targetContractAmount}</if>
  32. <if test="targetArrivalAmount != null "> and target_arrival_amount = #{targetArrivalAmount}</if>
  33. </where>
  34. order by p.create_time DESC
  35. </select>
  36. <select id="selectBmDeptPlanById" parameterType="Long" resultMap="BmDeptPlanResult">
  37. <include refid="selectBmDeptPlanVo"/>
  38. where id = #{id}
  39. </select>
  40. <insert id="insertBmDeptPlan" parameterType="BmDeptPlan" useGeneratedKeys="true" keyProperty="id">
  41. insert into bm_dept_plan
  42. <trim prefix="(" suffix=")" suffixOverrides=",">
  43. <if test="sysDeptId != null">sys_dept_id,</if>
  44. <if test="createBy != null">create_by,</if>
  45. <if test="createTime != null">create_time,</if>
  46. <if test="updateBy != null">update_by,</if>
  47. <if test="updateTime != null">update_time,</if>
  48. <if test="isDel != null">is_del,</if>
  49. <if test="year != null">year,</if>
  50. <if test="targetContractAmount != null">target_contract_amount,</if>
  51. <if test="targetArrivalAmount != null">target_arrival_amount,</if>
  52. <if test="remark != null">remark,</if>
  53. </trim>
  54. <trim prefix="values (" suffix=")" suffixOverrides=",">
  55. <if test="sysDeptId != null">#{sysDeptId},</if>
  56. <if test="createBy != null">#{createBy},</if>
  57. <if test="createTime != null">#{createTime},</if>
  58. <if test="updateBy != null">#{updateBy},</if>
  59. <if test="updateTime != null">#{updateTime},</if>
  60. <if test="isDel != null">#{isDel},</if>
  61. <if test="year != null">#{year},</if>
  62. <if test="targetContractAmount != null">#{targetContractAmount},</if>
  63. <if test="targetArrivalAmount != null">#{targetArrivalAmount},</if>
  64. <if test="remark != null">#{remark},</if>
  65. </trim>
  66. </insert>
  67. <update id="updateBmDeptPlan" parameterType="BmDeptPlan">
  68. update bm_dept_plan
  69. <trim prefix="SET" suffixOverrides=",">
  70. <if test="sysDeptId != null">sys_dept_id = #{sysDeptId},</if>
  71. <if test="createBy != null">create_by = #{createBy},</if>
  72. <if test="createTime != null">create_time = #{createTime},</if>
  73. <if test="updateBy != null">update_by = #{updateBy},</if>
  74. <if test="updateTime != null">update_time = #{updateTime},</if>
  75. <if test="isDel != null">is_del = #{isDel},</if>
  76. <if test="year != null">year = #{year},</if>
  77. <if test="targetContractAmount != null">target_contract_amount = #{targetContractAmount},</if>
  78. <if test="targetArrivalAmount != null">target_arrival_amount = #{targetArrivalAmount},</if>
  79. <if test="remark != null">remark = #{remark},</if>
  80. </trim>
  81. where id = #{id}
  82. </update>
  83. <delete id="deleteBmDeptPlanById" parameterType="Long">
  84. delete from bm_dept_plan where id = #{id}
  85. </delete>
  86. <delete id="deleteBmDeptPlanByIds" parameterType="String">
  87. delete from bm_dept_plan where id in
  88. <foreach item="id" collection="array" open="(" separator="," close=")">
  89. #{id}
  90. </foreach>
  91. </delete>
  92. <select id="selectUnitList" parameterType="string" resultMap="BmDeptPlanResult">
  93. select ifnull(p.target_contract_amount,0) as target_contract_amount , ifnull(p.target_arrival_amount,0) as target_arrival_amount, d.dept_name
  94. from bm_dept_plan p right join sys_dept d on p.sys_dept_id = d.dept_id and p.is_del = '0' and p.year = #{year} where d.parent_id = 124
  95. </select>
  96. <select id="selectUnitClueList" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  97. SELECT
  98. ifnull( s1.dept_name, '' ) AS deptName,
  99. ifnull( s1.plan, 0 ) AS plan,
  100. ifnull( count( p.id ), 0 ) AS successMission
  101. FROM
  102. (
  103. SELECT
  104. sd.dept_id,
  105. sd.dept_name,
  106. sd.parent_id,
  107. a.sys_dept_id,
  108. (ifnull(a.project_million_num,0)+ ifnull(a.project_pro_num,0)+ ifnull(a.project_investment_num,0))as plan
  109. FROM
  110. sys_dept sd
  111. LEFT JOIN `bm_dept_plan_area` a ON a.sys_dept_id = sd.dept_id
  112. AND a.is_del = '0'
  113. WHERE
  114. sd.del_flag = '0'
  115. ) s1
  116. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id
  117. AND p.is_del = '0'
  118. and year(p.create_time) = #{year}
  119. where
  120. s1.parent_id = 105
  121. GROUP BY
  122. s1.dept_id
  123. ORDER BY
  124. successMission DESC,
  125. plan DESC
  126. </select>
  127. <select id="selectUnitClueCityList" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  128. SELECT
  129. ifnull( s1.dept_name, '' ) AS deptName,
  130. ifnull( s1.target_arrival_amount, 0 ) AS targetArrivalAmount,
  131. ifnull( count( p.id ), 0 ) AS successMission
  132. FROM
  133. (
  134. SELECT
  135. sd.dept_id,
  136. sd.dept_name,
  137. sd.parent_id,
  138. a.sys_dept_id,
  139. a.target_arrival_amount
  140. FROM
  141. sys_dept sd
  142. LEFT JOIN `bm_dept_plan` a ON a.sys_dept_id = sd.dept_id
  143. AND a.is_del = '0'
  144. WHERE
  145. sd.del_flag = '0'
  146. ) s1
  147. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id
  148. AND p.is_del = '0'
  149. and year(p.create_time) = #{year}
  150. where
  151. s1.parent_id = 124
  152. and p.project_status in (1,2,3,4)
  153. GROUP BY
  154. s1.dept_id
  155. ORDER BY
  156. successMission DESC,
  157. targetArrivalAmount DESC
  158. </select>
  159. <select id="selectTargetSigningList" parameterType="String" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  160. SELECT
  161. ifnull(s1.dept_name,'') AS deptName,
  162. ifnull(s1.target_signing_num,0) AS targetSigningNum,
  163. ifnull(count( p.id ),0) AS successMission
  164. FROM
  165. (
  166. SELECT
  167. sd.dept_id,
  168. sd.dept_name,
  169. sd.parent_id,
  170. a.sys_dept_id,
  171. (ifnull(a.project_million_num,0)+ ifnull(a.project_pro_num,0)+ ifnull(a.project_investment_num,0))as target_signing_num
  172. FROM
  173. sys_dept sd
  174. LEFT JOIN `bm_dept_plan_area` a ON a.sys_dept_id = sd.dept_id and a.is_del = '0'
  175. where sd.del_flag = '0'
  176. ) s1
  177. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id
  178. and p.is_del = '0' and p.project_status &gt; 4 and year(p.create_time) = #{year}
  179. where
  180. s1.parent_id = 105
  181. GROUP BY
  182. s1.dept_id
  183. ORDER BY
  184. successMission DESC,
  185. targetSigningNum DESC
  186. </select>
  187. <select id="selectTotAmtList" parameterType="String" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  188. SELECT
  189. d.dept_name AS deptName,
  190. ifnull( dp.target_arrival_amount, 0 ) AS targetArrivalAmount,
  191. ifnull( p.tot_amt, 0 ) AS totAmt
  192. FROM
  193. sys_dept d
  194. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  195. AND p.is_del = '0' and year(p.create_time) = #{year}
  196. LEFT JOIN bm_dept_plan dp ON dp.sys_dept_id = d.dept_id and year(dp.create_time) = #{year}
  197. WHERE
  198. d.del_flag = '0'
  199. and d.parent_id = 124
  200. GROUP BY
  201. d.dept_id
  202. ORDER BY
  203. targetArrivalAmount DESC,
  204. totAmt DESC
  205. </select>
  206. <select id="selectProjectUnitAmountEharts" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  207. SELECT
  208. sd.dept_name AS deptName,
  209. ifnull( s1.payForMoney, 0 ) AS payForMoney
  210. FROM
  211. sys_dept sd
  212. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id and year(d.create_time) = #{year}
  213. AND d.is_del = '0'
  214. LEFT JOIN (
  215. SELECT
  216. sum( s.payForMoney ) AS payForMoney,
  217. s.dept_id
  218. FROM
  219. (
  220. SELECT
  221. cp.pay_for_money AS payForMoney,
  222. p.dept_id
  223. FROM
  224. bm_project p
  225. LEFT JOIN bm_construction_pay cp ON cp.bm_project_id = p.id
  226. AND p.is_del = '0' and year(cp.create_time) = #{year}
  227. ) s
  228. GROUP BY
  229. s.dept_id
  230. ) s1 ON s1.dept_id = d.sys_dept_id
  231. WHERE
  232. sd.del_flag = '0'
  233. ORDER BY
  234. s1.payForMoney DESC
  235. </select>
  236. <select id="selectProjectUnitAmountUnit" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  237. SELECT
  238. sd.dept_name AS deptName,
  239. ifnull( s1.payForMoney, 0 ) AS payForMoney,
  240. ifnull(d.target_contract_amount,0) as targetContractAmount
  241. FROM
  242. sys_dept sd
  243. LEFT JOIN `bm_dept_plan` d ON d.sys_dept_id = sd.dept_id
  244. AND d.is_del = '0' and year(d.create_time) = #{year}
  245. LEFT JOIN (
  246. SELECT
  247. sum( s.payForMoney ) AS payForMoney,
  248. s.dept_id
  249. FROM
  250. (
  251. SELECT
  252. cp.pay_for_money AS payForMoney,
  253. p.dept_id
  254. FROM
  255. bm_project p
  256. LEFT JOIN bm_construction_pay cp ON cp.bm_project_id = p.id
  257. AND p.is_del = '0' and year(cp.create_time) = #{year}
  258. ) s
  259. GROUP BY
  260. s.dept_id
  261. ) s1 ON s1.dept_id = d.sys_dept_id
  262. WHERE
  263. sd.del_flag = '0'
  264. and sd.parent_id = 124
  265. ORDER BY
  266. s1.payForMoney DESC
  267. </select>
  268. <select id="selectProjectAreaAmountUnit" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  269. SELECT
  270. ifnull(s1.dept_name,'') AS deptName,
  271. ifnull(s1.target_signing_num,0) AS targetSigningNum,
  272. ifnull(count( p.id ),0) AS successMission
  273. FROM
  274. (
  275. SELECT
  276. sd.dept_id,
  277. sd.dept_name,
  278. sd.parent_id,
  279. a.sys_dept_id,
  280. (ifnull(a.project_million_num,0)+ ifnull(a.project_pro_num,0)+ ifnull(a.project_investment_num,0))as target_signing_num
  281. FROM
  282. sys_dept sd
  283. LEFT JOIN `bm_dept_plan_area` a ON a.sys_dept_id = sd.dept_id and a.is_del = '0'
  284. where sd.del_flag = '0'
  285. ) s1
  286. LEFT JOIN bm_project p ON p.dept_id = s1.sys_dept_id
  287. and p.is_del = '0' and p.project_status in (8,9) and year(p.create_time) = #{year}
  288. where
  289. s1.parent_id = 105
  290. GROUP BY
  291. s1.dept_id
  292. ORDER BY
  293. successMission DESC,
  294. targetSigningNum DESC
  295. </select>
  296. <select id="selectInvestmentList" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  297. SELECT
  298. d.dept_name AS deptName,
  299. (ifnull( dp.project_million_num, 0 )+ ifnull( dp.project_pro_num, 0 )+ ifnull( dp.project_investment_num, 0 )) AS targetSigningNum,
  300. ifnull( count(p.id), 0 ) AS successMission
  301. FROM
  302. sys_dept d
  303. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  304. and p.is_del = '0' and p.project_status &gt; 8 and year(p.create_time) = #{year}
  305. LEFT JOIN bm_dept_plan_area dp ON dp.sys_dept_id = d.dept_id and year(dp.create_time) = #{year}
  306. where d.del_flag = '0' and d.parent_id = 105
  307. GROUP BY
  308. d.dept_id
  309. order by successMission DESC,
  310. targetSigningNum DESC
  311. </select>
  312. <select id="selectInvestmentCityList" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  313. SELECT
  314. sd.dept_name AS deptName,
  315. ifnull( s1.payForMoney, 0 ) AS payForMoney,
  316. ifnull( count(p.id), 0 ) AS successMission
  317. FROM
  318. sys_dept sd
  319. LEFT JOIN `bm_project` p ON p.dept_id = sd.dept_id and p.project_status &gt; 8
  320. AND p.is_del = '0' and year(p.create_time) = #{year}
  321. LEFT JOIN (
  322. SELECT
  323. sum( s.payForMoney ) AS payForMoney,
  324. s.dept_id
  325. FROM
  326. (
  327. SELECT
  328. cp.pay_for_money AS payForMoney,
  329. p.dept_id
  330. FROM
  331. bm_project p
  332. LEFT JOIN bm_construction_pay cp ON cp.bm_project_id = p.id
  333. AND p.is_del = '0' and year(cp.create_time) = #{year}
  334. ) s
  335. GROUP BY
  336. s.dept_id
  337. ) s1 ON s1.dept_id = p.dept_id
  338. WHERE
  339. sd.del_flag = '0'
  340. and sd.parent_id = 124
  341. GROUP BY
  342. sd.dept_id
  343. ORDER BY
  344. s1.payForMoney DESC
  345. </select>
  346. <select id="selectProjectInvestmentEharts" parameterType="string" resultType="com.ruoyi.system.domain.vo.BmDeptPlanVo">
  347. SELECT
  348. d.dept_name AS deptName,
  349. ifnull( count(p.id), 0 ) AS successMission
  350. FROM
  351. sys_dept d
  352. LEFT JOIN bm_project p ON p.dept_id = d.dept_id
  353. and p.is_del = '0' and p.project_status &gt; 8 and year(p.create_time) = #{year}
  354. where d.del_flag = '0'
  355. GROUP BY
  356. d.dept_id
  357. ORDER BY successMission
  358. </select>
  359. </mapper>