| | |
| | | import com.iailab.framework.common.util.collection.MapUtils; |
| | | import com.iailab.framework.common.util.date.DateUtils; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.bpm.controller.admin.base.user.UserSimpleBaseVO; |
| | | import com.iailab.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO; |
| | | import com.iailab.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; |
| | | import com.iailab.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; |
| | | import com.iailab.module.bpm.service.task.BpmProcessInstanceCopyService; |
| | | import com.iailab.module.bpm.service.task.BpmProcessInstanceService; |
| | | import com.iailab.module.bpm.service.task.BpmTaskService; |
| | | import com.iailab.module.system.api.user.AdminUserApi; |
| | | import com.iailab.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | import java.util.stream.Stream; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | import static com.iailab.framework.common.util.collection.CollectionUtils.convertListByFlatMap; |
| | | import static com.iailab.framework.common.util.collection.CollectionUtils.convertSet; |
| | | import static com.iailab.framework.common.util.collection.CollectionUtils.*; |
| | | import static com.iailab.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| | | |
| | | |
| | | @Tag(name = "管理后台 - 流程实例抄送") |
| | | @RestController |
| | |
| | | private BpmProcessInstanceCopyService processInstanceCopyService; |
| | | @Resource |
| | | private BpmProcessInstanceService processInstanceService; |
| | | @Resource |
| | | private BpmTaskService taskService; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | } |
| | | |
| | | // 拼接返回 |
| | | Map<String, String> taskNameMap = taskService.getTaskNameByTaskIds( |
| | | convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getTaskId)); |
| | | Map<String, HistoricProcessInstance> processInstanceMap = processInstanceService.getHistoricProcessInstanceMap( |
| | | convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), |
| | | copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator())))); |
| | | return success(BeanUtils.toBean(pageResult, BpmProcessInstanceCopyRespVO.class, copyVO -> { |
| | | MapUtils.findAndThen(userMap, Long.valueOf(copyVO.getCreator()), user -> copyVO.setCreatorName(user.getNickname())); |
| | | MapUtils.findAndThen(userMap, copyVO.getStartUserId(), user -> copyVO.setStartUserName(user.getNickname())); |
| | | MapUtils.findAndThen(taskNameMap, copyVO.getTaskId(), copyVO::setTaskName); |
| | | return success(convertPage(pageResult, copy -> { |
| | | BpmProcessInstanceCopyRespVO copyVO = BeanUtils.toBean(copy, BpmProcessInstanceCopyRespVO.class); |
| | | MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), |
| | | user -> copyVO.setStartUser(BeanUtils.toBean(user, UserSimpleBaseVO.class))); |
| | | MapUtils.findAndThen(userMap, copy.getStartUserId(), |
| | | user -> copyVO.setCreateUser(BeanUtils.toBean(user, UserSimpleBaseVO.class))); |
| | | MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(), |
| | | processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime()))); |
| | | return copyVO; |
| | | })); |
| | | } |
| | | |