Ver código fonte

Labsl定制接口开发

linhuili 3 anos atrás
pai
commit
39b85f9733

+ 3 - 0
src/main/java/com/persagy/proxy/adm/constant/AdmCommonConstant.java

@@ -21,6 +21,9 @@ public interface AdmCommonConstant {
     
     /** 默认的userId */
     String USER_ID = "systemId";
+
+    /** 默认项目id */
+    String PROJECTID = "system";
     
     /** 集团编码 header key*/
     String GROUP_CODE_HEADER = "groupCode";

+ 46 - 0
src/main/java/com/persagy/proxy/adm/controller/AdmDictController.java

@@ -1,5 +1,6 @@
 package com.persagy.proxy.adm.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
 import com.persagy.proxy.adm.constant.AdmDictConstant;
 import com.persagy.proxy.adm.model.*;
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.ws.rs.QueryParam;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @ClassName AdmDictController
@@ -175,4 +177,48 @@ public class AdmDictController {
         InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
         return AdmResponse.success(new ArrayList<>());
     }
+
+    /**
+     * 查询类型下所有字典信息 M 和 L 类型,包括自定义信息点
+     * @param projectId
+     * @param dictTypeList
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/morl/query")
+    @Deprecated
+    public AdmResponse queryMorlDict(@QueryParam("projectId") String projectId,
+                                                @RequestBody List<String> dictTypeList) throws Exception {
+        // 组装上下文条件
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        if(CollUtil.isEmpty(dictTypeList)){
+            return AdmResponse.success(new ArrayList<>());
+        }
+        //查询指定类型下的信息点
+        return service.queryMorlDict(context,dictTypeList);
+    }
+
+    /**
+     * 获取不能同步到物理世界对象的数量
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/data-count")
+    @Deprecated
+    public AdmResponse queryNotSyncDmpObjects(@RequestBody AdmDictQueryCriteria request) throws Exception {
+        return AdmResponse.success(new ArrayList<>());
+    }
+
+    /**
+     * 需采集信息同步到所有项目
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/syn-dic-project")
+    @Deprecated
+    public AdmResponse syncProjectObjectInfo() throws Exception {
+        return AdmResponse.success(new ArrayList<>());
+    }
+
 }

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

@@ -0,0 +1,101 @@
+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);
+    }
+
+}

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

@@ -0,0 +1,48 @@
+package com.persagy.proxy.adm.controller;
+
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmObjectType;
+import com.persagy.proxy.adm.request.AdmResponse;
+import com.persagy.proxy.common.entity.InstanceUrlParam;
+import lombok.extern.slf4j.Slf4j;
+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.ArrayList;
+import java.util.List;
+
+/**
+ * @ClassName AdmLabslController
+ * @Description: 平面图接口
+ * @Author linhuili
+ * @Date 2021/9/18 13:01
+ * @Version V1.0
+ **/
+@RestController
+@RequestMapping("/planar")
+@Slf4j
+public class AdmPlanarController {
+
+    @Value("${middleware.group.code}")
+    private String groupCode;
+
+    @Autowired
+
+    /**
+     * 查询设备信息
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/equip")
+    public AdmResponse queryEquip(@QueryParam("projectId") String projectId,
+                                          @RequestBody List<String> ids) throws Exception {
+        InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
+        //
+        return AdmResponse.success(new ArrayList<>());
+    }
+}

+ 10 - 0
src/main/java/com/persagy/proxy/adm/model/AdmEquipTypeLabsl.java

@@ -0,0 +1,10 @@
+package com.persagy.proxy.adm.model;
+
+import lombok.Data;
+
+@Data
+public class AdmEquipTypeLabsl {
+    /** 类型名称 */
+    private String codeName;
+
+}

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

@@ -8,6 +8,8 @@ import com.persagy.proxy.adm.request.AdmCreateRequest;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
 
+import java.util.List;
+
 /**
  * @ClassName IAdmDictService
  * @Description: 字典查询
@@ -46,4 +48,12 @@ public interface IAdmDictService<T> {
      */
     AdmResponse settingDicProject(InstanceUrlParam context , AdmCreateRequest<AdmObjectInfo> request, Class<T> clazz) throws Exception;
 
+
+    /**
+     * 查询所有字典信息 M 和 L 类型,包括自定义信息点
+     * @param context
+     * @param dictTypeList
+     * @return
+     */
+    AdmResponse queryMorlDict(InstanceUrlParam context,List<String> dictTypeList);
 }

