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/vl_ol_0030.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

119 lines
3.7 KiB
Text

/* @tier easy @module vl @transform validation-online */
/*
* vl_ol_0030.pgc - 정합성 승인처리 서비스 (VL_OL_0030) [tier=easy]
*
* 검토완료된 원장건을 완료(M) 상태로 전이하고, 승인이력(vl_approval_hist)
* 에 승인자/승인일시를 INSERT 한다.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "vl_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(VL_OL_0030, ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_key[16];
char h_approver[16];
EXEC SQL END DECLARE SECTION;
vl_rec_t rec;
char key[16];
char approver[16];
int rc;
tx_log(TX_LOG_INFO, "[VL_OL_0030] 정합성 승인처리 서비스 진입");
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK ||
tx_buf_get(ctx->in, "APPROVER", approver, sizeof(approver)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0030] 필수 필드(KEY/APPROVER) 누락");
tx_buf_sets(ctx->out, "ERRCODE", "VL3000");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
memset(&rec, 0, sizeof(rec));
rc = vl_rec_select(key, &rec);
if (rc != TX_OK) {
tx_log(TX_LOG_WARN, "[VL_OL_0030] 원장 없음 key=%s rc=%d(%s)",
key, rc, tx_strerror(rc));
tx_buf_sets(ctx->out, "ERRCODE", "VL3001");
tx_return(ctx, rc, ctx->out);
return;
}
/* 이미 완료/정산된 건은 승인 대상이 아니다 */
if (strcmp(rec.status, VL_ST_DONE) == 0 ||
strcmp(rec.status, VL_ST_SETTLED) == 0) {
tx_log(TX_LOG_WARN, "[VL_OL_0030] 승인불가 상태 key=%s status=%s",
key, rec.status);
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "KEY", key);
tx_buf_sets(ctx->out, "STATUS", rec.status);
tx_buf_sets(ctx->out, "RESULT", "ALREADY");
tx_buf_sets(ctx->out, "ERRCODE", "VL3002");
tx_return(ctx, TX_OK, ctx->out);
return;
}
if (tx_begin() != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0030] 트랜잭션 시작 실패");
tx_buf_sets(ctx->out, "ERRCODE", "VL3003");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
rc = vl_rec_update_status(key, VL_ST_DONE);
if (rc != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0030] 상태전이(M) 실패 key=%s rc=%d(%s)",
key, rc, tx_strerror(rc));
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "VL3004");
tx_return(ctx, rc, ctx->out);
return;
}
strncpy(h_key, key, sizeof(h_key) - 1);
h_key[sizeof(h_key) - 1] = '\0';
strncpy(h_approver, approver, sizeof(h_approver) - 1);
h_approver[sizeof(h_approver) - 1] = '\0';
EXEC SQL
INSERT INTO vl_approval_hist
(txn_key, approver_id, appr_dt, prev_status)
VALUES (:h_key, :h_approver,
TO_CHAR(SYSTIMESTAMP, 'YYYYMMDDHH24MISS'), 'R');
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("INSERT vl_approval_hist");
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "VL3009");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
if (tx_commit() != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0030] 커밋 실패 key=%s", key);
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "VL3005");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "KEY", key);
tx_buf_sets(ctx->out, "APPROVER", approver);
tx_buf_sets(ctx->out, "STATUS", VL_ST_DONE);
tx_buf_sets(ctx->out, "RESULT", "APPROVED");
tx_buf_sets(ctx->out, "ERRCODE", RESP_OK);
tx_log(TX_LOG_INFO, "[VL_OL_0030] 승인처리 완료 key=%s approver=%s",
key, approver);
tx_return(ctx, TX_OK, ctx->out);
}