|
@@ -7,6 +7,8 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
@@ -176,70 +178,49 @@ public class FlowTaskService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public Page<HisTaskVo> historicList(Page<HisTaskVo> page, Flow act) {
|
|
public Page<HisTaskVo> historicList(Page<HisTaskVo> page, Flow act) {
|
|
- String userId = UserUtils.getCurrentUserDTO ().getId ();
|
|
|
|
-
|
|
|
|
- HistoricTaskInstanceQuery histTaskQuery = historyService.createHistoricTaskInstanceQuery ().taskAssignee (userId).finished ()
|
|
|
|
- .includeProcessVariables ().orderByHistoricTaskInstanceEndTime ().desc ();
|
|
|
|
-
|
|
|
|
- // 设置查询条件
|
|
|
|
- if (StrUtil.isNotBlank (act.getProcDefKey ())) {
|
|
|
|
- histTaskQuery.processDefinitionKey (act.getProcDefKey ());
|
|
|
|
- }
|
|
|
|
- if (act.getBeginDate () != null) {
|
|
|
|
- histTaskQuery.taskCompletedAfter (act.getBeginDate ());
|
|
|
|
- }
|
|
|
|
- if (act.getEndDate () != null) {
|
|
|
|
- histTaskQuery.taskCompletedBefore (act.getEndDate ());
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank (act.getTitle ())) {
|
|
|
|
- // 实例标题
|
|
|
|
- histTaskQuery.processVariableValueLike (FlowableConstant.TITLE, "%" + act.getTitle () + "%");
|
|
|
|
- }
|
|
|
|
- if (StrUtil.isNotBlank (act.getApplyUserId())) {
|
|
|
|
- // 流程发起人
|
|
|
|
- histTaskQuery.processVariableValueEquals (FlowableConstant.INITIATOR, act.getApplyUserId ());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 查询总数
|
|
|
|
- page.setTotal (histTaskQuery.count ());
|
|
|
|
- // 查询列表
|
|
|
|
- List<HistoricTaskInstance> histList;
|
|
|
|
- if (page.getSize () == -1) {
|
|
|
|
- histList = histTaskQuery.list ();
|
|
|
|
- } else {
|
|
|
|
- int start = (int) ((page.getCurrent ( ) - 1) * page.getSize ( ));
|
|
|
|
- int size = (int) (page.getSize ( ));
|
|
|
|
- histList = histTaskQuery.listPage (start, size);
|
|
|
|
|
|
+ QueryWrapper<HisTaskVo> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("aht.ASSIGNEE_", UserUtils.getCurrentUserDTO ().getId ());
|
|
|
|
+ if (ObjectUtil.isNotEmpty(act)) {
|
|
|
|
+ if (StrUtil.isNotBlank (act.getProcDefKey ())) {
|
|
|
|
+ queryWrapper.eq ("aht.TASK_DEF_KEY_",act.getProcDefKey ());
|
|
|
|
+ }
|
|
|
|
+ if (act.getBeginDate () != null && act.getEndDate () != null) {
|
|
|
|
+ queryWrapper.between("aht.END_TIME_", act.getBeginDate (), act.getEndDate ());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank (act.getTitle ())) {
|
|
|
|
+ queryWrapper.like ("var.TEXT_", act.getTitle ());
|
|
|
|
+ }
|
|
|
|
+ if (StrUtil.isNotBlank (act.getApplyUserId())) {
|
|
|
|
+ queryWrapper.eq("hi_id.USER_ID_", act.getApplyUserId());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
- List records = Lists.newArrayList ();
|
|
|
|
- for (HistoricTaskInstance histTask : histList) {
|
|
|
|
- HisTaskVo hisTaskVo= new HisTaskVo (histTask);
|
|
|
|
- hisTaskVo.setProcessDefinitionName ( ProcessDefCache.get (histTask.getProcessDefinitionId ()).getName ());
|
|
|
|
- hisTaskVo.setBack (isBack (histTask));
|
|
|
|
- List<Task> currentTaskList = taskService.createTaskQuery ().processInstanceId (histTask.getProcessInstanceId ()).list ();
|
|
|
|
|
|
+ Page<HisTaskVo> histList = flowMapper.getHistoricList(page, queryWrapper);
|
|
|
|
+ histList.getRecords().stream().forEach(hisTaskVo -> {
|
|
|
|
+ hisTaskVo.setVars(new HashMap());
|
|
|
|
+ if (StringUtils.isNotBlank(hisTaskVo.getTitle())) {
|
|
|
|
+ hisTaskVo.getVars().put("title", hisTaskVo.getTitle());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(hisTaskVo.getStartUserName())) {
|
|
|
|
+ hisTaskVo.getVars().put("userName", hisTaskVo.getStartUserName());
|
|
|
|
+ }
|
|
|
|
+ hisTaskVo.setProcessDefinitionName ( ProcessDefCache.get (hisTaskVo.getProcessDefinitionId ()).getName ());
|
|
|
|
+ hisTaskVo.setBack (isBack (hisTaskVo));
|
|
|
|
+ List<Task> currentTaskList = taskService.createTaskQuery ().processInstanceId (hisTaskVo.getProcessInstanceId ()).list ();
|
|
if(((List) currentTaskList).size () > 0){
|
|
if(((List) currentTaskList).size () > 0){
|
|
TaskVo currentTaskVo = new TaskVo (currentTaskList.get (0));
|
|
TaskVo currentTaskVo = new TaskVo (currentTaskList.get (0));
|
|
hisTaskVo.setCurrentTask (currentTaskVo);
|
|
hisTaskVo.setCurrentTask (currentTaskVo);
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
// 获取意见评论内容
|
|
// 获取意见评论内容
|
|
-
|
|
|
|
- List<TaskComment> commentList = this.getTaskComments (histTask.getId ());
|
|
|
|
|
|
+ List<TaskComment> commentList = this.getTaskComments (hisTaskVo.getId ());
|
|
if (commentList.size () > 0) {
|
|
if (commentList.size () > 0) {
|
|
TaskComment comment = commentList.get (commentList.size ()-1);
|
|
TaskComment comment = commentList.get (commentList.size ()-1);
|
|
hisTaskVo.setComment (comment.getMessage ());
|
|
hisTaskVo.setComment (comment.getMessage ());
|
|
hisTaskVo.setLevel (comment.getLevel ());
|
|
hisTaskVo.setLevel (comment.getLevel ());
|
|
hisTaskVo.setType (comment.getType ());
|
|
hisTaskVo.setType (comment.getType ());
|
|
hisTaskVo.setStatus (comment.getStatus ());
|
|
hisTaskVo.setStatus (comment.getStatus ());
|
|
-
|
|
|
|
}
|
|
}
|
|
- records.add ( hisTaskVo );
|
|
|
|
- }
|
|
|
|
- page.setRecords ( records );
|
|
|
|
- return page;
|
|
|
|
|
|
+ });
|
|
|
|
+ return histList;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -821,21 +802,25 @@ public class FlowTaskService {
|
|
/**
|
|
/**
|
|
* 是否可以取回任务
|
|
* 是否可以取回任务
|
|
*/
|
|
*/
|
|
- public boolean isBack(HistoricTaskInstance hisTask) {
|
|
|
|
|
|
+ public boolean isBack(HisTaskVo hisTaskVo) {
|
|
ProcessInstance pi = runtimeService.createProcessInstanceQuery ()
|
|
ProcessInstance pi = runtimeService.createProcessInstanceQuery ()
|
|
- .processInstanceId (hisTask.getProcessInstanceId ()).singleResult ();
|
|
|
|
|
|
+ .processInstanceId (hisTaskVo.getProcessInstanceId ()).singleResult ();
|
|
if (pi != null) {
|
|
if (pi != null) {
|
|
if (pi.isSuspended ()) {
|
|
if (pi.isSuspended ()) {
|
|
return false;
|
|
return false;
|
|
} else {
|
|
} else {
|
|
- Task currentTask = taskService.createTaskQuery ().processInstanceId (hisTask.getProcessInstanceId ()).list ().get (0);
|
|
|
|
- HistoricTaskInstance lastHisTask = historyService.createHistoricTaskInstanceQuery ().processInstanceId (hisTask.getProcessInstanceId ()).finished ()
|
|
|
|
|
|
+ List<Task> list = taskService.createTaskQuery().processInstanceId(hisTaskVo.getProcessInstanceId()).list();
|
|
|
|
+ if (CollectionUtil.isEmpty(list)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ Task currentTask = list.get (0);
|
|
|
|
+ HistoricTaskInstance lastHisTask = historyService.createHistoricTaskInstanceQuery ().processInstanceId (hisTaskVo.getProcessInstanceId ()).finished ()
|
|
.includeProcessVariables ().orderByHistoricTaskInstanceEndTime ().desc ().list ().get (0);
|
|
.includeProcessVariables ().orderByHistoricTaskInstanceEndTime ().desc ().list ().get (0);
|
|
|
|
|
|
if (currentTask.getClaimTime () != null) {//用户已签收
|
|
if (currentTask.getClaimTime () != null) {//用户已签收
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if (hisTask.getId ().equals (lastHisTask.getId ())) {
|
|
|
|
|
|
+ if (hisTaskVo.getId ().equals (lastHisTask.getId ())) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
return false;
|