ERP 사원 동기화 시 이메일/전화번호 누락 수정
- EmployeeApiClient: API 요청에 extraColumns 추가 (emalAdd, outemalAdd, emgcTel, tel, joinDt) - BatchService: 급여이메일(emalAdd) 우선, 없으면 외부이메일(outemalAdd) fallback 처리, tel 매핑 추가 - batch.xml: upsertEmployee에 user_id, tel 컬럼 추가, ON CONFLICT (sabun) 기준 upsert Made-with: Cursor
This commit is contained in:
@@ -206,9 +206,10 @@ public class EmployeeApiClient {
|
||||
json.append(",\"pId\":\"\"");
|
||||
json.append("}");
|
||||
|
||||
// body 섹션
|
||||
// body 섹션 - extraColumns로 이메일/전화번호 등 추가 필드 요청
|
||||
json.append(",\"body\":{");
|
||||
json.append("\"coCd\":\"").append(escapeJson(coCd)).append("\"");
|
||||
json.append(",\"extraColumns\":[\"emalAdd\",\"outemalAdd\",\"emgcTel\",\"tel\",\"joinDt\"]");
|
||||
json.append("}");
|
||||
|
||||
json.append("}");
|
||||
|
||||
@@ -114,9 +114,10 @@
|
||||
data_type = #{data_type}
|
||||
</insert>
|
||||
|
||||
<!-- 사원 정보 UPSERT (실제 JSON 응답 기준) -->
|
||||
<!-- 사원 정보 UPSERT (sabun unique 인덱스 기준) -->
|
||||
<insert id="upsertEmployee" parameterType="map">
|
||||
INSERT INTO user_info (
|
||||
user_id,
|
||||
sabun,
|
||||
empseq,
|
||||
user_password,
|
||||
@@ -128,6 +129,7 @@
|
||||
position_name,
|
||||
rank,
|
||||
email,
|
||||
tel,
|
||||
cell_phone,
|
||||
user_type,
|
||||
user_type_name,
|
||||
@@ -136,6 +138,7 @@
|
||||
data_type,
|
||||
regdate
|
||||
) VALUES (
|
||||
#{sabun},
|
||||
#{sabun},
|
||||
#{empseq},
|
||||
#{user_password},
|
||||
@@ -147,11 +150,12 @@
|
||||
#{position_name},
|
||||
#{rank},
|
||||
#{email},
|
||||
#{tel},
|
||||
#{cell_phone},
|
||||
#{user_type},
|
||||
#{user_type_name},
|
||||
#{status},
|
||||
CASE
|
||||
CASE
|
||||
WHEN #{end_date} IS NULL OR #{end_date} = '' THEN NULL
|
||||
ELSE TO_TIMESTAMP(#{end_date}, 'YYYYMMDD')
|
||||
END,
|
||||
@@ -168,11 +172,12 @@
|
||||
position_name = #{position_name},
|
||||
rank = #{rank},
|
||||
email = #{email},
|
||||
tel = #{tel},
|
||||
cell_phone = #{cell_phone},
|
||||
user_type = #{user_type},
|
||||
user_type_name = #{user_type_name},
|
||||
status = #{status},
|
||||
end_date = CASE
|
||||
end_date = CASE
|
||||
WHEN #{end_date} IS NULL OR #{end_date} = '' THEN NULL
|
||||
ELSE TO_TIMESTAMP(#{end_date}, 'YYYYMMDD')
|
||||
END,
|
||||
|
||||
@@ -776,21 +776,17 @@ public class BatchService extends BaseService {
|
||||
System.out.println("====================================");
|
||||
|
||||
for (Map<String, Object> emp : empList) {
|
||||
// 처음 10건만 로그 출력
|
||||
if (processCount < 10) {
|
||||
System.out.println("[사원 " + (processCount + 1) + "]");
|
||||
System.out.println(" - USER_ID: " + emp.get("user_id"));
|
||||
System.out.println(" - SABUN: " + emp.get("sabun"));
|
||||
System.out.println(" - USER_NAME: " + emp.get("user_name"));
|
||||
System.out.println(" - USER_NAME_ENG: " + emp.get("user_name_eng"));
|
||||
System.out.println(" - DEPT_CODE: " + emp.get("dept_code"));
|
||||
System.out.println(" - DEPT_NAME: " + emp.get("dept_name"));
|
||||
System.out.println(" - EMAIL: " + emp.get("email"));
|
||||
System.out.println(" - CELL_PHONE: " + emp.get("cell_phone"));
|
||||
System.out.println(" - STATUS: " + emp.get("status"));
|
||||
System.out.println(" - TEL: " + emp.get("tel"));
|
||||
System.out.println("---");
|
||||
}
|
||||
|
||||
// UPSERT 실행
|
||||
|
||||
sqlSession.insert("batch.upsertEmployee", emp);
|
||||
processCount++;
|
||||
}
|
||||
@@ -1314,7 +1310,13 @@ public class BatchService extends BaseService {
|
||||
emp.put("position_code", extractJsonValue(json, "hclsCd")); // 직급코드 (hclsCd)
|
||||
emp.put("position_name", extractJsonValue(json, "hclsNm")); // 직급명 (hclsNm)
|
||||
emp.put("rank", extractJsonValue(json, "hrspNm")); // 직책명 (hrspNm - 사원, 대리 등)
|
||||
emp.put("email", extractJsonValue(json, "emalAdd")); // 이메일 (emalAdd)
|
||||
// 이메일: 급여이메일(emalAdd) 우선, 없으면 외부이메일(outemalAdd) 사용
|
||||
String email = extractJsonValue(json, "emalAdd");
|
||||
if (email == null || email.isEmpty()) {
|
||||
email = extractJsonValue(json, "outemalAdd");
|
||||
}
|
||||
emp.put("email", email);
|
||||
emp.put("tel", extractJsonValue(json, "tel")); // 전화번호 (tel)
|
||||
emp.put("cell_phone", extractJsonValue(json, "emgcTel")); // 휴대폰 (emgcTel)
|
||||
emp.put("user_type", extractJsonValue(json, "enrlFg")); // 사용자유형 (enrlFg - J01:재직)
|
||||
emp.put("user_type_name", extractJsonValue(json, "enrlNm")); // 사용자유형명 (enrlNm)
|
||||
|
||||
Reference in New Issue
Block a user