McBasicMoneyMapper.xml
27.8 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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?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.chinagas.modules.schsf.mapper.McBasicMoneyMapper">
<resultMap type="com.chinagas.modules.schsf.domain.McBasicMoney" id="McBasicMoneyResult">
<result property="id" column="id" />
<result property="fiscalYear" column="fiscal_year" />
<result property="regionName" column="region_name" />
<result property="groupName" column="group_name" />
<result property="companyName" column="company_name" />
<result property="companyCode" column="company_code" />
<result property="province" column="province" />
<result property="city" column="city" />
<result property="district" column="district" />
<result property="street" column="street" />
<result property="vlgOrCmty" column="vlg_or_cmty" />
<result property="respPerson" column="resp_person" />
<result property="urbRurCls" column="urb_rur_cls" />
<result property="budgConfPrev" column="budg_conf_prev" />
<result property="budgConfNew" column="budg_conf_new" />
<result property="budgTotal" column="budg_total" />
<result property="quarterlyTarget" column="quarterly_target" />
<result property="cnyGsgCharged" column="cny_gsg_charged" />
<result property="cnyGsgUncharged" column="cny_gsg_uncharged" />
<result property="cnyGsgTotal" column="cny_gsg_total" />
<result property="cnyYrFull" column="cny_yr_full" />
<result property="cnyYrInstal" column="cny_yr_instal" />
<result property="cnyPrevFull" column="cny_prev_full" />
<result property="cnyPrevInstall" column="cny_prev_install" />
<result property="cnyMarketCumr" column="cny_market_cumr" />
<result property="cnyFyCumReturn" column="cny_fy_cum_return" />
<result property="cnyFpCumReturn" column="cny_fp_cum_return" />
<result property="cnyInstCumReturn" column="cny_inst_cum_return" />
<result property="cnyNewCumReturn" column="cny_new_cum_return" />
<result property="cnyRcvblsCumReturn" column="cny_rcvbls_cum_return" />
<result property="cnyBdgtCmplRate" column="cny_bdgt_cmpl_rate" />
<result property="cnyRcvblsCmplRate" column="cny_rcvbls_cmpl_rate" />
<result property="cnyCynCmplRate" column="cny_cyn_cmpl_rate" />
<result property="cnyPtCmplRate" column="cny_pt_cmpl_rate" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="defFlag" column="def_flag" />
</resultMap>
<sql id="selectMcBasicMoneyVo">
select t.id, t.fiscal_year, t.region_name, t.group_name, t.company_name, t.company_code, t.province,
t.city, t.district, t.street, t.vlg_or_cmty, t.resp_person, t.urb_rur_cls, t.budg_conf_prev,
t.budg_conf_new, t.budg_total, t.quarterly_target, t.cny_gsg_charged, t.cny_gsg_uncharged,
t.cny_gsg_total, t.cny_yr_full, t.cny_yr_instal, t.cny_prev_full,
t.cny_prev_install, t.cny_market_cumr, t.cny_fy_cum_return,
t.cny_fp_cum_return, t.cny_inst_cum_return, t.cny_new_cum_return,
t.cny_rcvbls_cum_return, t.cny_bdgt_cmpl_rate,
t.cny_rcvbls_cmpl_rate, t.cny_cyn_cmpl_rate,
t.cny_pt_cmpl_rate, t.remark, t.create_time, t.create_by,
t.update_time, t.update_by, t.def_flag
from mc_basic_money t
left join sys_user u on u.user_id = t.create_by
left join sys_dept d on d.dept_id = t.company_code
</sql>
<select id="selectMcBasicMoneyList" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicMoneyVo" resultMap="McBasicMoneyResult">
<include refid="selectMcBasicMoneyVo"/>
<where>
<if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
<if test="regionName != null and regionName != ''"> and t.region_name like concat('%', #{regionName}, '%')</if>
<if test="groupName != null and groupName != ''"> and t.group_name like concat('%', #{groupName}, '%')</if>
<if test="companyName != null and companyName != ''"> and t.company_name like concat('%', #{companyName}, '%')</if>
<if test="companyCode != null and companyCode != ''"> and t.company_code = #{companyCode}</if>
<if test="province != null and province != ''"> and t.province = #{province}</if>
<if test="city != null and city != ''"> and t.city = #{city}</if>
<if test="district != null and district != ''"> and t.district = #{district}</if>
<if test="street != null and street != ''"> and t.street = #{street}</if>
<if test="vlgOrCmty != null and vlgOrCmty != ''"> and t.vlg_or_cmty = #{vlgOrCmty}</if>
<if test="respPerson != null and respPerson != ''"> and t.resp_person = #{respPerson}</if>
<if test="urbRurCls != null and urbRurCls != ''"> and t.urb_rur_cls = #{urbRurCls}</if>
<if test="budgConfPrev != null "> and t.budg_conf_prev = #{budgConfPrev}</if>
<if test="budgConfNew != null "> and t.budg_conf_new = #{budgConfNew}</if>
<if test="budgTotal != null "> and t.budg_total = #{budgTotal}</if>
<if test="quarterlyTarget != null "> and t.quarterly_target = #{quarterlyTarget}</if>
<if test="cnyGsgCharged != null "> and t.cny_gsg_charged = #{cnyGsgCharged}</if>
<if test="cnyGsgUncharged != null "> and t.cny_gsg_uncharged = #{cnyGsgUncharged}</if>
<if test="cnyGsgTotal != null "> and t.cny_gsg_total = #{cnyGsgTotal}</if>
<if test="cnyYrFull != null "> and t.cny_yr_full = #{cnyYrFull}</if>
<if test="cnyYrInstal != null "> and t.cny_yr_instal = #{cnyYrInstal}</if>
<if test="cnyPrevFull != null "> and t.cny_prev_full = #{cnyPrevFull}</if>
<if test="cnyPrevInstall != null "> and t.cny_prev_install = #{cnyPrevInstall}</if>
<if test="cnyMarketCumr != null "> and t.cny_market_cumr = #{cnyMarketCumr}</if>
<if test="cnyFyCumReturn != null "> and t.cny_fy_cum_return = #{cnyFyCumReturn}</if>
<if test="cnyFpCumReturn != null "> and t.cny_fp_cum_return = #{cnyFpCumReturn}</if>
<if test="cnyInstCumReturn != null "> and t.cny_inst_cum_return = #{cnyInstCumReturn}</if>
<if test="cnyNewCumReturn != null "> and t.cny_new_cum_return = #{cnyNewCumReturn}</if>
<if test="cnyRcvblsCumReturn != null "> and t.cny_rcvbls_cum_return = #{cnyRcvblsCumReturn}</if>
<if test="cnyBdgtCmplRate != null "> and t.cny_bdgt_cmpl_rate = #{cnyBdgtCmplRate}</if>
<if test="cnyRcvblsCmplRate != null "> and t.cny_rcvbls_cmpl_rate = #{cnyRcvblsCmplRate}</if>
<if test="cnyCynCmplRate != null "> and t.cny_cyn_cmpl_rate = #{cnyCynCmplRate}</if>
<if test="cnyPtCmplRate != null "> and t.cny_pt_cmpl_rate = #{cnyPtCmplRate}</if>
<if test="defFlag != null and defFlag != ''"> and t.def_flag = #{defFlag}</if>
<if test="startFiscalYear != null and startFiscalYear != ''"> and t.fiscal_year >= #{startFiscalYear}</if>
<if test="finishFiscalYear != null and finishFiscalYear != ''"> and t.fiscal_year <= #{finishFiscalYear}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
order by t.update_time desc
</select>
<select id="selectMcBasicMoneyById" parameterType="Long" resultMap="McBasicMoneyResult">
<include refid="selectMcBasicMoneyVo"/>
where id = #{id}
</select>
<insert id="insertMcBasicMoney" parameterType="com.chinagas.modules.schsf.domain.McBasicMoney">
insert into mc_basic_money
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="fiscalYear != null">fiscal_year,</if>
<if test="regionName != null and regionName != ''">region_name,</if>
<if test="groupName != null and groupName != ''">group_name,</if>
<if test="companyName != null and companyName != ''">company_name,</if>
<if test="companyCode != null and companyCode != ''">company_code,</if>
<if test="province != null">province,</if>
<if test="city != null">city,</if>
<if test="district != null">district,</if>
<if test="street != null">street,</if>
<if test="vlgOrCmty != null">vlg_or_cmty,</if>
<if test="respPerson != null">resp_person,</if>
<if test="urbRurCls != null">urb_rur_cls,</if>
<if test="budgConfPrev != null">budg_conf_prev,</if>
<if test="budgConfNew != null">budg_conf_new,</if>
<if test="budgTotal != null">budg_total,</if>
<if test="quarterlyTarget != null">quarterly_target,</if>
<if test="cnyGsgCharged != null">cny_gsg_charged,</if>
<if test="cnyGsgUncharged != null">cny_gsg_uncharged,</if>
<if test="cnyGsgTotal != null">cny_gsg_total,</if>
<if test="cnyYrFull != null">cny_yr_full,</if>
<if test="cnyYrInstal != null">cny_yr_instal,</if>
<if test="cnyPrevFull != null">cny_prev_full,</if>
<if test="cnyPrevInstall != null">cny_prev_install,</if>
<if test="cnyMarketCumr != null">cny_market_cumr,</if>
<if test="cnyFyCumReturn != null">cny_fy_cum_return,</if>
<if test="cnyFpCumReturn != null">cny_fp_cum_return,</if>
<if test="cnyInstCumReturn != null">cny_inst_cum_return,</if>
<if test="cnyNewCumReturn != null">cny_new_cum_return,</if>
<if test="cnyRcvblsCumReturn != null">cny_rcvbls_cum_return,</if>
<if test="cnyBdgtCmplRate != null">cny_bdgt_cmpl_rate,</if>
<if test="cnyRcvblsCmplRate != null">cny_rcvbls_cmpl_rate,</if>
<if test="cnyCynCmplRate != null">cny_cyn_cmpl_rate,</if>
<if test="cnyPtCmplRate != null">cny_pt_cmpl_rate,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null and updateBy != ''">update_by,</if>
<if test="defFlag != null and defFlag != ''">def_flag,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="fiscalYear != null">#{fiscalYear},</if>
<if test="regionName != null and regionName != ''">#{regionName},</if>
<if test="groupName != null and groupName != ''">#{groupName},</if>
<if test="companyName != null and companyName != ''">#{companyName},</if>
<if test="companyCode != null and companyCode != ''">#{companyCode},</if>
<if test="province != null">#{province},</if>
<if test="city != null">#{city},</if>
<if test="district != null">#{district},</if>
<if test="street != null">#{street},</if>
<if test="vlgOrCmty != null">#{vlgOrCmty},</if>
<if test="respPerson != null">#{respPerson},</if>
<if test="urbRurCls != null">#{urbRurCls},</if>
<if test="budgConfPrev != null">#{budgConfPrev},</if>
<if test="budgConfNew != null">#{budgConfNew},</if>
<if test="budgTotal != null">#{budgTotal},</if>
<if test="quarterlyTarget != null">#{quarterlyTarget},</if>
<if test="cnyGsgCharged != null">#{cnyGsgCharged},</if>
<if test="cnyGsgUncharged != null">#{cnyGsgUncharged},</if>
<if test="cnyGsgTotal != null">#{cnyGsgTotal},</if>
<if test="cnyYrFull != null">#{cnyYrFull},</if>
<if test="cnyYrInstal != null">#{cnyYrInstal},</if>
<if test="cnyPrevFull != null">#{cnyPrevFull},</if>
<if test="cnyPrevInstall != null">#{cnyPrevInstall},</if>
<if test="cnyMarketCumr != null">#{cnyMarketCumr},</if>
<if test="cnyFyCumReturn != null">#{cnyFyCumReturn},</if>
<if test="cnyFpCumReturn != null">#{cnyFpCumReturn},</if>
<if test="cnyInstCumReturn != null">#{cnyInstCumReturn},</if>
<if test="cnyNewCumReturn != null">#{cnyNewCumReturn},</if>
<if test="cnyRcvblsCumReturn != null">#{cnyRcvblsCumReturn},</if>
<if test="cnyBdgtCmplRate != null">#{cnyBdgtCmplRate},</if>
<if test="cnyRcvblsCmplRate != null">#{cnyRcvblsCmplRate},</if>
<if test="cnyCynCmplRate != null">#{cnyCynCmplRate},</if>
<if test="cnyPtCmplRate != null">#{cnyPtCmplRate},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null and updateBy != ''">#{updateBy},</if>
<if test="defFlag != null and defFlag != ''">#{defFlag},</if>
</trim>
</insert>
<update id="updateMcBasicMoney" parameterType="com.chinagas.modules.schsf.domain.McBasicMoney">
update mc_basic_money
<trim prefix="SET" suffixOverrides=",">
<if test="fiscalYear != null">fiscal_year = #{fiscalYear},</if>
<if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
<if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
<if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
<if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
<if test="province != null">province = #{province},</if>
<if test="city != null">city = #{city},</if>
<if test="district != null">district = #{district},</if>
<if test="street != null">street = #{street},</if>
<if test="vlgOrCmty != null">vlg_or_cmty = #{vlgOrCmty},</if>
<if test="respPerson != null">resp_person = #{respPerson},</if>
<if test="urbRurCls != null">urb_rur_cls = #{urbRurCls},</if>
<if test="budgConfPrev != null">budg_conf_prev = #{budgConfPrev},</if>
<if test="budgConfNew != null">budg_conf_new = #{budgConfNew},</if>
<if test="budgTotal != null">budg_total = #{budgTotal},</if>
<if test="quarterlyTarget != null">quarterly_target = #{quarterlyTarget},</if>
<if test="cnyGsgCharged != null">cny_gsg_charged = #{cnyGsgCharged},</if>
<if test="cnyGsgUncharged != null">cny_gsg_uncharged = #{cnyGsgUncharged},</if>
<if test="cnyGsgTotal != null">cny_gsg_total = #{cnyGsgTotal},</if>
<if test="cnyYrFull != null">cny_yr_full = #{cnyYrFull},</if>
<if test="cnyYrInstal != null">cny_yr_instal = #{cnyYrInstal},</if>
<if test="cnyPrevFull != null">cny_prev_full = #{cnyPrevFull},</if>
<if test="cnyPrevInstall != null">cny_prev_install = #{cnyPrevInstall},</if>
<if test="cnyMarketCumr != null">cny_market_cumr = #{cnyMarketCumr},</if>
<if test="cnyFyCumReturn != null">cny_fy_cum_return = #{cnyFyCumReturn},</if>
<if test="cnyFpCumReturn != null">cny_fp_cum_return = #{cnyFpCumReturn},</if>
<if test="cnyInstCumReturn != null">cny_inst_cum_return = #{cnyInstCumReturn},</if>
<if test="cnyNewCumReturn != null">cny_new_cum_return = #{cnyNewCumReturn},</if>
<if test="cnyRcvblsCumReturn != null">cny_rcvbls_cum_return = #{cnyRcvblsCumReturn},</if>
<if test="cnyBdgtCmplRate != null">cny_bdgt_cmpl_rate = #{cnyBdgtCmplRate},</if>
<if test="cnyRcvblsCmplRate != null">cny_rcvbls_cmpl_rate = #{cnyRcvblsCmplRate},</if>
<if test="cnyCynCmplRate != null">cny_cyn_cmpl_rate = #{cnyCynCmplRate},</if>
<if test="cnyPtCmplRate != null">cny_pt_cmpl_rate = #{cnyPtCmplRate},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="defFlag != null and defFlag != ''">def_flag = #{defFlag},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteMcBasicMoneyById" parameterType="Long">
delete from mc_basic_money where id = #{id}
</delete>
<delete id="deleteMcBasicMoneyByIds" parameterType="String">
delete from mc_basic_money where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="selectMcBasicMoneyByData" resultMap="McBasicMoneyResult" parameterType="com.chinagas.modules.schsf.domain.McBasicMoney">
<include refid="selectMcBasicMoneyVo"/>
where 1=1
and t.fiscal_year = #{fiscalYear}
and t.region_name = #{regionName}
and t.group_name = #{groupName}
and t.company_name = #{companyName}
and t.company_code = #{companyCode}
and t.province = #{province}
and t.city = #{city}
and t.district = #{district}
and t.street = #{street}
and t.vlg_or_cmty = #{vlgOrCmty}
</select>
<select id="selectMcBasicMoneySummaryList" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicMoneyVo" resultMap="McBasicMoneyResult">
SELECT d.id, d.fiscal_year, d.region_name, d.group_name, d.company_name, d.company_code, d.province, d.city, d.district, d.street, d.vlg_or_cmty, d.resp_person, d.urb_rur_cls, d.budg_conf_prev, d.budg_conf_new, d.budg_total, d.quarterly_target, d.cny_gsg_charged, d.cny_gsg_uncharged, d.cny_gsg_total,
d.cny_yr_full ,d.cny_yr_instal ,d.cny_prev_full ,d.cny_prev_install,
(d.cny_yr_full+d.cny_yr_instal+d.cny_prev_full+d.cny_prev_install) AS cny_market_cumr,
(d.cny_yr_full+d.cny_yr_instal+d.cny_prev_full+d.cny_prev_install+ IFNULL(d.cny_gsg_charged,0)) AS cny_fy_cum_return,
(d.cny_yr_full+d.cny_prev_full) AS cny_fp_cum_return,
(d.cny_yr_instal+d.cny_prev_install) AS cny_inst_cum_return,
(d.cny_yr_full+d.cny_yr_instal) AS cny_new_cum_return,
(d.cny_prev_full+d.cny_prev_install) AS cny_rcvbls_cum_return,
(d.cny_yr_full+d.cny_yr_instal+d.cny_prev_full+d.cny_prev_install+ IFNULL(d.cny_gsg_charged,0)) / d.budg_total as cny_bdgt_cmpl_rate,
(d.cny_prev_full+d.cny_prev_install) / IFNULL(d.budg_conf_prev,0) as cny_rcvbls_cmpl_rate,
(d.cny_yr_full+d.cny_yr_instal) / IFNULL(d.budg_conf_new,0) as cny_cyn_cmpl_rate,
IFNULL(d.quarterly_target,0) / (d.cny_yr_full+d.cny_yr_instal+d.cny_prev_full+d.cny_prev_install+ IFNULL(d.cny_gsg_charged,0)) as cny_pt_cmpl_rate
FROM (
SELECT
t.update_time,
t.id,
t.fiscal_year,
t.region_name,
t.group_name,
t.company_name,
t.company_code,
t.province,
t.city,
t.district,
t.street,
t.vlg_or_cmty,
t.resp_person,
t.urb_rur_cls,
t.budg_conf_prev,
t.budg_conf_new,
(IFNULL(t.budg_conf_prev,0) + IFNULL(t.budg_conf_new,0)) AS budg_total,
t.quarterly_target,
t.cny_gsg_charged,
t.cny_gsg_uncharged,
(IFNULL(t.cny_gsg_charged,0) + IFNULL(t.cny_gsg_uncharged,0)) AS cny_gsg_total,
(IFNULL(t.cny_yr_full,0) + IFNULL(bnqk.cny_yr_full,0)) AS cny_yr_full,
(IFNULL(t.cny_yr_instal,0) + IFNULL(bnfq.cny_yr_instal,0)) AS cny_yr_instal,
(IFNULL(t.cny_prev_full,0)+IFNULL(wnbnqk.cny_prev_full,0)) AS cny_prev_full,
(IFNULL(t.cny_prev_install,0) + IFNULL(wnbnfq.cny_prev_install,0)) AS cny_prev_install
FROM mc_basic_money t
left join sys_user u on u.user_id = t.create_by
left join sys_dept d on d.dept_id = t.company_code
LEFT JOIN (
SELECT fiscal_year, company_code, urb_rur_cls, vlg_or_cmty,SUM(charge_amt) AS cny_yr_full
FROM mc_visit
WHERE 1=1
AND is_charged='Y'
AND charge_type='2'
AND status_code ='APPROVED'
AND invoice_year_type='本年新增'
GROUP BY
fiscal_year, company_code, urb_rur_cls, vlg_or_cmty
) bnqk on bnqk.fiscal_year = t.fiscal_year and bnqk.company_code=t.company_code and bnqk.urb_rur_cls=t.urb_rur_cls and bnqk.vlg_or_cmty=t.vlg_or_cmty
LEFT JOIN (
SELECT fiscal_year, company_code, urb_rur_cls, vlg_or_cmty,SUM(charge_amt) AS cny_yr_instal
FROM mc_visit
WHERE 1=1
AND is_charged='Y'
AND charge_type in ('1','4')
AND status_code ='APPROVED'
AND invoice_year_type='本年新增'
GROUP BY
fiscal_year, company_code, urb_rur_cls, vlg_or_cmty
) bnfq on bnfq.fiscal_year = t.fiscal_year and bnfq.company_code=t.company_code and bnfq.urb_rur_cls=t.urb_rur_cls and bnfq.vlg_or_cmty=t.vlg_or_cmty
LEFT JOIN (
SELECT fiscal_year, company_code, urb_rur_cls, vlg_or_cmty,SUM(charge_amt) AS cny_prev_full
FROM mc_visit
WHERE 1=1
AND is_charged='Y'
AND charge_type='2'
AND status_code ='APPROVED'
AND invoice_year_type='往年应收'
GROUP BY
fiscal_year, company_code, urb_rur_cls, vlg_or_cmty
) wnbnqk on wnbnqk.fiscal_year = t.fiscal_year and wnbnqk.company_code=t.company_code and wnbnqk.urb_rur_cls=t.urb_rur_cls and wnbnqk.vlg_or_cmty=t.vlg_or_cmty
LEFT JOIN (
SELECT fiscal_year, company_code, urb_rur_cls,vlg_or_cmty,SUM(charge_amt) AS cny_prev_install
FROM mc_visit
WHERE 1=1
AND is_charged='Y'
AND charge_type in ('1','4')
AND status_code ='APPROVED'
AND invoice_year_type='往年应收'
GROUP BY
fiscal_year, company_code, urb_rur_cls, vlg_or_cmty
) wnbnfq on wnbnfq.fiscal_year = t.fiscal_year and wnbnfq.company_code=t.company_code and wnbnfq.urb_rur_cls=t.urb_rur_cls and wnbnfq.vlg_or_cmty=t.vlg_or_cmty
where 1=1
<if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
<if test="regionName != null and regionName != ''"> and t.region_name like concat('%', #{regionName}, '%')</if>
<if test="groupName != null and groupName != ''"> and t.group_name like concat('%', #{groupName}, '%')</if>
<if test="companyName != null and companyName != ''"> and t.company_name like concat('%', #{companyName}, '%')</if>
<if test="companyCode != null and companyCode != ''"> and t.company_code = #{companyCode}</if>
<if test="province != null and province != ''"> and t.province = #{province}</if>
<if test="city != null and city != ''"> and t.city = #{city}</if>
<if test="district != null and district != ''"> and t.district = #{district}</if>
<if test="street != null and street != ''"> and t.street = #{street}</if>
<if test="vlgOrCmty != null and vlgOrCmty != ''"> and t.vlg_or_cmty = #{vlgOrCmty}</if>
<if test="respPerson != null and respPerson != ''"> and t.resp_person = #{respPerson}</if>
<if test="urbRurCls != null and urbRurCls != ''"> and t.urb_rur_cls = #{urbRurCls}</if>
<if test="budgConfPrev != null "> and t.budg_conf_prev = #{budgConfPrev}</if>
<if test="budgConfNew != null "> and t.budg_conf_new = #{budgConfNew}</if>
<if test="budgTotal != null "> and t.budg_total = #{budgTotal}</if>
<if test="quarterlyTarget != null "> and t.quarterly_target = #{quarterlyTarget}</if>
<if test="cnyGsgCharged != null "> and t.cny_gsg_charged = #{cnyGsgCharged}</if>
<if test="cnyGsgUncharged != null "> and t.cny_gsg_uncharged = #{cnyGsgUncharged}</if>
<if test="cnyGsgTotal != null "> and t.cny_gsg_total = #{cnyGsgTotal}</if>
<if test="cnyYrFull != null "> and t.cny_yr_full = #{cnyYrFull}</if>
<if test="cnyYrInstal != null "> and t.cny_yr_instal = #{cnyYrInstal}</if>
<if test="cnyPrevFull != null "> and t.cny_prev_full = #{cnyPrevFull}</if>
<if test="cnyPrevInstall != null "> and t.cny_prev_install = #{cnyPrevInstall}</if>
<if test="cnyMarketCumr != null "> and t.cny_market_cumr = #{cnyMarketCumr}</if>
<if test="cnyFyCumReturn != null "> and t.cny_fy_cum_return = #{cnyFyCumReturn}</if>
<if test="cnyFpCumReturn != null "> and t.cny_fp_cum_return = #{cnyFpCumReturn}</if>
<if test="cnyInstCumReturn != null "> and t.cny_inst_cum_return = #{cnyInstCumReturn}</if>
<if test="cnyNewCumReturn != null "> and t.cny_new_cum_return = #{cnyNewCumReturn}</if>
<if test="cnyRcvblsCumReturn != null "> and t.cny_rcvbls_cum_return = #{cnyRcvblsCumReturn}</if>
<if test="cnyBdgtCmplRate != null "> and t.cny_bdgt_cmpl_rate = #{cnyBdgtCmplRate}</if>
<if test="cnyRcvblsCmplRate != null "> and t.cny_rcvbls_cmpl_rate = #{cnyRcvblsCmplRate}</if>
<if test="cnyCynCmplRate != null "> and t.cny_cyn_cmpl_rate = #{cnyCynCmplRate}</if>
<if test="cnyPtCmplRate != null "> and t.cny_pt_cmpl_rate = #{cnyPtCmplRate}</if>
<if test="defFlag != null and defFlag != ''"> and t.def_flag = #{defFlag}</if>
<if test="startFiscalYear != null and startFiscalYear != ''"> and t.fiscal_year >= #{startFiscalYear}</if>
<if test="finishFiscalYear != null and finishFiscalYear != ''"> and t.fiscal_year <= #{finishFiscalYear}</if>
<if test="idList != null and idList.size() > 0">
and t.id in
<foreach collection="idList" item="item" index="index" separator="," open=" (" close=")">
#{item}
</foreach>
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
) d
order by d.update_time desc
</select>
</mapper>