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