- 템플릿 클론(정규화 후 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>
201 lines
6.2 KiB
C
201 lines
6.2 KiB
C
/* Processed by ecpg (15.18 (Debian 15.18-0+deb12u1)) */
|
|
/* These include files are added by the preprocessor */
|
|
#include <ecpglib.h>
|
|
#include <ecpgerrno.h>
|
|
#include <sqlca.h>
|
|
/* End of automatic include section */
|
|
|
|
#line 1 "app/online/rc_ol_0006.pgc"
|
|
/* @tier medium @module rc @transform reconciliation-online */
|
|
/*
|
|
* rc_ol_0006.pgc - 건수 불일치 검출 온라인 서비스 (RC_OL_0006)
|
|
*
|
|
* 요청 영업일(BIZDATE)에 대해 상태별 원장 건수를 집계하여 대사 진행
|
|
* 상황을 점검한다. 상태별로 rc_rec_count 를 호출한다:
|
|
* 접수('R'), 매입확정('M'), 불일치('U'), 정산완료('S').
|
|
*
|
|
* 업무규칙:
|
|
* - total = 접수 + 매입확정 + 불일치 + 정산완료
|
|
* - 접수('R') 건이 하나라도 남아 있으면 아직 처리되지 않은 미처리
|
|
* 잔존이 있으므로 MISMATCH=Y, 없으면 MISMATCH=N.
|
|
*
|
|
* 응답: BIZDATE, CNTR, CNTM, CNTU, CNTS, TOTAL, MISMATCH
|
|
*
|
|
* 상태 코드 대응:
|
|
* CNTR 접수/승인('R') - 아직 대사되지 않은 미처리 건
|
|
* CNTM 매입확정('M') - 승인-매입 대사 완료 건
|
|
* CNTU 불일치/보류('U') - 예외처리 대기 건
|
|
* CNTS 정산완료('S') - 입금대사까지 종료된 건
|
|
*
|
|
* 판정 원칙: 하루의 대사가 완결되면 접수('R') 잔량이 0 이어야 한다.
|
|
* CNTR > 0 이면 미처리 잔존으로 보아 MISMATCH=Y 를 통지한다.
|
|
* (CNTU 는 예외처리 트랙으로 별도 관리하므로 여기서는 접수
|
|
* 잔량만을 완결 지표로 삼는다.) 상태별 단순 COUNT 집계만
|
|
* 수행하므로 커서/트랜잭션 경계가 필요 없다.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "acq_util.h"
|
|
#include "rc_core.h"
|
|
|
|
|
|
#line 1 "/usr/include/postgresql/sqlca.h"
|
|
#ifndef POSTGRES_SQLCA_H
|
|
#define POSTGRES_SQLCA_H
|
|
|
|
#ifndef PGDLLIMPORT
|
|
#if defined(WIN32) || defined(__CYGWIN__)
|
|
#define PGDLLIMPORT __declspec (dllimport)
|
|
#else
|
|
#define PGDLLIMPORT
|
|
#endif /* __CYGWIN__ */
|
|
#endif /* PGDLLIMPORT */
|
|
|
|
#define SQLERRMC_LEN 150
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
struct sqlca_t
|
|
{
|
|
char sqlcaid[8];
|
|
long sqlabc;
|
|
long sqlcode;
|
|
struct
|
|
{
|
|
int sqlerrml;
|
|
char sqlerrmc[SQLERRMC_LEN];
|
|
} sqlerrm;
|
|
char sqlerrp[8];
|
|
long sqlerrd[6];
|
|
/* Element 0: empty */
|
|
/* 1: OID of processed tuple if applicable */
|
|
/* 2: number of rows processed */
|
|
/* after an INSERT, UPDATE or */
|
|
/* DELETE statement */
|
|
/* 3: empty */
|
|
/* 4: empty */
|
|
/* 5: empty */
|
|
char sqlwarn[8];
|
|
/* Element 0: set to 'W' if at least one other is 'W' */
|
|
/* 1: if 'W' at least one character string */
|
|
/* value was truncated when it was */
|
|
/* stored into a host variable. */
|
|
|
|
/*
|
|
* 2: if 'W' a (hopefully) non-fatal notice occurred
|
|
*/ /* 3: empty */
|
|
/* 4: empty */
|
|
/* 5: empty */
|
|
/* 6: empty */
|
|
/* 7: empty */
|
|
|
|
char sqlstate[5];
|
|
};
|
|
|
|
struct sqlca_t *ECPGget_sqlca(void);
|
|
|
|
#ifndef POSTGRES_ECPG_INTERNAL
|
|
#define sqlca (*ECPGget_sqlca())
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#line 35 "app/online/rc_ol_0006.pgc"
|
|
|
|
|
|
TX_SERVICE(RC_OL_0006, ctx)
|
|
{
|
|
char bizdate[16];
|
|
long cnt_r, cnt_m, cnt_u, cnt_s;
|
|
long total;
|
|
const char *mismatch;
|
|
|
|
tx_log(TX_LOG_INFO, "[RC_OL_0006] 건수 불일치 검출 서비스 진입");
|
|
|
|
/* --- 요청 필드 추출 및 검증 --- */
|
|
if (tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[RC_OL_0006] BIZDATE 누락");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
if (!date_is_valid(bizdate)) {
|
|
tx_log(TX_LOG_WARN, "[RC_OL_0006] 영업일 형식 오류 date=%s", bizdate);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* --- 상태별 건수 집계 (음수 리턴은 조회오류) --- */
|
|
cnt_r = rc_rec_count(bizdate, RC_ST_RECV);
|
|
cnt_m = rc_rec_count(bizdate, RC_ST_DONE);
|
|
cnt_u = rc_rec_count(bizdate, RC_ST_FAIL);
|
|
cnt_s = rc_rec_count(bizdate, RC_ST_SETTLED);
|
|
|
|
if (cnt_r < 0 || cnt_m < 0 || cnt_u < 0 || cnt_s < 0) {
|
|
tx_log(TX_LOG_ERROR,
|
|
"[RC_OL_0006] 건수 집계 실패 date=%s R=%ld M=%ld U=%ld S=%ld",
|
|
bizdate, cnt_r, cnt_m, cnt_u, cnt_s);
|
|
tx_return(ctx, TX_EDB, ctx->out);
|
|
return;
|
|
}
|
|
|
|
total = cnt_r + cnt_m + cnt_u + cnt_s;
|
|
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0006] 집계 date=%s R=%ld M=%ld U=%ld S=%ld 총=%ld",
|
|
bizdate, cnt_r, cnt_m, cnt_u, cnt_s, total);
|
|
|
|
/* 총건수 0 이면 해당 영업일 대사 대상 자체가 없음 (참고 로그) */
|
|
if (total == 0)
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0006] 대사 대상 없음 date=%s (원장 무건)", bizdate);
|
|
|
|
/* 불일치('U') 누적 경고 (완결 지표와 별개로 예외 트랙 가시화) */
|
|
if (cnt_u > 0)
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0006] 예외처리 대기 date=%s 불일치=%ld", bizdate, cnt_u);
|
|
|
|
/* --- 미처리(접수) 잔존 여부로 불일치 플래그 결정 --- */
|
|
if (cnt_r > 0) {
|
|
mismatch = "Y";
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0006] 미처리 잔존 date=%s 접수=%ld → MISMATCH",
|
|
bizdate, cnt_r);
|
|
} else {
|
|
mismatch = "N";
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0006] 미처리 없음 date=%s 총=%ld → 정상",
|
|
bizdate, total);
|
|
}
|
|
|
|
/* --- 응답 구성 --- */
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
|
|
tx_buf_setlong(ctx->out, "CNTR", cnt_r);
|
|
tx_buf_setlong(ctx->out, "CNTM", cnt_m);
|
|
tx_buf_setlong(ctx->out, "CNTU", cnt_u);
|
|
tx_buf_setlong(ctx->out, "CNTS", cnt_s);
|
|
tx_buf_setlong(ctx->out, "TOTAL", total);
|
|
tx_buf_sets(ctx->out, "MISMATCH", mismatch);
|
|
|
|
/* 진행률 참고 로그: (매입확정+정산완료) / 총건수 */
|
|
if (total > 0) {
|
|
long done_cnt = cnt_m + cnt_s;
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0006] 검출완료 date=%s 완료=%ld/%ld MISMATCH=%s",
|
|
bizdate, done_cnt, total, mismatch);
|
|
} else {
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0006] 검출완료 date=%s 대상없음 MISMATCH=%s",
|
|
bizdate, mismatch);
|
|
}
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|