完成 bpm 已办任务列表
This commit is contained in:
parent
abe161669c
commit
4d37e9f8f0
@ -4,6 +4,6 @@ tenant-id: 1
|
||||
Authorization: Bearer {{token}}
|
||||
|
||||
### 请求 /bpm/task/done-page 接口 => 成功
|
||||
GET {{baseUrl}}/bpm/task/done-page
|
||||
GET {{baseUrl}}/bpm/task/done-page?pageSize=100
|
||||
tenant-id: 1
|
||||
Authorization: Bearer {{token}}
|
||||
|
@ -21,13 +21,16 @@ public class BpmTaskDonePageItemRespVO {
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
@ApiModelProperty(value = "结束时间", required = true)
|
||||
private Date endTime;
|
||||
|
||||
@ApiModelProperty(value = "持续时间", required = true, example = "1000")
|
||||
private Long durationInMillis;
|
||||
|
||||
@ApiModelProperty(value = "任务结果", required = true, notes = "参见 bpm_process_instance_result", example = "2")
|
||||
private Integer result;
|
||||
@ApiModelProperty(value = "审批建议", required = true, example = "不请假了!")
|
||||
private String comment;
|
||||
|
||||
/**
|
||||
* 所属流程实例
|
||||
*/
|
||||
|
@ -65,12 +65,14 @@ public interface BpmTaskConvert {
|
||||
SuspensionState.ACTIVE.getStateCode();
|
||||
}
|
||||
|
||||
default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks,
|
||||
default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks, Map<String, BpmTaskExtDO> bpmTaskExtDOMap,
|
||||
Map<String, HistoricProcessInstance> historicProcessInstanceMap,
|
||||
Map<Long, SysUserDO> userMap) {
|
||||
return CollectionUtils.convertList(tasks, task -> {
|
||||
BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId());
|
||||
HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId());
|
||||
return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId())));
|
||||
SysUserDO userDO = userMap.get(Long.valueOf(processInstance.getStartUserId()));
|
||||
return convert(task, taskExtDO, processInstance, userDO);
|
||||
});
|
||||
}
|
||||
|
||||
@ -81,13 +83,15 @@ public interface BpmTaskConvert {
|
||||
@Mapping(source = "task.createTime", target = "createTime"),
|
||||
@Mapping(source = "task.endTime", target = "endTime"),
|
||||
@Mapping(source = "task.durationInMillis", target = "durationInMillis"),
|
||||
@Mapping(source = "taskExtDO.result", target = "result"),
|
||||
@Mapping(source = "taskExtDO.comment", target = "comment"),
|
||||
@Mapping(source = "processInstance.id", target = "processInstance.id"),
|
||||
@Mapping(source = "processInstance.name", target = "processInstance.name"),
|
||||
@Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"),
|
||||
@Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"),
|
||||
@Mapping(source = "user.nickname", target = "processInstance.startUserNickname")
|
||||
})
|
||||
BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, HistoricProcessInstance processInstance, SysUserDO user);
|
||||
BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO user);
|
||||
|
||||
@Mappings({
|
||||
@Mapping(source = "id", target = "taskId"),
|
||||
|
@ -5,6 +5,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
||||
|
||||
@ -12,4 +15,8 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
||||
update(entity, new QueryWrapper<BpmTaskExtDO>().eq("task_id", entity.getTaskId()));
|
||||
}
|
||||
|
||||
default List<BpmTaskExtDO> selectListByTaskIds(Collection<String> taskIds) {
|
||||
return selectList("task_id", taskIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
/**
|
||||
@ -147,6 +148,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
return PageResult.empty(taskQuery.count());
|
||||
}
|
||||
|
||||
// 获得 TaskExtDO Map
|
||||
List<BpmTaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId));
|
||||
Map<String, BpmTaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId);
|
||||
// 获得 ProcessInstance Map
|
||||
Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap(
|
||||
convertSet(tasks, HistoricTaskInstance::getProcessInstanceId));
|
||||
@ -154,7 +158,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
Map<Long, SysUserDO> userMap = userService.getUserMap(
|
||||
convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
|
||||
// 拼接结果
|
||||
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, historicProcessInstanceMap, userMap),
|
||||
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap),
|
||||
taskQuery.count());
|
||||
}
|
||||
|
||||
|
26
yudao-admin-ui/src/utils/dateUtils.js
Normal file
26
yudao-admin-ui/src/utils/dateUtils.js
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 将毫秒,转换成时间字符串。例如说,xx 分钟
|
||||
*
|
||||
* @param ms 毫秒
|
||||
* @returns {string} 字符串
|
||||
*/
|
||||
export function getDate(ms) {
|
||||
const day = Math.floor(ms / (24 * 60 * 60 * 1000));
|
||||
const hour = Math.floor((ms / (60 * 60 * 1000) - day * 24));
|
||||
const minute = Math.floor(((ms / (60 * 1000)) - day * 24 * 60 - hour * 60));
|
||||
const second = Math.floor((ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60));
|
||||
if (day > 0) {
|
||||
return day + "天" + hour + "小时" + minute + "分钟";
|
||||
}
|
||||
if (hour > 0) {
|
||||
return hour + "小时" + minute + "分钟";
|
||||
}
|
||||
if (minute > 0) {
|
||||
return minute + "分钟";
|
||||
}
|
||||
if (second > 0) {
|
||||
return second + "秒";
|
||||
} else {
|
||||
return 0 + "秒";
|
||||
}
|
||||
}
|
@ -18,10 +18,29 @@
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="任务编号" align="center" prop="id" width="300" />
|
||||
<el-table-column label="任务名称" align="center" prop="name" />
|
||||
<el-table-column label="所属流程" align="center" prop="processInstance.name" />
|
||||
<el-table-column label="任务编号" align="center" prop="id" width="320" fixed />
|
||||
<el-table-column label="任务名称" align="center" prop="name" width="200" />
|
||||
<el-table-column label="所属流程" align="center" prop="processInstance.name" width="200" />
|
||||
<el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" />
|
||||
<el-table-column label="结果" align="center" prop="result">
|
||||
<template slot-scope="scope">
|
||||
<span>
|
||||
<el-tag type="primary" v-if="scope.row.result === 1"> <!-- 进行中 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }}
|
||||
</el-tag>
|
||||
<el-tag type="success" v-if="scope.row.result === 2"> <!-- 通过 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }}
|
||||
</el-tag>
|
||||
<el-tag type="danger" v-if="scope.row.result === 3"> <!-- 不通过 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }}
|
||||
</el-tag>
|
||||
<el-tag type="info" v-if="scope.row.result === 4"> <!-- 撤回 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="审批意见" align="center" prop="comment" width="200" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
@ -32,8 +51,13 @@
|
||||
<span>{{ parseTime(scope.row.endTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="耗时" align="center" prop="durationInMillis" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ getDateStar(scope.row.durationInMillis) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- TODO 耗时 -->
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<!-- TODO 权限、颜色 -->
|
||||
<el-button size="mini" type="text" icon="el-icon-edit">详情</el-button>
|
||||
@ -49,6 +73,7 @@
|
||||
|
||||
<script>
|
||||
import {getDoneTaskPage} from '@/api/bpm/task'
|
||||
import {getDate} from "@/utils/dateUtils";
|
||||
|
||||
export default {
|
||||
name: "Done",
|
||||
@ -100,6 +125,9 @@ export default {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
getDateStar(ms) {
|
||||
return getDate(ms);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
<!-- 列表 -->
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="任务编号" align="center" prop="id" width="300" />
|
||||
<el-table-column label="任务编号" align="center" prop="id" width="320" />
|
||||
<el-table-column label="任务名称" align="center" prop="name" />
|
||||
<el-table-column label="所属流程" align="center" prop="processInstance.name" />
|
||||
<el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" />
|
||||
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -44,4 +45,8 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
return selectList(new QueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default List<T> selectList(String field, Collection<?> values) {
|
||||
return selectList(new QueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user