package com.persagy.proxy.adm.controller; 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.AdmCalcSpecialService; import com.persagy.proxy.common.entity.InstanceUrlParam; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.*; import java.util.Map; /*** * Description: 机电管网系统关系计算 * @author : lijie * @date :2021/9/14 23:15 * Update By lijie 2021/9/14 23:15 */ @RestController @RequestMapping("/calc_special/") @RequiredArgsConstructor public class AdmCalcSpecialController { private final AdmCalcSpecialService admCalcSpecialService; @Value("${middleware.group.code}") private String groupCode; /*** * Description: 管网系统设备分块 + 计算流向 * @param projectId : 项目id * @param relationType : 关系类型 * @return : com.persagy.proxy.adm.request.AdmResponse * @author : lijie * @date :2021/9/29 11:12 * Update By lijie 2021/9/29 11:12 */ @PostMapping("sys-block") public AdmResponse sysBolck(@RequestParam("projectId") String projectId, @RequestParam("groupCode") String groupCode, @RequestParam("appId") String appId, @RequestParam("userId") String userId, @RequestParam("relationType ") String relationType) 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 relationTypeMap = AdmRelationTypeEnum.getRelationTypeMap(); if (!relationTypeMap.containsKey(relationType)){ throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc()); } return admCalcSpecialService.sysBlock(context, relationTypeMap.get(relationType)); } /*** * Description: 管网计算 * @param projectId : 项目id * @param groupCode : 集团编码 * @param appId : APP的id * @param userId : 用户id * @return : com.persagy.proxy.adm.request.AdmResponse * @author : lijie * @date :2021/9/29 11:58 * Update By lijie 2021/9/29 11:58 */ @GetMapping("calcNetworks") public AdmResponse calcNetworks(@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); return admCalcSpecialService.calcNetworks(context); } }