package com.ruoyi.project.listener.semsWeekCheck;

import com.alibaba.fastjson.JSON;
import com.github.stuxuhai.jpinyin.PinyinFormat;
import com.github.stuxuhai.jpinyin.PinyinHelper;
import com.ruoyi.common.sendEmail.IMailService;
import com.ruoyi.common.utils.SpringContextUtils;
import com.ruoyi.project.sems.domain.TApprove;
import com.ruoyi.project.sems.domain.TReportYlgd;
import com.ruoyi.project.sems.domain.TReportYlrq;
import com.ruoyi.project.sems.safecheck.domain.TSpecWeekcheck;
import com.ruoyi.project.sems.safecheck.service.ITSpecWeekcheckService;
import com.ruoyi.project.sems.service.ITApproveService;
import com.ruoyi.project.sems.service.ITReportYlgdService;
import com.ruoyi.project.sems.service.ITReportYlrqService;
import com.ruoyi.project.system.service.ISysUserService;
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("weekcheckEndFailListener")
public class WeekcheckEndFailListener implements Serializable, ExecutionListener {
    protected Logger logger = LoggerFactory.getLogger(getClass());
    private static final long serialVersionUID = -375905405805540186L;

    @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(2);
        itSpecWeekcheckService.updateTSpecWeekcheck(t);
    }
}
