代码注释
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
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.WlRecordClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_STAT_BOOT, path = "/record", fallbackFactory = WlRecordClientFallbackFactory.class,contextId = "record")
|
||||
public interface WlRecordFeignClient {
|
||||
|
||||
@PostMapping("/addOrUpdateBaseData")
|
||||
HttpResult<String> addOrUpdateBaseData(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage);
|
||||
|
||||
}
|
||||
//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.WlRecordClientFallbackFactory;
|
||||
//import org.springframework.cloud.openfeign.FeignClient;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//
|
||||
///**
|
||||
// * @author xy
|
||||
// */
|
||||
//@FeignClient(value = ServerInfo.CS_STAT_BOOT, path = "/record", fallbackFactory = WlRecordClientFallbackFactory.class,contextId = "record")
|
||||
//public interface WlRecordFeignClient {
|
||||
//
|
||||
// @PostMapping("/addOrUpdateBaseData")
|
||||
// HttpResult<String> addOrUpdateBaseData(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage);
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,35 +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.WlRecordFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFeignClient> {
|
||||
@Override
|
||||
public WlRecordFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new WlRecordFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> addOrUpdateBaseData(AppAutoDataMessage appAutoDataMessage) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增或更新装置基础数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
//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.WlRecordFeignClient;
|
||||
//import feign.hystrix.FallbackFactory;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * @author xy
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//public class WlRecordClientFallbackFactory implements FallbackFactory<WlRecordFeignClient> {
|
||||
// @Override
|
||||
// public WlRecordFeignClient create(Throwable cause) {
|
||||
// //判断抛出异常是否为解码器抛出的业务异常
|
||||
// Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
// if (cause.getCause() instanceof BusinessException) {
|
||||
// BusinessException businessException = (BusinessException) cause.getCause();
|
||||
// }
|
||||
// Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
// return new WlRecordFeignClient() {
|
||||
//
|
||||
// @Override
|
||||
// public HttpResult<String> addOrUpdateBaseData(AppAutoDataMessage appAutoDataMessage) {
|
||||
// log.error("{}异常,降级处理,异常为:{}","新增或更新装置基础数据",cause.toString());
|
||||
// throw new BusinessException(finalExceptionEnum);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
package com.njcn.stat.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.mq.message.AppAutoDataMessage;
|
||||
import com.njcn.stat.service.IWlRecordService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2024/9/10 9:23
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/record")
|
||||
@Api(tags = "便携式基础数据录入")
|
||||
@AllArgsConstructor
|
||||
public class WlRecordController extends BaseController {
|
||||
|
||||
private final IWlRecordService wlRecordService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/addOrUpdateBaseData")
|
||||
@ApiOperation("新增或更新装置基础数据")
|
||||
@ApiImplicitParam(name = "appAutoDataMessage", value = "数据实体", required = true)
|
||||
public HttpResult<String> addOrUpdateBaseData(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage){
|
||||
String methodDescribe = getMethodDescribe("addOrUpdateBaseData");
|
||||
wlRecordService.addOrUpdateBaseData(appAutoDataMessage);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.stat.controller;
|
||||
//
|
||||
//import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
//import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
//import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
//import com.njcn.common.pojo.response.HttpResult;
|
||||
//import com.njcn.common.utils.HttpResultUtil;
|
||||
//import com.njcn.mq.message.AppAutoDataMessage;
|
||||
//import com.njcn.stat.service.IWlRecordService;
|
||||
//import com.njcn.web.controller.BaseController;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiImplicitParam;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
//import lombok.AllArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2024/9/10 9:23
|
||||
// */
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("/record")
|
||||
//@Api(tags = "便携式基础数据录入")
|
||||
//@AllArgsConstructor
|
||||
//public class WlRecordController extends BaseController {
|
||||
//
|
||||
// private final IWlRecordService wlRecordService;
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @PostMapping("/addOrUpdateBaseData")
|
||||
// @ApiOperation("新增或更新装置基础数据")
|
||||
// @ApiImplicitParam(name = "appAutoDataMessage", value = "数据实体", required = true)
|
||||
// public HttpResult<String> addOrUpdateBaseData(@RequestBody @Validated AppAutoDataMessage appAutoDataMessage){
|
||||
// String methodDescribe = getMethodDescribe("addOrUpdateBaseData");
|
||||
// wlRecordService.addOrUpdateBaseData(appAutoDataMessage);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.njcn.stat.service;
|
||||
|
||||
import com.njcn.mq.message.AppAutoDataMessage;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
public interface IWlRecordService {
|
||||
|
||||
void addOrUpdateBaseData(AppAutoDataMessage appAutoDataMessage);
|
||||
|
||||
}
|
||||
//package com.njcn.stat.service;
|
||||
//
|
||||
//import com.njcn.mq.message.AppAutoDataMessage;
|
||||
//
|
||||
///**
|
||||
// * @author xy
|
||||
// */
|
||||
//public interface IWlRecordService {
|
||||
//
|
||||
// void addOrUpdateBaseData(AppAutoDataMessage appAutoDataMessage);
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.pojo.enums.RedisKeyEnum;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.stat.api.StatFeignClient;
|
||||
import com.njcn.stat.api.WlRecordFeignClient;
|
||||
import com.njcn.system.api.RocketMqLogFeignClient;
|
||||
import com.njcn.system.pojo.po.RocketmqMsgErrorLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -46,8 +45,8 @@ public class AppAutoDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDa
|
||||
|
||||
@Resource
|
||||
private RocketMqLogFeignClient rocketMqLogFeignClient;
|
||||
@Resource
|
||||
private WlRecordFeignClient wlRecordFeignClient;
|
||||
// @Resource
|
||||
// private WlRecordFeignClient wlRecordFeignClient;
|
||||
|
||||
@Override
|
||||
protected void handleMessage(AppAutoDataMessage appAutoDataMessage) {
|
||||
@@ -55,10 +54,6 @@ public class AppAutoDataConsumer extends EnhanceConsumerMessageHandler<AppAutoDa
|
||||
switch (dataAttr) {
|
||||
case 0:
|
||||
log.info("分发至事件处理");
|
||||
if (appAutoDataMessage.getMsg().getDataType() == 32) {
|
||||
log.info("分发至便携式基础数据处理");
|
||||
wlRecordFeignClient.addOrUpdateBaseData(appAutoDataMessage);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
log.info("分发至实时数据");
|
||||
|
||||
@@ -67,6 +67,10 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
||||
case 16:
|
||||
log.info("分发至录波报文处理");
|
||||
waveFeignClient.analysis(appEventMessage);
|
||||
break;
|
||||
case 32:
|
||||
log.info("分发至便携式基础数据处理");
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user