Blame view

src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml 18.1 KB
8dc487b1   함상기   Init Version - 20...
1
2
3
4
5
6
7
8
9
10
11
  <?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.batch.mapper.primary.MatchingInnerDelingMapper">
  	
  	<!-- 작업리스트 -->
  	<select id="getCustomItemReadData" parameterType="map" resultType="map">
  		SELECT 
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
8dc487b1   함상기   Init Version - 20...
12
13
14
15
16
17
18
  		FROM
  			(
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
8dc487b1   함상기   Init Version - 20...
19
20
21
22
23
24
25
26
  				    , case when count(*) > 0 then 1 else 0 end as cnt
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty is null
  					and dta_ty in ('11','21','31','33','35','37','41')
30bbef42   함상기   ai sub Matching 추가
27
28
29
30
31
32
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and cpr_code = #{cpr_code}
  					</if>									
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
  						and partn_cpr = #{partn_cpr}
  					</if>									
8dc487b1   함상기   Init Version - 20...
33
34
35
36
37
  				GROUP BY
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
8dc487b1   함상기   Init Version - 20...
38
39
40
41
42
43
  			union all
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , partn_cpr as cpr_code
  				    , cpr_code as partn_cpr
8dc487b1   함상기   Init Version - 20...
44
45
46
47
48
49
50
51
  				    , case when count(*) > 0 then 1 else 0 end as cnt
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty is null
  					and dta_ty in ('12','22','32','34','36','38','42')
30bbef42   함상기   ai sub Matching 추가
52
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
415842d2   함상기   20240408
53
54
55
56
  						and cpr_code = #{partn_cpr}
  					</if>									
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and partn_cpr = #{cpr_code}
30bbef42   함상기   ai sub Matching 추가
57
  					</if>									
8dc487b1   함상기   Init Version - 20...
58
59
60
61
62
  				GROUP BY
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
8dc487b1   함상기   Init Version - 20...
63
64
65
66
67
68
  			) m
  		GROUP BY	
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
8dc487b1   함상기   Init Version - 20...
69
70
71
72
73
74
75
76
77
78
79
80
81
  		HAVING sum(cnt) > 1	
  	</select>
  	
  	<!-- 작업키 업데이트 -->
  	<update id="setDataMakeCompareKy" parameterType="map">
  		UPDATE public.batch_tbcr_inner_delng
  		SET
  		    ${compareKey} = ${makeCompareKey}
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
8dc487b1   함상기   Init Version - 20...
82
83
84
85
86
87
88
89
90
91
  			<foreach collection="cond" item="item" open="" close="" separator="">
  				and ${item}
  			</foreach>
  	</update>
  
  	<!-- 매칭작업할 데이타 가져오기 -->
  	<select id="getMatchingData" parameterType="map" resultType="map">
  		SELECT
  		    accnut_ym
  		    , compare_ky
30bbef42   함상기   ai sub Matching 추가
92
  		    , ${currencyField}
8dc487b1   함상기   Init Version - 20...
93
94
95
96
97
98
99
100
101
  			, ${amtField}
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and compare_ky is not null
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
8dc487b1   함상기   Init Version - 20...
102
103
104
105
106
  			<foreach collection="cond" item="item" open="" close="" separator="">
  				and ${item}
  			</foreach>
  			group by
  			    accnut_ym,
30bbef42   함상기   ai sub Matching 추가
107
108
  				compare_ky,
  		    	${currencyField}						
