diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/controller/HomePageController.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/controller/HomePageController.java new file mode 100644 index 0000000..f0ce945 --- /dev/null +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/controller/HomePageController.java @@ -0,0 +1,41 @@ +package org.springblade.plugin.homepage.controller; + +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.tenant.annotation.NonDS; +import org.springblade.core.tool.api.R; +import org.springblade.plugin.operation.system.entity.ModuleInfo; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 首页 + * @Description + * @Author ytl + * @Date 2023/2/14 0014 15:54 + */ + +@NonDS +@RestController +@AllArgsConstructor +@RequestMapping("/homePage") +@Api(value = "首页", tags = "首页") +public class HomePageController extends BladeController { + + + /** + * 我的相关,首页的“到期提醒”、“我的待办”、“今日新增”、“今日完成”的统计 + */ + @GetMapping("/aboutMy") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "我的相关", notes = "首页的“到期提醒”、“我的待办”、“今日新增”、“今日完成”的统计") + public R aboutMy() { + + return null; + } +} diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/IHomePageService.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/IHomePageService.java new file mode 100644 index 0000000..3123064 --- /dev/null +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/IHomePageService.java @@ -0,0 +1,13 @@ +package org.springblade.plugin.homepage.service; + +import org.springblade.core.tool.api.R; + +/** + * @Description + * @Author ytl + * @Date 2023/2/14 0014 15:59 + */ +public interface IHomePageService { + + R aboutMy(); +} 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 new file mode 100644 index 0000000..51931fb --- /dev/null +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/homepage/service/impl/HomePageServiceImpl.java @@ -0,0 +1,72 @@ +package org.springblade.plugin.homepage.service.impl; + +import com.alibaba.fastjson.JSONObject; +import lombok.AllArgsConstructor; +import org.flowable.engine.HistoryService; +import org.flowable.engine.TaskService; +import org.flowable.engine.history.HistoricProcessInstance; +import org.flowable.engine.history.HistoricProcessInstanceQuery; +import org.flowable.task.api.Task; +import org.flowable.task.api.TaskQuery; +import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.plugin.homepage.service.IHomePageService; +import org.springblade.plugin.workflow.core.utils.WfTaskUtil; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @Description + * @Author ytl + * @Date 2023/2/14 0014 16:01 + */ +@Service +@AllArgsConstructor +public class HomePageServiceImpl implements IHomePageService { + private final TaskService taskService; + private final HistoryService historyService; + + @Override + public R aboutMy() { + //结果 + JSONObject result = new JSONObject(); + + String taskUser = WfTaskUtil.getTaskUser(); + String taskGroup = WfTaskUtil.getCandidateGroup(); + + //我的待办 + TaskQuery taskQuery = taskService.createTaskQuery() + .orderByTaskCreateTime() + .desc() + .taskTenantId(WfTaskUtil.getTenantId()) + .active(); + taskQuery.taskCandidateOrAssigned(taskUser) + .taskCandidateGroupIn(Func.toStrList(taskGroup)); + + List listNeedDo = taskQuery.list(); + //我的待办 + result.put("needDoNum", listNeedDo.size()); + + //与我相关的新增 + //1.获取今日新增的流程 + HistoricProcessInstanceQuery thisDayProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().startedAfter(DateUtil.plusDays(DateUtil.now(), -1)) + .processInstanceTenantId(WfTaskUtil.getTenantId()); + //2.遍历流程通过流程id获取与我相关的task + int todayAddNum = 0; + List list = thisDayProcessInstanceQuery.list(); + for(HistoricProcessInstance his : list){ + TaskQuery taskQuery1 = taskService.createTaskQuery().processInstanceId(his.getId()).taskAssignee(WfTaskUtil.getTenantId()); + if(taskQuery1.list().size() > 0){ + todayAddNum ++; + } + } + result.put("todayAddNum" , todayAddNum); + + return null; + } +} diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/core/constant/WfProcessConstant.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/core/constant/WfProcessConstant.java index 07d1908..6327c5e 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/core/constant/WfProcessConstant.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/core/constant/WfProcessConstant.java @@ -132,4 +132,6 @@ public interface WfProcessConstant { String TASK_VARIABLE_PLATFORM = "wf_platform"; + String TASK_CREATE_ROLE = "createRole"; + } diff --git a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java index 614552b..770d2ec 100644 --- a/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java +++ b/lab-plugin/lab-workflow/src/main/java/org/springblade/plugin/workflow/process/service/impl/WfProcessService.java @@ -34,6 +34,7 @@ import org.flowable.variable.api.history.HistoricVariableInstance; import org.flowable.variable.api.history.HistoricVariableInstanceQuery; import org.springblade.core.mp.support.Query; import org.springblade.core.redis.lock.RedisLock; +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; @@ -93,8 +94,11 @@ public class WfProcessService implements IWfProcessService { if (definition == null) { throw new RuntimeException("查询不到此部署的流程"); } + String createRoleName = AuthUtil.getUser().getRoleName(); + //创建人的角色名称 String userId = WfTaskUtil.getTaskUser(); variables.put(WfProcessConstant.TASK_VARIABLE_APPLY_USER, userId); + variables.put(WfProcessConstant.TASK_CREATE_ROLE, createRoleName); // 启动流程 identityService.setAuthenticatedUserId(userId); ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefId, definition.getKey(), variables);