dongyukun
6 天以前 ed8fc5f674544d3af63c6f68093ffc038385c493
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.bpm.controller.admin.task;
H 2
3 import cn.hutool.core.collection.CollUtil;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.pojo.PageResult;
6 import com.iailab.framework.common.util.collection.MapUtils;
7 import com.iailab.framework.common.util.date.DateUtils;
8 import com.iailab.framework.common.util.object.BeanUtils;
bb2880 9 import com.iailab.module.bpm.controller.admin.base.user.UserSimpleBaseVO;
e7c126 10 import com.iailab.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO;
H 11 import com.iailab.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO;
12 import com.iailab.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO;
13 import com.iailab.module.bpm.service.task.BpmProcessInstanceCopyService;
14 import com.iailab.module.bpm.service.task.BpmProcessInstanceService;
15 import com.iailab.module.system.api.user.AdminUserApi;
16 import com.iailab.module.system.api.user.dto.AdminUserRespDTO;
17 import io.swagger.v3.oas.annotations.Operation;
18 import io.swagger.v3.oas.annotations.tags.Tag;
19 import org.flowable.engine.history.HistoricProcessInstance;
20 import org.springframework.security.access.prepost.PreAuthorize;
21 import org.springframework.validation.annotation.Validated;
22 import org.springframework.web.bind.annotation.GetMapping;
23 import org.springframework.web.bind.annotation.RequestMapping;
24 import org.springframework.web.bind.annotation.RestController;
25
26 import javax.annotation.Resource;
27 import javax.validation.Valid;
28 import java.util.Map;
29 import java.util.stream.Stream;
30
31 import static com.iailab.framework.common.pojo.CommonResult.success;
bb2880 32 import static com.iailab.framework.common.util.collection.CollectionUtils.*;
e7c126 33 import static com.iailab.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
bb2880 34
e7c126 35
H 36 @Tag(name = "管理后台 - 流程实例抄送")
37 @RestController
38 @RequestMapping("/bpm/process-instance/copy")
39 @Validated
40 public class BpmProcessInstanceCopyController {
41
42     @Resource
43     private BpmProcessInstanceCopyService processInstanceCopyService;
44     @Resource
45     private BpmProcessInstanceService processInstanceService;
46
47     @Resource
48     private AdminUserApi adminUserApi;
49
50     @GetMapping("/page")
51     @Operation(summary = "获得抄送流程分页列表")
52     @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
53     public CommonResult<PageResult<BpmProcessInstanceCopyRespVO>> getProcessInstanceCopyPage(
54             @Valid BpmProcessInstanceCopyPageReqVO pageReqVO) {
55         PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyService.getProcessInstanceCopyPage(
56                 getLoginUserId(), pageReqVO);
57         if (CollUtil.isEmpty(pageResult.getList())) {
58             return success(new PageResult<>(pageResult.getTotal()));
59         }
60
61         // 拼接返回
62         Map<String, HistoricProcessInstance> processInstanceMap = processInstanceService.getHistoricProcessInstanceMap(
63                 convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
64         Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(),
65                 copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator()))));
bb2880 66         return success(convertPage(pageResult, copy -> {
H 67             BpmProcessInstanceCopyRespVO copyVO = BeanUtils.toBean(copy, BpmProcessInstanceCopyRespVO.class);
68             MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()),
69                     user -> copyVO.setStartUser(BeanUtils.toBean(user, UserSimpleBaseVO.class)));
70             MapUtils.findAndThen(userMap, copy.getStartUserId(),
71                     user -> copyVO.setCreateUser(BeanUtils.toBean(user, UserSimpleBaseVO.class)));
e7c126 72             MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(),
H 73                     processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime())));
bb2880 74             return copyVO;
e7c126 75         }));
H 76     }
77
78 }