diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java index 6eb0cdc..851f51a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java @@ -1,11 +1,13 @@ package cn.iocoder.yudao.module.system.controller.admin.qualification; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.qualification.EnterpriseQualificationServiceImpl; +import io.reactivex.rxjava3.core.Single; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; @@ -15,6 +17,7 @@ import io.swagger.v3.oas.annotations.Operation; import java.util.*; import java.io.IOException; +import java.util.stream.Collectors; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -81,7 +84,7 @@ public class EnterpriseQualificationController { public CommonResult getEnterpriseQualification(@RequestParam("id") Long id) { EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); EnterpriseQualificationRespVO bean = BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class); - List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, id.toString()); + List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, bean.getId().toString()); bean.setFiles(fileList); return success(bean); } @@ -94,9 +97,32 @@ public class EnterpriseQualificationController { pageResult.getList().forEach(item->{ item.setEnterpriseName(enterpriseService.getEnterprise(Long.valueOf(item.getEnterpriseId())).getEnterprisesName()); }); - return success(BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class)); + PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + + return success(bean); } + + @GetMapping("/pageEnterprise") + @Operation(summary = "获得企业资质分页") +// @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") + public CommonResult> getEnterpriseQualificationEnterprisePage(EnterpriseQualificationPageReqVO pageReqVO) { + PageResult pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO); + pageResult.getList().forEach(item -> { + item.setEnterpriseName(enterpriseService.getEnterprise(Long.valueOf(item.getEnterpriseId())).getEnterprisesName()); + }); + PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + List list = bean.getList(); + Map> longListMap = CollectionUtils.convertMultiMap(list, EnterpriseQualificationRespVO::getId); + List collect = longListMap.keySet().stream().map(x -> x.toString()).collect(Collectors.toList()); + Map> fileListMap = fileInfoService.getFileListMap(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, collect); + + for (EnterpriseQualificationRespVO item : list) { + item.setFiles(fileListMap.get(item.getId().toString())); + } + + return success(bean); + } @GetMapping("/export-excel") @Operation(summary = "导出企业资质 Excel") @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:export')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java index 8527967..6c3332c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.fileInfo.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import org.apache.poi.ss.formula.functions.T; import javax.validation.Valid; @@ -55,6 +56,7 @@ public interface FileInfoService { PageResult getFileInfoPage(FileInfoPageReqVO pageReqVO); List getFileList(Long dictType, Long dictData, String unitId); + Map> getFileListMap(Long dictType, Long dictData, Collection unitId); /** * 根据字典类型和字典数据保存附件信息 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java index 594547d..6ac0fca 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java @@ -99,6 +99,43 @@ public class FileInfoServiceImpl implements FileInfoService { return mapList; } + @Override + public Map> getFileListMap(Long dictType, Long dictData, Collection unitId) { + + Map> result =new HashMap<>(); + LambdaQueryWrapperX wrapper = new LambdaQueryWrapperX(); + wrapper.eqIfPresent(FileInfoDO::getDictType, dictType); + wrapper.eqIfPresent(FileInfoDO::getDictData, dictData); + wrapper.inIfPresent(FileInfoDO::getUnitId, unitId); + List fileInfoDOS = fileInfoMapper.selectList(wrapper); + if(fileInfoDOS.isEmpty()){ + return result; + } + Map> stringListMap = CollectionUtils.convertMultiMap(fileInfoDOS, FileInfoDO::getUnitId,FileInfoDO::getInfraFileId); + List longs = CollectionUtils.convertList(fileInfoDOS, FileInfoDO::getInfraFileId); + + if (!longs.isEmpty()) { + List infraFileInfoDTOS = fileApi.listFile(longs); + + Map longInfraFileInfoDTOMap = CollectionUtils.convertMap(infraFileInfoDTOS, InfraFileInfoDTO::getId); + + for (Map.Entry> entry : stringListMap.entrySet()) { + List list = new ArrayList<>(); + for (Long aLong : entry.getValue()) { + InfraFileInfoDTO infraFileInfoDTO = longInfraFileInfoDTOMap.get(aLong); + if (infraFileInfoDTO != null) { + list.add(infraFileInfoDTO); + } + } + result.put(entry.getKey(),list); + } + + return result; + } + + return result; + } + /** * 根据字典类型和字典数据保存附件信息 *