8dc487b1   함상기   Init Version - 20...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  	</select>
  	
  	<!-- 매칭결과 업데이트 -->
  	<select id="getMatchingResult" parameterType="map" resultType="map">
  		SELECT
  			sys_se
  		    , accnut_ym
  		    , sn
  			, compare_ky			
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and compare_ky is not null
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
8dc487b1   함상기   Init Version - 20...
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
  			<foreach collection="cond" item="item" open="" close="" separator="">
  				and ${item}
  			</foreach>
  	</select>
  	
  
  	<update id="setResult" parameterType="map">
  		<foreach collection="itemList" item="item" separator=";">
  		UPDATE public.batch_tbcr_inner_delng
  		SET
  			mtch_sys = 'AUTO',
  		    ${item.matchingType} = #{item.matchingTypeVal},
  		    ${item.matchingTypeName} = #{item.matchingTypeNameVal},
  		    ${item.matchingNumber} = #{item.matchingNumberVal}
  		WHERE
  			sys_se = #{item.sys_se}
  			and accnut_ym = #{item.accnut_ym}	
  			and sn = #{item.sn}
  		</foreach>
  	</update>	
   
  
  
  
  
  
   	<update id="deleteOriginalData" parameterType="map">
  		DELETE FROM tbcr_transaction_history
  		WHERE
  			cons_group = #{sysSe}
  			and account_period = #{accnutYm}
  			
  	</update>
  
   
   	<update id="insertOriginalData" parameterType="map">
  		INSERT INTO tbcr_transaction_history (
  		    session_id,
  		    cons_group,
  		    ledger,
  		    account_period,
  		    seq,
  		    tran_type,
  		    own_comp,
a99930a8   함상기   2024.04.18
170
  		    own_comp_name,
8dc487b1   함상기   Init Version - 20...
171
  		    tran_comp,
a99930a8   함상기   2024.04.18
172
  		    tran_comp_name,
8dc487b1   함상기   Init Version - 20...
173
  		    comp_acct_code,
a99930a8   함상기   2024.04.18
174
  		    comp_acct_name,
8dc487b1   함상기   Init Version - 20...
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
  		    comp_prod_code,
  		    recon_key,
  		    tran_date,
  		    tran_currency,
  		    tran_amt,
  		    book_amt,
  		    group_amt,
  		    book_cost,
  		    document_no,
  		    remark,
  		    cons_acct_code,
  		    cons_acct_name,
  		    prod_code,
  		    adjust_type,
  		    adjust_remark,
  		    if_account_period,
  		    if_comp_code,
  		    if_file_id,
  		    if_source,
  		    equal_check,
  		    cons_own_comp,
  		    cons_tran_comp,
  		    invoice_no,
  		    lc_no,
  		    bl_no,
  		    own_biz_no,
  		    partner_biz_no,
  		    acct_date,
  		    matching_cause,
  		    match_key	
  		) values 
  		<foreach collection="itemList" item="item" separator=",">
  		(
  		    #{item.SESSION_ID},
  		    #{item.CONS_GROUP},
  		    #{item.LEDGER},
  		    #{item.ACCOUNT_PERIOD},
  		    #{item.SEQ},
  		    #{item.TRAN_TYPE},
  		    #{item.OWN_COMP},
a99930a8   함상기   2024.04.18
215
  		    #{item.OWN_COMP_NAME},
8dc487b1   함상기   Init Version - 20...
216
  		    #{item.TRAN_COMP},
a99930a8   함상기   2024.04.18
217
  		    #{item.TRAN_COMP_NAME},
8dc487b1   함상기   Init Version - 20...
218
  		    #{item.COMP_ACCT_CODE},
a99930a8   함상기   2024.04.18
219
  		    #{item.COMP_ACCT_NAME},
8dc487b1   함상기   Init Version - 20...
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
  		    #{item.COMP_PROD_CODE},
  		    #{item.RECON_KEY},
  		    #{item.TRAN_DATE},
  		    #{item.TRAN_CURRENCY},
  		    #{item.TRAN_AMT},
  		    #{item.BOOK_AMT},
  		    #{item.GROUP_AMT},
  		    #{item.BOOK_COST},
  		    #{item.DOCUMENT_NO},
  		    #{item.REMARK},
  		    #{item.CONS_ACCT_CODE},
  		    #{item.CONS_ACCT_NAME},
  		    #{item.PROD_CODE},
  		    #{item.ADJUST_TYPE},
  		    #{item.ADJUST_REMARK},
  		    #{item.IF_ACCOUNT_PERIOD},
  		    #{item.IF_COMP_CODE},
  		    #{item.IF_FILE_ID},
  		    #{item.IF_SOURCE},
  		    #{item.EQUAL_CHECK},
  		    #{item.CONS_OWN_COMP},
  		    #{item.CONS_TRAN_COMP},
  		    #{item.INVOICE_NO},
  		    #{item.LC_NO},
  		    #{item.BL_NO},
  		    #{item.OWN_BIZ_NO},
  		    #{item.PARTNER_BIZ_NO},
  		    #{item.ACCT_DATE},
  		    #{item.MATCHING_CAUSE},
  		    #{item.MATCH_KEY}
  		)
  		</foreach>
  	 </update>
  
  	<update id="deleteData" parameterType="map">
  		DELETE FROM batch_tbcr_inner_delng
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}			
  	</update>
  	 
  	<update id="insertDataFromOriginal" parameterType="map">
  		INSERT INTO
  		    batch_tbcr_inner_delng
  		        (
  		            sys_se
  		            , accnut_ym
  		            , sn
  		            , dta_ty
  		            , cpr_code
  		            , partn_cpr
  		            , cpr_acnt_code
  		            , cnnc_acnt_code
  		            , cnnc_acnt_nm
  		            , delng_de
  		            , elcty_de
  		            , chit_no
  		            , cmpnsp_ky
  		            , ext_key1
  		            , ext_key2
  		            , ext_key3
  		            , ext_key4
  		            , ext_key5
  		            , delng_crncy
  		            , delng_amt
  		            , acntbk_amt
  		            , group_amt
  		            , suply_amount
  		            , sumry
  		            , org_mtch_ty
  		            , org_mtch_ky
  		            , new_mtch_ty
  		            , new_mtch_ky
  		            , compare_ky
  		            , mtch_ty
  		            , mtch_ty_nm
  		            , mtch_ky
  		        )
  		SELECT
  		    cons_group
  		    , account_period
  		    , seq
  		    , tran_type
  		    , own_comp
  		    , tran_comp
  		    , comp_acct_code
  		    , cons_acct_code
  		    , cons_acct_name
  		    , tran_date
  		    , acct_date
  		    , document_no
  		    , recon_key
  			, null
  		    , invoice_no
  		    , lc_no
  		    , bl_no
  			, null
  		    , tran_currency
  		    , tran_amt
  		    , book_amt
  		    , group_amt
  		    , book_cost
  		    , remark
  		    , matching_cause
  		    , match_key
  			, null
  			, null
  			, null
  			, null
  			, null
  			, null
  		FROM
  		    tbcr_transaction_history
  		WHERE
  			cons_group = #{sysSe}
  			and account_period = #{accnutYm}
