package com.leanwo.activiti.listener.base;

import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.leanwo.activiti.dto.base.WorkrecordDto;
import com.leanwo.activiti.service.base.impl.ProdogServer;
import com.leanwo.activiti.util.SpringUtil;

/**
 * 任务完成监听器：当审批任务完成时自动更新钉钉的待办任务
 * @author shenchong 2020-09-07 20:10:07
 *
 */
public class DingDingUserTaskCompleteListener implements TaskListener {
	
	private static Logger logger = LoggerFactory.getLogger(DingDingUserTaskCompleteListener.class);
	
	@Override
	public void notify(DelegateTask delegateTask) {
		ProdogServer prodogServer = SpringUtil.getBean(ProdogServer.class.getName());
		
		String taskId = delegateTask.getId();
		String userId = delegateTask.getAssignee();
		
		WorkrecordDto workRecordDto= new WorkrecordDto();
		workRecordDto.setUserId(userId);
		workRecordDto.setTaskId(taskId);
		prodogServer.updateWorkrecord(workRecordDto);
	}
}
