- dbio io(289): fetch/touch/total 시그니처 유지, SQL 바디를 JOIN/집계/커서/ upsert/DELETE 등 구조로 고유화 → 289/289 고유 - common cu(120): 유틸 시그니처 유지, Luhn/CRC/Zeller/BIN레인지/amortization/ netting 등 실 알고리즘으로 고유화 → 120/120 고유 - 심화: 실제 EXEC SQL 없던 프로그램에 SELECT/INSERT/UPDATE/커서+tx 추가 → online+batch 530/530 전부 실제 SQL 보유 - 전 코퍼스 프로그램 939/939 고유, 전체 docker make -j4 = EXIT 0, 958 오브젝트 - 임시 생성기 제거, inventory.json loc 실측 갱신 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
189 lines
5.2 KiB
C
189 lines
5.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/cm_ol_0028.pgc"
|
|
/* @tier easy @module cm @transform common-online */
|
|
/*
|
|
* cm_ol_0028.pgc - 시간 포맷 변환 서비스 (CM_OL_0028) [tier=easy]
|
|
*
|
|
* 입력 시각(HHMMSS 6자리)을 HH:MM:SS 로 변환하고 각 필드의 범위를
|
|
* 검증(시 0~23, 분/초 0~59)하여 포맷 결과와 총 경과초를 응답한다.
|
|
* 아울러 시간정책 마스터(cm_time_policy)에서 마감시각(cutoff_secs)을
|
|
* 조회하여 입력 시각의 마감초과 여부(AFTERCUTOFF=Y/N)를 통지한다.
|
|
* (ATMI void SVC(TPSVCINFO*) 대응)
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "txcore_dbio.h"
|
|
#include "acq_util.h"
|
|
#include "cm_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 19 "app/online/cm_ol_0028.pgc"
|
|
|
|
|
|
TX_SERVICE(CM_OL_0028, ctx)
|
|
{
|
|
/* exec sql begin declare section */
|
|
|
|
|
|
|
|
#line 24 "app/online/cm_ol_0028.pgc"
|
|
char h_policy [ 16 ] ;
|
|
|
|
#line 25 "app/online/cm_ol_0028.pgc"
|
|
long h_cutoff ;
|
|
/* exec sql end declare section */
|
|
#line 26 "app/online/cm_ol_0028.pgc"
|
|
|
|
|
|
char hms[16];
|
|
char formatted[16];
|
|
int hh;
|
|
int mm;
|
|
int ss;
|
|
int i;
|
|
long secs;
|
|
int after_cutoff = 0;
|
|
|
|
tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간 포맷 변환 서비스 진입");
|
|
|
|
if (tx_buf_get(ctx->in, "HMS", hms, sizeof(hms)) != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[CM_OL_0028] HMS 누락");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* 정확히 6자리 숫자여야 한다 */
|
|
if (strlen(hms) != 6) {
|
|
tx_log(TX_LOG_WARN, "[CM_OL_0028] 길이 오류 hms=%s", hms);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
for (i = 0; i < 6; i++) {
|
|
if (hms[i] < '0' || hms[i] > '9') {
|
|
tx_log(TX_LOG_WARN, "[CM_OL_0028] 숫자 아님 hms=%s", hms);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
}
|
|
|
|
hh = (hms[0] - '0') * 10 + (hms[1] - '0');
|
|
mm = (hms[2] - '0') * 10 + (hms[3] - '0');
|
|
ss = (hms[4] - '0') * 10 + (hms[5] - '0');
|
|
|
|
if (hh > 23 || mm > 59 || ss > 59) {
|
|
tx_log(TX_LOG_WARN, "[CM_OL_0028] 시간 범위 오류 %02d:%02d:%02d", hh, mm, ss);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
sprintf(formatted, "%02d:%02d:%02d", hh, mm, ss);
|
|
secs = (long)hh * 3600 + (long)mm * 60 + ss;
|
|
|
|
/* 시간정책 조회 : 마감시각(초). 정책구분 미지정 시 CUTOFF 기본 */
|
|
if (tx_buf_get(ctx->in, "POLICY", h_policy, sizeof(h_policy)) != TX_OK)
|
|
strncpy(h_policy, "CUTOFF", sizeof(h_policy) - 1);
|
|
h_policy[sizeof(h_policy) - 1] = '\0';
|
|
h_cutoff = -1;
|
|
|
|
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select cutoff_secs from cm_time_policy where policy_cd = $1 and use_yn = 'Y'",
|
|
ECPGt_char,(h_policy),(long)16,(long)1,(16)*sizeof(char),
|
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
|
|
ECPGt_long,&(h_cutoff),(long)1,(long)1,sizeof(long),
|
|
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
|
#line 82 "app/online/cm_ol_0028.pgc"
|
|
|
|
|
|
if (sqlca.sqlcode == TX_SQL_NOTFOUND) {
|
|
tx_log(TX_LOG_INFO, "[CM_OL_0028] 시간정책 미등록 policy=%s", h_policy);
|
|
} else if (sqlca.sqlcode != TX_SQL_OK) {
|
|
TX_DBIO_LOG_ERR("CM_OL_0028 SELECT cm_time_policy");
|
|
} else if (h_cutoff >= 0 && secs > h_cutoff) {
|
|
after_cutoff = 1;
|
|
}
|
|
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "HMS", hms);
|
|
tx_buf_sets(ctx->out, "FORMATTED", formatted);
|
|
tx_buf_setlong(ctx->out, "SECONDS", secs);
|
|
tx_buf_setlong(ctx->out, "CUTOFF", h_cutoff);
|
|
tx_buf_sets(ctx->out, "AFTERCUTOFF", after_cutoff ? "Y" : "N");
|
|
tx_log(TX_LOG_INFO, "[CM_OL_0028] 변환완료 %s -> %s (%ld초) cutoff=%ld",
|
|
hms, formatted, secs, h_cutoff);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|