Kaynağa Gözat

新增默认关系处理类

zhangqiankun 3 yıl önce
ebeveyn
işleme
2caa70b243
24 değiştirilmiş dosya ile 225 ekleme ve 51 silme
  1. 3 0
      src/main/java/com/persagy/proxy/adm/constant/AdmRelationType.java
  2. 3 3
      src/main/java/com/persagy/proxy/adm/handler/RelationReportHandler.java
  3. 4 4
      src/main/java/com/persagy/proxy/adm/handler/SpaceRelationInfoHandler.java
  4. 32 13
      src/main/java/com/persagy/proxy/adm/strategy/RelationObjectContext.java
  5. 40 3
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/AbstractRelationObject.java
  6. 29 4
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/AbstractReportRelationObject.java
  7. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkMixMechRelationObject.java
  8. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkNaturalRelationObject.java
  9. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkOnewayMechRelationObject.java
  10. 82 0
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/DeafultRelationObject.java
  11. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerEqBackupRelationObject.java
  12. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerEqNormalRelationObject.java
  13. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerSyBackupRelationObject.java
  14. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerSyNormalRelationObject.java
  15. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/RadiationNetworkConnectRelationObject.java
  16. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/RadiationNetworkTransparentRelationObject.java
  17. 6 4
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/RelationObjectStrategy.java
  18. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2EqRelationObject.java
  19. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2SpRelationObject.java
  20. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2SyRelationObject.java
  21. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkFFCloseRelationObject.java
  22. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkFFOpenRelationObject.java
  23. 1 1
      src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkNormalRelationObject.java
  24. 11 5
      src/main/java/com/persagy/proxy/report/controller/RelationReportController.java

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

@@ -10,6 +10,9 @@ package com.persagy.proxy.adm.constant;
  */
 public interface AdmRelationType {
 
+	/** 默认的处理类 */
+	String DEFAULT_RELATION_OBJECT = "deafultRelationObject";
+	
 	/** MECHINARCH_EQ2BD  设备所在建筑*/
 	String MECHINARCH_EQ2BD = "MechInArch_Eq2Bd";
 	

+ 3 - 3
src/main/java/com/persagy/proxy/adm/handler/RelationReportHandler.java

@@ -388,7 +388,7 @@ public class RelationReportHandler {
 		/** key: 建筑ID,value: 建筑名称 */
 		Map<String, String> buildNameTemp = new HashMap<String, String>();
 		String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Bd.name();
-		List<ObjectDigital> buildDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null);
+		List<ObjectDigital> buildDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null, null);
 		if (CollectionUtil.isNotEmpty(buildDigitals)) {
 			for (ObjectDigital master : buildDigitals) {
 				List<ObjectDigital> slaveDigitals = master.getRelObjs();
@@ -547,7 +547,7 @@ public class RelationReportHandler {
 	private void findBuildingName(Map<String, String> buildNameTemp, String groupCode, String projectId) {
 		// 获取建筑名称
 		String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Bd.name();
-		List<ObjectDigital> buildDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null);
+		List<ObjectDigital> buildDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null, null);
 		if (CollectionUtil.isNotEmpty(buildDigitals)) {
 			for (ObjectDigital master : buildDigitals) {
 				List<ObjectDigital> slaveDigitals = master.getRelObjs();
@@ -569,7 +569,7 @@ public class RelationReportHandler {
 	private void findFloorName(Map<String, String> floorNameTemp, String groupCode, String projectId) {
 		// 获取楼层名称
 		String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Fl.name();
-		List<ObjectDigital> floorDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null);
+		List<ObjectDigital> floorDigitals = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, null, null);
 		if (CollectionUtil.isNotEmpty(floorDigitals)) {
 			for (ObjectDigital master : floorDigitals) {
 				List<ObjectDigital> slaveDigitals = master.getRelObjs();

+ 4 - 4
src/main/java/com/persagy/proxy/adm/handler/SpaceRelationInfoHandler.java

@@ -72,7 +72,7 @@ public class SpaceRelationInfoHandler {
 		if (StrUtil.isNotBlank(buildingId) && StrUtil.isNotBlank(floorId) && !"isnull".equals(floorId)) {
 			// 当建筑ID不为空、楼层ID不为空时
 			String graphAndRelKey = GraphCodeEnum.ArchForArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Sp2Fl.name();
-			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId));
+			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId), null);
 			if (CollectionUtil.isNotEmpty(allRelations)) {
 				resultList = this.transferSpaceInfo(allRelations, buildingId, floorId);
 			}
@@ -84,7 +84,7 @@ public class SpaceRelationInfoHandler {
 		} else if (StrUtil.isNotBlank(buildingId) && StrUtil.isBlank(floorId) && !"isnull".equals(buildingId)) {
 			// 当建筑ID不为空、楼层ID为空时
 			String graphAndRelKey = GraphCodeEnum.ArchForArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Sp2Bd.name();
-			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId));
+			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId), null);
 			if (CollectionUtil.isNotEmpty(allRelations)) {
 				resultList = this.transferSpaceInfo(allRelations, buildingId, null);
 			}
@@ -156,7 +156,7 @@ public class SpaceRelationInfoHandler {
 		} else {
 			// 获取所有的空间数据
 			String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Fl.name();
-			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId));
+			List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId), null);
 			if (CollectionUtil.isNotEmpty(allRelations)) {
 				resultList = this.transferSpaceInfo(allRelations, buildingId, null);
 			}
