PmDemandMapper.xml 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  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="countProjectExceedThisYear" 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 YEAR(create_time) = YEAR(NOW())
  155. </select>
  156. <select id="countProjectExceedThisQua" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  157. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  158. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  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 (real_demand_commit_time > plan_demand_sub_time
  166. or real_purchase_finish_time > plan_purchase_finish_time
  167. or real_deliver_time > plan_deliver_time)
  168. and quarter(create_time) = quarter(NOW())
  169. </select>
  170. <select id="countProjectExceedThisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  171. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  172. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  173. FROM `pm_demand`
  174. WHERE purchase_dept_id in
  175. <foreach collection="vo.deptList" item="item" index="index"
  176. separator="," open="(" close=")">
  177. #{item}
  178. </foreach>
  179. AND (real_demand_commit_time > plan_demand_sub_time
  180. or real_purchase_finish_time > plan_purchase_finish_time
  181. or real_deliver_time > plan_deliver_time)
  182. and MONTH(create_time) = MONTH(NOW())
  183. </select>
  184. <select id="countProjectExceedAllNum" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  185. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  186. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  187. FROM `pm_demand`
  188. WHERE purchase_dept_id in
  189. <foreach collection="vo.deptList" item="item" index="index"
  190. separator="," open="(" close=")">
  191. #{item}
  192. </foreach>
  193. AND (real_demand_commit_time > plan_demand_sub_time
  194. or real_purchase_finish_time > plan_purchase_finish_time
  195. or real_deliver_time > plan_deliver_time)
  196. </select>
  197. <select id="countThisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  198. resultType="java.lang.Integer">
  199. SELECT COUNT(demand_id) num
  200. FROM `pm_demand`
  201. WHERE purchase_dept_id in
  202. <foreach collection="vo.deptList" item="item" index="index"
  203. separator="," open="(" close=")">
  204. #{item}
  205. </foreach>
  206. AND YEAR(create_time) = YEAR(NOW())
  207. </select>
  208. <select id="countProjectExceedYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  209. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  210. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  211. FROM `pm_demand`
  212. WHERE purchase_dept_id in
  213. <foreach collection="vo.deptList" item="item" index="index"
  214. separator="," open="(" close=")">
  215. #{item}
  216. </foreach>
  217. AND (real_demand_commit_time > plan_demand_sub_time
  218. or real_purchase_finish_time > plan_purchase_finish_time
  219. or real_deliver_time > plan_deliver_time)
  220. GROUP BY DATE_FORMAT(create_time, '%Y')
  221. order by create_time asc
  222. </select>
  223. <select id="countProjectExceedMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  224. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  225. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  226. FROM `pm_demand`
  227. WHERE purchase_dept_id in
  228. <foreach collection="vo.deptList" item="item" index="index"
  229. separator="," open="(" close=")">
  230. #{item}
  231. </foreach>
  232. AND (real_demand_commit_time > plan_demand_sub_time
  233. or real_purchase_finish_time > plan_purchase_finish_time
  234. or real_deliver_time > plan_deliver_time)
  235. and MONTH(
  236. create_time) = #{vo.month}
  237. AND DATE_FORMAT(create_time
  238. , '%Y') = #{vo.year}
  239. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  240. </select>
  241. <select id="countProjectExceedQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  242. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  243. SELECT DATE_FORMAT(create_time, '%Y-${quarter}季度') columnName, COUNT(demand_id) num
  244. FROM `pm_demand`
  245. WHERE purchase_dept_id in
  246. <foreach collection="vo.deptList" item="item" index="index"
  247. separator="," open="(" close=")">
  248. #{item}
  249. </foreach>
  250. AND (real_demand_commit_time > plan_demand_sub_time
  251. or real_purchase_finish_time > plan_purchase_finish_time
  252. or real_deliver_time > plan_deliver_time)
  253. and QUARTER(create_time) = #{vo.quarter}
  254. AND DATE_FORMAT(create_time, '%Y') = #{vo.year}
  255. </select>
  256. <select id="countProjectExceedAll" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  257. resultType="com.ozs.pm.doman.PmDemand">
  258. SELECT *
  259. FROM `pm_demand`
  260. WHERE purchase_dept_id in
  261. <foreach collection="vo.deptList" item="item" index="index"
  262. separator="," open="(" close=")">
  263. #{item}
  264. </foreach>
  265. AND (real_demand_commit_time > plan_demand_sub_time
  266. or real_purchase_finish_time > plan_purchase_finish_time
  267. or real_deliver_time > plan_deliver_time)
  268. </select>
  269. <select id="majorProjectByStatus" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  270. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  271. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  272. FROM `pm_demand`
  273. WHERE purchase_dept_id in
  274. <foreach collection="vo.deptList" item="item" index="index"
  275. separator="," open="(" close=")">
  276. #{item}
  277. </foreach>
  278. AND find_in_set('1', project_attr)
  279. AND `project_status` = #{vo.projectStatus}
  280. AND YEAR(create_time ) = year(now())
  281. </select>
  282. <select id="countMajorProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  283. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  284. FROM `pm_demand`
  285. WHERE purchase_dept_id in
  286. <foreach collection="vo.deptList" item="item" index="index"
  287. separator="," open="(" close=")">
  288. #{item}
  289. </foreach>
  290. AND (real_demand_commit_time > plan_demand_sub_time
  291. or real_purchase_finish_time > plan_purchase_finish_time
  292. or real_deliver_time > plan_deliver_time)
  293. AND find_in_set('1', project_attr)
  294. and YEAR(create_time ) = YEAR(NOW())
  295. </select>
  296. <select id="taskQuantityYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  297. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  298. SELECT YEAR(NOW()) columnName, COUNT(demand_id) num
  299. FROM `pm_demand`
  300. WHERE find_in_set('1'
  301. , project_attr)
  302. AND `project_status` = #{code}
  303. and YEAR(create_time) = YEAR(NOW())
  304. </select>
  305. <select id="taskQuantityLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  306. parameterType="java.lang.String">
  307. SELECT YEAR(NOW()) - 1 columnName, COUNT(demand_id) num
  308. FROM `pm_demand`
  309. WHERE find_in_set('1'
  310. , project_attr)
  311. AND `project_status` = #{code}
  312. and YEAR(create_time) = YEAR(NOW()) - 1
  313. </select>
  314. <select id="countEveryStatusNum" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  315. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  316. SELECT project_status columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  317. FROM `pm_demand`
  318. WHERE purchase_dept_id in
  319. <foreach collection="vo.deptList" item="item" index="index"
  320. separator="," open="(" close=")">
  321. #{item}
  322. </foreach>
  323. AND `project_status` IN (9, 10, 11, 12, 13, 14,15,16,17)
  324. and YEAR(create_time) = YEAR(NOW())
  325. GROUP BY project_status
  326. </select>
  327. <select id="selectByPlanId" parameterType="java.lang.Long" resultType="com.ozs.pm.doman.PmDemand">
  328. select *
  329. from pm_demand
  330. where plan_id = #{planId} limit 1
  331. </select>
  332. <select id="countMajorProjectLastYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  333. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  334. # AND find_in_set('1', project_attr)
  335. SELECT YEAR(NOW()) - 1 columnName, de.num, ifnull(sum(c.contract_amount), 0) evaluationContractTotal
  336. FROM pm_demand d, pm_contract_info c,
  337. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  338. in
  339. <foreach collection="vo.deptList" item="item" index="index"
  340. separator="," open="(" close=")">
  341. #{item}
  342. </foreach>
  343. AND find_in_set('1', project_attr) AND YEAR(create_time) =YEAR(NOW()) - 1 ) de
  344. WHERE d.demand_id = c.demand_id
  345. AND find_in_set('1', d.project_attr)
  346. AND d.purchase_dept_id in
  347. <foreach collection="vo.deptList" item="item" index="index"
  348. separator="," open="(" close=")">
  349. #{item}
  350. </foreach>
  351. AND YEAR(d.create_time) = YEAR(NOW()) - 1
  352. </select>
  353. <select id="countProjectMajorByYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  354. SELECT YEAR(create_time) columnName, COUNT(demand_id) num
  355. FROM `pm_demand`
  356. WHERE purchase_dept_id in
  357. <foreach collection="vo.deptList" item="item" index="index"
  358. separator="," open="(" close=")">
  359. #{item}
  360. </foreach>
  361. AND find_in_set('1', project_attr)
  362. GROUP BY YEAR(create_time)
  363. order by create_time asc
  364. </select>
  365. <select id="countProjectMajorByMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  366. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  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 find_in_set('1', project_attr)
  374. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  375. </select>
  376. <select id="countProjectMajorByQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  377. SELECT create_time columnName, COUNT(demand_id) num
  378. FROM `pm_demand`
  379. WHERE purchase_dept_id in
  380. <foreach collection="vo.deptList" item="item" index="index"
  381. separator="," open="(" close=")">
  382. #{item}
  383. </foreach>
  384. AND find_in_set('1', project_attr)
  385. and QUARTER(create_time) = #{quarter}
  386. AND YEAR(create_time) = #{year}
  387. </select>
  388. <!-- 正常推进项目 -->
  389. <select id="purchaseProjectExecuteNormalPropulsion" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  390. resultType="java.util.Map">
  391. select count(demand_id) countNormalPropulsion, ifnull(sum(evaluation), 0) evaluationNormalPropulsion
  392. from pm_demand
  393. where purchase_dept_id in
  394. <foreach collection="vo.deptList" item="item" index="index"
  395. separator="," open="(" close=")">
  396. #{item}
  397. </foreach>
  398. AND project_status !=21
  399. and (real_demand_commit_time > plan_demand_sub_time
  400. or real_purchase_finish_time > plan_purchase_finish_time
  401. or real_deliver_time > plan_deliver_time)
  402. </select>
  403. <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  404. resultType="java.util.Map">
  405. select count(demand_id) countIncomplete, ifnull(sum(evaluation), 0) evaluationIncomplete
  406. from pm_demand
  407. where purchase_dept_id in
  408. <foreach collection="vo.deptList" item="item" index="index"
  409. separator="," open="(" close=")">
  410. #{item}
  411. </foreach>
  412. AND project_status !=21
  413. </select>
  414. <select id="selectMinYear" resultType="java.lang.Integer">
  415. select min(year (plan_demand_sub_time))
  416. from pm_demand
  417. </select>
  418. <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  419. resultType="java.util.Map">
  420. select count(a.demand_id) countNum,
  421. ifnull(sum(a.evaluation), 0) evaluation,
  422. year(a.plan_demand_sub_time) yy,
  423. ifnull(sum(b.contract_amount), 0) contractAmount
  424. from (
  425. select evaluation, plan_demand_sub_time, demand_id
  426. from pm_demand
  427. where purchase_dept_id in
  428. <foreach collection="vo.deptList" item="item" index="index"
  429. separator="," open="(" close=")">
  430. #{item}
  431. </foreach>
  432. AND project_status = '21'
  433. ) a
  434. left join (
  435. select contract_amount, demand_id
  436. from pm_contract_info
  437. ) b on a.demand_id = b.demand_id
  438. group by year(plan_demand_sub_time)
  439. </select>
  440. <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  441. resultType="java.util.Map">
  442. select ifnull(sum(a.evaluation), 0) evaluation,
  443. quarter(a.plan_demand_sub_time) yy,
  444. ifnull(sum(b.contract_amount), 0) contractAmount
  445. from (
  446. select evaluation, plan_demand_sub_time, demand_id
  447. from pm_demand
  448. where purchase_dept_id in
  449. <foreach collection="vo.deptList" item="item" index="index"
  450. separator="," open="(" close=")">
  451. #{item}
  452. </foreach>
  453. AND project_status = '21'
  454. and year(plan_demand_sub_time) = year(NOW())
  455. ) a
  456. left join (
  457. select contract_amount, demand_id
  458. from pm_contract_info
  459. ) b on a.demand_id = b.demand_id
  460. group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  461. </select>
  462. <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  463. resultType="java.util.Map">
  464. select ifnull(sum(a.evaluation), 0) evaluation,
  465. date_format(plan_demand_sub_time, '%m') yy,
  466. ifnull(sum(b.contract_amount), 0) contractAmount
  467. from (
  468. select evaluation, plan_demand_sub_time, demand_id
  469. from pm_demand
  470. where purchase_dept_id in
  471. <foreach collection="vo.deptList" item="item" index="index"
  472. separator="," open="(" close=")">
  473. #{item}
  474. </foreach>
  475. AND project_status = '21'
  476. and year(plan_demand_sub_time) = year(NOW())
  477. ) a
  478. left join (
  479. select contract_amount, demand_id
  480. from pm_contract_info
  481. ) b on a.demand_id = b.demand_id
  482. group by date_format(a.plan_demand_sub_time, '%y%m')
  483. </select>
  484. <select id="selectPurchaseTaskFinishYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  485. resultType="java.util.Map">
  486. select count(a.demand_id) countNum,
  487. ifnull(sum(a.evaluation), 0) evaluation,
  488. year(a.plan_demand_sub_time) yy,
  489. ifnull(sum(b.contract_amount), 0) contractAmount
  490. from (
  491. select evaluation, plan_demand_sub_time, demand_id
  492. from pm_demand
  493. where purchase_dept_id in
  494. <foreach collection="vo.deptList" item="item" index="index"
  495. separator="," open="(" close=")">
  496. #{item}
  497. </foreach>
  498. AND project_status in (15, 16, 17)
  499. ) a
  500. left join (
  501. select contract_amount, demand_id
  502. from pm_contract_info
  503. ) b on a.demand_id = b.demand_id
  504. group by year(a.plan_demand_sub_time)
  505. </select>
  506. <select id="selectPurchaseTaskFinishQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  507. resultType="java.util.Map">
  508. select ifnull(sum(a.evaluation), 0) evaluation,
  509. quarter(a.plan_demand_sub_time) yy,
  510. ifnull(sum(b.contract_amount), 0) contractAmount
  511. from (
  512. select evaluation, plan_demand_sub_time, demand_id
  513. from pm_demand
  514. where purchase_dept_id in
  515. <foreach collection="vo.deptList" item="item" index="index"
  516. separator="," open="(" close=")">
  517. #{item}
  518. </foreach>
  519. AND project_status in (15, 16, 17)
  520. and year(plan_demand_sub_time) = year(NOW())
  521. ) a
  522. left join (
  523. select contract_amount, demand_id
  524. from pm_contract_info
  525. ) b on a.demand_id = b.demand_id
  526. group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  527. </select>
  528. <select id="selectPurchaseTaskFinishMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  529. resultType="java.util.Map">
  530. select ifnull(sum(a.evaluation), 0) evaluation,
  531. date_format(plan_demand_sub_time, '%m') yy,
  532. ifnull(sum(b.contract_amount), 0) contractAmount
  533. from (
  534. select evaluation, plan_demand_sub_time, demand_id
  535. from pm_demand
  536. where purchase_dept_id in
  537. <foreach collection="vo.deptList" item="item" index="index"
  538. separator="," open="(" close=")">
  539. #{item}
  540. </foreach>
  541. AND project_status in (15, 16, 17)
  542. and year(plan_demand_sub_time) = year(NOW())
  543. ) a
  544. left join (
  545. select contract_amount, demand_id
  546. from pm_contract_info
  547. ) b on a.demand_id = b.demand_id
  548. group by date_format(a.plan_demand_sub_time, '%y%m')
  549. </select>
  550. <select id="countProjectExceedAndMajor" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  551. resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  552. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  553. FROM `pm_demand`
  554. WHERE (real_demand_commit_time > plan_demand_sub_time
  555. or real_purchase_finish_time > plan_purchase_finish_time
  556. or real_deliver_time > plan_deliver_time)
  557. AND find_in_set('1', project_attr)
  558. and YEAR(create_time) = YEAR(NOW())
  559. </select>
  560. <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  561. resultType="java.util.Map">
  562. select count(demand_id) countNumber from pm_demand where purchase_dept_id in
  563. <foreach collection="vo.deptList" item="item" index="index"
  564. separator="," open="(" close=")">
  565. #{item}
  566. </foreach>
  567. AND project_status in
  568. <foreach item="item" collection="vo.projectStatusList" separator="," open="(" close=")">
  569. #{item}
  570. </foreach>
  571. </select>
  572. <select id="purchaseProjectNumberAnalysisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  573. resultType="java.util.Map">
  574. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, year(plan_demand_sub_time) yy
  575. from pm_demand
  576. where purchase_dept_id in
  577. <foreach collection="vo.deptList" item="item" index="index"
  578. separator="," open="(" close=")">
  579. #{item}
  580. </foreach>
  581. group by year(plan_demand_sub_time)
  582. </select>
  583. <select id="purchaseProjectNumberAnalysisQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  584. resultType="java.util.Map">
  585. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
  586. from pm_demand
  587. where purchase_dept_id in
  588. <foreach collection="vo.deptList" item="item" index="index"
  589. separator="," open="(" close=")">
  590. #{item}
  591. </foreach>
  592. AND year(plan_demand_sub_time) = year(NOW())
  593. group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
  594. </select>
  595. <select id="purchaseProjectNumberAnalysisOldYearQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  596. resultType="java.util.Map">
  597. select count(demand_id) countNum, ifnull(sum(evaluation), 0) evaluationSum, quarter(plan_demand_sub_time) yy
  598. from pm_demand
  599. where purchase_dept_id in
  600. <foreach collection="vo.deptList" item="item" index="index"
  601. separator="," open="(" close=")">
  602. #{item}
  603. </foreach>
  604. AND year(plan_demand_sub_time) = year(NOW() - 1)
  605. group by concat(Year(plan_demand_sub_time), quarter(plan_demand_sub_time))
  606. </select>
  607. <select id="purchaseProjectNumberAnalysisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  608. resultType="java.util.Map">
  609. select count(demand_id) countNum,
  610. ifnull(sum(evaluation), 0) evaluationSum,
  611. date_format(plan_demand_sub_time, '%m') yy
  612. from pm_demand
  613. where purchase_dept_id in
  614. <foreach collection="vo.deptList" item="item" index="index"
  615. separator="," open="(" close=")">
  616. #{item}
  617. </foreach>
  618. AND year(plan_demand_sub_time) = year(NOW())
  619. group by date_format(plan_demand_sub_time, '%y%m')
  620. </select>
  621. <select id="purchaseProjectNumberAnalysisOldYearMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  622. resultType="java.util.Map">
  623. select count(demand_id) countNum,
  624. ifnull(sum(evaluation), 0) evaluationSum,
  625. date_format(plan_demand_sub_time, '%m') yy
  626. from pm_demand
  627. where purchase_dept_id = #{purchaseDeptId}
  628. AND year(plan_demand_sub_time) = YEAR(NOW()) - 1
  629. group by date_format(plan_demand_sub_time, '%y%m')
  630. </select>
  631. <select id="selectSTSLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  632. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  633. FROM `pm_demand`
  634. WHERE purchase_dept_id in
  635. <foreach collection="vo.deptList" item="item" index="index"
  636. separator="," open="(" close=")">
  637. #{item}
  638. </foreach>
  639. AND `project_status` IN (6,7,8,9,10,11,12,13,14,15, 16, 17)
  640. and YEAR(create_time) = YEAR(NOW())-1
  641. </select>
  642. <select id="selectSTSThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  643. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  644. FROM `pm_demand`
  645. WHERE purchase_dept_id in
  646. <foreach collection="vo.deptList" item="item" index="index"
  647. separator="," open="(" close=")">
  648. #{item}
  649. </foreach>
  650. AND `project_status` &gt; 4
  651. and YEAR(create_time) = YEAR(NOW())
  652. </select>
  653. <select id="selectmeiJiDu" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  654. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  655. SELECT COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  656. FROM `pm_demand`
  657. WHERE purchase_dept_id in
  658. <foreach collection="vo.deptList" item="item" index="index"
  659. separator="," open="(" close=")">
  660. #{item}
  661. </foreach>
  662. AND (real_demand_commit_time &gt; plan_demand_sub_time)
  663. </select>
  664. <select id="selectByProjectType" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  665. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  666. SELECT project_type columnName, COUNT(demand_id) num, ifnull(sum(evaluation), 0) evaluationTotal
  667. FROM `pm_demand`
  668. WHERE purchase_dept_id in
  669. <foreach collection="vo.deptList" item="item" index="index"
  670. separator="," open="(" close=")">
  671. #{item}
  672. </foreach>
  673. GROUP BY project_type
  674. </select>
  675. <select id="selectSTS" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  676. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  677. SELECT ifnull(COUNT(demand_id),0)num, ifnull(sum(evaluation),0) evaluationTotal
  678. FROM `pm_demand`
  679. WHERE purchase_dept_id in
  680. <foreach collection="vo.deptList" item="item" index="index"
  681. separator="," open="(" close=")">
  682. #{item}
  683. </foreach>
  684. AND `project_status` &gt; 4
  685. and YEAR(create_time) = YEAR(NOW())
  686. </select>
  687. <select id="selectCGThisMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  688. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  689. SELECT MONTH(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  690. evaluationContractTotal
  691. FROM pm_demand d,pm_contract_info c,
  692. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  693. in
  694. <foreach collection="vo.deptList" item="item" index="index"
  695. separator="," open="(" close=")">
  696. #{item}
  697. </foreach>
  698. AND project_status &gt; 16 AND MONTH(create_time) =MONTH(NOW()) ) de
  699. where d.demand_id = c.demand_id and purchase_dept_id in
  700. <foreach collection="vo.deptList" item="item" index="index"
  701. separator="," open="(" close=")">
  702. #{item}
  703. </foreach>
  704. AND d.project_status &gt; 16
  705. AND MONTH(d.create_time) = MONTH(NOW())
  706. </select>
  707. <select id="selectCGThisQua" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  708. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  709. SELECT QUARTER(NOW()) columnName, de.num, de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  710. evaluationContractTotal
  711. FROM pm_demand d,pm_contract_info c,
  712. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  713. in
  714. <foreach collection="vo.deptList" item="item" index="index"
  715. separator="," open="(" close=")">
  716. #{item}
  717. </foreach>
  718. AND project_status &gt; 17 AND QUARTER(create_time) =QUARTER(NOW()) ) de
  719. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  720. <foreach collection="vo.deptList" item="item" index="index"
  721. separator="," open="(" close=")">
  722. #{item}
  723. </foreach>
  724. AND d.project_status &gt; 17
  725. AND QUARTER(d.create_time) = QUARTER(NOW())
  726. </select>
  727. <select id="selectZJLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  728. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  729. SELECT YEAR(NOW())-1 columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  730. evaluationContractTotal
  731. FROM pm_demand d, pm_contract_info c,
  732. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  733. in
  734. <foreach collection="vo.deptList" item="item" index="index"
  735. separator="," open="(" close=")">
  736. #{item}
  737. </foreach>
  738. AND project_status IN (17,18) AND YEAR(create_time) = YEAR(NOW())-1 ) de
  739. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  740. <foreach collection="vo.deptList" item="item" index="index"
  741. separator="," open="(" close=")">
  742. #{item}
  743. </foreach>
  744. AND d.project_status IN (17,18)
  745. AND YEAR(d.create_time) = YEAR(NOW())-1
  746. </select>
  747. <select id="selectTBThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  748. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  749. SELECT YEAR(NOW()) columnName, de.num,de.evaluationTotal,ifnull(sum(c.contract_amount), 0)
  750. evaluationContractTotal
  751. FROM pm_demand d, pm_contract_info c,
  752. (SELECT COUNT(demand_id) num ,ifnull(sum(evaluation), 0) evaluationTotal FROM pm_demand WHERE purchase_dept_id
  753. in
  754. <foreach collection="vo.deptList" item="item" index="index"
  755. separator="," open="(" close=")">
  756. #{item}
  757. </foreach>
  758. AND project_status &gt; 17 AND YEAR(create_time) = YEAR(NOW()) ) de
  759. WHERE d.demand_id = c.demand_id and purchase_dept_id in
  760. <foreach collection="vo.deptList" item="item" index="index"
  761. separator="," open="(" close=")">
  762. #{item}
  763. </foreach>
  764. AND d.project_status &gt; 17
  765. AND YEAR(d.create_time) = YEAR(NOW())
  766. </select>
  767. <select id="selectCCThisYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  768. parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo">
  769. SELECT YEAR(NOW()) columnName,ifnull(demand_id, 0) num,ifnull(sum(evaluation), 0) evaluationTotal
  770. FROM pm_demand
  771. WHERE purchase_dept_id in
  772. <foreach collection="vo.deptList" item="item" index="index"
  773. separator="," open="(" close=")">
  774. #{item}
  775. </foreach>
  776. AND real_purchase_finish_time &lt;=plan_purchase_finish_time
  777. AND DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  778. </select>
  779. </mapper>