远程通知反馈接口
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.njcn.gather.event.devcie.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PqLinedetailMapper extends BaseMapper<PqLinedetail> {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.gather.event.devcie.pojo.po;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-06-26
|
||||
* @Description:
|
||||
*/
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("PQ_LINEDETAIL")
|
||||
public class PqLinedetail {
|
||||
|
||||
@TableId(value = "LINE_INDEX", type = IdType.INPUT)
|
||||
private Integer lineIndex;
|
||||
|
||||
private Integer gdIndex;
|
||||
|
||||
private Integer subIndex;
|
||||
|
||||
private String lineName;
|
||||
|
||||
private Integer pttype;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date lastTime;
|
||||
|
||||
private Integer tinterval;
|
||||
|
||||
private String loadtype;
|
||||
|
||||
private String businesstype;
|
||||
|
||||
private String remark;
|
||||
|
||||
private String monitorId;
|
||||
|
||||
private Integer powerid;
|
||||
|
||||
private String objname;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Integer statflag;
|
||||
|
||||
private String lineGrade;
|
||||
|
||||
private String powerSubstationName;
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import cn.hutool.json.JSONObject;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
|
||||
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
|
||||
import com.njcn.gather.event.transientes.websocket.WebSocketServer;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -12,6 +14,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
@@ -25,9 +28,13 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventGateController extends BaseController {
|
||||
@Value("${SYS_TYPE_ZT}")
|
||||
private String sysTypeZt;
|
||||
|
||||
private final WebSocketServer webSocketServer;
|
||||
|
||||
private final PqsDeptslineService pqsDeptslineService;
|
||||
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/eventMsg")
|
||||
@@ -37,10 +44,20 @@ public class EventGateController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("eventMsg");
|
||||
log.info("接收到暂降事件:{}",msg);
|
||||
|
||||
JSONObject jsonObject = new JSONObject(msg);
|
||||
webSocketServer.sendMessageToAll(jsonObject.toString());
|
||||
//JSONObject jsonObject = new JSONObject(msg);
|
||||
webSocketServer.sendMessageToAll(msg);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void sendMessage(JSONObject jsonObject){
|
||||
Integer lineId = Integer.valueOf(jsonObject.get("lineid").toString());
|
||||
|
||||
pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex,lineId).eq(PqsDeptsline::getSystype,sysTypeZt);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
|
||||
import com.njcn.gather.event.transientes.pojo.param.MessageEventFeedbackParam;
|
||||
import com.njcn.gather.event.transientes.pojo.po.MsgEventInfo;
|
||||
import com.njcn.gather.event.transientes.pojo.vo.*;
|
||||
import com.njcn.gather.event.transientes.service.LargeScreenCountService;
|
||||
@@ -16,6 +17,7 @@ import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -118,13 +120,33 @@ public class LargeScreenCountController extends BaseController {
|
||||
@OperateInfo
|
||||
@PostMapping("/msgSendList")
|
||||
@ApiOperation("远程通知列表")
|
||||
@ApiImplicitParam(name = "eventId", value = "暂降事件id", required = true)
|
||||
@ApiImplicitParam(name = "largeScreenCountParam", value = "参数", required = true)
|
||||
public HttpResult<List<MsgEventInfo>> msgSendList(@RequestBody LargeScreenCountParam largeScreenCountParam) {
|
||||
String methodDescribe = getMethodDescribe("msgSendList");
|
||||
List<MsgEventInfo> result = largeScreenCountService.msgSendList(largeScreenCountParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/hasSendMsgPage")
|
||||
@ApiOperation("已发送短信列表")
|
||||
@ApiImplicitParam(name = "largeScreenCountParam", value = "参数", required = true)
|
||||
public HttpResult<Page<MsgEventInfo>> hasSendMsgPage(@RequestBody LargeScreenCountParam largeScreenCountParam) {
|
||||
String methodDescribe = getMethodDescribe("hasSendMsgPage");
|
||||
Page<MsgEventInfo> result = largeScreenCountService.hasSendMsgPage(largeScreenCountParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/msgHandle")
|
||||
@ApiOperation("短信处理")
|
||||
@ApiImplicitParam(name = "eventId", value = "暂降事件id", required = true)
|
||||
public HttpResult<Boolean> msgHandle(@RequestBody @Validated MessageEventFeedbackParam messageEventFeedbackParam) {
|
||||
String methodDescribe = getMethodDescribe("msgHandle");
|
||||
largeScreenCountService.msgHandle(messageEventFeedbackParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.gather.event.transientes.handler;
|
||||
|
||||
import com.njcn.common.pojo.constant.LogInfo;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年06月22日 10:25
|
||||
*/
|
||||
@Slf4j
|
||||
public class ControllerUtil {
|
||||
|
||||
/**
|
||||
* 针对methodArgumentNotValidException 异常的处理
|
||||
* @author cdf
|
||||
*/
|
||||
public static String getMethodArgumentNotValidException(MethodArgumentNotValidException methodArgumentNotValidException) {
|
||||
String operate = LogInfo.UNKNOWN_OPERATE;
|
||||
Method method = null;
|
||||
try {
|
||||
method = methodArgumentNotValidException.getParameter().getMethod();
|
||||
if (!Objects.isNull(method) && method.isAnnotationPresent(ApiOperation.class)) {
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
operate = apiOperation.value();
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("根据方法参数非法异常获取@ApiOperation注解值失败,参数非法异常信息:{},方法名:{},异常信息:{}",methodArgumentNotValidException.getMessage(),method,e.getMessage());
|
||||
}
|
||||
return operate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package com.njcn.gather.event.transientes.handler;
|
||||
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.common.utils.LogUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import com.njcn.web.utils.ReflectCommonUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONException;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.util.NestedServletException;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.ConstraintViolation;
|
||||
import javax.validation.ConstraintViolationException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 全局通用业务异常处理器
|
||||
*
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2021年04月20日 18:04
|
||||
*/
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RestControllerAdvice
|
||||
public class GlobalBusinessExceptionHandler {
|
||||
|
||||
|
||||
|
||||
private final ThreadPoolExecutor executor = new ThreadPoolExecutor(
|
||||
4, 8, 30, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(100),
|
||||
// 队列满时由主线程执行
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 捕获业务功能异常,通常为业务数据抛出的异常
|
||||
*
|
||||
* @param businessException 业务异常
|
||||
*/
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
public HttpResult<String> handleBusinessException(BusinessException businessException) {
|
||||
String operate = ReflectCommonUtil.getMethodDescribeByException(businessException);
|
||||
// recodeBusinessExceptionLog(businessException, businessException.getMessage());
|
||||
return HttpResultUtil.assembleBusinessExceptionResult(businessException, null, operate);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 空指针异常捕捉
|
||||
*
|
||||
* @param nullPointerException 空指针异常
|
||||
*/
|
||||
@ExceptionHandler(NullPointerException.class)
|
||||
public HttpResult<String> handleNullPointerException(NullPointerException nullPointerException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage(), nullPointerException);
|
||||
//recodeBusinessExceptionLog(nullPointerException, CommonResponseEnum.NULL_POINTER_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NULL_POINTER_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(nullPointerException));
|
||||
}
|
||||
|
||||
/**
|
||||
* 算数运算异常
|
||||
*
|
||||
* @param arithmeticException 算数运算异常,由于除数为0引起的异常
|
||||
*/
|
||||
@ExceptionHandler(ArithmeticException.class)
|
||||
public HttpResult<String> handleArithmeticException(ArithmeticException arithmeticException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage(), arithmeticException);
|
||||
// recodeBusinessExceptionLog(arithmeticException, CommonResponseEnum.ARITHMETIC_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ARITHMETIC_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(arithmeticException));
|
||||
}
|
||||
|
||||
/**
|
||||
* 类型转换异常捕捉
|
||||
*
|
||||
* @param classCastException 类型转换异常
|
||||
*/
|
||||
@ExceptionHandler(ClassCastException.class)
|
||||
public HttpResult<String> handleClassCastException(ClassCastException classCastException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage(), classCastException);
|
||||
// recodeBusinessExceptionLog(classCastException, CommonResponseEnum.CLASS_CAST_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.CLASS_CAST_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(classCastException));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 索引下标越界异常捕捉
|
||||
*
|
||||
* @param indexOutOfBoundsException 索引下标越界异常
|
||||
*/
|
||||
@ExceptionHandler(IndexOutOfBoundsException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(IndexOutOfBoundsException indexOutOfBoundsException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage(), indexOutOfBoundsException);
|
||||
// recodeBusinessExceptionLog(indexOutOfBoundsException, CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.INDEX_OUT_OF_BOUNDS_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(indexOutOfBoundsException));
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端请求后端,请求中参数的媒体方式不支持异常
|
||||
*
|
||||
* @param httpMediaTypeNotSupportedException 请求中参数的媒体方式不支持异常
|
||||
*/
|
||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||
public HttpResult<String> httpMediaTypeNotSupportedExceptionHandler(HttpMediaTypeNotSupportedException httpMediaTypeNotSupportedException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage(), httpMediaTypeNotSupportedException);
|
||||
// 然后提取错误提示信息进行返回
|
||||
// recodeBusinessExceptionLog(httpMediaTypeNotSupportedException, CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.HTTP_MEDIA_TYPE_NOT_SUPPORTED_EXCEPTION, null, ReflectCommonUtil.getMethodDescribeByException(httpMediaTypeNotSupportedException));
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端请求后端,参数校验异常捕捉
|
||||
* RequestBody注解参数异常
|
||||
*
|
||||
* @param methodArgumentNotValidException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public HttpResult<String> methodArgumentNotValidExceptionHandler(MethodArgumentNotValidException methodArgumentNotValidException) {
|
||||
// 从异常对象中拿到allErrors数据
|
||||
String messages = methodArgumentNotValidException.getBindingResult().getAllErrors()
|
||||
.stream().map(ObjectError::getDefaultMessage).collect(Collectors.joining(";"));
|
||||
// 然后提取错误提示信息进行返回
|
||||
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
|
||||
// recodeBusinessExceptionLog(methodArgumentNotValidException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages, ControllerUtil.getMethodArgumentNotValidException(methodArgumentNotValidException));
|
||||
}
|
||||
|
||||
/**
|
||||
* 前端请求后端,参数校验异常捕捉
|
||||
* PathVariable注解、RequestParam注解参数异常
|
||||
*
|
||||
* @param constraintViolationException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(ConstraintViolationException.class)
|
||||
public HttpResult<String> constraintViolationExceptionExceptionHandler(ConstraintViolationException constraintViolationException) {
|
||||
String exceptionMessage = constraintViolationException.getMessage();
|
||||
StringBuilder messages = new StringBuilder();
|
||||
if (exceptionMessage.indexOf(StrUtil.COMMA) > 0) {
|
||||
String[] tempMessage = exceptionMessage.split(StrUtil.COMMA);
|
||||
Stream.of(tempMessage).forEach(message -> {
|
||||
messages.append(message.substring(message.indexOf(StrUtil.COLON) + 2)).append(';');
|
||||
});
|
||||
} else {
|
||||
messages.append(exceptionMessage.substring(exceptionMessage.indexOf(StrUtil.COLON) + 2));
|
||||
}
|
||||
// 然后提取错误提示信息进行返回
|
||||
LogUtil.njcnDebug(log, "参数校验异常,异常为:{}", messages);
|
||||
// recodeBusinessExceptionLog(constraintViolationException, CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION.getMessage());
|
||||
List<ConstraintViolation<?>> constraintViolationList = new ArrayList<>(constraintViolationException.getConstraintViolations());
|
||||
ConstraintViolation<?> constraintViolation = constraintViolationList.get(0);
|
||||
Class<?> rootBeanClass = constraintViolation.getRootBeanClass();
|
||||
//判断校验参数异常捕获的根源是controller还是service处
|
||||
if (rootBeanClass.getName().endsWith("Controller")) {
|
||||
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));
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.METHOD_ARGUMENT_NOT_VALID_EXCEPTION, messages.toString(), ReflectCommonUtil.getMethodDescribeByException(constraintViolationException));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 索引下标越界异常捕捉
|
||||
*
|
||||
* @param illegalArgumentException 参数校验异常
|
||||
*/
|
||||
@ExceptionHandler(IllegalArgumentException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(IllegalArgumentException illegalArgumentException) {
|
||||
LogUtil.logExceptionStackInfo(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage(), illegalArgumentException);
|
||||
// recodeBusinessExceptionLog(illegalArgumentException, CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION.getMessage());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.ILLEGAL_ARGUMENT_EXCEPTION, illegalArgumentException.getMessage(), ReflectCommonUtil.getMethodDescribeByException(illegalArgumentException));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 未声明异常捕捉
|
||||
*
|
||||
* @param exception 未声明异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public HttpResult<String> handleException(Exception exception) {
|
||||
//针对fallbackFactory降级异常特殊处理
|
||||
Exception tempException = exception;
|
||||
String exceptionCause = CommonResponseEnum.UN_DECLARE.getMessage();
|
||||
String code = CommonResponseEnum.UN_DECLARE.getCode();
|
||||
if (exception instanceof NestedServletException) {
|
||||
Throwable cause = exception.getCause();
|
||||
if (cause instanceof AssertionError) {
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
tempException = (BusinessException) cause.getCause();
|
||||
BusinessException tempBusinessException = (BusinessException) cause.getCause();
|
||||
exceptionCause = tempBusinessException.getMessage();
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* json解析异常
|
||||
*
|
||||
* @param jsonException json参数
|
||||
*/
|
||||
@ExceptionHandler(JSONException.class)
|
||||
public HttpResult<String> handleIndexOutOfBoundsException(JSONException jsonException) {
|
||||
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));
|
||||
}
|
||||
/*
|
||||
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());
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -2,6 +2,10 @@ package com.njcn.gather.event.transientes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsUserSet;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -12,4 +16,6 @@ import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface PqsDeptslineMapper extends BaseMapper<PqsDeptsline> {
|
||||
|
||||
List<PqsDeptsline> getPhoneUser(@Param("lineId")String lineId);
|
||||
}
|
||||
@@ -12,4 +12,11 @@
|
||||
<!--@mbg.generated-->
|
||||
DEPTS_INDEX, LINE_INDEX, SYSTYPE
|
||||
</sql>
|
||||
|
||||
<select id="getPhoneUser">
|
||||
select *
|
||||
from
|
||||
PQS_DEPTSLINE deptLine
|
||||
inner join PQS_DEPTS dept on deptLine.DEPTS_INDEX = DEPTS_INDEX
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.njcn.gather.event.transientes.pojo.param;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
* @CreateTime: 2025-06-26
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class MessageEventFeedbackParam {
|
||||
|
||||
@NotBlank(message = "暂降事件id不可为空")
|
||||
private String eventIndex;
|
||||
|
||||
@NotNull(message = "是否影响敏感用户不可为空")
|
||||
@ApiModelProperty(value = " 0.否 1.是")
|
||||
private Integer isSensitive;
|
||||
|
||||
@ApiModelProperty(value = "方案")
|
||||
private String influenceFactors;
|
||||
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "处理时间")
|
||||
private LocalDate dealDate;
|
||||
|
||||
@ApiModelProperty(value = "原因")
|
||||
private String dealScheme;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
@@ -33,6 +33,8 @@ public class MsgEventInfo implements Serializable {
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
@@ -48,4 +50,19 @@ public class MsgEventInfo implements Serializable {
|
||||
* 事件索引
|
||||
*/
|
||||
private String eventIndex;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 发送结果
|
||||
*/
|
||||
private Integer sendResult;
|
||||
|
||||
/**
|
||||
* 是否反馈
|
||||
*/
|
||||
private Integer isHandle;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ public class EventMsgDetailVO {
|
||||
|
||||
private String remark;
|
||||
|
||||
private String objName;
|
||||
|
||||
private List<MsgEventInfo> msgList;
|
||||
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ public class AuthController extends BaseController {
|
||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||
|
||||
// 直接从 Authentication 对象中获取已加载的 UserDetails,避免重复查询
|
||||
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
MyUserDetails userDetails = (MyUserDetails) authentication.getPrincipal();
|
||||
|
||||
// 获取用户部门(假设 CustomUserDetails 包含部门信息)
|
||||
String department = ((MyUserDetails) userDetails).getDeptId();
|
||||
String department = userDetails.getDeptId();
|
||||
|
||||
final String jwt = jwtUtil.generateToken(userDetails);
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ public class MyUserDetails implements UserDetails {
|
||||
private boolean credentialsNonExpired; // 凭证是否未过期
|
||||
private boolean enabled; // 账户是否启用
|
||||
|
||||
public MyUserDetails(String username, String password, String deptId,Collection<? extends GrantedAuthority> authorities) {
|
||||
public MyUserDetails(String userId,String username, String password, String deptId,Collection<? extends GrantedAuthority> authorities) {
|
||||
this.userId = userId;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.deptId = deptId;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
public MyUserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
|
||||
|
||||
LambdaQueryWrapper<PqsUser> userWrapper = new LambdaQueryWrapper<>();
|
||||
/* LambdaQueryWrapper<PqsUser> userWrapper = new LambdaQueryWrapper<>();
|
||||
userWrapper.eq(PqsUser::getLoginname,username);
|
||||
PqsUser pqsUser = pqsUserMapper.selectOne(userWrapper);
|
||||
if(Objects.isNull(pqsUser)){
|
||||
@@ -41,7 +41,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
LambdaQueryWrapper<PqsUserSet> userSetWrapper = new LambdaQueryWrapper<>();
|
||||
userSetWrapper.eq(PqsUserSet::getUserIndex,pqsUser.getUserIndex());
|
||||
PqsUserSet pqsUserSet = pqsUserSetMapper.selectOne(userSetWrapper);
|
||||
String deptId = pqsUserSet.getDeptsIndex();
|
||||
String deptId = pqsUserSet.getDeptsIndex();*/
|
||||
|
||||
|
||||
|
||||
@@ -49,17 +49,17 @@ public class MyUserDetailsService implements UserDetailsService {
|
||||
if ("cdf".equals(username)) {
|
||||
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
|
||||
return new MyUserDetails("cdf", encodedPassword,"10001",
|
||||
return new MyUserDetails("1","cdf", encodedPassword,"10001",
|
||||
new ArrayList<>());
|
||||
}else if("screen".equals(username)){
|
||||
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
|
||||
return new MyUserDetails("screen", encodedPassword,"10001",
|
||||
return new MyUserDetails("2","screen", encodedPassword,"10001",
|
||||
new ArrayList<>());
|
||||
} else if("test".equals(username)){
|
||||
PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
||||
String encodedPassword = passwordEncoder.encode("@#001njcnpqs");
|
||||
return new MyUserDetails("test", encodedPassword,"10001",
|
||||
return new MyUserDetails("3","test", encodedPassword,"10001",
|
||||
new ArrayList<>());
|
||||
}else {
|
||||
throw new UsernameNotFoundException("User not found with username: " + username);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.gather.event.transientes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
|
||||
import com.njcn.gather.event.transientes.pojo.param.MessageEventFeedbackParam;
|
||||
import com.njcn.gather.event.transientes.pojo.po.MsgEventInfo;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail;
|
||||
import com.njcn.gather.event.transientes.pojo.vo.*;
|
||||
@@ -35,6 +36,10 @@ public interface LargeScreenCountService {
|
||||
|
||||
List<MsgEventInfo> msgSendList(LargeScreenCountParam largeScreenCountParam);
|
||||
|
||||
Page<MsgEventInfo> hasSendMsgPage(LargeScreenCountParam largeScreenCountParam);
|
||||
|
||||
boolean msgHandle(MessageEventFeedbackParam messageEventFeedbackParam);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@@ -14,23 +15,34 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.github.yulichang.wrapper.segments.Fun;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.event.devcie.mapper.PqLineMapper;
|
||||
import com.njcn.gather.event.devcie.mapper.PqLinedetailMapper;
|
||||
import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
|
||||
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqLine;
|
||||
import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline;
|
||||
import com.njcn.gather.event.transientes.pojo.param.MessageEventFeedbackParam;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsDepts;
|
||||
import com.njcn.gather.event.transientes.pojo.po.MessageEventFeedback;
|
||||
import com.njcn.gather.event.transientes.pojo.po.MsgEventInfo;
|
||||
import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail;
|
||||
import com.njcn.gather.event.transientes.pojo.po.*;
|
||||
import com.njcn.gather.event.transientes.pojo.vo.*;
|
||||
import com.njcn.gather.event.devcie.service.*;
|
||||
import com.njcn.gather.event.transientes.service.*;
|
||||
import com.njcn.gather.event.devcie.service.PqsDeptslineService;
|
||||
import com.njcn.gather.event.transientes.utils.JwtUtil;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -51,6 +63,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
|
||||
private final JwtUtil jwtUtil;
|
||||
private final PqsDeptslineService pqsDeptslineService;
|
||||
private final PqsDeptsService pqsDeptsService;
|
||||
private final PqLineService pqLineService;
|
||||
@@ -62,17 +75,19 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
private final CommGeneralService commGeneralService;
|
||||
|
||||
private final PqsUsersetService pqsUsersetService;
|
||||
private final PqLinedetailMapper pqLinedetailMapper;
|
||||
@Value("${SYS_TYPE_ZT}")
|
||||
private String sysTypeZt;
|
||||
|
||||
@Override
|
||||
public LedgerCountVO scaleStatistics(LargeScreenCountParam largeScreenCountParam) {
|
||||
LedgerCountVO ledgerCountVO = new LedgerCountVO();
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(deptslineIds)){
|
||||
if (CollectionUtils.isEmpty(deptslineIds)) {
|
||||
throw new BusinessException("部门下暂无监测点");
|
||||
|
||||
}
|
||||
@@ -110,35 +125,35 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
//结束时间
|
||||
String endTime = DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(deptslineIds)){
|
||||
if (CollectionUtils.isEmpty(deptslineIds)) {
|
||||
throw new BusinessException("部门下暂无监测点");
|
||||
|
||||
}
|
||||
List<PqsEventdetail> eventdetails = pqsEventdetailService.lambdaQuery()
|
||||
.between(PqsEventdetail::getTimeid, LocalDateTimeUtil.parse(startTime,DatePattern.NORM_DATETIME_FORMATTER), LocalDateTimeUtil.parse(endTime,DatePattern.NORM_DATETIME_FORMATTER))
|
||||
.in(PqsEventdetail::getLineid,deptslineIds).list();
|
||||
.between(PqsEventdetail::getTimeid, LocalDateTimeUtil.parse(startTime, DatePattern.NORM_DATETIME_FORMATTER), LocalDateTimeUtil.parse(endTime, DatePattern.NORM_DATETIME_FORMATTER))
|
||||
.in(PqsEventdetail::getLineid, deptslineIds).list();
|
||||
Integer eventCount = eventdetails.size();
|
||||
// 告警
|
||||
List<PqsEventdetail> aLarmEvent = eventdetails.stream().filter(temp -> temp.getEventvalue() < 0.5).collect(Collectors.toList());
|
||||
// 预警
|
||||
List<PqsEventdetail> warnEvent = eventdetails.stream().filter(temp -> temp.getEventvalue() >= 0.5&& temp.getEventvalue() <0.9).collect(Collectors.toList());
|
||||
List<PqsEventdetail> noticeEvent = eventdetails.stream().filter(temp ->Objects.equals(temp.getNoticeFlag(),1)).collect(Collectors.toList());
|
||||
List<PqsEventdetail> warnEvent = eventdetails.stream().filter(temp -> temp.getEventvalue() >= 0.5 && temp.getEventvalue() < 0.9).collect(Collectors.toList());
|
||||
List<PqsEventdetail> noticeEvent = eventdetails.stream().filter(temp -> Objects.equals(temp.getNoticeFlag(), 1)).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<PqsEventdetail> lookALarmEvent = aLarmEvent.stream().filter(temp ->Objects.equals(temp.getLookFlag(),1 )).collect(Collectors.toList());
|
||||
List<PqsEventdetail> lookWarnEvent = warnEvent.stream().filter(temp ->Objects.equals(temp.getLookFlag(),1 ) ).collect(Collectors.toList());
|
||||
List<PqsEventdetail> lookNoticeEvent = noticeEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(),1 )).collect(Collectors.toList());
|
||||
List<PqsEventdetail> lookALarmEvent = aLarmEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
|
||||
List<PqsEventdetail> lookWarnEvent = warnEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
|
||||
List<PqsEventdetail> lookNoticeEvent = noticeEvent.stream().filter(temp -> Objects.equals(temp.getLookFlag(), 1)).collect(Collectors.toList());
|
||||
|
||||
Integer aLarmCount =aLarmEvent.size();
|
||||
Integer warnCount =warnEvent.size();
|
||||
Integer noticeCount =noticeEvent.size();
|
||||
Integer lookALarmCount =lookALarmEvent.size();
|
||||
Integer lookWarnCount =lookWarnEvent.size();
|
||||
Integer lookNoticeCount =lookNoticeEvent.size();
|
||||
Integer aLarmCount = aLarmEvent.size();
|
||||
Integer warnCount = warnEvent.size();
|
||||
Integer noticeCount = noticeEvent.size();
|
||||
Integer lookALarmCount = lookALarmEvent.size();
|
||||
Integer lookWarnCount = lookWarnEvent.size();
|
||||
Integer lookNoticeCount = lookNoticeEvent.size();
|
||||
|
||||
alarmAnalysisVO.setEventCount(eventCount);
|
||||
alarmAnalysisVO.setALarmCount(aLarmCount);
|
||||
@@ -169,41 +184,41 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
LocalDateTime startTime;
|
||||
//结束时间
|
||||
LocalDateTime endTime;
|
||||
if(largeScreenCountParam.getType()==3){
|
||||
if (largeScreenCountParam.getType() == 3) {
|
||||
//起始时间
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
}else if(largeScreenCountParam.getType()==4){
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
} else if (largeScreenCountParam.getType() == 4) {
|
||||
//起始时间
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
}else {
|
||||
endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfWeek(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
} else {
|
||||
throw new BusinessException("统计类型有误类型");
|
||||
}
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(deptslineIds)){
|
||||
if (CollectionUtils.isEmpty(deptslineIds)) {
|
||||
throw new BusinessException("部门下暂无监测点");
|
||||
|
||||
}
|
||||
List<PqsEventdetail> eventdetails = new ArrayList<>();
|
||||
if(Objects.equals(largeScreenCountParam.getEventtype(),1)){
|
||||
if (Objects.equals(largeScreenCountParam.getEventtype(), 1)) {
|
||||
eventdetails = pqsEventdetailService.lambdaQuery()
|
||||
.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds)
|
||||
.eq(PqsEventdetail::getNoticeFlag,largeScreenCountParam.getEventtype()).list();
|
||||
}else {
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.eq(PqsEventdetail::getNoticeFlag, largeScreenCountParam.getEventtype()).list();
|
||||
} else {
|
||||
eventdetails = pqsEventdetailService.lambdaQuery()
|
||||
.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds)
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.and(w -> w.eq(PqsEventdetail::getNoticeFlag, 0).or().isNull(PqsEventdetail::getNoticeFlag)).list();
|
||||
}
|
||||
LocalDate startDate =LocalDate.parse(DateUtil.format(startTime, DatePattern.NORM_DATE_PATTERN)) ;
|
||||
LocalDate endDate = LocalDate.parse(DateUtil.format(endTime, DatePattern.NORM_DATE_PATTERN)) ;
|
||||
LocalDate startDate = LocalDate.parse(DateUtil.format(startTime, DatePattern.NORM_DATE_PATTERN));
|
||||
LocalDate endDate = LocalDate.parse(DateUtil.format(endTime, DatePattern.NORM_DATE_PATTERN));
|
||||
|
||||
List<String> dateList = new ArrayList<>();
|
||||
|
||||
@@ -221,18 +236,18 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
|
||||
@Override
|
||||
public Page<EventDetailVO> eventList(LargeScreenCountParam largeScreenCountParam) {
|
||||
Page<PqsEventdetail> pqsEventdetailPage = new Page<> (largeScreenCountParam.getPageNum ( ), largeScreenCountParam.getPageSize ( ));
|
||||
Page<PqsEventdetail> pqsEventdetailPage = new Page<>(largeScreenCountParam.getPageNum(), largeScreenCountParam.getPageSize());
|
||||
|
||||
//起始时间
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
LocalDateTime endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||
if(CollectionUtils.isEmpty(deptslineIds)){
|
||||
if (CollectionUtils.isEmpty(deptslineIds)) {
|
||||
throw new BusinessException("部门下暂无监测点");
|
||||
|
||||
}
|
||||
@@ -240,17 +255,17 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
||||
|
||||
QueryWrapper<PqsEventdetail> queryWrapper = new QueryWrapper<>();
|
||||
if(Objects.equals(largeScreenCountParam.getEventtype(),1)){
|
||||
if (Objects.equals(largeScreenCountParam.getEventtype(), 1)) {
|
||||
queryWrapper.lambda()
|
||||
.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds)
|
||||
.eq(PqsEventdetail::getNoticeFlag,largeScreenCountParam.getEventtype())
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.eq(PqsEventdetail::getNoticeFlag, largeScreenCountParam.getEventtype())
|
||||
.orderByAsc(PqsEventdetail::getLookFlag)
|
||||
.orderByDesc(PqsEventdetail::getTimeid);
|
||||
}else {
|
||||
} else {
|
||||
queryWrapper.lambda()
|
||||
.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds)
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.and(w -> w.eq(PqsEventdetail::getNoticeFlag, 0).or().isNull(PqsEventdetail::getNoticeFlag))
|
||||
.orderByAsc(PqsEventdetail::getLookFlag)
|
||||
.orderByDesc(PqsEventdetail::getTimeid);
|
||||
@@ -284,7 +299,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
eventDetailVO.setNeedDealFlag(noticeLineIds.contains(temp.getLineid())?1:0);
|
||||
return eventDetailVO;
|
||||
}).collect(Collectors.toList());
|
||||
Page<EventDetailVO> returnpage = new Page<> (largeScreenCountParam.getPageNum ( ), largeScreenCountParam.getPageSize ( ));
|
||||
Page<EventDetailVO> returnpage = new Page<>(largeScreenCountParam.getPageNum(), largeScreenCountParam.getPageSize());
|
||||
returnpage.setRecords(collect);
|
||||
return returnpage;
|
||||
}
|
||||
@@ -296,30 +311,30 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
DateTime end = DateUtil.endOfDay(DateTime.now());
|
||||
DateTime start = DateUtil.beginOfMonth(DateTime.now());
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(deptslineIds)){
|
||||
if (CollUtil.isEmpty(deptslineIds)) {
|
||||
return result;
|
||||
}
|
||||
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, start, end)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds)
|
||||
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
|
||||
if(Objects.nonNull(largeScreenCountParam.getEventDeep())){
|
||||
if(largeScreenCountParam.getEventDeep() == 0){
|
||||
lambdaQueryWrapper.ge(PqsEventdetail::getEventvalue,0.5).lt(PqsEventdetail::getEventtype,0.9);
|
||||
}else if(largeScreenCountParam.getEventDeep() == 1){
|
||||
lambdaQueryWrapper.lt(PqsEventdetail::getEventvalue,0.5);
|
||||
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
|
||||
if (largeScreenCountParam.getEventDeep() == 0) {
|
||||
lambdaQueryWrapper.ge(PqsEventdetail::getEventvalue, 0.5).lt(PqsEventdetail::getEventtype, 0.9);
|
||||
} else if (largeScreenCountParam.getEventDeep() == 1) {
|
||||
lambdaQueryWrapper.lt(PqsEventdetail::getEventvalue, 0.5);
|
||||
}
|
||||
}
|
||||
List<PqsEventdetail> eventList = pqsEventdetailService.list(lambdaQueryWrapper);
|
||||
if(CollUtil.isNotEmpty(eventList)){
|
||||
if (CollUtil.isNotEmpty(eventList)) {
|
||||
List<Integer> ids = eventList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
|
||||
List<LedgerBaseInfoDTO> pqLineList = pqLineMapper.getBaseLineInfo(ids);
|
||||
Map<Integer,LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
||||
eventList.forEach(it->{
|
||||
Map<Integer, LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
||||
eventList.forEach(it -> {
|
||||
EventDetailVO eventDetailVO = new EventDetailVO();
|
||||
eventDetailVO.setEventdetail_index(it.getEventdetailIndex());
|
||||
eventDetailVO.setTimeid(it.getTimeid());
|
||||
@@ -327,7 +342,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
eventDetailVO.setWavetype(it.getWavetype().toString());
|
||||
eventDetailVO.setPersisttime(it.getPersisttime().toString());
|
||||
eventDetailVO.setEventvalue(it.getEventvalue());
|
||||
if(ledgerBaseInfoDTOMap.containsKey(it.getLineid())){
|
||||
if (ledgerBaseInfoDTOMap.containsKey(it.getLineid())) {
|
||||
LedgerBaseInfoDTO ledgerBaseInfoDTO = ledgerBaseInfoDTOMap.get(it.getLineid());
|
||||
eventDetailVO.setLineid(ledgerBaseInfoDTO.getLineId());
|
||||
eventDetailVO.setPointname(ledgerBaseInfoDTO.getLineName());
|
||||
@@ -342,7 +357,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
@Override
|
||||
public boolean lookEvent(List<String> ids) {
|
||||
LambdaUpdateWrapper<PqsEventdetail> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(PqsEventdetail::getEventdetailIndex,ids).set(PqsEventdetail::getLookFlag,DataStateEnum.ENABLE.getCode());
|
||||
updateWrapper.in(PqsEventdetail::getEventdetailIndex, ids).set(PqsEventdetail::getLookFlag, DataStateEnum.ENABLE.getCode());
|
||||
pqsEventdetailService.update(updateWrapper);
|
||||
return true;
|
||||
}
|
||||
@@ -351,32 +366,32 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
public List<MapCountVO> mapCount(LargeScreenCountParam largeScreenCountParam) {
|
||||
List<MapCountVO> result = new ArrayList<>();
|
||||
//起始时间
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
LocalDateTime startTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.beginOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//结束时间
|
||||
LocalDateTime endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER),DatePattern.NORM_DATETIME_FORMATTER);
|
||||
LocalDateTime endTime = LocalDateTimeUtil.parse(DateUtil.format(DateUtil.endOfMonth(new Date()), DatePattern.NORM_DATETIME_FORMATTER), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
//根据用户获取当前部门及子部门id
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren( largeScreenCountParam.getDeptId());
|
||||
List<String> deptAndChildren = pqsDeptsService.findDeptAndChildren(largeScreenCountParam.getDeptId());
|
||||
//获取对应监测点id
|
||||
List<PqsDeptsline> deptslines = pqsDeptslineService.lambdaQuery().in(PqsDeptsline::getDeptsIndex, deptAndChildren).eq(PqsDeptsline::getSystype, sysTypeZt).list();
|
||||
if(CollectionUtils.isEmpty(deptslines)){
|
||||
if (CollectionUtils.isEmpty(deptslines)) {
|
||||
throw new BusinessException("部门下暂无监测点");
|
||||
|
||||
}
|
||||
List<PqsDepts> list = pqsDeptsService.lambdaQuery().list();
|
||||
Map<String, PqsDepts> stringPqsDeptsMap = list.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex, Function.identity(), (key1, key2) -> key2));
|
||||
Map<String, List<PqsDeptsline>> collect = deptslines.stream().collect(Collectors.groupingBy(PqsDeptsline::getDeptsIndex));
|
||||
collect.forEach((k,v)->{
|
||||
MapCountVO mapCountVO = new MapCountVO() ;
|
||||
collect.forEach((k, v) -> {
|
||||
MapCountVO mapCountVO = new MapCountVO();
|
||||
mapCountVO.setDeptsIndex(k);
|
||||
mapCountVO.setDeptsName(stringPqsDeptsMap.get(k).getDeptsname());
|
||||
mapCountVO.setLineCount(v.size());
|
||||
|
||||
List<Integer> deptslineIds = v.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||
List<PqsEventdetail> eventdetails = pqsEventdetailService.lambdaQuery()
|
||||
.between(PqsEventdetail::getTimeid, startTime,endTime)
|
||||
.in(PqsEventdetail::getLineid,deptslineIds).list();
|
||||
.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||
.in(PqsEventdetail::getLineid, deptslineIds).list();
|
||||
mapCountVO.setEventCount(eventdetails.size());
|
||||
List<PqsEventdetail> noticeEvent = eventdetails.stream().filter(temp ->Objects.equals(temp.getNoticeFlag(),1)).collect(Collectors.toList());
|
||||
List<PqsEventdetail> noticeEvent = eventdetails.stream().filter(temp -> Objects.equals(temp.getNoticeFlag(), 1)).collect(Collectors.toList());
|
||||
|
||||
|
||||
mapCountVO.setNoticeCount(noticeEvent.size());
|
||||
@@ -391,14 +406,19 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
EventMsgDetailVO eventMsgDetailVO = new EventMsgDetailVO();
|
||||
|
||||
LambdaQueryWrapper<MessageEventFeedback> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(MessageEventFeedback::getEventIndex,eventId);
|
||||
lambdaQueryWrapper.eq(MessageEventFeedback::getEventIndex, eventId);
|
||||
MessageEventFeedback messageEventFeedback = messageEventFeedbackService.getOne(lambdaQueryWrapper);
|
||||
if(Objects.nonNull(messageEventFeedback)){
|
||||
BeanUtil.copyProperties(messageEventFeedback,eventMsgDetailVO);
|
||||
if (Objects.nonNull(messageEventFeedback)) {
|
||||
BeanUtil.copyProperties(messageEventFeedback, eventMsgDetailVO);
|
||||
if(messageEventFeedback.getIsSensitive() == 1){
|
||||
PqsEventdetail pqsEventdetail = pqsEventdetailService.lambdaQuery().eq(PqsEventdetail::getEventdetailIndex,eventId).one();
|
||||
PqLinedetail pqLinedetail = pqLinedetailMapper.selectById(pqsEventdetail.getLineid());
|
||||
eventMsgDetailVO.setObjName(pqLinedetail.getObjname());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<MsgEventInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(MsgEventInfo::getEventIndex,eventId);
|
||||
queryWrapper.eq(MsgEventInfo::getEventIndex, eventId);
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.list(queryWrapper);
|
||||
eventMsgDetailVO.setMsgList(msgEventInfoList);
|
||||
|
||||
@@ -409,41 +429,63 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
||||
public List<MsgEventInfo> msgSendList(LargeScreenCountParam largeScreenCountParam) {
|
||||
List<MsgEventInfo> result = new ArrayList<>();
|
||||
List<Integer> ids = commGeneralService.getLineIdsByDept(largeScreenCountParam);
|
||||
if(CollUtil.isEmpty(ids)){
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return result;
|
||||
}
|
||||
List<PqsEventdetail> allEventList = new ArrayList<>();
|
||||
if(ids.size()>1000){
|
||||
List<List<Integer>> listIds = CollUtil.split(ids,1000);
|
||||
for(List<Integer> itemIds : listIds){
|
||||
List<PqsEventdetail> pqsEventdetailList = pqsEventdetailService.lambdaQuery().in(PqsEventdetail::getLineid,itemIds).select(PqsEventdetail::getEventdetailIndex).list();
|
||||
if (ids.size() > 1000) {
|
||||
List<List<Integer>> listIds = CollUtil.split(ids, 1000);
|
||||
for (List<Integer> itemIds : listIds) {
|
||||
List<PqsEventdetail> pqsEventdetailList = pqsEventdetailService.lambdaQuery().in(PqsEventdetail::getLineid, itemIds).select(PqsEventdetail::getEventdetailIndex).list();
|
||||
allEventList.addAll(pqsEventdetailList);
|
||||
}
|
||||
}else {
|
||||
List<PqsEventdetail> pqsEventdetailList = pqsEventdetailService.lambdaQuery().in(PqsEventdetail::getLineid,ids).select(PqsEventdetail::getEventdetailIndex).list();
|
||||
} else {
|
||||
List<PqsEventdetail> pqsEventdetailList = pqsEventdetailService.lambdaQuery().in(PqsEventdetail::getLineid, ids).select(PqsEventdetail::getEventdetailIndex).list();
|
||||
allEventList.addAll(pqsEventdetailList);
|
||||
}
|
||||
if(CollUtil.isEmpty(allEventList)){
|
||||
if (CollUtil.isEmpty(allEventList)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
List<String> eventIds = allEventList.stream().map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
|
||||
if(eventIds.size()>1000){
|
||||
List<List<String>> listEven = CollUtil.split(eventIds,1000);
|
||||
for(List<String> pList: listEven){
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,pList).list();
|
||||
if (eventIds.size() > 1000) {
|
||||
List<List<String>> listEven = CollUtil.split(eventIds, 1000);
|
||||
for (List<String> pList : listEven) {
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex, pList).list();
|
||||
result.addAll(msgEventInfoList);
|
||||
}
|
||||
}else {
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex,eventIds).list();
|
||||
} else {
|
||||
List<MsgEventInfo> msgEventInfoList = msgEventInfoService.lambdaQuery().in(MsgEventInfo::getEventIndex, eventIds).list();
|
||||
result.addAll(msgEventInfoList);
|
||||
}
|
||||
result = result.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime,Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
result = result.stream().sorted(Comparator.comparing(MsgEventInfo::getSendTime, Comparator.reverseOrder())).collect(Collectors.toList());
|
||||
if (result.size() > 200) {
|
||||
result = result.subList(0, 200);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<MsgEventInfo> hasSendMsgPage(LargeScreenCountParam largeScreenCountParam) {
|
||||
LambdaQueryWrapper<MsgEventInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.orderByDesc(MsgEventInfo::getSendTime);
|
||||
return msgEventInfoService.page(new Page<>(PageFactory.getPageNum(largeScreenCountParam),PageFactory.getPageSize(largeScreenCountParam)),lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean msgHandle(MessageEventFeedbackParam messageEventFeedbackParam) {
|
||||
MessageEventFeedback messageEventFeedback = messageEventFeedbackService.lambdaQuery().eq(MessageEventFeedback::getEventIndex, messageEventFeedbackParam.getEventIndex()).one();
|
||||
if (Objects.nonNull(messageEventFeedback)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"请勿重复处理!");
|
||||
}
|
||||
MessageEventFeedback po = new MessageEventFeedback();
|
||||
BeanUtil.copyProperties(messageEventFeedbackParam, po);
|
||||
po.setId(IdUtil.simpleUUID());
|
||||
messageEventFeedbackService.save(po);
|
||||
pqsEventdetailService.lambdaUpdate().set(PqsEventdetail::getNoticeFlag,DataStateEnum.ENABLE.getCode()).eq(PqsEventdetail::getEventdetailIndex,messageEventFeedbackParam.getEventIndex()).update();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.event.transientes.utils;
|
||||
|
||||
import com.njcn.gather.event.transientes.security.MyUserDetails;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
@@ -16,12 +17,20 @@ import java.util.function.Function;
|
||||
@Component
|
||||
public class JwtUtil {
|
||||
|
||||
private final String userId = "userId";
|
||||
private final String userName = "userName";
|
||||
private final String deptId = "deptId";
|
||||
|
||||
|
||||
private static final Key SECRET_KEY = Keys.secretKeyFor(SignatureAlgorithm.HS256);
|
||||
private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 100000L; // 10小时
|
||||
|
||||
// 生成JWT令牌
|
||||
public String generateToken(UserDetails userDetails) {
|
||||
public String generateToken(MyUserDetails userDetails) {
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put(userId,userDetails.getUserId());
|
||||
claims.put(userName,userDetails.getUsername());
|
||||
claims.put(deptId,userDetails.getDeptId());
|
||||
return createToken(claims, userDetails.getUsername());
|
||||
}
|
||||
|
||||
@@ -43,7 +52,17 @@ public class JwtUtil {
|
||||
|
||||
// 提取用户名
|
||||
public String extractUsername(String token) {
|
||||
return extractClaim(token, Claims::getSubject);
|
||||
return extractClaim(token, it->it.get(userName).toString());
|
||||
}
|
||||
|
||||
// 提取用户ID
|
||||
public String extractUserId(String token) {
|
||||
return extractClaim(token,it->it.get(userId).toString());
|
||||
}
|
||||
|
||||
// 提取用户部门
|
||||
public String extractDepartment(String token) {
|
||||
return extractClaim(token, it->it.get(deptId).toString());
|
||||
}
|
||||
|
||||
// 提取过期时间
|
||||
|
||||
Reference in New Issue
Block a user