diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/flowutil/TaskNodeUtil.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/flowutil/TaskNodeUtil.java new file mode 100644 index 0000000..6fb9aff --- /dev/null +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/flowutil/TaskNodeUtil.java @@ -0,0 +1,27 @@ +package org.springblade.plugin.homepage.flowutil; + +import org.flowable.engine.delegate.DelegateExecution; +import org.springframework.stereotype.Component; + +/** + * @Description + * 通过方法指定节点办理人 + * @Author ytl + * @Date 2023/2/18 0018 9:54 + */ + +@Component +public class TaskNodeUtil { + + //将运维公司指定为节点办理人 + public String setCompanyToAssignee(DelegateExecution execution){ + String assignee = ""; + Object yunweigongsi = execution.getVariable("yunweigongsi"); + + if(yunweigongsi != null){ + assignee = yunweigongsi.toString(); + } + return assignee; + } + +} diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java index 9f949d0..2b4b5de 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java @@ -3,6 +3,7 @@ package org.springblade.plugin.homepage.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.AllArgsConstructor; +import org.apache.commons.lang.StringUtils; import org.flowable.engine.HistoryService; import org.flowable.engine.RuntimeService; import org.flowable.engine.TaskService; @@ -16,6 +17,7 @@ import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.plugin.homepage.enumutil.TaskTypeColorEnum; import org.springblade.plugin.homepage.service.IHomePageService; import org.springblade.plugin.workflow.core.utils.WfTaskUtil; @@ -304,7 +306,7 @@ public class HomePageServiceImpl implements IHomePageService { } /** - * 流程状态 + * 流程状态统计 * @return */ @Override @@ -320,7 +322,6 @@ public class HomePageServiceImpl implements IHomePageService { .processInstanceTenantId(WfTaskUtil.getTenantId()) .list(); - //过滤出与当前用户所在部门一致的工作流实例 List collect = historicProcessInstanceList.stream().filter( process -> { @@ -341,11 +342,17 @@ public class HomePageServiceImpl implements IHomePageService { Map map = new HashMap<>(); collect.forEach(hi ->{ - HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(hi.getSuperProcessInstanceId()).unfinished().singleResult(); + HistoricActivityInstance historicActivityInstance = historyService.createHistoricActivityInstanceQuery().processInstanceId(hi.getId()).unfinished().singleResult(); if(historicActivityInstance == null){ - map.put("已结束", map.get("已结束") == null ? 1 : map.get("已结束") + 1); + map.put("已完成", map.get("已完成") == null ? 1 : map.get("已完成") + 1); }else{ - map.put(historicActivityInstance.getActivityName(), map.get(historicActivityInstance.getActivityName()) == null ? 1 : map.get(historicActivityInstance.getActivityName()) + 1); + String activityName = historicActivityInstance.getActivityName(); + if(StringUtils.contains(historicActivityInstance.getActivityName(), "审批")){ + map.put("审批中", map.get("审批中") == null ? 1 : map.get("审批中") + 1); + }else{ + map.put("运行中", map.get("运行中") == null ? 1 : map.get("运行中") + 1); + } + // map.put(historicActivityInstance.getActivityName(), map.get(historicActivityInstance.getActivityName()) == null ? 1 : map.get(historicActivityInstance.getActivityName()) + 1); } }); @@ -354,6 +361,7 @@ public class HomePageServiceImpl implements IHomePageService { Map.Entry next = iterator.next(); JSONObject jsonObject = new JSONObject(); jsonObject.put(next.getKey(),next.getValue()); + result.add(jsonObject); } return R.data(result); }