Browse Source

bug修复

linhuili 3 years ago
parent
commit
39c3d98e01

+ 1 - 5
src/main/java/com/persagy/proxy/adm/controller/AdmDictController.java

@@ -7,7 +7,6 @@ import com.persagy.proxy.adm.model.*;
 import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
-import com.persagy.proxy.adm.service.IAdmDictBaseService;
 import com.persagy.proxy.adm.service.IAdmDictService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
@@ -41,9 +40,6 @@ public class AdmDictController {
     @Autowired
     private IAdmDictService service;
 
-    @Autowired
-    private IAdmDictBaseService baseService;
-
     /**
      * 字典类型查询:所有设备类型、部件类型、系统类型、专业类型
      * @param projectId
@@ -93,7 +89,7 @@ public class AdmDictController {
         // 组装上下文条件
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         request.setName(request.getType());
-        return baseService.doQueryObjectInfo(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
+        return service.doQueryObjectInfo(context, request, AdmDictConstant.CLASS_CODE, AdmObjectInfo.class);
     }
 
     /**

+ 0 - 101
src/main/java/com/persagy/proxy/adm/controller/AdmLabslController.java

@@ -1,101 +0,0 @@
-package com.persagy.proxy.adm.controller;
-
-import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.AdmDict;
-import com.persagy.proxy.adm.model.AdmObjectInfo;
-import com.persagy.proxy.adm.model.AdmObjectType;
-import com.persagy.proxy.adm.request.AdmResponse;
-import com.persagy.proxy.adm.service.IAdmLabslService;
-import com.persagy.proxy.common.entity.InstanceUrlParam;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.checkerframework.checker.units.qual.A;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.ws.rs.QueryParam;
-import java.util.List;
-
-/**
- * @ClassName AdmLabslController
- * @Description: 蜡笔森林定制接口
- * @Author linhuili
- * @Date 2021/9/17 20:01
- * @Version V1.0
- **/
-@RestController
-@RequestMapping("/labsl")
-@Slf4j
-public class AdmLabslController {
-
-
-    @Autowired
-    private IAdmLabslService service;
-
-    @Value("${middleware.group.code}")
-    private String groupCode;
-
-    /**
-     * 查询项目下的设备类型
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/category")
-    public AdmResponse queryCategory() throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
-        return service.queryCategory(context, AdmObjectInfo.class);
-    }
-
-
-    /**
-     * 查询项目下的空间类型
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/zone/type")
-    public AdmResponse queryZoneType() throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, AdmCommonConstant.PROJECTID, AdmCommonConstant.APP_ID);
-        return service.queryZoneType(context, AdmObjectInfo.class);
-    }
-
-    /**
-     * 查询项目下的建筑楼层
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/building/floor")
-    public AdmResponse queryBuildFloor(@QueryParam("projectId") String projectId) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.queryBuildFloor(context, AdmObjectInfo.class);
-    }
-
-
-    /**
-     * 查询设备包含设备类型
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/query/equip")
-    public AdmResponse queryEquipType(@QueryParam("projectId") String projectId) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.queryBuildFloor(context, AdmObjectInfo.class);
-    }
-
-
-    /**
-     * 根据设备id统计设备所属的专业
-     * @return
-     * @throws Exception
-     */
-    @PostMapping("/major/category")
-    public AdmResponse queryMajorCategory(@QueryParam("projectId") String projectId,
-                                          @RequestBody List<String> ids) throws Exception {
-        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
-        return service.queryMajorCategory(context, ids , AdmObjectType.class);
-    }
-
-}

+ 0 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmPlanarController.java

@@ -31,8 +31,6 @@ public class AdmPlanarController {
     @Value("${middleware.group.code}")
     private String groupCode;
 
-    @Autowired
-
     /**
      * 查询设备信息
      * @return

+ 0 - 2
src/main/java/com/persagy/proxy/adm/controller/AdmShaftController.java

@@ -52,8 +52,6 @@ public class AdmShaftController {
     private IAdmRelationService relationService;
     @Autowired
     private IAdmBuildingService buildingService;
-    @Autowired
-    private IAdmDictBaseService dictBaseService;
     @Value("${middleware.group.code}")
     private String groupCode;
 

+ 1 - 1
src/main/java/com/persagy/proxy/adm/service/IAdmDictService.java

@@ -17,7 +17,7 @@ import java.util.List;
  * @Date 2021/8/31 14:30
  * @Version V1.0
  **/
-public interface IAdmDictService<T> {
+public interface IAdmDictService<T> extends IAdmDictBaseService<T>{
 
     /**
      * 查询字典分类

+ 1 - 5
src/main/java/com/persagy/proxy/adm/service/IAdmLabslService.java

@@ -1,9 +1,5 @@
 package com.persagy.proxy.adm.service;
 
-import com.persagy.proxy.adm.model.AdmDict;
-import com.persagy.proxy.adm.model.AdmDictQueryCriteria;
-import com.persagy.proxy.adm.model.AdmObjectInfo;
-import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 
@@ -16,7 +12,7 @@ import java.util.List;
  * @Date 2021/9/17 20:01
  * @Version V1.0
  **/
-public interface IAdmLabslService<T> {
+public interface IAdmLabslService<T> extends IAdmDictBaseService<T> {
 
     /**
      * 查询项目下的设备类型

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

@@ -15,6 +15,7 @@ import com.persagy.proxy.adm.service.IAdmDictService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -27,8 +28,8 @@ import java.util.stream.Collectors;
  * @Date 2021/8/31 18:21
  * @Version V1.0
  **/
-@Service
 @Slf4j
+@Service
 public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> implements IAdmDictService<T> {
 
     /**
@@ -281,8 +282,7 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
         AdmQueryCriteria criteria = new AdmQueryCriteria();
 
         StringBuilder filters = new StringBuilder();
-        filters.append("objType in "+ dictTypeList+";");
-        filters.append("category not in " + "category");
+        filters.append("objType in "+ dictTypeList);
         criteria.setFilters(filters.toString());
         return doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
     }

+ 0 - 218
src/main/java/com/persagy/proxy/adm/service/impl/AdmLabslServiceImpl.java

@@ -1,218 +0,0 @@
-package com.persagy.proxy.adm.service.impl;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.StrUtil;
-import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.persagy.dmp.basic.model.QueryCriteria;
-import com.persagy.proxy.adm.constant.AdmDictConstant;
-import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
-import com.persagy.proxy.adm.model.*;
-import com.persagy.proxy.adm.request.AdmCreateRequest;
-import com.persagy.proxy.adm.request.AdmQueryCriteria;
-import com.persagy.proxy.adm.request.AdmResponse;
-import com.persagy.proxy.adm.service.IAdmBuildingService;
-import com.persagy.proxy.adm.service.IAdmDictService;
-import com.persagy.proxy.adm.service.IAdmEquipmentService;
-import com.persagy.proxy.adm.service.IAdmLabslService;
-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.stereotype.Service;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @ClassName AdmLabslServiceImpl
- * @Description: 蜡笔森林定制接口
- * @Author linhuili
- * @Date 2021/9/17 20:01
- * @Version V1.0
- **/
-@Service
-@Slf4j
-public class AdmLabslServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> implements IAdmLabslService<T> {
-
-    @Autowired
-    private IAdmBuildingService buildingService;
-
-    @Autowired
-    private IAdmEquipmentService equipmentService;
-
-    /**
-     * 查询项目下的设备类型
-     * @return
-     * @throws Exception
-     */
-    @Override
-    public AdmResponse queryCategory(InstanceUrlParam context , Class<T> clazz) throws Exception {
-
-        List<AdmObjectInfo> result = new ArrayList<>();
-        QueryCriteria criteria = new QueryCriteria();
-        ObjectNode node = JsonNodeFactory.instance.objectNode();
-        //查询所有的专业
-        node.put("type",AdmDictCategoryEnum.MAJOR.getValue());
-        criteria.setCriteria(node);
-        AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
-
-        if(CollUtil.isNotEmpty(majorResonse.getContent())){
-            List<AdmObjectInfo> content = (List<AdmObjectInfo>) majorResonse.getContent();
-            result.addAll(content);
-        }
-
-        //查询所有的系统,设备类
-        List<String> objTypes = new ArrayList<>();
-        objTypes.add(AdmDictCategoryEnum.SYSTEM.getValue());
-        objTypes.add(AdmDictCategoryEnum.EQUIPMENT.getValue());
-        node.put("objType",objTypes.toString());
-        criteria.setCriteria(node);
-        AdmResponse equipResponse = doQueryObjectType(context, criteria, clazz);
-
-        if(CollUtil.isNotEmpty(equipResponse.getContent())){
-            List<AdmObjectInfo> content = (List<AdmObjectInfo>) equipResponse.getContent();
-            result.addAll(content);
-        }
-        return AdmResponse.success(result);
-    }
-
-    /**
-     * 查询项目下的空间类型
-     * @param context
-     * @param clazz
-     * @return
-     * @throws Exception
-     */
-    @Override
-    public AdmResponse queryZoneType(InstanceUrlParam context, Class<T> clazz) throws Exception {
-        QueryCriteria criteria = new QueryCriteria();
-        ObjectNode node = JsonNodeFactory.instance.objectNode();
-
-        //查询所有的空间类型
-        List<String> objTypes = new ArrayList<>();
-        objTypes.add(AdmDictCategoryEnum.SPACE.getValue());
-        node.put("objType",objTypes.toString());
-        criteria.setCriteria(node);
-        AdmResponse response = doQueryObjectType(context, criteria, clazz);
-
-        List<AdmObjectInfo> content = (List<AdmObjectInfo>) response.getContent();
-        return AdmResponse.success(content);
-    }
-
-    /**
-     * 查询项目下的建筑楼层
-     * @param context
-     * @param clazz
-     * @return
-     * @throws Exception
-     */
-    @Override
-    public AdmResponse queryBuildFloor(InstanceUrlParam context, Class<T> clazz) throws Exception {
-        List<AdmBuilding> admBuildings = new ArrayList<>();
-        //添加未明确建筑
-        AdmBuilding admBuilding = new AdmBuilding();
-        admBuilding.setId("fisnull");
-        admBuilding.setName("未明确建筑");
-        admBuilding.setLocalName("未明确建筑");
-
-        //添加未明确楼层
-        ArrayList<AdmFloor> admFloors = new ArrayList<>();
-        AdmFloor admFloor = new AdmFloor();
-        admFloor.setId("fisnull");
-        admFloor.setName("未明确楼层");
-        admFloor.setLocalName("未明确楼层");
-        admFloors.add(admFloor);
-
-        //获取项目下的建筑,建筑下的楼层
-        AdmQueryCriteria request = new AdmQueryCriteria();
-        request.setName(AdmBuilding.OBJ_TYPE);
-
-        //设置建筑->楼层级联查询参数
-        AdmQueryCriteria cascade = new AdmQueryCriteria();
-        cascade.setName(AdmFloor.OBJ_TYPE);
-        List<AdmQueryCriteria> cascadeList = new ArrayList<>();
-        cascadeList.add(cascade);
-        request.setCascade(cascadeList);
-
-        AdmResponse buildResponse = buildingService.doQuery(context, request, AdmBuilding.class);
-        if(CollUtil.isEmpty(buildResponse.getContent())){
-            admBuildings.add(admBuilding);
-            return AdmResponse.success((List<JSONObject>)admBuilding);
-        }
-
-        //建筑下的楼层添加默认"未明确楼层"
-        List<AdmBuilding> buildContent = (List<AdmBuilding>)buildResponse.getContent();
-        buildContent.add(admBuilding);
-        for (AdmBuilding building : buildContent) {
-            List<AdmFloor> floor = building.getFloor();
-            floor.add(admFloor);
-        }
-        return AdmResponse.success(buildContent);
-    }
-
-    /**
-     * 根据设备id统计设备所属的专业
-     * @param context
-     * @param ids
-     * @param clazz
-     * @return
-     * @throws Exception
-     */
-    @Override
-    public AdmResponse queryMajorCategory(InstanceUrlParam context, List<String> ids, Class<T> clazz) throws Exception {
-
-        //根据id查询对应的设备类型
-        AdmQueryCriteria request = new AdmQueryCriteria();
-        request.setName(AdmEquipment.OBJ_TYPE);
-        request.setFilters("id in " + ids);
-        AdmResponse equipResponse = equipmentService.doQuery(context, request, AdmEquipment.class);
-        if(CollUtil.isEmpty(equipResponse.getContent())){
-            throw new Exception("设备不存在");
-        }
-        List<AdmEquipment> equipments = (List<AdmEquipment>)equipResponse.getContent();
-        Set<String> classCodes = equipments.stream().map(k -> k.getClassCode()).collect(Collectors.toSet());
-
-        //根据设备类型查询设备所属专业
-        QueryCriteria dictCriteria = new QueryCriteria();
-        ObjectNode node = JsonNodeFactory.instance.objectNode();
-        node.put("code",classCodes.toString());
-        dictCriteria.setCriteria(node);
-        AdmResponse dictResponse = doQueryObjectType(context, dictCriteria, clazz);
-        if(CollUtil.isEmpty(dictResponse.getContent())){
-            throw new Exception("项目下没有设备类型");
-        }
-
-        //获取设备类对应的专业编码
-        List<AdmObjectType> classCodeList = (List<AdmObjectType>)dictResponse.getContent();
-        Map<String, List<AdmObjectType>> classCodeMap = classCodeList.stream().collect(Collectors.groupingBy(k->k.getMajorCode()));
-
-        Set<String> majors = classCodeList.stream().map(k -> k.getMajorCode()).collect(Collectors.toSet());
-        if(CollUtil.isEmpty(majors)){
-            return AdmResponse.success(new ArrayList<>());
-        }
-
-        //查询字典中的专业
-        QueryCriteria criteria = new QueryCriteria();
-        ObjectNode majorNode = JsonNodeFactory.instance.objectNode();
-        majorNode.put("type",AdmDictCategoryEnum.MAJOR.getValue());
-        criteria.setCriteria(majorNode);
-        AdmResponse majorResonse = doQueryDictData(context, criteria, clazz);
-        List<AdmObjectType> dictMajorList = (List<AdmObjectType>)majorResonse.getContent();
-        Map<String, List<AdmObjectType>> dictMajorMap = dictMajorList.stream().collect(Collectors.groupingBy(k->k.getCode()));
-
-        List<AdmObjectType> result = new ArrayList<>();
-        //组装成专业-设备类返回结果
-        for (String major : majors) {
-            List<AdmObjectType> objectTypes = dictMajorMap.get(major);
-            if(CollUtil.isNotEmpty(objectTypes)){
-                AdmObjectType objectType = objectTypes.get(0);
-                objectType.setChildren(classCodeMap.get(major));
-                result.add(objectType);
-            }
-        }
-        return AdmResponse.success(result);
-    }
-
-}