package cn.iocoder.yudao.module.system.job;

import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
import cn.iocoder.yudao.module.bpm.api.task.BpmProcessInstanceApi;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class BpmProcessInstanceCompleteJob implements JobHandler {

    private final static Logger logger = LoggerFactory.getLogger(BpmProcessInstanceCompleteJob.class);

    @Resource
    private BpmProcessInstanceApi processInstanceApi;

    @Override
    @TenantJob
    public String execute(String param) {
        Long tenantId = TenantContextHolder.getTenantId();
        logger.info("=====租户{}执行审批每日校验生效日期=====", tenantId);
        Boolean b = processInstanceApi.processInstanceComplete();
        logger.info("租户{}审批每日校验生效日期情况{}", TenantContextHolder.getTenantId(), b);
        return String.format("租户{}审批每日校验生效日期情况{}", TenantContextHolder.getTenantId(), b);
    }

}
