다양화: 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
|
|
@ -2,13 +2,16 @@
|
|||
/*
|
||||
* cl_ol_0009.pgc - 마감 온라인 서비스 (CL_OL_0009) [tier=hard]
|
||||
*
|
||||
* TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 cl 표준 DBIO 를
|
||||
* 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응)
|
||||
* 마감 순번 채번(採番). 요청 영업일(BIZDATE)에 대해 기존 마감완료(S) 건수를
|
||||
* 세어 다음 마감 순번(next = 기존건수 + 1)을 산출한다. 아울러 원장 전체
|
||||
* max(key) 기반 채번 참조값도 함께 조회하여, 영업일+순번 형식의 채번키를
|
||||
* 생성해 반환한다. 실제 원장을 변경하지 않는 read-only 채번 서비스이다.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
|
@ -16,83 +19,103 @@ EXEC SQL INCLUDE sqlca;
|
|||
|
||||
TX_SERVICE(CL_OL_0009, ctx)
|
||||
{
|
||||
cl_rec_t rec;
|
||||
char key[16], merch[16], bizdate[16], nextbiz[9];
|
||||
long amount = 0, daysum = 0;
|
||||
int rc;
|
||||
TXBUF *sub_in;
|
||||
TXBUF *sub_out;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
int h_settled_cnt;
|
||||
int h_all_cnt;
|
||||
char h_max_key[16];
|
||||
short h_maxkey_ind;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0009] 마감 트랜잭션 오케스트레이션 진입");
|
||||
char bizdate[16];
|
||||
long next_seq = 0;
|
||||
char seq_key[24];
|
||||
char maxkey_out[16];
|
||||
|
||||
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, "[CL_OL_0009] 필수 필드 누락");
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0009] 마감 순번 채번 서비스 진입");
|
||||
|
||||
/* 1. 요청 검증 */
|
||||
if (tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[CL_OL_0009] BIZDATE 누락");
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
tx_buf_getlong(ctx->in, "AMOUNT", &amount);
|
||||
|
||||
if (!amount_is_valid(amount) || !date_is_valid(bizdate)) {
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0009] 입력 검증 실패 amount=%ld date=%s",
|
||||
amount, bizdate);
|
||||
if (!date_is_valid(bizdate)) {
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0009] 영업일 형식 오류 date=%s", bizdate);
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 트랜잭션 시작 → 원장 반영 → 후속 서비스 연계 → 커밋 */
|
||||
if (tx_begin() != TX_OK) {
|
||||
tx_return(ctx, TX_FAIL, ctx->out);
|
||||
strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
/* 2. 당일 기존 마감완료(S) 건수 채번 기준 */
|
||||
EXEC SQL SELECT count(*)
|
||||
INTO :h_settled_cnt
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date
|
||||
AND status = 'S';
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("CL_OL_0009 settled count");
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
|
||||
tx_return(ctx, TX_EDB, 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, CL_ST_RECV, sizeof(rec.status) - 1);
|
||||
rec.amount = amount;
|
||||
rec.fee = amount / 100;
|
||||
|
||||
rc = cl_rec_insert(&rec);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[CL_OL_0009] 원장반영 실패 rc=%d", rc);
|
||||
tx_abort();
|
||||
tx_return(ctx, rc, ctx->out);
|
||||
/* 3. 당일 전체 건수 (참조 지표) */
|
||||
EXEC SQL SELECT count(*)
|
||||
INTO :h_all_cnt
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("CL_OL_0009 all count");
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
|
||||
tx_return(ctx, TX_EDB, ctx->out);
|
||||
return;
|
||||
}
|
||||
|
||||
/* 정산 영업일 = 거래일의 다음 영업일 */
|
||||
if (date_next_business(bizdate, nextbiz) != 0) {
|
||||
memcpy(nextbiz, bizdate, 8);
|
||||
nextbiz[8] = '\0';
|
||||
/* 4. 당일 max(key) 참조 (없으면 널 → indicator 로 감지) */
|
||||
h_maxkey_ind = 0;
|
||||
EXEC SQL SELECT max(key)
|
||||
INTO :h_max_key :h_maxkey_ind
|
||||
FROM cl_ledger
|
||||
WHERE biz_date = :h_biz_date;
|
||||
if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) {
|
||||
TX_DBIO_LOG_ERR("CL_OL_0009 max key");
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
|
||||
tx_return(ctx, TX_EDB, ctx->out);
|
||||
return;
|
||||
}
|
||||
if (h_maxkey_ind < 0) {
|
||||
strncpy(maxkey_out, "(none)", sizeof(maxkey_out) - 1);
|
||||
maxkey_out[sizeof(maxkey_out) - 1] = '\0';
|
||||
} else {
|
||||
h_max_key[sizeof(h_max_key) - 1] = '\0';
|
||||
strncpy(maxkey_out, h_max_key, sizeof(maxkey_out) - 1);
|
||||
maxkey_out[sizeof(maxkey_out) - 1] = '\0';
|
||||
}
|
||||
|
||||
/* 후속 정산집계 서비스 연계 (레지스트리 문자열 디스패치) */
|
||||
sub_in = tx_buf_alloc();
|
||||
sub_out = tx_buf_alloc();
|
||||
if (sub_in && sub_out) {
|
||||
tx_buf_sets(sub_in, "MERCHID", merch);
|
||||
tx_buf_sets(sub_in, "BIZDATE", nextbiz);
|
||||
tx_buf_setlong(sub_in, "AMOUNT", amount);
|
||||
rc = tx_call("CL_POST", sub_in, sub_out);
|
||||
if (rc != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0009] 후속연계 경고 rc=%d", rc);
|
||||
}
|
||||
tx_buf_free(sub_in);
|
||||
tx_buf_free(sub_out);
|
||||
|
||||
/* 교차 검증: 당일 합계 재계산 */
|
||||
if (cl_rec_sum(bizdate, &daysum) != TX_OK)
|
||||
daysum = 0;
|
||||
|
||||
tx_commit();
|
||||
/* 5. 다음 순번 = 기존 마감건수 + 1, 채번키 = 영업일+순번(4자리) */
|
||||
next_seq = (long)h_settled_cnt + 1;
|
||||
snprintf(seq_key, sizeof(seq_key), "%.8s%04ld", h_biz_date, next_seq);
|
||||
|
||||
/* 6. 응답 구성 (read-only) */
|
||||
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, "DAYSUM", daysum);
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0009] 완료 key=%s 당일합계=%ld", key, daysum);
|
||||
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
|
||||
tx_buf_setlong(ctx->out, "SETTLEDCNT", (long)h_settled_cnt);
|
||||
tx_buf_setlong(ctx->out, "ALLCNT", (long)h_all_cnt);
|
||||
tx_buf_setlong(ctx->out, "NEXTSEQ", next_seq);
|
||||
tx_buf_sets(ctx->out, "SEQKEY", seq_key);
|
||||
tx_buf_sets(ctx->out, "MAXKEY", maxkey_out);
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0009] 채번완료 date=%s 다음순번=%ld 채번키=%s",
|
||||
bizdate, next_seq, seq_key);
|
||||
tx_return(ctx, TX_OK, ctx->out);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue