初始版本提交

This commit is contained in:
hzj
2025-06-30 20:52:31 +08:00
parent dc366ae1c3
commit c013cd2eac
6 changed files with 384 additions and 368 deletions

View File

@@ -100,17 +100,21 @@
<version>1.0.0</version> <version>1.0.0</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>common-microservice</artifactId>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-echarts</artifactId>
</exclusion> </exclusion>
<exclusion> <exclusion>
<artifactId>common-web</artifactId>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version> <!-- 使用最新稳定版 -->
</dependency>
</dependencies> </dependencies>

View File

@@ -1,12 +1,17 @@
package com.njcn.gather.event; package com.njcn.gather.event;
import com.njcn.event.file.component.WavePicComponent;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
@Slf4j @Slf4j
@SpringBootApplication @SpringBootApplication(scanBasePackages = "com.njcn")
//@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = WavePicComponent.class))
@MapperScan("com.njcn.**.mapper") @MapperScan("com.njcn.**.mapper")
public class EventSmartApplication { public class EventSmartApplication {

View File

@@ -16,6 +16,7 @@ import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
import com.njcn.gather.event.transientes.pojo.po.PqsDepts; import com.njcn.gather.event.transientes.pojo.po.PqsDepts;
import com.njcn.gather.event.transientes.pojo.po.PqsUser; import com.njcn.gather.event.transientes.pojo.po.PqsUser;
import com.njcn.gather.event.transientes.pojo.po.PqsUserSet; import com.njcn.gather.event.transientes.pojo.po.PqsUserSet;
import com.njcn.gather.event.transientes.service.EventGateService;
import com.njcn.gather.event.transientes.service.PqsDeptsService; import com.njcn.gather.event.transientes.service.PqsDeptsService;
import com.njcn.gather.event.transientes.service.PqsUserService; import com.njcn.gather.event.transientes.service.PqsUserService;
import com.njcn.gather.event.transientes.service.PqsUsersetService; import com.njcn.gather.event.transientes.service.PqsUsersetService;
@@ -27,6 +28,7 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -63,6 +65,7 @@ public class EventGateController extends BaseController {
private final PqsUsersetService pqsUsersetService; private final PqsUsersetService pqsUsersetService;
private final PqLineMapper pqLineMapper; private final PqLineMapper pqLineMapper;
private final EventGateService eventGateService;
@@ -92,8 +95,8 @@ public class EventGateController extends BaseController {
@ApiOperation("暂态事件波形分析") @ApiOperation("暂态事件波形分析")
public HttpResult<WaveDataDTO> getTransientAnalyseWave(@RequestBody MonitorTerminalParam param){ public HttpResult<WaveDataDTO> getTransientAnalyseWave(@RequestBody MonitorTerminalParam param){
String methodDescribe = getMethodDescribe("getTransientAnalyseWave"); String methodDescribe = getMethodDescribe("getTransientAnalyseWave");
// WaveDataDTO wave = transientService.getTransientAnalyseWave(param); WaveDataDTO wave = eventGateService.getTransientAnalyseWave(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
} }

View File

@@ -1,255 +1,255 @@
package com.njcn.gather.event.transientes.handler; //package com.njcn.gather.event.transientes.handler;
//
import cn.hutool.core.text.StrFormatter; //import cn.hutool.core.text.StrFormatter;
import cn.hutool.core.util.StrUtil; //import cn.hutool.core.util.StrUtil;
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.common.utils.LogUtil; //import com.njcn.common.utils.LogUtil;
import com.njcn.web.utils.HttpResultUtil; //import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.HttpServletUtil; //import com.njcn.web.utils.HttpServletUtil;
import com.njcn.web.utils.ReflectCommonUtil; //import com.njcn.web.utils.ReflectCommonUtil;
import lombok.AllArgsConstructor; //import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; //import lombok.extern.slf4j.Slf4j;
import org.json.JSONException; //import org.json.JSONException;
import org.springframework.validation.ObjectError; //import org.springframework.validation.ObjectError;
import org.springframework.web.HttpMediaTypeNotSupportedException; //import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException; //import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler; //import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; //import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.util.NestedServletException; //import org.springframework.web.util.NestedServletException;
//
import javax.annotation.Resource; //import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; //import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolation; //import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException; //import javax.validation.ConstraintViolationException;
import java.util.ArrayList; //import java.util.ArrayList;
import java.util.List; //import java.util.List;
import java.util.concurrent.*; //import java.util.concurrent.*;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
import java.util.stream.Stream; //import java.util.stream.Stream;
//
/** ///**
* 全局通用业务异常处理器 // * 全局通用业务异常处理器
* // *
* @author hongawen // * @author hongawen
* @version 1.0.0 // * @version 1.0.0
* @date 2021年04月20日 18:04 // * @date 2021年04月20日 18:04
*/ // */
@Slf4j //@Slf4j
@AllArgsConstructor //@AllArgsConstructor
@RestControllerAdvice //@RestControllerAdvice
public class GlobalBusinessExceptionHandler { //public class GlobalBusinessExceptionHandler {
//
//
//
private final ThreadPoolExecutor executor = new ThreadPoolExecutor( // private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
4, 8, 30, TimeUnit.SECONDS, // 4, 8, 30, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(100), // new LinkedBlockingQueue<>(100),
// 队列满时由主线程执行 // // 队列满时由主线程执行
new ThreadPoolExecutor.CallerRunsPolicy() // new ThreadPoolExecutor.CallerRunsPolicy()
); // );
//
//
/** // /**
* 捕获业务功能异常,通常为业务数据抛出的异常 // * 捕获业务功能异常,通常为业务数据抛出的异常
* // *
* @param businessException 业务异常 // * @param businessException 业务异常
*/ // */
@ExceptionHandler(BusinessException.class) // @ExceptionHandler(BusinessException.class)
public HttpResult<String> handleBusinessException(BusinessException businessException) { // public HttpResult<String> handleBusinessException(BusinessException businessException) {
String operate = ReflectCommonUtil.getMethodDescribeByException(businessException); // String operate = ReflectCommonUtil.getMethodDescribeByException(businessException);
// recodeBusinessExceptionLog(businessException, businessException.getMessage()); // // recodeBusinessExceptionLog(businessException, businessException.getMessage());
return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate); // return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate);
} // }
//
//
/** // /**
* 空指针异常捕捉 // * 空指针异常捕捉
* // *
* @param nullPointerException 空指针异常 // * @param nullPointerException 空指针异常
*/ // */
@ExceptionHandler(NullPointerException.class) // @ExceptionHandler(NullPointerException.class)
public HttpResult<String> handleNullPointerException(NullPointerException nullPointerException) { // public HttpResult<String> handleNullPointerException(NullPointerException nullPointerException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage(), nullPointerException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage(), nullPointerException);
//recodeBusinessExceptionLog(nullPointerException, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage()); // //recodeBusinessExceptionLog(nullPointerException, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NULL_POINTER_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(nullPointerException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NULL_POINTER_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(nullPointerException));
} // }
//
/** // /**
* 算数运算异常 // * 算数运算异常
* // *
* @param arithmeticException 算数运算异常由于除数为0引起的异常 // * @param arithmeticException 算数运算异常由于除数为0引起的异常
*/ // */
@ExceptionHandler(ArithmeticException.class) // @ExceptionHandler(ArithmeticException.class)
public HttpResult<String> handleArithmeticException(ArithmeticException arithmeticException) { // public HttpResult<String> handleArithmeticException(ArithmeticException arithmeticException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage(), arithmeticException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage(), arithmeticException);
// recodeBusinessExceptionLog(arithmeticException, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(arithmeticException, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ARITHMETIC_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(arithmeticException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ARITHMETIC_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(arithmeticException));
} // }
//
/** // /**
* 类型转换异常捕捉 // * 类型转换异常捕捉
* // *
* @param classCastException 类型转换异常 // * @param classCastException 类型转换异常
*/ // */
@ExceptionHandler(ClassCastException.class) // @ExceptionHandler(ClassCastException.class)
public HttpResult<String> handleClassCastException(ClassCastException classCastException) { // public HttpResult<String> handleClassCastException(ClassCastException classCastException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage(), classCastException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage(), classCastException);
// recodeBusinessExceptionLog(classCastException, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(classCastException, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.CLASS_CAST_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(classCastException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.CLASS_CAST_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(classCastException));
} // }
//
//
/** // /**
* 索引下标越界异常捕捉 // * 索引下标越界异常捕捉
* // *
* @param indexOutOfBoundsException 索引下标越界异常 // * @param indexOutOfBoundsException 索引下标越界异常
*/ // */
@ExceptionHandler(IndexOutOfBoundsException.class) // @ExceptionHandler(IndexOutOfBoundsException.class)
public HttpResult<String> handleIndexOutOfBoundsException(IndexOutOfBoundsException indexOutOfBoundsException) { // public HttpResult<String> handleIndexOutOfBoundsException(IndexOutOfBoundsException indexOutOfBoundsException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage(), indexOutOfBoundsException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage(), indexOutOfBoundsException);
// recodeBusinessExceptionLog(indexOutOfBoundsException, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(indexOutOfBoundsException, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException));
} // }
//
/** // /**
* 前端请求后端,请求中参数的媒体方式不支持异常 // * 前端请求后端,请求中参数的媒体方式不支持异常
* // *
* @param httpMediaTypeNotSupportedException 请求中参数的媒体方式不支持异常 // * @param httpMediaTypeNotSupportedException 请求中参数的媒体方式不支持异常
*/ // */
@ExceptionHandler(HttpMediaTypeNotSupportedException.class) // @ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) { // public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage(), httpMediaTypeNotSupportedException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage(), httpMediaTypeNotSupportedException);
// 然后提取错误提示信息进行返回 // // 然后提取错误提示信息进行返回
// recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(httpMediaTypeNotSupportedException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(httpMediaTypeNotSupportedException));
} // }
//
/** // /**
* 前端请求后端,参数校验异常捕捉 // * 前端请求后端,参数校验异常捕捉
* RequestBody注解参数异常 // * RequestBody注解参数异常
* // *
* @param methodArgumentNotValidException 参数校验异常 // * @param methodArgumentNotValidException 参数校验异常
*/ // */
@ExceptionHandler(MethodArgumentNotValidException.class) // @ExceptionHandler(MethodArgumentNotValidException.class)
public HttpResult<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException methodArgumentNotValidException) { // public HttpResult<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException methodArgumentNotValidException) {
// 从异常对象中拿到allErrors数据 // // 从异常对象中拿到allErrors数据
String messages = methodArgumentNotValidException.getBindingResult().getAllErrors() // String messages = methodArgumentNotValidException.getBindingResult().getAllErrors()
.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining("")); // .stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(""));
// 然后提取错误提示信息进行返回 // // 然后提取错误提示信息进行返回
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages); // LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
// recodeBusinessExceptionLog(methodArgumentNotValidException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(methodArgumentNotValidException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages, ControllerUtil.getMethodArgumentNotValidException(methodArgumentNotValidException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages, ControllerUtil.getMethodArgumentNotValidException(methodArgumentNotValidException));
} // }
//
/** // /**
* 前端请求后端,参数校验异常捕捉 // * 前端请求后端,参数校验异常捕捉
* PathVariable注解、RequestParam注解参数异常 // * PathVariable注解、RequestParam注解参数异常
* // *
* @param constraintViolationException 参数校验异常 // * @param constraintViolationException 参数校验异常
*/ // */
@ExceptionHandler(ConstraintViolationException.class) // @ExceptionHandler(ConstraintViolationException.class)
public HttpResult<String> constraintViolationExceptionExceptionHandler(ConstraintViolationException constraintViolationException) { // public HttpResult<String> constraintViolationExceptionExceptionHandler(ConstraintViolationException constraintViolationException) {
String exceptionMessage = constraintViolationException.getMessage(); // String exceptionMessage = constraintViolationException.getMessage();
StringBuilder messages = new StringBuilder(); // StringBuilder messages = new StringBuilder();
if (exceptionMessage.indexOf(StrUtil.COMMA) > 0) { // if (exceptionMessage.indexOf(StrUtil.COMMA) > 0) {
String[] tempMessage = exceptionMessage.split(StrUtil.COMMA); // String[] tempMessage = exceptionMessage.split(StrUtil.COMMA);
Stream.of(tempMessage).forEach(message -> { // Stream.of(tempMessage).forEach(message -> {
messages.append(message.substring(message.indexOf(StrUtil.COLON) + 2)).append(';'); // messages.append(message.substring(message.indexOf(StrUtil.COLON) + 2)).append(';');
}); // });
} else { // } else {
messages.append(exceptionMessage.substring(exceptionMessage.indexOf(StrUtil.COLON) + 2)); // messages.append(exceptionMessage.substring(exceptionMessage.indexOf(StrUtil.COLON) + 2));
} // }
// 然后提取错误提示信息进行返回 // // 然后提取错误提示信息进行返回
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages); // LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
// recodeBusinessExceptionLog(constraintViolationException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(constraintViolationException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
List<ConstraintViolation<?>> constraintViolationList = new ArrayList<>(constraintViolationException.getConstraintViolations()); // List<ConstraintViolation<?>> constraintViolationList = new ArrayList<>(constraintViolationException.getConstraintViolations());
ConstraintViolation<?> constraintViolation = constraintViolationList.get(0); // ConstraintViolation<?> constraintViolation = constraintViolationList.get(0);
Class<?> rootBeanClass = constraintViolation.getRootBeanClass(); // Class<?> rootBeanClass = constraintViolation.getRootBeanClass();
//判断校验参数异常捕获的根源是controller还是service处 // //判断校验参数异常捕获的根源是controller还是service处
if (rootBeanClass.getName().endsWith("Controller")) { // if (rootBeanClass.getName().endsWith("Controller")) {
String methodName = constraintViolation.getPropertyPath().toString().substring(0, constraintViolation.getPropertyPath().toString().indexOf(StrUtil.DOT)); // String methodName = constraintViolation.getPropertyPath().toString().substring(0, constraintViolation.getPropertyPath().toString().indexOf(StrUtil.DOT));
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByClassAndMethodName(rootBeanClass, methodName)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByClassAndMethodName(rootBeanClass, methodName));
} else { // } else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByException(constraintViolationException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByException(constraintViolationException));
} // }
//
} // }
//
//
/** // /**
* 索引下标越界异常捕捉 // * 索引下标越界异常捕捉
* // *
* @param illegalArgumentException 参数校验异常 // * @param illegalArgumentException 参数校验异常
*/ // */
@ExceptionHandler(IllegalArgumentException.class) // @ExceptionHandler(IllegalArgumentException.class)
public HttpResult<String> handleIndexOutOfBoundsException(IllegalArgumentException illegalArgumentException) { // public HttpResult<String> handleIndexOutOfBoundsException(IllegalArgumentException illegalArgumentException) {
LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), illegalArgumentException); // LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), illegalArgumentException);
// recodeBusinessExceptionLog(illegalArgumentException, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage()); // // recodeBusinessExceptionLog(illegalArgumentException, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, illegalArgumentException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(illegalArgumentException)); // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, illegalArgumentException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(illegalArgumentException));
} // }
//
//
/** // /**
* 未声明异常捕捉 // * 未声明异常捕捉
* // *
* @param exception 未声明异常 // * @param exception 未声明异常
*/ // */
@ExceptionHandler(Exception.class) // @ExceptionHandler(Exception.class)
public HttpResult<String> handleException(Exception exception) { // public HttpResult<String> handleException(Exception exception) {
//针对fallbackFactory降级异常特殊处理 // //针对fallbackFactory降级异常特殊处理
Exception tempException = exception; // Exception tempException = exception;
String exceptionCause = CommonResponseEnum.UN_DECLARE.getMessage(); // String exceptionCause = CommonResponseEnum.UN_DECLARE.getMessage();
String code = CommonResponseEnum.UN_DECLARE.getCode(); // String code = CommonResponseEnum.UN_DECLARE.getCode();
if (exception instanceof NestedServletException) { // if (exception instanceof NestedServletException) {
Throwable cause = exception.getCause(); // Throwable cause = exception.getCause();
if (cause instanceof AssertionError) { // if (cause instanceof AssertionError) {
if (cause.getCause() instanceof BusinessException) { // if (cause.getCause() instanceof BusinessException) {
tempException = (BusinessException) cause.getCause(); // tempException = (BusinessException) cause.getCause();
BusinessException tempBusinessException = (BusinessException) cause.getCause(); // BusinessException tempBusinessException = (BusinessException) cause.getCause();
exceptionCause = tempBusinessException.getMessage(); // exceptionCause = tempBusinessException.getMessage();
code = tempBusinessException.getCode(); // code = tempBusinessException.getCode();
}
}
}
LogUtil.logExceptionStackInfo(exceptionCause, tempException);
// recodeBusinessExceptionLog(exception, exceptionCause);
//判断方法上是否有自定义注解,做特殊处理
// Method method = ReflectCommonUtil.getMethod(exception);
// if (!Objects.isNull(method)){
// if(method.isAnnotationPresent(ReturnMsg.class)){
// return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}",exceptionCause));
// } // }
// } // }
return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(tempException), StrUtil.C_COMMA, exceptionCause)); // }
} // LogUtil.logExceptionStackInfo(exceptionCause, tempException);
// // recodeBusinessExceptionLog(exception, exceptionCause);
// //判断方法上是否有自定义注解,做特殊处理
/** //// Method method = ReflectCommonUtil.getMethod(exception);
* json解析异常 //// if (!Objects.isNull(method)){
* //// if(method.isAnnotationPresent(ReturnMsg.class)){
* @param jsonException json参数 //// return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}",exceptionCause));
*/ //// }
@ExceptionHandler(JSONException.class) //// }
public HttpResult<String> handleIndexOutOfBoundsException(JSONException jsonException) { // return HttpResultUtil.assembleResult(code, null, StrFormatter.format("{}{}{}", ReflectCommonUtil.getMethodDescribeByException(tempException), StrUtil.C_COMMA, exceptionCause));
LogUtil.logExceptionStackInfo(CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage(), jsonException); // }
// recodeBusinessExceptionLog(jsonException, CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage()); //
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.JSON_CONVERT_EXCEPTION, jsonException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(jsonException)); //
} // /**
/* // * json解析异常
private void recodeBusinessExceptionLog(Exception businessException, String methodDescribe) { // *
HttpServletRequest httpServletRequest = HttpServletUtil.getRequest(); // * @param jsonException json参数
Future<?> future = executor.submit(() -> { // */
HttpServletUtil.setRequest(httpServletRequest); // @ExceptionHandler(JSONException.class)
sysLogAuditService.recodeBusinessExceptionLog(businessException, methodDescribe); // public HttpResult<String> handleIndexOutOfBoundsException(JSONException jsonException) {
}); // LogUtil.logExceptionStackInfo(CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage(), jsonException);
try { // // recodeBusinessExceptionLog(jsonException, CommonResponseEnum.JSON_CONVERT_EXCEPTION.getMessage());
// 抛出 ExecutionException // return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.JSON_CONVERT_EXCEPTION, jsonException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(jsonException));
future.get(); // }
} catch (ExecutionException | InterruptedException e) { ///*
log.error("保存审计日志异常,异常为:" + e.getMessage()); // private void recodeBusinessExceptionLog(Exception businessException, String methodDescribe) {
} // HttpServletRequest httpServletRequest = HttpServletUtil.getRequest();
}*/ // Future<?> future = executor.submit(() -> {
// HttpServletUtil.setRequest(httpServletRequest);
} // sysLogAuditService.recodeBusinessExceptionLog(businessException, methodDescribe);
// });
// try {
// // 抛出 ExecutionException
// future.get();
// } catch (ExecutionException | InterruptedException e) {
// log.error("保存审计日志异常,异常为:" + e.getMessage());
// }
// }*/
//
//}