f97db154   함상기   .
336
337
338
  			<foreach collection="conds" item="item" open="" close="" separator="">
  				and ${item}
  			</foreach>
8dc487b1   함상기   Init Version - 20...
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
  	 </update>
  
  	<update id="deleteDataAi" parameterType="map">
  		DELETE FROM batch_tbcr_inner_delng_ai
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}
  			
  	</update>
  	 
  	<update id="insertDataAiFromOriginal" parameterType="map">
  		INSERT INTO
  		    batch_tbcr_inner_delng_ai
  		        (
  		            sys_se
  		            , accnut_ym
  		            , sn
  					, ai_key1
  					, ai_key2
  					, ai_key3
  					, ai_key4
  					, ai_key5
  					, ai_key6
  					, ai_key7
  					, ai_key8
  					, ai_key9
  					, ai_key10		            
  		        )
  		SELECT
  		    cons_group
  		    , account_period
  		    , seq
  		    , regexp_replace(document_no, '[^0-9a-zA-Z]', '',1,0) as ai_key1
  		    , regexp_replace(recon_key, '[^0-9a-zA-Z]', '',1,0) as ai_key2
  		    , '' as ai_key3
  		    , '' as ai_key4
  		    , '' as ai_key5
  		    , '' as ai_key6
  		    , '' as ai_key7
  		    , '' as ai_key8
  		    , '' as ai_key9
  			, '' as ai_key10
  		FROM
  		    tbcr_transaction_history
  		WHERE
  			cons_group = #{sysSe}
  			and account_period = #{accnutYm}
8dc487b1   함상기   Init Version - 20...
386
  	 </update> 
78928007   함상기   20240305
387
388
389
390
391
392
393
394
395
396
  
  	<update id="updateClearNewMatchKey" parameterType="map">
  		update batch_tbcr_inner_delng
  		set
  			new_mtch_ty = null,
  			new_mtch_ky = null
  		where
  			sys_se = #{sysSe}
  			AND accnut_ym = #{accnutYm}
  	</update>
