parent
d08abc8c7e
commit
deb4b12ac0
5 changed files with 132 additions and 0 deletions
@ -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; |
||||
} |
||||
} |
||||
@ -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(); |
||||
} |
||||
@ -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<Task> 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<HistoricProcessInstance> 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; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue