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

import com.zfire.jiasm.syncdata.constant.TaskConfigEnum;
import com.zfire.jiasm.syncdata.service.UploadWorkeCertificateService;
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.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 同步师傅保险证件到格力总部 为师傅入驻总部网点或证件更新做准备   更新到格力总部时由 UploadWorkerTOGree 完成
 * WebsitWorker.getInsureStatus=2 && isNotNull(WebsitWorker.getInsureFiles)
 * 网点证件表保存一份供同步师傅信息使用
 *
 */
@Slf4j
@Component
public class UploadWorkBx {
    @Value("${workercertbxc}")
    private String workercertbxc = "";

    @Autowired
    UploadWorkeCertificateService uploadWorkeCertificateService;


    /** 这里只上传保险证件到总部，为师傅入驻新网点或证件更新做准备
     * 按师傅所在格力总部网点更新保险证件数据
     * 1：上传到格力总部网点
     * 2：本地保留一份
     *
     */
    @Scheduled(fixedDelayString = "${workercertbx}")
    public void processUploadTask() throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (workercertbxc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        log.info("开始同步师傅保险证件信息: \uF0B7{}",sdf.format(new Date()));

        // uploadWorkeCertificateService.procesInitWorkeBx();

        uploadWorkeCertificateService.procesUploadWorkeBx();

        log.info("同步师傅保险证件信息结束: \uF0B7{}",sdf.format(new Date()));
    }

}
