2022-10-27 00:02:05 +00:00
|
|
|
package com.dbnt.faisp.kwms.service;
|
|
|
|
|
|
|
|
|
|
import com.dbnt.faisp.kwms.model.VEmployee;
|
|
|
|
|
import com.dbnt.faisp.kwms.repository.VEmployeeRepository;
|
|
|
|
|
import com.dbnt.faisp.main.codeMgt.service.CodeMgtService;
|
|
|
|
|
import com.dbnt.faisp.main.userInfo.model.UserInfo;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
2022-10-27 06:38:53 +00:00
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
|
2022-10-27 00:02:05 +00:00
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class KwmsService {
|
|
|
|
|
private final VEmployeeRepository vEmployeeRepository;
|
|
|
|
|
private final CodeMgtService codeMgtService;
|
|
|
|
|
|
2022-10-27 06:38:53 +00:00
|
|
|
public UserInfo selectEmpInfo(String dicCode){
|
2022-10-27 00:02:05 +00:00
|
|
|
VEmployee empInfo = vEmployeeRepository.findByDicCode(dicCode).orElse(null);
|
2022-10-27 06:38:53 +00:00
|
|
|
if(empInfo==null){
|
|
|
|
|
return null;
|
|
|
|
|
}else{
|
|
|
|
|
return convertVEmployeeToUserInfo(empInfo);
|
|
|
|
|
}
|
2022-10-27 00:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private UserInfo convertVEmployeeToUserInfo(VEmployee empInfo){
|
|
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
|
|
userInfo.setDicCode(empInfo.getDicCode());
|
|
|
|
|
userInfo.setUserNm(empInfo.getEmpNm());
|
|
|
|
|
userInfo.setSex(empInfo.getSex());
|
|
|
|
|
String[] positionAry = empInfo.getCallBuseoNm().split(" ");
|
|
|
|
|
userInfo.setOgCd(codeMgtService.searchCode("OG", positionAry[0]));
|
|
|
|
|
if (positionAry.length>1){
|
|
|
|
|
userInfo.setOfcCd(codeMgtService.searchCode("OFC", positionAry[1]));
|
|
|
|
|
}
|
|
|
|
|
userInfo.setTitleCd(codeMgtService.searchCode("JT", empInfo.getJikgeup()));
|
|
|
|
|
userInfo.setOutturnCd(codeMgtService.searchCode("OTC", empInfo.getGyunggwa()));
|
|
|
|
|
userInfo.setSeriesCd(codeMgtService.searchCode("SRC", empInfo.getJikbyul()));
|
|
|
|
|
|
2022-10-27 06:38:53 +00:00
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
|
|
empInfo.setBirthDate(
|
|
|
|
|
(Integer.parseInt(empInfo.getBirthDate().substring(0,2))>60?"19":"20")+empInfo.getBirthDate());
|
|
|
|
|
userInfo.setBirthDate(LocalDate.parse(empInfo.getBirthDate(), formatter));
|
|
|
|
|
userInfo.setPoliceInDate(LocalDate.parse(empInfo.getPoliceBmngIl(), formatter));
|
|
|
|
|
userInfo.setTitleInDate(LocalDate.parse(empInfo.getHnJikgeupImyngil(), formatter));
|
2022-10-27 00:02:05 +00:00
|
|
|
return userInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|