治理暂态事件、文件解析功能

This commit is contained in:
2023-09-07 20:37:25 +08:00
parent 58feaf2aa0
commit d537021ffd
37 changed files with 1466 additions and 179 deletions

View File

@@ -0,0 +1,22 @@
package com.njcn.zlevent.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.mq.message.AppFileMessage;
import com.njcn.zlevent.api.fallback.FileClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_ZL_EVENT_BOOT, path = "/file", fallbackFactory = FileClientFallbackFactory.class,contextId = "file")
public interface FileFeignClient {
@PostMapping("/fileInfo")
HttpResult<String> fileInfo(AppFileMessage appFileMessage);
@PostMapping("/fileStream")
HttpResult<String> fileStream(AppFileMessage appFileMessage);
}

View File

@@ -0,0 +1,18 @@
package com.njcn.zlevent.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.mq.message.AppEventMessage;
import com.njcn.zlevent.api.fallback.EventClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_ZL_EVENT_BOOT, path = "/wave", fallbackFactory = EventClientFallbackFactory.class,contextId = "wave")
public interface WaveFeignClient {
@PostMapping("/analysis")
HttpResult<String> analysis(AppEventMessage appEventMessage);
}

View File

@@ -0,0 +1,41 @@
package com.njcn.zlevent.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.mq.message.AppFileMessage;
import com.njcn.zlevent.api.FileFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class FileClientFallbackFactory implements FallbackFactory<FileFeignClient> {
@Override
public FileFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new FileFeignClient() {
@Override
public HttpResult<String> fileInfo(AppFileMessage appFileMessage) {
log.error("{}异常,降级处理,异常为:{}","文件信息",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> fileStream(AppFileMessage appFileMessage) {
log.error("{}异常,降级处理,异常为:{}","解析文件流",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,35 @@
package com.njcn.zlevent.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.mq.message.AppEventMessage;
import com.njcn.zlevent.api.EventFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class WaveClientFallbackFactory implements FallbackFactory<EventFeignClient> {
@Override
public EventFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EventFeignClient() {
@Override
public HttpResult<String> analysis(AppEventMessage appEventMessage) {
log.error("{}异常,降级处理,异常为:{}","波形报文解析",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,27 @@
package com.njcn.zlevent.param;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/9/7 19:26
*/
@Data
public class CsEventParam implements Serializable {
private String lineId;
private String deviceId;
private String startTime;
private String endTime;
private String path;
}

View File

@@ -0,0 +1,37 @@
package com.njcn.zlevent.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/9/6 14:10
*/
@Data
public class FileInfoDto {
private String name;
private Long fileTime;
private Integer fileSize;
private String fileCheck;
private String fileChkType;
@ApiModelProperty("报文数量")
private Integer number;
private String startTime;
private String endTime;
private String deviceId;
private String lineId;
}

View File

@@ -0,0 +1,20 @@
package com.njcn.zlevent.pojo.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Map;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/9/7 9:02
*/
@Data
public class FileStreamDto implements Serializable {
private Map<Integer,String> map;
}

View File

@@ -0,0 +1,23 @@
package com.njcn.zlevent.pojo.dto;
import lombok.Data;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/9/7 18:54
*/
@Data
public class WaveTimeDto {
private String deviceId;
private String lineId;
private String startTime;
private String endTime;
}

View File

@@ -1,48 +0,0 @@
package com.njcn.zlevent.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* <p>
* 暂态事件表
* </p>
*
* @author xuyang
* @since 2023-08-23
*/
@Data
@TableName("cs_event")
public class CsEvent {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 监测点id
*/
private String lineId;
/**
* 事件名称
*/
private String name;
/**
* 展示名称
*/
private String showName;
/**
* 开始时间
*/
private LocalDateTime startTime;
}

View File

@@ -1,61 +0,0 @@
package com.njcn.zlevent.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* <p>
* 暂态事件详情表
* </p>
*
* @author xuyang
* @since 2023-08-23
*/
@Data
@TableName("cs_event_detail")
public class CsEventDetail {
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 暂态事件id
*/
private String pid;
/**
* 指标名称
*/
private String name;
/**
* 指标别名
*/
private String showName;
/**
* 数据类型
*/
private String type;
/**
* 单位
*/
private String unit;
/**
* 数值
*/
private Double data;
/**
* 相别
*/
private String phasic;
}