Phase 2c: 전 11모듈 per-service 레거시 구조 분해·확장 (실동작 유지)
- 10개 모듈(au py rc st lg cl mm vl mg cm)을 ac 템플릿대로 분해: svc/ 30 서비스 .pgc + 카피북 .h, 얇은 <mod>_svr 디스패처 dbio/ ~25 .pgc(+.h), batch/ ~17 .pgc, run/ ~17 .sh (모듈마다) - 파일: svc 330 + dbio 276 + batch 187 + run 187, 총 소스 1602본 - 서비스별 고유 실로직(정규화 md5), build.sh 자동발견(inline/split 양립) - 통합 검증: build DONE modules=11 servers=11 batches=187, 12서버 runok, 333 서비스 AVAIL, 매입체인 XA 커밋(status=S), prepared_xacts=0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c3b99a8b75
commit
fd8b418c6e
1404 changed files with 30322 additions and 5994 deletions
45
app/src/cl/batch/cl_approve_batch.pgc
Normal file
45
app/src/cl/batch/cl_approve_batch.pgc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* cl_approve_batch.pgc - cl 마감완료(C) 일괄 승인 배치 (커서 C->A) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_approve_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long rows = 0;
|
||||
EXEC SQL DECLARE cab CURSOR FOR
|
||||
SELECT close_id FROM cl_close_log
|
||||
WHERE biz_date = :h_bizdate AND status = 'C' ORDER BY close_id;
|
||||
EXEC SQL OPEN cab;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cab INTO :h_cid;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cab; tpabort(0); return 1; }
|
||||
if (cldb_update_close_status(h_cid, "A") < 0) { EXEC SQL CLOSE cab; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE cab;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_approve_batch COMMIT: bizdate=%s 승인=%ld건\n", bizdate, rows);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/cl/batch/cl_archive_batch.pgc
Normal file
35
app/src/cl/batch/cl_archive_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* cl_archive_batch.pgc - cl 완료마감 아카이브 표시 배치 (dbio update) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_archive_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
#include "cl_archive_mark_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long marked;
|
||||
marked = clqdb_archive_mark(bizdate);
|
||||
if (marked < 0) { fprintf(stderr, "cl_archive_batch FAIL\n"); tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_archive_batch COMMIT: %s 이전 완료마감 %ld건 아카이브\n", bizdate, marked);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
47
app/src/cl/batch/cl_lock_batch.pgc
Normal file
47
app/src/cl/batch/cl_lock_batch.pgc
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* cl_lock_batch.pgc - cl 기간 잠금 배치 (커서, 월 close_log 기간 잠금) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_lock_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
char h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long rows = 0;
|
||||
EXEC SQL DECLARE clb CURSOR FOR
|
||||
SELECT DISTINCT period_key FROM cl_close_log
|
||||
WHERE close_type = 'MONTHLY' AND status IN ('A','C') ORDER BY period_key;
|
||||
EXEC SQL OPEN clb;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH clb INTO :h_period;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE clb; tpabort(0); return 1; }
|
||||
EXEC SQL INSERT INTO cl_period_lock (period_key, locked) VALUES (:h_period, true)
|
||||
ON CONFLICT (period_key) DO UPDATE SET locked = true, locked_at = now();
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE clb; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE clb;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_lock_batch COMMIT: %ld개 기간 잠금\n", rows);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
38
app/src/cl/batch/cl_midclose_batch.pgc
Normal file
38
app/src/cl/batch/cl_midclose_batch.pgc
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* cl_midclose_batch.pgc - cl 중간 마감 배치 (접수/대사 A,M 집계 + MID close_log) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_midclose_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cnt, h_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long cid;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate AND status IN ('A','M');
|
||||
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, "MID", bizdate, bizdate, "O", h_cnt, h_amt, "중간마감(배치)") < 0) { tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_midclose_batch COMMIT: bizdate=%s cid=%ld 미마감대상=%ld\n", bizdate, cid, h_cnt);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
40
app/src/cl/batch/cl_monthly_batch.pgc
Normal file
40
app/src/cl/batch/cl_monthly_batch.pgc
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* cl_monthly_batch.pgc - cl 월 마감 배치 (월 집계 + close_log MONTHLY) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_monthly_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
char h_period[16];
|
||||
long h_cnt, h_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long cid;
|
||||
strncpy(h_period, bizdate, 7); h_period[7] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE to_char(biz_date,'YYYY-MM') = :h_period;
|
||||
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, "MONTHLY", h_period, bizdate, "C", h_cnt, h_amt, "월마감(배치)") < 0) { tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_monthly_batch COMMIT: period=%s cid=%ld 건수=%ld 총액=%ld\n", h_period, cid, h_cnt, h_amt);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/cl/batch/cl_purge_batch.pgc
Normal file
35
app/src/cl/batch/cl_purge_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* cl_purge_batch.pgc - cl 취소(X) 마감 정리 배치 (dbio delete) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_purge_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
#include "cl_cancel_purge_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long purged;
|
||||
purged = clqdb_cancel_purge(bizdate);
|
||||
if (purged < 0) { fprintf(stderr, "cl_purge_batch FAIL\n"); tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_purge_batch COMMIT: %s 이전 취소마감 %ld건 삭제\n", bizdate, purged);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
45
app/src/cl/batch/cl_quarter_batch.pgc
Normal file
45
app/src/cl/batch/cl_quarter_batch.pgc
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* cl_quarter_batch.pgc - cl 분기 마감 배치 (분기 프리픽스 집계) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_quarter_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
char h_year[8];
|
||||
long h_cnt, h_amt, h_q;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long cid;
|
||||
char period[16];
|
||||
int mm = (bizdate[5]-'0')*10 + (bizdate[6]-'0');
|
||||
h_q = (mm - 1) / 3 + 1;
|
||||
strncpy(h_year, bizdate, 4); h_year[4] = 0;
|
||||
snprintf(period, sizeof(period), "%s-Q%ld", h_year, h_q);
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE to_char(biz_date,'YYYY') = :h_year
|
||||
AND (extract(month from biz_date)::int - 1) / 3 + 1 = :h_q;
|
||||
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, "QUARTER", period, bizdate, "C", h_cnt, h_amt, "분기마감(배치)") < 0) { tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_quarter_batch COMMIT: period=%s cid=%ld 건수=%ld\n", period, cid, h_cnt);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
48
app/src/cl/batch/cl_recon_batch.pgc
Normal file
48
app/src/cl/batch/cl_recon_batch.pgc
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* cl_recon_batch.pgc - cl 마감 대사 배치 (커서, close_log vs purchase 총액 대사) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_recon_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cid, h_tsum, h_asum;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long checked = 0, bad = 0;
|
||||
EXEC SQL DECLARE cnb CURSOR FOR
|
||||
SELECT close_id, total_amount FROM cl_close_log
|
||||
WHERE close_type = 'DAILY' AND biz_date = :h_bizdate AND status <> 'X'
|
||||
ORDER BY close_id;
|
||||
EXEC SQL OPEN cnb;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cnb INTO :h_cid, :h_tsum;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnb; tpabort(0); return 1; }
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_asum FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cnb; tpabort(0); return 1; }
|
||||
if (h_tsum != h_asum) { bad++; printf(" cid=%ld 총액 불일치 마감=%ld 실제=%ld\n", h_cid, h_tsum, h_asum); }
|
||||
checked++;
|
||||
}
|
||||
EXEC SQL CLOSE cnb;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_recon_batch COMMIT: bizdate=%s 대사=%ld 불일치=%ld\n", bizdate, checked, bad);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
46
app/src/cl/batch/cl_report_batch.pgc
Normal file
46
app/src/cl/batch/cl_report_batch.pgc
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* cl_report_batch.pgc - cl 마감 리포트 배치 (커서, 마감별 총계 출력) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_report_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cid, h_cnt, h_amt;
|
||||
char h_type[16], h_status[8];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long rows = 0;
|
||||
EXEC SQL DECLARE crb CURSOR FOR
|
||||
SELECT close_id, close_type, status, txn_count, total_amount FROM cl_close_log
|
||||
WHERE biz_date = :h_bizdate ORDER BY close_id;
|
||||
EXEC SQL OPEN crb;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH crb INTO :h_cid, :h_type, :h_status, :h_cnt, :h_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE crb; tpabort(0); return 1; }
|
||||
printf(" cid=%ld %-8s [%s] 건수=%ld 총액=%ld\n", h_cid, h_type, h_status, h_cnt, h_amt);
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE crb;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_report_batch COMMIT: bizdate=%s 마감 %ld건\n", bizdate, rows);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/cl/batch/cl_restore_batch.pgc
Normal file
35
app/src/cl/batch/cl_restore_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* cl_restore_batch.pgc - cl 취소(X) 마감 복원 배치 (dbio update) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_restore_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "cl_dbio.h"
|
||||
#include "cl_restore_count_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long restored;
|
||||
restored = clqdb_restore_count(bizdate);
|
||||
if (restored < 0) { fprintf(stderr, "cl_restore_batch FAIL\n"); tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_restore_batch COMMIT: %s 취소마감 %ld건 개시복원\n", bizdate, restored);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
48
app/src/cl/batch/cl_rollup_batch.pgc
Normal file
48
app/src/cl/batch/cl_rollup_batch.pgc
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* cl_rollup_batch.pgc - cl 마감 스냅샷 롤업 배치 (커서, 마감별 gross/fee/net 집계) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_rollup_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cid, h_gross, h_fee, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long rows = 0;
|
||||
EXEC SQL DECLARE crl CURSOR FOR
|
||||
SELECT s.close_id, coalesce(sum(s.gross_amount),0),
|
||||
coalesce(sum(s.fee_amount),0), coalesce(sum(s.net_amount),0)
|
||||
FROM cl_snapshot s JOIN cl_close_log c ON c.close_id = s.close_id
|
||||
WHERE c.biz_date = :h_bizdate GROUP BY s.close_id ORDER BY s.close_id;
|
||||
EXEC SQL OPEN crl;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH crl INTO :h_cid, :h_gross, :h_fee, :h_net;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE crl; tpabort(0); return 1; }
|
||||
if (cldb_update_close_totals(h_cid, 0, h_gross) < 0) { EXEC SQL CLOSE crl; tpabort(0); return 1; }
|
||||
printf(" cid=%ld gross=%ld fee=%ld net=%ld\n", h_cid, h_gross, h_fee, h_net);
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE crl;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_rollup_batch COMMIT: bizdate=%s 롤업 %ld마감\n", bizdate, rows);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
38
app/src/cl/batch/cl_seq_batch.pgc
Normal file
38
app/src/cl/batch/cl_seq_batch.pgc
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* cl_seq_batch.pgc - cl 마감유형 순번 일괄 발번 배치 (dbio upsert 반복) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_seq_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
const char *types[] = { "DAILY", "MONTHLY", "QUARTER", "YEAREND", NULL };
|
||||
long seq; int i;
|
||||
for (i = 0; types[i] != NULL; i++) {
|
||||
seq = cldb_bump_seq(types[i]);
|
||||
if (seq < 0) { fprintf(stderr, "bump %s FAIL\n", types[i]); tpabort(0); return 1; }
|
||||
printf(" %-8s -> seq %ld\n", types[i], seq);
|
||||
}
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_seq_batch COMMIT: bizdate=%s 유형 %d종 발번\n", bizdate, i);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
37
app/src/cl/batch/cl_unclosed_batch.pgc
Normal file
37
app/src/cl/batch/cl_unclosed_batch.pgc
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* cl_unclosed_batch.pgc - cl 미마감 영업일 점검 배치 (단건 집계) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_unclosed_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_days, h_alert;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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(DISTINCT p.biz_date) INTO :h_days FROM purchase p
|
||||
WHERE NOT EXISTS (SELECT 1 FROM cl_close_log c
|
||||
WHERE c.close_type = 'DAILY' AND c.biz_date = p.biz_date AND c.status <> 'X');
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "DAYS FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
EXEC SQL SELECT count(*) INTO :h_alert FROM purchase WHERE biz_date = :h_bizdate AND status = 'M';
|
||||
if (sqlca.sqlcode < 0) { tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_unclosed_batch COMMIT: 미마감 영업일=%ld 당일 대사완료 미마감=%ld\n", h_days, h_alert);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
49
app/src/cl/batch/cl_verify_batch.pgc
Normal file
49
app/src/cl/batch/cl_verify_batch.pgc
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* cl_verify_batch.pgc - cl 마감 검증 배치 (커서, 저장건수 vs 실제 대사) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_verify_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cid, h_stored, h_actual;
|
||||
char h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long checked = 0, bad = 0;
|
||||
EXEC SQL DECLARE cvb CURSOR FOR
|
||||
SELECT close_id, txn_count, period_key FROM cl_close_log
|
||||
WHERE close_type = 'DAILY' AND biz_date = :h_bizdate AND status <> 'X'
|
||||
ORDER BY close_id;
|
||||
EXEC SQL OPEN cvb;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cvb INTO :h_cid, :h_stored, :h_period;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cvb; tpabort(0); return 1; }
|
||||
EXEC SQL SELECT count(*) INTO :h_actual FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cvb; tpabort(0); return 1; }
|
||||
if (h_stored != h_actual) { bad++; printf(" cid=%ld 불일치 저장=%ld 실제=%ld\n", h_cid, h_stored, h_actual); }
|
||||
checked++;
|
||||
}
|
||||
EXEC SQL CLOSE cvb;
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_verify_batch COMMIT: bizdate=%s 검증=%ld 불일치=%ld\n", bizdate, checked, bad);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
40
app/src/cl/batch/cl_yearend_batch.pgc
Normal file
40
app/src/cl/batch/cl_yearend_batch.pgc
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* cl_yearend_batch.pgc - cl 연말 마감 배치 (연도 집계) (XA 배치).
|
||||
*
|
||||
* ATMI client: tpinit/tpopen open the ECPG XA RM, tpbegin starts ONE global
|
||||
* transaction; EXEC SQL work runs on that branch, then tpcommit drives XA 2PC.
|
||||
* Usage: cl_yearend_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";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
char h_year[8];
|
||||
long h_cnt, h_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_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; }
|
||||
|
||||
long cid;
|
||||
strncpy(h_year, bizdate, 4); h_year[4] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE to_char(biz_date,'YYYY') = :h_year;
|
||||
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, "YEAREND", h_year, bizdate, "C", h_cnt, h_amt, "연마감(배치)") < 0) { tpabort(0); return 1; }
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> cl_yearend_batch COMMIT: year=%s cid=%ld 건수=%ld 총액=%ld\n", h_year, cid, h_cnt, h_amt);
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
/*
|
||||
* cl_svr.pgc - cl (마감/closing) MODULE SERVER.
|
||||
* cl_svr.pgc - cl (마감/closing) MODULE SERVER (thin dispatcher).
|
||||
*
|
||||
* ONE binary that tpadvertise()s ALL ~30 online cl services (the real Tuxedo
|
||||
* "one module server, many services" pattern). Every service is a distinct 마감
|
||||
* operation with genuine EXEC SQL (directly, or via the linked libcldbio.a dbio
|
||||
* layer) and common helpers from libacqcommon.a.
|
||||
* The legacy "one module server, many services" pattern: this binary owns NO
|
||||
* business logic. Each of cl's 30 online services now lives in its own file
|
||||
* (app/src/cl/svc/<SVCNAME>.pgc) with its own copybook header
|
||||
* (app/src/cl/svc/<SVCNAME>.h); those objects are archived into libclsvc.a and
|
||||
* linked into this server. Here we only:
|
||||
* - include every service copybook (for the extern prototypes),
|
||||
* - tpopen() the ECPG XA RM,
|
||||
* - tpadvertise() all services from a {name, fn} table,
|
||||
* - tpclose() at shutdown.
|
||||
*
|
||||
* 마감 도메인: 일/월/분기/연 마감 이력(close_log), 가맹점별 마감 스냅샷(snapshot),
|
||||
* 기간 잠금(period_lock). 마감 상태 O=개시 -> C=마감완료 -> A=승인 -> L=잠금,
|
||||
|
|
@ -13,44 +18,43 @@
|
|||
* XA: the connection is opened once by tpopen() (ECPG XA switch libndrxxaecpg.so);
|
||||
* there is NO EXEC SQL CONNECT. Each tpcall runs on this process's XA branch.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include <ubf.h>
|
||||
#include <userlog.h>
|
||||
#include <ndebug.h>
|
||||
#include "acq.fd.h"
|
||||
#include "cl_dbio.h"
|
||||
#include "acq_common.h"
|
||||
|
||||
/* ----- small UBF helpers ------------------------------------------------- */
|
||||
static long getl(UBFH *b, BFLDID f) { long v = 0; Bget(b, f, 0, (char *)&v, 0L); return v; }
|
||||
static void gets_(UBFH *b, BFLDID f, char *out, int cap)
|
||||
{ BFLDLEN l = cap; out[0] = 0; Bget(b, f, 0, out, &l); }
|
||||
static void setl(UBFH *b, BFLDID f, long v) { Bchg(b, f, 0, (char *)&v, 0L); }
|
||||
/* every cl service's copybook header (declares its record struct + prototype) */
|
||||
#include "CL_DAILY.h"
|
||||
#include "CL_MONTHLY.h"
|
||||
#include "CL_QUARTER.h"
|
||||
#include "CL_SNAPSHOT.h"
|
||||
#include "CL_RECLOSE.h"
|
||||
#include "CL_VERIFY.h"
|
||||
#include "CL_CANCEL.h"
|
||||
#include "CL_STATS.h"
|
||||
#include "CL_BALVERIFY.h"
|
||||
#include "CL_SEQ.h"
|
||||
#include "CL_REPORT.h"
|
||||
#include "CL_ALERT.h"
|
||||
#include "CL_UNCLOSED.h"
|
||||
#include "CL_APPROVE.h"
|
||||
#include "CL_LOCK.h"
|
||||
#include "CL_UNLOCK.h"
|
||||
#include "CL_AGGREGATE.h"
|
||||
#include "CL_DIFFCHK.h"
|
||||
#include "CL_SUMMARY.h"
|
||||
#include "CL_STATUS.h"
|
||||
#include "CL_ROLLBACK.h"
|
||||
#include "CL_CONFIRM.h"
|
||||
#include "CL_PERIOD.h"
|
||||
#include "CL_YEAREND.h"
|
||||
#include "CL_MIDCLOSE.h"
|
||||
#include "CL_RECON.h"
|
||||
#include "CL_ARCHIVE.h"
|
||||
#include "CL_PURGE.h"
|
||||
#include "CL_RESTORE.h"
|
||||
#include "CL_INQUIRY.h"
|
||||
|
||||
#define FAIL(b) do { tpreturn(TPFAIL, 0, (char *)(b), 0L, 0L); return; } while (0)
|
||||
#define OK(b) do { tpreturn(TPSUCCESS, 0, (char *)(b), 0L, 0L); return; } while (0)
|
||||
|
||||
/* ----- service prototypes ------------------------------------------------ */
|
||||
void CL_DAILY(TPSVCINFO *p); void CL_MONTHLY(TPSVCINFO *p);
|
||||
void CL_QUARTER(TPSVCINFO *p); void CL_SNAPSHOT(TPSVCINFO *p);
|
||||
void CL_RECLOSE(TPSVCINFO *p); void CL_VERIFY(TPSVCINFO *p);
|
||||
void CL_CANCEL(TPSVCINFO *p); void CL_STATS(TPSVCINFO *p);
|
||||
void CL_BALVERIFY(TPSVCINFO *p); void CL_SEQ(TPSVCINFO *p);
|
||||
void CL_REPORT(TPSVCINFO *p); void CL_ALERT(TPSVCINFO *p);
|
||||
void CL_UNCLOSED(TPSVCINFO *p); void CL_APPROVE(TPSVCINFO *p);
|
||||
void CL_LOCK(TPSVCINFO *p); void CL_UNLOCK(TPSVCINFO *p);
|
||||
void CL_AGGREGATE(TPSVCINFO *p); void CL_DIFFCHK(TPSVCINFO *p);
|
||||
void CL_SUMMARY(TPSVCINFO *p); void CL_STATUS(TPSVCINFO *p);
|
||||
void CL_ROLLBACK(TPSVCINFO *p); void CL_CONFIRM(TPSVCINFO *p);
|
||||
void CL_PERIOD(TPSVCINFO *p); void CL_YEAREND(TPSVCINFO *p);
|
||||
void CL_MIDCLOSE(TPSVCINFO *p); void CL_RECON(TPSVCINFO *p);
|
||||
void CL_ARCHIVE(TPSVCINFO *p); void CL_PURGE(TPSVCINFO *p);
|
||||
void CL_RESTORE(TPSVCINFO *p); void CL_INQUIRY(TPSVCINFO *p);
|
||||
|
||||
/* ----- advertise table (this is what "scales to 30" cleanly) ------------- */
|
||||
/* ----- advertise table: {service name, function} (fn is extern from its file) */
|
||||
static struct { const char *name; void (*fn)(TPSVCINFO *); } SVCS[] = {
|
||||
{"CL_DAILY", CL_DAILY}, {"CL_MONTHLY", CL_MONTHLY},
|
||||
{"CL_QUARTER", CL_QUARTER}, {"CL_SNAPSHOT", CL_SNAPSHOT},
|
||||
|
|
@ -93,558 +97,4 @@ void tpsvrdone(void)
|
|||
userlog("cl_svr: tpsvrdone");
|
||||
}
|
||||
|
||||
/* 공통: 매입 집계 후 마감 이력 생성 헬퍼 (일/월/분기/연 공용). */
|
||||
static int cl_open_close(UBFH *b, const char *ctype, const char *period,
|
||||
const char *bizdate, long *cid_out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_amt, h_cid;
|
||||
char h_bizdate[16], h_type[16], h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
|
||||
if (strcmp(ctype, "DAILY") == 0) {
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount), 0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
} else {
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount), 0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE to_char(biz_date, 'YYYY-MM') LIKE :h_period || '%';
|
||||
}
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
|
||||
h_cid = cldb_next_close_id();
|
||||
if (h_cid < 0) return -1;
|
||||
if (cldb_insert_close(h_cid, ctype, period, bizdate, "C", h_cnt, h_amt, "마감") < 0) return -1;
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_amt);
|
||||
*cid_out = h_cid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
/* 1. CL_DAILY - 일 마감: 당일 매입 집계 후 마감이력(DAILY) 생성. */
|
||||
/* ========================================================================= */
|
||||
void CL_DAILY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long cid = 0;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (cl_open_close(b, "DAILY", bizdate, bizdate, &cid) < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
userlog("CL_DAILY cid=%ld bizdate=%s 일마감 완료", cid, bizdate);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 2. CL_MONTHLY - 월 마감: 해당 월(YYYY-MM) 매입 집계 후 마감이력(MONTHLY). */
|
||||
void CL_MONTHLY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], period[16];
|
||||
long cid = 0;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_STR1, period, sizeof(period));
|
||||
if (period[0] == 0) { strncpy(period, bizdate, 7); period[7] = 0; }
|
||||
if (cl_open_close(b, "MONTHLY", period, bizdate, &cid) < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 3. CL_QUARTER - 분기 마감: 분기 프리픽스(YYYY-MM LIKE)로 집계. */
|
||||
void CL_QUARTER(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], period[16];
|
||||
long cid = 0;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_STR1, period, sizeof(period));
|
||||
if (period[0] == 0) { strncpy(period, bizdate, 4); period[4] = 0; }
|
||||
if (cl_open_close(b, "QUARTER", period, bizdate, &cid) < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 4. CL_SNAPSHOT - 마감 스냅샷: merchant_summary 를 close_id 로 고정 복사. */
|
||||
void CL_SNAPSHOT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], period[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt;
|
||||
char h_bizdate[16], h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_STR1, period, sizeof(period)); if (period[0] == 0) strcpy(period, bizdate);
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
|
||||
EXEC SQL INSERT INTO cl_snapshot
|
||||
(snapshot_id, close_id, period_key, biz_date, merchant_id,
|
||||
gross_amount, fee_amount, net_amount, txn_count)
|
||||
SELECT nextval('cl_snapshot_seq'), :h_cid, :h_period, :h_bizdate,
|
||||
ms.merchant_id, ms.gross_amount, ms.fee_amount, ms.net_amount, ms.txn_count
|
||||
FROM merchant_summary ms WHERE ms.biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("CL_SNAPSHOT FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); FAIL(b); }
|
||||
h_cnt = sqlca.sqlerrd[2];
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
userlog("CL_SNAPSHOT cid=%ld 가맹점 %ld건 스냅샷", h_cid, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 5. CL_RECLOSE - 재마감: 상태 R 로 표시하고 총계 재집계. */
|
||||
void CL_RECLOSE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt, h_amt;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (cldb_update_close_totals(h_cid, h_cnt, h_amt) < 0) FAIL(b);
|
||||
if (cldb_update_close_status(h_cid, "R") < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
Bchg(b, T_STATUS, 0, "R", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 6. CL_VERIFY - 마감 검증: close_log 총건수 vs 실제 매입건수 비교. */
|
||||
void CL_VERIFY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_stored, h_actual;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT txn_count INTO :h_stored FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
EXEC SQL SELECT count(*) INTO :h_actual FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_actual);
|
||||
setl(b, T_RC, (h_stored == h_actual) ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 7. CL_CANCEL - 마감 취소: 상태 X. */
|
||||
void CL_CANCEL(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "X") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "X", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 8. CL_STATS - 마감 통계: close_type 별 마감 건수/총액. */
|
||||
void CL_STATS(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char ctype[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_amt;
|
||||
char h_type[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_STR2, ctype, sizeof(ctype)); if (ctype[0] == 0) strcpy(ctype, "DAILY");
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(total_amount),0) INTO :h_cnt, :h_amt
|
||||
FROM cl_close_log WHERE close_type = :h_type AND status <> 'X';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_amt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 9. CL_BALVERIFY - 잔액 검증: 스냅샷 net 합 vs close_log total 비교. */
|
||||
void CL_BALVERIFY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_snap_net, h_total;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT coalesce(sum(net_amount),0) INTO :h_snap_net
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL SELECT total_amount INTO :h_total FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
setl(b, T_AMT2, h_snap_net);
|
||||
setl(b, T_AMT3, h_total);
|
||||
setl(b, T_DELTA, h_total - h_snap_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 10. CL_SEQ - 마감 순번 발번(dbio upsert). */
|
||||
void CL_SEQ(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char ctype[16];
|
||||
long seq;
|
||||
gets_(b, T_STR2, ctype, sizeof(ctype)); if (ctype[0] == 0) strcpy(ctype, "DAILY");
|
||||
seq = cldb_bump_seq(ctype);
|
||||
if (seq < 0) FAIL(b);
|
||||
setl(b, T_ID2, seq);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 11. CL_REPORT - 마감 리포트: 특정 마감의 스냅샷 건수/총매출. */
|
||||
void CL_REPORT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt, h_gross;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT count(*), coalesce(sum(gross_amount),0) INTO :h_cnt, :h_gross
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_gross);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 12. CL_ALERT - 미마감 경보: 당일 대사완료(M) 미전기 매입 건수. */
|
||||
void CL_ALERT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM purchase
|
||||
WHERE biz_date = :h_bizdate AND status = 'M';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_RC, (h_cnt > 0) ? 1 : 0);
|
||||
if (h_cnt > 0) userlog("CL_ALERT %s 미마감 %ld건 감지", bizdate, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 13. CL_UNCLOSED - 미마감일 점검: close_log 없는 매입 영업일 건수. */
|
||||
void CL_UNCLOSED(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(DISTINCT p.biz_date) INTO :h_cnt
|
||||
FROM purchase p
|
||||
WHERE NOT EXISTS (SELECT 1 FROM cl_close_log c
|
||||
WHERE c.close_type = 'DAILY' AND c.biz_date = p.biz_date
|
||||
AND c.status <> 'X');
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 14. CL_APPROVE - 마감 승인: 상태 A. */
|
||||
void CL_APPROVE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "A") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "A", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 15. CL_LOCK - 기간 잠금: cl_period_lock upsert(locked=true) + 마감 L. */
|
||||
void CL_LOCK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char period[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid;
|
||||
char h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_STR1, period, sizeof(period)); if (period[0] == 0) gets_(b, T_BIZDATE, period, sizeof(period));
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
EXEC SQL INSERT INTO cl_period_lock (period_key, locked) VALUES (:h_period, true)
|
||||
ON CONFLICT (period_key) DO UPDATE SET locked = true, locked_at = now();
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (h_cid > 0 && cldb_update_close_status(h_cid, "L") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "L", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 16. CL_UNLOCK - 기간 잠금 해제. */
|
||||
void CL_UNLOCK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char period[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_STR1, period, sizeof(period)); if (period[0] == 0) gets_(b, T_BIZDATE, period, sizeof(period));
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
EXEC SQL UPDATE cl_period_lock SET locked = false, locked_at = now()
|
||||
WHERE period_key = :h_period;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, sqlca.sqlerrd[2]);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 17. CL_AGGREGATE - 마감 총계 재집계 후 close_log 반영. */
|
||||
void CL_AGGREGATE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt, h_amt;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (cldb_update_close_totals(h_cid, h_cnt, h_amt) < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_amt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 18. CL_DIFFCHK - 차액 점검: close_log total vs 스냅샷 gross 합. */
|
||||
void CL_DIFFCHK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_total, h_snap;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT total_amount INTO :h_total FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
EXEC SQL SELECT coalesce(sum(gross_amount),0) INTO :h_snap
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_DELTA, h_total - h_snap);
|
||||
setl(b, T_RC, (h_total == h_snap) ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 19. CL_SUMMARY - 마감 요약: 스냅샷 gross/fee/net 합계 반환. */
|
||||
void CL_SUMMARY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_gross, h_fee, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT coalesce(sum(gross_amount),0), coalesce(sum(fee_amount),0),
|
||||
coalesce(sum(net_amount),0)
|
||||
INTO :h_gross, :h_fee, :h_net FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_GROSS, h_gross);
|
||||
setl(b, T_FEE, h_fee);
|
||||
setl(b, T_NET, h_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 20. CL_STATUS - 마감 상태 조회(dbio getter). */
|
||||
void CL_STATUS(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
char st[4];
|
||||
if (cldb_get_close_status(cid, st) < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, st, 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 21. CL_ROLLBACK - 마감 롤백: 스냅샷 삭제 + 상태 O 로 복귀. */
|
||||
void CL_ROLLBACK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL DELETE FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, sqlca.sqlerrd[2]);
|
||||
if (cldb_update_close_status(h_cid, "O") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "O", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 22. CL_CONFIRM - 마감 확정: 상태 C. */
|
||||
void CL_CONFIRM(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "C") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 23. CL_PERIOD - 기간 마감 개시(open): close_log 를 O 상태로 등록. */
|
||||
void CL_PERIOD(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], period[16], ctype[16];
|
||||
long cid;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_STR1, period, sizeof(period)); if (period[0] == 0) strcpy(period, bizdate);
|
||||
gets_(b, T_STR2, ctype, sizeof(ctype)); if (ctype[0] == 0) strcpy(ctype, "DAILY");
|
||||
cid = cldb_next_close_id();
|
||||
if (cid < 0) FAIL(b);
|
||||
if (cldb_insert_close(cid, ctype, period, bizdate, "O", 0, 0, "기간개시") < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
Bchg(b, T_STATUS, 0, "O", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 24. CL_YEAREND - 연말 마감: 연도(YYYY) 프리픽스로 집계. */
|
||||
void CL_YEAREND(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], period[16];
|
||||
long cid = 0;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(period, bizdate, 4); period[4] = 0;
|
||||
if (cl_open_close(b, "YEAREND", period, bizdate, &cid) < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
userlog("CL_YEAREND cid=%ld 연도=%s 연마감 완료", cid, period);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 25. CL_MIDCLOSE - 중간 마감: 당일 중간 스냅 마감이력(MID) 생성. */
|
||||
void CL_MIDCLOSE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_amt, h_cid;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate AND status IN ('A', 'M');
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
h_cid = cldb_next_close_id();
|
||||
if (h_cid < 0) FAIL(b);
|
||||
if (cldb_insert_close(h_cid, "MID", bizdate, bizdate, "O", h_cnt, h_amt, "중간마감") < 0) FAIL(b);
|
||||
setl(b, T_ID1, h_cid);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 26. CL_RECON - 마감 대사: 실제 매입건수 vs close_log txn_count 대사. */
|
||||
void CL_RECON(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_stored, h_actual, h_asum, h_tsum;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT txn_count, total_amount INTO :h_stored, :h_tsum
|
||||
FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_actual, :h_asum
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_actual);
|
||||
setl(b, T_DELTA, h_tsum - h_asum);
|
||||
setl(b, T_RC, (h_stored == h_actual && h_tsum == h_asum) ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 27. CL_ARCHIVE - 마감 아카이브: 승인/완료 마감을 보관 상태로(memo 표시). */
|
||||
void CL_ARCHIVE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL UPDATE cl_close_log
|
||||
SET memo = 'ARCHIVED', updated_at = now()
|
||||
WHERE close_id = :h_cid AND status IN ('C', 'A', 'L');
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
setl(b, T_COUNT, sqlca.sqlerrd[2]);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 28. CL_PURGE - 취소 마감 정리: 오래된 X 상태 마감과 그 스냅샷 삭제. */
|
||||
void CL_PURGE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cnt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DELETE FROM cl_snapshot WHERE close_id IN
|
||||
(SELECT close_id FROM cl_close_log WHERE status = 'X' AND biz_date < :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL DELETE FROM cl_close_log WHERE status = 'X' AND biz_date < :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
h_cnt = sqlca.sqlerrd[2];
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
userlog("CL_PURGE %s 이전 취소마감 %ld건 삭제", bizdate, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 29. CL_RESTORE - 마감 복원: 취소(X) 마감을 개시(O) 상태로 되돌림. */
|
||||
void CL_RESTORE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL UPDATE cl_close_log SET status = 'O', memo = 'RESTORED', updated_at = now()
|
||||
WHERE close_id = :h_cid AND status = 'X';
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "O", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 30. CL_INQUIRY - 마감 조회: close_type/기간/상태/총건수 반환. */
|
||||
void CL_INQUIRY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt, h_amt;
|
||||
char h_type[16], h_status[8];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT close_type, status, txn_count, total_amount
|
||||
INTO :h_type, :h_status, :h_cnt, :h_amt
|
||||
FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
Bchg(b, T_STR2, 0, h_type, 0L);
|
||||
Bchg(b, T_STATUS, 0, h_status, 0L);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_amt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
|
|
|
|||
11
app/src/cl/dbio/cl_approve_pending_dbio.h
Normal file
11
app/src/cl/dbio/cl_approve_pending_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_approve_pending_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_approve_pending_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 승인 대기(C) 마감 수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_APPROVE_PENDING_DBIO_H
|
||||
#define CL_APPROVE_PENDING_DBIO_H
|
||||
|
||||
long clqdb_approve_pending(void);
|
||||
#endif /* CL_APPROVE_PENDING_DBIO_H */
|
||||
19
app/src/cl/dbio/cl_approve_pending_dbio.pgc
Normal file
19
app/src/cl/dbio/cl_approve_pending_dbio.pgc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* cl_approve_pending_dbio.pgc - cl 모듈 DB 접근 함수 (cl_approve_pending_dbio), archived into libcldbio.a.
|
||||
* 승인 대기(C) 마감 수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_approve_pending_dbio.h"
|
||||
|
||||
/* 마감완료(C) 이나 아직 승인(A)되지 않은 마감 수. */
|
||||
long clqdb_approve_pending(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM cl_close_log WHERE status = 'C';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_approve_pending FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_archive_mark_dbio.h
Normal file
11
app/src/cl/dbio/cl_archive_mark_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_archive_mark_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_archive_mark_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 완료/승인 마감 아카이브 표시 (update count).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_ARCHIVE_MARK_DBIO_H
|
||||
#define CL_ARCHIVE_MARK_DBIO_H
|
||||
|
||||
long clqdb_archive_mark(const char *before);
|
||||
#endif /* CL_ARCHIVE_MARK_DBIO_H */
|
||||
21
app/src/cl/dbio/cl_archive_mark_dbio.pgc
Normal file
21
app/src/cl/dbio/cl_archive_mark_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* cl_archive_mark_dbio.pgc - cl 모듈 DB 접근 함수 (cl_archive_mark_dbio), archived into libcldbio.a.
|
||||
* 완료/승인 마감 아카이브 표시 (update count).
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_archive_mark_dbio.h"
|
||||
|
||||
/* before 이전 완료(C)/승인(A) 마감을 ARCHIVED 로 표시, 표시 건수 반환. */
|
||||
long clqdb_archive_mark(const char *before)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_before[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_before, before, sizeof(h_before)-1); h_before[sizeof(h_before)-1] = 0;
|
||||
EXEC SQL UPDATE cl_close_log SET memo = 'ARCHIVED', updated_at = now()
|
||||
WHERE biz_date < :h_before AND status IN ('C','A','L') AND memo <> 'ARCHIVED';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_archive_mark FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return sqlca.sqlerrd[2];
|
||||
}
|
||||
11
app/src/cl/dbio/cl_cancel_purge_dbio.h
Normal file
11
app/src/cl/dbio/cl_cancel_purge_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_cancel_purge_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_cancel_purge_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 오래된 취소(X) 마감 및 스냅샷 삭제.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_CANCEL_PURGE_DBIO_H
|
||||
#define CL_CANCEL_PURGE_DBIO_H
|
||||
|
||||
long clqdb_cancel_purge(const char *before);
|
||||
#endif /* CL_CANCEL_PURGE_DBIO_H */
|
||||
25
app/src/cl/dbio/cl_cancel_purge_dbio.pgc
Normal file
25
app/src/cl/dbio/cl_cancel_purge_dbio.pgc
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* cl_cancel_purge_dbio.pgc - cl 모듈 DB 접근 함수 (cl_cancel_purge_dbio), archived into libcldbio.a.
|
||||
* 오래된 취소(X) 마감 및 스냅샷 삭제.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_cancel_purge_dbio.h"
|
||||
|
||||
/* before 이전 취소(X) 마감과 스냅샷 삭제, 삭제 마감 수 반환. */
|
||||
long clqdb_cancel_purge(const char *before)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_before[16];
|
||||
long h_cnt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_before, before, sizeof(h_before)-1); h_before[sizeof(h_before)-1] = 0;
|
||||
EXEC SQL DELETE FROM cl_snapshot WHERE close_id IN
|
||||
(SELECT close_id FROM cl_close_log WHERE status = 'X' AND biz_date < :h_before);
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_cancel_purge snap FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
EXEC SQL DELETE FROM cl_close_log WHERE status = 'X' AND biz_date < :h_before;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_cancel_purge log FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
h_cnt = sqlca.sqlerrd[2];
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_close_count_dbio.h
Normal file
11
app/src/cl/dbio/cl_close_count_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_close_count_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_close_count_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감유형별 유효 마감 건수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_CLOSE_COUNT_DBIO_H
|
||||
#define CL_CLOSE_COUNT_DBIO_H
|
||||
|
||||
long clqdb_close_count(const char *ctype);
|
||||
#endif /* CL_CLOSE_COUNT_DBIO_H */
|
||||
22
app/src/cl/dbio/cl_close_count_dbio.pgc
Normal file
22
app/src/cl/dbio/cl_close_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* cl_close_count_dbio.pgc - cl 모듈 DB 접근 함수 (cl_close_count_dbio), archived into libcldbio.a.
|
||||
* 마감유형별 유효 마감 건수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_close_count_dbio.h"
|
||||
|
||||
/* close_type 별 취소되지 않은 마감 수. */
|
||||
long clqdb_close_count(const char *ctype)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_type[16];
|
||||
long h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM cl_close_log
|
||||
WHERE close_type = :h_type AND status <> 'X';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_close_count FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_close_total_dbio.h
Normal file
11
app/src/cl/dbio/cl_close_total_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_close_total_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_close_total_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 헤더 총액/건수 조회.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_CLOSE_TOTAL_DBIO_H
|
||||
#define CL_CLOSE_TOTAL_DBIO_H
|
||||
|
||||
int clqdb_close_total(long cid, long *cnt, long *amt);
|
||||
#endif /* CL_CLOSE_TOTAL_DBIO_H */
|
||||
21
app/src/cl/dbio/cl_close_total_dbio.pgc
Normal file
21
app/src/cl/dbio/cl_close_total_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* cl_close_total_dbio.pgc - cl 모듈 DB 접근 함수 (cl_close_total_dbio), archived into libcldbio.a.
|
||||
* 마감 헤더 총액/건수 조회.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_close_total_dbio.h"
|
||||
|
||||
/* 마감 헤더의 저장된 txn_count/total_amount. */
|
||||
int clqdb_close_total(long cid, long *cnt, long *amt)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_cnt, h_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT txn_count, total_amount INTO :h_cnt, :h_amt
|
||||
FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) { userlog("clqdb_close_total miss [%d]", sqlca.sqlcode); return -1; }
|
||||
*cnt = h_cnt; *amt = h_amt;
|
||||
return 0;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_daily_gap_dbio.h
Normal file
11
app/src/cl/dbio/cl_daily_gap_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_daily_gap_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_daily_gap_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 일마감 저장건수 vs 실제 매입건수 차이.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_DAILY_GAP_DBIO_H
|
||||
#define CL_DAILY_GAP_DBIO_H
|
||||
|
||||
int clqdb_daily_gap(long cid, const char *bizdate, long *stored, long *actual);
|
||||
#endif /* CL_DAILY_GAP_DBIO_H */
|
||||
24
app/src/cl/dbio/cl_daily_gap_dbio.pgc
Normal file
24
app/src/cl/dbio/cl_daily_gap_dbio.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* cl_daily_gap_dbio.pgc - cl 모듈 DB 접근 함수 (cl_daily_gap_dbio), archived into libcldbio.a.
|
||||
* 일마감 저장건수 vs 실제 매입건수 차이.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_daily_gap_dbio.h"
|
||||
|
||||
/* close_log txn_count 와 실제 매입 건수 대사. */
|
||||
int clqdb_daily_gap(long cid, const char *bizdate, long *stored, long *actual)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_stored, h_actual;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT txn_count INTO :h_stored FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) return -1;
|
||||
EXEC SQL SELECT count(*) INTO :h_actual FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
*stored = h_stored; *actual = h_actual;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -25,4 +25,9 @@ int cldb_insert_snapshot(long sid, long cid, const char *period, const char *bi
|
|||
/* 마감 순번 관리 (seq registry) */
|
||||
long cldb_bump_seq(const char *ctype);
|
||||
|
||||
/* 일/월/분기/연 공용: 매입 집계(count/sum) 후 마감이력(status=C) 생성.
|
||||
* cnt_out/amt_out 로 집계값 반환. DAILY 는 당일, 그 외는 period 프리픽스 집계. */
|
||||
int cldb_open_close(const char *ctype, const char *period, const char *bizdate,
|
||||
long *cid_out, long *cnt_out, long *amt_out);
|
||||
|
||||
#endif /* CL_DBIO_H */
|
||||
|
|
|
|||
11
app/src/cl/dbio/cl_lock_walk_dbio.h
Normal file
11
app/src/cl/dbio/cl_lock_walk_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_lock_walk_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_lock_walk_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 기간 커서 순회 - 잠긴 기간 수 누적.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_LOCK_WALK_DBIO_H
|
||||
#define CL_LOCK_WALK_DBIO_H
|
||||
|
||||
long clqdb_lock_walk(void);
|
||||
#endif /* CL_LOCK_WALK_DBIO_H */
|
||||
30
app/src/cl/dbio/cl_lock_walk_dbio.pgc
Normal file
30
app/src/cl/dbio/cl_lock_walk_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* cl_lock_walk_dbio.pgc - cl 모듈 DB 접근 함수 (cl_lock_walk_dbio), archived into libcldbio.a.
|
||||
* 기간 커서 순회 - 잠긴 기간 수 누적.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_lock_walk_dbio.h"
|
||||
|
||||
/* period_lock 을 커서로 훑어 잠긴(locked) 기간 수 누적. */
|
||||
long clqdb_lock_walk(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_period[16];
|
||||
int h_locked;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
long locked = 0;
|
||||
EXEC SQL DECLARE clw CURSOR FOR
|
||||
SELECT period_key, CASE WHEN locked THEN 1 ELSE 0 END FROM cl_period_lock;
|
||||
EXEC SQL OPEN clw;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH clw INTO :h_period, :h_locked;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE clw; return -1; }
|
||||
if (h_locked) locked++;
|
||||
}
|
||||
EXEC SQL CLOSE clw;
|
||||
return locked;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_max_close_dbio.h
Normal file
11
app/src/cl/dbio/cl_max_close_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_max_close_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_max_close_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 당일 최대 마감 ID.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_MAX_CLOSE_DBIO_H
|
||||
#define CL_MAX_CLOSE_DBIO_H
|
||||
|
||||
long clqdb_max_close(const char *bizdate);
|
||||
#endif /* CL_MAX_CLOSE_DBIO_H */
|
||||
22
app/src/cl/dbio/cl_max_close_dbio.pgc
Normal file
22
app/src/cl/dbio/cl_max_close_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* cl_max_close_dbio.pgc - cl 모듈 DB 접근 함수 (cl_max_close_dbio), archived into libcldbio.a.
|
||||
* 당일 최대 마감 ID.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_max_close_dbio.h"
|
||||
|
||||
/* 당일 채번된 최대 마감 ID (없으면 0). */
|
||||
long clqdb_max_close(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_max = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(max(close_id), 0) INTO :h_max
|
||||
FROM cl_close_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_max_close FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_max;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_month_walk_dbio.h
Normal file
11
app/src/cl/dbio/cl_month_walk_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_month_walk_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_month_walk_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 월별 마감 커서 순회 - 마감 총액 누적.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_MONTH_WALK_DBIO_H
|
||||
#define CL_MONTH_WALK_DBIO_H
|
||||
|
||||
long clqdb_month_walk(const char *prefix);
|
||||
#endif /* CL_MONTH_WALK_DBIO_H */
|
||||
33
app/src/cl/dbio/cl_month_walk_dbio.pgc
Normal file
33
app/src/cl/dbio/cl_month_walk_dbio.pgc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* cl_month_walk_dbio.pgc - cl 모듈 DB 접근 함수 (cl_month_walk_dbio), archived into libcldbio.a.
|
||||
* 월별 마감 커서 순회 - 마감 총액 누적.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_month_walk_dbio.h"
|
||||
|
||||
/* 프리픽스에 맞는 월 마감을 커서로 훑어 총액 누적. */
|
||||
long clqdb_month_walk(const char *prefix)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_prefix[16], h_period[16];
|
||||
long h_amt;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
long total = 0;
|
||||
strncpy(h_prefix, prefix, sizeof(h_prefix)-1); h_prefix[sizeof(h_prefix)-1] = 0;
|
||||
EXEC SQL DECLARE cmw CURSOR FOR
|
||||
SELECT period_key, total_amount FROM cl_close_log
|
||||
WHERE close_type = 'MONTHLY' AND period_key LIKE :h_prefix || '%' AND status <> 'X'
|
||||
ORDER BY period_key;
|
||||
EXEC SQL OPEN cmw;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cmw INTO :h_period, :h_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE cmw; return -1; }
|
||||
total += h_amt;
|
||||
}
|
||||
EXEC SQL CLOSE cmw;
|
||||
return total;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_open_count_dbio.h
Normal file
11
app/src/cl/dbio/cl_open_count_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_open_count_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_open_count_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 개시(O) 상태 미완료 마감 수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_OPEN_COUNT_DBIO_H
|
||||
#define CL_OPEN_COUNT_DBIO_H
|
||||
|
||||
long clqdb_open_count(void);
|
||||
#endif /* CL_OPEN_COUNT_DBIO_H */
|
||||
19
app/src/cl/dbio/cl_open_count_dbio.pgc
Normal file
19
app/src/cl/dbio/cl_open_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* cl_open_count_dbio.pgc - cl 모듈 DB 접근 함수 (cl_open_count_dbio), archived into libcldbio.a.
|
||||
* 개시(O) 상태 미완료 마감 수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_open_count_dbio.h"
|
||||
|
||||
/* 아직 마감완료되지 않은 개시(O) 상태 마감 수. */
|
||||
long clqdb_open_count(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM cl_close_log WHERE status = 'O';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_open_count FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
42
app/src/cl/dbio/cl_openclose_dbio.pgc
Normal file
42
app/src/cl/dbio/cl_openclose_dbio.pgc
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* cl_openclose_dbio.pgc - 일/월/분기/연 공용 마감 집계+이력생성 (part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* CL_DAILY/MONTHLY/QUARTER/YEAREND 서비스가 공유한다. (예전 cl_svr 인라인
|
||||
* static cl_open_close 를 dbio 계층으로 이전; EXEC SQL 은 .pgc 에서만 허용됨.)
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_dbio.h"
|
||||
|
||||
int cldb_open_close(const char *ctype, const char *period, const char *bizdate,
|
||||
long *cid_out, long *cnt_out, long *amt_out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_amt, h_cid;
|
||||
char h_bizdate[16], h_type[16], h_period[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
|
||||
if (strcmp(ctype, "DAILY") == 0) {
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount), 0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
} else {
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount), 0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE to_char(biz_date, 'YYYY-MM') LIKE :h_period || '%';
|
||||
}
|
||||
if (sqlca.sqlcode < 0) {
|
||||
userlog("cldb_open_close agg FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
|
||||
return -1;
|
||||
}
|
||||
|
||||
h_cid = cldb_next_close_id();
|
||||
if (h_cid < 0) return -1;
|
||||
if (cldb_insert_close(h_cid, ctype, period, bizdate, "C", h_cnt, h_amt, "마감") < 0) return -1;
|
||||
*cid_out = h_cid;
|
||||
*cnt_out = h_cnt;
|
||||
*amt_out = h_amt;
|
||||
return 0;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_period_locked_dbio.h
Normal file
11
app/src/cl/dbio/cl_period_locked_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_period_locked_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_period_locked_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 기간 잠금 여부 조회 (1=잠김).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_PERIOD_LOCKED_DBIO_H
|
||||
#define CL_PERIOD_LOCKED_DBIO_H
|
||||
|
||||
int clqdb_period_locked(const char *period);
|
||||
#endif /* CL_PERIOD_LOCKED_DBIO_H */
|
||||
23
app/src/cl/dbio/cl_period_locked_dbio.pgc
Normal file
23
app/src/cl/dbio/cl_period_locked_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* cl_period_locked_dbio.pgc - cl 모듈 DB 접근 함수 (cl_period_locked_dbio), archived into libcldbio.a.
|
||||
* 기간 잠금 여부 조회 (1=잠김).
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_period_locked_dbio.h"
|
||||
|
||||
/* period_key 가 잠겨있으면 1, 아니면 0, 없으면 0. */
|
||||
int clqdb_period_locked(const char *period)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_period[16];
|
||||
int h_locked;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_period, period, sizeof(h_period)-1); h_period[sizeof(h_period)-1] = 0;
|
||||
EXEC SQL SELECT CASE WHEN locked THEN 1 ELSE 0 END INTO :h_locked
|
||||
FROM cl_period_lock WHERE period_key = :h_period;
|
||||
if (sqlca.sqlcode == 100) return 0;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_period_locked FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_locked;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_period_sum_dbio.h
Normal file
11
app/src/cl/dbio/cl_period_sum_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_period_sum_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_period_sum_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 기간 프리픽스 마감 총액 합계.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_PERIOD_SUM_DBIO_H
|
||||
#define CL_PERIOD_SUM_DBIO_H
|
||||
|
||||
long clqdb_period_sum(const char *prefix);
|
||||
#endif /* CL_PERIOD_SUM_DBIO_H */
|
||||
22
app/src/cl/dbio/cl_period_sum_dbio.pgc
Normal file
22
app/src/cl/dbio/cl_period_sum_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* cl_period_sum_dbio.pgc - cl 모듈 DB 접근 함수 (cl_period_sum_dbio), archived into libcldbio.a.
|
||||
* 기간 프리픽스 마감 총액 합계.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_period_sum_dbio.h"
|
||||
|
||||
/* period_key 프리픽스로 마감 total_amount 누계. */
|
||||
long clqdb_period_sum(const char *prefix)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_prefix[16];
|
||||
long h_amt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_prefix, prefix, sizeof(h_prefix)-1); h_prefix[sizeof(h_prefix)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(total_amount),0) INTO :h_amt FROM cl_close_log
|
||||
WHERE period_key LIKE :h_prefix || '%' AND status <> 'X';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_period_sum FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_amt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_reclose_count_dbio.h
Normal file
11
app/src/cl/dbio/cl_reclose_count_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_reclose_count_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_reclose_count_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 재마감(R) 상태 마감 수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_RECLOSE_COUNT_DBIO_H
|
||||
#define CL_RECLOSE_COUNT_DBIO_H
|
||||
|
||||
long clqdb_reclose_count(const char *ctype);
|
||||
#endif /* CL_RECLOSE_COUNT_DBIO_H */
|
||||
22
app/src/cl/dbio/cl_reclose_count_dbio.pgc
Normal file
22
app/src/cl/dbio/cl_reclose_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* cl_reclose_count_dbio.pgc - cl 모듈 DB 접근 함수 (cl_reclose_count_dbio), archived into libcldbio.a.
|
||||
* 재마감(R) 상태 마감 수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_reclose_count_dbio.h"
|
||||
|
||||
/* close_type 별 재마감(R) 상태 수. */
|
||||
long clqdb_reclose_count(const char *ctype)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_type[16];
|
||||
long h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM cl_close_log
|
||||
WHERE close_type = :h_type AND status = 'R';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_reclose_count FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_restore_count_dbio.h
Normal file
11
app/src/cl/dbio/cl_restore_count_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_restore_count_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_restore_count_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 취소(X) 마감 개시(O) 복원 (update count).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_RESTORE_COUNT_DBIO_H
|
||||
#define CL_RESTORE_COUNT_DBIO_H
|
||||
|
||||
long clqdb_restore_count(const char *bizdate);
|
||||
#endif /* CL_RESTORE_COUNT_DBIO_H */
|
||||
21
app/src/cl/dbio/cl_restore_count_dbio.pgc
Normal file
21
app/src/cl/dbio/cl_restore_count_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* cl_restore_count_dbio.pgc - cl 모듈 DB 접근 함수 (cl_restore_count_dbio), archived into libcldbio.a.
|
||||
* 취소(X) 마감 개시(O) 복원 (update count).
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_restore_count_dbio.h"
|
||||
|
||||
/* 당일 취소(X) 마감을 개시(O) 로 복원, 복원 건수 반환. */
|
||||
long clqdb_restore_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL UPDATE cl_close_log SET status = 'O', memo = 'RESTORED', updated_at = now()
|
||||
WHERE biz_date = :h_bizdate AND status = 'X';
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_restore_count FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return sqlca.sqlerrd[2];
|
||||
}
|
||||
11
app/src/cl/dbio/cl_seq_last_dbio.h
Normal file
11
app/src/cl/dbio/cl_seq_last_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_seq_last_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_seq_last_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감유형 마지막 순번 조회.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SEQ_LAST_DBIO_H
|
||||
#define CL_SEQ_LAST_DBIO_H
|
||||
|
||||
long clqdb_seq_last(const char *ctype);
|
||||
#endif /* CL_SEQ_LAST_DBIO_H */
|
||||
22
app/src/cl/dbio/cl_seq_last_dbio.pgc
Normal file
22
app/src/cl/dbio/cl_seq_last_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* cl_seq_last_dbio.pgc - cl 모듈 DB 접근 함수 (cl_seq_last_dbio), archived into libcldbio.a.
|
||||
* 마감유형 마지막 순번 조회.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_seq_last_dbio.h"
|
||||
|
||||
/* close_type 의 마지막 발번 순번(없으면 0). */
|
||||
long clqdb_seq_last(const char *ctype)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_type[16];
|
||||
long h_seq = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(last_seq,0) INTO :h_seq FROM cl_seq_reg WHERE close_type = :h_type;
|
||||
if (sqlca.sqlcode == 100) return 0;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_seq_last FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_seq;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_snap_fee_dbio.h
Normal file
11
app/src/cl/dbio/cl_snap_fee_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_snap_fee_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_snap_fee_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 스냅샷 수수료(fee) 합계.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SNAP_FEE_DBIO_H
|
||||
#define CL_SNAP_FEE_DBIO_H
|
||||
|
||||
long clqdb_snap_fee(long cid);
|
||||
#endif /* CL_SNAP_FEE_DBIO_H */
|
||||
20
app/src/cl/dbio/cl_snap_fee_dbio.pgc
Normal file
20
app/src/cl/dbio/cl_snap_fee_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* cl_snap_fee_dbio.pgc - cl 모듈 DB 접근 함수 (cl_snap_fee_dbio), archived into libcldbio.a.
|
||||
* 마감 스냅샷 수수료(fee) 합계.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_snap_fee_dbio.h"
|
||||
|
||||
/* 특정 마감 스냅샷의 fee 합. */
|
||||
long clqdb_snap_fee(long cid)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_fee = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT coalesce(sum(fee_amount),0) INTO :h_fee
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_snap_fee FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_fee;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_snap_gross_dbio.h
Normal file
11
app/src/cl/dbio/cl_snap_gross_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_snap_gross_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_snap_gross_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 스냅샷 총매출(gross) 합계.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SNAP_GROSS_DBIO_H
|
||||
#define CL_SNAP_GROSS_DBIO_H
|
||||
|
||||
long clqdb_snap_gross(long cid);
|
||||
#endif /* CL_SNAP_GROSS_DBIO_H */
|
||||
20
app/src/cl/dbio/cl_snap_gross_dbio.pgc
Normal file
20
app/src/cl/dbio/cl_snap_gross_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* cl_snap_gross_dbio.pgc - cl 모듈 DB 접근 함수 (cl_snap_gross_dbio), archived into libcldbio.a.
|
||||
* 마감 스냅샷 총매출(gross) 합계.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_snap_gross_dbio.h"
|
||||
|
||||
/* 특정 마감 스냅샷의 gross 합. */
|
||||
long clqdb_snap_gross(long cid)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_gross = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT coalesce(sum(gross_amount),0) INTO :h_gross
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_snap_gross FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_gross;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_snap_merch_dbio.h
Normal file
11
app/src/cl/dbio/cl_snap_merch_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_snap_merch_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_snap_merch_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 스냅샷 가맹점 수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SNAP_MERCH_DBIO_H
|
||||
#define CL_SNAP_MERCH_DBIO_H
|
||||
|
||||
long clqdb_snap_merch(long cid);
|
||||
#endif /* CL_SNAP_MERCH_DBIO_H */
|
||||
20
app/src/cl/dbio/cl_snap_merch_dbio.pgc
Normal file
20
app/src/cl/dbio/cl_snap_merch_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* cl_snap_merch_dbio.pgc - cl 모듈 DB 접근 함수 (cl_snap_merch_dbio), archived into libcldbio.a.
|
||||
* 마감 스냅샷 가맹점 수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_snap_merch_dbio.h"
|
||||
|
||||
/* 특정 마감에 포함된 가맹점(스냅샷 행) 수. */
|
||||
long clqdb_snap_merch(long cid)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(DISTINCT merchant_id) INTO :h_cnt
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_snap_merch FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_snap_net_dbio.h
Normal file
11
app/src/cl/dbio/cl_snap_net_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_snap_net_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_snap_net_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 스냅샷 순매출(net) 합계.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SNAP_NET_DBIO_H
|
||||
#define CL_SNAP_NET_DBIO_H
|
||||
|
||||
long clqdb_snap_net(long cid);
|
||||
#endif /* CL_SNAP_NET_DBIO_H */
|
||||
21
app/src/cl/dbio/cl_snap_net_dbio.pgc
Normal file
21
app/src/cl/dbio/cl_snap_net_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* cl_snap_net_dbio.pgc - cl 모듈 DB 접근 함수 (cl_snap_net_dbio), archived into libcldbio.a.
|
||||
* 마감 스냅샷 순매출(net) 합계.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_snap_net_dbio.h"
|
||||
|
||||
/* 특정 마감 스냅샷의 net 합. */
|
||||
long clqdb_snap_net(long cid)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_net = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT coalesce(sum(net_amount),0) INTO :h_net
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_snap_net FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
if (h_net < 0) return -1;
|
||||
return h_net;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_snap_top_dbio.h
Normal file
11
app/src/cl/dbio/cl_snap_top_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_snap_top_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_snap_top_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 내 최대 매출 가맹점.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_SNAP_TOP_DBIO_H
|
||||
#define CL_SNAP_TOP_DBIO_H
|
||||
|
||||
int clqdb_snap_top(long cid, char *merch_out, long *gross_out);
|
||||
#endif /* CL_SNAP_TOP_DBIO_H */
|
||||
23
app/src/cl/dbio/cl_snap_top_dbio.pgc
Normal file
23
app/src/cl/dbio/cl_snap_top_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* cl_snap_top_dbio.pgc - cl 모듈 DB 접근 함수 (cl_snap_top_dbio), archived into libcldbio.a.
|
||||
* 마감 내 최대 매출 가맹점.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_snap_top_dbio.h"
|
||||
|
||||
/* 스냅샷에서 gross 최대 가맹점 (order by limit 1). */
|
||||
int clqdb_snap_top(long cid, char *merch_out, long *gross_out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_gross;
|
||||
char h_merch[64];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT merchant_id, gross_amount INTO :h_merch, :h_gross
|
||||
FROM cl_snapshot WHERE close_id = :h_cid ORDER BY gross_amount DESC LIMIT 1;
|
||||
if (sqlca.sqlcode == 100) { merch_out[0] = 0; *gross_out = 0; return 0; }
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
strcpy(merch_out, h_merch); *gross_out = h_gross;
|
||||
return 0;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_status_walk_dbio.h
Normal file
11
app/src/cl/dbio/cl_status_walk_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_status_walk_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_status_walk_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 커서 순회 - 특정 상태 마감 수 누적.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_STATUS_WALK_DBIO_H
|
||||
#define CL_STATUS_WALK_DBIO_H
|
||||
|
||||
long clqdb_status_walk(const char *ctype, const char *want);
|
||||
#endif /* CL_STATUS_WALK_DBIO_H */
|
||||
31
app/src/cl/dbio/cl_status_walk_dbio.pgc
Normal file
31
app/src/cl/dbio/cl_status_walk_dbio.pgc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* cl_status_walk_dbio.pgc - cl 모듈 DB 접근 함수 (cl_status_walk_dbio), archived into libcldbio.a.
|
||||
* 마감 커서 순회 - 특정 상태 마감 수 누적.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_status_walk_dbio.h"
|
||||
|
||||
/* 커서로 유형별 마감을 훑어 want 상태 건수를 누적. */
|
||||
long clqdb_status_walk(const char *ctype, const char *want)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_type[16], h_st[8];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
long hit = 0;
|
||||
char want0 = want[0];
|
||||
strncpy(h_type, ctype, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL DECLARE csw CURSOR FOR
|
||||
SELECT status FROM cl_close_log WHERE close_type = :h_type ORDER BY close_id;
|
||||
EXEC SQL OPEN csw;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH csw INTO :h_st;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE csw; return -1; }
|
||||
if (h_st[0] == want0) hit++;
|
||||
}
|
||||
EXEC SQL CLOSE csw;
|
||||
return hit;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_unclosed_days_dbio.h
Normal file
11
app/src/cl/dbio/cl_unclosed_days_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_unclosed_days_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_unclosed_days_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 일마감 누락 영업일 수.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_UNCLOSED_DAYS_DBIO_H
|
||||
#define CL_UNCLOSED_DAYS_DBIO_H
|
||||
|
||||
long clqdb_unclosed_days(void);
|
||||
#endif /* CL_UNCLOSED_DAYS_DBIO_H */
|
||||
21
app/src/cl/dbio/cl_unclosed_days_dbio.pgc
Normal file
21
app/src/cl/dbio/cl_unclosed_days_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* cl_unclosed_days_dbio.pgc - cl 모듈 DB 접근 함수 (cl_unclosed_days_dbio), archived into libcldbio.a.
|
||||
* 일마감 누락 영업일 수.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_unclosed_days_dbio.h"
|
||||
|
||||
/* DAILY 마감이 없는 매입 영업일 수. */
|
||||
long clqdb_unclosed_days(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(DISTINCT p.biz_date) INTO :h_cnt FROM purchase p
|
||||
WHERE NOT EXISTS (SELECT 1 FROM cl_close_log c
|
||||
WHERE c.close_type = 'DAILY' AND c.biz_date = p.biz_date AND c.status <> 'X');
|
||||
if (sqlca.sqlcode < 0) { userlog("clqdb_unclosed_days FAIL [%d]", sqlca.sqlcode); return -1; }
|
||||
return h_cnt;
|
||||
}
|
||||
11
app/src/cl/dbio/cl_verify_amt_dbio.h
Normal file
11
app/src/cl/dbio/cl_verify_amt_dbio.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* cl_verify_amt_dbio.h - cl 모듈 DB 접근 계층 copybook (cl_verify_amt_dbio, part of libcldbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* 마감 저장총액 vs 실제 매입총액 검증.
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef CL_VERIFY_AMT_DBIO_H
|
||||
#define CL_VERIFY_AMT_DBIO_H
|
||||
|
||||
int clqdb_verify_amt(long cid, const char *bizdate, long *stored, long *actual);
|
||||
#endif /* CL_VERIFY_AMT_DBIO_H */
|
||||
24
app/src/cl/dbio/cl_verify_amt_dbio.pgc
Normal file
24
app/src/cl/dbio/cl_verify_amt_dbio.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* cl_verify_amt_dbio.pgc - cl 모듈 DB 접근 함수 (cl_verify_amt_dbio), archived into libcldbio.a.
|
||||
* 마감 저장총액 vs 실제 매입총액 검증.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "cl_verify_amt_dbio.h"
|
||||
|
||||
/* close_log total_amount 와 실제 매입 총액 대사. */
|
||||
int clqdb_verify_amt(long cid, const char *bizdate, long *stored, long *actual)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid = cid, h_stored, h_actual;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT total_amount INTO :h_stored FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) return -1;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_actual FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
*stored = h_stored; *actual = h_actual;
|
||||
return 0;
|
||||
}
|
||||
13
app/src/cl/run/run_approve.sh
Executable file
13
app/src/cl/run/run_approve.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_approve.sh - 마감 일괄 승인 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_approve.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_approve.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_approve_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_archive.sh
Executable file
13
app/src/cl/run/run_archive.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_archive.sh - 완료마감 아카이브 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_archive.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_archive.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_archive_batch "$BIZDATE"
|
||||
19
app/src/cl/run/run_close.sh
Executable file
19
app/src/cl/run/run_close.sh
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_close.sh - cl 일마감 파이프라인 (여러 배치 일괄 실행).
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치들을 순차 실행.
|
||||
## Usage: run_close.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_close.sh] BIZDATE=$BIZDATE"
|
||||
for b in cl_daily_batch \
|
||||
cl_snapshot_batch \
|
||||
cl_rollup_batch \
|
||||
cl_verify_batch; do
|
||||
echo "--- $b $BIZDATE ---"
|
||||
"/app/bin/$b" "$BIZDATE" || exit 1
|
||||
done
|
||||
13
app/src/cl/run/run_daily.sh
Executable file
13
app/src/cl/run/run_daily.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_daily.sh - 일 마감 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_daily.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_daily.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_daily_batch "$BIZDATE"
|
||||
21
app/src/cl/run/run_eom.sh
Executable file
21
app/src/cl/run/run_eom.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_eom.sh - cl 월마감 파이프라인 (여러 배치 일괄 실행).
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치들을 순차 실행.
|
||||
## Usage: run_eom.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_eom.sh] BIZDATE=$BIZDATE"
|
||||
for b in cl_monthly_batch \
|
||||
cl_snapshot_batch \
|
||||
cl_rollup_batch \
|
||||
cl_approve_batch \
|
||||
cl_lock_batch \
|
||||
cl_archive_batch; do
|
||||
echo "--- $b $BIZDATE ---"
|
||||
"/app/bin/$b" "$BIZDATE" || exit 1
|
||||
done
|
||||
13
app/src/cl/run/run_lock.sh
Executable file
13
app/src/cl/run/run_lock.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_lock.sh - 기간 잠금 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_lock.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_lock.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_lock_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_midclose.sh
Executable file
13
app/src/cl/run/run_midclose.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_midclose.sh - 중간 마감 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_midclose.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_midclose.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_midclose_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_monthly.sh
Executable file
13
app/src/cl/run/run_monthly.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_monthly.sh - 월 마감 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_monthly.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_monthly.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_monthly_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_purge.sh
Executable file
13
app/src/cl/run/run_purge.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_purge.sh - 취소마감 정리 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_purge.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_purge.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_purge_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_quarter.sh
Executable file
13
app/src/cl/run/run_quarter.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_quarter.sh - 분기 마감 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_quarter.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_quarter.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_quarter_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_recon.sh
Executable file
13
app/src/cl/run/run_recon.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_recon.sh - 마감 대사 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_recon.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_recon.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_recon_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_report.sh
Executable file
13
app/src/cl/run/run_report.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_report.sh - 마감 리포트 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_report.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_report.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_report_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_seq.sh
Executable file
13
app/src/cl/run/run_seq.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_seq.sh - 마감 순번 발번 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_seq.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_seq.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_seq_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_snapshot.sh
Executable file
13
app/src/cl/run/run_snapshot.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_snapshot.sh - 마감 스냅샷 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_snapshot.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_snapshot.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_snapshot_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_unclosed.sh
Executable file
13
app/src/cl/run/run_unclosed.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_unclosed.sh - 미마감 영업일 점검 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_unclosed.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_unclosed.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_unclosed_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_verify.sh
Executable file
13
app/src/cl/run/run_verify.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_verify.sh - 마감 검증 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_verify.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_verify.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_verify_batch "$BIZDATE"
|
||||
13
app/src/cl/run/run_yearend.sh
Executable file
13
app/src/cl/run/run_yearend.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_yearend.sh - 연말 마감 배치.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치를 실행.
|
||||
## Usage: run_yearend.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_yearend.sh] BIZDATE=$BIZDATE"
|
||||
exec /app/bin/cl_yearend_batch "$BIZDATE"
|
||||
21
app/src/cl/svc/CL_AGGREGATE.h
Normal file
21
app/src/cl/svc/CL_AGGREGATE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_AGGREGATE.h - cl 서비스 CL_AGGREGATE 카피북 (copybook / record header).
|
||||
* 마감 총계 재집계 후 close_log 반영.
|
||||
*/
|
||||
#ifndef CL_AGGREGATE_H
|
||||
#define CL_AGGREGATE_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_aggregate_rec_t;
|
||||
|
||||
void CL_AGGREGATE(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_AGGREGATE_H */
|
||||
29
app/src/cl/svc/CL_AGGREGATE.pgc
Normal file
29
app/src/cl/svc/CL_AGGREGATE.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* CL_AGGREGATE.pgc - cl 모듈 서비스 CL_AGGREGATE (one service = one file).
|
||||
* 마감 총계 재집계 후 close_log 반영.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_AGGREGATE.h"
|
||||
|
||||
void CL_AGGREGATE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_cnt, h_amt;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(amount),0) INTO :h_cnt, :h_amt
|
||||
FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (cldb_update_close_totals(h_cid, h_cnt, h_amt) < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_amt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_ALERT.h
Normal file
21
app/src/cl/svc/CL_ALERT.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_ALERT.h - cl 서비스 CL_ALERT 카피북 (copybook / record header).
|
||||
* 미마감 경보: 당일 대사완료(M) 미전기 매입 건수.
|
||||
*/
|
||||
#ifndef CL_ALERT_H
|
||||
#define CL_ALERT_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_alert_rec_t;
|
||||
|
||||
void CL_ALERT(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_ALERT_H */
|
||||
28
app/src/cl/svc/CL_ALERT.pgc
Normal file
28
app/src/cl/svc/CL_ALERT.pgc
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* CL_ALERT.pgc - cl 모듈 서비스 CL_ALERT (one service = one file).
|
||||
* 미마감 경보: 당일 대사완료(M) 미전기 매입 건수.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_ALERT.h"
|
||||
|
||||
void CL_ALERT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_cnt FROM purchase
|
||||
WHERE biz_date = :h_bizdate AND status = 'M';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_RC, (h_cnt > 0) ? 1 : 0);
|
||||
if (h_cnt > 0) userlog("CL_ALERT %s 미마감 %ld건 감지", bizdate, h_cnt);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_APPROVE.h
Normal file
21
app/src/cl/svc/CL_APPROVE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_APPROVE.h - cl 서비스 CL_APPROVE 카피북 (copybook / record header).
|
||||
* 마감 승인: 상태 A.
|
||||
*/
|
||||
#ifndef CL_APPROVE_H
|
||||
#define CL_APPROVE_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_approve_rec_t;
|
||||
|
||||
void CL_APPROVE(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_APPROVE_H */
|
||||
18
app/src/cl/svc/CL_APPROVE.pgc
Normal file
18
app/src/cl/svc/CL_APPROVE.pgc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* CL_APPROVE.pgc - cl 모듈 서비스 CL_APPROVE (one service = one file).
|
||||
* 마감 승인: 상태 A.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_APPROVE.h"
|
||||
|
||||
void CL_APPROVE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "A") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "A", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_ARCHIVE.h
Normal file
21
app/src/cl/svc/CL_ARCHIVE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_ARCHIVE.h - cl 서비스 CL_ARCHIVE 카피북 (copybook / record header).
|
||||
* 마감 아카이브: 승인/완료 마감을 보관 상태로(memo 표시).
|
||||
*/
|
||||
#ifndef CL_ARCHIVE_H
|
||||
#define CL_ARCHIVE_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_archive_rec_t;
|
||||
|
||||
void CL_ARCHIVE(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_ARCHIVE_H */
|
||||
24
app/src/cl/svc/CL_ARCHIVE.pgc
Normal file
24
app/src/cl/svc/CL_ARCHIVE.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* CL_ARCHIVE.pgc - cl 모듈 서비스 CL_ARCHIVE (one service = one file).
|
||||
* 마감 아카이브: 승인/완료 마감을 보관 상태로(memo 표시).
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_ARCHIVE.h"
|
||||
|
||||
void CL_ARCHIVE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL UPDATE cl_close_log
|
||||
SET memo = 'ARCHIVED', updated_at = now()
|
||||
WHERE close_id = :h_cid AND status IN ('C', 'A', 'L');
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
setl(b, T_COUNT, sqlca.sqlerrd[2]);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_BALVERIFY.h
Normal file
21
app/src/cl/svc/CL_BALVERIFY.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_BALVERIFY.h - cl 서비스 CL_BALVERIFY 카피북 (copybook / record header).
|
||||
* 잔액 검증: 스냅샷 net 합 vs close_log total 비교.
|
||||
*/
|
||||
#ifndef CL_BALVERIFY_H
|
||||
#define CL_BALVERIFY_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_balverify_rec_t;
|
||||
|
||||
void CL_BALVERIFY(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_BALVERIFY_H */
|
||||
27
app/src/cl/svc/CL_BALVERIFY.pgc
Normal file
27
app/src/cl/svc/CL_BALVERIFY.pgc
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* CL_BALVERIFY.pgc - cl 모듈 서비스 CL_BALVERIFY (one service = one file).
|
||||
* 잔액 검증: 스냅샷 net 합 vs close_log total 비교.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_BALVERIFY.h"
|
||||
|
||||
void CL_BALVERIFY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_snap_net, h_total;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT coalesce(sum(net_amount),0) INTO :h_snap_net
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL SELECT total_amount INTO :h_total FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
setl(b, T_AMT2, h_snap_net);
|
||||
setl(b, T_AMT3, h_total);
|
||||
setl(b, T_DELTA, h_total - h_snap_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_CANCEL.h
Normal file
21
app/src/cl/svc/CL_CANCEL.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_CANCEL.h - cl 서비스 CL_CANCEL 카피북 (copybook / record header).
|
||||
* 마감 취소: 상태 X.
|
||||
*/
|
||||
#ifndef CL_CANCEL_H
|
||||
#define CL_CANCEL_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_cancel_rec_t;
|
||||
|
||||
void CL_CANCEL(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_CANCEL_H */
|
||||
18
app/src/cl/svc/CL_CANCEL.pgc
Normal file
18
app/src/cl/svc/CL_CANCEL.pgc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* CL_CANCEL.pgc - cl 모듈 서비스 CL_CANCEL (one service = one file).
|
||||
* 마감 취소: 상태 X.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_CANCEL.h"
|
||||
|
||||
void CL_CANCEL(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "X") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "X", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_CONFIRM.h
Normal file
21
app/src/cl/svc/CL_CONFIRM.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_CONFIRM.h - cl 서비스 CL_CONFIRM 카피북 (copybook / record header).
|
||||
* 마감 확정: 상태 C.
|
||||
*/
|
||||
#ifndef CL_CONFIRM_H
|
||||
#define CL_CONFIRM_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_confirm_rec_t;
|
||||
|
||||
void CL_CONFIRM(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_CONFIRM_H */
|
||||
18
app/src/cl/svc/CL_CONFIRM.pgc
Normal file
18
app/src/cl/svc/CL_CONFIRM.pgc
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* CL_CONFIRM.pgc - cl 모듈 서비스 CL_CONFIRM (one service = one file).
|
||||
* 마감 확정: 상태 C.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_CONFIRM.h"
|
||||
|
||||
void CL_CONFIRM(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long cid = getl(b, T_ID1);
|
||||
if (cldb_update_close_status(cid, "C") < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_DAILY.h
Normal file
21
app/src/cl/svc/CL_DAILY.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_DAILY.h - cl 서비스 CL_DAILY 카피북 (copybook / record header).
|
||||
* 일 마감: 당일 매입 집계 후 마감이력(DAILY) 생성.
|
||||
*/
|
||||
#ifndef CL_DAILY_H
|
||||
#define CL_DAILY_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_daily_rec_t;
|
||||
|
||||
void CL_DAILY(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_DAILY_H */
|
||||
22
app/src/cl/svc/CL_DAILY.pgc
Normal file
22
app/src/cl/svc/CL_DAILY.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* CL_DAILY.pgc - cl 모듈 서비스 CL_DAILY (one service = one file).
|
||||
* 일 마감: 당일 매입 집계 후 마감이력(DAILY) 생성.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_DAILY.h"
|
||||
|
||||
void CL_DAILY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long cid = 0;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (cl_open_close(b, "DAILY", bizdate, bizdate, &cid) < 0) FAIL(b);
|
||||
setl(b, T_ID1, cid);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
userlog("CL_DAILY cid=%ld bizdate=%s 일마감 완료", cid, bizdate);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_DIFFCHK.h
Normal file
21
app/src/cl/svc/CL_DIFFCHK.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_DIFFCHK.h - cl 서비스 CL_DIFFCHK 카피북 (copybook / record header).
|
||||
* 차액 점검: close_log total vs 스냅샷 gross 합.
|
||||
*/
|
||||
#ifndef CL_DIFFCHK_H
|
||||
#define CL_DIFFCHK_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_diffchk_rec_t;
|
||||
|
||||
void CL_DIFFCHK(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_DIFFCHK_H */
|
||||
26
app/src/cl/svc/CL_DIFFCHK.pgc
Normal file
26
app/src/cl/svc/CL_DIFFCHK.pgc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* CL_DIFFCHK.pgc - cl 모듈 서비스 CL_DIFFCHK (one service = one file).
|
||||
* 차액 점검: close_log total vs 스냅샷 gross 합.
|
||||
* 이전 인라인 cl_svr.pgc 에서 분리; 호출자의 XA 브랜치에서 수행(EXEC SQL CONNECT 없음).
|
||||
* cl_svr 가 tpsvrinit 에서 tpadvertise 로 광고한다.
|
||||
*/
|
||||
#include "CL_DIFFCHK.h"
|
||||
|
||||
void CL_DIFFCHK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cid, h_total, h_snap;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_cid = getl(b, T_ID1);
|
||||
EXEC SQL SELECT total_amount INTO :h_total FROM cl_close_log WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
EXEC SQL SELECT coalesce(sum(gross_amount),0) INTO :h_snap
|
||||
FROM cl_snapshot WHERE close_id = :h_cid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_DELTA, h_total - h_snap);
|
||||
setl(b, T_RC, (h_total == h_snap) ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/cl/svc/CL_INQUIRY.h
Normal file
21
app/src/cl/svc/CL_INQUIRY.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* CL_INQUIRY.h - cl 서비스 CL_INQUIRY 카피북 (copybook / record header).
|
||||
* 마감 조회: close_type/기간/상태/총건수 반환.
|
||||
*/
|
||||
#ifndef CL_INQUIRY_H
|
||||
#define CL_INQUIRY_H
|
||||
|
||||
#include "cl_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long id1;
|
||||
long id2;
|
||||
long amount;
|
||||
char status[8];
|
||||
char key1[32];
|
||||
char biz_date[16];
|
||||
} cl_cl_inquiry_rec_t;
|
||||
|
||||
void CL_INQUIRY(TPSVCINFO *p);
|
||||
|
||||
#endif /* CL_INQUIRY_H */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue