Files
wace_rps/frontend/lib/api/erpSync.ts
T
chpark 97b333dd2e Amaranth(Wehago) ERP REST API 연계 + 배치 시스템 강화
부팅 시 자동 시드:
- 외부 REST API 연결 6종 (부서/사원/거래처/창고/계정과목/Wehago 사용자)
- 매칭 배치 6개 + Wehago HMAC-SHA256 서명 자동 부착 (erpApiClient/erpPresetSeedService/erpBatchSeedService)
- 동기화 대상 테이블/컬럼 보장 idempotent 마이그레이션 (erpTableMigration)

배치 기능 확장:
- 조건부 매핑 (mapping_type='conditional') — when/then/default 규칙으로 값 변환 (예: enrlFg=J01→active)
- 행 단위 제외 필터 (row_filter_config) — 특정 API 필드 값 가진 행 동기화 제외 (예: loginId=wace 통합 ERP 계정 제외)
- save_mode/conflict_key 기반 UPSERT, data_array_path 응답 배열 추출

UI 정비:
- 배치/플로우/메일/REST API 목록에 페이징 + FullHD 컴팩트 레이아웃
- 배치 편집 화면 한 화면 풀 활용 — TO 패널 가로 그리드, FROM 패널 등록 연결 한 줄 요약, 응답/JSON/파라미터 details 접힘
- ResponsiveDataView/AdminPageRenderer 쿼리 파라미터(?edit=N) 파싱

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 09:48:28 +09:00

69 lines
1.5 KiB
TypeScript

// ERP 마스터 동기화 API 클라이언트
// 자동화 관리 > 배치 관리 화면의 "ERP 동기화" 탭에서 호출
import { apiClient } from "./client";
export interface ErpSyncResult {
resource: string;
fetched: number;
inserted: number;
updated: number;
skipped: number;
errors: string[];
durationMs: number;
}
export type ErpSyncResource =
| "employees"
| "departments"
| "warehouses"
| "customers"
| "account-codes"
| "all";
interface ErpSyncRequest {
coCd: string;
companyCode?: string;
searchText?: string;
baselocFg?: string;
}
interface SingleResponse {
success: boolean;
data?: ErpSyncResult;
message?: string;
}
interface AllResponse {
success: boolean;
totals?: {
fetched: number;
inserted: number;
updated: number;
skipped: number;
errorsCount: number;
};
data?: ErpSyncResult[];
message?: string;
}
const BASE = "/erp-sync";
export const ErpSyncAPI = {
async syncOne(resource: Exclude<ErpSyncResource, "all">, body: ErpSyncRequest): Promise<ErpSyncResult> {
const res = await apiClient.post<SingleResponse>(`${BASE}/${resource}`, body);
if (!res.data.success) {
throw new Error(res.data.message || `${resource} 동기화 실패`);
}
return res.data.data!;
},
async syncAll(body: ErpSyncRequest): Promise<{ totals: AllResponse["totals"]; results: ErpSyncResult[] }> {
const res = await apiClient.post<AllResponse>(`${BASE}/all`, body);
return {
totals: res.data.totals,
results: res.data.data || [],
};
},
};