@@ -187,7 +187,7 @@ public class SpaceRelationInfoHandler {
 				String buildingId = objectNode.get("id").asText();
 				// 获取所有的空间数据
 				String graphAndRelKey = GraphCodeEnum.MechInArch.name() + AdmCommonConstant.UNDERLINE + RelCodeEnum.Eq2Fl.name();
-				List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId));
+				List<ObjectDigital> allRelations = this.relationObjectContext.queryAllRelations(groupCode, projectId, graphAndRelKey, null, Sets.newHashSet(buildingId), null);
 				if (CollectionUtil.isNotEmpty(allRelations)) {
 					// 获取所有的对象数据
 					resultList = this.transferSpaceInfo(allRelations, buildingId, null);

+ 32 - 13
src/main/java/com/persagy/proxy/adm/strategy/RelationObjectContext.java

@@ -1,18 +1,22 @@
 package com.persagy.proxy.adm.strategy;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Component;
+
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.google.common.collect.Lists;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.proxy.adm.constant.AdmRelationType;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.adm.strategy.relationdata.RelationObjectStrategy;
 import com.persagy.proxy.report.model.AdmRelationObject;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 /**
  * 获取关系对象的上下文类
@@ -55,13 +59,19 @@ public class RelationObjectContext {
 	 * 检查关联对象的合法性
 	 * 
 	 * @param relationObject 当前需要校验的对象
+	 * @param groupCode
+	 * @param projectId
 	 * @param relType graphCode_relCode
 	 * @param code 获取对象的依据
+	 * @param admRelType ADM定义的类型
 	 * @return String - 校验失败的原因, ObjectNode -- BDTP接口的参数,不会返回null,请用instanceOf 判断返回值
 	 */
-	public Object checkRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String relType, String code) {
+	public Object checkRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String relType, String code, AdmRelationTypeEnum typeEnum) {
 		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
-		return strategy == null ? "不存在此策略类" : strategy.beforeSaveRelationObject(relationObject, groupCode, projectId, code);
+		if (strategy == null && typeEnum != null) {
+			strategy = this.relationObjectStrategyMap.get(AdmRelationType.DEFAULT_RELATION_OBJECT);
+		}
+		return strategy == null ? "不存在此类型" : strategy.beforeSaveRelationObject(relationObject, groupCode, projectId, code, typeEnum);
 	}
 	
 	/**
@@ -75,6 +85,9 @@ public class RelationObjectContext {
 	 */
 	public boolean saveRelationObjects(List<ObjectNode> relationObjects, String groupCode, String projectId, String relType) {
 		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
+		if (strategy == null) {
+			strategy = this.relationObjectStrategyMap.get(AdmRelationType.DEFAULT_RELATION_OBJECT);
+		}
 		return strategy == null ? false : strategy.saveRelationObjects(relationObjects, groupCode, projectId);
 	}
 
