1.物消息路由转发功能

2.物解析功能
This commit is contained in:
2023-08-14 21:06:19 +08:00
parent 02f5f7c031
commit 1d75cce63d
34 changed files with 869 additions and 449 deletions

View File

@@ -0,0 +1,19 @@
package com.njcn.stat.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.mq.message.AppAutoDataMessage;
import com.njcn.stat.api.fallback.RtClientFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_STAT_BOOT, path = "/stat", fallbackFactory = RtClientFallbackFactory.class,contextId = "stat")
public interface RtFeignClient {
@PostMapping("/analysis")
HttpResult<String> analysis(AppAutoDataMessage appAutoDataMessage);
}

View File

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

View File

@@ -0,0 +1,37 @@
package com.njcn.stat.enums;
import lombok.Getter;
/**
* @author xuyang
* @version 1.0.0
* @date 2023年04月17日 10:50
*/
@Getter
public enum StatResponseEnum {
/**
* A1001 ~ A1099 用于用户模块的枚举
* <p>
*/
STAT_ERROR("A10001","统计数据模块错误"),
DATA_ARRAY_NULL("A10002","详细数据为空"),
AUTO_DATA_NULL("A10002","上送数据为空"),
DICT_NULL("A10002","字典数据为空"),
LINE_NULL("A10002","监测点为空"),
ARRAY_DATA_NOT_MATCH("A10003","上送数据与模板匹配失败"),
;
private final String code;
private final String message;
StatResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}