규모확장 Wave B: 전 11모듈 svc 75→133·batch 35→46 (BAIS 온라인 1:1)
- svc 825→1,463 (모듈당 133), batch 385→506 (모듈당 46) — 전부 새 고유 실업무 로직 + 카피북 헤더, 디스패처 133 advertise, 한글 기능설명(매니페스트 추출) - BAIS As-Is 대비: 온라인 1,463 vs 1,466(99.8%), 배치 506 vs 503(초과) - 화면 매니페스트 1,463 재생성 - 검증: build DONE modules=11 batches=506, 12서버 runok, xadmin psc 1,466 AVAIL, 매입체인 XA 커밋, 신규서비스 실데이터 스모크, 전 코퍼스 .pgc 클론 0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ea90bef264
commit
c62d91b7a7
1526 changed files with 59213 additions and 12 deletions
35
app/src/cl/batch/cl_apprstat_batch.pgc
Normal file
35
app/src/cl/batch/cl_apprstat_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* cl_apprstat_batch.pgc - cl 마감 승인현황 집계 배치 (단계별 집계 리포트, 조회 전용).
|
||||
*
|
||||
* 마감이력의 승인 단계(1차 APPR:L1 / 2차 APPR:L2 / 최종 status=A) 건수를 집계해 출력한다.
|
||||
* host 변수는 전용 카피북 cl_apprstat_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_apprstat_batch
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc; (void)argv;
|
||||
|
||||
EXEC SQL INCLUDE cl_apprstat_cpy;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(30, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT
|
||||
count(*) FILTER (WHERE memo = 'APPR:L1'),
|
||||
count(*) FILTER (WHERE memo = 'APPR:L2'),
|
||||
count(*) FILTER (WHERE status = 'A')
|
||||
INTO :as_l1, :as_l2, :as_fin FROM cl_close_log WHERE status <> 'X';
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
printf(">>> cl_apprstat_batch 승인현황: 1차=%ld 2차=%ld 최종=%ld\n", as_l1, as_l2, as_fin);
|
||||
|
||||
tpcommit(0);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
6
app/src/cl/batch/cl_apprstat_cpy.h
Normal file
6
app/src/cl/batch/cl_apprstat_cpy.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* cl_apprstat_cpy.h - cl_apprstat_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long as_l1;
|
||||
long as_l2;
|
||||
long as_fin;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
37
app/src/cl/batch/cl_cxlstat_batch.pgc
Normal file
37
app/src/cl/batch/cl_cxlstat_batch.pgc
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* cl_cxlstat_batch.pgc - cl 마감 취소현황 집계 배치 (사유별 집계 리포트, 조회 전용).
|
||||
*
|
||||
* 취소(status=X) 마감이력을 취소 사유(오류정정/지연자료/중복마감)별로 집계해 출력한다.
|
||||
* host 변수는 전용 카피북 cl_cxlstat_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_cxlstat_batch
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc; (void)argv;
|
||||
|
||||
EXEC SQL INCLUDE cl_cxlstat_cpy;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(30, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT
|
||||
count(*) FILTER (WHERE memo LIKE '취소:오류%'),
|
||||
count(*) FILTER (WHERE memo LIKE '취소:지연%'),
|
||||
count(*) FILTER (WHERE memo LIKE '취소:중복%'),
|
||||
count(*)
|
||||
INTO :cs_err, :cs_late, :cs_dup, :cs_tot FROM cl_close_log WHERE status = 'X';
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
printf(">>> cl_cxlstat_batch 취소현황: 오류정정=%ld 지연자료=%ld 중복마감=%ld 총=%ld\n",
|
||||
cs_err, cs_late, cs_dup, cs_tot);
|
||||
|
||||
tpcommit(0);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
7
app/src/cl/batch/cl_cxlstat_cpy.h
Normal file
7
app/src/cl/batch/cl_cxlstat_cpy.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* cl_cxlstat_cpy.h - cl_cxlstat_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long cs_err;
|
||||
long cs_late;
|
||||
long cs_dup;
|
||||
long cs_tot;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
54
app/src/cl/batch/cl_duelist_batch.pgc
Normal file
54
app/src/cl/batch/cl_duelist_batch.pgc
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* cl_duelist_batch.pgc - cl 마감 예정 목록 배치 (미마감 영업일 커서 출력, 조회 전용).
|
||||
*
|
||||
* 기준일 이전 14일 내 영업일(주말 제외) 중 DAILY 마감이 없는 미마감 대상일을 커서로 출력한다.
|
||||
* host 변수는 전용 카피북 cl_duelist_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_duelist_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long due = 0;
|
||||
|
||||
EXEC SQL INCLUDE cl_duelist_cpy;
|
||||
|
||||
strncpy(dl_bizdate, bizdate, sizeof(dl_bizdate)-1); dl_bizdate[sizeof(dl_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(30, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE cdueb CURSOR FOR
|
||||
SELECT to_char(d,'YYYY-MM-DD') FROM (
|
||||
SELECT (:dl_bizdate::date - s) AS d,
|
||||
extract(dow from (:dl_bizdate::date - s)) AS dw
|
||||
FROM generate_series(0,13) s) t
|
||||
WHERE dw NOT IN (0,6)
|
||||
AND NOT EXISTS (SELECT 1 FROM cl_close_log
|
||||
WHERE close_type = 'DAILY'
|
||||
AND period_key = to_char(t.d,'YYYY-MM-DD') AND status <> 'X')
|
||||
ORDER BY d DESC;
|
||||
EXEC SQL OPEN cdueb;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
printf(">>> cl_duelist_batch %s 기준 마감 예정(미마감) 목록:\n", bizdate);
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cdueb INTO :dl_day;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cdueb; tpabort(0); return 1; }
|
||||
printf(" - %s 미마감\n", dl_day);
|
||||
due++;
|
||||
}
|
||||
EXEC SQL CLOSE cdueb;
|
||||
|
||||
tpcommit(0);
|
||||
printf(">>> cl_duelist_batch 미마감 대상일 %ld건\n", due);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
5
app/src/cl/batch/cl_duelist_cpy.h
Normal file
5
app/src/cl/batch/cl_duelist_cpy.h
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/* cl_duelist_cpy.h - cl_duelist_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char dl_bizdate[16];
|
||||
char dl_day[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
55
app/src/cl/batch/cl_issclose_batch.pgc
Normal file
55
app/src/cl/batch/cl_issclose_batch.pgc
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* cl_issclose_batch.pgc - cl 발급사별 마감 배치 (발급사 커서 + ISS 마감 + XA).
|
||||
*
|
||||
* 당일 매입을 발급사(issuer)별로 커서 순회하며 발급사마다 ISS 마감이력을 1건씩 기록한다.
|
||||
* host 변수는 전용 카피북 cl_issclose_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_issclose_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long made = 0, cid, totfee = 0;
|
||||
char memo[48];
|
||||
|
||||
EXEC SQL INCLUDE cl_issclose_cpy;
|
||||
|
||||
strncpy(ic_bizdate, bizdate, sizeof(ic_bizdate)-1); ic_bizdate[sizeof(ic_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE cissb CURSOR FOR
|
||||
SELECT issuer, count(*), coalesce(sum(amount),0), coalesce(sum(fee),0)
|
||||
FROM purchase WHERE biz_date = :ic_bizdate
|
||||
GROUP BY issuer ORDER BY 3 DESC;
|
||||
EXEC SQL OPEN cissb;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cissb INTO :ic_iss, :ic_cnt, :ic_amt, :ic_fee;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cissb; tpabort(0); return 1; }
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { EXEC SQL CLOSE cissb; tpabort(0); return 1; }
|
||||
snprintf(memo, sizeof(memo), "발급사마감(배치):%s", ic_iss);
|
||||
if (cldb_insert_close(cid, "ISS", ic_bizdate, ic_bizdate, "C", ic_cnt, ic_amt, memo) < 0) {
|
||||
EXEC SQL CLOSE cissb; tpabort(0); return 1;
|
||||
}
|
||||
totfee += ic_fee;
|
||||
made++;
|
||||
}
|
||||
EXEC SQL CLOSE cissb;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_issclose_batch COMMIT: %s 발급사마감 %ld건 수수료합=%ld\n", bizdate, made, totfee);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
8
app/src/cl/batch/cl_issclose_cpy.h
Normal file
8
app/src/cl/batch/cl_issclose_cpy.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
/* cl_issclose_cpy.h - cl_issclose_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char ic_bizdate[16];
|
||||
char ic_iss[24];
|
||||
long ic_cnt;
|
||||
long ic_amt;
|
||||
long ic_fee;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
42
app/src/cl/batch/cl_mainclose_batch.pgc
Normal file
42
app/src/cl/batch/cl_mainclose_batch.pgc
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* cl_mainclose_batch.pgc - cl 본마감 승격 배치 (가마감 재집계 + O->C 승격 + XA).
|
||||
*
|
||||
* 당일 가마감(TENT, status=O) 이력을 당일 전체 매입으로 재집계해 확정(status=C)으로 승격.
|
||||
* host 변수는 전용 카피북 cl_mainclose_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_mainclose_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long promoted;
|
||||
|
||||
EXEC SQL INCLUDE cl_mainclose_cpy;
|
||||
|
||||
strncpy(mc_bizdate, bizdate, sizeof(mc_bizdate)-1); mc_bizdate[sizeof(mc_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :mc_cnt, :mc_amt
|
||||
FROM purchase WHERE biz_date = :mc_bizdate;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
EXEC SQL UPDATE cl_close_log
|
||||
SET status = 'C', txn_count = :mc_cnt, total_amount = :mc_amt, memo = '본마감(배치)', updated_at = now()
|
||||
WHERE close_type = 'TENT' AND period_key = :mc_bizdate AND status = 'O';
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
promoted = (long)sqlca.sqlerrd[2];
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_mainclose_batch COMMIT: %s 본마감 승격 %ld건 확정건수=%ld\n", bizdate, promoted, mc_cnt);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
6
app/src/cl/batch/cl_mainclose_cpy.h
Normal file
6
app/src/cl/batch/cl_mainclose_cpy.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* cl_mainclose_cpy.h - cl_mainclose_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char mc_bizdate[16];
|
||||
long mc_cnt;
|
||||
long mc_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
59
app/src/cl/batch/cl_netcross_batch.pgc
Normal file
59
app/src/cl/batch/cl_netcross_batch.pgc
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* cl_netcross_batch.pgc - cl 정산액 크로스검증 배치 (마감별 스냅샷 net vs 매입 net + XA).
|
||||
*
|
||||
* 당일 확정(C) 마감이력을 커서 순회하며 각 마감의 스냅샷 net 합계와 당일 매입 net 합계를
|
||||
* 대사하고 편차가 있는 마감을 출력한다 (조회 전용 XA 브랜치).
|
||||
* host 변수는 전용 카피북 cl_netcross_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_netcross_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long checked = 0, mism = 0, delta;
|
||||
|
||||
EXEC SQL INCLUDE cl_netcross_cpy;
|
||||
|
||||
strncpy(nx_bizdate, bizdate, sizeof(nx_bizdate)-1); nx_bizdate[sizeof(nx_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :nx_real
|
||||
FROM purchase WHERE biz_date = :nx_bizdate;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
EXEC SQL DECLARE cnxb CURSOR FOR
|
||||
SELECT close_id FROM cl_close_log
|
||||
WHERE period_key = :nx_bizdate AND status = 'C' ORDER BY close_id;
|
||||
EXEC SQL OPEN cnxb;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
printf(">>> cl_netcross_batch %s 정산액 크로스검증 (매입 net=%ld)\n", bizdate, nx_real);
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cnxb INTO :nx_cid;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnxb; tpabort(0); return 1; }
|
||||
EXEC SQL SELECT coalesce(sum(net_amount),0) INTO :nx_snap
|
||||
FROM cl_snapshot WHERE close_id = :nx_cid;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnxb; tpabort(0); return 1; }
|
||||
delta = nx_snap - nx_real; if (delta < 0) delta = -delta;
|
||||
if (nx_snap != 0 && delta != 0) {
|
||||
printf(" ! cid=%ld 스냅샷net=%ld 편차=%ld\n", nx_cid, nx_snap, delta);
|
||||
mism++;
|
||||
}
|
||||
checked++;
|
||||
}
|
||||
EXEC SQL CLOSE cnxb;
|
||||
|
||||
tpcommit(0);
|
||||
printf(">>> cl_netcross_batch 점검=%ld건 편차=%ld건\n", checked, mism);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
7
app/src/cl/batch/cl_netcross_cpy.h
Normal file
7
app/src/cl/batch/cl_netcross_cpy.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* cl_netcross_cpy.h - cl_netcross_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char nx_bizdate[16];
|
||||
long nx_cid;
|
||||
long nx_snap;
|
||||
long nx_real;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
54
app/src/cl/batch/cl_segclose_batch.pgc
Normal file
54
app/src/cl/batch/cl_segclose_batch.pgc
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* cl_segclose_batch.pgc - cl 부문별 마감 배치 (업종 커서 + 부문마다 SEG 마감 + XA).
|
||||
*
|
||||
* 당일 매입을 업종(category) 부문으로 커서 순회하며 부문마다 SEG 마감이력을 1건씩 기록한다.
|
||||
* host 변수는 전용 카피북 cl_segclose_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_segclose_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long made = 0, cid;
|
||||
char memo[48];
|
||||
|
||||
EXEC SQL INCLUDE cl_segclose_cpy;
|
||||
|
||||
strncpy(sc_bizdate, bizdate, sizeof(sc_bizdate)-1); sc_bizdate[sizeof(sc_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE csegb CURSOR FOR
|
||||
SELECT category, count(*), coalesce(sum(amount),0)
|
||||
FROM purchase WHERE biz_date = :sc_bizdate
|
||||
GROUP BY category ORDER BY category;
|
||||
EXEC SQL OPEN csegb;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH csegb INTO :sc_cat, :sc_cnt, :sc_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE csegb; tpabort(0); return 1; }
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { EXEC SQL CLOSE csegb; tpabort(0); return 1; }
|
||||
snprintf(memo, sizeof(memo), "부문마감(배치):%s", sc_cat);
|
||||
if (cldb_insert_close(cid, "SEG", sc_bizdate, sc_bizdate, "C", sc_cnt, sc_amt, memo) < 0) {
|
||||
EXEC SQL CLOSE csegb; tpabort(0); return 1;
|
||||
}
|
||||
made++;
|
||||
}
|
||||
EXEC SQL CLOSE csegb;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_segclose_batch COMMIT: %s 부문마감 %ld건 생성\n", bizdate, made);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
7
app/src/cl/batch/cl_segclose_cpy.h
Normal file
7
app/src/cl/batch/cl_segclose_cpy.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* cl_segclose_cpy.h - cl_segclose_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char sc_bizdate[16];
|
||||
char sc_cat[16];
|
||||
long sc_cnt;
|
||||
long sc_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
54
app/src/cl/batch/cl_semimonth_batch.pgc
Normal file
54
app/src/cl/batch/cl_semimonth_batch.pgc
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* cl_semimonth_batch.pgc - cl 반월 마감 배치 (전반/후반 집계 + SEMIMON 마감 + XA).
|
||||
*
|
||||
* 기준일이 속한 반월(전반 1~15 / 후반 16~말) 구간 매입을 집계해 SEMIMON 마감이력을 기록.
|
||||
* host 변수는 전용 카피북 cl_semimonth_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_semimonth_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long cid, half;
|
||||
char period[24], memo[32];
|
||||
|
||||
EXEC SQL INCLUDE cl_semimonth_cpy;
|
||||
|
||||
strncpy(sm_bizdate, bizdate, sizeof(sm_bizdate)-1); sm_bizdate[sizeof(sm_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT extract(day from :sm_bizdate::date)::int,
|
||||
to_char(:sm_bizdate::date, 'YYYY-MM') INTO :sm_day, :sm_ym;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
half = (sm_day <= 15) ? 1 : 2;
|
||||
sm_lo = (half == 1) ? 1 : 16;
|
||||
sm_hi = (half == 1) ? 15 : 31;
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :sm_cnt, :sm_amt
|
||||
FROM purchase WHERE to_char(biz_date,'YYYY-MM') = :sm_ym
|
||||
AND extract(day from biz_date) BETWEEN :sm_lo AND :sm_hi;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
snprintf(period, sizeof(period), "%s-H%ld", sm_ym, half);
|
||||
snprintf(memo, sizeof(memo), "반월마감(배치):%s", (half == 1) ? "전반" : "후반");
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { tpabort(0); return 1; }
|
||||
if (cldb_insert_close(cid, "SEMIMON", period, bizdate, "C", sm_cnt, sm_amt, memo) < 0) {
|
||||
tpabort(0); return 1;
|
||||
}
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_semimonth_batch COMMIT: %s %s cid=%ld 건수=%ld\n",
|
||||
sm_ym, (half==1)?"전반":"후반", cid, sm_cnt);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
10
app/src/cl/batch/cl_semimonth_cpy.h
Normal file
10
app/src/cl/batch/cl_semimonth_cpy.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* cl_semimonth_cpy.h - cl_semimonth_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char sm_bizdate[16];
|
||||
char sm_ym[16];
|
||||
long sm_day;
|
||||
long sm_lo;
|
||||
long sm_hi;
|
||||
long sm_cnt;
|
||||
long sm_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
53
app/src/cl/batch/cl_tenday_batch.pgc
Normal file
53
app/src/cl/batch/cl_tenday_batch.pgc
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* cl_tenday_batch.pgc - cl 순(10일) 마감 배치 (상/중/하순 집계 + TENDAY 마감 + XA).
|
||||
*
|
||||
* 기준일이 속한 순(1~10/11~20/21~말) 구간의 매입을 집계해 TENDAY 마감이력을 기록한다.
|
||||
* host 변수는 전용 카피북 cl_tenday_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_tenday_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long cid, dec;
|
||||
char period[24], memo[32];
|
||||
|
||||
EXEC SQL INCLUDE cl_tenday_cpy;
|
||||
|
||||
strncpy(td_bizdate, bizdate, sizeof(td_bizdate)-1); td_bizdate[sizeof(td_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT extract(day from :td_bizdate::date)::int,
|
||||
to_char(:td_bizdate::date, 'YYYY-MM') INTO :td_day, :td_ym;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
dec = (td_day <= 10) ? 1 : (td_day <= 20 ? 2 : 3);
|
||||
td_lo = (dec - 1) * 10 + 1;
|
||||
td_hi = (dec == 3) ? 31 : dec * 10;
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :td_cnt, :td_amt
|
||||
FROM purchase WHERE to_char(biz_date,'YYYY-MM') = :td_ym
|
||||
AND extract(day from biz_date) BETWEEN :td_lo AND :td_hi;
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
snprintf(period, sizeof(period), "%s-T%ld", td_ym, dec);
|
||||
snprintf(memo, sizeof(memo), "순마감(배치):%ld순", dec);
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { tpabort(0); return 1; }
|
||||
if (cldb_insert_close(cid, "TENDAY", period, bizdate, "C", td_cnt, td_amt, memo) < 0) {
|
||||
tpabort(0); return 1;
|
||||
}
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_tenday_batch COMMIT: %s %ld순 cid=%ld 건수=%ld\n", td_ym, dec, cid, td_cnt);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
10
app/src/cl/batch/cl_tenday_cpy.h
Normal file
10
app/src/cl/batch/cl_tenday_cpy.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/* cl_tenday_cpy.h - cl_tenday_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char td_bizdate[16];
|
||||
char td_ym[16];
|
||||
long td_day;
|
||||
long td_lo;
|
||||
long td_hi;
|
||||
long td_cnt;
|
||||
long td_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
42
app/src/cl/batch/cl_tentclose_batch.pgc
Normal file
42
app/src/cl/batch/cl_tentclose_batch.pgc
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* cl_tentclose_batch.pgc - cl 가마감(잠정) 배치 (접수/대사 잠정집계 + TENT(O) + XA).
|
||||
*
|
||||
* 당일 접수(A)/대사완료(M) 매입을 잠정 집계해 가마감(status=O) 이력을 1건 기록한다.
|
||||
* host 변수는 전용 카피북 cl_tentclose_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_tentclose_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long cid;
|
||||
|
||||
EXEC SQL INCLUDE cl_tentclose_cpy;
|
||||
|
||||
strncpy(tc_bizdate, bizdate, sizeof(tc_bizdate)-1); tc_bizdate[sizeof(tc_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :tc_cnt, :tc_amt
|
||||
FROM purchase WHERE biz_date = :tc_bizdate AND status IN ('A','M');
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { tpabort(0); return 1; }
|
||||
if (cldb_insert_close(cid, "TENT", bizdate, bizdate, "O", tc_cnt, tc_amt, "가마감(배치)") < 0) {
|
||||
tpabort(0); return 1;
|
||||
}
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_tentclose_batch COMMIT: %s 가마감 cid=%ld 잠정건수=%ld\n", bizdate, cid, tc_cnt);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
6
app/src/cl/batch/cl_tentclose_cpy.h
Normal file
6
app/src/cl/batch/cl_tentclose_cpy.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
/* cl_tentclose_cpy.h - cl_tentclose_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char tc_bizdate[16];
|
||||
long tc_cnt;
|
||||
long tc_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
44
app/src/cl/batch/cl_weekly_batch.pgc
Normal file
44
app/src/cl/batch/cl_weekly_batch.pgc
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* cl_weekly_batch.pgc - cl 주 마감 배치 (주간 집계 + WEEKLY 마감이력 + XA).
|
||||
*
|
||||
* 기준일이 속한 주(월~일) 매입을 집계해 WEEKLY 마감이력(close_log)을 1건 기록한다.
|
||||
* host 변수는 전용 카피북 cl_weekly_cpy.h 를 EXEC SQL INCLUDE 로 가져온다.
|
||||
* Usage: cl_weekly_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long cid;
|
||||
|
||||
EXEC SQL INCLUDE cl_weekly_cpy;
|
||||
|
||||
strncpy(wk_bizdate, bizdate, sizeof(wk_bizdate)-1); wk_bizdate[sizeof(wk_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT to_char(date_trunc('week', :wk_bizdate::date), 'IYYY"W"IW'),
|
||||
count(*), coalesce(sum(amount),0)
|
||||
INTO :wk_key, :wk_cnt, :wk_amt FROM purchase
|
||||
WHERE date_trunc('week', biz_date) = date_trunc('week', :wk_bizdate::date);
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "AGG FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) { tpabort(0); return 1; }
|
||||
if (cldb_insert_close(cid, "WEEKLY", wk_key, bizdate, "C", wk_cnt, wk_amt, "주마감(배치)") < 0) {
|
||||
tpabort(0); return 1;
|
||||
}
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_weekly_batch COMMIT: 주=%s cid=%ld 건수=%ld 금액=%ld\n", wk_key, cid, wk_cnt, wk_amt);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
7
app/src/cl/batch/cl_weekly_cpy.h
Normal file
7
app/src/cl/batch/cl_weekly_cpy.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* cl_weekly_cpy.h - cl_weekly_batch 전용 카피북 (host 변수 선언, EXEC SQL INCLUDE 대상). */
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char wk_bizdate[16];
|
||||
char wk_key[16];
|
||||
long wk_cnt;
|
||||
long wk_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
Loading…
Add table
Add a link
Reference in a new issue