package com.zfire.jiasm.syncdata.upload.worker;

import com.zfire.jiasm.syncdata.constant.TaskConfigEnum;
import com.zfire.jiasm.syncdata.service.UploadWorkerTOGreeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 同步师傅信息到格力总部
 */
@Slf4j
@Component
public class UploadWorkerTOGree {
    @Value("${workerceruploadc}")
    private String workerceruploadc = "";

    @Autowired
    UploadWorkerTOGreeService uploadWorkerTOGreeService;



    /** 同步师傅信息到格力总部
     * 无论新增或是修改-所有证件都必须重新上传一次
     * 师傅所在网点都要上传一次
     * @throws Exception
     */
    @Scheduled(fixedDelayString = "${workercerupload}")
    public void uploadWorkProcess() throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (workerceruploadc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        log.info("开始同步师傅信息到格力总部: \uF0B7{}",sdf.format(new Date()));

        uploadWorkerTOGreeService.procesUploadWorker();

        log.info("同步师傅信息到格力总部完成: \uF0B7{}",sdf.format(new Date()));
        return;
    }

}
