/**
 * Project Name : 전사 법무/계약관리시스템 개선
 * File Name    : GaisJobExecutor.java
 * Description  : 
 * Author       : basslee
 * Date         : 2023.02.23
 * Copyright 	: 2023 by SAMSUNG. All rights reserved.
 */
package com.samsung.embo.cronJob.executor;



import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import com.samsung.embo.cronJob.control.service.GHRPJobService;

import lombok.extern.log4j.Log4j2;

@Component
@Log4j2
public class GhrpJobExecutor extends QuartzJobBean {

    @Value("node-id")
    private String nodeId;
    
    @Autowired
    private GHRPJobService legacyGHRPJob;
    
    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
      
        
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        String jobName = jobDetail.getKey().getName();
        log.info(new StringBuilder()
                .append("nodeId : ").append(nodeId).append(", ")
                .append("jobName : ").append(jobDetail.getKey().getName()).append(", ")
                .append("description : ").append(jobDetail.getDescription())
        );
        
        switch (jobName) {
	        case "recvDeptInfo":
	        	// 부서정보 수신
				try {
					legacyGHRPJob.recvDeptInfo();
				} catch (Exception e) {
					log.error(e.getMessage());
				}
	            break;
	        case "recvUserInfo":
	        	// 임직원정보 수신
				try {
					legacyGHRPJob.recvUserInfo();
				} catch (Exception e) {
					log.error(e.getMessage());
				}
	            break;	            
	    }
    }
    
	
}
