InventoryTransactionsMapper.xml
1.73 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
38
39
40
41
42
43
44
45
46
47
48
<?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.InventoryTransactionsMapper">
<select id="select" resultType="com.huaheng.pc.inventory.report.domain.InventoryTransactionsRep">
select d.created,
d.transactionType,
IFNULL(taskQty,0) taskQty
FROM
(select created,transactionType from (
(SELECT
@date := DATE_ADD( @date, INTERVAL + 1 DAY ) created
FROM
( SELECT @date := DATE_ADD( #{startTime}, INTERVAL - 1 DAY ) FROM inventory_transaction ) time
WHERE
to_days( @date ) < to_days( #{endTime} ) - 1 ) a INNER JOIN (select transactionType from transactionType) type ) where 1=1
<if test="transactionType != null">
and transactionType = #{transactionType}
</if>
ORDER BY created,transactionType) d
LEFT JOIN (
SELECT
DATE_FORMAT( created, '%Y-%m-%d' ) created,
transactionType,
sum( taskQty ) taskQty
FROM
inventory_transaction b
GROUP BY
DATE_FORMAT( created, '%Y-%m-%d' ),
transactionType
) t ON t.created = d.created and t.transactionType = d.transactionType
ORDER BY
d.created
</select>
<select id="selectCount" resultType="com.huaheng.pc.inventory.report.domain.InventoryTransactionsRep">
SELECT
DATE_FORMAT( created, '%Y-%m-%d' ) created,
count( DISTINCT transactionType ) seriesLen
FROM
inventory_transaction
GROUP BY
DATE_FORMAT( created, '%Y-%m-%d' )
</select>
</mapper>