1.审计用户消息和邮件推送
2.国网上送母线,变电站,主配网监测点统计,典型源荷统计等算法调整 3.国网上送定时任务调整
This commit is contained in:
@@ -104,7 +104,7 @@ public class UserTokenService {
|
||||
redisUtil.saveByKeyWithExpire(onlineUserKey, userTokenInfo, refreshLifeTime.plusMinutes(5L).toEpochSecond(ZoneOffset.of("+8")) - LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
|
||||
|
||||
//记录成功登录后的信息
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, nickName, ip, "登录认证", OperateType.AUTHENTICATE, 1, "", 0, 1, generalInfo.getMicroServiceName(), userIndex);
|
||||
LogInfoDTO logInfoDTO = new LogInfoDTO(loginName, nickName, ip, "登录认证", OperateType.AUTHENTICATE, 1, "", 0, 1, generalInfo.getMicroServiceName(), userIndex,LocalDateTime.now());
|
||||
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -153,6 +153,9 @@ public class PqTypicalSourceCreatePO {
|
||||
@TableField("interferenceSourceCount")
|
||||
private Integer interferenceSourceCount;
|
||||
|
||||
|
||||
/**
|
||||
* 计算日期
|
||||
*/
|
||||
private String computeDate;
|
||||
|
||||
}
|
||||
@@ -130,5 +130,9 @@ public class RUploadEvaluationDataD {
|
||||
*/
|
||||
private Integer uploadStatus;
|
||||
|
||||
/**
|
||||
* 计算日期
|
||||
*/
|
||||
private String computeDate;
|
||||
|
||||
}
|
||||
|
||||
@@ -130,4 +130,8 @@ public class RUploadPointStatisticalDataD {
|
||||
* 上送状态(0:未上送 1:已上送)
|
||||
*/
|
||||
private Integer uploadStatus;
|
||||
/**
|
||||
* 计算日期
|
||||
*/
|
||||
private String computeDate;
|
||||
}
|
||||
|
||||
@@ -109,10 +109,13 @@ public class RUploadSubstationStatisticalDataD {
|
||||
@MppMultiId
|
||||
private String statisticalType;
|
||||
|
||||
private String statisticalMonth;
|
||||
|
||||
/**
|
||||
* 上送状态(0:未上送 1:已上送)
|
||||
*/
|
||||
private Integer uploadStatus;
|
||||
/**
|
||||
* 计算日期
|
||||
*/
|
||||
private String computeDate;
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
|
||||
if (Objects.equals(dataType, "02")) {
|
||||
return DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(searchBeginTime, DatePattern.NORM_MONTH_PATTERN)), DatePattern.NORM_MONTH_PATTERN);
|
||||
}
|
||||
if (Objects.equals(dataType, "01")) {
|
||||
return DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(searchBeginTime, DatePattern.NORM_YEAR_PATTERN)), DatePattern.NORM_YEAR_PATTERN);
|
||||
}
|
||||
return searchBeginTime;
|
||||
}
|
||||
|
||||
@@ -144,22 +147,21 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
|
||||
.in(PqTypicalSourceCreatePO::getStatisticalLevel, Stream.of("3","4").collect(Collectors.toList()))
|
||||
.list();
|
||||
}
|
||||
List<PqTypicalSourceCreateDTO> dtoList = BeanUtil.copyToList(list, PqTypicalSourceCreateDTO.class);
|
||||
|
||||
//以尺寸100分片
|
||||
List<List<PqTypicalSourceCreateDTO>> pendingIds = ListUtils.partition(dtoList, 100);
|
||||
pendingIds.forEach(temp->{
|
||||
List<List<PqTypicalSourceCreatePO>> partition = ListUtils.partition(list, 100);
|
||||
partition.forEach(temp->{
|
||||
List<PqTypicalSourceCreateDTO> dtoList = BeanUtil.copyToList(temp, PqTypicalSourceCreateDTO.class);
|
||||
SendParam sendParam = new SendParam();
|
||||
sendParam.setStats(temp);
|
||||
sendParam.setStatisticalDate(temp.get(0).getStatisticalDate());
|
||||
sendParam.setStats(dtoList);
|
||||
sendParam.setStatisticalDate(temp.get(0).getComputeDate());
|
||||
String s = JSONObject.toJSONStringWithDateFormat(sendParam, JSON.DEFFAULT_DATE_FORMAT);
|
||||
log.info(Thread.currentThread().getName() + "获取返回体 换流站指标统计明细数据接口数据:" + s + "开始----!");
|
||||
Map<String, String> send = GwSendUtil.send(sendParam, GWSendEnum.TYPICAL_SOURCE);
|
||||
log.info(Thread.currentThread().getName() + "获取返回体换流站指标统计明细数据接口响应结果:" + send + "结束----!");
|
||||
|
||||
List<String> trIds = temp.stream().map(PqTypicalSourceCreateDTO::getId).distinct().collect(Collectors.toList());
|
||||
List<String> trIds = dtoList.stream().map(PqTypicalSourceCreateDTO::getId).distinct().collect(Collectors.toList());
|
||||
returnInformation(1, trIds, send);
|
||||
});
|
||||
|
||||
return "成功";
|
||||
|
||||
}
|
||||
|
||||
@@ -94,19 +94,17 @@ public class PointStatisticalDataServiceImpl extends ServiceImpl<RUploadPointSta
|
||||
}
|
||||
|
||||
list = list.stream().peek(item->item.setStationType(dictDataMap.get(item.getStationType()).getValue())).collect(Collectors.toList());
|
||||
|
||||
List<MonitorStatisticalDTO> dtoList = BeanUtil.copyToList(list, MonitorStatisticalDTO.class);
|
||||
//以尺寸100分片
|
||||
List<List<MonitorStatisticalDTO>> pendingIds = ListUtils.partition(dtoList, 100);
|
||||
List<List<RUploadPointStatisticalDataD>> partition = ListUtils.partition(list, 100);
|
||||
//分片上传
|
||||
for (int i = 0; i < pendingIds.size(); i++) {
|
||||
for (int i = 0; i < partition.size(); i++) {
|
||||
List<MonitorStatisticalDTO> dtoList = BeanUtil.copyToList(partition.get(i), MonitorStatisticalDTO.class);
|
||||
SendParam sp = new SendParam();
|
||||
sp.setStats(pendingIds.get(i));
|
||||
sp.setStatisticalDate(param.getTime());
|
||||
sp.setStats(dtoList);
|
||||
sp.setStatisticalDate(partition.get(i).get(0).getComputeDate());
|
||||
//上送数据
|
||||
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.STATISTICAL_CREATE);
|
||||
//获取返回结果
|
||||
List<String> l = pendingIds.get(i).stream().map(MonitorStatisticalDTO::getId).collect(Collectors.toList());
|
||||
List<String> l = dtoList.stream().map(MonitorStatisticalDTO::getId).collect(Collectors.toList());
|
||||
returnInformation(i,l,send);
|
||||
}
|
||||
return "上送成功:成功数据" + list.size() + "条";
|
||||
|
||||
@@ -107,49 +107,50 @@ public class REvaluationDataServiceImpl extends ServiceImpl<RUploadEvaluationDat
|
||||
.in(RUploadEvaluationDataD::getStatisticalLevel, Stream.of("3","4").collect(Collectors.toList()))
|
||||
.list();
|
||||
}
|
||||
List<PqEvaluationCreateDTO> dtoList = BeanUtil.copyToList(list, PqEvaluationCreateDTO.class);
|
||||
|
||||
//以尺寸100分片
|
||||
List<List<PqEvaluationCreateDTO>> pendingIds = ListUtils.partition(dtoList, 100);
|
||||
List<List<RUploadEvaluationDataD>> partition = ListUtils.partition(list, 100);
|
||||
//分片上传
|
||||
for (int i = 0; i < pendingIds.size(); i++) {
|
||||
for (int i = 0; i < partition.size(); i++) {
|
||||
//处理数据
|
||||
List<PqEvaluationCreateDTO> l1 = pendingIds.get(i).stream().peek(item->{
|
||||
if (Objects.equals(item.getAvgValue(),3.1415926)){
|
||||
List<RUploadEvaluationDataD> collect = partition.get(i).stream().peek(item -> {
|
||||
if (Objects.equals(item.getAvgValue(), 3.1415926)) {
|
||||
item.setAvgValue(0d);
|
||||
} else {
|
||||
BigDecimal four = BigDecimal.valueOf(item.getAvgValue());
|
||||
double value = four.setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
double value = four.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
item.setAvgValue(value);
|
||||
}
|
||||
if (Objects.equals(item.getStandardDeviation(),3.1415926)){
|
||||
if (Objects.equals(item.getStandardDeviation(), 3.1415926)) {
|
||||
item.setStandardDeviation(0d);
|
||||
}
|
||||
if (Objects.equals(item.getHarmonicNum(),0)){
|
||||
if (Objects.equals(item.getHarmonicNum(), 0)) {
|
||||
item.setHarmonicNum(null);
|
||||
}
|
||||
if (Objects.equals(item.getVoltageLevel(),"0")){
|
||||
if (Objects.equals(item.getVoltageLevel(), "0")) {
|
||||
item.setVoltageLevel(null);
|
||||
} else {
|
||||
item.setVoltageLevel(getVoltage(item.getVoltageLevel()));
|
||||
}
|
||||
if (Objects.equals(item.getCityId(),"")){
|
||||
if (Objects.equals(item.getCityId(), "")) {
|
||||
item.setCityId(null);
|
||||
}
|
||||
if (Objects.equals(item.getCountyId(),"")){
|
||||
if (Objects.equals(item.getCountyId(), "")) {
|
||||
item.setCountyId(null);
|
||||
}
|
||||
BigDecimal four = BigDecimal.valueOf(item.getMonitorBusRate());
|
||||
double value = four.setScale(4,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
double value = four.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
item.setMonitorBusRate(value);
|
||||
}).collect(Collectors.toList());
|
||||
List<PqEvaluationCreateDTO> dtoList = BeanUtil.copyToList(collect, PqEvaluationCreateDTO.class);
|
||||
//组装数据
|
||||
SendParam sp = new SendParam();
|
||||
sp.setStats(l1);
|
||||
sp.setStatisticalDate(param.getTime());
|
||||
sp.setStats(dtoList);
|
||||
sp.setStatisticalDate(collect.get(0).getComputeDate());
|
||||
//上送数据
|
||||
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.EVALUATION);
|
||||
//获取返回结果
|
||||
List<String> l = pendingIds.get(i).stream().map(PqEvaluationCreateDTO::getId).collect(Collectors.toList());
|
||||
List<String> l = dtoList.stream().map(PqEvaluationCreateDTO::getId).collect(Collectors.toList());
|
||||
returnInformation(i,l,send);
|
||||
}
|
||||
return "上送成功:成功数据" + list.size() + "条";
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
@@ -12,6 +13,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.harmonic.mapper.upload.RUploadSubstationStatisticalDataDMapper;
|
||||
import com.njcn.harmonic.pojo.dto.PqTypicalSourceCreateDTO;
|
||||
import com.njcn.harmonic.pojo.dto.upload.SubstationQualityStatisticsDTO;
|
||||
import com.njcn.harmonic.pojo.param.UploadDataParam;
|
||||
import com.njcn.harmonic.pojo.param.UploadParam;
|
||||
@@ -86,21 +88,21 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
|
||||
//.eq(RUploadSubstationStatisticalDataD::getCountyId,"")
|
||||
.list();
|
||||
}
|
||||
//处理时间
|
||||
String[] arr = param.getTime().split("-");
|
||||
String time = arr[0]+"-"+arr[1];
|
||||
List<SubstationQualityStatisticsDTO> dtoList = BeanUtil.copyToList(list, SubstationQualityStatisticsDTO.class);
|
||||
//以尺寸100分片
|
||||
List<List<SubstationQualityStatisticsDTO>> pendingIds = ListUtils.partition(dtoList, 100);
|
||||
List<List<RUploadSubstationStatisticalDataD>> partition = ListUtils.partition(list, 100);
|
||||
//分片上传
|
||||
for (int i = 0; i < pendingIds.size(); i++) {
|
||||
for (int i = 0; i < partition.size(); i++) {
|
||||
List<RUploadSubstationStatisticalDataD> collect = partition.get(i).stream().peek(item -> {
|
||||
item.setStatisticalDate(item.getComputeDate().substring(0, 7));
|
||||
}).collect(Collectors.toList());
|
||||
List<SubstationQualityStatisticsDTO> dtoList = BeanUtil.copyToList(collect, SubstationQualityStatisticsDTO.class);
|
||||
SendParam sp = new SendParam();
|
||||
sp.setStats(pendingIds.get(i));
|
||||
sp.setStatisticalDate(time);
|
||||
sp.setStats(dtoList);
|
||||
sp.setStatisticalDate(partition.get(i).get(0).getComputeDate());
|
||||
//上送数据
|
||||
Map<String, String> send = GwSendUtil.send(sp, GWSendEnum.SUBSTATION_MONITOR);
|
||||
//获取返回结果
|
||||
List<String> l = pendingIds.get(i).stream().map(SubstationQualityStatisticsDTO::getId).collect(Collectors.toList());
|
||||
List<String> l = dtoList.stream().map(SubstationQualityStatisticsDTO::getId).collect(Collectors.toList());
|
||||
returnInformation(i,l,send);
|
||||
}
|
||||
return "上送成功:成功数据" + list.size() + "条";
|
||||
@@ -143,9 +145,7 @@ public class RSubstationStatisticalDataServiceImpl extends ServiceImpl<RUploadSu
|
||||
if (Objects.equals(dataType, "02")) {
|
||||
return DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(searchBeginTime, DatePattern.NORM_MONTH_PATTERN)), DatePattern.NORM_MONTH_PATTERN);
|
||||
}else if(Objects.equals(dataType, "01")){
|
||||
String year = DateUtil.format(DateUtil.parse(searchBeginTime,DatePattern.NORM_DATE_PATTERN),DatePattern.NORM_YEAR_PATTERN);
|
||||
String month = DateUtil.format(new Date(),DatePattern.NORM_MONTH_PATTERN).split("-")[1];
|
||||
return year+"-"+month;
|
||||
return DateUtil.format(DateUtil.parse(searchBeginTime,DatePattern.NORM_DATE_PATTERN),DatePattern.NORM_YEAR_PATTERN);
|
||||
}
|
||||
return searchBeginTime;
|
||||
}
|
||||
|
||||
@@ -675,6 +675,12 @@ public class OrgPointExecutor extends BaseExecutor{
|
||||
//月表
|
||||
pqTypicalSourceCreatePOService.handlerMonth(calculatedParam);
|
||||
}
|
||||
}else if (tag.equalsIgnoreCase("pq_typical_source_create_y")) {
|
||||
//数据补招不执行非日表算法
|
||||
if (!calculatedParam.isRepair()) {
|
||||
//年表
|
||||
pqTypicalSourceCreatePOService.handleYear(calculatedParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -147,7 +147,7 @@ public class SubStationExecutor extends BaseExecutor{
|
||||
} else if (tag.equalsIgnoreCase("r_upload_substation_statistical_data_m")) {
|
||||
//数据补招不执行非日表算法
|
||||
if (!calculatedParam.isRepair()) {
|
||||
//月表
|
||||
//年算法
|
||||
rUploadSubstationStatisticalDataDService.insertSubStatisticalDataMonth(bindCmp.getRequestData());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,11 @@ import org.apache.ibatis.annotations.Param;
|
||||
*/
|
||||
public interface PqTypicalSourceCreatePOMapper extends BaseMapper<PqTypicalSourceCreatePO> {
|
||||
|
||||
PqTypicalSourceCreatePO selectAvg(@Param("param") PqTypicalSourceCreatePO param,
|
||||
PqTypicalSourceCreatePO selectAvgMonth(@Param("param") PqTypicalSourceCreatePO param,
|
||||
@Param("startTime")String begin,
|
||||
@Param("endTime")String end);
|
||||
|
||||
PqTypicalSourceCreatePO selectAvgYear(@Param("param") PqTypicalSourceCreatePO param,
|
||||
@Param("startTime")String begin,
|
||||
@Param("endTime")String end);
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.prepare.harmonic.mapper.mysql.send.PqTypicalSourceCreatePOMapper">
|
||||
|
||||
<select id="selectAvg" resultType="com.njcn.harmonic.pojo.po.send.PqTypicalSourceCreatePO">
|
||||
<select id="selectAvgMonth" resultType="com.njcn.harmonic.pojo.po.send.PqTypicalSourceCreatePO">
|
||||
select
|
||||
avg(interferenceSourceNum) as interferenceSourceNum,
|
||||
avg(averageOvDays) as averageOvDays,
|
||||
@@ -25,18 +25,17 @@
|
||||
avg(vOvNum) as vOvNum,
|
||||
avg(vOvRate) as vOvRate,
|
||||
avg(unbanAvgOvRate) as unbanAvgOvRate,
|
||||
avg(ovDayCount) as ovDayCount,
|
||||
avg(is_upload_head) as is_upload_head,
|
||||
avg(monthsCount) as monthsCount,
|
||||
avg(flickerOvCount) as flickerOvCount,
|
||||
avg(harmiOvCount) as harmiOvCount,
|
||||
avg(inseqOvCount) as inseqOvCount,
|
||||
avg(unbanOvCount) as unbanOvCount,
|
||||
avg(harmvOvCount) as harmvOvCount,
|
||||
avg(monitorCount) as monitorCount,
|
||||
avg(voltageLevel) as voltageLevel,
|
||||
avg(ovCount) as ovCount,
|
||||
avg(interferenceSourceCount) as interferenceSourceCount
|
||||
sum(ovDayCount) as ovDayCount,
|
||||
sum(monthsCount) as monthsCount,
|
||||
sum(flickerOvCount) as flickerOvCount,
|
||||
sum(harmiOvCount) as harmiOvCount,
|
||||
sum(inseqOvCount) as inseqOvCount,
|
||||
sum(unbanOvCount) as unbanOvCount,
|
||||
sum(harmvOvCount) as harmvOvCount,
|
||||
sum(monitorCount) as monitorCount,
|
||||
voltageLevel,
|
||||
sum(ovCount) as ovCount,
|
||||
sum(interferenceSourceCount) as interferenceSourceCount
|
||||
FROM
|
||||
pq_typical_source_create
|
||||
<where>
|
||||
@@ -85,6 +84,90 @@
|
||||
</if>
|
||||
|
||||
</where>
|
||||
GROUP BY voltageLevel
|
||||
</select>
|
||||
<select id="selectAvgYear" resultType="com.njcn.harmonic.pojo.po.send.PqTypicalSourceCreatePO">
|
||||
select
|
||||
avg(interferenceSourceNum) as interferenceSourceNum,
|
||||
avg(averageOvDays) as averageOvDays,
|
||||
avg(flickerAvgOvRate) as flickerAvgOvRate,
|
||||
avg(flickerOvNum) as flickerOvNum,
|
||||
avg(flickerOvRate) as flickerOvRate,
|
||||
avg(iAvgOvRate) as iAvgOvRate,
|
||||
avg(iOvNum) as iOvNum,
|
||||
avg(iOvRate) as iOvRate,
|
||||
avg(inseqAvgOvRate) as inseqAvgOvRate,
|
||||
avg(inseqOvNum) as inseqOvNum,
|
||||
avg(inseqOvRate) as inseqOvRate,
|
||||
avg(monitorNum) as monitorNum,
|
||||
avg(monitoringRate) as monitoringRate,
|
||||
avg(ovNum) as ovNum,
|
||||
avg(ovRate) as ovRate,
|
||||
avg(unbanOvNum) as unbanOvNum,
|
||||
avg(unbanOvRate) as unbanOvRate,
|
||||
avg(vAvgOvRate) as vAvgOvRate,
|
||||
avg(vOvNum) as vOvNum,
|
||||
avg(vOvRate) as vOvRate,
|
||||
avg(unbanAvgOvRate) as unbanAvgOvRate,
|
||||
sum(ovDayCount) as ovDayCount,
|
||||
sum(monthsCount) as monthsCount,
|
||||
sum(flickerOvCount) as flickerOvCount,
|
||||
sum(harmiOvCount) as harmiOvCount,
|
||||
sum(inseqOvCount) as inseqOvCount,
|
||||
sum(unbanOvCount) as unbanOvCount,
|
||||
sum(harmvOvCount) as harmvOvCount,
|
||||
sum(monitorCount) as monitorCount,
|
||||
voltageLevel,
|
||||
sum(ovCount) as ovCount,
|
||||
sum(interferenceSourceCount) as interferenceSourceCount
|
||||
FROM
|
||||
pq_typical_source_create
|
||||
<where>
|
||||
<if test="param.provinceId != null and param.provinceId != '' ">
|
||||
AND provinceId = #{param.provinceId}
|
||||
</if>
|
||||
<if test="param.cityId != null and param.cityId != '' ">
|
||||
AND cityId = #{param.cityId}
|
||||
</if>
|
||||
<if test="param.countyId != null and param.countyId != '' ">
|
||||
AND countyId = #{param.countyId}
|
||||
</if>
|
||||
|
||||
<if test="param.provinceId == null ">
|
||||
AND provinceId IS NULL
|
||||
</if>
|
||||
<if test="param.cityId == null">
|
||||
AND cityId IS NULL
|
||||
</if>
|
||||
<if test="param.countyId == null">
|
||||
AND countyId IS NULL
|
||||
</if>
|
||||
|
||||
|
||||
|
||||
<if test="param.statisticalType != null and param.statisticalType != '' ">
|
||||
AND statisticalType = #{param.statisticalType}
|
||||
</if>
|
||||
|
||||
<if test="param.statisticalLevel != null and param.statisticalLevel != '' ">
|
||||
AND statisticalLevel = #{param.statisticalLevel}
|
||||
</if>
|
||||
|
||||
<if test="param.indexType != null and param.indexType != '' ">
|
||||
AND indexType = #{param.indexType}
|
||||
</if>
|
||||
|
||||
<if test="param.industryType != null and param.industryType != '' ">
|
||||
AND industryType = #{param.industryType}
|
||||
</if>
|
||||
<if test="startTime != null and startTime != ''">
|
||||
AND DATE_FORMAT(CONCAT(statisticalDate, '-01'), '%Y-%m') >= DATE_FORMAT(#{startTime}, '%Y-%m')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''">
|
||||
AND DATE_FORMAT(CONCAT(statisticalDate, '-01'), '%Y-%m') <= DATE_FORMAT(#{endTime}, '%Y-%m')
|
||||
</if>
|
||||
|
||||
</where>
|
||||
GROUP BY voltageLevel
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -18,13 +18,13 @@
|
||||
round(avg(coverage_rate),4) coverageRate,
|
||||
case when avg(run_substation_num) = 0 then 0 else round(avg(monitor_substaion_num)/avg(run_substation_num)*100,4) end monitoringRate,
|
||||
#{monthDate} statisticalDate,
|
||||
#{monthDate} statisticalMonth,
|
||||
'01' statisticalType,
|
||||
0 uploadStatus
|
||||
from
|
||||
r_upload_substation_statistical_data_d
|
||||
where
|
||||
statistical_date between #{startTime} and #{endTime}
|
||||
and statistical_type = "02"
|
||||
group by province_id ,
|
||||
province_name ,
|
||||
city_id ,
|
||||
|
||||
@@ -17,4 +17,6 @@ public interface PqTypicalSourceCreatePOService extends IService<PqTypicalSource
|
||||
void handlerDay(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam);
|
||||
|
||||
void handlerMonth(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam);
|
||||
|
||||
void handleYear(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam);
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
|
||||
pqTypicalSourceCreatePO = initPqTypicalSourceCreatePO(pqTypicalSourceCreatePO,rMpPartHarmonicDetailDS,rMpSurplusHarmonicDetailDS,monitorIds.size());
|
||||
pqTypicalSourceCreatePO.setIndexType(temp);
|
||||
pqTypicalSourceCreatePO.setStatisticalDate(calculatedParam.getDataDate());
|
||||
pqTypicalSourceCreatePO.setComputeDate(calculatedParam.getDataDate());
|
||||
pqTypicalSourceCreatePO.setStatisticalType("03");
|
||||
pqTypicalSourceCreatePO.setMonitorNum(monitorIds.size());
|
||||
pqTypicalSourceCreatePO.setMonitorCount(monitorIds.size());
|
||||
@@ -356,12 +357,12 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
|
||||
}
|
||||
pqTypicalSourceCreatePO.setIndexType(temp);
|
||||
pqTypicalSourceCreatePO.setStatisticalType("03");
|
||||
PqTypicalSourceCreatePO po= this.baseMapper.selectAvg(pqTypicalSourceCreatePO, begin, end);
|
||||
PqTypicalSourceCreatePO po= this.baseMapper.selectAvgMonth(pqTypicalSourceCreatePO, begin, end);
|
||||
if(ObjectUtil.isNotNull(po)){
|
||||
po.setId(deptGetChildrenMoreDTO.getUnitId()+"-"+pqTypicalSourceCreatePO.getIndexType()+"-"+pqTypicalSourceCreatePO.getStatisticalType()+"-"+begin);
|
||||
po.setStatisticalType("02");
|
||||
po.setIndexType(temp);
|
||||
po.setStatisticalDate(date);
|
||||
po.setComputeDate(calculatedParam.getDataDate());
|
||||
po.setProvinceName(pqTypicalSourceCreatePO.getProvinceName());
|
||||
po.setProvinceId(pqTypicalSourceCreatePO.getProvinceId());
|
||||
po.setCityName(pqTypicalSourceCreatePO.getCityName());
|
||||
@@ -370,6 +371,110 @@ public class PqTypicalSourceCreatePOServiceImpl extends ServiceImpl<PqTypicalSou
|
||||
po.setCountyId(pqTypicalSourceCreatePO.getCountyId());
|
||||
po.setStatisticalLevel(pqTypicalSourceCreatePO.getStatisticalLevel());
|
||||
po.setIndustryType(pqTypicalSourceCreatePO.getIndustryType());
|
||||
po.setId(deptGetChildrenMoreDTO.getUnitId()+"-"+po.getIndexType()+"-"+po.getStatisticalType()+"-"+date);
|
||||
pqTypicalSourceCreatePOList.add(po);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(pqTypicalSourceCreatePOList)){
|
||||
this.saveOrUpdateBatch(pqTypicalSourceCreatePOList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleYear(CalculatedParam<DeptGetChildrenMoreDTO> calculatedParam) {
|
||||
List<PqTypicalSourceCreatePO> pqTypicalSourceCreatePOList = new ArrayList<>();
|
||||
//查询时间范围
|
||||
String begin = DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString();
|
||||
String end = DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)).toString();
|
||||
String date = begin.substring(0, 4);
|
||||
|
||||
/*3.45 典型源荷用户类型*/
|
||||
List<String> collect = Stream.of(DicDataEnum.TRACTIONSTATION.getCode(),
|
||||
DicDataEnum.WINDFARM_USER.getCode(),
|
||||
DicDataEnum.PHOTOVOLTAICSIT_EUSERS.getCode(),
|
||||
DicDataEnum.OTHER_INTERFERENCESOURCE_USERS.getCode()).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<PvTerminalTreeVO> deptList = deptFeignClient.allDeptList().getData();
|
||||
Map<String, PvTerminalTreeVO> mapCode = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getCode, Function.identity()));
|
||||
Map<String, PvTerminalTreeVO> mapList = deptList.stream().collect(Collectors.toMap(PvTerminalTreeVO::getId, Function.identity()));
|
||||
|
||||
for (DeptGetChildrenMoreDTO deptGetChildrenMoreDTO : calculatedParam.getIdList()) {
|
||||
|
||||
collect.stream().forEach(temp->{
|
||||
PqTypicalSourceCreatePO pqTypicalSourceCreatePO = new PqTypicalSourceCreatePO();
|
||||
if (temp.equals(DicDataEnum.TRACTIONSTATION.getCode())){
|
||||
pqTypicalSourceCreatePO.setIndustryType("99");
|
||||
|
||||
} else if (temp.equals(DicDataEnum.WINDFARM_USER.getCode())) {
|
||||
pqTypicalSourceCreatePO.setIndustryType("99");
|
||||
|
||||
}else if(temp.equals(DicDataEnum.PHOTOVOLTAICSIT_EUSERS.getCode())) {
|
||||
pqTypicalSourceCreatePO.setIndustryType("99");
|
||||
}else if(temp.equals(DicDataEnum.OTHER_INTERFERENCESOURCE_USERS.getCode())) {
|
||||
pqTypicalSourceCreatePO.setIndustryType("00");
|
||||
|
||||
}
|
||||
if (mapCode.containsKey(deptGetChildrenMoreDTO.getUnitId())) {
|
||||
PvTerminalTreeVO pvTerminalTreeVO = mapCode.get(deptGetChildrenMoreDTO.getUnitId());
|
||||
String[] split = (pvTerminalTreeVO.getPids() + StrUtil.COMMA + pvTerminalTreeVO.getId())
|
||||
.split(StrUtil.COMMA);
|
||||
if (split.length <3) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 2; i < split.length; i++) {
|
||||
//省
|
||||
if (i == 2) {
|
||||
if (mapList.containsKey(split[i])) {
|
||||
pvTerminalTreeVO = mapList.get(split[i]);
|
||||
pqTypicalSourceCreatePO.setProvinceName(pvTerminalTreeVO.getName());
|
||||
pqTypicalSourceCreatePO.setProvinceId(pvTerminalTreeVO.getCode());
|
||||
pqTypicalSourceCreatePO.setStatisticalLevel("3");
|
||||
}
|
||||
}
|
||||
//市
|
||||
if (i == 3) {
|
||||
if (mapList.containsKey(split[i])) {
|
||||
pvTerminalTreeVO = mapList.get(split[i]);
|
||||
pqTypicalSourceCreatePO.setCityName(pvTerminalTreeVO.getName());
|
||||
pqTypicalSourceCreatePO.setCityId(pvTerminalTreeVO.getCode());
|
||||
pqTypicalSourceCreatePO.setStatisticalLevel("4");
|
||||
|
||||
}
|
||||
}
|
||||
//县
|
||||
if (i == 4) {
|
||||
if (mapList.containsKey(split[i])) {
|
||||
pvTerminalTreeVO = mapList.get(split[i]);
|
||||
pqTypicalSourceCreatePO.setCountyName(pvTerminalTreeVO.getName());
|
||||
pqTypicalSourceCreatePO.setCountyId(pvTerminalTreeVO.getCode());
|
||||
pqTypicalSourceCreatePO.setStatisticalLevel("5");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pqTypicalSourceCreatePO.setIndexType(temp);
|
||||
pqTypicalSourceCreatePO.setStatisticalType("02");
|
||||
PqTypicalSourceCreatePO po= this.baseMapper.selectAvgYear(pqTypicalSourceCreatePO, begin, end);
|
||||
if(ObjectUtil.isNotNull(po)){
|
||||
po.setStatisticalType("01");
|
||||
po.setIndexType(temp);
|
||||
po.setStatisticalDate(date);
|
||||
po.setComputeDate(calculatedParam.getDataDate());
|
||||
po.setProvinceName(pqTypicalSourceCreatePO.getProvinceName());
|
||||
po.setProvinceId(pqTypicalSourceCreatePO.getProvinceId());
|
||||
po.setCityName(pqTypicalSourceCreatePO.getCityName());
|
||||
po.setCityId(pqTypicalSourceCreatePO.getCityId());
|
||||
po.setCountyName(pqTypicalSourceCreatePO.getCountyName());
|
||||
po.setCountyId(pqTypicalSourceCreatePO.getCountyId());
|
||||
po.setStatisticalLevel(pqTypicalSourceCreatePO.getStatisticalLevel());
|
||||
po.setIndustryType(pqTypicalSourceCreatePO.getIndustryType());
|
||||
po.setId(deptGetChildrenMoreDTO.getUnitId()+"-"+po.getIndexType()+"-"+po.getStatisticalType()+"-"+date);
|
||||
pqTypicalSourceCreatePOList.add(po);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,6 +101,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
|
||||
rUploadEvaluationDataD.setProvinceName(dept.getName());
|
||||
rUploadEvaluationDataD.setDataSources(UploadEnum.DATA_SOURCES_01.getCode());
|
||||
rUploadEvaluationDataD.setStatisticalDate(calculatedParam.getDataDate());
|
||||
rUploadEvaluationDataD.setComputeDate(calculatedParam.getDataDate());
|
||||
rUploadEvaluationDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode());
|
||||
rUploadEvaluationDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode()));
|
||||
this.judgeLevel(item.getDeptLevel(),rUploadEvaluationDataD,item.getUnitId(),item.getUnitName(),deptList,deptMap);
|
||||
@@ -186,6 +187,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
list.forEach(item->{
|
||||
item.setId(IdUtil.simpleUUID());
|
||||
item.setComputeDate(calculatedParam.getDataDate());
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
@@ -208,6 +210,7 @@ public class RUploadEvaluationDataDServiceImpl extends MppServiceImpl<RUploadEva
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
list.forEach(item->{
|
||||
item.setId(IdUtil.simpleUUID());
|
||||
item.setComputeDate(calculatedParam.getDataDate());
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
|
||||
@@ -159,6 +159,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
rUploadPointStatisticalDataD.setProvinceId(dept.getCode());
|
||||
rUploadPointStatisticalDataD.setProvinceName(dept.getName());
|
||||
rUploadPointStatisticalDataD.setStatisticalDate(calculatedParam.getDataDate());
|
||||
rUploadPointStatisticalDataD.setComputeDate(calculatedParam.getDataDate());
|
||||
rUploadPointStatisticalDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode());
|
||||
rUploadPointStatisticalDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode()));
|
||||
//fixme 主配网标识文档中没有,先随便定义一个,后期调整
|
||||
@@ -204,6 +205,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
rUploadPointStatisticalDataD.setProvinceId(dept.getCode());
|
||||
rUploadPointStatisticalDataD.setProvinceName(dept.getName());
|
||||
rUploadPointStatisticalDataD.setStatisticalDate(calculatedParam.getDataDate());
|
||||
rUploadPointStatisticalDataD.setComputeDate(calculatedParam.getDataDate());
|
||||
rUploadPointStatisticalDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_03.getCode());
|
||||
rUploadPointStatisticalDataD.setUploadStatus(Integer.parseInt(UploadEnum.UPLOAD_STATUS_0.getCode()));
|
||||
//fixme 主配网标识文档中没有,先随便定义一个,后期调整
|
||||
@@ -275,6 +277,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
list.forEach(item->{
|
||||
item.setId(IdUtil.simpleUUID());
|
||||
item.setComputeDate(calculatedParam.getDataDate());
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
@@ -293,6 +296,7 @@ public class RUploadPointStatisticalDataDServiceImpl extends MppServiceImpl<RUpl
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
list.forEach(item->{
|
||||
item.setId(IdUtil.simpleUUID());
|
||||
item.setComputeDate(calculatedParam.getDataDate());
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl
|
||||
RUploadSubstationStatisticalDataD rUploadSubstationStatisticalDataD = new RUploadSubstationStatisticalDataD();
|
||||
rUploadSubstationStatisticalDataD.setId(IdUtil.simpleUUID());
|
||||
rUploadSubstationStatisticalDataD.setStatisticalDate(DateUtil.format(DateUtil.parse(calculatedParam.getDataDate()),DatePattern.NORM_MONTH_PATTERN));
|
||||
rUploadSubstationStatisticalDataD.setComputeDate(calculatedParam.getDataDate());
|
||||
rUploadSubstationStatisticalDataD.setStatisticalType(UploadEnum.STATISTICAL_TYPE_02.getCode());
|
||||
rUploadSubstationStatisticalDataD.setProvinceId(dept.getCode());
|
||||
rUploadSubstationStatisticalDataD.setProvinceName(dept.getName());
|
||||
@@ -114,19 +115,17 @@ public class RUploadSubstationStatisticalDataDServiceImpl extends MppServiceImpl
|
||||
@Override
|
||||
public void insertSubStatisticalDataMonth(CalculatedParam<String> calculatedParam) {
|
||||
//开始月份
|
||||
String beginMonth = DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_MONTH_PATTERN)), DatePattern.NORM_MONTH_PATTERN);
|
||||
String beginMonth = DateUtil.format(DateUtil.beginOfMonth(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_MONTH_PATTERN)), DatePattern.NORM_YEAR_PATTERN);
|
||||
//起始时间
|
||||
String startTime = DateUtil.format(DateUtil.beginOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
|
||||
//结束时间
|
||||
String endTime = DateUtil.format(DateUtil.endOfYear(DateUtil.parse(calculatedParam.getDataDate(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATE_PATTERN);
|
||||
//数据集
|
||||
List<RUploadSubstationStatisticalDataD> list = this.baseMapper.substationStatisticalMonthData(beginMonth,startTime,endTime);
|
||||
|
||||
|
||||
|
||||
if (CollUtil.isNotEmpty(list)){
|
||||
list.forEach(item->{
|
||||
item.setId(IdUtil.simpleUUID());
|
||||
item.setComputeDate(calculatedParam.getDataDate());
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,27 @@
|
||||
package com.njcn.system.handler;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.common.pojo.dto.LogInfoDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.system.service.IUserLogService;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.web.utils.EmailUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -23,6 +34,8 @@ import java.nio.charset.StandardCharsets;
|
||||
public class MqttMessageHandler {
|
||||
|
||||
private final IUserLogService userLogService;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final EmailUtil emailUtil;
|
||||
|
||||
/**
|
||||
* 订阅审计日志的记录,并进行入库操作
|
||||
@@ -32,4 +45,35 @@ public class MqttMessageHandler {
|
||||
LogInfoDTO logInfoDTO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
userLogService.addUserLog(logInfoDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订阅审计日志的记录,并进行入库操作
|
||||
*/
|
||||
@MqttSubscribe(value = "/userLogEmailPush")
|
||||
public void subUserLogEmail(String topic, MqttMessage message, @Payload String payload) {
|
||||
LogInfoDTO auditLogVO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),LogInfoDTO.class);
|
||||
List<User> data = userFeignClient.getUserListByRoleCode("audit_manager").getData();
|
||||
List<String> emails = data.stream()
|
||||
.filter(x -> Pattern.matches(PatternRegex.EMAIL_REGEX,x.getEmail()))
|
||||
.filter(x -> StrUtil.isNotBlank(x.getEmail()) && x.getEmailNotice() == 1)
|
||||
.map(User::getEmail).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(emails)){
|
||||
StringBuilder describe = new StringBuilder();
|
||||
describe.append(auditLogVO.getType() == 0 ? "业务事件 -> " : "系统事件 -> ");
|
||||
describe.append(auditLogVO.getUserName()).append("在")
|
||||
.append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(auditLogVO.getCreateTime()))
|
||||
.append("在")
|
||||
.append(auditLogVO.getIp())
|
||||
.append("执行了")
|
||||
.append(auditLogVO.getOperate())
|
||||
.append(",结果为");
|
||||
if (auditLogVO.getResult() == 1) {
|
||||
describe.append("成功");
|
||||
}
|
||||
if (auditLogVO.getResult() == 0) {
|
||||
describe.append("失败").append(",失败原因为").append(auditLogVO.getFailReason());
|
||||
}
|
||||
emailUtil.sendMultiple(emails,"告警消息",describe.toString(),false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class AuditServiceImpl extends ServiceImpl<UserLogMapper, UserLog> implem
|
||||
auditLogVO.setUserName(userLog.getLoginName());
|
||||
auditLogVO.setOperate(userLog.getOperate());
|
||||
StringBuilder describe = new StringBuilder();
|
||||
describe.append(auditLogVO.getUserName()).append("在").append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm").format(userLog.getUpdateTime())).append("在").append(userLog.getIp()).append("执行了").append(userLog.getOperate()).append(",结果为");
|
||||
describe.append(auditLogVO.getUserName()).append("在").append(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(userLog.getUpdateTime())).append("在").append(userLog.getIp()).append("执行了").append(userLog.getOperate()).append(",结果为");
|
||||
if (userLog.getResult() == 1) {
|
||||
describe.append("成功");
|
||||
}
|
||||
|
||||
@@ -22,11 +22,18 @@ public class PqTypicalSourceTaskMRunner implements TimerTaskRunner {
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
//月
|
||||
UploadParam param=new UploadParam();
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_MONTH_PATTERN));
|
||||
String code = pqTypicalSourceFeignClient.send(param).getCode();
|
||||
if(code.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
//年
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
|
||||
String code2 = pqTypicalSourceFeignClient.send(param).getCode();
|
||||
if(code2.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,18 @@ public class UploadGwTaskEvaluationMRunner implements TimerTaskRunner {
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
//月
|
||||
UploadParam param = new UploadParam();
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_MONTH_PATTERN));
|
||||
String code = uploadGwDataFeignClient.uploadEvaluationData(param).getCode();
|
||||
if(code.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
//年
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
|
||||
String code2 = uploadGwDataFeignClient.uploadEvaluationData(param).getCode();
|
||||
if(code2.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,11 @@ public class UploadGwTaskMRunner implements TimerTaskRunner {
|
||||
if(code.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
//年
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
|
||||
String code2 = uploadGwDataFeignClient.uploadPointStatisticalData(param).getCode();
|
||||
if(code2.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,11 @@ public class UploadGwTaskSubstationMRunner implements TimerTaskRunner {
|
||||
if(code.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
//年
|
||||
param.setTime(DateUtil.yesterday().toString(DatePattern.NORM_YEAR_PATTERN));
|
||||
String code2 = uploadGwDataFeignClient.uploadSubstationStatisticalData(param).getCode();
|
||||
if(code2.equals("A0002")){
|
||||
throw new BusinessException("失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,4 +73,11 @@ public interface UserFeignClient {
|
||||
*/
|
||||
@PostMapping("/getUserByDeptIds")
|
||||
HttpResult<List<User>> getUserByDeptIds(@RequestBody List<String> deptId);
|
||||
/**
|
||||
* 根据角色Code集合查询用户信息
|
||||
* @param roleCode
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserListByRoleCode")
|
||||
HttpResult<List<User>> getUserListByRoleCode(@RequestParam("roleCode") String roleCode);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,12 @@ public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeign
|
||||
log.error("{}异常,降级处理,异常为:{}","根据部门ids查询用户信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<User>> getUserListByRoleCode(String roleCode) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据角色Code集合查询用户信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ public class DeptController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getDeptInfoListByIds")
|
||||
@ApiOperation("根据部门ids获取部门集合")
|
||||
@ApiImplicitParam(name = "list", value = "code集合", required = true)
|
||||
@ApiImplicitParam(name = "deptIds", value = "code集合", required = true)
|
||||
public HttpResult<List<Dept>> getDeptInfoListByIds(@RequestBody List<String> deptIds) {
|
||||
String methodDescribe = getMethodDescribe("getDeptInfoListByIds");
|
||||
List<Dept> result = deptService.getDeptInfoListByIds(deptIds);
|
||||
|
||||
@@ -483,5 +483,20 @@ public class UserController extends BaseController {
|
||||
);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, users, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取同级部门用户,以及下级部门所有用户
|
||||
* @author cdf
|
||||
* @date 2023/7/31
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_SERIOUS)
|
||||
@GetMapping("/getUserListByRoleCode")
|
||||
@ApiOperation("根据角色Code集合查询用户信息")
|
||||
@ApiImplicitParam(name = "roleCode", value = "角色Code", required = true)
|
||||
public HttpResult<List<User>> getUserListByRoleCode(@RequestParam("roleCode") String roleCode) {
|
||||
String methodDescribe = getMethodDescribe("getUserListByRoleCode");
|
||||
List<User> users = userService.getUserListByRoleCode(roleCode);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, users, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.user.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.user.pojo.po.Role;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.UserRole;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -32,4 +33,12 @@ public interface UserRoleMapper extends BaseMapper<UserRole> {
|
||||
* @return 角色结果集
|
||||
*/
|
||||
List<Role> getRoleListByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 根据角色Code获取角色信息
|
||||
* @param roleCode
|
||||
* @return
|
||||
*/
|
||||
List<User> selectUserRoleCode(@Param("roleCode")String roleCode);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,4 +18,14 @@
|
||||
where a.user_id = #{userId}
|
||||
and b.state = 1
|
||||
</select>
|
||||
<select id="selectUserRoleCode" resultType="com.njcn.user.pojo.po.User">
|
||||
SELECT
|
||||
usr.*
|
||||
FROM
|
||||
sys_user usr
|
||||
INNER JOIN sys_user_role usrRole ON usrRole.User_Id = usr.Id
|
||||
INNER JOIN sys_role role ON role.Id = usrRole.Role_Id
|
||||
WHERE
|
||||
role.`Code` = #{roleCode}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -185,4 +185,7 @@ public interface IUserService extends IService<User> {
|
||||
String uploadImage(MultipartFile issuesFile);
|
||||
|
||||
String getUrl(String headSculpture);
|
||||
|
||||
List<User> getUserListByRoleCode(String roleCode);
|
||||
|
||||
}
|
||||
|
||||
@@ -518,6 +518,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
||||
return fileStorageUtil.getFileUrl(headSculpture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getUserListByRoleCode(String roleCode) {
|
||||
return userRoleMapper.selectUserRoleCode(roleCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据登录名查询用户
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user