View File

@@ -1,106 +1,74 @@
//package com.njcn.gather.event.transientes.service.impl; package com.njcn.gather.event.transientes.service.impl;
//
//import cn.hutool.core.util.StrUtil; import cn.hutool.core.collection.CollectionUtil;
//import com.njcn.common.pojo.exception.BusinessException; import cn.hutool.core.util.StrUtil;
//import com.njcn.common.utils.PubUtils; import com.njcn.common.pojo.exception.BusinessException;
//import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.common.utils.PubUtils;
//import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.file.component.WaveFileComponent;
//import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam; import com.njcn.event.file.pojo.dto.WaveDataDTO;
//import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail; import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
//import com.njcn.gather.event.transientes.service.EventGateService; import com.njcn.gather.event.devcie.mapper.PqLinedetailMapper;
//import com.njcn.gather.event.transientes.service.PqsEventdetailService; import com.njcn.gather.event.devcie.pojo.po.PqLine;
//import lombok.RequiredArgsConstructor; import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
//import lombok.extern.slf4j.Slf4j; import com.njcn.gather.event.devcie.service.PqLineService;
//import org.springframework.stereotype.Service; import com.njcn.gather.event.transientes.pojo.param.MonitorTerminalParam;
// import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail;
//import java.io.File; import com.njcn.gather.event.transientes.service.EventGateService;
//import java.io.InputStream; import com.njcn.gather.event.transientes.service.PqsEventdetailService;
//import java.util.Objects; import lombok.RequiredArgsConstructor;
// import lombok.extern.slf4j.Slf4j;
///** import org.springframework.stereotype.Service;
// * @Author: cdf
// * @CreateTime: 2025-06-30 import java.io.File;
// * @Description: import java.io.InputStream;
// */ import java.util.List;
//@Service import java.util.Objects;
//@RequiredArgsConstructor import java.util.stream.Collectors;
//@Slf4j import java.util.stream.Stream;
//public class EventGateServiceImpl implements EventGateService {
// /**
// private final PqsEventdetailService pqsEventdetailService; * @Author: cdf
// * @CreateTime: 2025-06-30
// * @Description:
// @Override */
// public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) { @Service
// WaveDataDTO waveDataDTO; @RequiredArgsConstructor
// //获取暂降事件 @Slf4j
// PqsEventdetail eventDetail = pqsEventdetailService.getById(param.getId()); public class EventGateServiceImpl implements EventGateService {
// LineDetailDataVO lineDetailData = new LineDetailDataVO();
// MonitorVO monitorVO = new MonitorVO(); private final PqsEventdetailService pqsEventdetailService;
// String ip; private final WaveFileComponent waveFileComponent;
// if (param.getSystemType() == 0) { private final PqLineService pqLineService;
// lineDetailData = lineFeignClient.getLineDetailData(eventDetail.getMeasurementPointId()).getData(); private final PqLinedetailMapper pqLinedetailMapper;
// ip = lineDetailData.getIp(); @Override
// } else { public WaveDataDTO getTransientAnalyseWave(MonitorTerminalParam param) {
// param.setId(eventDetail.getMeasurementPointId()); WaveDataDTO waveDataDTO;
// monitorVO = monitorClient.getMonitorTerminal(param).getData(); //获取暂降事件
// ip = monitorVO.getIp(); PqsEventdetail eventDetail = pqsEventdetailService.getById(param.getId());
// } String waveName = eventDetail.getWavename();
// String waveName = eventDetail.getWavePath(); String cfgPath, datPath;
// String cfgPath, datPath, cfgPath2, datPath2; if (StrUtil.isBlank(waveName)) {
// if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) { throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
// cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG; }
// datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT; cfgPath = "D:\\10.98.182.99\\"+waveName+".CFG";
// log.info("本地磁盘波形文件路径----" + cfgPath); datPath = "D:\\10.98.182.99\\"+waveName+".DAT";
// InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath); log.info("本地磁盘波形文件路径----" + cfgPath);
// InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath); InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) { InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
// } throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1); }
// } else { waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
// cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
// datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT; waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
// //适配文件后缀小写 Integer lineid = eventDetail.getLineid();
// cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase(); PqLine pqLine = pqLineService.getById(lineid);
// datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase(); PqLinedetail pqLinedetail = pqLinedetailMapper.selectById(lineid);
// log.info("文件服务器波形文件路径----" + cfgPath); waveDataDTO.setPtType(pqLinedetail.getPttype());
// try ( waveDataDTO.setPt(pqLine.getPt1()/ pqLine.getPt2());
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath); waveDataDTO.setCt(pqLine.getCt1()/ pqLine.getCt2());
// InputStream datStream = fileStorageUtil.getFileStream(datPath) waveDataDTO.setMonitorName(pqLine.getName());
// ) { return waveDataDTO;
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND); }
// } }
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
// } catch (Exception e) {
// try {
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
// InputStream datStream = fileStorageUtil.getFileStream(datPath2);
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
// }
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
// } catch (Exception e1) {
// throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
// }
//
// }
// }
// waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
// if (param.getSystemType() == 0) {
// waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
// double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]);
// double pt2 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[1]);
// double ct1 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[0]);
// double ct2 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[1]);
// waveDataDTO.setPt(pt1 / pt2);
// waveDataDTO.setCt(ct1 / ct2);
// return waveDataDTO;
// }
// waveDataDTO.setPtType(Integer.valueOf(monitorVO.getTerminalWiringMethod()));
// waveDataDTO.setPt(monitorVO.getPt1() / monitorVO.getPt2());
// waveDataDTO.setCt(monitorVO.getCt1() / monitorVO.getCt2());
// return waveDataDTO;
// }
//}

