Commit 4d37e9f8f06d04886d364f95fd03347a55de8864
1 parent
abe16166
完成 bpm 已办任务列表
Showing
9 changed files
with
89 additions
and
12 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http
| @@ -4,6 +4,6 @@ tenant-id: 1 | @@ -4,6 +4,6 @@ tenant-id: 1 | ||
| 4 | Authorization: Bearer {{token}} | 4 | Authorization: Bearer {{token}} |
| 5 | 5 | ||
| 6 | ### 请求 /bpm/task/done-page 接口 => 成功 | 6 | ### 请求 /bpm/task/done-page 接口 => 成功 |
| 7 | -GET {{baseUrl}}/bpm/task/done-page | 7 | +GET {{baseUrl}}/bpm/task/done-page?pageSize=100 |
| 8 | tenant-id: 1 | 8 | tenant-id: 1 |
| 9 | Authorization: Bearer {{token}} | 9 | Authorization: Bearer {{token}} |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java
| @@ -21,13 +21,16 @@ public class BpmTaskDonePageItemRespVO { | @@ -21,13 +21,16 @@ public class BpmTaskDonePageItemRespVO { | ||
| 21 | 21 | ||
| 22 | @ApiModelProperty(value = "创建时间", required = true) | 22 | @ApiModelProperty(value = "创建时间", required = true) |
| 23 | private Date createTime; | 23 | private Date createTime; |
| 24 | - | ||
| 25 | @ApiModelProperty(value = "结束时间", required = true) | 24 | @ApiModelProperty(value = "结束时间", required = true) |
| 26 | private Date endTime; | 25 | private Date endTime; |
| 27 | - | ||
| 28 | @ApiModelProperty(value = "持续时间", required = true, example = "1000") | 26 | @ApiModelProperty(value = "持续时间", required = true, example = "1000") |
| 29 | private Long durationInMillis; | 27 | private Long durationInMillis; |
| 30 | 28 | ||
| 29 | + @ApiModelProperty(value = "任务结果", required = true, notes = "参见 bpm_process_instance_result", example = "2") | ||
| 30 | + private Integer result; | ||
| 31 | + @ApiModelProperty(value = "审批建议", required = true, example = "不请假了!") | ||
| 32 | + private String comment; | ||
| 33 | + | ||
| 31 | /** | 34 | /** |
| 32 | * 所属流程实例 | 35 | * 所属流程实例 |
| 33 | */ | 36 | */ |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java
| @@ -65,12 +65,14 @@ public interface BpmTaskConvert { | @@ -65,12 +65,14 @@ public interface BpmTaskConvert { | ||
| 65 | SuspensionState.ACTIVE.getStateCode(); | 65 | SuspensionState.ACTIVE.getStateCode(); |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | - default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks, | 68 | + default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks, Map<String, BpmTaskExtDO> bpmTaskExtDOMap, |
| 69 | Map<String, HistoricProcessInstance> historicProcessInstanceMap, | 69 | Map<String, HistoricProcessInstance> historicProcessInstanceMap, |
| 70 | Map<Long, SysUserDO> userMap) { | 70 | Map<Long, SysUserDO> userMap) { |
| 71 | return CollectionUtils.convertList(tasks, task -> { | 71 | return CollectionUtils.convertList(tasks, task -> { |
| 72 | + BpmTaskExtDO taskExtDO = bpmTaskExtDOMap.get(task.getId()); | ||
| 72 | HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId()); | 73 | HistoricProcessInstance processInstance = historicProcessInstanceMap.get(task.getProcessInstanceId()); |
| 73 | - return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId()))); | 74 | + SysUserDO userDO = userMap.get(Long.valueOf(processInstance.getStartUserId())); |
| 75 | + return convert(task, taskExtDO, processInstance, userDO); | ||
| 74 | }); | 76 | }); |
| 75 | } | 77 | } |
| 76 | 78 | ||
| @@ -81,13 +83,15 @@ public interface BpmTaskConvert { | @@ -81,13 +83,15 @@ public interface BpmTaskConvert { | ||
| 81 | @Mapping(source = "task.createTime", target = "createTime"), | 83 | @Mapping(source = "task.createTime", target = "createTime"), |
| 82 | @Mapping(source = "task.endTime", target = "endTime"), | 84 | @Mapping(source = "task.endTime", target = "endTime"), |
| 83 | @Mapping(source = "task.durationInMillis", target = "durationInMillis"), | 85 | @Mapping(source = "task.durationInMillis", target = "durationInMillis"), |
| 86 | + @Mapping(source = "taskExtDO.result", target = "result"), | ||
| 87 | + @Mapping(source = "taskExtDO.comment", target = "comment"), | ||
| 84 | @Mapping(source = "processInstance.id", target = "processInstance.id"), | 88 | @Mapping(source = "processInstance.id", target = "processInstance.id"), |
| 85 | @Mapping(source = "processInstance.name", target = "processInstance.name"), | 89 | @Mapping(source = "processInstance.name", target = "processInstance.name"), |
| 86 | @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), | 90 | @Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"), |
| 87 | @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), | 91 | @Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"), |
| 88 | @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") | 92 | @Mapping(source = "user.nickname", target = "processInstance.startUserNickname") |
| 89 | }) | 93 | }) |
| 90 | - BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, HistoricProcessInstance processInstance, SysUserDO user); | 94 | + BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, BpmTaskExtDO taskExtDO, HistoricProcessInstance processInstance, SysUserDO user); |
| 91 | 95 | ||
| 92 | @Mappings({ | 96 | @Mappings({ |
| 93 | @Mapping(source = "id", target = "taskId"), | 97 | @Mapping(source = "id", target = "taskId"), |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmTaskExtMapper.java
| @@ -5,6 +5,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | @@ -5,6 +5,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 6 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 7 | 7 | ||
| 8 | +import java.util.Collection; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 8 | @Mapper | 11 | @Mapper |
| 9 | public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { | 12 | public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { |
| 10 | 13 | ||
| @@ -12,4 +15,8 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { | @@ -12,4 +15,8 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { | ||
| 12 | update(entity, new QueryWrapper<BpmTaskExtDO>().eq("task_id", entity.getTaskId())); | 15 | update(entity, new QueryWrapper<BpmTaskExtDO>().eq("task_id", entity.getTaskId())); |
| 13 | } | 16 | } |
| 14 | 17 | ||
| 18 | + default List<BpmTaskExtDO> selectListByTaskIds(Collection<String> taskIds) { | ||
| 19 | + return selectList("task_id", taskIds); | ||
| 20 | + } | ||
| 21 | + | ||
| 15 | } | 22 | } |
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java
| @@ -47,6 +47,7 @@ import java.util.*; | @@ -47,6 +47,7 @@ import java.util.*; | ||
| 47 | 47 | ||
| 48 | import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; | 48 | import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*; |
| 49 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 49 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 50 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 50 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 51 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 51 | 52 | ||
| 52 | /** | 53 | /** |
| @@ -147,6 +148,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -147,6 +148,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 147 | return PageResult.empty(taskQuery.count()); | 148 | return PageResult.empty(taskQuery.count()); |
| 148 | } | 149 | } |
| 149 | 150 | ||
| 151 | + // 获得 TaskExtDO Map | ||
| 152 | + List<BpmTaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); | ||
| 153 | + Map<String, BpmTaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); | ||
| 150 | // 获得 ProcessInstance Map | 154 | // 获得 ProcessInstance Map |
| 151 | Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( | 155 | Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( |
| 152 | convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); | 156 | convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); |
| @@ -154,7 +158,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -154,7 +158,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 154 | Map<Long, SysUserDO> userMap = userService.getUserMap( | 158 | Map<Long, SysUserDO> userMap = userService.getUserMap( |
| 155 | convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); | 159 | convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId()))); |
| 156 | // 拼接结果 | 160 | // 拼接结果 |
| 157 | - return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, historicProcessInstanceMap, userMap), | 161 | + return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap), |
| 158 | taskQuery.count()); | 162 | taskQuery.count()); |
| 159 | } | 163 | } |
| 160 | 164 |
yudao-admin-ui/src/utils/dateUtils.js
0 → 100644
| 1 | +/** | ||
| 2 | + * 将毫秒,转换成时间字符串。例如说,xx 分钟 | ||
| 3 | + * | ||
| 4 | + * @param ms 毫秒 | ||
| 5 | + * @returns {string} 字符串 | ||
| 6 | + */ | ||
| 7 | +export function getDate(ms) { | ||
| 8 | + const day = Math.floor(ms / (24 * 60 * 60 * 1000)); | ||
| 9 | + const hour = Math.floor((ms / (60 * 60 * 1000) - day * 24)); | ||
| 10 | + const minute = Math.floor(((ms / (60 * 1000)) - day * 24 * 60 - hour * 60)); | ||
| 11 | + const second = Math.floor((ms / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60)); | ||
| 12 | + if (day > 0) { | ||
| 13 | + return day + "天" + hour + "小时" + minute + "分钟"; | ||
| 14 | + } | ||
| 15 | + if (hour > 0) { | ||
| 16 | + return hour + "小时" + minute + "分钟"; | ||
| 17 | + } | ||
| 18 | + if (minute > 0) { | ||
| 19 | + return minute + "分钟"; | ||
| 20 | + } | ||
| 21 | + if (second > 0) { | ||
| 22 | + return second + "秒"; | ||
| 23 | + } else { | ||
| 24 | + return 0 + "秒"; | ||
| 25 | + } | ||
| 26 | +} |
yudao-admin-ui/src/views/bpm/task/done.vue
| @@ -18,10 +18,29 @@ | @@ -18,10 +18,29 @@ | ||
| 18 | 18 | ||
| 19 | <!-- 列表 --> | 19 | <!-- 列表 --> |
| 20 | <el-table v-loading="loading" :data="list"> | 20 | <el-table v-loading="loading" :data="list"> |
| 21 | - <el-table-column label="任务编号" align="center" prop="id" width="300" /> | ||
| 22 | - <el-table-column label="任务名称" align="center" prop="name" /> | ||
| 23 | - <el-table-column label="所属流程" align="center" prop="processInstance.name" /> | 21 | + <el-table-column label="任务编号" align="center" prop="id" width="320" fixed /> |
| 22 | + <el-table-column label="任务名称" align="center" prop="name" width="200" /> | ||
| 23 | + <el-table-column label="所属流程" align="center" prop="processInstance.name" width="200" /> | ||
| 24 | <el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" /> | 24 | <el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" /> |
| 25 | + <el-table-column label="结果" align="center" prop="result"> | ||
| 26 | + <template slot-scope="scope"> | ||
| 27 | + <span> | ||
| 28 | + <el-tag type="primary" v-if="scope.row.result === 1"> <!-- 进行中 --> | ||
| 29 | + {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }} | ||
| 30 | + </el-tag> | ||
| 31 | + <el-tag type="success" v-if="scope.row.result === 2"> <!-- 通过 --> | ||
| 32 | + {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }} | ||
| 33 | + </el-tag> | ||
| 34 | + <el-tag type="danger" v-if="scope.row.result === 3"> <!-- 不通过 --> | ||
| 35 | + {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }} | ||
| 36 | + </el-tag> | ||
| 37 | + <el-tag type="info" v-if="scope.row.result === 4"> <!-- 撤回 --> | ||
| 38 | + {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, scope.row.result) }} | ||
| 39 | + </el-tag> | ||
| 40 | + </span> | ||
| 41 | + </template> | ||
| 42 | + </el-table-column> | ||
| 43 | + <el-table-column label="审批意见" align="center" prop="comment" width="200" /> | ||
| 25 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | 44 | <el-table-column label="创建时间" align="center" prop="createTime" width="180"> |
| 26 | <template slot-scope="scope"> | 45 | <template slot-scope="scope"> |
| 27 | <span>{{ parseTime(scope.row.createTime) }}</span> | 46 | <span>{{ parseTime(scope.row.createTime) }}</span> |
| @@ -32,8 +51,13 @@ | @@ -32,8 +51,13 @@ | ||
| 32 | <span>{{ parseTime(scope.row.endTime) }}</span> | 51 | <span>{{ parseTime(scope.row.endTime) }}</span> |
| 33 | </template> | 52 | </template> |
| 34 | </el-table-column> | 53 | </el-table-column> |
| 54 | + <el-table-column label="耗时" align="center" prop="durationInMillis" width="180"> | ||
| 55 | + <template slot-scope="scope"> | ||
| 56 | + <span>{{ getDateStar(scope.row.durationInMillis) }}</span> | ||
| 57 | + </template> | ||
| 58 | + </el-table-column> | ||
| 35 | <!-- TODO 耗时 --> | 59 | <!-- TODO 耗时 --> |
| 36 | - <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | 60 | + <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width"> |
| 37 | <template slot-scope="scope"> | 61 | <template slot-scope="scope"> |
| 38 | <!-- TODO 权限、颜色 --> | 62 | <!-- TODO 权限、颜色 --> |
| 39 | <el-button size="mini" type="text" icon="el-icon-edit">详情</el-button> | 63 | <el-button size="mini" type="text" icon="el-icon-edit">详情</el-button> |
| @@ -49,6 +73,7 @@ | @@ -49,6 +73,7 @@ | ||
| 49 | 73 | ||
| 50 | <script> | 74 | <script> |
| 51 | import {getDoneTaskPage} from '@/api/bpm/task' | 75 | import {getDoneTaskPage} from '@/api/bpm/task' |
| 76 | +import {getDate} from "@/utils/dateUtils"; | ||
| 52 | 77 | ||
| 53 | export default { | 78 | export default { |
| 54 | name: "Done", | 79 | name: "Done", |
| @@ -100,6 +125,9 @@ export default { | @@ -100,6 +125,9 @@ export default { | ||
| 100 | this.resetForm("queryForm"); | 125 | this.resetForm("queryForm"); |
| 101 | this.handleQuery(); | 126 | this.handleQuery(); |
| 102 | }, | 127 | }, |
| 128 | + getDateStar(ms) { | ||
| 129 | + return getDate(ms); | ||
| 130 | + } | ||
| 103 | } | 131 | } |
| 104 | }; | 132 | }; |
| 105 | </script> | 133 | </script> |
yudao-admin-ui/src/views/bpm/task/todo.vue
| @@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
| 18 | 18 | ||
| 19 | <!-- 列表 --> | 19 | <!-- 列表 --> |
| 20 | <el-table v-loading="loading" :data="list"> | 20 | <el-table v-loading="loading" :data="list"> |
| 21 | - <el-table-column label="任务编号" align="center" prop="id" width="300" /> | 21 | + <el-table-column label="任务编号" align="center" prop="id" width="320" /> |
| 22 | <el-table-column label="任务名称" align="center" prop="name" /> | 22 | <el-table-column label="任务名称" align="center" prop="name" /> |
| 23 | <el-table-column label="所属流程" align="center" prop="processInstance.name" /> | 23 | <el-table-column label="所属流程" align="center" prop="processInstance.name" /> |
| 24 | <el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" /> | 24 | <el-table-column label="流程发起人" align="center" prop="processInstance.startUserNickname" /> |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
| @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | @@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 9 | import com.baomidou.mybatisplus.core.metadata.IPage; | 9 | import com.baomidou.mybatisplus.core.metadata.IPage; |
| 10 | import org.apache.ibatis.annotations.Param; | 10 | import org.apache.ibatis.annotations.Param; |
| 11 | 11 | ||
| 12 | +import java.util.Collection; | ||
| 12 | import java.util.List; | 13 | import java.util.List; |
| 13 | 14 | ||
| 14 | /** | 15 | /** |
| @@ -44,4 +45,8 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | @@ -44,4 +45,8 @@ public interface BaseMapperX<T> extends BaseMapper<T> { | ||
| 44 | return selectList(new QueryWrapper<T>().eq(field, value)); | 45 | return selectList(new QueryWrapper<T>().eq(field, value)); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 48 | + default List<T> selectList(String field, Collection<?> values) { | ||
| 49 | + return selectList(new QueryWrapper<T>().in(field, values)); | ||
| 50 | + } | ||
| 51 | + | ||
| 47 | } | 52 | } |