package net.northking.cctp.executePlan.quartz;

import net.northking.cctp.executePlan.api.service.AtuPlanInfoApiService;
import net.northking.cctp.executePlan.constants.PlanConstant;
import net.northking.cctp.executePlan.db.entity.AtuPlanInfo;
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanRunDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>Title: PlanTaskExecute</p>
 * <p>Description:反射调用 </p>
 *
 * @Author chenjianfeng
 * @Version V1.0
 * @Date 2022/12/29
 * <p>Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.</p>
 */

@Component("planTaskExecute")
public class PlanTaskExecute {

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

    @Autowired
    private AtuPlanInfoApiService planInfoApiService;

    public void execute(AtuPlanInfo planInfo){
        logger.info("planTaskExecute 开始执行...");
        AtuPlanRunDto runDto = new AtuPlanRunDto();
        runDto.setPlanId(planInfo.getId());
        runDto.setTriggerType(PlanConstant.TRIGGER_TYPE_AUTO);
        runDto.setExecutedBy(planInfo.getPrincipalId());
        planInfoApiService.run(runDto);
        logger.info("planTaskExecute 执行结束...");
    }
}
