This repository has been archived on 2026-07-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
acquire-core-full/app/online/cl_ol_0010.pgc
forge-bot c3a0259e95 다양화: 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>
2026-07-19 01:37:54 +00:00

122 lines
4.5 KiB
Text

/* @tier easy @module cl @transform closing-online */
/*
* cl_ol_0010.pgc - 마감 온라인 서비스 (CL_OL_0010) [tier=easy]
*
* 마감 리포트 조회. 요청 영업일(BIZDATE)의 상태별 건수를 접수(R)/처리완료(M)/
* 불일치(U)/정산완료(S) 각각 개별 SELECT 로 산출하여 리포트 형태로 응답한다.
* 마감 진척률(정산완료/전체)도 함께 계산한다. (read-only)
*
* ── 서비스 계약(Contract) ────────────────────────────────────────────
* 입력 필드:
* BIZDATE (필수) 영업일(YYYYMMDD)
* 출력 필드:
* RESPCODE 0000=정상 / 9001=입력오류 / 9999=시스템오류
* BIZDATE 리포트 대상 영업일
* CNTRECV 접수(R) 건수
* CNTDONE 처리완료(M) 건수
* CNTFAIL 불일치(U) 건수
* CNTSETTLED 정산완료(S) 건수
* CNTTOTAL 전체 건수(R+M+U+S)
* PROGRESS 마감 진척률(%) = 정산완료 / 전체 * 100
*
* ── 리포트 규칙 ──────────────────────────────────────────────────────
* · 상태코드 R/M/U/S 각각에 대해 개별 count SELECT 를 순회 수행한다.
* · 진척률은 전체 건이 0 일 때 0% 로 처리(0 나눗셈 방지)한다.
* · 마감 담당자의 일일 마감현황 대시보드 소스로 사용된다.
*/
#include <stdio.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "cl_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(CL_OL_0010, ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_biz_date[9];
char h_status[2];
int h_cnt;
EXEC SQL END DECLARE SECTION;
char bizdate[16];
long cnt_r = 0, cnt_m = 0, cnt_u = 0, cnt_s = 0, total = 0;
long remain = 0;
long progress = 0;
int i;
const char *codes = "RMUS";
tx_log(TX_LOG_INFO, "[CL_OL_0010] 마감 리포트 조회 서비스 진입");
/* 1. 요청 검증 */
if (tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[CL_OL_0010] BIZDATE 누락");
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
if (!date_is_valid(bizdate)) {
tx_log(TX_LOG_WARN, "[CL_OL_0010] 영업일 형식 오류 date=%s", bizdate);
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
strncpy(h_biz_date, bizdate, sizeof(h_biz_date) - 1);
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
/* 2. 상태코드별 개별 count SELECT (R/M/U/S 순회) */
for (i = 0; i < 4; i++) {
long v;
h_status[0] = codes[i];
h_status[1] = '\0';
EXEC SQL SELECT count(*)
INTO :h_cnt
FROM cl_ledger
WHERE biz_date = :h_biz_date
AND status = :h_status;
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("CL_OL_0010 status count");
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
tx_return(ctx, TX_EDB, ctx->out);
return;
}
v = (long)h_cnt;
switch (codes[i]) {
case 'R': cnt_r = v; break;
case 'M': cnt_m = v; break;
case 'U': cnt_u = v; break;
case 'S': cnt_s = v; break;
default: break;
}
}
/* 3. 합계 / 미정산 잔여(R+M+U) / 진척률(%) 계산 */
total = cnt_r + cnt_m + cnt_u + cnt_s;
remain = cnt_r + cnt_m + cnt_u;
progress = (total > 0) ? (cnt_s * 100 / total) : 0;
/* 4. 리포트 응답 구성 */
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESPCODE", RESP_OK);
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
tx_buf_setlong(ctx->out, "CNTRECV", cnt_r);
tx_buf_setlong(ctx->out, "CNTDONE", cnt_m);
tx_buf_setlong(ctx->out, "CNTFAIL", cnt_u);
tx_buf_setlong(ctx->out, "CNTSETTLED", cnt_s);
tx_buf_setlong(ctx->out, "CNTTOTAL", total);
tx_buf_setlong(ctx->out, "CNTREMAIN", remain);
tx_buf_setlong(ctx->out, "PROGRESS", progress);
tx_buf_sets(ctx->out, "COMPLETED", (remain == 0 && total > 0) ? "Y" : "N");
tx_log(TX_LOG_INFO,
"[CL_OL_0010] 리포트 date=%s R=%ld M=%ld U=%ld S=%ld 진척=%ld%%",
bizdate, cnt_r, cnt_m, cnt_u, cnt_s, progress);
tx_return(ctx, TX_OK, ctx->out);
}