1.审计用户消息和邮件推送
2.国网上送母线,变电站,主配网监测点统计,典型源荷统计等算法调整 3.国网上送定时任务调整
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
package com.njcn.common.pojo.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -62,4 +68,11 @@ public class LogInfoDTO implements Serializable {
|
||||
*/
|
||||
private String userIndex;
|
||||
|
||||
/**
|
||||
* 0 未登录; 1 已登录
|
||||
*/
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -78,8 +79,17 @@ public class LogServiceImpl implements ILogService {
|
||||
String type = ReflectCommonUtil.getOperateInfoByMethod(returnType.getMethod()).getOperateType();
|
||||
String level = ReflectCommonUtil.getOperateInfoByMethod(returnType.getMethod()).getOperateLevel();
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(returnType.getMethod());
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, userName, ip, methodDescribe, operateType, result.equalsIgnoreCase("失败") ? 0 : 1, "", levelStringToNumber(level), type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex);
|
||||
Integer severity = levelStringToNumber(level);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, userName, ip, methodDescribe, operateType, result.equalsIgnoreCase("失败") ? 0 : 1, "", severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
//推送审计消息功能
|
||||
if(severity!=0){
|
||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
//发送邮箱功能
|
||||
if(severity==2&&logInfoDTO.getResult()==0){
|
||||
publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
}
|
||||
}
|
||||
//如果存在设备日志注解,则记录设备日志
|
||||
if(Objects.nonNull((returnType.getMethod()))&& (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)){
|
||||
String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType();
|
||||
@@ -120,8 +130,10 @@ public class LogServiceImpl implements ILogService {
|
||||
String type = ReflectCommonUtil.getOperateInfoByMethod(method).getOperateType();
|
||||
String level = ReflectCommonUtil.getOperateInfoByMethod(method).getOperateLevel();
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(tempLogInfo.getLoginName(), tempLogInfo.getUserName(), tempLogInfo.getIp(), ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, levelStringToNumber(level), type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex);
|
||||
Integer severity = levelStringToNumber(level);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(tempLogInfo.getLoginName(), tempLogInfo.getUserName(), tempLogInfo.getIp(), ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), userIndex, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
auditPush(severity, logInfoDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,9 +157,22 @@ public class LogServiceImpl implements ILogService {
|
||||
String ip = RequestUtil.getRealIp(request);
|
||||
String type = ReflectCommonUtil.getOperateInfoByMethod(method).getOperateType();
|
||||
String level = ReflectCommonUtil.getOperateInfoByMethod(method).getOperateLevel();
|
||||
Integer severity = levelStringToNumber(level);
|
||||
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, "", ip, ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, levelStringToNumber(level), type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), loginName);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, "", ip, ReflectCommonUtil.getMethodDescribeByMethod(method), operateType, result.equalsIgnoreCase("失败") ? 0 : 1, message, severity, type.equalsIgnoreCase("业务事件") ? 0 : 1, generalInfo.getMicroServiceName(), loginName, LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
|
||||
auditPush(severity, logInfoDTO);
|
||||
}
|
||||
|
||||
private void auditPush(Integer severity, LogInfoDTO logInfoDTO) {
|
||||
//推送审计消息功能
|
||||
if(severity !=0){
|
||||
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
//发送邮箱功能
|
||||
if(severity ==2&& logInfoDTO.getResult()==0){
|
||||
publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.web.utils;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.extra.mail.MailUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2024/3/11 14:32
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class EmailUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 推送单邮件信息发送
|
||||
* @param to
|
||||
* @param title
|
||||
* @param content
|
||||
* @param isHtml
|
||||
*/
|
||||
public void send(String to,String title,String content,Boolean isHtml) {
|
||||
if(isHtml){
|
||||
String s = FileUtil.readUtf8String("cs.html");
|
||||
content = s.replace("#{content}", content);
|
||||
}
|
||||
MailUtil.send(to, title, content, isHtml);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送多个邮件信息
|
||||
* @param to
|
||||
* @param title
|
||||
* @param content
|
||||
* @param isHtml
|
||||
*/
|
||||
public void sendMultiple(List<String> to,String title,String content,Boolean isHtml) {
|
||||
if(isHtml){
|
||||
String s = FileUtil.readUtf8String("cs.html");
|
||||
content = s.replace("#{content}", content);
|
||||
}
|
||||
MailUtil.send(to, title, content, isHtml);
|
||||
}
|
||||
}
|
||||
53
pqs-common/common-web/src/main/resources/cs.html
Normal file
53
pqs-common/common-web/src/main/resources/cs.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>系统通知邮件</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="font-size: 14px;">
|
||||
<br><br><br><br>
|
||||
<div style="width: 600px; margin: 0 auto; background-color: #00838a; border-radius: 3px;">
|
||||
<div style="padding: 0 15px; padding-bottom: 20px;">
|
||||
<div style="height: 30px;">
|
||||
</div>
|
||||
<div style="background: #fff; padding: 20px 15px; border-radius: 3px;">
|
||||
<div><span style="font-size: 16px; font-weight: bold;">消息通知:</span>
|
||||
<div style="line-height: 24px; margin-top: 10px;">
|
||||
<div>
|
||||
#{content}
|
||||
<br/>
|
||||
如有疑问
|
||||
<a style="color: #006eff;font-weight: bold;" href="/"
|
||||
target="_blank" rel="noopener">登录系统 </a>处理!
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-top: 60px;margin-bottom: 10px;"><span
|
||||
style="font-size: 13px; font-weight: bold; color: #666;">温馨提醒</span>
|
||||
<div style="line-height: 24px; margin-top: 10px;">
|
||||
<div style="font-size: 13px; color: #666;">使用过程中如有任何问题,请联系系统管理员。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
style="width: 600px; margin: 0 auto; margin-top: 50px; font-size: 12px; -webkit-font-smoothing: subpixel-antialiased; text-size-adjust: 100%;">
|
||||
<p
|
||||
style="text-align: center; line-height: 20.4px; text-size-adjust: 100%; font-family: 'Microsoft YaHei'!important; padding: 0px !important; margin: 0px !important; color: #7e8890 !important;">
|
||||
<span class="appleLinks">
|
||||
Copyright © 2023-2024 南京灿能电力自动化股份有限公司. 保留所有权利。</span>
|
||||
</p>
|
||||
<p
|
||||
style="text-align: center;line-height: 20.4px; text-size-adjust: 100%; font-family: 'Microsoft YaHei'!important; padding: 0px !important; margin: 0px; color: #7e8890 !important; margin-top: 10px;">
|
||||
<span class="appleLinks">
|
||||
邮件由系统自动发送,请勿直接回复本邮件!</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
10
pqs-common/common-web/src/main/resources/mail.setting
Normal file
10
pqs-common/common-web/src/main/resources/mail.setting
Normal file
@@ -0,0 +1,10 @@
|
||||
# 邮件服务器的SMTP地址,可选,默认为smtp.<发件人邮箱后缀>
|
||||
host = smtp.163.com
|
||||
# 邮件服务器的SMTP端口,可选,默认25
|
||||
port = 25
|
||||
# 发件人(必须正确,否则发送失败)
|
||||
from = wxb41010@163.com
|
||||
# 用户名,默认为发件人邮箱前缀
|
||||
user = wxb41010
|
||||
# 密码(注意,某些邮箱需要为SMTP服务单独设置授权码,详情查看相关帮助)
|
||||
pass = ZMZJRKMKRIXWZLMP
|
||||
Reference in New Issue
Block a user