Browse Source

Merge remote-tracking branch 'origin/develop' into develop

lijie 3 years ago
parent
commit
7602ca9cf1

+ 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)){

+ 32 - 3
src/main/java/com/persagy/proxy/adm/controller/AdmEquipmentController.java

@@ -9,8 +9,10 @@ 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.IAdmEquipmentService;
+import com.persagy.proxy.adm.service.IAdmRelationService;
 import com.persagy.proxy.adm.utils.AdmContextUtil;
 import com.persagy.proxy.adm.utils.ObjectNameUtil;
+import com.persagy.proxy.common.entity.RelationDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -28,6 +30,8 @@ import java.util.List;
 public class AdmEquipmentController {
     @Autowired
     private IAdmEquipmentService service;
+    @Autowired
+    private IAdmRelationService relationService;
 
     /**
      * 统计
@@ -175,7 +179,7 @@ public class AdmEquipmentController {
      */
     @PostMapping("/creat-equip-pro")
     public AdmResponse createExt(@RequestBody AdmCreateRequest<AdmEquipment> admEquipment) throws Exception {
-        List<AdmEquipment> vos = CollUtil.newArrayList(admEquipment.getContent());
+        List<AdmEquipment> vos = admEquipment.getContent();
         if(CollUtil.isEmpty(vos)){
             return AdmResponse.success();
         }
@@ -185,8 +189,33 @@ public class AdmEquipmentController {
                 equipment.setName(ObjectNameUtil.objectName("设备-"));
             }
         });
-        vos = service.doInsertExt(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
-        return AdmResponse.success(vos);
+        List<AdmEquipment> reVos = new ArrayList<>(vos.size());
+        List<RelationDTO> relationDTOS = new ArrayList<>(16);
+        vos.stream().forEach(admEq -> {
+            //创建设备
+            List<AdmEquipment> vosR = service.doInsert(AdmContextUtil.toDmpContext(), AdmEquipment.class, CollUtil.newArrayList(admEq));
+            //TODO 创建资产
+            //添加设备和系统、建筑、楼层的关系
+            if(CollUtil.isNotEmpty(vosR)){
+                String equipId = vosR.get(0).getId();
+                if(StrUtil.isNotEmpty(equipId)){
+                    if(CollUtil.isNotEmpty(admEq.getLinkSystem())){
+                        admEq.getLinkSystem().stream().forEach(admSystem -> {
+                            relationDTOS.add(new RelationDTO(null, "MechSubset", "Sy2Eq", null , admSystem.getId(), equipId));
+                        });
+                    }
+                    if(StrUtil.isNotEmpty(admEq.getBuildingId())){
+                        relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Bd", null , equipId, admEq.getBuildingId()));
+                    }
+                    if(StrUtil.isNotEmpty(admEq.getFloorId())){
+                        relationDTOS.add(new RelationDTO(null, "MechInArch", "Eq2Fl", null , equipId, admEq.getBuildingId()));
+                    }
+                }
+            }
+            reVos.addAll(vosR);
+        });
+        relationService.doSave(AdmContextUtil.toDmpContext(),relationDTOS);
+        return AdmResponse.success(reVos);
     }
 
 

+ 88 - 9
src/main/java/com/persagy/proxy/adm/controller/AdmSpaceInfoController.java

@@ -1,15 +1,23 @@
 package com.persagy.proxy.adm.controller;
 
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
+import cn.hutool.core.util.StrUtil;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.common.constant.ResponseCode;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmSystem;
+import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
-
+import com.persagy.proxy.adm.service.*;
+import com.persagy.proxy.adm.utils.AdmContextUtil;
 import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.QueryParam;
 
 /**
  * 
@@ -20,20 +28,30 @@ import lombok.RequiredArgsConstructor;
  */
 @RestController
 @RequiredArgsConstructor
+@RequestMapping("/space")
 public class AdmSpaceInfoController {
 
 	public static final String EXPORT_SHEET_NAME = "关系维护";
 
 	@Value("${middleware.group.code}")
 	private String defaultCode;
-
+	@Autowired
+	private IAdmSpaceService spaceService;
+	@Autowired
+	private IAdmSystemService systemService;
+	@Autowired
+	private IAdmEquipmentService equipmentService;
+	@Autowired
+	private IAdmRelationService relationService;
+	@Autowired
+	private IAdmFloorService floorService;
 	/**
 	 * 统计 属于多建筑楼层的空间
 	 * 
 	 * @param request
 	 * @return
 	 */
-	@RequestMapping("/space/space-bd-fl")
+	@RequestMapping("/space-bd-fl")
 	public AdmResponse queryCount(HttpServletRequest request) {
 		String groupCode = request.getHeader(AdmCommonConstant.GROUP_CODE_HEADER);
 		String projectId = request.getHeader(AdmCommonConstant.PROJECT_ID_HEADER);
@@ -42,4 +60,65 @@ public class AdmSpaceInfoController {
 		return response;
 	}
 
+	/**
+	 * 查询没有和当前空间绑定的系统
+	 *  description= "例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " + "spaceId 为当前空间id type为当前空间类型 "
+	 * @param   type        空间类型  空间id确定,空间类型一定确定,此参数可以不用
+	 * @param   spaceId     空间id
+	 *
+	 * @author lxy
+	 */
+	@RequestMapping("/unspace-in-sys")
+	public AdmResponse unSpaceSys(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request){
+		//sy2sp
+		ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
+		relationFrom.put("relCode", "Sy2Sp");
+		relationFrom.put("graphCode", "MechInArch");
+		relationFrom.put("objTo", spaceId);
+		relationFrom.put("$bindFlag",false);
+		request.setRelationFrom(relationFrom);
+		request.setName(AdmSystem.OBJ_TYPE);
+		return systemService.doQuery(AdmContextUtil.toDmpContext(),request, AdmSystem.class);
+	}
+
+	/**
+	 * 查询没有和当前空间绑定的设备
+	 * description ="例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 " + "spaceId 为当前空间id type为当前空间类型 "
+	 * @return
+	 */
+	@PostMapping("/unspace-in-eq")
+	public AdmResponse unSpaceEq(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
+		return unSpaceEq(type, spaceId, request, "MechInArch");
+	}
+
+	/**
+	 * 空间内没有服务于当前空间的设备
+	 */
+	@PostMapping("/unspace-for-eq-point")
+	public AdmResponse unSpaceForEqPoint(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
+		return unSpaceEq(type, spaceId, request, "MechForArch");
+	}
+
+	/**
+	 * 空间内没有和空间关联的设备
+	 */
+	@PostMapping("/unspace-fIn-eq-point")
+	public AdmResponse unSpaceInEqPoint(@QueryParam("type") String type, @QueryParam("spaceId") String spaceId, @RequestBody AdmQueryCriteria request) {
+		return unSpaceEq(type, spaceId, request, "MechInArch");
+	}
+
+
+	private AdmResponse unSpaceEq(String type, String spaceId, AdmQueryCriteria request, String graphCode) {
+		if (StrUtil.isBlank(spaceId)) {
+			return AdmResponse.failure(ResponseCode.A0400.getDesc() + "空间id为空");
+		}
+		request.setName(AdmEquipment.OBJ_TYPE);
+		ObjectNode relationFrom = JsonNodeFactory.instance.objectNode();
+		relationFrom.put("relCode", "Eq2Sp");
+		relationFrom.put("graphCode", graphCode);
+		relationFrom.put("objTo", spaceId);
+		relationFrom.put("$bindFlag", false);
+		request.setRelationFrom(relationFrom);
+		return equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
+	}
 }

+ 0 - 2
src/main/java/com/persagy/proxy/adm/service/IAdmEquipmentService.java

@@ -39,8 +39,6 @@ public interface IAdmEquipmentService extends IAdmBaseService<AdmEquipment>{
      */
     @Deprecated
     void doDeleteEuip(InstanceUrlParam context, List<AdmEquipment> voList);
-    @Deprecated
-    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList);
 
     /**
      * 补充设备类型属性

+ 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();
 
         //采集值配置查询

+ 4 - 8
src/main/java/com/persagy/proxy/adm/service/impl/AdmEquipmentServiceImpl.java

@@ -15,7 +15,10 @@ import com.persagy.dmp.define.entity.ObjectTypeDefine;
 import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
-import com.persagy.proxy.adm.model.*;
+import com.persagy.proxy.adm.model.AdmDict;
+import com.persagy.proxy.adm.model.AdmEquipment;
+import com.persagy.proxy.adm.model.AdmObjectType;
+import com.persagy.proxy.adm.model.AdmProperty;
 import com.persagy.proxy.adm.request.AdmQueryCriteria;
 import com.persagy.proxy.adm.request.AdmResponse;
 import com.persagy.proxy.adm.service.IAdmComAndEquipService;
@@ -162,13 +165,6 @@ public class AdmEquipmentServiceImpl extends AbstractAdmBaseServiceImpl<AdmEquip
         }
     }
 
-    @Override
-    public List<AdmEquipment> doInsertExt(InstanceUrlParam context, Class<AdmEquipment> clazz, List<AdmEquipment> voList) {
-        List<AdmEquipment> vos = doInsert(context, AdmEquipment.class, voList);
-        //TODO 创建资产
-        //TODO 创建设备和系统关系 systemList
-        return vos;
-    }
     private DmpResult<List<ObjRelationDTO>> queryRelation(InstanceUrlParam context, Map<String, AdmEquipment> voMap){
         QueryCriteria dmpRequest = new QueryCriteria();
         ObjectNode criteria = JsonNodeFactory.instance.objectNode();