8dc487b1   함상기   Init Version - 20...
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
  	 
  	<update id="updateNewMatchKey" parameterType="map">
  		merge into batch_tbcr_inner_delng m
  		using 
  				(
  				select 
  					sys_se,
  					accnut_ym,
  					sn,
  					org_mtch_ty,
  					org_mtch_ky,
  					mtch_ty as new_mtch_ty,
  					mtch_ky,
  					DENSE_RANK() over (order by mtch_ty, mtch_ky) AS new_mtch_ky
  				from batch_tbcr_inner_delng
  				where
  					sys_se = #{sysSe}
  					AND accnut_ym = #{accnutYm}
  					AND mtch_ty is not null
  				) t
  		on 
  			m.sys_se = t.sys_se
  			and m.accnut_ym = t.accnut_ym
  			and m.sn = t.sn
  		when matched then
  			update set
  				new_mtch_ty = t.new_mtch_ty,
  				new_mtch_ky = t.new_mtch_ky		
  	</update>	
  	
  	
  	
  	<!-- 매칭작업할 데이타 가져오기 -->
  	<select id="getMatchingExtraDataOne" parameterType="map" resultType="map">
  		SELECT	
  			sys_se		
  		    , accnut_ym
  		    , sn
  		    , '' as compare_ky
  		    , delng_de
8dc487b1   함상기   Init Version - 20...
437
438
439
440
441
442
443
444
  			, delng_amt
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
8dc487b1   함상기   Init Version - 20...
445
  			and mtch_ky is null
78928007   함상기   20240305
446
447
448
449
450
451
  			<if test='conds eq "T".toString()'>
  				and dta_ty in ('11','21','41')
  			</if>
  			<if test='conds eq "B".toString()'>
  				and dta_ty in ('31','33','35','37')	
  			</if>
8dc487b1   함상기   Init Version - 20...
452
453
  			and delng_amt != 0		
  		ORDER BY 
d3e8a8a9   함상기   2024-04-01
454
  			delng_de
8dc487b1   함상기   Init Version - 20...
455
456
457
458
459
460
461
462
463
464
  	</select>
  
  	<!-- 매칭작업할 데이타 가져오기 -->
  	<select id="getMatchingExtraDataTwo" parameterType="map" resultType="map">
  		SELECT	
  			sys_se		
  		    , accnut_ym
  		    , sn
  		    , '' as compare_ky
  		    , delng_de
8dc487b1   함상기   Init Version - 20...
465
466
467
468
469
470
471
472
  			, delng_amt
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
8dc487b1   함상기   Init Version - 20...
473
  			and mtch_ky is null
78928007   함상기   20240305
474
475
476
477
478
479
  			<if test='conds eq "T".toString()'>
  				and dta_ty in ('12','22','42')
  			</if>
  			<if test='conds eq "B".toString()'>
  				and dta_ty in ('32','34','36','38')	
  			</if>
8dc487b1   함상기   Init Version - 20...
480
481
  			and delng_amt != 0		
  		ORDER BY 
d3e8a8a9   함상기   2024-04-01
482
  			delng_de
8dc487b1   함상기   Init Version - 20...
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
  	</select>
  	 
  	<update id="setExtraResult" parameterType="map">
  		<foreach collection="itemList" item="item" separator=";">
  		UPDATE public.batch_tbcr_inner_delng
  		SET
  		    mtch_sys = #{item.mtch_sys},
  		    mtch_ty = #{item.mtch_ty},
  		    mtch_ty_nm = #{item.mtch_ty_nm},
  		    mtch_ky = #{item.mtch_ky}
  		WHERE
  			sys_se = #{item.sys_se}
  			and accnut_ym = #{item.accnut_ym}	
  			and sn = #{item.sn}
  		</foreach>
  	</update>	
  
  	<update id="createUserJob" parameterType="map">
  		INSERT INTO public.batch_user_job_status (
78928007   함상기   20240305
502
  			user_job_group,
8dc487b1   함상기   Init Version - 20...
503
504
505
506
507
  			user_job_id,
  			user_job_name,
  			start_time,
  			status
  		) VALUES (
78928007   함상기   20240305
508
  			#{user_job_group},
8dc487b1   함상기   Init Version - 20...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
  			#{user_job_id},
  			#{user_job_name},
  			now(),
  			'Started'
  		)
  	</update>	
  
  	<update id="finishUserJob" parameterType="map">
  		UPDATE public.batch_user_job_status 
  		SET
  			end_time = now(),
  			status = 'Finished',
  			exit_code = #{exit_code},
  			exit_message = #{exit_message}
  		WHERE
  			user_job_id = #{user_job_id}
  	</update>	
  	 
  	<!-- AI 작업리스트 -->
  	<select id="getAiReadData" parameterType="map" resultType="map">
