加入公共录入表单(作为所有流程第一个用户任务)处理
This commit is contained in:
parent
34fd01f208
commit
396a7b5c6b
|
@ -0,0 +1,67 @@
|
|||
package io.renren.common.listener;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import io.renren.common.dto.AuditingBaseDTO;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.delegate.DelegateTask;
|
||||
import org.activiti.engine.delegate.TaskListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 流程发起人录入表单
|
||||
*/
|
||||
@Component
|
||||
public class InitiatorDataEntryListener implements TaskListener {
|
||||
private static Logger logger = LoggerFactory.getLogger(InitiatorDataEntryListener.class);
|
||||
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@Override
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
logger.error("----------------------流程发起人录入表单节点---------------------------");
|
||||
logger.error("事件类型:" + delegateTask.getEventName());
|
||||
final String eventName = delegateTask.getEventName();
|
||||
switch (eventName) {
|
||||
case EVENTNAME_CREATE:
|
||||
create(delegateTask);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void create(DelegateTask delegateTask) {
|
||||
Map<String, Object> kv = delegateTask.getVariables();
|
||||
logger.error("录入表单:" + kv.toString());
|
||||
if (kv.containsKey("creator")) { // 表单存在创建者
|
||||
taskService.setAssignee(delegateTask.getId(), kv.get("creator").toString());
|
||||
}
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
|
||||
|
||||
Gson gson = builder.create();
|
||||
JsonElement jsonElement = gson.toJsonTree(kv);
|
||||
AuditingBaseDTO auditingBaseDTO = gson.fromJson(jsonElement, AuditingBaseDTO.class);
|
||||
if (auditingBaseDTO.getBackToFirst() != null && auditingBaseDTO.getBackToFirst()) {
|
||||
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "被驳回需修改后重新提交");
|
||||
logger.error("被驳回,需修改后重新提交");
|
||||
} else {
|
||||
if (auditingBaseDTO.getCompleteEntry()) {
|
||||
taskService.addComment(delegateTask.getId(), delegateTask.getProcessInstanceId(), "完成申请提交");
|
||||
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
|
||||
logger.error("首次录入,自动审核通过!");
|
||||
}
|
||||
}
|
||||
logger.error("----------完成录入表单-----------");
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue