From 17f8dd032fc267b38cdddc88de416aeab2600f90 Mon Sep 17 00:00:00 2001 From: zhangfeng <1603559716@qq.com> Date: 星期三, 21 九月 2022 14:38:23 +0800 Subject: [PATCH] 根据物资类型分类-应急物资列表 --- emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java | 39 +++++++++++++++++++++++++++++++++++---- 1 files changed, 35 insertions(+), 4 deletions(-) diff --git a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java index 442af4e..c33c62e 100644 --- a/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java +++ b/emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java @@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService; import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepInfoRPCRespDTO; +import com.gkhy.safePlatform.commons.co.ContextCacheUser; +import com.gkhy.safePlatform.commons.enums.E; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.query.PageQuery; import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; @@ -28,10 +30,8 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.stream.Collectors; @Service("emergencySuppliesService") public class EmergencySuppliesServiceImpl implements EmergencySuppliesService { @@ -196,6 +196,37 @@ } } + /** + * 按照物资类型分类获取列表 + * @param currentUser + * @return + */ + @Override + public ResultVO<List<EmergencySuppliesTypeRespDTO>> emergencySuppliesList(ContextCacheUser currentUser) { + + List<EmergencySuppliesInfo> emergencySuppliesInfoList = emergencySuppliesInfoService.listByNoConditions(); + List<EmergencySuppliesTypeRespDTO> typeRespDTOList = new ArrayList<>(); + for (EmergencySuppliesClassificationEnum teamLevelEnum : EmergencySuppliesClassificationEnum.values()) { + EmergencySuppliesTypeRespDTO typeRespDTO = new EmergencySuppliesTypeRespDTO(); + typeRespDTO.setMaterialType(teamLevelEnum.getCode()); + typeRespDTO.setMaterialTypeName(teamLevelEnum.getValue()); + List<EmergencySuppliesRespDTO> respDTOList = new ArrayList<>(); + List<EmergencySuppliesInfo> collect = emergencySuppliesInfoList.stream().filter(item -> item.getClassification().equals(teamLevelEnum.getCode())).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(collect)){ + for (EmergencySuppliesInfo info : collect) { + EmergencySuppliesRespDTO respDTO = new EmergencySuppliesRespDTO(); + BeanUtils.copyProperties(info,respDTO); + respDTO.setMaterialType(info.getClassification()); + respDTO.setMaterialTypeName(teamLevelEnum.getValue()); + respDTOList.add(respDTO); + } + } + typeRespDTO.setList(respDTOList); + typeRespDTOList.add(typeRespDTO); + } + return new ResultVO<>(ResultCodes.OK,typeRespDTOList); + } + private void deleteEmergencySupplies(Long id) { //查询是否存在 EmergencySuppliesInfoDetailDO emergencySuppliesInfoDetailDO = emergencySuppliesInfoService.selectEmergencySuppliesById(id); -- Gitblit v1.9.2