PmDemandMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 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
  15. <where>
  16. <if test="projectName != null and projectName != ''">
  17. and project_name like '%' + #{projectName} + '%'
  18. </if>
  19. <if test="startTime != null "><!-- 开始时间检索 -->
  20. and date_format(plan_demand_sub_time,'%y%m%d') &gt;= date_format(#{startTime},'%y%m%d')
  21. </if>
  22. <if test="endTime != null "><!-- 结束时间检索 -->
  23. and date_format(plan_demand_sub_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  24. </if>
  25. </where>
  26. </select>
  27. <select id="purchaseProjectStatistical" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  28. resultType="java.util.Map">
  29. select count(demand_id) countId
  30. from pm_demand
  31. </select>
  32. <select id="purchaseProjectStatisticalYWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  33. resultType="java.util.Map">
  34. select count(demand_id) countYWC, ifnull(sum(evaluation), 0) evaluationYWC
  35. from pm_demand
  36. where project_status = '17'
  37. </select>
  38. <select id="purchaseProjectStatisticalXCJ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  39. resultType="java.util.Map">
  40. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  41. select count(demand_id) countXCJ, ifnull(sum(evaluation), 0) evaluationXCJ
  42. from pm_demand
  43. where project_status != '17' and year(plan_demand_sub_time) = year(NOW())
  44. </select>
  45. <select id="purchaseProjectStatisticalQNWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  46. resultType="java.util.Map">
  47. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  48. select count(demand_id) countQNWC, ifnull(sum(evaluation), 0) evaluationQNWC
  49. from pm_demand
  50. where project_status != '17'
  51. and year(plan_demand_sub_time) = year(NOW()) - 1
  52. </select>
  53. <select id="countByProjectAttr" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  54. SELECT project_status columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  55. FROM `pm_demand`
  56. GROUP BY project_status
  57. </select>
  58. <select id="countByPurchaseMode" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  59. SELECT purchase_mode columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  60. FROM `pm_demand`
  61. GROUP BY purchase_mode
  62. </select>
  63. <select id="countByEvaluationLt" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  64. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  65. FROM `pm_demand`
  66. WHERE evaluation &lt; #{evaluation}
  67. </select>
  68. <select id="countByEvaluationBet" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  69. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  70. FROM `pm_demand`
  71. WHERE evaluation BETWEEN #{evaluation} and #{evaluationEnd}
  72. </select>
  73. <select id="countByEvaluationGt" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  74. parameterType="java.lang.Integer">
  75. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  76. FROM `pm_demand`
  77. WHERE evaluation &gt; #{evaluation}
  78. </select>
  79. <select id="countProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  80. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  81. FROM `pm_demand`
  82. WHERE (real_demand_commit_time > plan_demand_sub_time
  83. or real_purchase_finish_time > plan_purchase_finish_time
  84. or real_deliver_time > plan_deliver_time)
  85. and DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  86. </select>
  87. <select id="countThisYear" resultType="java.lang.Integer">
  88. SELECT COUNT(demand_id) num
  89. FROM `pm_demand`
  90. WHERE DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  91. </select>
  92. <select id="countProjectExceedYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  93. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  94. FROM `pm_demand`
  95. WHERE (real_demand_commit_time > plan_demand_sub_time
  96. or real_purchase_finish_time > plan_purchase_finish_time
  97. or real_deliver_time > plan_deliver_time)
  98. GROUP BY DATE_FORMAT(create_time, '%Y')
  99. order by create_time asc
  100. </select>
  101. <select id="countProjectExceedMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  102. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  103. FROM `pm_demand`
  104. WHERE (real_demand_commit_time > plan_demand_sub_time
  105. or real_purchase_finish_time > plan_purchase_finish_time
  106. or real_deliver_time > plan_deliver_time)
  107. and MONTH(create_time) = #{month}
  108. AND DATE_FORMAT(create_time, '%Y') = #{year}
  109. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  110. </select>
  111. <select id="countProjectExceedQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  112. SELECT DATE_FORMAT(create_time, '%Y-${quarter}季度') columnName, COUNT(demand_id) num
  113. FROM `pm_demand`
  114. WHERE (real_demand_commit_time > plan_demand_sub_time
  115. or real_purchase_finish_time > plan_purchase_finish_time
  116. or real_deliver_time > plan_deliver_time)
  117. and QUARTER(create_time) = #{quarter}
  118. AND DATE_FORMAT(create_time, '%Y') = #{year}
  119. </select>
  120. <select id="countProjectExceedAll" resultType="com.ozs.pm.doman.PmDemand">
  121. SELECT *
  122. FROM `pm_demand`
  123. WHERE (real_demand_commit_time > plan_demand_sub_time
  124. or real_purchase_finish_time > plan_purchase_finish_time
  125. or real_deliver_time > plan_deliver_time)
  126. </select>
  127. <select id="majorProjectByStatus" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  128. parameterType="java.lang.String">
  129. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  130. FROM `pm_demand`
  131. WHERE find_in_set('1', project_attr)
  132. AND `project_status` = #{code}
  133. AND DATE_FORMAT(create_time, '%Y') = year (now())
  134. </select>
  135. <select id="countMajorProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  136. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  137. FROM `pm_demand`
  138. WHERE (real_demand_commit_time > plan_demand_sub_time
  139. or real_purchase_finish_time > plan_purchase_finish_time
  140. or real_deliver_time > plan_deliver_time)
  141. AND find_in_set('1', project_attr)
  142. and DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  143. </select>
  144. <select id="taskQuantityYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  145. SELECT YEAR (NOW()) columnName, COUNT (demand_id) num
  146. FROM `pm_demand`
  147. WHERE find_in_set('1'
  148. , project_attr)
  149. AND `project_status` = #{code}
  150. and DATE_FORMAT(create_time
  151. , '%Y') = YEAR (NOW())
  152. </select>
  153. <select id="taskQuantityLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  154. parameterType="java.lang.String">
  155. SELECT YEAR (NOW()) - 1 columnName, COUNT (demand_id) num
  156. FROM `pm_demand`
  157. WHERE find_in_set('1'
  158. , project_attr)
  159. AND `project_status` = #{code}
  160. and DATE_FORMAT(create_time
  161. , '%Y') = YEAR(NOW()) - 1
  162. </select>
  163. <select id="countEveryStatusNum" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  164. SELECT project_status columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  165. FROM `pm_demand`
  166. WHERE `project_status` IN (9, 10, 11, 12, 13, 14)
  167. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  168. GROUP BY project_status
  169. </select>
  170. <select id="countEveryStatusNumTwo" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  171. SELECT project_status columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  172. FROM `pm_demand`
  173. WHERE `project_status` IN (15, 16, 17)
  174. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  175. GROUP BY project_status
  176. </select>
  177. <select id="selectByPlanId" parameterType="java.lang.Integer" resultType="com.ozs.pm.doman.PmDemand">
  178. select *
  179. from pm_demand
  180. where plan_id = #{planId}
  181. limit 1
  182. </select>
  183. <select id="countMajorProjectLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  184. SELECT YEAR(NOW()) - 1 columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  185. FROM `pm_demand`
  186. WHERE find_in_set('1', project_attr)
  187. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW()) - 1
  188. </select>
  189. <select id="countProjectMajorByYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  190. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  191. FROM `pm_demand`
  192. WHERE find_in_set('1', project_attr)
  193. GROUP BY DATE_FORMAT(create_time, '%Y')
  194. order by create_time asc
  195. </select>
  196. <select id="countProjectMajorByMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  197. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  198. FROM `pm_demand`
  199. WHERE find_in_set('1', project_attr)
  200. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  201. </select>
  202. <select id="countProjectMajorByQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  203. SELECT create_time columnName, COUNT(demand_id) num
  204. FROM `pm_demand`
  205. WHERE find_in_set('1', project_attr)
  206. and QUARTER(create_time) = #{quarter}
  207. AND DATE_FORMAT(create_time, '%Y') = #{year}
  208. </select>
  209. <!-- 正常推荐项目 -->
  210. <select id="purchaseProjectExecuteNormalPropulsion" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  211. resultType="java.util.Map">
  212. select count(demand_id) countNormalPropulsion, ifnull(sum(evaluation), 0) evaluationNormalPropulsion
  213. from pm_demand
  214. where project_status != '17'
  215. and (real_demand_commit_time > plan_demand_sub_time
  216. or real_purchase_finish_time > plan_purchase_finish_time
  217. or real_deliver_time > plan_deliver_time)
  218. </select>
  219. <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  220. resultType="java.util.Map">
  221. select count(demand_id) countIncomplete, ifnull(sum(evaluation), 0) evaluationIncomplete
  222. from pm_demand
  223. where project_status in (4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
  224. </select>
  225. <select id="selectMinYear" resultType="java.lang.Integer">
  226. select min(year (plan_demand_sub_time))
  227. from pm_demand
  228. </select>
  229. <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  230. resultType="java.util.Map">
  231. select count(demand_id) countNum, ifnull(sum(a.evaluation), 0) evaluation, year (a.plan_demand_sub_time) yy, ifnull(sum(b.contract_amount), 0) contractAmount
  232. from (
  233. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status = '17'
  234. ) a left join (
  235. select contract_amount, demand_id from pm_contract_info
  236. ) b on a.demand_id = b.demand_id
  237. group by year (a.plan_demand_sub_time)
  238. </select>
  239. <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  240. resultType="java.util.Map">
  241. select ifnull(sum(a.evaluation), 0) evaluation, quarter(a.plan_demand_sub_time) yy, ifnull(sum(b.contract_amount), 0) contractAmount from (
  242. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status = '17' and year (plan_demand_sub_time) = year(NOW())
  243. ) a left join (
  244. select contract_amount, demand_id from pm_contract_info
  245. ) b on a.demand_id = b.demand_id
  246. group by concat(Year (a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  247. </select>
  248. <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  249. resultType="java.util.Map">
  250. select ifnull(sum(a.evaluation), 0) evaluation,
  251. date_format(plan_demand_sub_time, '%m') yy,
  252. ifnull(sum(b.contract_amount), 0) contractAmount
  253. from (
  254. select evaluation, plan_demand_sub_time, demand_id
  255. from pm_demand
  256. where project_status = '17'
  257. and year(plan_demand_sub_time) = year(NOW())
  258. ) a
  259. left join (
  260. select contract_amount, demand_id
  261. from pm_contract_info
  262. ) b on a.demand_id = b.demand_id
  263. group by date_format(a.plan_demand_sub_time, '%y%m')
  264. </select>
  265. <select id="selectPurchaseTaskFinishYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  266. resultType="java.util.Map">
  267. select count(demand_id) countNum,
  268. ifnull(sum(a.evaluation), 0) evaluation,
  269. year(a.plan_demand_sub_time) yy,
  270. ifnull(sum(b.contract_amount), 0) contractAmount
  271. from (
  272. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status in (15, 16, 17)
  273. ) a
  274. left join (
  275. select contract_amount, demand_id
  276. from pm_contract_info
  277. ) b on a.demand_id = b.demand_id
  278. group by year(a.plan_demand_sub_time)
  279. </select>
  280. <select id="selectPurchaseTaskFinishQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  281. resultType="java.util.Map">
  282. select ifnull(sum(a.evaluation), 0) evaluation,
  283. quarter(a.plan_demand_sub_time) yy,
  284. ifnull(sum(b.contract_amount), 0) contractAmount
  285. from (
  286. select evaluation, plan_demand_sub_time, demand_id
  287. from pm_demand
  288. where project_status in (15, 16, 17)
  289. and year(plan_demand_sub_time) = year(NOW())
  290. ) a
  291. left join (
  292. select contract_amount, demand_id
  293. from pm_contract_info
  294. ) b on a.demand_id = b.demand_id
  295. group by concat(Year(a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  296. </select>
  297. <select id="selectPurchaseTaskFinishMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  298. resultType="java.util.Map">
  299. select ifnull(sum(a.evaluation), 0) evaluation,
  300. date_format(plan_demand_sub_time, '%m') yy,
  301. ifnull(sum(b.contract_amount), 0) contractAmount
  302. from (
  303. select evaluation, plan_demand_sub_time, demand_id
  304. from pm_demand
  305. where project_status in (15, 16, 17)
  306. and year(plan_demand_sub_time) = year(NOW())
  307. ) a
  308. left join (
  309. select contract_amount, demand_id
  310. from pm_contract_info
  311. ) b on a.demand_id = b.demand_id
  312. group by date_format(a.plan_demand_sub_time, '%y%m')
  313. </select>
  314. <select id="countProjectExceedAndMajor" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  315. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  316. FROM `pm_demand`
  317. WHERE (real_demand_commit_time > plan_demand_sub_time
  318. or real_purchase_finish_time > plan_purchase_finish_time
  319. or real_deliver_time > plan_deliver_time)
  320. AND find_in_set('1', project_attr)
  321. and DATE_FORMAT(create_time, '%Y') = YEAR(NOW())
  322. </select>
  323. <select id="purchaseProjectDistribution" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  324. resultType="java.util.Map">
  325. select count(demand_id) countNumber from pm_demand where project_status in
  326. <foreach item = "item" collection="projectStatusList" separator="," open="(" close=")">
  327. #{item}
  328. </foreach>
  329. </select>
  330. <select id="purchaseProjectNumberAnalysisYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  331. resultType="java.util.Map">
  332. select count(demand_id) countNum, year(plan_demand_sub_time) yy
  333. from pm_demand
  334. group by year (plan_demand_sub_time)
  335. </select>
  336. <select id="purchaseProjectNumberAnalysisQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  337. resultType="java.util.Map">
  338. select count(demand_id) countNum, quarter(plan_demand_sub_time) yy
  339. from pm_demand
  340. where year (plan_demand_sub_time) = year(NOW())
  341. group by concat(Year (plan_demand_sub_time), quarter(plan_demand_sub_time))
  342. </select>
  343. <select id="purchaseProjectNumberAnalysisMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  344. resultType="java.util.Map">
  345. select count(demand_id) countNum, date_format(plan_demand_sub_time, '%m') yy
  346. from pm_demand
  347. where year(plan_demand_sub_time) = year(NOW())
  348. group by date_format(plan_demand_sub_time, '%y%m')
  349. </select>
  350. </mapper>