TaskStatisticsMapper.xml
1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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.huaheng.pc.inventory.report.mapper.TaskStatisticsMapper">
<select id="select" resultType="com.huaheng.pc.inventory.report.domain.TaskStatisticsRep">
select d.created,
d.taskType,
IFNULL(count,0) count
FROM
(select created,taskType from (
(SELECT
@date := DATE_ADD( @date, INTERVAL + 1 DAY ) created
FROM
( SELECT @date := DATE_ADD( #{startTime}, INTERVAL - 1 DAY ) FROM task_header ) time
WHERE
to_days( @date ) < to_days( #{endTime} ) - 1) a INNER JOIN (select taskType from taskType) type ) where 1=1
<if test="taskType != null">
and taskType = #{taskType}
</if>
ORDER BY created,taskType) d
LEFT JOIN (
SELECT
DATE_FORMAT( created, '%Y-%m-%d' ) created,
taskType,
count(1) count
FROM
task_header b
GROUP BY
DATE_FORMAT( created, '%Y-%m-%d' ),
taskType
) t ON t.created = d.created and t.taskType = d.taskType
ORDER BY
d.created
</select>
</mapper>