| | |
| | | package cn.iocoder.yudao.module.mes.controller.admin.pd.documentaudit; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| | |
| | | import cn.iocoder.yudao.module.mes.controller.admin.pd.documentaudit.vo.MesPdDocumentAuditSaveReqVO; |
| | | import cn.iocoder.yudao.module.mes.dal.dataobject.pd.documentaudit.MesPdDocumentAuditDO; |
| | | import cn.iocoder.yudao.module.mes.service.pd.documentaudit.MesPdDocumentAuditService; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | | |
| | | @Resource |
| | | private StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建资料审核") |
| | |
| | | // 1.1 批量获取关联数据(审核人) |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(list, MesPdDocumentAuditDO::getReviewer)); |
| | | // 2. 拼接 VO |
| | | return BeanUtils.toBean(list, MesPdDocumentAuditRespVO.class, vo -> { |
| | | List<MesPdDocumentAuditRespVO> voList = BeanUtils.toBean(list, MesPdDocumentAuditRespVO.class, vo -> { |
| | | MapUtils.findAndThen(userMap, vo.getReviewer(), |
| | | user -> vo.setReviewerNickname(user.getNickname())); |
| | | }); |
| | | // 3. 拼接资料文件信息:取该资料第一个附件,供列表直接查看文件 |
| | | for (MesPdDocumentAuditRespVO vo : voList) { |
| | | if (vo.getDocumentId() == null) { |
| | | continue; |
| | | } |
| | | List<StorageBlobRespDTO> attachments = storageAttachmentApi.listAttachments("mes_pd_document", vo.getDocumentId()); |
| | | if (CollUtil.isNotEmpty(attachments)) { |
| | | StorageBlobRespDTO first = attachments.get(0); |
| | | vo.setFileUrl(first.getUrl()); |
| | | vo.setFileName(StrUtil.isEmpty(vo.getFileName()) ? first.getName() : vo.getFileName()); |
| | | } |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | } |