台账模块调整

This commit is contained in:
2023-04-24 20:11:35 +08:00
parent 93e4c8c7c0
commit f32790abba
59 changed files with 352 additions and 5032 deletions

View File

@@ -0,0 +1,36 @@
package com.njcn.device.biz.commApi;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.commApi.fallback.DeptLineGeneralClientFallbackFactory;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
*
* @author cdf
* @date 2023/4/24
*/
@FeignClient(
value = ServerInfo.DEVICE,
path = "commTerminal",
fallbackFactory = DeptLineGeneralClientFallbackFactory.class)
public interface DeptLineGeneralClient {
/**
* 通过部门获取所有子集部门所拥有的监测点
*
* @param deptGetLineParam
* @return 指定的部门监测点信息
*/
@PostMapping("/deptGetLineIds")
HttpResult<List<DeptGetChildrenDTO>> deptGetLineList(@RequestBody DeptGetLineParam deptGetLineParam);
}

View File

@@ -0,0 +1,43 @@
package com.njcn.device.biz.commApi.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.commApi.DeptLineGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenDTO;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 告警管理熔断降级
* @author yzh
* @date 2022/9/19
*/
@Slf4j
@Component
public class DeptLineGeneralClientFallbackFactory implements FallbackFactory<DeptLineGeneralClient> {
@Override
public DeptLineGeneralClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new DeptLineGeneralClient() {
@Override
public HttpResult<List<DeptGetChildrenDTO>> deptGetLineList(DeptGetLineParam deptGetLineParam) {
log.error("{}异常,降级处理,异常为:{}", "获取终获取告警策略列表", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,113 @@
package com.njcn.device.biz.enums;
import lombok.Getter;
/**
* pqs
* 终端枚举
* @author cdf
* @date 2021/6/21
*/
@Getter
public enum DeviceResponseEnum {
/**
* A0250 ~ A0349 用于终端模块的枚举
*/
DEVICE_COMMON_ERROR("A00349","终端模块异常"),
PROJECT_SAME_NAME("A0250","项目名称已存在"),
PROJECT_NO("A0251","项目为空"),
PROVINCE_SAME_NAME("A0260","省份不可重复"),
PROVINCE_GET_ERROR("A0261","未知区域"),
PROVINCE_EMPTY("A0262","省份为空"),
GD_SAME_NAME("A0270","供电公司名称已存在"),
GD_NO("A0271","未知供电公司"),
GD_EMPTY("A0272","公司为空"),
SUB_SAME_NAME("A0280","变电站名称已存在"),
SUB_NO("A0281","变电站为空"),
DEVICE_SAME_NAME("A0290","设备名称已存在"),
DEVICE_REPETITION("A0291","设备名称重复"),
DEVICE_IP_REPETITION("A0292","设备ip端口号重复"),
DEVICE_SAME_IP("A0293","当前设备ip端口号已存在"),
DEVICE_EMPTY("A0294","设备为空"),
NODE_SAME_NAME("A0259","前置机名称已存在"),
NODE_IP_SAME("A0260","前置机ip已存在"),
NODE_INFO_FAIL("A0261","前置机服务器为空"),
SUBV_NAME_REPETITION("A0262","同一变电站下母线名称重复"),
SUBV_NAME_SAME("A0263","母线名称已存在"),
SUBV_NO("A0264","母线不存在"),
LINE_NAME_REPETITION("A0264","监测点名称重复"),
LINE_NUM_USE("A0266","监测点序号已存在"),
LINE_NUM_REPETITION("A0267","监测点序号重复"),
LINE_NO("A0268","监测点不存在"),
DEVICE_LINE_BIG("A0268","每台装置下监测点数量最多6个"),
DEVICE_UNKNOWN_ERROR("A0269","终端服务未知异常"),
PARENT_INDEX_LACK("A0270","索引和实体同时存在"),
DEVICE_VOLTAGE_BIG("A0271","每台装置下母线数量最多6个"),
VOLTAGE_NUM_USE("A0272","母线序号已存在"),
REQUEST_DATA_ERROR("A2071","请求体格式有误"),
DEPT_LINE_EMPTY("A2072","当前用户部门未有监测点绑定"),
DIC_GET_EMPTY("A2073","字典获取为空"),
ALGORITHM_LINE_EMPTY("A00558","算法监测点数据为空"),
ALGORITHM_FREP_RULE("A00559","该监测点频率数据异常"),
ALGORITHM_RMS_RULE("A00560","该监测点相变压数据异常"),
ALGORITHM_RMS_LVR_RULE("A00561","该监测点线变压数据异常"),
ALGORITHM_V_THD_RULE("A00562","该监测点电压总谐波畸变率数据异常"),
ALGORITHM_V_UNBALANCE_RULE("A00563","该监测点负序电压不平衡度数据异常"),
ALGORITHM_DATA_ERROR("A00564","未获取到data数据"),
INVALID_LEVEL("A2074","非法拓扑等级"),
LINE_EMPTY("A2075","监测点为空"),
/*excel相关*/
Excel_ERROR("A2080","excel解析异常"),
FLOW_SAME_NAME("A0350","当前名称已存在"),
FLOW_FLAG("A0351","默认类型已存在"),
FLOW_ERROR("A0352","占比参数异常"),
IMPORT_ORACLE_EXCEPTION("A0353","导入旧库台账异常"),
PARAM_VAL_ERR("A0354","参数校验异常"),
QUERY_LINE_DATA_EMPTY("A0355","查询监测点数据为空"),
QUERY_SUB_DATA_EMPTY("A0356","查询变电站数据为空"),
QUERY_GD_DATA_EMPTY("A0357","查询供电公司数据为空"),
QUERY_PROVINCE_DATA_EMPTY("A0358","查询区域数据为空"),
QUERY_ALARMSTRATEGY_DATA_EMPTY("A0359","查询告警策略数据为空"),
QUERY_DEVICELEVELANDID_DATA_EMPTY("A0360","查询终端等级和id数据为空"),
QUERY_DEVICE_DATA_EMPTY("A0360","查询终端数据数据为空"),
SAME_ALARM_STRATEGY("A0361","当前等级策略已存在"),
LINE_GRADE_INDEX_ERR("A0362","异常等级索引"),
LINE_GRADE_LESS("A0363","监测点等级策略缺失")
;
private final String code;
private final String message;
DeviceResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -0,0 +1,24 @@
package com.njcn.device.biz.pojo.dto;
import lombok.Data;
import java.util.List;
/**
* pqs
*
* @author cdf
* @date 2023/4/24
*/
@Data
public class DeptGetChildrenDTO {
private String deptId;
private String deptName;
private List<String> deptChildren;
private List<String> lineIds;
}

View File

@@ -0,0 +1,28 @@
package com.njcn.device.biz.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* pqs
*
* @author cdf
* @date 2023/4/24
*/
@Data
public class DeptGetLineParam {
@NotBlank(message = "部门id不可为空")
@ApiModelProperty(name = "deptId",value = "部门id")
private String deptId;
@NotBlank(message = "系统类型不可为空")
@ApiModelProperty(name = "serverName",value = "系统类型 0.event-boot 1.harmonic-boot")
private String serverName;
}

View File

@@ -0,0 +1,51 @@
package com.njcn.device.biz.utils;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.EnumUtils;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import javax.validation.constraints.NotNull;
import java.util.Objects;
/**
* @author hongawen
* @version 1.0.0
* @date 2021年12月20日 10:03
*/
public class DeviceEnumUtil {
/**
* 获取UserResponseEnum实例
*/
public static DeviceResponseEnum getDeviceEnumResponseEnumByMessage(@NotNull Object value) {
DeviceResponseEnum deviceResponseEnum;
try {
String message = value.toString();
if(message.indexOf(StrUtil.C_COMMA)>0){
value = message.substring(message.indexOf(StrUtil.C_COMMA)+1);
}
deviceResponseEnum = EnumUtils.valueOf(DeviceResponseEnum.class, value, DeviceResponseEnum.class.getMethod(BusinessException.GET_MESSAGE_METHOD));
return Objects.isNull(deviceResponseEnum) ? DeviceResponseEnum.DEVICE_COMMON_ERROR : deviceResponseEnum;
} catch (NoSuchMethodException e) {
throw new BusinessException(CommonResponseEnum.INTERNAL_ERROR);
}
}
public static Enum<?> getExceptionEnum(HttpResult<Object> result){
//如果返回错误,且为内部错误,则直接抛出异常
CommonResponseEnum commonResponseEnum = EnumUtils.getCommonResponseEnumByCode(result.getCode());
if (commonResponseEnum == CommonResponseEnum.DEVICE_RESPONSE_ENUM) {
return getDeviceEnumResponseEnumByMessage(result.getMessage());
}
return commonResponseEnum;
}
}