chore: acquire-core migration monorepo (legacy C + Spring Boot target skeleton)
Some checks failed
ci / build (push) Failing after 2s
Some checks failed
ci / build (push) Failing after 2s
TxCore/ECPG legacy 매입·정산 C 슬라이스(빌드검증) + Spring Boot 멀티모듈 골격(mvn test green) + MIGRATION.md 전환룰 + CI(boot 빌드).
This commit is contained in:
commit
ff0b0b60a2
31 changed files with 2208 additions and 0 deletions
147
legacy/app/batch/rc_match_batch.pgc
Normal file
147
legacy/app/batch/rc_match_batch.pgc
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* rc_match_batch.pgc - 승인-매입 대사(對査) 배치 (RC_MATCH)
|
||||
*
|
||||
* 지정 영업일의 접수(status='R') 매입 건을 커서로 순회하며 승인원장과
|
||||
* 대사한다. 금액이 일치하면 대사완료('M'), 아니면 불일치('U') 로 갱신하고,
|
||||
* 처리 요약을 출력한다. 배치 main 엔트리를 포함한다.
|
||||
*
|
||||
* 실행: rc_match_batch <YYYYMMDD> [db@host]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "purchase_dbio.h"
|
||||
|
||||
EXEC SQL INCLUDE sqlca;
|
||||
|
||||
static int run_match(const char *biz_date)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_biz_date[9];
|
||||
char h_appr_no[10];
|
||||
char h_merch_id[16];
|
||||
long h_amount;
|
||||
char h_new_status[2];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
long total = 0, matched = 0, unmatched = 0, errcnt = 0;
|
||||
int rc;
|
||||
|
||||
strncpy(h_biz_date, biz_date, sizeof(h_biz_date) - 1);
|
||||
h_biz_date[sizeof(h_biz_date) - 1] = '\0';
|
||||
|
||||
/* 접수상태 매입 건에 대한 커서 선언 */
|
||||
EXEC SQL DECLARE cur_purchase CURSOR FOR
|
||||
SELECT appr_no, merch_id, amount
|
||||
FROM purchase
|
||||
WHERE txn_date = :h_biz_date
|
||||
AND status = 'R'
|
||||
ORDER BY appr_no;
|
||||
|
||||
EXEC SQL OPEN cur_purchase;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("OPEN cur_purchase");
|
||||
return TX_EDB;
|
||||
}
|
||||
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[RC_MATCH] tx_begin 경고");
|
||||
|
||||
for (;;) {
|
||||
EXEC SQL FETCH cur_purchase
|
||||
INTO :h_appr_no, :h_merch_id, :h_amount;
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_NOTFOUND) /* 100 = 커서 소진 */
|
||||
break;
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("FETCH cur_purchase");
|
||||
errcnt++;
|
||||
break;
|
||||
}
|
||||
|
||||
total++;
|
||||
|
||||
/* 업무규칙: 승인원장에서 승인번호+금액 일치 확인 */
|
||||
rc = approval_match(h_appr_no, h_amount);
|
||||
if (rc == TX_OK) {
|
||||
strncpy(h_new_status, PUR_ST_MATCHED, sizeof(h_new_status));
|
||||
matched++;
|
||||
} else if (rc == TX_ENOENT) {
|
||||
strncpy(h_new_status, PUR_ST_UNMATCH, sizeof(h_new_status));
|
||||
unmatched++;
|
||||
} else {
|
||||
tx_log(TX_LOG_ERROR, "[RC_MATCH] 승인대사 오류 appr=%s rc=%d",
|
||||
h_appr_no, rc);
|
||||
errcnt++;
|
||||
continue;
|
||||
}
|
||||
|
||||
rc = purchase_update_status(h_appr_no, h_new_status);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[RC_MATCH] 상태갱신 실패 appr=%s rc=%d",
|
||||
h_appr_no, rc);
|
||||
errcnt++;
|
||||
}
|
||||
}
|
||||
|
||||
EXEC SQL CLOSE cur_purchase;
|
||||
|
||||
if (errcnt == 0)
|
||||
tx_commit();
|
||||
else
|
||||
tx_abort();
|
||||
|
||||
tx_log(TX_LOG_INFO,
|
||||
"[RC_MATCH] 요약 date=%s 대상=%ld 대사완료=%ld 불일치=%ld 오류=%ld",
|
||||
biz_date, total, matched, unmatched, errcnt);
|
||||
|
||||
printf("========== 승인-매입 대사 배치 결과 ==========\n");
|
||||
printf(" 영업일 : %s\n", biz_date);
|
||||
printf(" 대상 건수 : %ld\n", total);
|
||||
printf(" 대사완료(M) : %ld\n", matched);
|
||||
printf(" 대사불일치(U) : %ld\n", unmatched);
|
||||
printf(" 오류 건수 : %ld\n", errcnt);
|
||||
printf("=============================================\n");
|
||||
|
||||
return (errcnt == 0) ? TX_OK : TX_FAIL;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *biz_date;
|
||||
const char *target;
|
||||
int rc;
|
||||
|
||||
tx_set_loglevel(TX_LOG_INFO);
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "사용법: %s <YYYYMMDD> [db@host]\n", argv[0]);
|
||||
return 2;
|
||||
}
|
||||
biz_date = argv[1];
|
||||
target = (argc >= 3) ? argv[2] : NULL;
|
||||
|
||||
if (!date_is_valid(biz_date)) {
|
||||
fprintf(stderr, "오류: 유효하지 않은 영업일 '%s'\n", biz_date);
|
||||
return 2;
|
||||
}
|
||||
|
||||
tx_log(TX_LOG_INFO, "[RC_MATCH] 배치 시작 date=%s", biz_date);
|
||||
|
||||
rc = dbio_connect(target);
|
||||
if (rc != TX_OK) {
|
||||
tx_log(TX_LOG_ERROR, "[RC_MATCH] DB 접속 실패 rc=%d", rc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rc = run_match(biz_date);
|
||||
|
||||
dbio_disconnect();
|
||||
|
||||
tx_log(TX_LOG_INFO, "[RC_MATCH] 배치 종료 rc=%d(%s)", rc, tx_strerror(rc));
|
||||
return (rc == TX_OK) ? 0 : 1;
|
||||
}
|
||||
Reference in a new issue