|
@@ -3,18 +3,34 @@ package com.minto.app.task.util;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.minto.app.behavior.beans.BehSummaryBean;
|
|
|
import com.minto.app.behavior.enums.BehaviorEnum;
|
|
|
import com.minto.app.behavior.manager.IBehManager;
|
|
|
+import com.minto.app.collaboration.bo.ColAffairBO;
|
|
|
+import com.minto.app.message.beans.MessageBean;
|
|
|
+import com.minto.app.message.enums.MessageEnum;
|
|
|
+import com.minto.app.message.manager.MessageService;
|
|
|
+import com.minto.app.organization.OrgEnum;
|
|
|
+import com.minto.app.organization.beans.OrgPersonBean;
|
|
|
+import com.minto.app.organization.beans.OrgRelationBean;
|
|
|
import com.minto.app.organization.manager.IOrgManager;
|
|
|
import com.minto.app.resource.enums.ResourceEnum;
|
|
|
import com.minto.app.task.beans.TaskMemberBean;
|
|
|
import com.minto.app.task.enums.TaskEnum;
|
|
|
import com.minto.app.task.manager.ITaskManager;
|
|
|
+import com.minto.app.workflow.beans.NodeBO;
|
|
|
+import com.minto.app.workflow.enums.WorkflowEnum;
|
|
|
+import com.minto.app.workflow.manager.IWorkflowManager;
|
|
|
import com.minto.core.common.AppContext;
|
|
|
-import com.minto.core.util.CollectionUtil;
|
|
|
+import com.minto.core.util.*;
|
|
|
import com.minto.tip.common.exceptions.BusinessException;
|
|
|
import com.minto.tip.common.util.ApplicationContextHolder;
|
|
|
+import com.minto.tip.organization.enums.RelationValueName;
|
|
|
+import org.apache.commons.lang.ObjectUtils;
|
|
|
+import org.jbpm.JbpmContext;
|
|
|
+import org.jbpm.taskmgmt.exe.TaskInstance;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
/**
|
|
|
* 应用模块名称<p>
|
|
@@ -129,4 +145,108 @@ public final class TaskKaizhouUtil{
|
|
|
}
|
|
|
return isManager;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前人员的秘书
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Long getClerkOfLindao() {
|
|
|
+ if(isShujiQuZhangQuLingDao()) {
|
|
|
+ Long lingdaoId = AppContext.getCurrentUser().getId();
|
|
|
+ Integer person = ResourceEnum.ResourceTypeEnum.OrgPerson.getKey();
|
|
|
+ Integer category = OrgEnum.OrgRelationCategoryEnum.Secretary.getKey();
|
|
|
+ IOrgManager orgManager = ApplicationContextHolder.getBean(IOrgManager.class);
|
|
|
+ List<OrgRelationBean> relationBeans = orgManager.findOrgRelation(person, lingdaoId, person, (Long)null, category, (EnumMap<RelationValueName, Object>)null, (Long)null);
|
|
|
+ return CollectionUtil.isNotEmpty(relationBeans)?relationBeans.get(0).getId():null;
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送消息给秘书
|
|
|
+ * @param taskId 任务ID
|
|
|
+ * @param content 消息内容
|
|
|
+ */
|
|
|
+ public static void sendMessageToClerk(String taskId,String content) {
|
|
|
+ try{
|
|
|
+ MessageService msgManager = AppContext.getBean(MessageService.class);
|
|
|
+ IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
|
|
|
+ Long clerkId = getClerkOfLindao();
|
|
|
+ Long currentPid = AppContext.getCurrentUser().getId();
|
|
|
+ if(clerkId != null) {
|
|
|
+ MessageBean messageBean = new MessageBean();
|
|
|
+ messageBean.setSenderId(currentPid);
|
|
|
+ messageBean.setSendTime(new Date());
|
|
|
+ messageBean.setId(UUIDUtil.UUIDAbsLong());
|
|
|
+ messageBean.setMessageType(MessageEnum.MessageTypeEnum.System.getKey());
|
|
|
+ messageBean.setReceiverId(clerkId);
|
|
|
+ messageBean.setMessage(content);
|
|
|
+ messageBean.setResourceId(taskId);
|
|
|
+ messageBean.setResourceType(ResourceEnum.ResourceTypeEnum.Task.getKey());
|
|
|
+ messageBean.setOrgCorporationId(AppContext.currentLoginCorporation());
|
|
|
+ msgManager.sendMessage(messageBean);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ LoggerFactory.getLogger(TaskKaizhouUtil.class).error("领导秘书消息发送失败",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void addClerkNodeOfPishi(ColAffairBO affairBO) {
|
|
|
+ try{
|
|
|
+ IWorkflowManager workflowManager = AppContext.getBean(IWorkflowManager.class);
|
|
|
+ Long clerkId = getClerkOfLindao();
|
|
|
+ Long lingdaoId = AppContext.getCurrentUser().getId();
|
|
|
+ if(clerkId != null) {
|
|
|
+ WorkflowEnum.WorkflowTypeEnum tcType = WorkflowEnum.WorkflowTypeEnum.task;
|
|
|
+ // TODO tcId是什么怎么获取
|
|
|
+ NodeBO nodeBO = convertReqNodes(affairBO, clerkId);
|
|
|
+ workflowManager.addNode(AppContext.currentLoginCorporation(), null, tcType, Lists.newArrayList(nodeBO), lingdaoId);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ LoggerFactory.getLogger(TaskKaizhouUtil.class).error("添加领导秘书节点失败",e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private static NodeBO convertReqNodes(ColAffairBO affairBO, Long clerkId) {
|
|
|
+ /**
|
|
|
+ * 加签时的JSON数据,用作参考
|
|
|
+ * [{"nodeTitle":"书记工作人员","nodeType":"task-node","description":"node4",
|
|
|
+ * "nodeId":"node4","next":"end-state","actorType":"","actorId":"10000003_177185277732605312",
|
|
|
+ * "nodeActionName":"协同","baseInfo":["","","10000003_177185277732605312","10001","","",
|
|
|
+ * "测试加签","2700748035842131130","","",0,"-1",""]}]
|
|
|
+ */
|
|
|
+ IOrgManager orgManager = AppContext.getBean(IOrgManager.class);
|
|
|
+ IWorkflowManager workflowManager = AppContext.getBean(IWorkflowManager.class);
|
|
|
+ OrgPersonBean clerk = orgManager.findPersonById(clerkId);
|
|
|
+ NodeBO nodeBO = new NodeBO();
|
|
|
+ nodeBO.setNodeId(String.valueOf(UUIDUtil.UUIDAbsLong()));
|
|
|
+ String actorId = ResourceEnum.ResourceTypeEnum.OrgPerson+"_"+clerkId;
|
|
|
+ String nodeTitle = "领导批示交办秘书";
|
|
|
+ String next = "end-state";
|
|
|
+ Long tcId = affairBO.getAffairBean().getNodeId();
|
|
|
+ if(true) {
|
|
|
+ List<NodeBO> nodeBOS = workflowManager.getNodesByTC(tcId, WorkflowEnum.WorkflowTypeEnum.col);
|
|
|
+ for(NodeBO n:nodeBOS) {
|
|
|
+ if(n.getNodeId().equals(String.valueOf(tcId))) {
|
|
|
+ next = n.getNext();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ nodeBO.setActorId(actorId);
|
|
|
+ nodeBO.setActorName(clerk.getName());
|
|
|
+ nodeBO.setActorType("");
|
|
|
+ nodeBO.setNodeState("");
|
|
|
+ nodeBO.setNodeType("task-node");
|
|
|
+ nodeBO.setNodeTitle(nodeTitle);
|
|
|
+ nodeBO.setNodeActionName("协同");
|
|
|
+ nodeBO.setDescription("");
|
|
|
+ nodeBO.setAttrMap(null);
|
|
|
+ nodeBO.setBaseInfo(new String[]{"","",actorId,"10001","","", nodeTitle , String.valueOf(tcId),"","", "0","-1",""});
|
|
|
+ nodeBO.setNext(next);
|
|
|
+
|
|
|
+ return nodeBO;
|
|
|
+ }
|
|
|
}
|