diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http index 4742c83e7..d974a83f1 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/BpmTaskController.http @@ -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}} diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java index d43b92e83..9779992fe 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/controller/task/vo/task/BpmTaskDonePageItemRespVO.java +++ b/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 { @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; + /** * 所属流程实例 */ diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java index a4556ce24..abaf25360 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/convert/task/BpmTaskConvert.java @@ -65,12 +65,14 @@ public interface BpmTaskConvert { SuspensionState.ACTIVE.getStateCode(); } - default List convertList2(List tasks, + default List convertList2(List tasks, Map bpmTaskExtDOMap, Map historicProcessInstanceMap, Map 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"), diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmTaskExtMapper.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmTaskExtMapper.java index c7d2fb72e..a71f06151 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/dal/mysql/task/BpmTaskExtMapper.java +++ b/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; 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 { @@ -12,4 +15,8 @@ public interface BpmTaskExtMapper extends BaseMapperX { update(entity, new QueryWrapper().eq("task_id", entity.getTaskId())); } + default List selectListByTaskIds(Collection taskIds) { + return selectList("task_id", taskIds); + } + } diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java index 6a18eae80..9c9e4f1ef 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/bpm/service/task/impl/BpmTaskServiceImpl.java @@ -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 bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId)); + Map bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId); // 获得 ProcessInstance Map Map historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap( convertSet(tasks, HistoricTaskInstance::getProcessInstanceId)); @@ -154,7 +158,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { Map 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()); } diff --git a/yudao-admin-ui/src/utils/dateUtils.js b/yudao-admin-ui/src/utils/dateUtils.js new file mode 100644 index 000000000..2e658b4a3 --- /dev/null +++ b/yudao-admin-ui/src/utils/dateUtils.js @@ -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 + "秒"; + } +} diff --git a/yudao-admin-ui/src/views/bpm/task/done.vue b/yudao-admin-ui/src/views/bpm/task/done.vue index 8def1171e..9d63a2f7e 100644 --- a/yudao-admin-ui/src/views/bpm/task/done.vue +++ b/yudao-admin-ui/src/views/bpm/task/done.vue @@ -18,10 +18,29 @@ - - - + + + + + + + + + + - +