package com.engine.salary.timer;

import com.engine.common.util.ServiceUtil;
import com.engine.salary.wrapper.TaxAgentWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StopWatch;
import weaver.hrm.User;
import weaver.interfaces.schedule.BaseCronJob;

/**
 * 自动同步人员
 * <p>Copyright: Copyright (c) 2022</p>
 * <p>Company: 泛微软件</p>
 *
 * @author qiantao
 * @version 1.0
 **/
@Slf4j
public class SyncTaxAgentEmpJob extends BaseCronJob {

    private TaxAgentWrapper getTaxAgentWrapper(User user) {
        return ServiceUtil.getService(TaxAgentWrapper.class, user);
    }

    @Override
    public void execute() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start("计划任务【SyncTaxAgentEmpJob】");
        start();
        stopWatch.stop();
        log.info(stopWatch.prettyPrint());
    }


    /**
     * 代码执行逻辑方法
     */
    private void start() {
        try {
            getTaxAgentWrapper(null).syncAllRange();
        } catch (Exception e) {
            log.error("计划任务【SyncTaxAgentEmpJob】执行异常：" + e);
        }
    }
}