@@ -86,9 +99,12 @@ public class RelationObjectContext {
 	 * @param relType graphCode_relCode
 	 * @return 
 	 */
-	public long countRelationObjects(String groupCode, String projectId, String relType) {
+	public long countRelationObjects(String groupCode, String projectId, String relType, AdmRelationTypeEnum typeEnum) {
 		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
-		return strategy == null ? 0 : strategy.countRelationObjects(groupCode, projectId);
+		if (strategy == null && typeEnum != null) {
+			strategy = this.relationObjectStrategyMap.get(AdmRelationType.DEFAULT_RELATION_OBJECT);
+		}
+		return strategy == null ? 0 : strategy.countRelationObjects(groupCode, projectId, typeEnum);
 	}
 
 	/**
@@ -102,9 +118,12 @@ public class RelationObjectContext {
 	 * @param mainContent	主对象的筛选关键字,筛选范围为id,name,local_id,local_name,cADID.为关系左侧对象
 	 * @param slaveContent	从对象的筛选关键字.objTo对应的对象,筛选范围为id,name,local_id,local_name.为关系右侧对象
 	 */
-	public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String relType, String mainContent, Set<String> slaveContent) {
+	public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String relType, String mainContent, Set<String> slaveContent, AdmRelationTypeEnum typeEnum) {
 		RelationObjectStrategy strategy = this.relationObjectStrategyMap.get(relType);
-		return strategy == null ? Lists.newArrayList() : strategy.queryAllRelations(groupCode, projectId, mainContent, slaveContent);
+		if (strategy == null && typeEnum != null) {
+			strategy = this.relationObjectStrategyMap.get(AdmRelationType.DEFAULT_RELATION_OBJECT);
+		}
+		return strategy == null ? Lists.newArrayList() : strategy.queryAllRelations(groupCode, projectId, mainContent, slaveContent, typeEnum);
 	}
 	
 	/**

+ 40 - 3
src/main/java/com/persagy/proxy/adm/strategy/relationdata/AbstractRelationObject.java

@@ -1,6 +1,7 @@
 package com.persagy.proxy.adm.strategy.relationdata;
 
 import java.util.List;
+import java.util.Set;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
@@ -10,6 +11,7 @@ import com.persagy.dmp.digital.client.DigitalRelationFacade;
 import com.persagy.dmp.digital.entity.ObjectDigital;
 import com.persagy.dmp.digital.entity.ObjectRelation;
 import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.report.model.AdmRelationObject;
 import com.persagy.proxy.report.service.IRelationReportService;
 
@@ -32,6 +34,37 @@ public abstract class AbstractRelationObject implements RelationObjectStrategy {
 	}
 	
 	@Override
+	public long countRelationObjects(String groupCode, String projectId, AdmRelationTypeEnum typeEnum) {
+		return this.countRelationObjects(groupCode, projectId);
+	}
+	
+	/**
+	 * 统计关系总数
+	 * 
+	 * @param groupCode
+	 * @param projectId
+	 * @return
+	 */
+	protected abstract long countRelationObjects(String groupCode, String projectId);
+	
+	@Override
+	public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent, AdmRelationTypeEnum typeEnum) {
+		return this.queryAllRelations(groupCode, projectId, mainContent, slaveContent);
+	}
+	
+	/**
+	 * 查询出所有的关系对象数据
+	 * 
+	 * @param groupCode 集团编码
+	 * @param projectId 项目ID
+	 * @param mainContent	主对象的筛选关键字,筛选范围为id,name,local_id,local_name,cADID.为关系左侧对象
+	 * @param slaveContent	从对象的筛选关键字.objTo对应的对象,筛选范围为id,name,local_id,local_name.为关系右侧对象
+	 * @return 不会返回null
+	 */
+	protected abstract List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent);
+	
+	
+	@Override
 	public void queryPageRelations(List<ObjectDigital> allDigitals, RequestData requestData, String groupCode, String projectId) {
 		CommonResult<List<ObjectDigital>> queryPrototype = DigitalObjectFacade.queryObjectListByGraphCodeAndRelCodePrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, requestData);
 		Long count = queryPrototype.getCount();
@@ -67,12 +100,16 @@ public abstract class AbstractRelationObject implements RelationObjectStrategy {
 	
 	@Override
 	public List<AdmRelationObject> exportRelationObject(String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override
-	public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
-		throw new UnsupportedOperationException("未实现的策略类");
+	public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code, AdmRelationTypeEnum typeEnum) {
+		return this.beforeSaveRelationObject(relationObject, groupCode, projectId, code);
+	}
+	
+	protected Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 	
 }

+ 29 - 4
src/main/java/com/persagy/proxy/adm/strategy/relationdata/AbstractReportRelationObject.java

@@ -2,6 +2,7 @@ package com.persagy.proxy.adm.strategy.relationdata;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.digital.entity.ObjectDigital;
@@ -29,6 +30,16 @@ public abstract class AbstractReportRelationObject extends AbstractRelationObjec
 	}
 
 	@Override