d3e8a8a9   함상기   2024-04-01
529
530
531
532
533
  		SELECT 
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
f97db154   함상기   .
534
  			, tb_ty
d3e8a8a9   함상기   2024-04-01
535
536
537
  			, delng_crncy
  		FROM
  			(
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
538
539
540
541
542
543
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
  				    , delng_crncy
f97db154   함상기   .
544
  				    , case when dta_ty in ('11','21','41') then 'T' else 'B' end tb_ty
d3e8a8a9   함상기   2024-04-01
545
  				    , case when count(*) > 0 then 1 else 0 end as cnt
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
546
547
548
549
550
551
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty is null
d3e8a8a9   함상기   2024-04-01
552
  					and dta_ty in ('11','21','31','33','35','37','41')
30bbef42   함상기   ai sub Matching 추가
553
554
555
556
557
558
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and cpr_code = #{cpr_code}
  					</if>									
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
  						and partn_cpr = #{partn_cpr}
  					</if>									
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
559
560
561
562
563
564
  				GROUP BY
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
  				    , delng_crncy
f97db154   함상기   .
565
  				    , case when dta_ty in ('11','21','41') then 'T' else 'B' end
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
566
567
568
569
570
571
572
  			union all
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , partn_cpr as cpr_code
  				    , cpr_code as partn_cpr
  				    , delng_crncy
f97db154   함상기   .
573
  				    , case when dta_ty in ('12','22','42') then 'T' else 'B' end as tb_ty
d3e8a8a9   함상기   2024-04-01
574
  				    , case when count(*) > 0 then 1 else 0 end as cnt
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
575
576
577
578
579
580
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty is null
d3e8a8a9   함상기   2024-04-01
581
  					and dta_ty in ('12','22','32','34','36','38','42')
30bbef42   함상기   ai sub Matching 추가
582
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
415842d2   함상기   20240408
583
584
585
586
  						and cpr_code = #{partn_cpr}
  					</if>									
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and partn_cpr = #{cpr_code}
30bbef42   함상기   ai sub Matching 추가
587
  					</if>									
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
588
589
590
  				GROUP BY
  				    sys_se
  				    , accnut_ym
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
591
  				    , cpr_code
d3e8a8a9   함상기   2024-04-01
592
  				    , partn_cpr
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
593
  				    , delng_crncy
f97db154   함상기   .
594
  				    , case when dta_ty in ('12','22','42') then 'T' else 'B' end
d3e8a8a9   함상기   2024-04-01
595
  			) m
a45ecedc   ggun12   * EX 매칭은 순차 실행으로 처리
596
597
598
599
600
601
  		GROUP BY	
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
  			, delng_crncy
4aa0b12d   함상기   .
602
  			, tb_ty
d3e8a8a9   함상기   2024-04-01
603
  		HAVING sum(cnt) > 1	
78928007   함상기   20240305
604
605
606
607
608
609
610
611
612
613
614
615
616
  	</select>	
  
  	<!-- User Job Status -->
  	<select id="getUserJobStatus" parameterType="map" resultType="map">
  		SELECT
  		    user_job_id
  		    , user_job_name
  		    , start_time
  		    , end_time
  		    , status
  		    , exit_code
  		    , exit_message
  		    , user_job_group
78928007   함상기   20240305
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
  		FROM
  		    public.batch_user_job_status
  		WHERE
  			user_job_group = #{userJobGroup}
  		ORDER BY 
  			user_job_id ASC
  	</select>
  	
  	<!-- ReturnData Select -->
  	<select id="getReturnData" parameterType="map" resultType="map">
  		SELECT
  		    sys_se
  		    , accnut_ym
  		    , sn
  		    , dta_ty
  		    , cpr_code
  		    , partn_cpr
  		    , cpr_acnt_code
  		    , cnnc_acnt_code
  		    , cnnc_acnt_nm
  		    , delng_de
  		    , elcty_de
  		    , chit_no
  		    , cmpnsp_ky
  		    , ext_key1
  		    , ext_key2
  		    , ext_key3
  		    , ext_key4
  		    , ext_key5
  		    , delng_crncy
  		    , delng_amt
  		    , acntbk_amt
  		    , group_amt
  		    , suply_amount
  		    , sumry
  		    , org_mtch_ty
  		    , org_mtch_ky
  		    , new_mtch_ty
  		    , new_mtch_ky
  		    , compare_ky
  		    , mtch_sys
  		    , mtch_ty
  		    , mtch_ty_nm
  		    , mtch_ky
  		FROM
  		    batch_tbcr_inner_delng
  		WHERE	
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}		    	
  	</select>
  
