PmDemandMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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 = 15 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 project_status = 13
  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. </select>
  30. <select id="purchaseProjectStatisticalYWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  31. resultType="java.util.Map">
  32. select count(demand_id) countYWC, ifnull(sum(evaluation), 0) evaluationYWC
  33. from pm_demand
  34. where project_status = '17'
  35. </select>
  36. <select id="purchaseProjectStatisticalXCJ" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  37. resultType="java.util.Map">
  38. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  39. select count(demand_id) countXCJ, ifnull(sum(evaluation), 0) evaluationXCJ
  40. from pm_demand
  41. where project_status != '17' and year(plan_demand_sub_time) = year(NOW())
  42. </select>
  43. <select id="purchaseProjectStatisticalQNWC" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  44. resultType="java.util.Map">
  45. -- DATE_FORMAT(plan_demand_sub_time,'%Y')
  46. select count(demand_id) countQNWC, ifnull(sum(evaluation), 0) evaluationQNWC
  47. from pm_demand
  48. where project_status != '17' and year(plan_demand_sub_time) = year(NOW())-1
  49. </select>
  50. <select id="countByProjectAttr" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  51. SELECT project_status columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  52. FROM `pm_demand`
  53. GROUP BY project_status
  54. </select>
  55. <select id="countByEvaluationLt" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  56. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  57. FROM `pm_demand`
  58. WHERE evaluation &lt; #{evaluation}
  59. </select>
  60. <select id="countByEvaluationBet" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  61. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  62. FROM `pm_demand`
  63. WHERE evaluation BETWEEN #{evaluation} and #{evaluationEnd}
  64. </select>
  65. <select id="countByEvaluationGt" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  66. parameterType="java.lang.Integer">
  67. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  68. FROM `pm_demand`
  69. WHERE evaluation &gt; #{evaluation}
  70. </select>
  71. <select id="countProjectExceed" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  72. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  73. FROM `pm_demand`
  74. WHERE (real_demand_commit_time > plan_demand_sub_time
  75. or real_purchase_finish_time > plan_purchase_finish_time
  76. or real_deliver_time > plan_deliver_time)
  77. and DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  78. </select>
  79. <select id="countThisYear" resultType="java.lang.Integer">
  80. SELECT COUNT(demand_id) num
  81. FROM `pm_demand`
  82. WHERE DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  83. </select>
  84. <select id="countProjectExceedYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  85. SELECT DATE_FORMAT(create_time, '%Y') columnName, COUNT(demand_id) num
  86. FROM `pm_demand`
  87. WHERE (real_demand_commit_time > plan_demand_sub_time
  88. or real_purchase_finish_time > plan_purchase_finish_time
  89. or real_deliver_time > plan_deliver_time)
  90. GROUP BY DATE_FORMAT(create_time, '%Y')
  91. order by create_time asc
  92. </select>
  93. <select id="countProjectExceedMonth" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  94. SELECT DATE_FORMAT(create_time, '%Y-%m') columnName, COUNT(demand_id) num
  95. FROM `pm_demand`
  96. WHERE (real_demand_commit_time > plan_demand_sub_time
  97. or real_purchase_finish_time > plan_purchase_finish_time
  98. or real_deliver_time > plan_deliver_time)
  99. GROUP BY DATE_FORMAT(create_time, '%Y-%m')
  100. </select>
  101. <select id="countProjectExceedQuarter" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  102. SELECT create_time 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 QUARTER(create_time) = #{quarter}
  108. AND DATE_FORMAT(create_time, '%Y') = #{year}
  109. </select>
  110. <select id="countProjectExceedAll" resultType="com.ozs.pm.doman.PmDemand">
  111. SELECT *
  112. FROM `pm_demand`
  113. WHERE (real_demand_commit_time > plan_demand_sub_time
  114. or real_purchase_finish_time > plan_purchase_finish_time
  115. or real_deliver_time > plan_deliver_time)
  116. </select>
  117. <select id="majorProjectByStatus" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  118. parameterType="java.lang.String">
  119. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  120. FROM `pm_demand`
  121. WHERE find_in_set('1', project_attr)
  122. AND `project_status` = #{code}
  123. AND DATE_FORMAT(create_time, '%Y') = year (now())
  124. </select>
  125. <select id="countProjectExceedAndMajor" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  126. SELECT COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  127. FROM `pm_demand`
  128. WHERE (real_demand_commit_time > plan_demand_sub_time
  129. or real_purchase_finish_time > plan_purchase_finish_time
  130. or real_deliver_time > plan_deliver_time)
  131. AND find_in_set('1', project_attr)
  132. and DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  133. </select>
  134. <select id="taskQuantityYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  135. SELECT YEAR (NOW()) columnName, COUNT (demand_id) num
  136. FROM `pm_demand`
  137. WHERE find_in_set('1'
  138. , project_attr)
  139. AND `project_status` = #{code}
  140. and DATE_FORMAT(create_time
  141. , '%Y') = YEAR (NOW())
  142. </select>
  143. <select id="taskQuantityLastYear" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo"
  144. parameterType="java.lang.String">
  145. SELECT YEAR (NOW()) - 1 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()) - 1
  152. </select>
  153. <select id="countEveryStatusNum" resultType="com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo">
  154. SELECT project_status columnName, COUNT(demand_id) num, SUM(evaluation) evaluationTotal
  155. FROM `pm_demand`
  156. WHERE `project_status` IN (9, 10, 11, 12, 13, 14)
  157. and DATE_FORMAT(create_time, '%Y') = YEAR (NOW())
  158. GROUP BY project_status
  159. </select>
  160. <select id="selectByPlanId" parameterType="java.lang.Integer" resultType="com.ozs.pm.doman.PmDemand">
  161. select *
  162. from pm_demand
  163. where plan_id = #{planId} limit 1
  164. </select>
  165. <!-- 正常推荐项目 -->
  166. <select id="purchaseProjectExecuteNormalPropulsion" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  167. resultType="java.util.Map">
  168. select count(demand_id) countNormalPropulsion, ifnull(sum(evaluation), 0) evaluationNormalPropulsion
  169. from pm_demand
  170. where project_status != '17'
  171. and (real_demand_commit_time > plan_demand_sub_time
  172. or real_purchase_finish_time > plan_purchase_finish_time
  173. or real_deliver_time > plan_deliver_time)
  174. </select>
  175. <select id="purchaseProjectExecuteIncomplete" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  176. resultType="java.util.Map">
  177. select count(demand_id) countIncomplete, ifnull(sum(evaluation), 0) evaluationIncomplete
  178. from pm_demand
  179. where project_status in (4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)
  180. </select>
  181. <select id="selectMinYear" resultType="java.lang.Integer">
  182. select min(year (plan_demand_sub_time))
  183. from pm_demand
  184. </select>
  185. <select id="selectpurchaseProjectCompleteNumberYear" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  186. resultType="java.util.Map">
  187. select ifnull(sum(a.evaluation), 0) evaluation, year (a.plan_demand_sub_time) yy, ifnull(sum(b.contract_amount), 0) contractAmount
  188. from (
  189. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status = '17'
  190. ) a left join (
  191. select contract_amount, demand_id from pm_contract_info
  192. ) b on a.demand_id = b.demand_id
  193. group by year (a.plan_demand_sub_time)
  194. </select>
  195. <select id="selectpurchaseProjectCompleteNumberQuarter" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  196. resultType="java.util.Map">
  197. select ifnull(sum(a.evaluation), 0) evaluation, quarter(a.plan_demand_sub_time) yy, ifnull(sum(b.contract_amount), 0) contractAmount from (
  198. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status = '17' and year (plan_demand_sub_time) = year(NOW())
  199. ) a left join (
  200. select contract_amount, demand_id from pm_contract_info
  201. ) b on a.demand_id = b.demand_id
  202. group by concat(Year (a.plan_demand_sub_time), quarter(a.plan_demand_sub_time))
  203. </select>
  204. <select id="selectpurchaseProjectCompleteNumberMonth" parameterType="com.ozs.pm.doman.vo.requestVo.PmDemandReqVo"
  205. resultType="java.util.Map">
  206. select ifnull(sum(a.evaluation), 0) evaluation, date_format(plan_demand_sub_time,'%m') yy, ifnull(sum(b.contract_amount), 0) contractAmount from (
  207. select evaluation, plan_demand_sub_time, demand_id from pm_demand where project_status = '17' and year(plan_demand_sub_time) = year(NOW())
  208. ) a left join (
  209. select contract_amount, demand_id from pm_contract_info
  210. ) b on a.demand_id = b.demand_id
  211. group by date_format(a.plan_demand_sub_time,'%y%m')
  212. </select>
  213. </mapper>