From f600f38c6c23a282b61ed4db1b2da094d695276f Mon Sep 17 00:00:00 2001 From: zhangfeng <1603559716@qq.com> Date: 星期五, 25 十一月 2022 16:43:52 +0800 Subject: [PATCH] 安全物资和设备管理调整 --- equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/MaterialClassifyServiceImpl.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/MaterialClassifyServiceImpl.java b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/MaterialClassifyServiceImpl.java index c4a001d..735b542 100644 --- a/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/MaterialClassifyServiceImpl.java +++ b/equipment/equipment-service/src/main/java/com/gkhy/safePlatform/equipment/service/impl/MaterialClassifyServiceImpl.java @@ -1,12 +1,17 @@ package com.gkhy.safePlatform.equipment.service.impl; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gkhy.safePlatform.commons.co.ContextCacheUser; import com.gkhy.safePlatform.commons.enums.ResultCodes; +import com.gkhy.safePlatform.commons.query.PageQuery; +import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; import com.gkhy.safePlatform.commons.vo.ResultVO; +import com.gkhy.safePlatform.commons.vo.SearchResultVO; import com.gkhy.safePlatform.equipment.entity.SafeMaterialClassifyDO; import com.gkhy.safePlatform.equipment.entity.SafeMaterialClassifyInfo; import com.gkhy.safePlatform.equipment.enums.EquipmentResultCodes; import com.gkhy.safePlatform.equipment.excepiton.EquipmentException; +import com.gkhy.safePlatform.equipment.model.dto.req.MaterialClassifyQuery; import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialClassifyAddReq; import com.gkhy.safePlatform.equipment.model.dto.req.SafeMaterialClassifyModReq; import com.gkhy.safePlatform.equipment.model.dto.resp.SafeMaterialClassifyDto; @@ -200,5 +205,38 @@ return safeMaterialClassifyInfoService.getTraceabilityClassifyList(smallClassifyIds); } + @Override + public SearchResultVO<List<SafeMaterialClassifyDto>> listByPage(PageQuery<MaterialClassifyQuery> pageQuery) { + Page<SafeMaterialClassifyInfo> page = new Page<>(pageQuery.getPageIndex(),pageQuery.getPageSize()); + List<SafeMaterialClassifyInfo> classifyInfoList = safeMaterialClassifyInfoService.listByPage(page, pageQuery.getSearchParams()); + List<SafeMaterialClassifyInfo> childList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(classifyInfoList)) { + List<Long> parentIdList = classifyInfoList.stream().map(SafeMaterialClassifyInfo::getId).collect(Collectors.toList()); + childList = safeMaterialClassifyInfoService.getListByParentIds(parentIdList); + } + List<SafeMaterialClassifyDto> respList = new ArrayList<>(); + for(SafeMaterialClassifyInfo classifyInfo:classifyInfoList){ + SafeMaterialClassifyDto classifyDto = new SafeMaterialClassifyDto(); + classifyDto.setId(classifyInfo.getId()); + classifyDto.setMaterialClassifyName(classifyInfo.getMaterialClassifyName()); + classifyDto.setParentId(classifyInfo.getParentId()); + //获取子级 + List<SafeMaterialClassifyInfo> selectList = childList.stream().filter(cl -> cl.getParentId().equals(classifyInfo.getId())).collect(Collectors.toList()); + List<SafeMaterialClassifyDto> childRespList = new ArrayList<>(); + if(selectList.size()>0){ + childRespList = BeanCopyUtils.copyBeanList(selectList,SafeMaterialClassifyDto.class); + } + classifyDto.setChildList(childRespList); + respList.add(classifyDto); + } + return new SearchResultVO<>(true, + page.getCurrent(), + page.getSize(), + page.getPages(), + page.getTotal(), + respList, + ResultCodes.OK); + } + } -- Gitblit v1.9.2