+	protected long countRelationObjects(String groupCode, String projectId) {
+		throw new UnsupportedOperationException("未实现的策略方法");
+	}
+
+	@Override
+	protected List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent) {
+		throw new UnsupportedOperationException("未实现的策略方法");
+	}
+	
+	@Override
 	public List<AdmRelationObject> exportRelationObject(String groupCode, String projectId) {
 		List<ObjectDigital> masterObjs = this.queryAllRelations(groupCode, projectId, null, null);
 		// 转换中台数据
@@ -132,19 +143,33 @@ public abstract class AbstractReportRelationObject extends AbstractRelationObjec
 		if (!StrUtil.isAllNotBlank(relationObject.getMasterCode(), relationObject.getSlaveCode())) {
 			return "主对象或从对象的识别编码为空";
 		}
-		if (!StrUtil.isAllNotBlank(relationObject.getMasterId(), relationObject.getSlaveId())) {
+		/*if (!StrUtil.isAllNotBlank(relationObject.getMasterId(), relationObject.getSlaveId())) {
 			return "主对象或从对象的ID为空";
-		}
+		}*/
+		
+		// 获取备用的类型
+		String relationType = relationTypeEnum.getRelationType();
+		int indexOf = relationType.indexOf("_");
+		String relCodeBak = indexOf > 0 ? relationType.substring(0, indexOf) : relationType;
 		
 		String relCode = relationTypeEnum.getRelCode();
 		String relCodePrefix = ObjTypeMapping.getRelCodePrefix(relCode);
 		String masterObjType = ObjTypeMapping.PREFIX_FULLNAME.get(relCodePrefix);
 		if (StrUtil.isBlank(masterObjType)) {
-			return "边类型错误";
+			relCodePrefix = ObjTypeMapping.getRelCodePrefix(relCodeBak);
+			relCodePrefix = StrUtil.upperFirst(relCodePrefix);
+			masterObjType = ObjTypeMapping.PREFIX_FULLNAME.get(relCodePrefix);
+			if (StrUtil.isBlank(masterObjType)) {
+				return "边类型错误";
+			}
 		}
 		String slaveObjType = ObjTypeMapping.PREFIX_FULLNAME.get(ObjTypeMapping.getRelCodeSuffix(relCode));
 		if (StrUtil.isBlank(slaveObjType)) {
-			return "边类型错误";
+			String relCodeSuffix = StrUtil.upperFirst(ObjTypeMapping.getRelCodeSuffix(relCodeBak));
+			slaveObjType = ObjTypeMapping.PREFIX_FULLNAME.get(relCodeSuffix);
+			if (StrUtil.isBlank(slaveObjType)) {
+				return "边类型错误";
+			}
 		}
 		// 查询出对象信息
 		List<ObjectNode> masters = this.relationReportService.findObjectNodes(groupCode, projectId, masterObjType, code, relationObject.getMasterCode());

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkMixMechRelationObject.java

@@ -72,7 +72,7 @@ public class ConvectionNetworkMixMechRelationObject extends AbstractReportRelati
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkNaturalRelationObject.java

@@ -72,7 +72,7 @@ public class ConvectionNetworkNaturalRelationObject extends AbstractReportRelati
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/ConvectionNetworkOnewayMechRelationObject.java

@@ -72,7 +72,7 @@ public class ConvectionNetworkOnewayMechRelationObject extends AbstractReportRel
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 82 - 0
src/main/java/com/persagy/proxy/adm/strategy/relationdata/DeafultRelationObject.java

@@ -0,0 +1,82 @@
+package com.persagy.proxy.adm.strategy.relationdata;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.springframework.stereotype.Component;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.persagy.dmp.basic.dto.RequestData;
+import com.persagy.dmp.basic.model.QueryCriteria;
+import com.persagy.dmp.common.model.response.CommonResult;
+import com.persagy.dmp.digital.client.DigitalRelationFacade;
+import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.dmp.digital.entity.ObjectRelation;
+import com.persagy.proxy.adm.constant.AdmCommonConstant;
+import com.persagy.proxy.adm.constant.AdmRelationType;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
+import com.persagy.proxy.report.model.AdmRelationObject;
+import com.persagy.proxy.report.service.IRelationReportService;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
+
+/**
+ * 
+ * @version 1.0.0
+ * @company persagy 
+ * @author zhangqiankun
+ * @date 2021年11月1日 上午11:42:26
+ */
+@Component(value = AdmRelationType.DEFAULT_RELATION_OBJECT)
+public class DeafultRelationObject extends AbstractReportRelationObject {
+
+	public DeafultRelationObject(IRelationReportService reportDownloadService) {
+		super(reportDownloadService);
+	}
+
+	@Override
+	public long countRelationObjects(String groupCode, String projectId, AdmRelationTypeEnum typeEnum) {
+		QueryCriteria queryCriteria = new QueryCriteria();
+		ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
+		objectNode.put("graphCode", typeEnum.getGraphCode());
+		objectNode.put("relCode", typeEnum.getRelCode());
+		objectNode.put("valid", 1);
+		queryCriteria.setCriteria(objectNode);
+		queryCriteria.setOnlyCount(true);
+		
+		CommonResult<List<ObjectRelation>> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
+		return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
+	}
+
+	@Override
+	public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent, AdmRelationTypeEnum typeEnum) {
+		RequestData requestData = new RequestData();
+		requestData.setGraphCode(typeEnum.getGraphCode());
+		requestData.setRelCode(typeEnum.getRelCode());
+		if (StrUtil.isNotBlank(mainContent)) {
+			requestData.setMainContent(mainContent);
+		}
+		if (CollectionUtil.isNotEmpty(slaveContent)) {
+			requestData.setSlaveContent(slaveContent);
+		}
+		requestData.setPage(1L);
+		requestData.setSize(500L);
+		
+		List<ObjectDigital> allDigitals = new ArrayList<ObjectDigital>();
+		this.queryPageRelations(allDigitals, requestData, groupCode, projectId);
+		return allDigitals;
+	}
+	
+	@Override
+	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
+		throw new UnsupportedOperationException("未实现的策略方法");
+	}
+	
+	@Override
+	public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code, AdmRelationTypeEnum typeEnum) {
+		return this.beforeSaveRelationObject(relationObject, typeEnum, groupCode, projectId, code);
+	}
+
+}

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerEqBackupRelationObject.java

