123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397 |
- package com.persagy.proxy.adm.controller;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.util.StrUtil;
- import com.persagy.dmp.common.exception.BusinessException;
- import com.persagy.proxy.adm.constant.AdmCommonConstant;
- import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
- import com.persagy.proxy.adm.constant.BusinessErrorRwdCode;
- import com.persagy.proxy.adm.request.AdmResponse;
- import com.persagy.proxy.adm.service.AdmRelCalService;
- import com.persagy.proxy.common.entity.InstanceUrlParam;
- import lombok.RequiredArgsConstructor;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpServletRequest;
- import javax.ws.rs.QueryParam;
- import java.util.ArrayList;
- import java.util.Map;
- /***
- * Description:关系计算输入类
- * @author : lijie
- * @date :2021/8/31 11:37
- * Update By lijie 2021/8/31 11:37
- */
- @RestController
- @RequestMapping("/relation-calc/")
- @RequiredArgsConstructor
- public class AdmRelCalController {
- private final AdmRelCalService admRelCalService;
- @Value("${middleware.group.code}")
- private String groupCode;
-
- /***
- * Description: 添加关系(图类型关系为ArchSubset)
- * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
- * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
- * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
- * bd2sp: 建筑下的空间
- * fl2sp: 楼层下的空间
- * sh2bd: 建筑下的竖井,实际关系应该是bd2sh
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"bd2sp","fl2sp","sh2bd"})
- public AdmResponse archSubsetCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId,
- @RequestParam("objectTypes") String objectTypeStr,
- @RequestParam("relationType") String relationTypeStr,
- HttpServletRequest request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为MechInArch)
- * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
- * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
- * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
- * eq2bd:设备所在建筑
- * eq2fl:设备所在楼层
- * eq2sh:设备所在竖井
- * eq2sp_in:设备所在业务空间
- * sy2bd: 系统所在建筑
- * sy2fl: 系统所在楼层
- * sy2sh: 系统所在竖井
- * sy2sp: 系统所在业务空间
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"eq2bd","eq2fl","eq2sh","eq2sp_in","sy2bd","sy2fl","sy2sh","sy2sp"})
- public AdmResponse mechInArchCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId,
- @RequestParam("objectTypes") String objectTypeStr,
- @RequestParam("relationType") String relationTypeStr,
- HttpServletRequest request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context, CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为PropertyInArch)
- * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
- * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
- * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
- * pe2bd:资产所在建筑
- * pe2fl:资产所在楼层
- * pe2sh:资产所在竖井
- * pe2sp:资产所在业务空间
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"pe2bd","pe2fl","pe2sh","pe2sp"})
- public AdmResponse propertyInArchCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId,
- @RequestParam("objectTypes") String objectTypeStr,
- @RequestParam("relationType") String relationTypeStr) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为MechForArch)
- * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
- * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
- * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
- * eq2sp_for:设备服务空间关系
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"eq2sp_for"})
- public AdmResponse mechForArchCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId,
- @RequestParam("objectTypes") String objectTypeStr,
- @RequestParam("relationType") String relationTypeStr) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为ArchForArch)
- * @param buildingId : 建筑id
- * @param objectType : 对象分类
- * @param type : 对象类型
- * @param projectId : 项目id
- * @param groupCode : 集团编码
- * @param appId : APP的id
- * @param userId : 账号id
- * sp2sp:空间服务于空间
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sp2sp"})
- public AdmResponse archForArchCalcRelation( @RequestParam("buildingId") String buildingId,
- @RequestParam("objectType") String objectType,
- @RequestParam("type") String type,
- @RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelationForArchForArchSpToSp(context,buildingId,objectType,type,AdmRelationTypeEnum.SP2SP_ARCHFORARCH);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为SensorRelationship)
- * eq2sp_SensorRelationship_ss2sp:传感器测量空间关系
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"eq2sp_SensorRelationship_ss2sp"})
- public AdmResponse sensorRelationshipCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.EQ2SP_SENSORRELATIONSHIP_SS2SP),"AirConditioningZone");
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为ConvectionNetwork)
- * sp2sp_ConvectionNetwork_1:Natural-空气自然对流
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sp2sp_ConvectionNetwork_1"})
- public AdmResponse convectionNetworkCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_1),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为RadiationNetwork)
- * sp2sp_RadiationNetwork_1:光照辐射网络-Connect-光照连通
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sp2sp_RadiationNetwork_1"})
- public AdmResponse radiationNetworkCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_RADIATIONNETWORK_1),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为SpaceNeighborhood)
- * sp2sp_SpaceNeighborhood_5:业务空间(同类)邻接关系-Connect-空间连通
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sp2sp_SpaceNeighborhood_5"})
- public AdmResponse spaceNeighborhoodCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_SPACENEIGHBORHOOD_5),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(计算设备所在建筑,系统所在建筑,图类型关系为MechInArch)
- * syeq2bd:建筑下的系统设备部件,计算设备所在建筑(eq2bd),系统所在建筑(sy2bd)
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"syeq2bd"})
- public AdmResponse syeq2bdCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
- if (!relationTypeMap.containsKey("eq2bd") || !relationTypeMap.containsKey("sy2bd")){
- throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
- }
- ArrayList<AdmRelationTypeEnum> admRelationTypeEnums =
- CollUtil.newArrayList(relationTypeMap.get("eq2bd"), relationTypeMap.get("sy2bd"));
- admRelCalService.calcRelation(context,admRelationTypeEnums,null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为TrafficNetwork)
- * sp2sp_TrafficNetwork_1:建筑交通网络(同类)-Normal-普通交通
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sp2sp_TrafficNetwork_1"})
- public AdmResponse trafficNetworkCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(AdmRelationTypeEnum.SP2SP_TRAFFICNETWORK_1),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 添加关系(图类型关系为ThroughRelationship)
- * fl2fl:楼层贯通关系
- * sh2sh:竖井贯通关系
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"fl2fl","sh2sh"})
- public AdmResponse throughRelationshipCalcRelation(@RequestParam("projectId") String projectId,
- @RequestParam("groupCode") String groupCode,
- @RequestParam("appId") String appId,
- @RequestParam("userId") String userId,
- HttpServletRequest request) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(StrUtil.isNotBlank(groupCode)?groupCode:this.groupCode,
- null, projectId, StrUtil.isNotBlank(appId)?appId:AdmCommonConstant.APP_ID,
- StrUtil.isNotBlank(userId)?userId:AdmCommonConstant.USER_ID);
- admRelCalService.calcRelation(context,CollUtil.newArrayList(getAdmRelationTypeEnum(request)),null);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 更改计算标记
- * @param relType : 关系类型
- * @param objectTypeStr : 参与计算的业务空间(为空表示所有业务空间类型),以英文逗号隔开 HeatingZone,CleanZone,
- * DomesticWaterSupplyZone,NetworkZone,TenantZone,AirConditioningZone,FunctionZone,
- * FireZone,SecurityZone,GeneralZone,PowerSupplyZone,LightingZone
- * sign: 更改计算标记
- * @return : com.persagy.proxy.adm.request.AdmCreateResponse
- * @author : lijie
- * @date :2021/8/31 12:10
- * Update By lijie 2021/8/31 12:10
- */
- @PostMapping(value = {"sign"})
- public AdmResponse changeSign( @PathVariable("relType") String relType,
- @QueryParam("projectId") String projectId,
- @QueryParam("objectTypes") String objectTypeStr,
- @QueryParam("relationType") String relationTypeStr) throws Exception {
- // 资产暂时未引入,直接返回成功
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- // admRelCalService.calcRelation(context,relType,objectTypeStr,relationTypeStr);
- return AdmResponse.success(new ArrayList<>());
- }
- /***
- * Description: 获得关系枚举类型
- * @param request : 请求体
- * @return : com.persagy.proxy.adm.constant.AdmRelationTypeEnum
- * @author : lijie
- * @date :2021/9/11 22:33
- * Update By lijie 2021/9/11 22:33
- */
- private AdmRelationTypeEnum getAdmRelationTypeEnum(HttpServletRequest request) {
- String suffix = getSuffixRequestUrl(request);
- Map<String, AdmRelationTypeEnum> relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap();
- if (!relationTypeMap.containsKey(suffix)){
- throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
- }
- return relationTypeMap.get(suffix);
- }
- /***
- * Description: 获得最后一个/后请求地址
- * @param request : 请求对象
- * @return : void
- * @author : lijie
- * @date :2021/9/11 22:09
- * Update By lijie 2021/9/11 22:09
- */
- private String getSuffixRequestUrl(HttpServletRequest request) {
- String requestURI = request.getRequestURI();
- return requestURI.substring(requestURI.lastIndexOf("/")+1);
- }
- }
|