|
1
2
3
4
5
6
7
|
<?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.InventoryChangesMapper">
<select id="select" resultType="com.huaheng.pc.inventory.report.domain.InventoryChanges">
|
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
select a.created,IFNULL(count,0) count,materialCode from (
select DATE_FORMAT(d.m, '%Y-%m') created
from(
select
( #{startTime} - INTERVAL DAYOFMONTH(#{endTime})-1 DAY)
+INTERVAL m MONTH as m
from(
select @rownum:=@rownum+1 as m from
(select 1 union select 2 union select 3 union select 4) t1,
(select 1 union select 2 union select 3 union select 4) t2,
(select 1 union select 2 union select 3 union select 4) t3,
(select 1 union select 2 union select 3 union select 4) t4,
(select @rownum:=-1) t
) d1
) d
where m <= #{endTime}
order by created ) a left join
|
|
25
|
(SELECT
|
|
26
|
DATE_FORMAT( created, '%Y-%m' ) created,
|
|
27
28
29
|
sum( qty ) count,
materialCode
FROM
|
|
30
|
snapshot_inventory_detail where 1 = 1
|
|
31
32
33
|
<if test="materialCode != null">
and materialCode = #{materialCode}
</if>
|
|
34
35
|
GROUP BY DATE_FORMAT( created, '%Y-%m' )
) t on t.created = a.created
|
|
36
37
|
</select>
</mapper>
|