package com.zcloud.personnel.positioning.plan;

import com.jjb.saas.framework.job.Job;
import com.jjb.saas.framework.job.annotation.JobRegister;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.zcloud.personnel.positioning.command.FindsPendingSyncService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FindsPendingRetryJob implements Job {
    private final FindsPendingSyncService findsPendingSyncService;

    @Override
    @JobRegister(cron = "0 */1 * * * ?", jobDesc = "FindS待同步数据重试", author = "申智丹", triggerStatus = 1)
    @XxlJob("com.zcloud.personnel.positioning.plan.FindsPendingRetryJob")
    public ReturnT<String> execute(String param) {
        try {
            findsPendingSyncService.retryPending();
            XxlJobHelper.log("FindS待同步围栏、告警规则和终端重试完成");
            return new ReturnT<>(ReturnT.SUCCESS_CODE, "FindS pending synchronization retry completed");
        } catch (Exception e) {
            XxlJobHelper.log("FindS待同步数据重试失败: " + e.getMessage());
            return new ReturnT<>(ReturnT.FAIL_CODE, e.getMessage());
        }
    }
}
