package com.ruoyi.project.listener.semsWeekCheck;

import com.alibaba.fastjson.JSON;
import com.ruoyi.common.utils.SpringContextUtils;
import com.ruoyi.project.invoice.service.ITInvoiceBookingworkticketService;
import com.ruoyi.project.sems.safecheck.domain.TSpecWeekcheck;
import com.ruoyi.project.sems.safecheck.service.ITSpecWeekcheckService;
import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.ExecutionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Date;
import java.util.Map;

@Service("weekcheckEndSuccessListener")
public class WeekcheckEndSuccessListener implements Serializable, ExecutionListener {
    protected Logger logger = LoggerFactory.getLogger(getClass());

    private static final long serialVersionUID = -3759054058055401826L;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        String id = delegateExecution.getProcessInstanceBusinessKey();

        Map variableInstances = delegateExecution.getVariableInstances();
        logger.debug("参数--------------------------------" + JSON.toJSONString(variableInstances));
        logger.debug("审批id--------------------------------" + id);
        ITSpecWeekcheckService itSpecWeekcheckService = (ITSpecWeekcheckService) SpringContextUtils.getBean("tSpecWeekcheckServiceImpl");
        TSpecWeekcheck t = itSpecWeekcheckService.selectTSpecWeekcheckById(Long.parseLong(id));
        t.setStatus(1);
        itSpecWeekcheckService.updateTSpecWeekcheck(t);

    }
}