+ 51 - 0
src/main/java/com/persagy/proxy/adm/service/IAdmLabslService.java

@@ -0,0 +1,51 @@
+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;
+
+import java.util.List;
+
+/**
+ * @ClassName IAdmLabslService
+ * @Description: 蜡笔森林定制接口
+ * @Author linhuili
+ * @Date 2021/9/17 20:01
+ * @Version V1.0
+ **/
+public interface IAdmLabslService<T> {
+
+    /**
+     * 查询项目下的设备类型
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryCategory(InstanceUrlParam context , Class<T> clazz) throws Exception;
+
+    /**
+     * 查询项目下的空间类型
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryZoneType(InstanceUrlParam context , Class<T> clazz) throws Exception;
+
+    /**
+     * 查询项目下的建筑楼层
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryBuildFloor(InstanceUrlParam context , Class<T> clazz) throws Exception;
+
+    /**
+     * 根据设备id统计设备所属的专业
+     * @param context
+     * @param ids
+     * @param clazz
+     * @return
+     * @throws Exception
+     */
+    AdmResponse queryMajorCategory(InstanceUrlParam context ,List<String> ids , Class<T> clazz) throws Exception;
+}

+ 1 - 0
src/main/java/com/persagy/proxy/adm/service/impl/AbstractAdmDictBaseServiceImpl.java

@@ -26,6 +26,7 @@ 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.io.IOException;
 import java.util.ArrayList;

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

@@ -5,9 +5,11 @@ import cn.hutool.core.collection.CollUtil;
 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.IAdmDictService;
 import com.persagy.proxy.common.entity.InstanceUrlParam;
@@ -268,6 +270,24 @@ public class AdmDictServiceImpl<T> extends AbstractAdmDictBaseServiceImpl<T> imp
     }
 
     /**
+     * 查询所有字典信息 M 和 L 类型,包括自定义信息点
+     * @param context
+     * @param dictTypeList
+     * @return
+     */
+    @Override
+    public AdmResponse queryMorlDict(InstanceUrlParam context, List<String> dictTypeList) {
+
+        AdmQueryCriteria criteria = new AdmQueryCriteria();
+
+        StringBuilder filters = new StringBuilder();
+        filters.append("objType in "+ dictTypeList+";");
+        filters.append("category not in " + "category");
+        criteria.setFilters(filters.toString());
+        return doQueryObjectInfo(context, criteria, AdmDictConstant.CLASS_CODE, (Class<T>) AdmObjectInfo.class);
+    }
+
+    /**
      * 信息点转换为中台格式
      * @param content
      * @param dmpObjectInfos

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

@@ -0,0 +1,218 @@
+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);
+    }
+
+}

+ 0 - 1
src/main/java/com/persagy/proxy/adm/service/impl/AdmManualRelCalServiceImpl.java

@@ -7,7 +7,6 @@ import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.common.context.AppContext;
 import com.persagy.dmp.common.model.response.CommonResult;
 import com.persagy.dmp.digital.client.DigitalObjectClient;
-import com.persagy.dmp.digital.client.DigitalObjectFacade;
 import com.persagy.dmp.digital.client.DigitalRelationCaclClient;
 import com.persagy.dmp.digital.entity.ObjectDigital;
 import com.persagy.dmp.digital.entity.ObjectRelation;