30bbef42   함상기   ai sub Matching 추가
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
  	<!-- 작업리스트 -->
  	<select id="getAiSubReadData" parameterType="map" resultType="map">
  		SELECT 
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
  			, mtch_ty
  			, mtch_ky
  		FROM
  			(
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
  				    , mtch_ty
  				    , mtch_ky
  				    , case when count(*) > 0 then 1 else 0 end as cnt
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty = #{mtch_ty}
  					and dta_ty in ('11','21','31','33','35','37','41')
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and cpr_code = #{cpr_code}
  					</if>									
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
  						and partn_cpr = #{partn_cpr}
  					</if>									
  				GROUP BY
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
  				    , mtch_ty
  				    , mtch_ky
  			union all
  			SELECT
  				    sys_se
  				    , accnut_ym
  				    , partn_cpr as cpr_code
  				    , cpr_code as partn_cpr
  				    , mtch_ty
  				    , mtch_ky
  				    , case when count(*) > 0 then 1 else 0 end as cnt
  				FROM
  				    public.batch_tbcr_inner_delng
  				WHERE
  					sys_se = #{sysSe}
  					and accnut_ym = #{accnutYm}
  					and mtch_ty = #{mtch_ty}
  					and dta_ty in ('12','22','32','34','36','38','42')
30bbef42   함상기   ai sub Matching 추가
723
  					<if test='partn_cpr != null  and !partn_cpr.equals("")'>
415842d2   함상기   20240408
724
725
726
727
  						and cpr_code = #{partn_cpr}
  					</if>									
  					<if test='cpr_code != null  and !cpr_code.equals("")'>
  						and partn_cpr = #{cpr_code}
30bbef42   함상기   ai sub Matching 추가
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
  					</if>									
  				GROUP BY
  				    sys_se
  				    , accnut_ym
  				    , cpr_code
  				    , partn_cpr
  				    , mtch_ty
  				    , mtch_ky
  			) m
  		GROUP BY	
  			sys_se
  			, accnut_ym
  			, cpr_code
  			, partn_cpr
  			, mtch_ty
  			, mtch_ky
  		HAVING sum(cnt) > 1	
  	</select>
  
  	
  	<!-- 매칭작업할 데이타 가져오기 -->
  	<select id="getAiSubDataOne" parameterType="map" resultType="map">
  		SELECT	
  			sys_se		
  		    , accnut_ym
  		    , sn
  		    , '' as compare_ky
  		    , delng_de
  			, delng_amt
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
  			and mtch_ty = #{mtchTy}
  			and mtch_ky = #{mtchKy}
  			<if test='conds eq "T".toString()'>
  				and dta_ty in ('11','21','41')
  			</if>
  			<if test='conds eq "B".toString()'>
  				and dta_ty in ('31','33','35','37')	
  			</if>
  			and delng_amt != 0		
  		ORDER BY 
  			delng_de
  	</select>
  
  	<!-- 매칭작업할 데이타 가져오기 -->
  	<select id="getAiSubDataTwo" parameterType="map" resultType="map">
  		SELECT	
  			sys_se		
  		    , accnut_ym
  		    , sn
  		    , '' as compare_ky
  		    , delng_de
  			, delng_amt
  		FROM
  		    public.batch_tbcr_inner_delng	
  		WHERE
  			sys_se = #{sysSe}
  			and accnut_ym = #{accnutYm}	
  			and cpr_code = #{cprCode}
  			and partn_cpr = #{partnCpr}
  			and mtch_ty = #{mtchTy}
  			and mtch_ky = #{mtchKy}
  			<if test='conds eq "T".toString()'>
  				and dta_ty in ('12','22','42')
  			</if>
  			<if test='conds eq "B".toString()'>
  				and dta_ty in ('32','34','36','38')	
  			</if>
  			and delng_amt != 0		
  		ORDER BY 
  			delng_de
  	</select>
  
8dc487b1   함상기   Init Version - 20...
806
  </mapper>