From 29f5825e22f8ed6cc2019511ad75a4939bafb6a8 Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期六, 06 五月 2023 16:00:35 +0800
Subject: [PATCH] 用户token 过滤链判断限制

---
 emergency/emergency-service/src/main/java/com/gkhy/safePlatform/emergency/service/impl/EmergencySuppliesServiceImpl.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 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..c7ac66d 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,50 @@
         }
     }
 
+    /**
+     * 按照物资类型分类获取列表
+     * @param currentUser
+     * @return
+     */
+    @Override
+    public 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 typeRespDTOList;
+    }
+
+    @Override
+    public List<EmergencySuppliesRespDTO> listCountByIds(ContextCacheUser currentUser, List<Long> ids) {
+        if(null == ids || ids.size() == 0 ){
+            throw new EmergencyException(EmergencyResultCodes.SUPPLIES_PARAM_NULL);
+        }
+        List<EmergencySuppliesInfo> emergencySuppliesInfos = emergencySuppliesInfoService.listCountByIds(ids);
+        List<EmergencySuppliesRespDTO> respDTOList = new ArrayList<>();
+        if(!CollectionUtils.isEmpty(emergencySuppliesInfos)){
+            respDTOList = BeanCopyUtils.copyBeanList(emergencySuppliesInfos,EmergencySuppliesRespDTO.class);
+        }
+        return respDTOList;
+    }
+
     private void deleteEmergencySupplies(Long id) {
         //查询是否存在
         EmergencySuppliesInfoDetailDO emergencySuppliesInfoDetailDO = emergencySuppliesInfoService.selectEmergencySuppliesById(id);
@@ -213,6 +257,8 @@
         }
     }
 
+
+
     /**
      * 验证必填项
      * @return

--
Gitblit v1.9.2