View File

@@ -1,3 +1,7 @@
#当前服务的基本信息
microservice:
ename: 12345
name: 12345
server: server:
port: 18093 port: 18093
spring: spring:
@@ -46,9 +50,9 @@ mybatis-plus:
#驼峰命名 #驼峰命名
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
#配置sql日志输出 #配置sql日志输出
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#关闭日志输出 #关闭日志输出
# log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
global-config: global-config:
db-config: db-config:
#指定主键生成策略 #指定主键生成策略
@@ -60,4 +64,36 @@ SYS_TYPE_WT: 983f9dfe-4f9a-4c96-89d8-7d425a1f1d6c
db: db:
type: oracle type: oracle
#文件位置配置
business:
#处理波形数据位置
# wavePath: D://comtrade
wavePath: /usr/local/comtrade
#处理临时数据
#tempPath: D://file
tempPath: /usr/local/file
#文件存储的方式
file:
storage: 3
#oss服务器配置
min:
io:
endpoint: http://192.168.1.13:9009
accessKey: minio
secretKey: minio@123
bucket: excelreport
#华为obs服务器配置
huawei:
access-key: J9GS9EA79PZ60OK23LWP
security-key: BirGrAFDSLxU8ow5fffyXgZRAmMRb1R1AdqCI60d
obs:
bucket: test-8601
endpoint: https://obs.cn-east-3.myhuaweicloud.com
# 单位为秒
expire: 3600
#线程池配置信息
threadPool:
corePoolSize: 10
maxPoolSize: 20
queueCapacity: 500
keepAliveSeconds: 60