다양화: 530개 online/batch 프로그램을 모듈별 고유 실업무 로직으로 재작성

- 템플릿 클론(정규화 후 0줄 상이) → 전 코퍼스 530/530 고유 바디
- 11개 모듈(mg/au/ac/rc/vl/st/py/lg/mm/cm/cl) 각 파일이 distinct한
  매입·대사·정산·수수료·지급·원장·마감·마스터·정합성·전문게이트웨이·공통 업무
- TxCore(ATMI 유사) + ECPG(EXEC SQL) 관용구, 프레임워크/헤더/DBIO API/파일ID·경로 유지
- 전체 docker make -j4 = EXIT 0, 958 오브젝트, 데모 바이너리 링크
- inventory.json loc 실측 갱신

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
forge-bot 2026-07-19 01:37:54 +00:00
parent b96cf702ee
commit c3a0259e95
1027 changed files with 68915 additions and 40962 deletions

View file

@ -1,14 +1,17 @@
/* @tier easy @module mg @transform msg-gateway-online */
/* @tier medium @module mg @transform msg-gateway-online */
/*
* mg_ol_0032.pgc - 전문게이트웨이 온라인 서비스 (MG_OL_0032) [tier=easy]
* mg_ol_0032.pgc - 전문게이트웨이 전문 라우팅 통계 조회 서비스 (MG_OL_0032) [tier=medium]
*
* TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 mg 표준 DBIO 를
* 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응)
* 지정 영업일(BIZDATE)의 처리원장(mg_ledger)을 채널코드(chan_cd)별로 집계
* (count GROUP BY)하여 채널 수·총 전문건수·최다 처리채널(상위채널)을 산출한다.
* 커서로 집계결과를 순회하며 최상위 채널을 선별해 응답한다.
* (ATMI void SVC(TPSVCINFO*) 대응)
*/
#include <stdio.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "mg_core.h"
@ -16,32 +19,99 @@ EXEC SQL INCLUDE sqlca;
TX_SERVICE(MG_OL_0032, ctx)
{
mg_rec_t rec;
char key[16];
int rc;
EXEC SQL BEGIN DECLARE SECTION;
char h_biz_date[9];
char h_chan_cd[9];
long h_chan_cnt;
EXEC SQL END DECLARE SECTION;
tx_log(TX_LOG_INFO, "[MG_OL_0032] 전문게이트웨이 단건조회 서비스 진입");
char bizdate[16];
char top_chan[9];
long top_cnt = 0, total_cnt = 0, chan_num = 0;
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[MG_OL_0032] KEY 누락");
tx_log(TX_LOG_INFO, "[MG_OL_0032] 전문 라우팅 통계 조회 서비스 진입");
/* 1) 집계 대상 영업일 수신/검증 */
if (tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[MG_OL_0032] BIZDATE 누락");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
if (!date_is_valid(bizdate)) {
tx_log(TX_LOG_WARN, "[MG_OL_0032] 영업일 형식 오류 date=%s", bizdate);
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESP", RESP_INVALID);
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
memset(&rec, 0, sizeof(rec));
rc = mg_rec_select(key, &rec);
if (rc != TX_OK) {
tx_log(TX_LOG_WARN, "[MG_OL_0032] 조회 실패 key=%s rc=%d(%s)",
key, rc, tx_strerror(rc));
tx_return(ctx, rc, ctx->out);
strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1);
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
memset(top_chan, 0, sizeof(top_chan));
/* 2) 채널별 전문건수 집계 커서 (건수 내림차순) */
EXEC SQL DECLARE cur_mg_ol_0032 CURSOR FOR
SELECT chan_cd, count(*)
FROM mg_ledger
WHERE biz_date = :h_biz_date
GROUP BY chan_cd
ORDER BY count(*) DESC;
EXEC SQL OPEN cur_mg_ol_0032;
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("OPEN cur_mg_ol_0032");
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESP", RESP_SYSERR);
tx_return(ctx, TX_EDB, ctx->out);
return;
}
/* 3) 집계결과 순회: 총건수 누적 + 최상위 채널 선별 */
for (;;) {
EXEC SQL FETCH cur_mg_ol_0032 INTO :h_chan_cd, :h_chan_cnt;
if (sqlca.sqlcode == TX_SQL_NOTFOUND)
break;
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("FETCH cur_mg_ol_0032");
EXEC SQL CLOSE cur_mg_ol_0032;
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESP", RESP_SYSERR);
tx_return(ctx, TX_EDB, ctx->out);
return;
}
total_cnt += h_chan_cnt;
chan_num++;
if (h_chan_cnt > top_cnt) {
top_cnt = h_chan_cnt;
strncpy(top_chan, h_chan_cd, sizeof(top_chan) - 1);
top_chan[sizeof(top_chan) - 1] = '\0';
}
}
EXEC SQL CLOSE cur_mg_ol_0032;
/* 4) 집계대상 없음 처리 */
if (chan_num == 0) {
tx_log(TX_LOG_INFO, "[MG_OL_0032] 집계대상 없음 date=%s", bizdate);
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESP", RESP_OK);
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
tx_buf_setlong(ctx->out, "CHANNUM", 0);
tx_buf_setlong(ctx->out, "TOTALCNT", 0);
tx_return(ctx, TX_OK, ctx->out);
return;
}
/* 5) 통계결과 응답 (상위채널 포함) */
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "KEY", rec.key);
tx_buf_sets(ctx->out, "MERCHID", rec.merch_id);
tx_buf_setlong(ctx->out, "AMOUNT", rec.amount);
tx_buf_sets(ctx->out, "STATUS", rec.status);
tx_log(TX_LOG_INFO, "[MG_OL_0032] 조회완료 key=%s amount=%ld", key, rec.amount);
tx_buf_sets(ctx->out, "RESP", RESP_OK);
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
tx_buf_setlong(ctx->out, "CHANNUM", chan_num);
tx_buf_setlong(ctx->out, "TOTALCNT", total_cnt);
tx_buf_sets(ctx->out, "TOPCHAN", top_chan);
tx_buf_setlong(ctx->out, "TOPCNT", top_cnt);
tx_log(TX_LOG_INFO, "[MG_OL_0032] 통계완료 date=%s 채널수=%ld 총건수=%ld 상위채널=%s(%ld)",
bizdate, chan_num, total_cnt, top_chan, top_cnt);
tx_return(ctx, TX_OK, ctx->out);
}