package org.springblade.mdm.flow.excution.dispatch;
|
|
import lombok.extern.slf4j.Slf4j;
|
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.delegate.DelegateExecution;
|
import org.springblade.core.log.exception.ServiceException;
|
import org.springblade.core.tool.utils.DateUtil;
|
import org.springblade.mdm.flow.service.FlowCommonService;
|
import org.springblade.mdm.flow.service.FlowProgramProperties;
|
import org.springblade.mdm.program.service.NcNodeHisService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
|
/**
|
* 派工审批通过执行的事件,功能:插入审批表数据
|
*/
|
@Slf4j
|
@Component("dispatchFinishListener")
|
public class DispatchFinishListener {
|
@Autowired
|
private RuntimeService runtimeService;
|
@Autowired
|
private NcNodeHisService nodeHisService;
|
@Autowired
|
private FlowCommonService flowCommonService;
|
|
@Autowired
|
private DataHandlerHelper dataHandlerHelper;
|
/**
|
* 在流程结束时自动调用,(配置在审批结束事件的executelistener中了)
|
* @param execution 执行对象
|
*/
|
public void handle(DelegateExecution execution) {
|
// 执行业务逻辑
|
Date time = DateUtil.now();
|
|
String instId = execution.getProcessInstanceId();
|
log.info("事件名称{},instid={}" , execution.getEventName(),instId);
|
|
FlowProgramProperties props = flowCommonService.getProgramProperties(instId);
|
FinishDataHandler dataHandler = dataHandlerHelper.getDataHandler(props);
|
try {
|
dataHandler.handleData(props);
|
}catch(Exception e) {
|
log.error("处理错误",e);
|
throw new ServiceException("派工完成处理异常"+e.getMessage());
|
}
|
nodeHisService.mergeNodeToHisGeTime(time);
|
log.info("流程已完成in DispatchFinishListener");
|
}
|
|
}
|