MCzglMapper.xml
6.57 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<?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.hotent.lpg.manage.dao.MCzglDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.hotent.lpg.common.model.WCzgl">
<id column="ID_" property="id"/>
<result column="REF_ID_" property="refId"/>
<result column="F_czsj" property="fCzsj"/>
<result column="F_czqzmc" property="fCzqzmc"/>
<result column="F_czxkzbh" property="fCzxkzbh"/>
<result column="F_czqz" property="fCzqz"/>
<result column="F_czhz" property="fCzhz"/>
<result column="F_czqwgjc" property="fCzqwgjc"/>
<result column="F_czqpfjc" property="fCzqpfjc"/>
<result column="F_czqfzjc" property="fCzqfzjc"/>
<result column="F_czqhjjc" property="fCzqhjjc"/>
<result column="F_czqjcxm" property="fCzqjcxm"/>
<result column="F_czqjcgh" property="fCzqjcgh"/>
<result column="F_czqczxm" property="fCzqczxm"/>
<result column="F_czqczgh" property="fCzqczgh"/>
<result column="F_czqjcsj" property="fCzqjcsj"/>
<result column="F_czhxljc" property="fCzhxljc"/>
<result column="F_czhpkjc" property="fCzhpkjc"/>
<result column="F_czhsjczl" property="fCzhsjczl"/>
<result column="F_czhfjjc" property="fCzhfjjc"/>
<result column="F_czhjsbq" property="fCzhjsbq"/>
<result column="F_czhxxbq" property="fCzhxxbq"/>
<result column="F_fcsj" property="fFcsj"/>
<result column="F_qplzID" property="fQplzid"/>
<result column="F_qptm" property="fQptm"/>
<result column="F_qpID" property="fQpid"/>
<result column="F_ssczmc" property="fSsczmc"/>
<result column="F_ssczID" property="fSsczid"/>
<result column="F_ssqymc" property="fSsqymc"/>
<result column="F_ssqyID" property="fSsqyid"/>
<result column="F_form_data_rev_" property="fFormDataRev"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
ID_,
REF_ID_,
F_czsj,
F_czqzmc,
F_czxkzbh,
F_czqz,
F_czhz,
F_czqwgjc,
F_czqpfjc,
F_czqfzjc,
F_czqhjjc,
F_czqjcxm,
F_czqjcgh,
F_czqczxm,
F_czqczgh,
F_czqjcsj,
F_czhxljc,
F_czhpkjc,
F_czhsjczl,
F_czhfjjc,
F_czhjsbq,
F_czhxxbq,
F_fcsj,
F_qplzID,
F_qptm,
F_qpID,
F_ssczmc,
F_ssczID,
F_ssqymc,
F_ssqyID,
F_form_data_rev_
</sql>
<select id="selectPage" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_czgl
${ew.customSqlSegment}
</select>
<select id="selectList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_czgl
${ew.customSqlSegment}
</select>
<select id="selectById" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from
w_czgl
where
ID_ = #{id}
</select>
<select id="page1" resultMap="BaseResultMap">
SELECT
*
FROM
w_czgl w_czgl
<where>
<if test="qptm != null and qptm != ''">
AND w_czgl.F_qptm = #{qptm}
</if>
</where>
ORDER BY w_czgl.F_czsj DESC
</select>
<select id="cpczPage" resultType="java.util.HashMap">
SELECT
w_qpxx.F_qpbh,
w_qpxx.F_ssczmc,
temp1.cs
FROM
(
SELECT
w_czgl.F_qpbh,
count(w_czgl.F_qpbh) AS cs
FROM w_czgl w_czgl
INNER JOIN w_qpxx w_qpxx ON w_qpxx.id_ = w_czgl.F_qpID
WHERE DATE_FORMAT(w_czgl.F_czsj,'%Y-%m-%d') BETWEEN #{query.startDate} AND #{query.endDate}
<if test="query.fSsczid != null and query.fSsczid != ''">
AND w_czgl.F_ssczID = #{query.fSsczid}
</if>
<if test="query.fQpbh != null and query.fQpbh != ''">
AND w_czgl.F_qpbh = #{query.fQpbh}
</if>
<if test="list != null and list.size() > 0">
AND w_czgl.F_ssczID IN
<foreach collection="list" separator="," item="czId" open="(" close=")">
#{czId}
</foreach>
</if>
GROUP BY w_czgl.F_qpbh
HAVING cs
<if test="query.operator == '1'.toString">
>=
</if>
<if test="query.operator == '2'.toString">
<=
</if>
<if test="query.operator == '3'.toString">
=
</if>
#{query.times}
) temp1
INNER JOIN w_qpxx w_qpxx ON temp1.F_qpbh = w_qpxx.F_qpbh
</select>
<select id="cpczmxPage" resultMap="BaseResultMap">
SELECT
*
FROM
w_czgl
WHERE
DATE_FORMAT( w_czgl.F_czsj, '%Y-%m-%d' ) BETWEEN #{query.startDate} AND #{query.endDate}
<if test="query.fQpbh != null and query.fQpbh != ''">
AND w_czgl.F_qpbh = #{query.fQpbh}
</if>
ORDER BY
w_czgl.F_czsj DESC
</select>
<select id="yearFilling" resultType="java.lang.Double">
select Round(ifnull(sum(F_czhsjczl),0.00),2) from w_czgl where F_ssczID = #{czId} and YEAR(F_czsj) = YEAR(SYSDATE())
</select>
<select id="monthFilling" resultType="java.lang.Double">
select Round(ifnull(sum(F_czhsjczl),0.00),2) from w_czgl where F_ssczID = #{czId} and MONTH(F_czsj) = MONTH(SYSDATE())
</select>
<select id="monthFillingOnMonth" resultType="java.lang.Double">
select
ROUND(ifnull(
ifnull(sum(case when MONTH(F_czsj) = MONTH(SYSDATE()) and year(F_czsj) = year(SYSDATE()) then F_czhsjczl else 0 end ),0.00)
/
ifnull(sum(case when MONTH(F_czsj) = MONTH(SYSDATE())-1 and year(F_czsj) = year(SYSDATE()) then F_czhsjczl else 0 end ),0.00)
,0),2)
from w_czgl where F_ssczID = #{czId}
</select>
<select id="allMonthFilling" resultType="java.util.HashMap">
SELECT
monthStr,
ROUND(ifnull((select sum(F_czhsjczl) from w_czgl where F_ssczID = #{czId} and YEAR(F_czsj) = YEAR(SYSDATE()) and MONTH(F_czsj) = monthStr),0.00),2) as monthFilling
FROM
(SELECT 1 monthStr UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9 UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12) t1
WHERE
monthStr <= MONTH(SYSDATE())
</select>
</mapper>