다양화: 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:
parent
b96cf702ee
commit
c3a0259e95
1027 changed files with 68915 additions and 40962 deletions
|
|
@ -8,10 +8,12 @@
|
|||
#line 1 "app/online/mg_ol_0013.pgc"
|
||||
/* @tier medium @module mg @transform msg-gateway-online */
|
||||
/*
|
||||
* mg_ol_0013.pgc - 전문게이트웨이 온라인 서비스 (MG_OL_0013) [tier=medium]
|
||||
* mg_ol_0013.pgc - 전문게이트웨이 채널별 어댑터 서비스 (MG_OL_0013) [tier=medium]
|
||||
*
|
||||
* TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 mg 표준 DBIO 를
|
||||
* 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응)
|
||||
* 채널마다 상이한 수신 헤더 포맷을 표준공통헤더(STDHDR)로 정규화한다.
|
||||
* 채널코드(CHAN)별 규칙은 in-code switch 로 분기하며, 각 채널이 자신의
|
||||
* 헤더에 배치한 전문종별/전문길이/일시 오프셋을 표준 배열로 재배치한다.
|
||||
* 표준헤더 = 전문종별(4) + 채널(3) + 전문길이(5) + 일시(14) = 26바이트.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -89,60 +91,116 @@ struct sqlca_t *ECPGget_sqlca(void);
|
|||
|
||||
#endif
|
||||
|
||||
#line 15 "app/online/mg_ol_0013.pgc"
|
||||
#line 17 "app/online/mg_ol_0013.pgc"
|
||||
|
||||
|
||||
/* 채널 어댑터 정규화 규칙 */
|
||||
#define STD_HDR_LEN 26
|
||||
|
||||
TX_SERVICE(MG_OL_0013, ctx)
|
||||
{
|
||||
mg_rec_t rec;
|
||||
char key[16], merch[16], bizdate[16];
|
||||
long amount = 0, cnt;
|
||||
int rc;
|
||||
char raw[256];
|
||||
char chan[8];
|
||||
char stdhdr[STD_HDR_LEN + 1];
|
||||
char mtype[FLD_MSG_TYPE_LEN + 1];
|
||||
char yyyymmdd[9];
|
||||
char hhmmss[7];
|
||||
int rawlen;
|
||||
int bodyoff;
|
||||
int chan3;
|
||||
|
||||
tx_log(TX_LOG_INFO, "[MG_OL_0013] 전문게이트웨이 등록 서비스 진입");
|
||||
tx_log(TX_LOG_INFO, "[MG_OL_0013] 채널별 어댑터 서비스 진입");
|
||||
|
||||
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK ||
|
||||
tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK ||
|
||||
tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[MG_OL_0013] 필수 필드 누락");
|
||||
rawlen = tx_buf_get(ctx->in, "RAWMSG", raw, sizeof(raw));
|
||||
if (rawlen <= 0 ||
|
||||
tx_buf_get(ctx->in, "CHAN", chan, sizeof(chan)) != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[MG_OL_0013] 필수 필드 누락(RAWMSG/CHAN)");
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
tx_buf_getlong(ctx->in, "AMOUNT", &amount);
|
||||
rawlen = (int)strlen(raw);
|
||||
|
||||
/* 업무검증: 금액 범위 + 영업일 형식 */
|
||||
if (!amount_is_valid(amount)) {
|
||||
tx_log(TX_LOG_WARN, "[MG_OL_0013] 금액 범위 오류 amount=%ld", amount);
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
if (!date_is_valid(bizdate)) {
|
||||
tx_log(TX_LOG_WARN, "[MG_OL_0013] 영업일 오류 date=%s", bizdate);
|
||||
memset(mtype, 0, sizeof(mtype));
|
||||
memset(yyyymmdd, 0, sizeof(yyyymmdd));
|
||||
memset(hhmmss, 0, sizeof(hhmmss));
|
||||
|
||||
/* 채널별 헤더 규칙 분기: 각 채널이 필드를 서로 다른 오프셋에 둔다 */
|
||||
if (strcmp(chan, "VAN") == 0) {
|
||||
/* VAN(부가통신): [종별4][일시14][본문...] */
|
||||
if (rawlen < 18) { bodyoff = -1; }
|
||||
else {
|
||||
memcpy(mtype, raw + 0, 4);
|
||||
memcpy(yyyymmdd, raw + 4, 8);
|
||||
memcpy(hhmmss, raw + 12, 6);
|
||||
bodyoff = 18;
|
||||
}
|
||||
chan3 = 0;
|
||||
} else if (strcmp(chan, "PGW") == 0) {
|
||||
/* PGW(전자지불): [일시14][종별4][본문...] - 순서 반전 */
|
||||
if (rawlen < 18) { bodyoff = -1; }
|
||||
else {
|
||||
memcpy(yyyymmdd, raw + 0, 8);
|
||||
memcpy(hhmmss, raw + 8, 6);
|
||||
memcpy(mtype, raw + 14, 4);
|
||||
bodyoff = 18;
|
||||
}
|
||||
chan3 = 1;
|
||||
} else if (strcmp(chan, "MPI") == 0) {
|
||||
/* MPI(모바일): [종별4][채널프리픽스2][일시14][본문...] */
|
||||
if (rawlen < 20) { bodyoff = -1; }
|
||||
else {
|
||||
memcpy(mtype, raw + 0, 4);
|
||||
memcpy(yyyymmdd, raw + 6, 8);
|
||||
memcpy(hhmmss, raw + 14, 6);
|
||||
bodyoff = 20;
|
||||
}
|
||||
chan3 = 2;
|
||||
} else {
|
||||
tx_log(TX_LOG_WARN, "[MG_OL_0013] 미지원 채널코드 chan=%s", chan);
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&rec, 0, sizeof(rec));
|
||||
strncpy(rec.key, key, sizeof(rec.key) - 1);
|
||||
strncpy(rec.merch_id, merch, sizeof(rec.merch_id) - 1);
|
||||
strncpy(rec.biz_date, bizdate, sizeof(rec.biz_date) - 1);
|
||||
strncpy(rec.status, MG_ST_RECV, sizeof(rec.status) - 1);
|
||||
rec.amount = amount;
|
||||
rec.fee = amount / 100; /* 수수료 1% 가정 */
|
||||
|
||||
rc = mg_rec_insert(&rec);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[MG_OL_0013] 등록 실패 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
tx_return(ctx, rc, ctx->out);
|
||||
if (bodyoff < 0) {
|
||||
tx_log(TX_LOG_WARN, "[MG_OL_0013] 헤더 길이부족 chan=%s len=%d", chan, rawlen);
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
||||
tx_return(ctx, TX_FAIL, ctx->out);
|
||||
return;
|
||||
}
|
||||
|
||||
cnt = mg_rec_count(bizdate, MG_ST_RECV);
|
||||
/* 종별 검증: 정규화 대상은 수신/응답/정산 전문만 허용 */
|
||||
if (strncmp(mtype, MSG_TYPE_RECV, 4) != 0 &&
|
||||
strncmp(mtype, MSG_TYPE_RESP, 4) != 0 &&
|
||||
strncmp(mtype, MSG_TYPE_RECON, 4) != 0) {
|
||||
tx_log(TX_LOG_WARN, "[MG_OL_0013] 전문종별 오류 chan=%s type=%.4s", chan, mtype);
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
||||
tx_return(ctx, TX_FAIL, ctx->out);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 표준공통헤더 재배치: 종별(4)+채널(3)+본문길이(5)+일자(8)+시각(6) */
|
||||
memset(stdhdr, ' ', STD_HDR_LEN);
|
||||
stdhdr[STD_HDR_LEN] = '\0';
|
||||
memcpy(stdhdr + 0, mtype, 4);
|
||||
memcpy(stdhdr + 4, chan, (strlen(chan) < 3) ? strlen(chan) : 3);
|
||||
snprintf(stdhdr + 7, 6, "%05d", rawlen - bodyoff);
|
||||
memcpy(stdhdr + 12, yyyymmdd, 8);
|
||||
memcpy(stdhdr + 20, hhmmss, 6);
|
||||
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_OK);
|
||||
tx_buf_sets(ctx->out, "KEY", key);
|
||||
tx_buf_setlong(ctx->out, "DAYCNT", (cnt < 0) ? 0 : cnt);
|
||||
tx_log(TX_LOG_INFO, "[MG_OL_0013] 등록완료 key=%s 당일건수=%ld", key, cnt);
|
||||
tx_buf_sets(ctx->out, "STDHDR", stdhdr);
|
||||
tx_buf_sets(ctx->out, "MSGTYPE", mtype);
|
||||
tx_buf_sets(ctx->out, "TXNDATE", yyyymmdd);
|
||||
tx_buf_sets(ctx->out, "TXNTIME", hhmmss);
|
||||
tx_buf_sets(ctx->out, "BODY", raw + bodyoff);
|
||||
tx_buf_setlong(ctx->out, "CHANIDX", (long)chan3);
|
||||
tx_buf_setlong(ctx->out, "BODYLEN", (long)(rawlen - bodyoff));
|
||||
tx_log(TX_LOG_INFO, "[MG_OL_0013] 정규화 완료 chan=%s type=%.4s bodylen=%d",
|
||||
chan, mtype, rawlen - bodyoff);
|
||||
tx_return(ctx, TX_OK, ctx->out);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue