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.SimpleDateFormat;
import java.util.Date;

/**
 * 同步师傅人脸照到格力总部，为师傅入驻新网点或证件更新做准备
 *
 * 用于更新已入驻的网点证件照数据
 * 更新证件到格力总部(师傅已入驻 且平台网点与格力总部网点有对应关系)
 * .in(WorkerCert::getOutSyncStatus,0,99)
 * .lt(WorkerCert::getOutSyncTimes,10)
 * 网点证件表保存一份供师傅同步使用 这里不修改  WorkerCert.out_sync_status
 */
@Slf4j
@Component
public class UploadWorkeFace {
    @Value("${workerfacec}")
    private String workerfacec = "";

    @Autowired
    UploadWorkeCertificateService uploadWorkeCertificateService;


    /**
     * 师傅人脸面像同步到格力总部 为师傅入驻新网点或证件更新做准备
     * 1：上传到格力总部网点
     * 2：本地保留一份
     */
    @Scheduled(fixedDelayString = "${workerface}")
    public void processUploadTask(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        if (workerfacec.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        log.info("开始同步师傅人脸面像信息: \uF0B7{}",sdf.format(new Date()));

        uploadWorkeCertificateService.procesUploadWorkeFace();

        log.info("同步师傅人脸面像信息结束: \uF0B7{}",sdf.format(new Date()));
    }


}
