完成责任量化功能
This commit is contained in:
@@ -49,8 +49,16 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.influxdb</groupId>
|
||||
<artifactId>influxdb-java</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pqs-influx</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<!--排除okhttp3的依赖-->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.harmonic.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.harmonic.api.fallback.HarmDataFeignClientFallbackFactory;
|
||||
import com.njcn.harmonic.pojo.param.HistoryHarmParam;
|
||||
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(
|
||||
value = ServerInfo.HARMONIC,
|
||||
path = "/harmonic",
|
||||
fallbackFactory = HarmDataFeignClientFallbackFactory.class,
|
||||
contextId = "harmonic")
|
||||
public interface HarmDataFeignClient {
|
||||
|
||||
|
||||
/**
|
||||
* 获取监测点信息
|
||||
* @param historyHarmParam 请求查询参数
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/getHistoryHarmData")
|
||||
HttpResult<HarmHistoryDataDTO> getHistoryHarmData(@RequestBody HistoryHarmParam historyHarmParam);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.harmonic.api.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.utils.DeviceEnumUtil;
|
||||
import com.njcn.harmonic.api.HarmDataFeignClient;
|
||||
import com.njcn.harmonic.pojo.param.HistoryHarmParam;
|
||||
import com.njcn.influx.pojo.dto.HarmHistoryDataDTO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年07月21日 14:31
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class HarmDataFeignClientFallbackFactory implements FallbackFactory<HarmDataFeignClient> {
|
||||
@Override
|
||||
public HarmDataFeignClient 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 HarmDataFeignClient() {
|
||||
@Override
|
||||
public HttpResult<HarmHistoryDataDTO> getHistoryHarmData(HistoryHarmParam historyHarmParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "获取谐波历史数据", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ public enum HarmonicResponseEnum {
|
||||
|
||||
REPORT_DOWNLOAD_ERROR("A00559","报表文件下载异常"),
|
||||
REPORT_TEMPLATE_DOWNLOAD_ERROR("A00560","报表模板下载异常"),
|
||||
NO_DATA("A00561","时间范围内暂无谐波数据"),
|
||||
INSUFFICIENCY_OF_INTEGRITY("A00561","时间范围内谐波数据完整性不足"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.harmonic.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.harmonic.constant.HarmonicValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年07月19日 09:23
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HistoryHarmParam implements Serializable {
|
||||
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
@NotBlank(message = HarmonicValidMessage.DATA_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
|
||||
private String searchBeginTime;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
@NotBlank(message = HarmonicValidMessage.DATA_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.TIME_FORMAT, message = "时间格式错误")
|
||||
private String searchEndTime;
|
||||
|
||||
@NotBlank(message = HarmonicValidMessage.DATA_NOT_BLANK)
|
||||
@ApiModelProperty("监测点索引")
|
||||
private String lineId;
|
||||
|
||||
|
||||
@Max(1)
|
||||
@Min(0)
|
||||
@ApiModelProperty("0-电流 1-电压")
|
||||
private int type;
|
||||
|
||||
@Max(50)
|
||||
@Min(2)
|
||||
@ApiModelProperty("谐波次数")
|
||||
private Integer time;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.njcn.harmonic.pojo.po;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.njcn.common.utils.serializer.InstantDateSerializer;
|
||||
import lombok.Data;
|
||||
import org.influxdb.annotation.Column;
|
||||
import org.influxdb.annotation.Measurement;
|
||||
@@ -18,6 +20,7 @@ import java.time.Instant;
|
||||
public class LimitTarget {
|
||||
|
||||
@Column(name = "time")
|
||||
@JsonSerialize(using = InstantDateSerializer.class)
|
||||
private Instant time;
|
||||
|
||||
@Column(name = "line_id")
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.njcn.harmonic.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @date 2022/3/15
|
||||
* 存值
|
||||
*/
|
||||
@Data
|
||||
public class QueryResultLimitVO implements Serializable {
|
||||
private QueryResult queryResult;
|
||||
private Float topLimit;
|
||||
private Float lowerLimit;
|
||||
private String lineName;
|
||||
private String targetName;
|
||||
private List<String> phaiscType;
|
||||
private List<String> unit;
|
||||
private Integer harmNum;
|
||||
}
|
||||
Reference in New Issue
Block a user