|
@@ -2,16 +2,25 @@ package com.persagy.proxy.adm.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.persagy.dmp.basic.dto.RequestData;
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
|
+import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
|
+import com.persagy.dmp.digital.client.DigitalRelationCaclClient;
|
|
|
|
+import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
|
|
import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
|
|
|
|
+import com.persagy.proxy.adm.constant.BusinessErrorRwdCode;
|
|
import com.persagy.proxy.adm.model.AdmRelationAddRequest;
|
|
import com.persagy.proxy.adm.model.AdmRelationAddRequest;
|
|
import com.persagy.proxy.adm.request.AdmCreateResponse;
|
|
import com.persagy.proxy.adm.request.AdmCreateResponse;
|
|
-import com.persagy.proxy.adm.service.AdmManualRelationCalcService;
|
|
|
|
|
|
+import com.persagy.proxy.adm.service.AdmManualRelCalService;
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
|
|
|
|
+import com.persagy.proxy.common.entity.InstanceUrlParam;
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/***
|
|
/***
|
|
* Description: 手动计算逻辑处理类
|
|
* Description: 手动计算逻辑处理类
|
|
@@ -21,10 +30,16 @@ import java.util.Map;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelationCalcService {
|
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
+public class AdmManualRelCalServiceImpl implements AdmManualRelCalService {
|
|
|
|
+
|
|
|
|
+ private final DigitalRelationCaclClient digitalRelationCaclClient;
|
|
|
|
+
|
|
|
|
|
|
/***
|
|
/***
|
|
* Description: 添加关系
|
|
* Description: 添加关系
|
|
|
|
+ *
|
|
|
|
+ * @param context
|
|
* @param request : 请求参数
|
|
* @param request : 请求参数
|
|
* @return : com.persagy.proxy.adm.request.AdmCreateResponse
|
|
* @return : com.persagy.proxy.adm.request.AdmCreateResponse
|
|
* @author : lijie
|
|
* @author : lijie
|
|
@@ -32,7 +47,7 @@ public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelati
|
|
* Update By lijie 2021/8/31 12:14
|
|
* Update By lijie 2021/8/31 12:14
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public AdmCreateResponse addRels(AdmRelationAddRequest request) {
|
|
|
|
|
|
+ public AdmCreateResponse addRels(InstanceUrlParam context, AdmRelationAddRequest request) {
|
|
// 获取项目id
|
|
// 获取项目id
|
|
String projectId = AppContext.getContext().getProjectId();
|
|
String projectId = AppContext.getContext().getProjectId();
|
|
if (StrUtil.isBlank(request.getRelType())){
|
|
if (StrUtil.isBlank(request.getRelType())){
|
|
@@ -66,14 +81,45 @@ public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelati
|
|
if (AdmObjectInfoConstant.CADID.equals(request.getType()) && relationTypeEnum.getHasCheckCadId()){
|
|
if (AdmObjectInfoConstant.CADID.equals(request.getType()) && relationTypeEnum.getHasCheckCadId()){
|
|
return AdmCreateResponse.failure("从对象不存在CADID编码","2");
|
|
return AdmCreateResponse.failure("从对象不存在CADID编码","2");
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // 1.根据项目id和关系类型更新计算时间为当前时间
|
|
|
|
- // 2.根据不同关系类型进行处理
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ // relType为下面几种的从对象不能重复,主对象和从对象不能重复
|
|
|
|
+ if (AdmObjectInfoConstant.CHECK_SPECIAL_TYPES.contains(request.getRelType())){
|
|
|
|
+ Set<String> fromContent = request.getFromContent();
|
|
|
|
+ if (fromContent.contains(request.getMainContent())){
|
|
|
|
+ return AdmCreateResponse.failure(request.getMainContent()+":从对象不能重复","2");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ RequestData requestData = RequestData.builder()
|
|
|
|
+ .graphCode(relationTypeEnum.getGraphCode())
|
|
|
|
+ .relCode(relationTypeEnum.getRelCode())
|
|
|
|
+ .masterObjType(relationTypeEnum.getMasterObjType())
|
|
|
|
+ .slaveObjType(relationTypeEnum.getSlaveObjType())
|
|
|
|
+ .type(request.getType())
|
|
|
|
+ .hasRelValue(relationTypeEnum.getHasRelValue())
|
|
|
|
+ .hasFilterMasterId(relationTypeEnum.getHasFilterMasterId())
|
|
|
|
+ .hasFilterClassCode(relationTypeEnum.getHasFilterClassCode())
|
|
|
|
+ .hasCheckSensor(relationTypeEnum.getHasCheckSensor())
|
|
|
|
+ .hasCheckClassCode(relationTypeEnum.getHasCheckClassCode())
|
|
|
|
+ .checkClassCodes(relationTypeEnum.getCheckClassCodes())
|
|
|
|
+ .checkSensorCodes(relationTypeEnum.getCheckSensorCodes())
|
|
|
|
+ .sign("1")
|
|
|
|
+ .mainContent(request.getMainContent())
|
|
|
|
+ .fromContent(request.getFromContent())
|
|
|
|
+ .build();
|
|
|
|
+ CommonResult<List<ObjectRelation>> commonResult = digitalRelationCaclClient
|
|
|
|
+ .createObjRelationsByKeywordAndObjType(context.getGroupCode(), context.getProjectId(),
|
|
|
|
+ context.getAppId(), "0", requestData);
|
|
|
|
+ if (BusinessErrorRwdCode.A7301.getCode().equals(commonResult.getResult())
|
|
|
|
+ || BusinessErrorRwdCode.A7302.getCode().equals(commonResult.getResult())
|
|
|
|
+ || BusinessErrorRwdCode.A7305.getCode().equals(commonResult.getResult())
|
|
|
|
+ || BusinessErrorRwdCode.A7306.getCode().equals(commonResult.getResult())){
|
|
|
|
+ return AdmCreateResponse.failure(commonResult.getMessage(),"1");
|
|
|
|
+ }
|
|
|
|
+ if (BusinessErrorRwdCode.A7303.getCode().equals(commonResult.getResult())
|
|
|
|
+ || BusinessErrorRwdCode.A7304.getCode().equals(commonResult.getResult())){
|
|
|
|
+ return AdmCreateResponse.failure(commonResult.getMessage(),"2");
|
|
|
|
+ }
|
|
|
|
+ return AdmCreateResponse.success("添加成功");
|
|
|
|
+ // 原数据中心逻辑
|
|
// 2.2 特殊类型的判断
|
|
// 2.2 特殊类型的判断
|
|
// *******
|
|
// *******
|
|
// sp2sp_RadiationNetwork_2,sp2sp_RadiationNetwork_1 && classCode!=LightingZone errorType=1,不是照明分区类型
|
|
// sp2sp_RadiationNetwork_2,sp2sp_RadiationNetwork_1 && classCode!=LightingZone errorType=1,不是照明分区类型
|
|
@@ -219,17 +265,10 @@ public class AbstractAdmManualRelationCalcServiceImpl implements AdmManualRelati
|
|
// 传感器类型检查
|
|
// 传感器类型检查
|
|
// eq2sp_SensorRelationship_ss2sp:图类型为SensorRelationship,边类型为Ss2Sp
|
|
// eq2sp_SensorRelationship_ss2sp:图类型为SensorRelationship,边类型为Ss2Sp
|
|
// *****
|
|
// *****
|
|
- // eq2sp_x
|
|
|
|
|
|
+ // eq2sp_x,已经不存在的类型
|
|
// bd2bd_ArchForArch,bd2fl_ArchForArch,bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch
|
|
// bd2bd_ArchForArch,bd2fl_ArchForArch,bd2sh_ArchForArch,bd2sp_ArchForArch,fl2bd_ArchForArch,fl2fl_ArchForArch
|
|
// fl2sh_ArchForArch,fl2sp_ArchForArch,sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch
|
|
// fl2sh_ArchForArch,fl2sp_ArchForArch,sh2bd_ArchForArch,sh2fl_ArchForArch,sh2sh_ArchForArch,sh2sp_ArchForArch
|
|
// sp2bd_ArchForArch,sp2fl_ArchForArch,sp2sh_ArchForArch,sp2sp_ArchForArch
|
|
// sp2bd_ArchForArch,sp2fl_ArchForArch,sp2sh_ArchForArch,sp2sp_ArchForArch
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- return null;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|