@@ -72,7 +72,7 @@ public class EquipPowerEqBackupRelationObject extends AbstractReportRelationObje
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerEqNormalRelationObject.java

@@ -72,7 +72,7 @@ public class EquipPowerEqNormalRelationObject extends AbstractReportRelationObje
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerSyBackupRelationObject.java

@@ -72,7 +72,7 @@ public class EquipPowerSyBackupRelationObject extends AbstractReportRelationObje
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/EquipPowerSyNormalRelationObject.java

@@ -72,7 +72,7 @@ public class EquipPowerSyNormalRelationObject extends AbstractReportRelationObje
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/RadiationNetworkConnectRelationObject.java

@@ -72,7 +72,7 @@ public class RadiationNetworkConnectRelationObject extends AbstractReportRelatio
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/RadiationNetworkTransparentRelationObject.java

@@ -72,7 +72,7 @@ public class RadiationNetworkTransparentRelationObject extends AbstractReportRel
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 6 - 4
src/main/java/com/persagy/proxy/adm/strategy/relationdata/RelationObjectStrategy.java

@@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
 import com.persagy.dmp.basic.dto.RequestData;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.digital.entity.ObjectDigital;
+import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
 import com.persagy.proxy.report.model.AdmRelationObject;
 
 /**
@@ -45,7 +46,7 @@ public interface RelationObjectStrategy {
 	 * @param projectId
 	 * @return
 	 */
-    long countRelationObjects(String groupCode, String projectId);
+    long countRelationObjects(String groupCode, String projectId, AdmRelationTypeEnum typeEnum);
     
 	/**
 	 * 查询出所有的关系信息
@@ -65,7 +66,7 @@ public interface RelationObjectStrategy {
 	 * @param slaveContent	从对象的筛选关键字.objTo对应的对象,筛选范围为id,name,local_id,local_name.为关系右侧对象
 	 * @return 不会返回null
 	 */
-	List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent);
+	List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent, AdmRelationTypeEnum typeEnum);
 	
 	/**
 	 * 分页查询关系对象数据
@@ -78,15 +79,16 @@ public interface RelationObjectStrategy {
 	void queryPageRelations(List<ObjectDigital> masterObjs, RequestData requestData, String groupCode, String projectId);
 	
 	/**
-	 * 保存之前校验数据的合法性
+	 * 保存之前校验数据的合法性
 	 * 
 	 * @param relationObject 需要校验的对象
 	 * @param groupCode
 	 * @param projectId
 	 * @param code 参考 OBJNAME_2_TYPE
+	 * @param typeEnum 
 	 * @return String - 校验失败的原因, ObjectNode -- BDTP接口的参数,不会返回null,请用instanceOf 判断返回值
 	 */
