PmDemandMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  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.ozs.pm.mapper.PmDemandMapper">
  6. <select id="selectByDemandIdList" parameterType="java.util.List" resultType="com.ozs.pm.doman.PmDemand">
  7. select * from pm_demand where project_status &gt;= 12 and demand_id in
  8. <foreach item="item" collection="demandIdList" separator="," open="(" close=")" index="">
  9. #{item}
  10. </foreach>
  11. </select>
  12. <select id="selectExtractionExpert" parameterType="com.ozs.base.domain.vo.BaseExpertVo"
  13. resultType="com.ozs.pm.doman.PmDemand">
  14. select * from pm_demand where demand_id in (select demand_id from pm_demand_expert_ref group by demand_id)
  15. <if test="projectName != null and projectName != ''">
  16. and project_name like '%' + #{projectName} + '%'
  17. </if>
  18. <if test="startTime != null "><!-- 开始时间检索 -->
  19. and date_format(plan_demand_sub_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
  20. </if>
  21. <if test="endTime != null "><!-- 结束时间检索 -->
  22. and date_format(plan_demand_sub_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  23. </if>
  24. </select>
  25. <select id="purchaseProjectStatistical" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  26. resultType="java.util.Map">
  27. select count(demand_id) countId
  28. from pm_demand
  29. WHERE purchase_dept_id in
  30. <foreach collection="vo.deptList" item="item" index="index"
  31. separator="," open="(" close=")">
  32. #{item}
  33. </foreach>
  34. </select>
  35. <select id="purchaseProjectStatisticalYWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  36. resultType="java.util.Map">
  37. select count(d.demand_id) countYWC, ifnull(sum(c.contract_amount), 0) evaluationYWC
  38. from pm_demand d, pm_contract_info c,
  39. (SELECT COUNT(demand_id) countYWC ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
  40. purchase_dept_id in
  41. <foreach collection="vo.deptList" item="item" index="index"
  42. separator="," open="(" close=")">
  43. #{item}
  44. </foreach>
  45. AND project_status =21 ) de
  46. where d.demand_id = c.demand_id
  47. AND d.purchase_dept_id in
  48. <foreach collection="vo.deptList" item="item" index="index"
  49. separator="," open="(" close=")">
  50. #{item}
  51. </foreach>
  52. AND d.project_status =21
  53. </select>
  54. <select id="purchaseProjectStatisticalXCJ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  55. resultType="java.util.Map">
  56. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  57. select count(demand_id) countXCJ, ifnull(sum(evaluation), 0) evaluationXCJ
  58. from pm_demand
  59. where purchase_dept_id in
  60. <foreach collection="vo.deptList" item="item" index="index"
  61. separator="," open="(" close=")">
  62. #{item}
  63. </foreach>
  64. AND project_status !=17
  65. and year(plan_demand_sub_time) = year(NOW())
  66. </select>
  67. <select id="purchaseProjectStatisticalQNWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  68. resultType="java.util.Map">
  69. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  70. select de.countYWC, ifnull(sum(c.contract_amount), 0) evaluationQNWC
  71. from pm_demand d, pm_contract_info c,
  72. (SELECT COUNT(demand_id) countYWC ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE
  73. purchase_dept_id in
  74. <foreach collection="vo.deptList" item="item" index="index"
  75. separator="," open="(" close=")">
  76. #{item}
  77. </foreach>
  78. AND project_status =21 and year(create_time) = year(NOW())-1) de
  79. WHERE d.demand_id = c.demand_id
  80. AND d.purchase_dept_id in
  81. <foreach collection="vo.deptList" item="item" index="index"
  82. separator="," open="(" close=")">
  83. #{item}
  84. </foreach>
  85. AND d.project_status =21 and year(d.create_time) = year(NOW())-1
  86. </select>
  87. <select id="countByProjectAttr" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  88. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  89. SELECT project_attr columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  90. FROM `pm_demand`
  91. WHERE purchase_dept_id in
  92. <foreach collection="vo.deptList" item="item" index="index"
  93. separator="," open="(" close=")">
  94. #{item}
  95. </foreach>
  96. GROUP BY project_attr
  97. </select>
  98. <select id="countByPurchaseMode" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  99. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  100. SELECT purchase_mode columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  101. FROM `pm_demand`
  102. WHERE purchase_dept_id in
  103. <foreach collection="vo.deptList" item="item" index="index"
  104. separator="," open="(" close=")">
  105. #{item}
  106. </foreach>
  107. GROUP BY purchase_mode
  108. </select>
  109. <select id="countByEvaluationLt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  110. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  111. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  112. FROM `pm_demand`
  113. WHERE purchase_dept_id in
  114. <foreach collection="vo.deptList" item="item" index="index"
  115. separator="," open="(" close=")">
  116. #{item}
  117. </foreach>
  118. AND evaluation &lt; #{vo.evaluation}
  119. </select>
  120. <select id="countByEvaluationBet" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  121. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  122. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  123. FROM `pm_demand`
  124. WHERE purchase_dept_id in
  125. <foreach collection="vo.deptList" item="item" index="index"
  126. separator="," open="(" close=")">
  127. #{item}
  128. </foreach>
  129. AND evaluation BETWEEN #{vo.evaluation} and #{vo.evaluationEnd}
  130. </select>
  131. <select id="countByEvaluationGt" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  132. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  133. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  134. FROM `pm_demand`
  135. WHERE purchase_dept_id in
  136. <foreach collection="vo.deptList" item="item" index="index"
  137. separator="," open="(" close=")">
  138. #{item}
  139. </foreach>
  140. AND evaluation &gt; #{vo.evaluation}
  141. </select>
  142. <select id="countProjectExceed" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  143. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  144. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  145. FROM `pm_demand`
  146. WHERE purchase_dept_id in
  147. <foreach collection="vo.deptList" item="item" index="index"
  148. separator="," open="(" close=")">
  149. #{item}
  150. </foreach>
  151. AND (real_demand_commit_time > plan_demand_sub_time
  152. or real_purchase_finish_time > plan_purchase_finish_time
  153. or real_deliver_time > plan_deliver_time)
  154. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  155. </select>
  156. <select id="countThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  157. resultType="java.lang.Integer">
  158. SELECT COUNT(demand_id) num
  159. FROM `pm_demand`
  160. WHERE purchase_dept_id in
  161. <foreach collection="vo.deptList" item="item" index="index"
  162. separator="," open="(" close=")">
  163. #{item}
  164. </foreach>
  165. AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  166. </select>
  167. <select id="countProjectExceedYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  168. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  169. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  170. FROM `pm_demand`
  171. WHERE purchase_dept_id in
  172. <foreach collection="vo.deptList" item="item" index="index"
  173. separator="," open="(" close=")">
  174. #{item}
  175. </foreach>
  176. AND (real_demand_commit_time > plan_demand_sub_time
  177. or real_purchase_finish_time > plan_purchase_finish_time
  178. or real_deliver_time > plan_deliver_time)
  179. GROUP BY DATE_FORMAT(create_time, '%Y')
  180. order by create_time asc
  181. </select>
  182. <select id="countProjectExceedMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  183. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  184. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  185. FROM `pm_demand`
  186. WHERE purchase_dept_id in
  187. <foreach collection="vo.deptList" item="item" index="index"
  188. separator="," open="(" close=")">
  189. #{item}
  190. </foreach>
  191. AND (real_demand_commit_time > plan_demand_sub_time
  192. or real_purchase_finish_time > plan_purchase_finish_time
  193. or real_deliver_time > plan_deliver_time)
  194. and MONTH(
  195. create_time) = #{vo.month}
  196. AND DATE_FORMAT(create_time
  197. , '%Y') = #{vo.year}
  198. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  199. </select>
  200. <select id="countProjectExceedQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  201. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  202. SELECT DATE_FORMAT(create_time, '%Y-${quarter}季度') columnName, COUNT(demand_id) num
  203. FROM `pm_demand`
  204. WHERE purchase_dept_id in
  205. <foreach collection="vo.deptList" item="item" index="index"
  206. separator="," open="(" close=")">
  207. #{item}
  208. </foreach>
  209. AND (real_demand_commit_time > plan_demand_sub_time
  210. or real_purchase_finish_time > plan_purchase_finish_time
  211. or real_deliver_time > plan_deliver_time)
  212. and QUARTER(create_time) = #{vo.quarter}
  213. AND DATE_FORMAT(create_time, '%Y') = #{vo.year}
  214. </select>
  215. <select id="countProjectExceedAll" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  216. resultType="com.ozs.pm.doman.PmDemand">
  217. SELECT *
  218. FROM `pm_demand`
  219. WHERE purchase_dept_id in
  220. <foreach collection="vo.deptList" item="item" index="index"
  221. separator="," open="(" close=")">
  222. #{item}
  223. </foreach>
  224. AND (real_demand_commit_time > plan_demand_sub_time
  225. or real_purchase_finish_time > plan_purchase_finish_time
  226. or real_deliver_time > plan_deliver_time)
  227. </select>
  228. <select id="majorProjectByStatus" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  229. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  230. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  231. FROM `pm_demand`
  232. WHERE purchase_dept_id in
  233. <foreach collection="vo.deptList" item="item" index="index"
  234. separator="," open="(" close=")">
  235. #{item}
  236. </foreach>
  237. AND find_in_set('1', project_attr)
  238. AND `project_status` = #{vo.projectStatus}
  239. AND DATE_FORMAT(create_time, '%Y') = year(now())
  240. </select>
  241. <select id="countMajorProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  242. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  243. FROM `pm_demand`
  244. WHERE purchase_dept_id in
  245. <foreach collection="vo.deptList" item="item" index="index"
  246. separator="," open="(" close=")">
  247. #{item}
  248. </foreach>
  249. AND (real_demand_commit_time > plan_demand_sub_time
  250. or real_purchase_finish_time > plan_purchase_finish_time
  251. or real_deliver_time > plan_deliver_time)
  252. AND find_in_set('1', project_attr)
  253. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  254. </select>
  255. <select id="taskQuantityYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  256. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  257. SELECT YEAR(NOW()) columnName, COUNT(demand_id) num
  258. FROM `pm_demand`
  259. WHERE find_in_set('1'
  260. , project_attr)
  261. AND `project_status` = #{code}
  262. and DATE_FORMAT(create_time
  263. , '%Y') = YEAR(NOW())
  264. </select>
  265. <select id="taskQuantityLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  266. parameterType="java.lang.String">
  267. SELECT YEAR (NOW()) - 1 columnName, COUNT (demand_id) num
  268. FROM `pm_demand`
  269. WHERE find_in_set('1'
  270. , project_attr)
  271. AND `project_status` = #{code}
  272. and DATE_FORMAT(create_time
  273. , '%Y') = YEAR (NOW()) - 1
  274. </select>
  275. <select id="countEveryStatusNum" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  276. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  277. SELECT project_status columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  278. FROM `pm_demand`
  279. WHERE purchase_dept_id in
  280. <foreach collection="vo.deptList" item="item" index="index"
  281. separator="," open="(" close=")">
  282. #{item}
  283. </foreach>
  284. AND `project_status` IN (9, 10, 11, 12, 13, 14,15,16,17)
  285. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  286. GROUP BY project_status
  287. </select>
  288. <select id="selectByPlanId" parameterType="java.lang.Long" resultType="com.ozs.pm.doman.PmDemand">
  289. select *
  290. from pm_demand
  291. where plan_id = #{planId} limit 1
  292. </select>
  293. <select id="countMajorProjectLastYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  294. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  295. # AND find_in_set('1', project_attr)
  296. SELECT YEAR(NOW()) - 1 columnName, de.num, ifnull(sum(c.contract_amount), 0) evaluationContractTotal
  297. FROM pm_demand d, pm_contract_info c,
  298. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  299. in
  300. <foreach collection="vo.deptList" item="item" index="index"
  301. separator="," open="(" close=")">
  302. #{item}
  303. </foreach>
  304. AND find_in_set('1', project_attr) AND DATE_FORMAT(create_time, '%Y') =YEAR(NOW()) - 1 ) de
  305. WHERE d.demand_id = c.demand_id
  306. AND find_in_set('1', d.project_attr)
  307. AND d.purchase_dept_id in
  308. <foreach collection="vo.deptList" item="item" index="index"
  309. separator="," open="(" close=")">
  310. #{item}
  311. </foreach>
  312. AND DATE_FORMAT(d.create_time, '%Y') = YEAR(NOW()) - 1
  313. </select>
  314. <select id="countProjectMajorByYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  315. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  316. FROM `pm_demand`
  317. WHERE purchase_dept_id in
  318. <foreach collection="vo.deptList" item="item" index="index"
  319. separator="," open="(" close=")">
  320. #{item}
  321. </foreach>
  322. AND find_in_set('1', project_attr)
  323. GROUP BY DATE_FORMAT(create_time, '%Y')
  324. order by create_time asc
  325. </select>
  326. <select id="countProjectMajorByMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  327. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  328. FROM `pm_demand`
  329. WHERE purchase_dept_id in
  330. <foreach collection="vo.deptList" item="item" index="index"
  331. separator="," open="(" close=")">
  332. #{item}
  333. </foreach>
  334. AND find_in_set('1', project_attr)
  335. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  336. </select>
  337. <select id="countProjectMajorByQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  338. SELECT create_time columnName, COUNT(demand_id) num
  339. FROM `pm_demand`
  340. WHERE purchase_dept_id in
  341. <foreach collection="vo.deptList" item="item" index="index"
  342. separator="," open="(" close=")">
  343. #{item}
  344. </foreach>
  345. AND find_in_set('1', project_attr)
  346. and QUARTER(create_time) = #{quarter}
  347. AND DATE_FORMAT(create_time, '%Y') = #{year}
  348. </select>
  349. <!-- 正常推进项目 -->
  350. <select id="purchaseProjectExecuteNormalPropulsion" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  351. resultType="java.util.Map">
  352. select count(demand_id) countNormalPropulsion, ifnull(sum(evaluation), 0) evaluationNormalPropulsion
  353. from pm_demand
  354. where purchase_dept_id in
  355. <foreach collection="vo.deptList" item="item" index="index"
  356. separator="," open="(" close=")">
  357. #{item}
  358. </foreach>
  359. AND project_status !=21
  360. and (real_demand_commit_time > plan_demand_sub_time
  361. or real_purchase_finish_time > plan_purchase_finish_time
  362. or real_deliver_time > plan_deliver_time)
  363. </select>
  364. <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  365. resultType="java.util.Map">
  366. select count(demand_id) countIncomplete, ifnull(sum(evaluation), 0) evaluationIncomplete
  367. from pm_demand
  368. where purchase_dept_id in
  369. <foreach collection="vo.deptList" item="item" index="index"
  370. separator="," open="(" close=")">
  371. #{item}
  372. </foreach>
  373. AND project_status !=21
  374. </select>
  375. <select id="selectMinYear" resultType="java.lang.Integer">
  376. select min(year (plan_demand_sub_time))
  377. from pm_demand
  378. </select>
  379. <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  380. resultType="java.util.Map">
  381. select count(a.demand_id) countNum,
  382. ifnull(sum(a.evaluation), 0) evaluation,
  383. year(a.plan_demand_sub_time) yy,
  384. ifnull(sum(b.contract_amount), 0) contractAmount
  385. from (
  386. select evaluation, plan_demand_sub_time, demand_id
  387. from pm_demand
  388. where purchase_dept_id in
  389. <foreach collection="vo.deptList" item="item" index="index"
  390. separator="," open="(" close=")">
  391. #{item}
  392. </foreach>
  393. AND project_status = '21'
  394. ) a
  395. left join (
  396. select contract_amount, demand_id
  397. from pm_contract_info
  398. ) b on a.demand_id = b.demand_id
  399. group by year(plan_demand_sub_time)
  400. </select>
  401. <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  402. resultType="java.util.Map">
  403. select ifnull(sum(a.evaluation), 0) evaluation,
  404. quarter(a.plan_demand_sub_time) yy,
  405. ifnull(sum(b.contract_amount), 0) contractAmount
  406. from (
  407. select evaluation, plan_demand_sub_time, demand_id
  408. from pm_demand
  409. where purchase_dept_id in
  410. <foreach collection="vo.deptList" item="item" index="index"
  411. separator="," open="(" close=")">
  412. #{item}
  413. </foreach>
  414. AND project_status = '21'
  415. and year(plan_demand_sub_time) = year(NOW())
  416. ) a
  417. left join (
  418. select contract_amount, demand_id
  419. from pm_contract_info
  420. ) b on a.demand_id = b.demand_id
  421. group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  422. </select>
  423. <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  424. resultType="java.util.Map">
  425. select ifnull(sum(a.evaluation), 0) evaluation,
  426. date_format(plan_demand_sub_time, '%m') yy,
  427. ifnull(sum(b.contract_amount), 0) contractAmount
  428. from (
  429. select evaluation, plan_demand_sub_time, demand_id
  430. from pm_demand
  431. where purchase_dept_id in
  432. <foreach collection="vo.deptList" item="item" index="index"
  433. separator="," open="(" close=")">
  434. #{item}
  435. </foreach>
  436. AND project_status = '21'
  437. and year(plan_demand_sub_time) = year(NOW())
  438. ) a
  439. left join (
  440. select contract_amount, demand_id
  441. from pm_contract_info
  442. ) b on a.demand_id = b.demand_id
  443. group by date_format(a.plan_demand_sub_time, '%y%m')
  444. </select>
  445. <select id="selectPurchaseTaskFinishYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  446. resultType="java.util.Map">
  447. select count(a.demand_id) countNum,
  448. ifnull(sum(a.evaluation), 0) evaluation,
  449. year(a.plan_demand_sub_time) yy,
  450. ifnull(sum(b.contract_amount), 0) contractAmount
  451. from (
  452. select evaluation, plan_demand_sub_time, demand_id
  453. from pm_demand
  454. where purchase_dept_id in
  455. <foreach collection="vo.deptList" item="item" index="index"
  456. separator="," open="(" close=")">
  457. #{item}
  458. </foreach>
  459. AND project_status in (15, 16, 17)
  460. ) a
  461. left join (
  462. select contract_amount, demand_id
  463. from pm_contract_info
  464. ) b on a.demand_id = b.demand_id
  465. group by year(a.plan_demand_sub_time)
  466. </select>
  467. <select id="selectPurchaseTaskFinishQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  468. resultType="java.util.Map">
  469. select ifnull(sum(a.evaluation), 0) evaluation,
  470. quarter(a.plan_demand_sub_time) yy,
  471. ifnull(sum(b.contract_amount), 0) contractAmount
  472. from (
  473. select evaluation, plan_demand_sub_time, demand_id
  474. from pm_demand
  475. where purchase_dept_id in
  476. <foreach collection="vo.deptList" item="item" index="index"
  477. separator="," open="(" close=")">
  478. #{item}
  479. </foreach>
  480. AND project_status in (15, 16, 17)
  481. and year(plan_demand_sub_time) = year(NOW())
  482. ) a
  483. left join (
  484. select contract_amount, demand_id
  485. from pm_contract_info
  486. ) b on a.demand_id = b.demand_id
  487. group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  488. </select>
  489. <select id="selectPurchaseTaskFinishMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  490. resultType="java.util.Map">
  491. select ifnull(sum(a.evaluation), 0) evaluation,
  492. date_format(plan_demand_sub_time, '%m') yy,
  493. ifnull(sum(b.contract_amount), 0) contractAmount
  494. from (
  495. select evaluation, plan_demand_sub_time, demand_id
  496. from pm_demand
  497. where purchase_dept_id in
  498. <foreach collection="vo.deptList" item="item" index="index"
  499. separator="," open="(" close=")">
  500. #{item}
  501. </foreach>
  502. AND project_status in (15, 16, 17)
  503. and year(plan_demand_sub_time) = year(NOW())
  504. ) a
  505. left join (
  506. select contract_amount, demand_id
  507. from pm_contract_info
  508. ) b on a.demand_id = b.demand_id
  509. group by date_format(a.plan_demand_sub_time, '%y%m')
  510. </select>
  511. <select id="countProjectExceedAndMajor" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  512. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  513. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  514. FROM `pm_demand`
  515. WHERE (real_demand_commit_time > plan_demand_sub_time
  516. or real_purchase_finish_time > plan_purchase_finish_time
  517. or real_deliver_time > plan_deliver_time)
  518. AND find_in_set('1', project_attr)
  519. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  520. </select>
  521. <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  522. resultType="java.util.Map">
  523. select count(demand_id) countNumber from pm_demand where purchase_dept_id in
  524. <foreach collection="vo.deptList" item="item" index="index"
  525. separator="," open="(" close=")">
  526. #{item}
  527. </foreach>
  528. AND project_status in
  529. <foreach item="item" collection="vo.projectStatusList" separator="," open="(" close=")">
  530. #{item}
  531. </foreach>
  532. </select>
  533. <select id="purchaseProjectNumberAnalysisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  534. resultType="java.util.Map">
  535. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, year(plan_demand_sub_time) yy
  536. from pm_demand
  537. where purchase_dept_id in
  538. <foreach collection="vo.deptList" item="item" index="index"
  539. separator="," open="(" close=")">
  540. #{item}
  541. </foreach>
  542. group by year(plan_demand_sub_time)
  543. </select>
  544. <select id="purchaseProjectNumberAnalysisQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  545. resultType="java.util.Map">
  546. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
  547. from pm_demand
  548. where purchase_dept_id in
  549. <foreach collection="vo.deptList" item="item" index="index"
  550. separator="," open="(" close=")">
  551. #{item}
  552. </foreach>
  553. AND year(plan_demand_sub_time) = year(NOW())
  554. group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
  555. </select>
  556. <select id="purchaseProjectNumberAnalysisOldYearQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  557. resultType="java.util.Map">
  558. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
  559. from pm_demand
  560. where purchase_dept_id in
  561. <foreach collection="vo.deptList" item="item" index="index"
  562. separator="," open="(" close=")">
  563. #{item}
  564. </foreach>
  565. AND year(plan_demand_sub_time) = year(NOW() - 1)
  566. group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
  567. </select>
  568. <select id="purchaseProjectNumberAnalysisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  569. resultType="java.util.Map">
  570. select count(demand_id) countNum,
  571. ifnull(sum(evaluation), 0) evaluationSum,
  572. date_format(plan_demand_sub_time, '%m') yy
  573. from pm_demand
  574. where purchase_dept_id in
  575. <foreach collection="vo.deptList" item="item" index="index"
  576. separator="," open="(" close=")">
  577. #{item}
  578. </foreach>
  579. AND year(plan_demand_sub_time) = year(NOW())
  580. group by date_format(plan_demand_sub_time, '%y%m')
  581. </select>
  582. <select id="purchaseProjectNumberAnalysisOldYearMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  583. resultType="java.util.Map">
  584. select count(demand_id) countNum,
  585. ifnull(sum(evaluation), 0) evaluationSum,
  586. date_format(plan_demand_sub_time, '%m') yy
  587. from pm_demand
  588. where purchase_dept_id = #{purchaseDeptId}
  589. AND year(plan_demand_sub_time) = YEAR(NOW()) - 1
  590. group by date_format(plan_demand_sub_time, '%y%m')
  591. </select>
  592. <select id="selectSTSLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  593. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  594. FROM `pm_demand`
  595. WHERE purchase_dept_id in
  596. <foreach collection="vo.deptList" item="item" index="index"
  597. separator="," open="(" close=")">
  598. #{item}
  599. </foreach>
  600. AND `project_status` IN (6,7,8,9,10,11,12,13,14,15, 16, 17)
  601. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())-1
  602. </select>
  603. <select id="selectSTSThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  604. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  605. FROM `pm_demand`
  606. WHERE purchase_dept_id in
  607. <foreach collection="vo.deptList" item="item" index="index"
  608. separator="," open="(" close=")">
  609. #{item}
  610. </foreach>
  611. AND `project_status` &gt; 4
  612. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  613. </select>
  614. <select id="selectmeiJiDu" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  615. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  616. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  617. FROM `pm_demand`
  618. WHERE purchase_dept_id in
  619. <foreach collection="vo.deptList" item="item" index="index"
  620. separator="," open="(" close=")">
  621. #{item}
  622. </foreach>
  623. AND (real_demand_commit_time &gt; plan_demand_sub_time)
  624. </select>
  625. <select id="selectByProjectType" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  626. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  627. SELECT project_type columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  628. FROM `pm_demand`
  629. WHERE purchase_dept_id in
  630. <foreach collection="vo.deptList" item="item" index="index"
  631. separator="," open="(" close=")">
  632. #{item}
  633. </foreach>
  634. GROUP BY project_type
  635. </select>
  636. <select id="selectSTS" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  637. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  638. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  639. FROM `pm_demand`
  640. WHERE purchase_dept_id in
  641. <foreach collection="vo.deptList" item="item" index="index"
  642. separator="," open="(" close=")">
  643. #{item}
  644. </foreach>
  645. AND `project_status` &gt; 4
  646. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  647. </select>
  648. <select id="selectCGThisMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  649. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  650. SELECT MONTH(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  651. evaluationContractTotal
  652. FROM pm_demand d,pm_contract_info c,
  653. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  654. in
  655. <foreach collection="vo.deptList" item="item" index="index"
  656. separator="," open="(" close=")">
  657. #{item}
  658. </foreach>
  659. AND project_status &gt; 16 AND DATE_FORMAT(create_time, '%Y') =MONTH(NOW()) ) de
  660. where d.demand_id = c.demand_id and purchase_dept_id in
  661. <foreach collection="vo.deptList" item="item" index="index"
  662. separator="," open="(" close=")">
  663. #{item}
  664. </foreach>
  665. AND d.project_status &gt; 16
  666. AND DATE_FORMAT(d.create_time, '%Y') = MONTH(NOW())
  667. </select>
  668. <select id="selectCGThisQua" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  669. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  670. SELECT QUARTER(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  671. evaluationContractTotal
  672. FROM pm_demand d,pm_contract_info c,
  673. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  674. in
  675. <foreach collection="vo.deptList" item="item" index="index"
  676. separator="," open="(" close=")">
  677. #{item}
  678. </foreach>
  679. AND project_status &gt; 17 AND DATE_FORMAT(create_time, '%Y') =QUARTER(NOW()) ) de
  680. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  681. <foreach collection="vo.deptList" item="item" index="index"
  682. separator="," open="(" close=")">
  683. #{item}
  684. </foreach>
  685. AND d.project_status &gt; 17
  686. AND DATE_FORMAT(d.create_time, '%Y') = QUARTER(NOW())
  687. </select>
  688. <select id="selectZJLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  689. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  690. SELECT YEAR(NOW())-1 columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  691. evaluationContractTotal
  692. FROM pm_demand d, pm_contract_info c,
  693. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  694. in
  695. <foreach collection="vo.deptList" item="item" index="index"
  696. separator="," open="(" close=")">
  697. #{item}
  698. </foreach>
  699. AND project_status IN (17,18) AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())-1 ) de
  700. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  701. <foreach collection="vo.deptList" item="item" index="index"
  702. separator="," open="(" close=")">
  703. #{item}
  704. </foreach>
  705. AND d.project_status IN (17,18)
  706. AND DATE_FORMAT(d.create_time, '%Y') = YEAR(NOW())-1
  707. </select>
  708. <select id="selectTBThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  709. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  710. SELECT YEAR(NOW()) columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  711. evaluationContractTotal
  712. FROM pm_demand d, pm_contract_info c,
  713. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  714. in
  715. <foreach collection="vo.deptList" item="item" index="index"
  716. separator="," open="(" close=")">
  717. #{item}
  718. </foreach>
  719. AND project_status &gt; 17 AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW()) ) de
  720. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  721. <foreach collection="vo.deptList" item="item" index="index"
  722. separator="," open="(" close=")">
  723. #{item}
  724. </foreach>
  725. AND d.project_status &gt; 17
  726. AND DATE_FORMAT(d.create_time, '%Y') = YEAR(NOW())
  727. </select>
  728. <select id="selectCCThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  729. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  730. SELECT YEAR(NOW()) columnName,ifnull(demand_id, 0) num,ifnull(sum(evaluation), 0) evaluationTotal
  731. FROM pm_demand
  732. WHERE purchase_dept_id in
  733. <foreach collection="vo.deptList" item="item" index="index"
  734. separator="," open="(" close=")">
  735. #{item}
  736. </foreach>
  737. AND real_purchase_finish_time &lt;=plan_purchase_finish_time
  738. AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  739. </select>
  740. </mapper>