TaskStatisMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.sys.mapper.TaskStatisMapper">
  5. <!-- 按状态统计 -->
  6. <select id="counterByStatus" parameterType="java.util.Map" resultType="com.zhyc.xps.sys.vo.TaskCountByStatusVo">
  7. SELECT
  8. IFNULL(SUM( CASE WHEN A.status = 0 THEN 1 ELSE 0 END ) ,0) AS 'waiting',
  9. IFNULL(SUM( CASE WHEN A.status = 1 THEN 1 ELSE 0 END ) ,0) AS 'completed',
  10. IFNULL(SUM( CASE WHEN A.status = -1 THEN 1 ELSE 0 END ) ,0) AS 'canceled'
  11. FROM task AS A
  12. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id )
  13. LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.task_id = W.wf_ins_id)
  14. WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
  15. <if test="handleAccountId != null">
  16. AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
  17. </if>
  18. <if test="handleGroupId != null">
  19. AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
  20. </if>
  21. <if test="handlePositionId != null">
  22. AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
  23. </if>
  24. <if test="launchGroupId != null">
  25. AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
  26. </if>
  27. <if test="launchPositionId != null">
  28. AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
  29. </if>
  30. <if test="launchAccountId != null">
  31. AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
  32. </if>
  33. <if test="nodeLeft != null and nodeRight != null">
  34. <![CDATA[
  35. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  36. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  37. ]]>
  38. </if>
  39. </select>
  40. <!-- 按条件统计 -->
  41. <select id="counterByCondition" parameterType="java.util.Map" resultType="int">
  42. SELECT
  43. count(*)
  44. FROM task AS A
  45. LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.handle_group_id = C.group_id )
  46. LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.task_id = W.wf_ins_id )
  47. WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
  48. <if test="handleAccountId != null">
  49. AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
  50. </if>
  51. <if test="handleGroupId != null">
  52. AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
  53. </if>
  54. <if test="handlePositionId != null">
  55. AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
  56. </if>
  57. <if test="launchGroupId != null">
  58. AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
  59. </if>
  60. <if test="launchPositionId != null">
  61. AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
  62. </if>
  63. <if test="launchAccountId != null">
  64. AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
  65. </if>
  66. <if test="handleGroupNodeLeft != null and handleGroupNodeRight != null">
  67. <![CDATA[
  68. AND C.node_left >= #{handleGroupNodeLeft, jdbcType=BIGINT}
  69. AND C.node_right <= #{handleGroupNodeRight, jdbcType=BIGINT}
  70. ]]>
  71. </if>
  72. <if test="status != null">
  73. AND A.status = #{status}
  74. </if>
  75. </select>
  76. <!-- 按月份统计 -->
  77. <select id="counterByMonth" parameterType="java.util.Map" resultType="com.zhyc.xps.sys.vo.TaskCountByMonthVo">
  78. SELECT
  79. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '1' THEN 1 ELSE 0 END) ,0) AS Jan,
  80. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '2' THEN 1 ELSE 0 END) ,0) AS Feb,
  81. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '3' THEN 1 ELSE 0 END) ,0) AS Mar,
  82. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '4' THEN 1 ELSE 0 END) ,0) AS Apr,
  83. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '5' THEN 1 ELSE 0 END) ,0) AS May,
  84. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '6' THEN 1 ELSE 0 END) ,0) AS June,
  85. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '7' THEN 1 ELSE 0 END) ,0) AS July,
  86. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '8' THEN 1 ELSE 0 END) ,0) AS Aug,
  87. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '9' THEN 1 ELSE 0 END) ,0) AS Sept,
  88. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '10' THEN 1 ELSE 0 END) ,0) AS Oct,
  89. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '11' THEN 1 ELSE 0 END) ,0) AS Nov,
  90. IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '12' THEN 1 ELSE 0 END) ,0) AS Dece
  91. FROM task AS A
  92. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id)
  93. WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
  94. <if test="handleAccountId != null">
  95. AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
  96. </if>
  97. <if test="handleGroupId != null">
  98. AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
  99. </if>
  100. <if test="handlePositionId != null">
  101. AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
  102. </if>
  103. <if test="launchGroupId != null">
  104. AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
  105. </if>
  106. <if test="launchPositionId != null">
  107. AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
  108. </if>
  109. <if test="launchAccountId != null">
  110. AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
  111. </if>
  112. <if test="nodeLeft != null and nodeRight != null">
  113. <![CDATA[
  114. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  115. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  116. ]]>
  117. </if>
  118. <if test="status != null">
  119. AND A.status = #{status}
  120. </if>
  121. <if test="year != null">
  122. AND YEAR(launch_time) = #{year}
  123. </if>
  124. </select>
  125. </mapper>