123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
- <mapper namespace="com.zhyc.xps.sys.mapper.TaskStatisMapper">
- <!-- 按状态统计 -->
- <select id="counterByStatus" parameterType="java.util.Map" resultType="com.zhyc.xps.sys.vo.TaskCountByStatusVo">
- SELECT
- IFNULL(SUM( CASE WHEN A.status = 0 THEN 1 ELSE 0 END ) ,0) AS 'waiting',
- IFNULL(SUM( CASE WHEN A.status = 1 THEN 1 ELSE 0 END ) ,0) AS 'completed',
- IFNULL(SUM( CASE WHEN A.status = -1 THEN 1 ELSE 0 END ) ,0) AS 'canceled'
- FROM task AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id )
- LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.task_id = W.wf_ins_id)
- WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
- <if test="handleAccountId != null">
- AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
- </if>
- <if test="handleGroupId != null">
- AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
- </if>
- <if test="handlePositionId != null">
- AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchGroupId != null">
- AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
- </if>
- <if test="launchPositionId != null">
- AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchAccountId != null">
- AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- </select>
- <!-- 按条件统计 -->
- <select id="counterByCondition" parameterType="java.util.Map" resultType="int">
- SELECT
- count(*)
- FROM task AS A
- LEFT JOIN s_group AS C ON (A.oc_id = C.oc_id AND A.handle_group_id = C.group_id )
- LEFT JOIN wf_ins AS W ON (A.oc_id = W.oc_id AND A.task_id = W.wf_ins_id )
- WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
- <if test="handleAccountId != null">
- AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
- </if>
- <if test="handleGroupId != null">
- AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
- </if>
- <if test="handlePositionId != null">
- AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchGroupId != null">
- AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
- </if>
- <if test="launchPositionId != null">
- AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchAccountId != null">
- AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
- </if>
- <if test="handleGroupNodeLeft != null and handleGroupNodeRight != null">
- <![CDATA[
- AND C.node_left >= #{handleGroupNodeLeft, jdbcType=BIGINT}
- AND C.node_right <= #{handleGroupNodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- <if test="status != null">
- AND A.status = #{status}
- </if>
- </select>
- <!-- 按月份统计 -->
- <select id="counterByMonth" parameterType="java.util.Map" resultType="com.zhyc.xps.sys.vo.TaskCountByMonthVo">
- SELECT
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '1' THEN 1 ELSE 0 END) ,0) AS Jan,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '2' THEN 1 ELSE 0 END) ,0) AS Feb,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '3' THEN 1 ELSE 0 END) ,0) AS Mar,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '4' THEN 1 ELSE 0 END) ,0) AS Apr,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '5' THEN 1 ELSE 0 END) ,0) AS May,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '6' THEN 1 ELSE 0 END) ,0) AS June,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '7' THEN 1 ELSE 0 END) ,0) AS July,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '8' THEN 1 ELSE 0 END) ,0) AS Aug,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '9' THEN 1 ELSE 0 END) ,0) AS Sept,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '10' THEN 1 ELSE 0 END) ,0) AS Oct,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '11' THEN 1 ELSE 0 END) ,0) AS Nov,
- IFNULL(SUM(CASE MONTH(A.launch_time) WHEN '12' THEN 1 ELSE 0 END) ,0) AS Dece
- FROM task AS A
- LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.handle_group_id = B.group_id)
- WHERE A.oc_id = #{ocId} AND A.deleted_flag = 0
- <if test="handleAccountId != null">
- AND A.handle_account_id = #{handleAccountId ,jdbcType=BIGINT}
- </if>
- <if test="handleGroupId != null">
- AND A.handle_group_id = #{handleGroupId ,jdbcType=BIGINT}
- </if>
- <if test="handlePositionId != null">
- AND A.handle_position_id = #{handlePositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchGroupId != null">
- AND A.launch_group_id = #{launchGroupId ,jdbcType=BIGINT}
- </if>
- <if test="launchPositionId != null">
- AND A.launch_position_id = #{launchPositionId ,jdbcType=BIGINT}
- </if>
- <if test="launchAccountId != null">
- AND A.launch_account_id = #{launchAccountId ,jdbcType=BIGINT}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND B.node_left >= #{nodeLeft ,jdbcType=BIGINT}
- AND B.node_right <= #{nodeRight ,jdbcType=BIGINT}
- ]]>
- </if>
- <if test="status != null">
- AND A.status = #{status}
- </if>
- <if test="year != null">
- AND YEAR(launch_time) = #{year}
- </if>
- </select>
- </mapper>
|