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

import com.zfire.jiasm.syncdata.constant.TaskConfigEnum;
import com.zfire.jiasm.syncdata.gree.recycle.RecycleAcquisitionLogic;
import com.zfire.jiasm.syncdata.gree.recycle.RecycleAssignLogic;
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;

/**
 * 回收工单 状态同步
 */
@Slf4j
@Component
public class RecycleUpload {
    @Value("${hsgdzttmc}")
    private String hsgdzttmc = "";
    @Value("${hsgdcjtmc}")
    private String hsgdcjtmc = "";


    @Autowired
    RecycleAssignLogic recycleAssignLogic;
    @Autowired
    RecycleAcquisitionLogic recycleAcquisitionLogic;

    /**
     * 与总部进行状态同步 按照待同步的反馈明细表数据进行同步
     * 平台对数据变更时同步回总部 这里为反馈明细数据同步、工单的状态、改派网点信息的同步
     * 1:需要有对应的反馈明细数据，无则不同步
     */
    @Scheduled(fixedDelayString = "${hsgdzttm}")
    private void statusBatchUpload() {
        if (hsgdzttmc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        recycleAssignLogic.statusUpload();
    }

    /**
     * 同步采集数据到总部任务
     * @throws Exception
     */
    @Scheduled(fixedDelayString = "${hsgdcjtm}")
    private void acquisitionUpload() {
        if (hsgdcjtmc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        recycleAcquisitionLogic.acquisitionUpload();
    }


}