-	Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code);
+	Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code, AdmRelationTypeEnum typeEnum);
 
 	/**
 	 * 保存对象之间的关系

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2EqRelationObject.java

@@ -72,7 +72,7 @@ public class SensorRelationshipSs2EqRelationObject extends AbstractReportRelatio
 
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2SpRelationObject.java

@@ -73,7 +73,7 @@ public class SensorRelationshipSs2SpRelationObject extends AbstractReportRelatio
 
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/SensorRelationshipSs2SyRelationObject.java

@@ -72,7 +72,7 @@ public class SensorRelationshipSs2SyRelationObject extends AbstractReportRelatio
 
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkFFCloseRelationObject.java

@@ -72,7 +72,7 @@ public class TrafficNetworkFFCloseRelationObject extends AbstractReportRelationO
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkFFOpenRelationObject.java

@@ -72,7 +72,7 @@ public class TrafficNetworkFFOpenRelationObject extends AbstractReportRelationOb
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/persagy/proxy/adm/strategy/relationdata/TrafficNetworkNormalRelationObject.java

@@ -72,7 +72,7 @@ public class TrafficNetworkNormalRelationObject extends AbstractReportRelationOb
 	
 	@Override
 	protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
-		throw new UnsupportedOperationException("未实现的策略");
+		throw new UnsupportedOperationException("未实现的策略方法");
 	}
 
 	@Override

+ 11 - 5
src/main/java/com/persagy/proxy/report/controller/RelationReportController.java

@@ -488,8 +488,8 @@ public class RelationReportController {
 	 * @param response
 	 */
 	@RequestMapping("/graphic/import")
-	public AdmResponse importFile(@RequestParam("file") MultipartFile file, @RequestParam String relType, @RequestParam(required = false) String zoneType, 
-			HttpServletRequest request, HttpServletResponse response) {
+	public AdmResponse importFile(@RequestParam("file") MultipartFile file, @RequestParam String relType, 
+			@RequestParam(required = false) String zoneType, HttpServletRequest request, HttpServletResponse response) {
 		String failure = null;
 		XSSFWorkbook workbook = null;
 		FileOutputStream fileOutputStream = null;
@@ -537,7 +537,7 @@ public class RelationReportController {
 		    	relationObject.setSlaveId(slaveIdCell == null ? null : slaveIdCell.getStringCellValue());
 		    	
 		    	// 校验数据
-				Object result = this.relationObjectContext.checkRelationObject(relationObject, groupCode, projectId, graphAndRelKey, code);
+				Object result = this.relationObjectContext.checkRelationObject(relationObject, groupCode, projectId, graphAndRelKey, code, typeEnum);
 				if (result instanceof String) {
 					failurNum++;
 					xssfRow.createCell(16).setCellValue((String)result);
@@ -553,10 +553,13 @@ public class RelationReportController {
 					boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, graphAndRelKey);
 					if (objects) {
 						successNum += relationObjects.size();
+						for (int rowNum : rowNums) {
+							sheet.getRow(rowNum).createCell(16).setCellValue("关联成功");
+						}
 					} else {
 						failurNum += relationObjects.size();
 						for (int rowNum : rowNums) {
-							sheet.getRow(rowNum).createCell(16).setCellValue("调用中台,存储失败");
+							sheet.getRow(rowNum).createCell(16).setCellValue("关联失败");
 						}
 					}
 					rowNums.clear();
@@ -568,10 +571,13 @@ public class RelationReportController {
 		    	boolean objects = this.relationObjectContext.saveRelationObjects(relationObjects, groupCode, projectId, graphAndRelKey);
 				if (objects) {
 					successNum += relationObjects.size();
+					for (int rowNum : rowNums) {
+						sheet.getRow(rowNum).createCell(16).setCellValue("关联成功");
+					}
 				} else {
 					failurNum += relationObjects.size();
 					for (int rowNum : rowNums) {
-						sheet.getRow(rowNum).createCell(16).setCellValue("调用中台,存储失败");
+						sheet.getRow(rowNum).createCell(16).setCellValue("关联失败");
 					}
 				}
 			}