浏览代码

解决lambda排序问题

yucheng 3 年之前
父节点
当前提交
342fd2358d

+ 9 - 21
src/main/java/com/persagy/proxy/adm/controller/AdmDictController.java

@@ -2,7 +2,6 @@ package com.persagy.proxy.adm.controller;
 
 import cn.hutool.core.collection.CollUtil;
 import com.persagy.dmp.define.entity.ObjectInfoCollect;
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmDictConstant;
 import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
 import com.persagy.proxy.adm.model.*;
@@ -15,10 +14,8 @@ import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.*;
 
-import javax.ws.rs.QueryParam;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -45,8 +42,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/category")
-    public AdmResponse queryCategory(@QueryParam("projectId") String projectId,
-                                     @RequestBody AdmDict request) throws Exception {
+    public AdmResponse queryCategory(@RequestBody AdmDict request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(StringUtils.isEmpty(request.getType())){
@@ -64,8 +60,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/dict-batch")
-    public AdmResponse dictBatch(@QueryParam("projectId") String projectId,
-                                     @RequestBody AdmCreateRequest<AdmDictBatch> request) throws Exception {
+    public AdmResponse dictBatch( @RequestBody AdmCreateRequest<AdmDictBatch> request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         //方案设定:方案id :全新设定(schemeZero)、方案1(schemeOne)、方案2(schemeTwo),
@@ -81,8 +76,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/query")
-    public AdmResponse query(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmDictQueryCriteria request) throws Exception {
+    public AdmResponse query(@RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setName(request.getType());
@@ -98,8 +92,7 @@ public class AdmDictController {
      */
     @PostMapping("/family/query")
     @Deprecated
-    public AdmResponse familyQuery(@QueryParam("projectId") String projectId,
-                             @RequestBody AdmQueryCriteria request) throws Exception {
+    public AdmResponse familyQuery(@RequestBody AdmQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return AdmResponse.success(new ArrayList<>());
@@ -113,8 +106,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/reset-dic")
-    public AdmResponse resetDic(@QueryParam("projectId") String projectId,
-                                   @RequestBody AdmDictQueryCriteria request) throws Exception {
+    public AdmResponse resetDic(@RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.resetDic(context,request,null,AdmObjectInfo.class);
@@ -129,8 +121,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/reset-type")
-    public AdmResponse resetType(@QueryParam("projectId") String projectId,
-                                @RequestBody AdmDictQueryCriteria request) throws Exception {
+    public AdmResponse resetType(@RequestBody AdmDictQueryCriteria request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(StringUtils.isEmpty(request.getType())){
@@ -148,8 +139,7 @@ public class AdmDictController {
      * @throws Exception
      */
     @PostMapping("/setting-dic-project")
-    public AdmResponse settingDicProject(@QueryParam("projectId") String projectId,
-                                 @RequestBody AdmCreateRequest<AdmDefFuncIdGather> request) throws Exception {
+    public AdmResponse settingDicProject(@RequestBody AdmCreateRequest<AdmDefFuncIdGather> request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         return service.settingDicProject(context,request, ObjectInfoCollect.class);
@@ -164,8 +154,7 @@ public class AdmDictController {
      */
     @PostMapping("/system/equip/category")
     @Deprecated
-    public AdmResponse querySystemEquipCategory(@QueryParam("projectId") String projectId,
-                                 @RequestBody AdmDict request) throws Exception {
+    public AdmResponse querySystemEquipCategory(@RequestBody AdmDict request) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         request.setType(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue());
@@ -181,8 +170,7 @@ public class AdmDictController {
      */
     @PostMapping("/morl/query")
     @Deprecated
-    public AdmResponse queryMorlDict(@QueryParam("projectId") String projectId,
-                                                @RequestBody List<String> dictTypeList) throws Exception {
+    public AdmResponse queryMorlDict(@RequestBody List<String> dictTypeList) throws Exception {
         // 组装上下文条件
         InstanceUrlParam context = AdmContextUtil.toDmpContext();
         if(CollUtil.isEmpty(dictTypeList)){

+ 18 - 12
src/main/java/com/persagy/proxy/adm/service/impl/AdmDictServiceImpl.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.adm.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 import com.fasterxml.jackson.databind.node.JsonNodeFactory;
@@ -19,10 +20,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -360,16 +358,24 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
         admObjectInfos = sortFuncidForEdit(admObjectInfos);
         //查询平台级信息点采集信息
         List<ObjectInfoCollect> commonObjectInfoCollect = queryObjectInfoCollect(context, "common", request.getType(), clazz);
-        Map<String, Boolean> commonObjectInfoCollectMap = commonObjectInfoCollect.stream().filter(item ->
-                StrUtil.isNotEmpty(item.getDefineInfoId())).collect(
-                        Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable,(k1,k2)->k1));
-
+        Map<String, Boolean> commonObjectInfoCollectMap = new HashMap<>();
+        for(int i = 0,j = CollUtil.size(commonObjectInfoCollect);i < j;i++) {
+            ObjectInfoCollect collect = commonObjectInfoCollect.get(i);
+            if(StrUtil.isBlank(collect.getDefineInfoId())) {
+                continue;
+            }
+            commonObjectInfoCollectMap.put(collect.getDefineInfoId(), BooleanUtil.isTrue(collect.getVisiable()));
+        }
         //查询项目级信息点采集信息
         List<ObjectInfoCollect> projectObjectInfoCollect = queryObjectInfoCollect(context, "project", request.getType(), clazz);
-        Map<String, Boolean> projectObjectInfoCollectMap = projectObjectInfoCollect.stream().filter(item ->
-                StrUtil.isNotEmpty(item.getDefineInfoId())).collect(
-                        Collectors.toMap(ObjectInfoCollect::getDefineInfoId,ObjectInfoCollect::getVisiable,(k1,k2)->k1));
-
+        Map<String, Boolean> projectObjectInfoCollectMap  = new HashMap<>();
+        for(int i = 0,j = CollUtil.size(projectObjectInfoCollect);i < j;i++) {
+            ObjectInfoCollect collect = projectObjectInfoCollect.get(i);
+            if(StrUtil.isBlank(collect.getDefineInfoId())) {
+                continue;
+            }
+            projectObjectInfoCollectMap.put(collect.getDefineInfoId(), BooleanUtil.isTrue(collect.getVisiable()));
+        }
         String dictType = request.getDictType();
 
         //采集值配置查询