Browse Source

modify:

1. 任务完成监听;
tags/24093001
WendyYang 3 months ago
parent
commit
c0c2d095eb
1 changed files with 45 additions and 3 deletions
  1. +45
    -3
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java

+ 45
- 3
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/UserTaskCreateOrFinishListener.java View File

@@ -24,6 +24,7 @@ import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.CollUtils;
import com.wflow.bean.entity.WflowModelHistorys;
import com.wflow.workflow.enums.ProcessHandlerEnum;
import com.wflow.workflow.notify.event.NodeCompleteEvent;
import com.wflow.workflow.notify.event.NodeCreateEvent;
import com.wflow.workflow.service.ProcessModelHistorysService;
@@ -124,12 +125,14 @@ public class UserTaskCreateOrFinishListener {
paramObj.setProjectId(purchaseInst.getProjectId());
}
String projectName = "";
String buildOrgName = "";
// 上边查不到ID的时候说明是手动新增的信创项目
if (paramObj.getBidId() == null) {
XinchuangInst xinchuangInst = xinchuangInstService.getByInstCode(procInstId);
if (xinchuangInst != null) {
Xinchuang xinchuang = xinchuangService.getById(xinchuangInst.getXinchuangId());
paramObj.setXinchuangId(xinchuang.getId());
buildOrgName = xinchuang.getBuildOrgName();
projectName = xinchuang.getProjectName();
} else {
ProjectInst projectInst = projectInstService.getByInstCode(procInstId);
@@ -141,16 +144,20 @@ public class UserTaskCreateOrFinishListener {
}
if (paramObj.getProjectId() != null) {
Project project = projectService.getNewProject(paramObj.getProjectId());
buildOrgName = project.getBuildOrgName();
projectName = project.getProjectName();
paramObj.setProjectId(project.getId());
paramObj.setProjectCode(project.getProjectCode());
}
String content = String.format("【%s】的【%s】需要您审核,请及时处理。", projectName, procType.getDesc());
mhTodoClient.addTodo(paramObj, assignee, todoType, task.getId(), content);
String mhContent = String.format("收到来自%s提交的【%s】的%s,请尽快审批!",
buildOrgName, projectName, getProcessTypeName(procType));
mhTodoClient.addTodo(paramObj, assignee, todoType, task.getId(), mhContent);
// 发送浙政钉工作通知
if (assignee.getAccountId() != null) {
String zzdContent = String.format("收到来自%s提交的【%s】的%s,请尽快登录杭州数字信创平台审批!",
buildOrgName, projectName, getProcessTypeName(procType));
MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder()
.content(content)
.content(zzdContent)
.title(todoType.getVal())
.targetUser(assignee.getMhUserId())
.build();
@@ -162,6 +169,10 @@ public class UserTaskCreateOrFinishListener {
}
}

private static String getProcessTypeName(ProjectProcessType processType) {
return StrUtil.appendIfMissing(StrUtil.removeSuffix(processType.getDesc(), "流程"), "审批");
}

public void handleEvent(NodeCompleteEvent event) {
String procDefId = event.getProcessDefinitionId();
WflowModelHistorys models = processModelHistorysService.getByProcessDefId(procDefId);
@@ -192,6 +203,37 @@ public class UserTaskCreateOrFinishListener {
} else {
mhTodoClient.completeTodo(todoType, task.getId());
}
if (!event.getAction().equals(ProcessHandlerEnum.PASS)
&& !event.getAction().equals(ProcessHandlerEnum.SEAL_PASS)) {
String projectName;
Long createBy;
ProjectInst projectInst = projectInstService.getByInstCode(event.getInstCode());
if (projectInst != null) {
Project project = projectService.getNewestNoNull(projectInst.getProjectId());
projectName = project.getProjectName();
createBy = project.getCreateBy();
} else {
XinchuangInst xinchuangInst = xinchuangInstService.getByInstCode(event.getInstCode());
if (xinchuangInst == null) {
return;
}
Xinchuang xinchuang = xinchuangService.getById(xinchuangInst.getXinchuangId());
projectName = xinchuang.getProjectName();
createBy = Long.parseLong(xinchuang.getCreateBy());
}
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(createBy);
if (userFullInfo == null || StrUtil.isBlank(userFullInfo.getMhUserId())) {
return;
}
String zzdContent = String.format("您单位的【%s】的%s已被驳回,请按时完成提交!",
projectName, getProcessTypeName(procType));
MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder()
.content(zzdContent)
.title(todoType.getVal())
.targetUser(userFullInfo.getMhUserId())
.build();
mhApiClient.sendZwddWorkNotice(notice);
}
break;
default:
break;


Loading…
Cancel
Save