CheckTaskStatisMapper.xml 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.aqpt.mapper.CheckTaskStatisMapper">
  5. <!-- 按状态统计 -->
  6. <select id="counterByStatus" parameterType="java.util.Map" resultType="com.zhyc.xps.aqpt.vo.CheckTaskCountByStatusVo">
  7. SELECT
  8. IFNULL(SUM( CASE WHEN M.check_status = 0 THEN 1 ELSE 0 END) ,0) AS 'waiting',
  9. IFNULL(SUM( CASE WHEN M.check_status = 1 THEN 1 ELSE 0 END) ,0) AS 'handling',
  10. IFNULL(SUM( CASE WHEN M.check_status = 2 THEN 1 ELSE 0 END) ,0) AS 'completed',
  11. IFNULL(SUM( CASE WHEN M.check_status = -1 THEN 1 ELSE 0 END) ,0) AS 'canceled'
  12. FROM check_task AS M
  13. LEFT JOIN task AS A ON (M.oc_id = A.oc_id AND M.task_id = A.task_id)
  14. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id)
  15. WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
  16. <if test="handleAccountId != null">
  17. AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
  18. </if>
  19. <if test="handleGroupId != null">
  20. AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
  21. </if>
  22. <if test="handlePositionId != null">
  23. AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
  24. </if>
  25. <if test="launchGroupId != null">
  26. AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
  27. </if>
  28. <if test="launchPositionId != null">
  29. AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
  30. </if>
  31. <if test="launchAccountId != null">
  32. AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
  33. </if>
  34. <if test="nodeLeft != null and nodeRight != null">
  35. <![CDATA[
  36. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  37. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  38. ]]>
  39. </if>
  40. <if test="checkStatus != null">
  41. AND M.check_status = #{checkStatus ,jdbcType=BIGINT}
  42. </if>
  43. </select>
  44. <!-- 按条件统计 -->
  45. <select id="counterByCondition" parameterType="java.util.Map" resultType="int">
  46. SELECT
  47. count(*)
  48. FROM check_task AS M
  49. LEFT JOIN task AS A ON (M.oc_id = A.oc_id AND M.task_id = A.task_id)
  50. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id)
  51. WHERE M.oc_id = #{ocId} AND M.deleted_flag = 0
  52. <if test="handleAccountId != null">
  53. AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
  54. </if>
  55. <if test="handleGroupId != null">
  56. AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
  57. </if>
  58. <if test="handlePositionId != null">
  59. AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
  60. </if>
  61. <if test="launchGroupId != null">
  62. AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
  63. </if>
  64. <if test="launchPositionId != null">
  65. AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
  66. </if>
  67. <if test="launchAccountId != null">
  68. AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
  69. </if>
  70. <if test="nodeLeft != null and nodeRight != null">
  71. <![CDATA[
  72. AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
  73. AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
  74. ]]>
  75. </if>
  76. <if test="checkStatus != null">
  77. AND M.check_status = #{checkStatus ,jdbcType=BIGINT}
  78. </if>
  79. </select>
  80. <!-- 按月份统计-->
  81. </mapper>