다양화: 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
|
|
@ -10,13 +10,22 @@
|
|||
/*
|
||||
* cl_ol_0025.pgc - 마감 온라인 서비스 (CL_OL_0025) [tier=medium]
|
||||
*
|
||||
* TxCore TX_SERVICE 엔트리. 요청 TXBUF 를 검증하고 cl 표준 DBIO 를
|
||||
* 통해 처리한 뒤 응답 TXBUF 를 구성한다. (ATMI void SVC(TPSVCINFO*) 대응)
|
||||
* 알림 재발송
|
||||
* ----------------------------------------------------------------------
|
||||
* 요청 영업일(BIZDATE)의 미마감(R) 건수와 불일치(U) 건수를 각각 개별
|
||||
* 조회한 뒤, 두 값을 바탕으로 마감 지연/불일치 알림 메시지를 구성하여
|
||||
* ALERT 유형 응답으로 반환한다. 미마감·불일치가 모두 0 이면
|
||||
* 정상(알림불필요)으로 표시한다.
|
||||
*
|
||||
* 미마감/불일치 규모에 따라 심각도(SEVERITY: NONE/WARN/CRIT)를 부여
|
||||
* 하고, 정산완료(S) 건수를 함께 조회하여 진행 맥락을 알림에 포함한다.
|
||||
* 재발송 대상 수신처(TARGET)와 감사추적 REQID 는 선택 입력으로 받는다.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "cl_core.h"
|
||||
|
||||
|
|
@ -89,60 +98,105 @@ struct sqlca_t *ECPGget_sqlca(void);
|
|||
|
||||
#endif
|
||||
|
||||
#line 15 "app/online/cl_ol_0025.pgc"
|
||||
#line 24 "app/online/cl_ol_0025.pgc"
|
||||
|
||||
|
||||
#define CL_OL_0025_CRIT_THRESHOLD 10
|
||||
|
||||
TX_SERVICE(CL_OL_0025, ctx)
|
||||
{
|
||||
cl_rec_t rec;
|
||||
char key[16], merch[16], bizdate[16];
|
||||
long amount = 0, cnt;
|
||||
int rc;
|
||||
char bizdate[16];
|
||||
char reqid[32];
|
||||
char target[32];
|
||||
char alert[TX_VAL_LEN];
|
||||
const char *severity;
|
||||
long recv_cnt, fail_cnt, settled_cnt, done_cnt;
|
||||
long pending, total_cnt;
|
||||
int need_alert;
|
||||
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0025] 마감 등록 서비스 진입");
|
||||
tx_log(TX_LOG_INFO, "[CL_OL_0025] 알림 재발송 서비스 진입");
|
||||
|
||||
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_0025] 필수 필드 누락");
|
||||
/* 1) 입력 수신 및 검증 */
|
||||
if (tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[CL_OL_0025] 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 (tx_buf_get(ctx->in, "REQID", reqid, sizeof(reqid)) != TX_OK)
|
||||
strncpy(reqid, "-", sizeof(reqid) - 1);
|
||||
if (tx_buf_get(ctx->in, "TARGET", target, sizeof(target)) != TX_OK)
|
||||
strncpy(target, "OPS-DESK", sizeof(target) - 1);
|
||||
|
||||
/* 업무검증: 금액 범위 + 영업일 형식 */
|
||||
if (!amount_is_valid(amount)) {
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0025] 금액 범위 오류 amount=%ld", amount);
|
||||
tx_return(ctx, TX_EINVAL, ctx->out);
|
||||
return;
|
||||
}
|
||||
if (!date_is_valid(bizdate)) {
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0025] 영업일 오류 date=%s", bizdate);
|
||||
tx_log(TX_LOG_WARN, "[CL_OL_0025] 영업일 형식 오류 date=%s", bizdate);
|
||||
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, CL_ST_RECV, sizeof(rec.status) - 1);
|
||||
rec.amount = amount;
|
||||
rec.fee = amount / 100; /* 수수료 1% 가정 */
|
||||
|
||||
rc = cl_rec_insert(&rec);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[CL_OL_0025] 등록 실패 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
tx_return(ctx, rc, ctx->out);
|
||||
/* 2) 미마감(R)/불일치(U)/정산완료(S) 건수 개별 조회 */
|
||||
recv_cnt = cl_rec_count(bizdate, CL_ST_RECV);
|
||||
fail_cnt = cl_rec_count(bizdate, CL_ST_FAIL);
|
||||
settled_cnt = cl_rec_count(bizdate, CL_ST_SETTLED);
|
||||
done_cnt = cl_rec_count(bizdate, CL_ST_DONE);
|
||||
if (recv_cnt < 0 || fail_cnt < 0 || settled_cnt < 0 || done_cnt < 0) {
|
||||
tx_log(TX_LOG_ERROR, "[CL_OL_0025] 건수 조회 실패 date=%s", bizdate);
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
|
||||
tx_return(ctx, TX_EDB, ctx->out);
|
||||
return;
|
||||
}
|
||||
total_cnt = recv_cnt + done_cnt + fail_cnt + settled_cnt;
|
||||
|
||||
cnt = cl_rec_count(bizdate, CL_ST_RECV);
|
||||
/*
|
||||
* 3) 심각도 판정 및 알림 메시지 구성
|
||||
* - pending(미마감+불일치)이 0 이면 알림 불필요(NONE)
|
||||
* - 임계(CRIT_THRESHOLD) 이상이면 즉시 조치 대상(CRIT)
|
||||
* - 그 외 잔량이 있으면 주의(WARN)
|
||||
*/
|
||||
pending = recv_cnt + fail_cnt;
|
||||
need_alert = (pending > 0) ? 1 : 0;
|
||||
if (pending == 0)
|
||||
severity = "NONE";
|
||||
else if (pending >= CL_OL_0025_CRIT_THRESHOLD)
|
||||
severity = "CRIT";
|
||||
else
|
||||
severity = "WARN";
|
||||
|
||||
if (need_alert)
|
||||
snprintf(alert, sizeof(alert),
|
||||
"[마감알림/%s] %s 미마감 %ld건, 불일치 %ld건 (정산완료 %ld건) - 확인 요망",
|
||||
severity, bizdate, recv_cnt, fail_cnt, settled_cnt);
|
||||
else
|
||||
snprintf(alert, sizeof(alert),
|
||||
"[마감알림/%s] %s 마감 정상완료(정산완료 %ld건) - 조치 불필요",
|
||||
severity, bizdate, settled_cnt);
|
||||
|
||||
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, "[CL_OL_0025] 등록완료 key=%s 당일건수=%ld", key, cnt);
|
||||
tx_buf_sets(ctx->out, "TYPE", "ALERT");
|
||||
tx_buf_sets(ctx->out, "BIZDATE", bizdate);
|
||||
tx_buf_sets(ctx->out, "REQID", reqid);
|
||||
tx_buf_sets(ctx->out, "TARGET", target);
|
||||
tx_buf_setlong(ctx->out, "RECVCNT", recv_cnt);
|
||||
tx_buf_setlong(ctx->out, "FAILCNT", fail_cnt);
|
||||
tx_buf_setlong(ctx->out, "DONECNT", done_cnt);
|
||||
tx_buf_setlong(ctx->out, "SETTLEDCNT", settled_cnt);
|
||||
tx_buf_setlong(ctx->out, "TOTALCNT", total_cnt);
|
||||
tx_buf_setlong(ctx->out, "PENDING", pending);
|
||||
tx_buf_sets(ctx->out, "SEVERITY", severity);
|
||||
tx_buf_sets(ctx->out, "NEEDALERT", need_alert ? "Y" : "N");
|
||||
tx_buf_sets(ctx->out, "ALERTMSG", alert);
|
||||
/* 미마감 우세/불일치 우세 구분 (조치 우선순위 힌트) */
|
||||
tx_buf_sets(ctx->out, "FOCUS",
|
||||
(fail_cnt > recv_cnt) ? "UNMATCH" : "PENDING");
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[CL_OL_0025] 완료 date=%s R=%ld U=%ld sev=%s 발송=%s target=%s",
|
||||
bizdate, recv_cnt, fail_cnt, severity,
|
||||
need_alert ? "Y" : "N", target);
|
||||
tx_return(ctx, TX_OK, ctx->out);
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue