...
This commit is contained in:
parent
57477cba83
commit
d2439cd096
|
@ -1,19 +1,76 @@
|
|||
package io.renren.modules.processForm.listener;
|
||||
|
||||
import org.activiti.engine.delegate.DelegateExecution;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.ExecutionListener;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
|
||||
import io.renren.modules.sys.service.SysRoleService;
|
||||
import io.renren.modules.sys.service.SysRoleUserService;
|
||||
import io.renren.modules.sys.service.SysUserService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.delegate.*;
|
||||
import org.activiti.engine.delegate.event.ActivitiEvent;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class CorrectionListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
|
||||
private static Logger logger = LoggerFactory.getLogger(CorrectionListener.class);
|
||||
|
||||
@Autowired
|
||||
private SysRoleService sysRoleService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
@Autowired
|
||||
private SysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysRoleUserService sysRoleUserService;
|
||||
|
||||
public class CorrectionListener implements TaskListener, ExecutionListener {
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
logger.info("进入DelegateTask");
|
||||
logger.info("EventName:" + delegateTask.getEventName());
|
||||
logger.info("Owner:" + delegateTask.getOwner());
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
Gson gson = new Gson();
|
||||
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
|
||||
logger.info(abilityApplicationDTO.toString());
|
||||
abilityApplicationDTO.getUnit();
|
||||
|
||||
delegateTask.setAssignee("1513432847327199233");
|
||||
System.out.println("进入DelegateTask");
|
||||
String taskKey = delegateTask.getTaskDefinitionKey();
|
||||
taskService.setAssignee(delegateTask.getId(), "1516307964617076737");
|
||||
String processDefinitionId = delegateTask.getProcessDefinitionId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notify(DelegateExecution execution) throws Exception {
|
||||
System.out.println("进入DelegateExecution");
|
||||
public void notify(DelegateExecution delegateExecution) throws Exception {
|
||||
logger.info("事件:" + delegateExecution.getEventName());
|
||||
delegateExecution.getVariableNames().stream().forEach(index -> logger.info("variable:" + index));
|
||||
delegateExecution.getVariables().values().stream().filter(index -> index != null).forEach(value -> logger.info(value.toString()));
|
||||
// taskService.setAssignee(delegateExecution.getProcessInstanceId(), "1516307964617076737");// 可以设置
|
||||
|
||||
logger.info("修改审批人成功!" + delegateExecution.getCurrentActivityId() + " " + delegateExecution.getProcessInstanceId() + " " + delegateExecution.getProcessBusinessKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(ActivitiEvent activitiEvent) { // 事件回调
|
||||
logger.info("事件类型:" + activitiEvent.getType().toString());
|
||||
logger.info("" + activitiEvent.getProcessDefinitionId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFailOnException() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(DelegateExecution delegateExecution) throws Exception {
|
||||
logger.info("异常", delegateExecution);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue