Merge remote-tracking branch 'origin/main'

This commit is contained in:
wr
2026-01-26 15:00:34 +08:00
103 changed files with 7570 additions and 2651 deletions

View File

@@ -53,9 +53,9 @@
<!--nacos的ip:port--> <!--nacos的ip:port-->
<nacos.password>nacos</nacos.password> <nacos.password>nacos</nacos.password>
<!--服务器发布内容为空--> <!--服务器发布内容为空-->
<nacos.namespace>hswbpm</nacos.namespace> <nacos.namespace>hswbpm</nacos.namespace>
<!-- <nacos.namespace>30c701c4-2a94-49d9-82e1-76aa9456573f</nacos.namespace>--> <!-- <nacos.namespace>30c701c4-2a94-49d9-82e1-76aa9456573f</nacos.namespace>-->
<!-- <nacos.namespace>12b467cc-a7e6-411d-8944-090cbfa09dde</nacos.namespace>--> <!-- <nacos.namespace>12b467cc-a7e6-411d-8944-090cbfa09dde</nacos.namespace>-->
<!-- <nacos.namespace>910d0d69-2254-481b-b9f7-7ecf9cb881b0</nacos.namespace>--> <!-- <nacos.namespace>910d0d69-2254-481b-b9f7-7ecf9cb881b0</nacos.namespace>-->
<!-- sentinel:port--> <!-- sentinel:port-->
<sentinel.url>${middle.server.url}:8080</sentinel.url> <sentinel.url>${middle.server.url}:8080</sentinel.url>

View File

@@ -74,6 +74,12 @@
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<!--数据库相关********end--> <!--数据库相关********end-->
</dependencies> </dependencies>

View File

@@ -25,7 +25,7 @@ public class BusinessDataUtil {
List<List<Double>> unTolerateData = new ArrayList<>(); List<List<Double>> unTolerateData = new ArrayList<>();
for (List<Double> list : originData) { for (List<Double> list : originData) {
//是否超过上限 //是否超过上限
if (list.get(0) <= 0.03) { if (list.get(0) <= 0.003) {
int line = 230 - 30000 * list.get(0).intValue(); int line = 230 - 30000 * list.get(0).intValue();
if (list.get(1) > line) { if (list.get(1) > line) {
unTolerateData.add(list); unTolerateData.add(list);

View File

@@ -63,6 +63,13 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.18.0</version>
<optional>false</optional>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -45,7 +45,22 @@ public enum RedisKeyEnum {
/** /**
* 云前置心跳 * 云前置心跳
*/ */
CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L); CLD_HEART_BEAT_KEY("CLD_HEART_BEAT:", 180L),
/**
* 用户日志队列
*/
USER_LOG_QUEUE("USER_LOG_QUEUE", -1L),
/**
* 用户日志邮件推送队列
*/
USER_LOG_EMAIL_QUEUE("USER_LOG_EMAIL_QUEUE", -1L),
/**
* 终端日志
*/
DEVICE_LOG_QUEUE("DEVICE_LOG_QUEUE", -1L);
private final String key; private final String key;

View File

@@ -0,0 +1,66 @@
package com.njcn.redis.utils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* Redis 消息队列工具类
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class RedisMessageQueueUtil {
private final RedisTemplate<String, Object> redisTemplate;
/**
* 推送消息到队列(左推)
*
* @param queueKey 队列Key
* @param message 消息内容JSON字符串
*/
public void pushMessage(String queueKey, String message) {
try {
redisTemplate.opsForList().leftPush(queueKey, message);
} catch (Exception e) {
log.error("推送消息到队列失败queueKey={}", queueKey, e);
throw e;
}
}
/**
* 阻塞式弹出消息(右弹)
*
* @param queueKey 队列Key
* @param timeout 超时时间(秒)
* @return 消息内容超时返回null
*/
public String popMessage(String queueKey, long timeout) {
try {
Object result = redisTemplate.opsForList().rightPop(queueKey, timeout, TimeUnit.SECONDS);
return result != null ? result.toString() : null;
} catch (Exception e) {
log.error("弹出消息失败queueKey={}", queueKey, e);
return null;
}
}
/**
* 获取队列长度(用于监控)
*
* @param queueKey 队列Key
* @return 队列长度
*/
public Long getQueueSize(String queueKey) {
try {
return redisTemplate.opsForList().size(queueKey);
} catch (Exception e) {
log.error("获取队列长度失败queueKey={}", queueKey, e);
return 0L;
}
}
}

View File

@@ -47,6 +47,7 @@ public class FeignConfig {
@Bean @Bean
public Decoder feignDecoder() { public Decoder feignDecoder() {
return (response, type) -> { return (response, type) -> {
String bodyStr = Util.toString(response.body().asReader(Util.UTF_8)); String bodyStr = Util.toString(response.body().asReader(Util.UTF_8));
//对结果进行转换 //对结果进行转换
HttpResult<Object> result = PubUtils.json2obj(bodyStr, type); HttpResult<Object> result = PubUtils.json2obj(bodyStr, type);
@@ -60,6 +61,8 @@ public class FeignConfig {
} }
switch (commonResponseEnum) { switch (commonResponseEnum) {
case SUCCESS: case SUCCESS:
// case NO_DATA:
// case FAIL:
return result; return result;
default: default:
throw new BusinessException(result); throw new BusinessException(result);

View File

@@ -1,8 +1,6 @@
package com.njcn.web.service.impl; package com.njcn.web.service.impl;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.common.config.GeneralInfo; import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.LogInfo; import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.dto.DeviceLogDTO; import com.njcn.common.pojo.dto.DeviceLogDTO;
import com.njcn.common.pojo.dto.LogInfoDTO; import com.njcn.common.pojo.dto.LogInfoDTO;
@@ -10,6 +8,8 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.common.utils.ReflectCommonUtil; import com.njcn.common.utils.ReflectCommonUtil;
import com.njcn.redis.pojo.enums.RedisKeyEnum;
import com.njcn.redis.utils.RedisMessageQueueUtil;
import com.njcn.web.advice.DeviceLog; import com.njcn.web.advice.DeviceLog;
import com.njcn.web.service.ILogService; import com.njcn.web.service.ILogService;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
@@ -46,8 +46,15 @@ public class LogServiceImpl implements ILogService {
private final GeneralInfo generalInfo; private final GeneralInfo generalInfo;
/**
* mqtt处理日志异步发布
*/
// private final MqttPublisher publisher;
private final MqttPublisher publisher; /**
* redis队列处理日志异步发布
*/
private final RedisMessageQueueUtil redisMessageQueueUtil;
/** /**
@@ -82,14 +89,27 @@ public class LogServiceImpl implements ILogService {
String operateType = ReflectCommonUtil.getOperateTypeByMethod(returnType.getMethod()); String operateType = ReflectCommonUtil.getOperateTypeByMethod(returnType.getMethod());
Integer severity = levelStringToNumber(level); 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()); 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); // publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
redisMessageQueueUtil.pushMessage(
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
PubUtils.obj2json(logInfoDTO)
);
//推送审计消息功能 //推送审计消息功能
if (severity != 0) { if (severity != 0) {
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) { if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false); /**注意此处是给前端推送的如果没有了mqtt协议此处前端就无消息可消费了*/
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
//发送邮箱功能 //发送邮箱功能
if (severity == 2 && logInfoDTO.getResult() == 0) { if (severity == 2 && logInfoDTO.getResult() == 0) {
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false); //publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);
// redisMessageQueueUtil.pushMessage(
// RedisKeyEnum.USER_LOG_EMAIL_QUEUE.getKey(),
// PubUtils.obj2json(logInfoDTO)
// );
} }
} }
} }
@@ -97,8 +117,11 @@ public class LogServiceImpl implements ILogService {
if (Objects.nonNull((returnType.getMethod())) && (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)) { if (Objects.nonNull((returnType.getMethod())) && (returnType.getMethod()).isAnnotationPresent(DeviceLog.class)) {
String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType(); String deviceOperate = returnType.getMethod().getAnnotation(DeviceLog.class).operateType();
DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName, deviceOperate, result.equalsIgnoreCase("失败") ? 0 : 1, "", loginName, userIndex); DeviceLogDTO deviceLogDTO = new DeviceLogDTO(userName, deviceOperate, result.equalsIgnoreCase("失败") ? 0 : 1, "", loginName, userIndex);
publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false); // publisher.send("/deviceLog", PubUtils.obj2json(deviceLogDTO), 2, false);
redisMessageQueueUtil.pushMessage(
RedisKeyEnum.DEVICE_LOG_QUEUE.getKey(),
PubUtils.obj2json(deviceLogDTO)
);
} }
} }
@@ -135,7 +158,11 @@ public class LogServiceImpl implements ILogService {
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method); String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
Integer severity = levelStringToNumber(level); 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()); 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); // publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
redisMessageQueueUtil.pushMessage(
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
PubUtils.obj2json(logInfoDTO)
);
auditPush(severity, logInfoDTO); auditPush(severity, logInfoDTO);
} }
@@ -163,7 +190,11 @@ public class LogServiceImpl implements ILogService {
Integer severity = levelStringToNumber(level); Integer severity = levelStringToNumber(level);
String operateType = ReflectCommonUtil.getOperateTypeByMethod(method); String operateType = ReflectCommonUtil.getOperateTypeByMethod(method);
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()); 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); // publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 1, false);
redisMessageQueueUtil.pushMessage(
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
PubUtils.obj2json(logInfoDTO)
);
auditPush(severity, logInfoDTO); auditPush(severity, logInfoDTO);
} }
@@ -171,7 +202,12 @@ public class LogServiceImpl implements ILogService {
//推送审计消息功能 //推送审计消息功能
if (severity != 0) { if (severity != 0) {
if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) { if (!logInfoDTO.getLoginName().equals(LogInfo.UNKNOWN_USER)) {
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false); /**注意此处是给前端推送的如果没有了mqtt协议此处前端就无消息可消费了*/
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
// redisMessageQueueUtil.pushMessage(
// RedisKeyEnum.USER_LOG_QUEUE.getKey(),
// PubUtils.obj2json(logInfoDTO)
// );
//发送邮箱功能 //发送邮箱功能
if (severity == 2 && logInfoDTO.getResult() == 0) { if (severity == 2 && logInfoDTO.getResult() == 0) {
//publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false); //publisher.send("/userLogEmailPush", PubUtils.obj2json(logInfoDTO), 2, false);

View File

@@ -60,6 +60,7 @@
<artifactId>pqs-influx</artifactId> <artifactId>pqs-influx</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -0,0 +1,22 @@
package com.njcn.device.biz.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.biz.pojo.po.Overlimit;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2022-01-04
*/
@DS("sjzx")
@Mapper
public interface OverLimitWlMapper extends BaseMapper<Overlimit> {
}

View File

@@ -1,4 +1,4 @@
package com.njcn.device.overlimit.mapper; package com.njcn.device.biz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.device.overlimit.mapper.OverlimitMapper"> <mapper namespace="com.njcn.device.biz.mapper.OverlimitMapper">
<select id="getAllLineOverLimit" resultType="com.njcn.device.biz.pojo.po.Overlimit"> <select id="getAllLineOverLimit" resultType="com.njcn.device.biz.pojo.po.Overlimit">
select f.* from pq_line a select f.* from pq_line a

View File

@@ -762,81 +762,6 @@ public class Overlimit implements Serializable {
public Overlimit(){} public Overlimit(){}
public Overlimit(String lineId, String scaTmp, float fDLRL, float fJZRL, float fXYRL, float fSBRL){
float[] fLimit = COverlimit.GetOverLimit(scaTmp, fDLRL, fJZRL, fXYRL, fSBRL);
this.id=lineId;
this.freqDev=fLimit[0];
this.voltageDev=fLimit[1];
this.ubalance=fLimit[2];
this.flicker=fLimit[3];
this.uaberrance=fLimit[4];
this.uharm2=fLimit[5];
this.uharm3=fLimit[6];
this.uharm4=fLimit[7];
this.uharm5=fLimit[8];
this.uharm6=fLimit[9];
this.uharm7=fLimit[10];
this.uharm8=fLimit[11];
this.uharm9=fLimit[12];
this.uharm10=fLimit[13];
this.uharm11=fLimit[14];
this.uharm12=fLimit[15];
this.uharm13=fLimit[16];
this.uharm14=fLimit[17];
this.uharm15=fLimit[18];
this.uharm16=fLimit[19];
this.uharm17=fLimit[20];
this.uharm18=fLimit[21];
this.uharm19=fLimit[22];
this.uharm20=fLimit[23];
this.uharm21=fLimit[24];
this.uharm22=fLimit[25];
this.uharm23=fLimit[26];
this.uharm24=fLimit[27];
this.uharm25=fLimit[28];
this.iharm2=fLimit[29];
this.iharm3=fLimit[30];
this.iharm4=fLimit[31];
this.iharm5=fLimit[32];
this.iharm6=fLimit[33];
this.iharm7=fLimit[34];
this.iharm8=fLimit[35];
this.iharm9=fLimit[36];
this.iharm10=fLimit[37];
this.iharm11=fLimit[38];
this.iharm12=fLimit[39];
this.iharm13=fLimit[40];
this.iharm14=fLimit[41];
this.iharm15=fLimit[42];
this.iharm16=fLimit[43];
this.iharm17=fLimit[44];
this.iharm18=fLimit[45];
this.iharm19=fLimit[46];
this.iharm20=fLimit[47];
this.iharm21=fLimit[48];
this.iharm22=fLimit[49];
this.iharm23=fLimit[50];
this.iharm24=fLimit[51];
this.iharm25=fLimit[52];
this.uvoltageDev=fLimit[53];
this.iNeg=fLimit[54];
this.inuharm1=fLimit[55];
this.inuharm2=fLimit[56];
this.inuharm3=fLimit[57];
this.inuharm4=fLimit[58];
this.inuharm5=fLimit[59];
this.inuharm6=fLimit[60];
this.inuharm7=fLimit[61];
this.inuharm8=fLimit[62];
this.inuharm9=fLimit[63];
this.inuharm10=fLimit[64];
this.inuharm11=fLimit[65];
this.inuharm12=fLimit[66];
this.inuharm13=fLimit[67];
this.inuharm14=fLimit[68];
this.inuharm15=fLimit[69];
this.inuharm16=fLimit[70];
}
public void buildIHarm(Float[] iHarmTem){ public void buildIHarm(Float[] iHarmTem){
this.iharm2= iHarmTem[0]; this.iharm2= iHarmTem[0];

View File

@@ -41,7 +41,7 @@ import com.njcn.device.line.mapper.LineDetailMapper;
import com.njcn.device.line.mapper.LineMapper; import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.line.service.LineBakService; import com.njcn.device.line.service.LineBakService;
import com.njcn.device.node.service.INodeService; import com.njcn.device.node.service.INodeService;
import com.njcn.device.overlimit.mapper.OverlimitMapper; import com.njcn.device.biz.mapper.OverlimitMapper;
import com.njcn.device.pq.constant.Param; import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.enums.LineBaseEnum; import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.enums.PvDeviceResponseEnum; import com.njcn.device.pq.enums.PvDeviceResponseEnum;
@@ -96,6 +96,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -3698,305 +3699,339 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList = new ArrayList<>(); List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList = new ArrayList<>();
List<String> addAndDelteId = new ArrayList<>(); List<String> addAndDelteId = new ArrayList<>();
//异常标志
Boolean exFlag= false;
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(list)) {
//前置层修改 List<PqsTerminalLogs> list1 = new ArrayList<>();
List<PqsTerminalLogs> list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList()); try {
if (!CollectionUtils.isEmpty(list1)) { //前置层修改
for (PqsTerminalLogs temp : list1) { list1 = list.stream().filter(temp -> temp.getTerminalDescribe().contains("终端所属前置机由")).collect(Collectors.toList());
String temLos = "%s终端所属前置机由 %s 改为> %s;"; if (!CollectionUtils.isEmpty(list1)) {
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe()); for (PqsTerminalLogs temp : list1) {
String node1 = strings.get(1); // 第一个前置 String temLos = "%s终端所属前置机由 %s 改为> %s;";
String node2 = strings.get(2); // 第二个前置 List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
if (deviceProcesseMap.containsKey(temp.getObjIndex())) { String node1 = strings.get(1); // 第一个前置
Integer processNum = deviceProcesseMap.get(temp.getObjIndex()); String node2 = strings.get(2); // 第二个前置
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO(); if (deviceProcesseMap.containsKey(temp.getObjIndex())) {
pqsTerminalPushLogDTO.setId(temp.getId()); Integer processNum = deviceProcesseMap.get(temp.getObjIndex());
String deviceId = temp.getObjIndex(); PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
pqsTerminalPushLogDTO.setNodeId(node1);
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(node1).getName());
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO.setProcessNum(processNum);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
PqsTerminalPushLogDTO pqsTerminalPushLogDTO2 = new PqsTerminalPushLogDTO();
pqsTerminalPushLogDTO2.setId(temp.getId());
pqsTerminalPushLogDTO2.setDevId(deviceId);
pqsTerminalPushLogDTO2.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
pqsTerminalPushLogDTO2.setNodeId(node2);
pqsTerminalPushLogDTO2.setNodeName(nodeMap.get(node2).getName());
pqsTerminalPushLogDTO2.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO2.setProcessNum(processNum);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO2);
}
}
}
list.removeAll(list1);
if (!CollectionUtils.isEmpty(list)) {
//终端层面和检测点层面修改
list.forEach(temp -> {
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
if (Objects.equals(temp.getTerminalType(), 6)) {
pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId;
//如果不存在该设备id,说明监测点删除
if (!lineDeviceMap.containsKey(temp.getObjIndex())) {
String temLos = "%s监测点名称: %s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String[] lineName = strings.get(1).split("->");
List<Line> devList = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[1])).collect(Collectors.toList());
if (CollectionUtils.isEmpty(devList)) {
//如果不存在该设备说明设备也被删除,直接走下边删除设备逻辑;
return;
} else {
Line sub = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[0])).collect(Collectors.toList()).get(0);
Line tempDev = devList.stream().filter(dev -> dev.getPid().equals(sub.getId())).collect(Collectors.toList()).get(0);
deviceId = tempDev.getId();
}
} else {
deviceId = lineDeviceMap.get(temp.getObjIndex());
}
pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
//如果前置删了直接返回
if (!nodeMap.containsKey(nodeId)) {
return;
}
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
if (deviceProcesseMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
} else {
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
}
pqsTerminalPushLogDTO.setOperateType(DeviceRebootType.LEDGER_MODIFY);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
} else if (Objects.equals(temp.getTerminalType(), 4)) {
//如果是修改进程操作记录2个进程日志;
if (temp.getLogsType().equals(dataDic.getId())) {
String temLos = "%s进行更新终端进程操作;终端名称 %s,由进程%s修改成进程%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String num1 = strings.get(2); // 第一个进程
String num2 = strings.get(3); // 第二个进程
int processId1 = Integer.parseInt(num1);
int processId2 = Integer.parseInt(num2);
pqsTerminalPushLogDTO.setId(temp.getId()); pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId = temp.getObjIndex(); String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId); pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备"); pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
pqsTerminalPushLogDTO.setNodeId(node1);
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(node1).getName());
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO.setProcessNum(processNum);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
PqsTerminalPushLogDTO pqsTerminalPushLogDTO2 = new PqsTerminalPushLogDTO();
pqsTerminalPushLogDTO2.setId(temp.getId());
pqsTerminalPushLogDTO2.setDevId(deviceId);
pqsTerminalPushLogDTO2.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
pqsTerminalPushLogDTO2.setNodeId(node2);
pqsTerminalPushLogDTO2.setNodeName(nodeMap.get(node2).getName());
pqsTerminalPushLogDTO2.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO2.setProcessNum(processNum);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO2);
}
}
}
list.removeAll(list1);
if (!CollectionUtils.isEmpty(list)) {
//终端层面和检测点层面修改
list.forEach(temp -> {
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = new PqsTerminalPushLogDTO();
if (Objects.equals(temp.getTerminalType(), 6)) {
pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId;
//如果不存在该设备id,说明监测点删除
if (!lineDeviceMap.containsKey(temp.getObjIndex())) {
String temLos = "%s监测点名称: %s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String[] lineName = strings.get(1).split("->");
List<Line> devList = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[1])).collect(Collectors.toList());
if (CollectionUtils.isEmpty(devList)) {
//如果不存在该设备说明设备也被删除,直接走下边删除设备逻辑;
return;
} else {
Line sub = lineById.stream().filter(line -> Objects.equals(line.getName(), lineName[0])).collect(Collectors.toList()).get(0);
Line tempDev = devList.stream().filter(dev -> dev.getPid().equals(sub.getId())).collect(Collectors.toList()).get(0);
deviceId = tempDev.getId();
}
} else {
deviceId = lineDeviceMap.get(temp.getObjIndex());
}
pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
String nodeId = deviceMap.get(deviceId).getNodeId(); String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId); pqsTerminalPushLogDTO.setNodeId(nodeId);
//如果前置删了直接返回
if (!nodeMap.containsKey(nodeId)) {
return;
}
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName()); pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO.setProcessNum(processId1);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
PqsTerminalPushLogDTO pqsTerminalPushLogDTO1 = new PqsTerminalPushLogDTO();
pqsTerminalPushLogDTO1.setId(temp.getId());
pqsTerminalPushLogDTO1.setDevId(deviceId);
pqsTerminalPushLogDTO1.setDevName(lineMap.get(deviceId).getName());
pqsTerminalPushLogDTO1.setNodeId(nodeId);
pqsTerminalPushLogDTO1.setNodeName(nodeMap.get(nodeId).getName());
pqsTerminalPushLogDTO1.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO1.setProcessNum(processId2);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO1);
} else {
pqsTerminalPushLogDTO.setId(temp.getId());
String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId);
//区分删除操作,新增和其他操作
String operate = DeviceRebootType.LEDGER_MODIFY;
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
operate = DeviceRebootType.DELETE_TERMINAL;
} else if (Objects.equals(temp.getOperateType(), Param.ADD)) {
operate = DeviceRebootType.ADD_TERMINAL;
}
//设备删除找不到设备名称,重日志截取
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
String temLos = "%s名称:%s;前置信息:%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String devName = strings.get(1); // 设备名称
String nodeName = strings.get(2); // 进程名称
pqsTerminalPushLogDTO.setDevName(devName);
String nodeId = nodeNameMap.get(nodeName).getId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeName);
} else {
//如果存在说明设备未被删除不存在说明有一条删除日志直接return
if (lineMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
} else {
pqsTerminalPushLogDTO.setDevName("删除设备");
}
//如果新增的没有,说明该新增设备在本次也删除了,
if (deviceMap.containsKey(deviceId)) {
String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
} else {
addAndDelteId.add(deviceId);
return;
}
}
pqsTerminalPushLogDTO.setProcessUpdateFlag(false); pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
if (deviceProcesseMap.containsKey(deviceId)) { if (deviceProcesseMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId)); pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
} else { } else {
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作"); throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
} }
pqsTerminalPushLogDTO.setOperateType(DeviceRebootType.LEDGER_MODIFY);
pqsTerminalPushLogDTO.setOperateType(operate);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO); pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
} else if (Objects.equals(temp.getTerminalType(), 4)) {
String deviceId = temp.getObjIndex();
if(!deviceMap.containsKey(deviceId)){
//说明设备被删除
String temLos = "%s名称:%s;前置信息:%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String devName = strings.get(1); // 设备名称
String nodeName = strings.get(2); // 进程名称
pqsTerminalPushLogDTO.setDevName(devName);
//如果前置删了直接返回
if(!nodeNameMap.containsKey(nodeName)){
return;
}
String nodeId = nodeNameMap.get(nodeName).getId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeName);
}
//如果是修改进程操作记录2个进程日志;
if (temp.getLogsType().equals(dataDic.getId())) {
String temLos = "%s进行更新终端进程操作;终端名称 %s,由进程%s修改成进程%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String num1 = strings.get(2); // 第一个进程
String num2 = strings.get(3); // 第二个进程
int processId1 = Integer.parseInt(num1);
int processId2 = Integer.parseInt(num2);
pqsTerminalPushLogDTO.setId(temp.getId());
// String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId);
pqsTerminalPushLogDTO.setDevName(lineMap.containsKey(deviceId) ? lineMap.get(deviceId).getName() : "删除设备");
String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeMap.get(nodeId).getName());
pqsTerminalPushLogDTO.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO.setProcessNum(processId1);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
PqsTerminalPushLogDTO pqsTerminalPushLogDTO1 = new PqsTerminalPushLogDTO();
pqsTerminalPushLogDTO1.setId(temp.getId());
pqsTerminalPushLogDTO1.setDevId(deviceId);
pqsTerminalPushLogDTO1.setDevName(lineMap.get(deviceId).getName());
pqsTerminalPushLogDTO1.setNodeId(nodeId);
pqsTerminalPushLogDTO1.setNodeName(nodeMap.get(nodeId).getName());
pqsTerminalPushLogDTO1.setProcessUpdateFlag(true);
pqsTerminalPushLogDTO1.setProcessNum(processId2);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO1);
} else {
pqsTerminalPushLogDTO.setId(temp.getId());
// String deviceId = temp.getObjIndex();
pqsTerminalPushLogDTO.setDevId(deviceId);
//区分删除操作,新增和其他操作
String operate = DeviceRebootType.LEDGER_MODIFY;
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
operate = DeviceRebootType.DELETE_TERMINAL;
} else if (Objects.equals(temp.getOperateType(), Param.ADD)) {
operate = DeviceRebootType.ADD_TERMINAL;
}
//设备删除找不到设备名称,重日志截取
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
String temLos = "%s名称:%s;前置信息:%s";
List<String> strings = this.parseTemplateValues(temLos, temp.getTerminalDescribe());
String devName = strings.get(1); // 设备名称
String nodeName = strings.get(2); // 进程名称
pqsTerminalPushLogDTO.setDevName(devName);
String nodeId = nodeNameMap.get(nodeName).getId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeName);
} else {
//如果存在说明设备未被删除不存在说明有一条删除日志直接return
if (lineMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
} else {
pqsTerminalPushLogDTO.setDevName("删除设备");
}
//如果新增的没有,说明该新增设备在本次也删除了,
if (deviceMap.containsKey(deviceId)) {
String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeMap.containsKey(nodeId)?nodeMap.get(nodeId).getName():"删除前置");
} else {
addAndDelteId.add(deviceId);
return;
}
}
pqsTerminalPushLogDTO.setProcessUpdateFlag(false);
if (deviceProcesseMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setProcessNum(deviceProcesseMap.get(deviceId));
} else {
throw new BusinessException("存在终端未设置进程号,请在前置管理页面设置进程号在进行此操作");
}
pqsTerminalPushLogDTO.setOperateType(operate);
pqsTerminalPushLogDTOList.add(pqsTerminalPushLogDTO);
}
} }
});
} }
});
}
Map<String, Map<Integer, List<PqsTerminalPushLogDTO>>> collect2 = pqsTerminalPushLogDTOList.stream().filter(temp -> !addAndDelteId.contains(temp.getDevId())).collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getNodeId, Collectors.groupingBy(PqsTerminalPushLogDTO::getProcessNum))); Map<String, Map<Integer, List<PqsTerminalPushLogDTO>>> collect2 = pqsTerminalPushLogDTOList.stream().filter(temp -> !addAndDelteId.contains(temp.getDevId())).collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getNodeId, Collectors.groupingBy(PqsTerminalPushLogDTO::getProcessNum)));
collect2.forEach((nodeId, pqsTerminalPushLogDTOMap) -> { collect2.forEach((nodeId, pqsTerminalPushLogDTOMap) -> {
pqsTerminalPushLogDTOMap.forEach((processId, tempPqsTerminalPushLogDTOList) -> { pqsTerminalPushLogDTOMap.forEach((processId, tempPqsTerminalPushLogDTOList) -> {
PqsTerminalPushLogDTO pqsTerminalPushLogDTO = tempPqsTerminalPushLogDTOList.get(0); PqsTerminalPushLogDTO pqsTerminalPushLogDTO = tempPqsTerminalPushLogDTOList.get(0);
//如果存在终端变更进程的记录直接重启进程 //如果存在终端变更进程的记录直接重启进程
boolean processUpdateFlag = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getProcessUpdateFlag).anyMatch(b -> b != null && b); boolean processUpdateFlag = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getProcessUpdateFlag).anyMatch(b -> b != null && b);
if (processUpdateFlag) { if (processUpdateFlag) {
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启进程接口
this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
preCommandDTOList.add(preCommandDTO);
} else {
List<String> deviceIds = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
//如果一个进程上涉及10个以上的设备修改直接重启进程否则重启设备
if (CollectionUtil.isNotEmpty(deviceIds) && deviceIds.size() > 10) {
PreCommandDTO preCommandDTO = new PreCommandDTO(); PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID(); String guid = IdUtil.simpleUUID();
String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId; String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
preCommandDTO.setGuid(guid); preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command); preCommandDTO.setCommand(command);
preCommandDTO.setResult("2"); preCommandDTO.setResult("2");
//调用重启进程接口 //调用重启进程接口
this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all"); this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
preCommandDTOList.add(preCommandDTO); preCommandDTOList.add(preCommandDTO);
} else { } else {
//调用重启设备接口先删除设备,在新增,在修改在重启设备 List<String> deviceIds = tempPqsTerminalPushLogDTOList.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
List<String> deleteDevIds = new ArrayList<>(); //如果一个进程上涉及10个以上的设备修改直接重启进程否则重启设备
List<String> addDevIds = new ArrayList<>(); if (CollectionUtil.isNotEmpty(deviceIds) && deviceIds.size() > 10) {
List<String> modifyDevIds = new ArrayList<>(); PreCommandDTO preCommandDTO = new PreCommandDTO();
Map<String, List<PqsTerminalPushLogDTO>> collect = tempPqsTerminalPushLogDTOList.stream().collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getOperateType)); String guid = IdUtil.simpleUUID();
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) { String command = "重启前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId;
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL); preCommandDTO.setGuid(guid);
deleteDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList()); preCommandDTO.setCommand(command);
} preCommandDTO.setResult("2");
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
addDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
}
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
modifyDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
}
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
List<String> finalAddDevIds = addDevIds;
//过滤本次新增的设备,因为前置那边还没有新增该装备
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalAddDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "删除前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString; //调用重启进程接口
preCommandDTO.setGuid(guid); this.askRestartProcess(guid, pqsTerminalPushLogDTO.getNodeId(), processId, "delete", "all");
preCommandDTO.setCommand(command); preCommandDTOList.add(preCommandDTO);
preCommandDTO.setResult("2");
} else {
//调用重启设备接口先删除设备,在新增,在修改在重启设备
List<String> deleteDevIds = new ArrayList<>();
List<String> addDevIds = new ArrayList<>();
List<String> modifyDevIds = new ArrayList<>();
Map<String, List<PqsTerminalPushLogDTO>> collect = tempPqsTerminalPushLogDTOList.stream().collect(Collectors.groupingBy(PqsTerminalPushLogDTO::getOperateType));
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
deleteDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
}
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
addDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
}
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
modifyDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
}
if (collect.containsKey(DeviceRebootType.DELETE_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.DELETE_TERMINAL);
List<String> finalAddDevIds = addDevIds;
//过滤本次新增的设备,因为前置那边还没有新增该装备
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalAddDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "删除前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启设备接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.DELETE_TERMINAL, processId);
preCommandDTOList.add(preCommandDTO);
}
}
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
List<String> finalDeleteDevIds = deleteDevIds;
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "新增前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启进程接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.ADD_TERMINAL, processId);
preCommandDTOList.add(preCommandDTO);
}
}
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
List<String> finalDeleteDevIds1 = deleteDevIds;
List<String> finalAddDevIds1 = addDevIds;
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds1.contains(temp.getDevId()) && !finalAddDevIds1.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "修改前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启进程接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.LEDGER_MODIFY, processId);
preCommandDTOList.add(preCommandDTO);
}
//调用重启设备接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.DELETE_TERMINAL, processId);
preCommandDTOList.add(preCommandDTO);
} }
} }
if (collect.containsKey(DeviceRebootType.ADD_TERMINAL)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.ADD_TERMINAL);
List<String> finalDeleteDevIds = deleteDevIds;
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "新增前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启进程接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.ADD_TERMINAL, processId);
preCommandDTOList.add(preCommandDTO);
}
}
if (collect.containsKey(DeviceRebootType.LEDGER_MODIFY)) {
List<PqsTerminalPushLogDTO> pqsTerminalPushLogDTOList1 = collect.get(DeviceRebootType.LEDGER_MODIFY);
List<String> finalDeleteDevIds1 = deleteDevIds;
List<String> finalAddDevIds1 = addDevIds;
pqsTerminalPushLogDTOList1 = pqsTerminalPushLogDTOList1.stream().filter(temp -> !finalDeleteDevIds1.contains(temp.getDevId()) && !finalAddDevIds1.contains(temp.getDevId())).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pqsTerminalPushLogDTOList1)) {
String devNameString = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevName).distinct().collect(Collectors.joining(","));
List<String> resultDevIds = pqsTerminalPushLogDTOList1.stream().map(PqsTerminalPushLogDTO::getDevId).distinct().collect(Collectors.toList());
PreCommandDTO preCommandDTO = new PreCommandDTO();
String guid = IdUtil.simpleUUID();
String command = "修改前置机:" + pqsTerminalPushLogDTO.getNodeName() + "下进程:" + processId + "下终端" + devNameString;
preCommandDTO.setGuid(guid);
preCommandDTO.setCommand(command);
preCommandDTO.setResult("2");
//调用重启进程接口
this.askRestartDevice(guid, pqsTerminalPushLogDTO.getNodeId(), resultDevIds, DeviceRebootType.LEDGER_MODIFY, processId);
preCommandDTOList.add(preCommandDTO);
}
}
} }
}
});
}); });
}); } catch (Exception e) {
//出现异常,直接重启整个前置
exFlag=true;
for (Node node : nodes) {
RestartParam restartParam = new RestartParam();
restartParam.setDeviceRebootType("1");
restartParam.setNodeId(node.getId());
askRestartProcess(restartParam);
}
}
if (!CollectionUtils.isEmpty(list1)) { if (!CollectionUtils.isEmpty(list1)) {
list1.forEach(temp -> { list1.forEach(temp -> {
temp.setIsPush(1); temp.setIsPush(1);
@@ -4016,6 +4051,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
} else { } else {
throw new BusinessException("暂无变动的装置测点推送"); throw new BusinessException("暂无变动的装置测点推送");
} }
if(exFlag){
throw new BusinessException("存在未知错误,重启前置");
}
if (CollectionUtils.isEmpty(preCommandDTOList)) { if (CollectionUtils.isEmpty(preCommandDTOList)) {
throw new BusinessException("暂无变动的装置测点推送"); throw new BusinessException("暂无变动的装置测点推送");
} }
@@ -4166,7 +4205,21 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
subName = subMap.get(line.getPids().split(StrUtil.COMMA)[SUB_LEVEL.getCode()]).getName(); subName = subMap.get(line.getPids().split(StrUtil.COMMA)[SUB_LEVEL.getCode()]).getName();
String temLos = "%s进行%s%s操作;详细信息: %s名称: %s"; String temLos = "%s进行%s%s操作;详细信息: %s名称: %s";
if (line.getLevel().equals(LINE_LEVEL.getCode())) { if (line.getLevel().equals(LINE_LEVEL.getCode())) {
String devName = this.getById(line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()]).getName(); String devId=line.getPids().split(StrUtil.COMMA)[DEVICE_LEVEL.getCode()];
Line byId = this.getById(devId);
String devName="";
//设备已删除
if(Objects.nonNull(byId)){
devName= byId.getName();
}else{
List<Line> device = logsList.stream().filter(temp -> Objects.equals(temp.getId(), devId)).collect(Collectors.toList());
if(!CollectionUtils.isEmpty(device)){
devName =device.get(0).getName();
}else {
devName = "已删除设备";
}
}
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + devName + "->" + line.getName() + nodeName); tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + devName + "->" + line.getName() + nodeName);
} else { } else {
tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + line.getName() + nodeName); tem = String.format(temLos, name, op, levelOperate, levelOperate, subName + "->" + line.getName() + nodeName);

View File

@@ -26,7 +26,7 @@ import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.line.service.DeptLineService; import com.njcn.device.line.service.DeptLineService;
import com.njcn.device.line.service.LineService; import com.njcn.device.line.service.LineService;
import com.njcn.device.line.mapper.LineDetailMapper; import com.njcn.device.line.mapper.LineDetailMapper;
import com.njcn.device.overlimit.mapper.OverlimitMapper; import com.njcn.device.biz.mapper.OverlimitMapper;
import com.njcn.device.pq.enums.LineBaseEnum; import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.enums.PowerFlagEnum; import com.njcn.device.pq.enums.PowerFlagEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO; import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;

View File

@@ -10,7 +10,7 @@ import com.njcn.common.utils.EnumUtils;
import com.njcn.device.biz.enums.DeviceResponseEnum; import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.biz.pojo.po.Overlimit; import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.common.service.GeneralDeviceService; import com.njcn.device.common.service.GeneralDeviceService;
import com.njcn.device.overlimit.mapper.OverlimitMapper; import com.njcn.device.biz.mapper.OverlimitMapper;
import com.njcn.device.overlimit.service.IOverLimitService; import com.njcn.device.overlimit.service.IOverLimitService;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO; import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam; import com.njcn.device.pq.pojo.param.DeviceInfoParam;

View File

@@ -94,6 +94,11 @@
<artifactId>advance-api</artifactId> <artifactId>advance-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>event-common</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>

View File

@@ -16,7 +16,7 @@ import com.njcn.event.pojo.param.EventCountParam;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.GeneralVO; import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;

View File

@@ -7,7 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.event.pojo.param.EventMonitorReportParam; import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService; import com.njcn.event.common.service.EventMonitorReportService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -51,7 +51,7 @@ public class EventMonitorReportController extends BaseController {
} }
/*** /***
* *
* @author jianghaifei * @author jianghaifei
* @date 2022-10-29 14:08 * @date 2022-10-29 14:08
* @param eventMonitorReportParam * @param eventMonitorReportParam
@@ -67,7 +67,7 @@ public class EventMonitorReportController extends BaseController {
} }
/*** /***
* *
* @author jianghaifei * @author jianghaifei
* @date 2022-10-29 14:08 * @date 2022-10-29 14:08
* @param eventMonitorReportParam * @param eventMonitorReportParam

View File

@@ -2,15 +2,13 @@ package com.njcn.event.controller.majornetwork;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService; import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -18,7 +16,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;

View File

@@ -1,18 +1,29 @@
package com.njcn.event.controller.majornetwork; package com.njcn.event.controller.majornetwork;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.param.DeviceInfoParam; import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.param.*;
import com.njcn.event.pojo.vo.DetailVO; import com.njcn.event.pojo.vo.DetailVO;
import com.njcn.event.pojo.vo.GeneralVO; import com.njcn.event.pojo.vo.GeneralVO;
import com.njcn.event.pojo.vo.ReasonsVO; import com.njcn.event.pojo.vo.ReasonsVO;
import com.njcn.event.pojo.vo.WaveTypeVO; import com.njcn.event.pojo.vo.WaveTypeVO;
import com.njcn.event.service.majornetwork.ReportService; import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import freemarker.template.TemplateException; import freemarker.template.TemplateException;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@@ -27,6 +38,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@@ -44,6 +56,14 @@ public class ReportController extends BaseController {
private final ReportService reportService; private final ReportService reportService;
private final CommMonitorEventReportService commMonitorEventReportService;
private final LineFeignClient lineFeignClient;
private final MonitorClient monitorClient;
private final DicDataFeignClient dicDataFeignClient;
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getGeneralSituation") @PostMapping("/getGeneralSituation")
@ApiOperation("暂态总体概况(区域)") @ApiOperation("暂态总体概况(区域)")
@@ -149,7 +169,31 @@ public class ReportController extends BaseController {
@ApiOperation("监测点报告导出") @ApiOperation("监测点报告导出")
@ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true) @ApiImplicitParam(name = "exportParam", value = "监测点报告导出参数", required = true)
public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException { public void getLineExport(@RequestBody @Validated ExportParam exportParam, HttpServletResponse response) throws IOException, InvalidFormatException, TemplateException, ParseException {
reportService.getLineExport(exportParam, response);
LineDetailDataCommDTO lineDetailDataCommDTO = new LineDetailDataCommDTO();
if(exportParam.getType() == 0) {
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(exportParam.getLineId()).getData();
if (ObjectUtil.isNull(lineDetailData)) {
throw new BusinessException(CommonResponseEnum.FAIL, "查询监测点失败");
}
BeanUtil.copyProperties(lineDetailData,lineDetailDataCommDTO);
}else {
HttpResult<List<Monitor>> monitorList = monitorClient.getMonitorList(Arrays.asList(exportParam.getLineId()));
if (ObjectUtil.isNull(monitorList)) {
throw new BusinessException(EventResponseEnum.NOT_FOUND);
}
lineDetailDataCommDTO.setLineName(monitorList.getData().get(0).getName());
lineDetailDataCommDTO.setScale(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getVoltageLevel()).getData().getName());
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getPt1() + "/" + monitorList.getData().get(0).getPt2());
lineDetailDataCommDTO.setPt(monitorList.getData().get(0).getCt1() + "/" + monitorList.getData().get(0).getCt2());
lineDetailDataCommDTO.setDealCapacity(monitorList.getData().get(0).getUserAgreementCapacity());
// insertRow(doc, table, centerParagraph, false, "基准容量", monitorList.getData().get(0).getMinShortCircuitCapacity() + "");
lineDetailDataCommDTO.setDevCapacity(monitorList.getData().get(0).getPowerSupplyEqCapacity());
lineDetailDataCommDTO.setShortCapacity(monitorList.getData().get(0).getMinShortCircuitCapacity());
lineDetailDataCommDTO.setPtType(dicDataFeignClient.getDicDataById(monitorList.getData().get(0).getTerminalWiringMethod()).getData().getName());
}
commMonitorEventReportService.getLineExport(exportParam, lineDetailDataCommDTO,response);
} }
/** /**

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper"> <mapper namespace="com.njcn.event.common.mapper.EventDistributionStatisticsMapper">
<!--获取暂态指标分布统计--> <!--获取暂态指标分布统计-->
<select id="getEventDistributionStatistics" <select id="getEventDistributionStatistics"
@@ -469,4 +469,4 @@
) )
r r
</select> </select>
</mapper> </mapper>

View File

@@ -1,78 +1,78 @@
package com.njcn.event.service.majornetwork; //package com.njcn.event.service.majornetwork;
//
import com.njcn.event.pojo.param.StatisticsParam; //import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail; //import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*; //import com.njcn.event.pojo.vo.*;
import com.njcn.system.pojo.po.DictData; //import com.njcn.system.pojo.po.DictData;
//
import java.text.ParseException; //import java.text.ParseException;
import java.util.List; //import java.util.List;
//
/** ///**
* <监测点报表> // * <监测点报表>
* // *
* @author wr // * @author wr
* @createTime: 2023-02-10 // * @createTime: 2023-02-10
*/ // */
public interface EventReportService { //public interface EventReportService {
//
/** // /**
*获取Disdip表格监测点报表专用 // *获取Disdip表格监测点报表专用
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<DISDIPVO> eventDisdip(List<EventDetail> info); // List<DISDIPVO> eventDisdip(List<EventDetail> info);
//
/** // /**
* 获取IEC411数据 // * 获取IEC411数据
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<IEC411VO> IEC411(List<EventDetail> info); // List<IEC411VO> IEC411(List<EventDetail> info);
//
/** // /**
* 获取IEC28数据 // * 获取IEC28数据
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<IEC28VO> IEC28(List<EventDetail> info); // List<IEC28VO> IEC28(List<EventDetail> info);
//
/** // /**
*暂降幅值概率分布 // *暂降幅值概率分布
* @param info2 influxdb查询结果pqs_eventdetail表 // * @param info2 influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2); // ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
//
/** // /**
* 获取时间列表(月份统计) // * 获取时间列表(月份统计)
* @param info influxdb查询结果pqs_eventdetail表 // * @param info influxdb查询结果pqs_eventdetail表
* @return // * @return
*/ // */
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException; // List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
//
/** // /**
* 获取点状表格数据2.1 // * 获取点状表格数据2.1
* @param info 结果集 // * @param info 结果集
* @param reasonData 暂降原因 // * @param reasonData 暂降原因
* @param typeData 暂降类型 // * @param typeData 暂降类型
* @return // * @return
*/ // */
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData); // List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
//
/** // /**
* 获取详细数据对象 // * 获取详细数据对象
* @param info // * @param info
* @param reasonData // * @param reasonData
* @param typeData // * @param typeData
* @return // * @return
*/ // */
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData); // StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
//
/** // /**
* 获取密度点图 // * 获取密度点图
* @param info // * @param info
* @return // * @return
*/ // */
Integer[][] getCoords(List<EventDetail> info); // Integer[][] getCoords(List<EventDetail> info);
} //}

View File

@@ -20,12 +20,11 @@ import com.njcn.event.pojo.vo.AreaAnalysisVO;
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO; import com.njcn.event.pojo.vo.VoltageToleranceCurveVO;
import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList; import com.njcn.event.pojo.vo.VoltageToleranceCurveVO.VoltageToleranceCurveDataList;
import com.njcn.event.service.majornetwork.AreaAnalysisService; import com.njcn.event.service.majornetwork.AreaAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -34,8 +33,6 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* pqs-event * pqs-event
* *
@@ -54,9 +51,11 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
private final EventDetailService eventDetailService; private final EventDetailService eventDetailService;
@Override @Override
public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) { public AreaAnalysisVO getEventReason(DeviceInfoParam.BusinessParam deviceInfoParam) {
//根据单体系统这里只要不为录波的都统计
//获取暂降字典信息 //获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData(); DictData recordingWaveData = dicDataFeignClient.getDicDataByCode(DicDataEnum.RECORDING_WAVE.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){
if(ObjectUtil.isNull(recordingWaveData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY); throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
} }
AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO(); AreaAnalysisVO areaAnalysisVO = new AreaAnalysisVO();
@@ -71,7 +70,7 @@ public class AreaAnalysisServiceImpl implements AreaAnalysisService {
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>() List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("advance_reason,advance_type,count(event_id) as count") .select("advance_reason,advance_type,count(event_id) as count")
.in("measurement_point_id", lineIds) .in("measurement_point_id", lineIds)
.eq("event_type", voltageData.getId()) .ne("event_type", recordingWaveData.getId())
.in("advance_reason", dicReasonList.stream().map(DictData::getId).collect(Collectors.toList())) .in("advance_reason", dicReasonList.stream().map(DictData::getId).collect(Collectors.toList()))
.in("advance_type", dicTypeList.stream().map(DictData::getId).collect(Collectors.toList())) .in("advance_type", dicTypeList.stream().map(DictData::getId).collect(Collectors.toList()))
.ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))) .ge(StrUtil.isNotBlank(deviceInfoParam.getSearchBeginTime()),"start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))

View File

@@ -14,7 +14,7 @@ import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.AreaSubLineVO; import com.njcn.event.pojo.vo.AreaSubLineVO;
import com.njcn.event.service.majornetwork.AreaInfoService; import com.njcn.event.service.majornetwork.AreaInfoService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.harmonic.api.PollutionSubstationClient; import com.njcn.harmonic.api.PollutionSubstationClient;
import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution; import com.njcn.harmonic.pojo.excel.pollution.UserLinePollution;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

View File

@@ -24,7 +24,7 @@ import com.njcn.event.pojo.vo.*;
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO; import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningInfoVO;
import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO; import com.njcn.event.pojo.vo.TerminalRunningStatisticsVO.TerminalRunningVO;
import com.njcn.event.service.majornetwork.AreaLineService; import com.njcn.event.service.majornetwork.AreaLineService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.LargeScreenService; import com.njcn.event.service.majornetwork.LargeScreenService;
import com.njcn.harmonic.pojo.dto.ComAssessDTO; import com.njcn.harmonic.pojo.dto.ComAssessDTO;
import com.njcn.harmonic.pojo.po.PQSComAssesPO; import com.njcn.harmonic.pojo.po.PQSComAssesPO;
@@ -47,6 +47,7 @@ import java.util.*;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.njcn.event.influxdb.QueryBuilder.beginOfDay; import static com.njcn.event.influxdb.QueryBuilder.beginOfDay;
import static com.njcn.event.influxdb.QueryBuilder.endOfDay; import static com.njcn.event.influxdb.QueryBuilder.endOfDay;
@@ -122,9 +123,12 @@ public class AreaLineServiceImpl implements AreaLineService {
@Override @Override
public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) { public EventHeatMapVO getEventHeatMap(DeviceInfoParam.BusinessParam deviceInfoParam) {
//新增需求添加中断
//获取暂降字典信息 //获取暂降字典信息
DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData(); DictData voltageData = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
if(ObjectUtil.isNull(voltageData)){ DictData shortInterruptionsData = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
if(ObjectUtil.isNull(voltageData)||ObjectUtil.isNull(shortInterruptionsData)){
throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY); throw new BusinessException(DeviceResponseEnum.DIC_GET_EMPTY);
} }
EventHeatMapVO eventHeatMapVO = new EventHeatMapVO(); EventHeatMapVO eventHeatMapVO = new EventHeatMapVO();
@@ -146,7 +150,7 @@ public class AreaLineServiceImpl implements AreaLineService {
List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>() List<RmpEventDetailPO> info = eventDetailService.list(new QueryWrapper<RmpEventDetailPO>()
.select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag") .select("measurement_point_id as measurementPointId,count(file_flag) as fileFlag")
.in("measurement_point_id", lineIndexs) .in("measurement_point_id", lineIndexs)
.eq("event_type", voltageData.getId()) .in("event_type", Stream.of(voltageData.getId(),shortInterruptionsData.getId()).collect(Collectors.toList()))
.ge("start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime()))) .ge("start_time" ,DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
.le("start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime()))) .le("start_time", DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
.groupBy("measurement_point_id") .groupBy("measurement_point_id")

View File

@@ -22,7 +22,7 @@ import com.njcn.event.pojo.vo.AreaStatisticalVO.VoltageStatisticsVO;
import com.njcn.event.pojo.vo.MonthCalculationVO; import com.njcn.event.pojo.vo.MonthCalculationVO;
import com.njcn.event.pojo.vo.VoltageLevelCalculationVO; import com.njcn.event.pojo.vo.VoltageLevelCalculationVO;
import com.njcn.event.service.majornetwork.AreaStatisticalService; import com.njcn.event.service.majornetwork.AreaStatisticalService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.pojo.vo.NodeVO; import com.njcn.event.pojo.vo.NodeVO;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;

View File

@@ -8,7 +8,7 @@ import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient; import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient;
import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO; import com.njcn.device.pms.pojo.dto.PmsGeneralDeviceDTO;
import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam; import com.njcn.device.pms.pojo.param.PmsDeviceInfoParam;
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper; import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
import com.njcn.event.pojo.po.EventDistributionStatisticsPO; import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
import com.njcn.event.pojo.po.EventDurationLineChartPO; import com.njcn.event.pojo.po.EventDurationLineChartPO;
import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO; import com.njcn.event.pojo.po.EventFeatureAmplitudeLineChartPO;
@@ -21,8 +21,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;

View File

@@ -35,6 +35,7 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.echarts.pojo.constant.PicCommonData; import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil; import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.EventDetailMapper; import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.mapper.majornetwork.ReportMapper; import com.njcn.event.mapper.majornetwork.ReportMapper;
@@ -44,11 +45,10 @@ import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.Eventass; import com.njcn.event.pojo.po.Eventass;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService; import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.event.service.majornetwork.ReportService; import com.njcn.event.service.majornetwork.ReportService;
import com.njcn.event.utils.WordUtils; import com.njcn.event.common.utils.WordUtils;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.util.PoiUtil; import com.njcn.poi.util.PoiUtil;
@@ -89,10 +89,8 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.jetbrains.annotations.NotNull;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.core.io.InputStreamResource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import sun.misc.BASE64Decoder; import sun.misc.BASE64Decoder;
@@ -4271,11 +4269,11 @@ public class ReportServiceImpl implements ReportService {
List<OB> obs = new ArrayList<>(); List<OB> obs = new ArrayList<>();
ArrayList<List<Double>> list = new ArrayList<>(); ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetailNew eventDetail : detailList) { for (EventDetailNew eventDetail : detailList) {
obs.add(new OB(Double.parseDouble(eventDetail.getDuration() / 1000 + "") obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + "")
, Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + ""))); , Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));
ArrayList<Double> doubles = new ArrayList<>(); ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + "")); doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100))); doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles); list.add(doubles);
} }
@@ -4332,10 +4330,10 @@ public class ReportServiceImpl implements ReportService {
ArrayList<List<Double>> list = new ArrayList<>(); ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetailNew eventDetail : detailList) { for (EventDetailNew eventDetail : detailList) {
obs.add(new OB(Double.parseDouble(eventDetail.getDuration() / 1000 + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + ""))); obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));
ArrayList<Double> doubles = new ArrayList<>(); ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + "")); doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100))); doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles); list.add(doubles);
} }
@@ -7203,11 +7201,11 @@ public class ReportServiceImpl implements ReportService {
List<OB> obs = new ArrayList<>(); List<OB> obs = new ArrayList<>();
ArrayList<List<Double>> list = new ArrayList<>(); ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetailNew eventDetail : detailList) { for (EventDetailNew eventDetail : detailList) {
obs.add(new OB(Double.parseDouble(eventDetail.getDuration() / 1000 + "") obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + "")
, Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + ""))); , Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));
ArrayList<Double> doubles = new ArrayList<>(); ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + "")); doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100))); doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles); list.add(doubles);
} }
@@ -7264,10 +7262,10 @@ public class ReportServiceImpl implements ReportService {
ArrayList<List<Double>> list = new ArrayList<>(); ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetailNew eventDetail : detailList) { for (EventDetailNew eventDetail : detailList) {
obs.add(new OB(Double.parseDouble(eventDetail.getDuration() / 1000 + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + ""))); obs.add(new OB(Double.parseDouble(eventDetail.getDuration() + ""), Double.parseDouble(eventDetail.getFeatureAmplitude() * 100 + "")));
ArrayList<Double> doubles = new ArrayList<>(); ArrayList<Double> doubles = new ArrayList<>();
doubles.add(Double.parseDouble(eventDetail.getDuration() / 1000 + "")); doubles.add(Double.parseDouble(eventDetail.getDuration() + ""));
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100))); doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles); list.add(doubles);
} }
@@ -7991,7 +7989,7 @@ public class ReportServiceImpl implements ReportService {
} }
for (int i = 0; i < areaTableParam.getInfo().size(); i++) { for (int i = 0; i < areaTableParam.getInfo().size(); i++) {
Double eventvalue = areaTableParam.getInfo().get(i).getFeatureAmplitude(); Double eventvalue = areaTableParam.getInfo().get(i).getFeatureAmplitude();
double persisttime = areaTableParam.getInfo().get(i).getDuration(); double persisttime = areaTableParam.getInfo().get(i).getDuration()*1000;
if (eventvalue * 100 < 1 && eventvalue * 100 >= 0) { if (eventvalue * 100 < 1 && eventvalue * 100 >= 0) {
if (persisttime > 10 && persisttime <= 100) { if (persisttime > 10 && persisttime <= 100) {
arr[16][0]++; arr[16][0]++;
@@ -8719,28 +8717,28 @@ public class ReportServiceImpl implements ReportService {
List<String> sisttime = new ArrayList<>(); List<String> sisttime = new ArrayList<>();
for (EventDetailNew eventDetail : info) { for (EventDetailNew eventDetail : info) {
Double persistTime = eventDetail.getDuration(); Double persistTime = eventDetail.getDuration();
if (persistTime / 1000 < 0.1) { if (persistTime < 0.1) {
timeMap2.put("<0.1", timeMap2.get("<0.1") + 1); timeMap2.put("<0.1", timeMap2.get("<0.1") + 1);
} }
if (persistTime / 1000 < 0.25) { if (persistTime < 0.25) {
timeMap2.put("<0.25", timeMap2.get("<0.25") + 1); timeMap2.put("<0.25", timeMap2.get("<0.25") + 1);
} }
if (persistTime / 1000 < 0.5) { if (persistTime < 0.5) {
timeMap2.put("<0.5", timeMap2.get("<0.5") + 1); timeMap2.put("<0.5", timeMap2.get("<0.5") + 1);
} }
if (persistTime / 1000 < 1) { if (persistTime < 1) {
timeMap2.put("<1", timeMap2.get("<1") + 1); timeMap2.put("<1", timeMap2.get("<1") + 1);
} }
if (persistTime / 1000 < 3) { if (persistTime < 3) {
timeMap2.put("<3", timeMap2.get("<3") + 1); timeMap2.put("<3", timeMap2.get("<3") + 1);
} }
if (persistTime / 1000 < 20) { if (persistTime < 20) {
timeMap2.put("<20", timeMap2.get("<20") + 1); timeMap2.put("<20", timeMap2.get("<20") + 1);
} }
if (persistTime / 1000 < 60) { if (persistTime < 60) {
timeMap2.put("<60", timeMap2.get("<60") + 1); timeMap2.put("<60", timeMap2.get("<60") + 1);
} }
if (persistTime / 1000 < 180) { if (persistTime < 180) {
timeMap2.put("<180", timeMap2.get("<180") + 1); timeMap2.put("<180", timeMap2.get("<180") + 1);
} }
} }
@@ -8807,7 +8805,7 @@ public class ReportServiceImpl implements ReportService {
for (int i = 0; i < xbardata.size(); i++) { for (int i = 0; i < xbardata.size(); i++) {
OB ob = xbardata.get(i); OB ob = xbardata.get(i);
//是否超过上限 //是否超过上限
if (ob.getA() <= 0.03) { if (ob.getA() <= 0.003) {
int line = 230 - 30000 * (int) ob.getA(); int line = 230 - 30000 * (int) ob.getA();
if (ob.getB() > line) { if (ob.getB() > line) {
pointno[i][0] = ob.getA(); pointno[i][0] = ob.getA();

View File

@@ -36,7 +36,7 @@ import com.njcn.device.pq.pojo.vo.GridDiagramVO;
import com.njcn.device.pq.pojo.vo.LineDetailVO; import com.njcn.device.pq.pojo.vo.LineDetailVO;
import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper; import com.njcn.event.mapper.majornetwork.RMpEventDetailMMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.dto.EventCount; import com.njcn.event.pojo.dto.EventCount;
import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.EventBaseParam;
import com.njcn.event.pojo.param.UniversalFrontEndParam; import com.njcn.event.pojo.param.UniversalFrontEndParam;

View File

@@ -25,7 +25,7 @@ import com.njcn.event.file.component.WaveFileComponent;
import com.njcn.event.file.pojo.dto.WaveDataDTO; import com.njcn.event.file.pojo.dto.WaveDataDTO;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper; import com.njcn.event.mapper.distribution.PwRmpEventDetailMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.mapper.majornetwork.TransientMapper; import com.njcn.event.mapper.majornetwork.TransientMapper;
import com.njcn.event.pojo.param.EventVerifyReasonParam; import com.njcn.event.pojo.param.EventVerifyReasonParam;
import com.njcn.event.pojo.param.TransientParam; import com.njcn.event.pojo.param.TransientParam;
@@ -33,7 +33,7 @@ import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.TransientVO; import com.njcn.event.pojo.vo.TransientVO;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.TransientService; import com.njcn.event.service.majornetwork.TransientService;
import com.njcn.minioss.config.MinIossProperties; import com.njcn.minioss.config.MinIossProperties;
import com.njcn.minioss.util.MinIoUtils; import com.njcn.minioss.util.MinIoUtils;
@@ -56,7 +56,6 @@ import java.text.DecimalFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;

View File

@@ -10,7 +10,7 @@ import com.njcn.event.pojo.param.VoltageRideThroughQueryParam;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.EventNewStationVo; import com.njcn.event.pojo.vo.EventNewStationVo;
import com.njcn.event.pojo.vo.VoltageRideThroughVo; import com.njcn.event.pojo.vo.VoltageRideThroughVo;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.service.majornetwork.SpThroughService; import com.njcn.event.service.majornetwork.SpThroughService;
import com.njcn.event.service.majornetwork.VoltageRideThroughEventService; import com.njcn.event.service.majornetwork.VoltageRideThroughEventService;
import com.njcn.event.pojo.param.SpThroughParam; import com.njcn.event.pojo.param.SpThroughParam;

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.njcn</groupId>
<artifactId>pqs-event</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>event-common</artifactId>
<version>1.0.0</version>
<name>event-common</name>
<description>event-common</description>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>event-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>advance-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,4 +1,4 @@
package com.njcn.event.mapper.majornetwork; package com.njcn.event.common.mapper;
import com.njcn.event.pojo.po.EventDistributionStatisticsPO; import com.njcn.event.pojo.po.EventDistributionStatisticsPO;
import com.njcn.event.pojo.po.EventDurationLineChartPO; import com.njcn.event.pojo.po.EventDurationLineChartPO;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.mapper.majornetwork; package com.njcn.event.common.mapper;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;

View File

@@ -1,5 +1,5 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.event.mapper.majornetwork.RmpEventDetailMapper"> <mapper namespace="com.njcn.event.common.mapper.RmpEventDetailMapper">
<select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO"> <select id="getDetailsOfTransientEvents" resultType="com.njcn.event.pojo.po.RmpEventDetailPO">
SELECT SELECT

View File

@@ -0,0 +1,133 @@
package com.njcn.event.common.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Data
public class LineDetailDataCommDTO {
private String lineId;
@ApiModelProperty(name = "id",value = "监测点序号")
private Integer id;
@ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName;
@ApiModelProperty(name = "areaName",value = "工程名称")
private String areaName;
@ApiModelProperty(name = "gdName",value = "单位")
private String gdName;
@ApiModelProperty(name = "bdName",value = "部门")
private String bdName;
@ApiModelProperty(name = "scale",value = "电压等级")
private String scale;
@ApiModelProperty(name = "manufacturer",value = "厂家")
private String manufacturer;
@ApiModelProperty(name = "devId",value = "终端Id")
private String devId;
@ApiModelProperty(name = "devName",value = "终端名称")
private String devName;
@ApiModelProperty(name = "ip",value = "网络参数")
private String ip;
@ApiModelProperty(name = "runFlag",value = "终端运行状态")
private String runFlag;
@ApiModelProperty(name = "comFlag",value = "通讯状态")
private String comFlag;
@ApiModelProperty(name = "loadType",value = "干扰源类型")
private String loadType;
@ApiModelProperty(name = "businessType",value = "行业类型")
private String businessType;
@ApiModelProperty(name = "objName",value = "监测点对象名称")
private String objName;
@ApiModelProperty(name = "ptType",value = "接线方式")
private String ptType;
@ApiModelProperty(name = "pt",value = "PT变比")
private String pt;
@ApiModelProperty(name = "ct",value = "CT变比")
private String ct;
@ApiModelProperty(name = "standardCapacity",value = "基准容量MVA")
private Float standardCapacity;
@ApiModelProperty(name = "shortCapacity",value = "最小短路容量MVA")
private Float shortCapacity;
@ApiModelProperty(name = "devCapacity",value = "供电设备容量MVA")
private Float devCapacity;
@ApiModelProperty(name = "dealCapacity",value = "用户协议容量MVA")
private Float dealCapacity;
@ApiModelProperty(name = "powerFlag",value = "电网标志0-电网侧1-非电网侧)")
private Integer powerFlag;
/**
* 测量间隔1-10分钟
*/
@ApiModelProperty(name = "timeInterval",value = "测量间隔1-10分钟")
private Integer timeInterval;
/**
* 监测点拥有者
*/
@ApiModelProperty(name = "owner",value = "监测点拥有者")
private String owner;
/**
* 拥有者职务
*/
@ApiModelProperty(name = "ownerDuty",value = "拥有者职务")
private String ownerDuty;
/**
* 拥有者联系方式
*/
@ApiModelProperty(name = "ownerTel",value = "拥有者联系方式")
private String ownerTel;
/**
* 接线图
*/
@ApiModelProperty(name = "wiringDiagram",value = "接线图")
private String wiringDiagram;
@ApiModelProperty(name = "ptPhaseType",value = "监测点接线相别0单相,1三相默认三相")
private Integer ptPhaseType;
@ApiModelProperty(name = "投运日期")
private LocalDate loginTime;
@ApiModelProperty(name = "最新数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@ApiModelProperty(name = "监测对象信息ID")
private String objId;
@ApiModelProperty(name = "对象类型大类")
private String bigObjType;
}

View File

@@ -0,0 +1,18 @@
package com.njcn.event.common.service;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.pojo.param.ExportParam;
import javax.servlet.http.HttpServletResponse;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
public interface CommMonitorEventReportService {
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
}

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork; package com.njcn.event.common.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.event.pojo.param.*; import com.njcn.event.pojo.param.*;
@@ -55,7 +55,7 @@ public interface EventAnalysisService {
* @param statisticsParam * @param statisticsParam
* @return * @return
*/ */
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException; List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam);
/** /**
* 获取详细数据对象 * 获取详细数据对象

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork; package com.njcn.event.common.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.event.pojo.dto.EventDeatilDTO; import com.njcn.event.pojo.dto.EventDeatilDTO;
@@ -41,4 +41,4 @@ public interface EventDetailService extends IService<RmpEventDetailPO> {
List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType); List<EventDetail> getEventDetailLimit(List<String> lineIndexes, String startTime, String endTime, Integer pageSize, Integer pageNum, List<String> waveType);
Boolean addEventDetail(EventDeatilDTO deatilDTO); Boolean addEventDetail(EventDeatilDTO deatilDTO);
} }

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork; package com.njcn.event.common.service;
import com.njcn.event.pojo.param.EventMonitorReportParam; import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;

View File

@@ -0,0 +1,78 @@
package com.njcn.event.common.service;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.vo.*;
import com.njcn.system.pojo.po.DictData;
import java.text.ParseException;
import java.util.List;
/**
* <监测点报表>
*
* @author wr
* @createTime: 2023-02-10
*/
public interface EventReportService {
/**
*获取Disdip表格监测点报表专用
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<DISDIPVO> eventDisdip(List<EventDetail> info);
/**
* 获取IEC411数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC411VO> IEC411(List<EventDetail> info);
/**
* 获取IEC28数据
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<IEC28VO> IEC28(List<EventDetail> info);
/**
*暂降幅值概率分布
* @param info2 influxdb查询结果pqs_eventdetail表
* @return
*/
ProbabilityVO getProbabilityDistribution(List<EventDetail> info2);
/**
* 获取时间列表(月份统计)
* @param info influxdb查询结果pqs_eventdetail表
* @return
*/
List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam,List<EventDetail> info) throws ParseException;
/**
* 获取点状表格数据2.1
* @param info 结果集
* @param reasonData 暂降原因
* @param typeData 暂降类型
* @return
*/
List<EventDetail> getPlot(List<EventDetail> info, List<DictData> reasonData, List<DictData> typeData);
/**
* 获取详细数据对象
* @param info
* @param reasonData
* @param typeData
* @return
*/
StatisticVO getStatistic(List<EventDetail> info,List<DictData> reasonData,List<DictData>typeData);
/**
* 获取密度点图
* @param info
* @return
*/
Integer[][] getCoords(List<EventDetail> info);
}

View File

@@ -0,0 +1,589 @@
package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.echarts.pojo.constant.PicCommonData;
import com.njcn.echarts.util.DrawPicUtil;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.common.service.CommMonitorEventReportService;
import com.njcn.event.common.utils.WordUtils;
import com.njcn.event.pojo.param.ExportParam;
import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
import org.springframework.stereotype.Service;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class CommMonitorEventReportServiceImpl implements CommMonitorEventReportService {
private final LineFeignClient lineFeignClient;
private final DicDataFeignClient dicDataFeignClient;
private final EventReportService eventReportService;
//调用暂降密度接口
private final EventAnalysisService eventAnalysisService;
private final MonitorClient monitorClient;
private final RmpEventDetailMapper rmpEventDetailMapper;
private final DrawPicUtil drawPicUtil;
/**
* 监测点导出word
*
* @param exportParam .
* @param response .
*/
@Override
public void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailData, HttpServletResponse response) {
//创建word文档(poi生成word)
XWPFDocument doc = new XWPFDocument(); //创建Word文件
//设置标题样式
WordUtils.setHeadingStyle(doc);
XWPFParagraph p = doc.createParagraph(); //新建一个段落
//设置对齐
p.setAlignment(ParagraphAlignment.CENTER);
p.setVerticalAlignment(TextAlignment.CENTER);
XWPFRun r = p.createRun();//创建段落文本
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.addBreak();
r.setText("");
r.setBold(true);//设置为粗体
r.setFontSize(14);//字体大小
r.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r1 = p.createRun();//创建段落文本
r1.setText("电压暂降事件分析报告");
r1.setBold(true);//设置为粗体
r1.setFontSize(36);//字体大小
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
r1.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r2 = p.createRun();//创建段落文本
//获取当前时间
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
String time = dateFormat.format(date);
r2.setText("日期: " + time);
r2.setBold(true);//设置为粗体
r2.setFontSize(14);//字体大小
r2.addBreak();
r2.addBreak();
r2.addBreak();
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.CENTER);
XWPFRun r3 = p.createRun();//创建段落文本
r3.setText("电压暂降事件区域报告");
r3.setFontSize(24);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "1. 引言", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r5 = p.createRun();//创建段落文本
r5.setText("对所选中区间内电压暂降事件进行分析,能够直观清晰查看响应的暂降事件信息。");
r5.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r7 = p.createRun();//创建段落文本
r7.setText(exportParam.getLineName());
r7.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.BOTH);
XWPFRun r9 = p.createRun();//创建段落文本
r9.setText(exportParam.getSearchBeginTime() + "" + exportParam.getSearchEndTime());
r9.setFontSize(11);//字体大小
p = doc.createParagraph(); //新建一个段落
p.setAlignment(ParagraphAlignment.LEFT);
createTitle(doc, "4. 总汇信息", "标题 1", 0, 15);
//查询参数
StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag());
//获取暂降原因字典
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
//获取暂降类型字典
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
//influxdb查询结果pqs_eventdetail表
List<EventDetail> info = info(param);
//记录数
int i = 1;
//1.监测点信息
if (exportParam.isXq()) {
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
insertRow(doc, table, centerParagraph, true, "项目", "描述");
insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getLineName());
insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getScale());
insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getPt());
insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getCt());
insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getDealCapacity() + "");
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getDevCapacity() + "");
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getShortCapacity() + "");
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getPtType());
if (exportParam.getType() == 0) {
insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getStandardCapacity() + "");
}
i++;
}
//2.暂降事件暂降事件列表和暂降点图
//2.1.判断列表和点图是否是要导出
if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
// List<EventDetail> plot = eventAnalysisService.getPlot(param);
List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
//暂降事件列表
if (exportParam.isLb()) {
createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
XWPFTable table = createTable(doc);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
for (int j = 0; j < plot.size(); j++) {
EventDetail eventDetail = plot.get(j);
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", eventDetail.getAdvanceType(), eventDetail.getAdvanceReason(), eventDetail.getSeverity() + "");
}
i++;
}
//暂降事件点图
if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
ArrayList<List<Double>> ass = getAss(plot);
createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
int two = 1;
if (exportParam.isSjdITIC()) {
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
String itic = drawPicUtil.drawItic(ass);
createPic(doc, itic, "ITIC曲线");
two++;
}
if (exportParam.isSjdF47()) {
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
String f47 = drawPicUtil.drawF47(ass);
createPic(doc, f47, "SEMI F47曲线");
two++;
}
i++;
}
}
//3.暂降密度
if (exportParam.isMdbg() || exportParam.isMdtx()) {
createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
int two = 1;
if (exportParam.isMdtx()) {
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
Integer[][] eventDensityData = eventReportService.getCoords(info);
String str = drawPicUtil.drawEventDensity(eventDensityData);
createPic(doc, str, "暂降密度图");
two++;
}
if (exportParam.isMdbg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
// List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
for (int j = 0; j < eventDisdip.size(); j++) {
DISDIPVO disdipvo = eventDisdip.get(j);
insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
}
two++;
createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
// List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
XWPFTable table2 = createTable(doc);
insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
for (int j = 0; j < iec411VOS.size(); j++) {
IEC411VO iec411VO = iec411VOS.get(j);
insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
}
two++;
createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
// List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
XWPFTable table3 = createTable(doc);
insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
for (int j = 0; j < iec28VOS.size(); j++) {
IEC28VO iec28VO = iec28VOS.get(j);
insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
}
two++;
}
i++;
}
//4.暂降幅值概率分布
if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
// ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
int two = 1;
if (exportParam.isGlfbfz()) {
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPereventvalue();
List<String> ylinedata = probabilityVO.getEventvalue();
String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
createPic(doc, fz, "暂降幅值的概率分布函数");
two++;
}
if (exportParam.isGlfbsj()) {
createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
List<String> ybardata = probabilityVO.getPersisttime();
List<String> ylinedata = probabilityVO.getSisttime();
String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
createPic(doc, sj, "持续时间的概率分布函数");
two++;
}
i++;
}
//5.月份统计
if (exportParam.isTjbg() || exportParam.isTjtx()) {
createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
int two = 1;
List<TimeVO> reasonTypeTime = eventAnalysisService.getReasonTypeTime(param);
//暂时时间端按月查询不能查询
// List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
if (exportParam.isTjtx()) {
createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
List<Integer> count = new ArrayList<>();
List<String> name = new ArrayList<>();
if (exportParam.getFlag() == 0) {
for (TimeVO timeVO : reasonTypeTime) {
name.add(timeVO.getMonth() + "");
count.add(Integer.parseInt(timeVO.getTimes()));
}
} else {
for (TimeVO timeVO : reasonTypeTime) {
name.add(timeVO.getDay() + "");
count.add(Integer.parseInt(timeVO.getTimes()));
}
}
String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
createPic(doc, yftj, "月份统计图");
two++;
}
if (exportParam.isTjbg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15);
XWPFTable table1 = createTable(doc);
if (exportParam.getFlag() == 0) {
insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数");
} else {
insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数");
}
if (exportParam.getFlag() == 0) {
for (int j = 0; j < reasonTypeTime.size(); j++) {
TimeVO timeVO = reasonTypeTime.get(j);
insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes());
}
} else {
for (int j = 0; j < reasonTypeTime.size(); j++) {
TimeVO timeVO = reasonTypeTime.get(j);
insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
}
}
two++;
}
i++;
}
//6.原因统计
//6.1整合提出查询语句
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
if (fly) {
StatisticVO statistic = eventReportService.getStatistic(info, reasonData, typeData);
if (exportParam.isYybg() || exportParam.isYytx()) {
createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
int two = 1;
if (exportParam.isYytx()) {
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
List<String> xdata = new ArrayList<>();
List<Map<String, Object>> reasonList = new ArrayList<>();
List<ReasonsVO> reason = statistic.getReason();
for (ReasonsVO reasonsVO : reason) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", reasonsVO.getTimes());
map.put("name", reasonsVO.getReason());
reasonList.add(map);
xdata.add(reasonsVO.getReason());
}
String tr = drawPicUtil.drawReason(xdata, reasonList);
createPic(doc, tr, "暂降原因图");
two++;
}
if (exportParam.isYybg()) {
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
List<ReasonsVO> reason = statistic.getReason();
for (int j = 0; j < reason.size(); j++) {
ReasonsVO reasonsVO = reason.get(j);
insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + "");
}
two++;
}
i++;
}
//7.类型统计
if (exportParam.isLxbg() || exportParam.isLxtx()) {
createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15);
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
int two = 1;
if (exportParam.isLxtx()) {
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
List<String> xdata = new ArrayList<>();
List<TypesVO> types = statistic.getTypes();
List<Map<String, Object>> reasonList = new ArrayList<>();
for (TypesVO type : types) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("value", type.getTimes());
map.put("name", type.getType());
reasonList.add(map);
xdata.add(type.getType());
}
String tr = drawPicUtil.drawType(xdata, reasonList);
createPic(doc, tr, "暂降类型图");
two++;
}
if (exportParam.isLxbg()) {
createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15);
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
XWPFTable table1 = createTable(doc);
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
List<TypesVO> types = statistic.getTypes();
for (int j = 0; j < types.size(); j++) {
TypesVO typesVO = types.get(j);
insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + "");
}
two++;
}
i++;
}
}
try {
ServletOutputStream outputStream = response.getOutputStream();
String fileName = URLEncoder.encode(exportParam.getLineName() + ".docx", "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=UTF-8");
doc.write(outputStream);
outputStream.close();
}catch (Exception e){
throw new BusinessException(CommonResponseEnum.FAIL,"导出监测点暂降报告异常");
}
}
/**
* 创建标题
*
* @param document 文档
* @param message 标题内容
* @param style 标题等级
* @param line 缩进
* @param fontSize 字体大小
*/
public void createTitle(XWPFDocument document, String message, String style, int line, int fontSize) {
XWPFParagraph summaeTableParagraph = WordUtils.getLeftParagraph(document);
summaeTableParagraph.setStyle(style);
summaeTableParagraph.setIndentationFirstLine(line);
XWPFRun summaeTableRun = summaeTableParagraph.createRun();
WordUtils.addParagraph(summaeTableRun, "宋体", fontSize, "000000", message, false);
}
/**
* 表格插入行数据
*
* @param document 文档
* @param table 表格
* @param head 是否是表头
* @param values 数据内容
*/
public static void insertRow(XWPFDocument document, XWPFTable table, XWPFParagraph excelParagraph, boolean head,
String... values) {
if (head) {
XWPFTableRow summaTableRowOne = table.getRow(0);
WordUtils.setExcelHeadContent(excelParagraph, summaTableRowOne, values);
} else {
XWPFTableRow summaTableRowOne = table.createRow();
WordUtils.setExcelContent(excelParagraph, summaTableRowOne, values);
}
}
/**
* 创建表格
*
* @param document
* @return
*/
public XWPFTable createTable(XWPFDocument document) {
XWPFTable summaTable = document.createTable();
// 列宽自动分割
CTTblWidth summaTableWidth = summaTable.getCTTbl().addNewTblPr().addNewTblW();
summaTableWidth.setType(STTblWidth.DXA);
summaTableWidth.setW(BigInteger.valueOf(8160));
return summaTable;
}
public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
cellname.setCellValue(value);
cellname.setCellStyle(style);
}
/**
*
*
* @param document 文档
* @param image 图片base64
* @param name 图片名
* @throws IOException
* @throws InvalidFormatException
*/
public void createPic(XWPFDocument document, String image, String name) {
try {
XWPFParagraph picParagraph = WordUtils.getCenterParagraph(document);
XWPFRun createRun = picParagraph.createRun();
if (image.contains(PicCommonData.PNG_PREFIX)) {
image = image.replace(PicCommonData.PNG_PREFIX, "");
}
byte[] bytes = Base64.getDecoder().decode(image);
InputStream in = new ByteArrayInputStream(bytes);
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
}catch (Exception e){
log.error("在word中创建图片异常:",e);
}
}
/**
* 监测点暂降事件点图赋值
*
* @param plot
* @return
*/
private ArrayList<List<Double>> getAss(List<EventDetail> plot) {
ArrayList<List<Double>> list = new ArrayList<>();
for (EventDetail eventDetail : plot) {
ArrayList<Double> doubles = new ArrayList<>();
doubles.add(eventDetail.getDuration());
doubles.add(Double.parseDouble(String.valueOf(eventDetail.getFeatureAmplitude() * 100)));
list.add(doubles);
}
return list;
}
/**
* influxdb查询结果集
*
* @param statisticsParam
* @return
*/
private List<EventDetail> info(StatisticsParam statisticsParam) {
//获取事件类型
List<DictData> dictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeIds = dictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
.map(DictData::getId).collect(Collectors.toList());
//数据暂降查询
List<RmpEventDetailPO> info = rmpEventDetailMapper.selectList(new LambdaQueryWrapper<RmpEventDetailPO>()
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
.in(RmpEventDetailPO::getEventType, typeIds)
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
);
return BeanUtil.copyToList(info, EventDetail.class);
}
}

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@@ -13,6 +13,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.service.EventDetailService;
import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.enums.EventResponseEnum;
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum; import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
import com.njcn.event.pojo.param.EventBaseParam; import com.njcn.event.pojo.param.EventBaseParam;
@@ -20,8 +21,7 @@ import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventAnalysisService; import com.njcn.event.common.service.EventAnalysisService;
import com.njcn.event.service.majornetwork.EventDetailService;
import com.njcn.influx.utils.InfluxDbUtils; import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
@@ -792,7 +792,7 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
* @author xxy * @author xxy
*/ */
@Override @Override
public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) throws ParseException { public List<TimeVO> getReasonTypeTime(StatisticsParam statisticsParam) {
//获取暂降字典信息 //获取暂降字典信息
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData(); List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList()); List<TimeVO> list = new ArrayList<>(); List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList()); List<TimeVO> list = new ArrayList<>();
@@ -941,37 +941,28 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
.le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime()))) .le(StringUtils.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
); );
HttpResult<List<DictData>> reason = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()); List<DictData> reasonList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
HttpResult<List<DictData>> type = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()); Map<String,String> reasonData = reasonList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
List<DictData> reasonData = reason.getData(); Map<String, Integer> reasonMap = convertMap(reasonData);
List<DictData> typeData = type.getData(); List<DictData> advanceTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
Map<String,String> advanceTypeData = advanceTypeList.stream().collect(Collectors.toMap(DictData::getId, DictData::getName));
Map<String, Integer> reasonMap = new LinkedHashMap<>(); Map<String, Integer> typeMap = convertMap(advanceTypeData);
Map<String, Integer> typeMap = new LinkedHashMap<>();
//添加detail //添加detail
for (RmpEventDetailPO detail : info) { for (RmpEventDetailPO detail : info) {
EventDetail details = null; EventDetail details = BeanUtil.copyProperties(detail, EventDetail.class);
if (typeList.contains(detail.getEventType())) { if(StrUtil.isNotBlank(detail.getAdvanceType())){
for (DictData data : reasonData) { details.setAdvanceType(advanceTypeData.get(detail.getAdvanceType()));
reasonMap.put(data.getName(), 0); }else {
if (detail.getAdvanceReason().equals(data.getId())) { details.setAdvanceType(DicDataEnum.OTHER.getName());
details = BeanUtil.copyProperties(detail, EventDetail.class);
details.setAdvanceReason(data.getName());
}
}
for (DictData data : typeData) {
typeMap.put(data.getName(), 0);
if (detail.getAdvanceType().equals(data.getId())) {
// details = BeanUtil.copyProperties(detail, EventDetail.class);
details.setAdvanceType(data.getName());
}
}
list.add(details);
} }
if(StrUtil.isNotBlank(detail.getAdvanceReason())){
details.setAdvanceReason(reasonData.get(detail.getAdvanceReason()));
}else {
details.setAdvanceReason(DicDataEnum.OTHER.getName());
}
list.add(details);
} }
//添加reason到map //添加reason到map
for (EventDetail data : list) { for (EventDetail data : list) {
if (reasonMap.get(data.getAdvanceReason()) != null) { if (reasonMap.get(data.getAdvanceReason()) != null) {
@@ -994,10 +985,29 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
} }
result.setTypes(typesVOS); result.setTypes(typesVOS);
result.setReason(reasonsVOS); result.setReason(reasonsVOS);
//result.setDetail(list);
return result; return result;
} }
/**
* 将原Map的value作为新Map的key0作为新Map的value
* @param originalMap 原始Mapkey和value唯一
* @return 转换后的新Map
*/
public static <K, V> Map<V, Integer> convertMap(Map<K, V> originalMap) {
// 创建新的HashMap存储结果
Map<V, Integer> newMap = new HashMap<>();
// 遍历原始Map的所有entry
for (Map.Entry<K, V> entry : originalMap.entrySet()) {
// 原value作为新key0作为新value
V originalValue = entry.getValue();
newMap.put(originalValue, 0);
}
return newMap;
}
/** /**
* 暂降幅值的概率分布函数 * 暂降幅值的概率分布函数
* *

View File

@@ -1,8 +1,7 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.common.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -10,33 +9,27 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.tocrhz.mqtt.publisher.MqttPublisher; import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.advance.api.EventCauseFeignClient; import com.njcn.advance.api.EventCauseFeignClient;
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
import com.njcn.advance.pojo.dto.EventAnalysisDTO; import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.dto.LogInfoDTO;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.DeptGetBase;
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
import com.njcn.device.pq.api.DeptLineFeignClient; import com.njcn.device.pq.api.DeptLineFeignClient;
import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.pojo.po.DeptLine; import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO; import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.vo.SendEventVO; import com.njcn.event.pojo.vo.SendEventVO;
import com.njcn.event.utils.EventUtil; import com.njcn.event.utils.EventUtil;
import com.njcn.event.mapper.majornetwork.EventDetailMapper;
import com.njcn.event.pojo.dto.EventDeatilDTO; import com.njcn.event.pojo.dto.EventDeatilDTO;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.common.service.EventDetailService;
import com.njcn.influx.utils.InfluxDbUtils; import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient; import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept; import com.njcn.user.pojo.po.Dept;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.influxdb.dto.QueryResult; import org.influxdb.dto.QueryResult;
@@ -60,7 +53,7 @@ import java.util.*;
@Slf4j @Slf4j
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
public class EventDetailServiceImpl extends ServiceImpl<EventDetailMapper, RmpEventDetailPO> implements EventDetailService { public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, RmpEventDetailPO> implements EventDetailService {
private final InfluxDbUtils influxDbUtils; private final InfluxDbUtils influxDbUtils;
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.common.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.njcn.common.pojo.constant.BizParamConstant; import com.njcn.common.pojo.constant.BizParamConstant;
@@ -7,12 +7,12 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.pojo.dto.PmsMonitorDTO; import com.njcn.device.pms.pojo.dto.PmsMonitorDTO;
import com.njcn.device.pms.pojo.param.PmsMonitorParam; import com.njcn.device.pms.pojo.param.PmsMonitorParam;
import com.njcn.event.mapper.majornetwork.EventDistributionStatisticsMapper; import com.njcn.event.common.mapper.EventDistributionStatisticsMapper;
import com.njcn.event.mapper.majornetwork.RmpEventDetailMapper; import com.njcn.event.common.service.EventMonitorReportService;
import com.njcn.event.common.mapper.RmpEventDetailMapper;
import com.njcn.event.pojo.param.EventMonitorReportParam; import com.njcn.event.pojo.param.EventMonitorReportParam;
import com.njcn.event.pojo.po.RmpEventDetailPO; import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventMonitorReportService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;

View File

@@ -1,13 +1,13 @@
package com.njcn.event.service.majornetwork.Impl; package com.njcn.event.common.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.njcn.event.common.service.EventReportService;
import com.njcn.event.pojo.constant.Param; import com.njcn.event.pojo.constant.Param;
import com.njcn.event.pojo.param.StatisticsParam; import com.njcn.event.pojo.param.StatisticsParam;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.EventDetailNew; import com.njcn.event.pojo.po.EventDetailNew;
import com.njcn.event.pojo.vo.*; import com.njcn.event.pojo.vo.*;
import com.njcn.event.service.majornetwork.EventReportService;
import com.njcn.influx.utils.InfluxDbUtils; import com.njcn.influx.utils.InfluxDbUtils;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

View File

@@ -1,4 +1,4 @@
package com.njcn.event.utils; package com.njcn.event.common.utils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.math.BigInteger; import java.math.BigInteger;
@@ -28,7 +28,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.STStyleType;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
public class WordUtils { public class WordUtils {
public static void main(String[] args)throws Exception { public static void main(String[] args)throws Exception {
@@ -200,7 +200,7 @@ public class WordUtils {
paragraph.setSpacingAfter(100); paragraph.setSpacingAfter(100);
} }
/** /**
* 返回指定格式的段落 居中型 * 返回指定格式的段落 居中型
* @param document 文档对象 * @param document 文档对象
*/ */
@@ -211,8 +211,8 @@ public class WordUtils {
paragraph.setVerticalAlignment(TextAlignment.CENTER); paragraph.setVerticalAlignment(TextAlignment.CENTER);
return paragraph; return paragraph;
} }
/** /**
* 返回指定格式的段落 居左型 * 返回指定格式的段落 居左型
* @param document 文档对象 * @param document 文档对象
*/ */
@@ -223,7 +223,7 @@ public class WordUtils {
return paragraph; return paragraph;
} }
/** /**
* 添加换行符 * 添加换行符

View File

@@ -13,10 +13,11 @@
<modules> <modules>
<module>event-api</module> <module>event-api</module>
<module>event-boot</module> <module>event-boot</module>
<module>event-common</module>
</modules> </modules>
<properties> <properties>
<maven.compiler.source>8</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
</properties> </properties>
<packaging>pom</packaging> <packaging>pom</packaging>
</project> </project>

View File

@@ -4,9 +4,6 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.IoUtil; import cn.hutool.core.io.IoUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
import com.njcn.common.pojo.constant.LogInfo;
import com.njcn.common.pojo.constant.SecurityConstants; import com.njcn.common.pojo.constant.SecurityConstants;
import com.njcn.common.pojo.dto.LogInfoDTO; import com.njcn.common.pojo.dto.LogInfoDTO;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
@@ -14,6 +11,8 @@ import com.njcn.gateway.enums.GateWayEnum;
import com.njcn.gateway.security.AuthorizationManager; import com.njcn.gateway.security.AuthorizationManager;
import com.njcn.gateway.utils.ResponseUtils; import com.njcn.gateway.utils.ResponseUtils;
import com.njcn.gateway.utils.WebFluxRequestUtil; import com.njcn.gateway.utils.WebFluxRequestUtil;
import com.njcn.redis.pojo.enums.RedisKeyEnum;
import com.njcn.redis.utils.RedisMessageQueueUtil;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@@ -39,7 +38,6 @@ import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey; import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec; import java.security.spec.X509EncodedKeySpec;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Objects;
/** /**
* @author hongawen * @author hongawen
@@ -54,7 +52,16 @@ public class ResourceServerConfig {
private final WhiteListConfig whiteListConfig; private final WhiteListConfig whiteListConfig;
private final MqttPublisher publisher; /**
* mqtt处理日志异步发布
*/
// private final MqttPublisher publisher;
/**
* redis队列处理日志异步发布
*/
private final RedisMessageQueueUtil redisMessageQueueUtil;
@Bean @Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
@@ -108,8 +115,12 @@ public class ResourceServerConfig {
userIndex, userIndex,
LocalDateTime.now() LocalDateTime.now()
); );
publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false); // publisher.send("/userLog", PubUtils.obj2json(logInfoDTO), 2, false);
publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false); redisMessageQueueUtil.pushMessage(
RedisKeyEnum.USER_LOG_QUEUE.getKey(),
PubUtils.obj2json(logInfoDTO)
);
// publisher.send("/userLogPush", PubUtils.obj2json(logInfoDTO), 2, false);
return ResponseUtils.writeErrorInfo(response, GateWayEnum.NO_AUTHORIZATION); return ResponseUtils.writeErrorInfo(response, GateWayEnum.NO_AUTHORIZATION);
}); });
} }

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.controller; package com.njcn.harmonic.controller;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@@ -12,7 +12,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.param.*; import com.njcn.harmonic.pojo.param.*;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.*; import com.njcn.harmonic.pojo.vo.*;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService; import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.controller; package com.njcn.harmonic.controller;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
@@ -15,7 +15,7 @@ import com.njcn.harmonic.pojo.vo.LimitCalendarVO;
import com.njcn.harmonic.pojo.vo.LimitExtentVO; import com.njcn.harmonic.pojo.vo.LimitExtentVO;
import com.njcn.harmonic.pojo.vo.LimitProbabilityVO; import com.njcn.harmonic.pojo.vo.LimitProbabilityVO;
import com.njcn.harmonic.pojo.vo.LimitTimeProbabilityVO; import com.njcn.harmonic.pojo.vo.LimitTimeProbabilityVO;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDetailDService; import com.njcn.harmonic.service.IRStatLimitRateDetailDService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;

View File

@@ -10,7 +10,7 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.harmonic.pojo.param.ReportSearchParam; import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp; import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.vo.ReportTreeVO; import com.njcn.harmonic.pojo.vo.ReportTreeVO;
import com.njcn.harmonic.pojo.vo.SysDeptTempVO; import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
import com.njcn.harmonic.service.report.CustomReportService; import com.njcn.harmonic.service.report.CustomReportService;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.mapper; package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.mapper; package com.njcn.harmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDetailDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDetailDPO;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.mapper.RStatDataIDMapper"> <mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatDataIDMapper">
<select id="getINeg" resultType="com.njcn.harmonic.pojo.po.day.RStatDataIDPO"> <select id="getINeg" resultType="com.njcn.harmonic.pojo.po.day.RStatDataIDPO">
select select

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.mapper.RStatDataInharmVDMapper"> <mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatDataInharmVDMapper">
<select id="getV" resultType="com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO"> <select id="getV" resultType="com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO">

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.mapper.RStatDataVDMapper"> <mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatDataVDMapper">
<select id="getFreqDev" resultType="com.njcn.harmonic.pojo.po.RStatDataVD"> <select id="getFreqDev" resultType="com.njcn.harmonic.pojo.po.RStatDataVD">
select select

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper"> <mapper namespace="com.njcn.harmonic.mapper.RStatLimitRateDMapper">
<select id="getSumPassRate" resultType="com.njcn.harmonic.pojo.vo.RStatLimitRateDVO"> <select id="getSumPassRate" resultType="com.njcn.harmonic.pojo.vo.RStatLimitRateDVO">
SELECT SELECT

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDetailDMapper"> <mapper namespace="com.njcn.harmonic.mapper.RStatLimitRateDetailDMapper">
</mapper> </mapper>

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.service; package com.njcn.harmonic.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.service; package com.njcn.harmonic.service;
import cn.hutool.json.JSONArray; import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -33,7 +33,7 @@ import com.njcn.harmonic.pojo.vo.MonitorOverLimitVO;
import com.njcn.harmonic.pojo.vo.OverAreaLimitVO; import com.njcn.harmonic.pojo.vo.OverAreaLimitVO;
import com.njcn.harmonic.pojo.vo.OverAreaVO; import com.njcn.harmonic.pojo.vo.OverAreaVO;
import com.njcn.harmonic.pojo.vo.WarningSubstationVO; import com.njcn.harmonic.pojo.vo.WarningSubstationVO;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.IAnalyzeService; import com.njcn.harmonic.service.IAnalyzeService;
import com.njcn.poi.excel.ExcelUtil; import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.api.UserLedgerFeignClient;

View File

@@ -23,7 +23,10 @@ import com.njcn.harmonic.pojo.vo.hebeinorth.AssessDetailVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.AssessVo; import com.njcn.harmonic.pojo.vo.hebeinorth.AssessVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationLevelVo; import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationLevelVo;
import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationVo; import com.njcn.harmonic.pojo.vo.hebeinorth.EvaluationVo;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
import com.njcn.harmonic.common.mapper.RStatDataInharmVDMapper;
import com.njcn.harmonic.common.mapper.RStatDataVDMapper;
import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.hebeinorth.IGridService; import com.njcn.harmonic.service.hebeinorth.IGridService;
import com.njcn.harmonic.util.ComAssesUtil; import com.njcn.harmonic.util.ComAssesUtil;
import com.njcn.harmonic.util.TimeUtil; import com.njcn.harmonic.util.TimeUtil;

View File

@@ -12,7 +12,6 @@ import com.njcn.common.pojo.constant.BizParamConstant;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.param.StatisticsBizBaseParam; import com.njcn.common.pojo.param.StatisticsBizBaseParam;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.dataProcess.pojo.po.RStatDataHarmRateVD;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO; import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.biz.pojo.po.Overlimit; import com.njcn.device.biz.pojo.po.Overlimit;
@@ -20,7 +19,6 @@ import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.device.biz.utils.COverlimitUtil; import com.njcn.device.biz.utils.COverlimitUtil;
import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.pojo.po.EventDetail; import com.njcn.event.pojo.po.EventDetail;
import com.njcn.event.pojo.po.RmpEventDetailPO;
import com.njcn.harmonic.enums.HarmonicResponseEnum; import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.mapper.*; import com.njcn.harmonic.mapper.*;
import com.njcn.harmonic.pojo.QueryResultLimitVO; import com.njcn.harmonic.pojo.QueryResultLimitVO;
@@ -33,8 +31,10 @@ import com.njcn.harmonic.pojo.vo.AssessEvaluation;
import com.njcn.harmonic.pojo.vo.EventDetailVO; import com.njcn.harmonic.pojo.vo.EventDetailVO;
import com.njcn.harmonic.pojo.vo.HistoryDataResultVO; import com.njcn.harmonic.pojo.vo.HistoryDataResultVO;
import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO; import com.njcn.harmonic.pojo.vo.StatHarmonicOrgVO;
import com.njcn.harmonic.common.mapper.RStatDataHarmRateVDMapper;
import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
import com.njcn.harmonic.common.mapper.RStatDataVDMapper;
import com.njcn.harmonic.service.HistoryResultService; import com.njcn.harmonic.service.HistoryResultService;
import com.njcn.harmonic.service.IRStatDataVDService;
import com.njcn.influx.imapper.CommonMapper; import com.njcn.influx.imapper.CommonMapper;
import com.njcn.influx.imapper.DataHarmRateVMapper; import com.njcn.influx.imapper.DataHarmRateVMapper;
import com.njcn.influx.imapper.DataIMapper; import com.njcn.influx.imapper.DataIMapper;
@@ -50,14 +50,11 @@ import com.njcn.system.pojo.po.DictData;
import com.njcn.user.api.DeptFeignClient; import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.dto.DeptDTO; import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.utils.WebUtil; import com.njcn.web.utils.WebUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;

View File

@@ -58,7 +58,7 @@ import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.PollutionSubstationVO; import com.njcn.harmonic.pojo.vo.PollutionSubstationVO;
import com.njcn.harmonic.pojo.vo.PollutionVO; import com.njcn.harmonic.pojo.vo.PollutionVO;
import com.njcn.harmonic.pojo.vo.SubstationVo; import com.njcn.harmonic.pojo.vo.SubstationVo;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.PollutionSubstationService; import com.njcn.harmonic.service.PollutionSubstationService;
import com.njcn.poi.excel.ExcelUtil; import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.api.UserLedgerFeignClient;

View File

@@ -1,7 +1,7 @@
package com.njcn.harmonic.service.impl; package com.njcn.harmonic.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.harmonic.mapper.RStatDataVDMapper; import com.njcn.harmonic.common.mapper.RStatDataVDMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD; import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.service.IRStatDataVDService; import com.njcn.harmonic.service.IRStatDataVDService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.service.impl; package com.njcn.harmonic.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
@@ -19,8 +19,8 @@ import com.njcn.harmonic.pojo.param.TotalLimitStatisticsDetailsQueryParam;
import com.njcn.harmonic.pojo.param.TotalLimitStatisticsParam; import com.njcn.harmonic.pojo.param.TotalLimitStatisticsParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.*; import com.njcn.harmonic.pojo.vo.*;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService; import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.rstatlimitrate.service.impl; package com.njcn.harmonic.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Pair; import cn.hutool.core.lang.Pair;
@@ -24,9 +24,9 @@ import com.njcn.harmonic.pojo.vo.LimitCalendarVO;
import com.njcn.harmonic.pojo.vo.LimitExtentVO; import com.njcn.harmonic.pojo.vo.LimitExtentVO;
import com.njcn.harmonic.pojo.vo.LimitProbabilityVO; import com.njcn.harmonic.pojo.vo.LimitProbabilityVO;
import com.njcn.harmonic.pojo.vo.LimitTimeProbabilityVO; import com.njcn.harmonic.pojo.vo.LimitTimeProbabilityVO;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDetailDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDetailDMapper;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService; import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDetailDService; import com.njcn.harmonic.service.IRStatLimitRateDetailDService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;

View File

@@ -4,9 +4,9 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.harmonic.mapper.RStatDataHarmRateVDMapper; import com.njcn.harmonic.common.mapper.RStatDataHarmRateVDMapper;
import com.njcn.harmonic.mapper.RStatDataIDMapper; import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
import com.njcn.harmonic.mapper.RStatDataInharmVDMapper; import com.njcn.harmonic.common.mapper.RStatDataInharmVDMapper;
import com.njcn.harmonic.mapper.ReportMapper; import com.njcn.harmonic.mapper.ReportMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD; import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO; import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;
@@ -15,6 +15,7 @@ import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO; import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO;
import com.njcn.harmonic.pojo.po.report.OverLimitInfo; import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
import com.njcn.harmonic.pojo.vo.ReportValue; import com.njcn.harmonic.pojo.vo.ReportValue;
import com.njcn.harmonic.common.service.impl.RegroupDataComm;
import com.njcn.harmonic.service.IRStatDataVDService; import com.njcn.harmonic.service.IRStatDataVDService;
import com.njcn.harmonic.service.ReportService; import com.njcn.harmonic.service.ReportService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -74,9 +75,9 @@ public class ReportServiceImpl implements ReportService {
//获取线电压有效值 //获取线电压有效值
List<ReportValue> listVV = reportMapper.getVVirtualData(param); List<ReportValue> listVV = reportMapper.getVVirtualData(param);
RegroupData.regroupData(listV, true); RegroupDataComm.regroupData(listV, true);
RegroupData.regroupData(listI, true); RegroupDataComm.regroupData(listI, true);
RegroupData.regroupData(listVV, true); RegroupDataComm.regroupData(listVV, true);
list.addAll(listV); list.addAll(listV);
list.addAll(listI); list.addAll(listI);
list.addAll(listVV); list.addAll(listVV);
@@ -96,10 +97,10 @@ public class ReportServiceImpl implements ReportService {
//获取功率因数 //获取功率因数
List<ReportValue> listF = reportMapper.getPF(param); List<ReportValue> listF = reportMapper.getPF(param);
RegroupData.regroupData(listP, true, false); RegroupDataComm.regroupData(listP, true, false);
RegroupData.regroupData(listQ, true, false); RegroupDataComm.regroupData(listQ, true, false);
RegroupData.regroupData(listS, true, false); RegroupDataComm.regroupData(listS, true, false);
RegroupData.regroupData(listF, true, false); RegroupDataComm.regroupData(listF, true, false);
list.addAll(listP); list.addAll(listP);
list.addAll(listQ); list.addAll(listQ);
list.addAll(listS); list.addAll(listS);
@@ -116,8 +117,8 @@ public class ReportServiceImpl implements ReportService {
//长时闪变 //长时闪变
List<ReportValue> listLFlicker = reportMapper.getLFlickerData(param); List<ReportValue> listLFlicker = reportMapper.getLFlickerData(param);
RegroupData.regroupData(listFlicker, true); RegroupDataComm.regroupData(listFlicker, true);
RegroupData.regroupData(listLFlicker, true); RegroupDataComm.regroupData(listLFlicker, true);
list.addAll(listFlicker); list.addAll(listFlicker);
list.addAll(listLFlicker); list.addAll(listLFlicker);
@@ -132,8 +133,8 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> listU = reportMapper.getUVdeviationData(param); List<ReportValue> listU = reportMapper.getUVdeviationData(param);
List<ReportValue> listL = reportMapper.getLVdeviationData(param); List<ReportValue> listL = reportMapper.getLVdeviationData(param);
RegroupData.regroupData(listU, true); RegroupDataComm.regroupData(listU, true);
RegroupData.regroupData(listL, true); RegroupDataComm.regroupData(listL, true);
list.addAll(listU); list.addAll(listU);
list.addAll(listL); list.addAll(listL);
return list; return list;
@@ -148,8 +149,8 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> listI = reportMapper.getDistortionDataI(param); List<ReportValue> listI = reportMapper.getDistortionDataI(param);
//添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中 //添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中
RegroupData.regroupData(listU, true); RegroupDataComm.regroupData(listU, true);
RegroupData.regroupData(listI, true); RegroupDataComm.regroupData(listI, true);
list.addAll(listU); list.addAll(listU);
list.addAll(listI); list.addAll(listI);
@@ -164,8 +165,8 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> listFreDEV = reportMapper.getDEVFrequencyData(param); List<ReportValue> listFreDEV = reportMapper.getDEVFrequencyData(param);
RegroupData.regroupData(listFre, true); RegroupDataComm.regroupData(listFre, true);
RegroupData.regroupData(listFreDEV, true); RegroupDataComm.regroupData(listFreDEV, true);
list.addAll(listFre); list.addAll(listFre);
list.addAll(listFreDEV); list.addAll(listFreDEV);
return list; return list;
@@ -201,7 +202,7 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0); List<ReportValue> listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0);
if (CollUtil.isEmpty(listI)) { if (CollUtil.isEmpty(listI)) {
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
RegroupData.regroupData(list, true, true); RegroupDataComm.regroupData(list, true, true);
} }
} else { } else {
list.addAll(listI); list.addAll(listI);
@@ -217,7 +218,7 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> listV = dataV(param, Arrays.asList("A", "B", "C"), 1, 2, false, 5); List<ReportValue> listV = dataV(param, Arrays.asList("A", "B", "C"), 1, 2, false, 5);
if (CollUtil.isEmpty(listV)) { if (CollUtil.isEmpty(listV)) {
RegroupData.regroupData(list, true, true); RegroupDataComm.regroupData(list, true, true);
} else { } else {
list.addAll(listV); list.addAll(listV);
} }
@@ -227,7 +228,7 @@ public class ReportServiceImpl implements ReportService {
if (CollUtil.isEmpty(listRate)) { if (CollUtil.isEmpty(listRate)) {
for (int i = 0; i < 49; i++) { for (int i = 0; i < 49; i++) {
RegroupData.regroupData(list, true, true); RegroupDataComm.regroupData(list, true, true);
} }
} else { } else {
list.addAll(listRate); list.addAll(listRate);
@@ -235,7 +236,7 @@ public class ReportServiceImpl implements ReportService {
//获取电压畸变率 //获取电压畸变率
List<ReportValue> listU = reportMapper.getDistortionDataV(param); List<ReportValue> listU = reportMapper.getDistortionDataV(param);
RegroupData.regroupData(listU, true); RegroupDataComm.regroupData(listU, true);
list.addAll(listU); list.addAll(listU);
return list; return list;
} }
@@ -290,7 +291,7 @@ public class ReportServiceImpl implements ReportService {
}); });
if (CollUtil.isEmpty(a)) { if (CollUtil.isEmpty(a)) {
for (int i = 1; i < 17; i++) { for (int i = 1; i < 17; i++) {
RegroupData.regroupData(a, true, true); RegroupDataComm.regroupData(a, true, true);
} }
} }
return a; return a;
@@ -301,7 +302,7 @@ public class ReportServiceImpl implements ReportService {
List<ReportValue> list = new ArrayList<>(); List<ReportValue> list = new ArrayList<>();
//负序电流 //负序电流
List<ReportValue> iNegData = reportMapper.getINegData(param); List<ReportValue> iNegData = reportMapper.getINegData(param);
RegroupData.regroupData(iNegData, true); RegroupDataComm.regroupData(iNegData, true);
list.addAll(iNegData); list.addAll(iNegData);
return list; return list;
} }
@@ -310,7 +311,7 @@ public class ReportServiceImpl implements ReportService {
private void regroupData(List<ReportValue> list) { private void regroupData(List<ReportValue> list) {
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
List<ReportValue> list1 = new ArrayList<>(); List<ReportValue> list1 = new ArrayList<>();
RegroupData.regroupData(list1, false); RegroupDataComm.regroupData(list1, false);
list.addAll(list1); list.addAll(list1);
} }
} }

View File

@@ -20,8 +20,7 @@ import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.MonitorOverLimitVO; import com.njcn.harmonic.pojo.vo.MonitorOverLimitVO;
import com.njcn.harmonic.pojo.vo.SteadyExceedRateCensusVO; import com.njcn.harmonic.pojo.vo.SteadyExceedRateCensusVO;
import com.njcn.harmonic.pojo.vo.SteadyExceedRateVO; import com.njcn.harmonic.pojo.vo.SteadyExceedRateVO;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService;
import com.njcn.harmonic.service.SteadyExceedRateService; import com.njcn.harmonic.service.SteadyExceedRateService;
import com.njcn.harmonic.utils.PubUtils; import com.njcn.harmonic.utils.PubUtils;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant; import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
@@ -53,7 +52,6 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
private final GeneralDeviceInfoClient generalDeviceInfoClient; private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final SteadyExceedRateMapper steadyExceedRateMapper; private final SteadyExceedRateMapper steadyExceedRateMapper;
private final IRStatLimitRateDService rateDService;
private final RStatLimitRateDMapper rateDMapper; private final RStatLimitRateDMapper rateDMapper;
private final UserLedgerFeignClient userLedgerFeignClient; private final UserLedgerFeignClient userLedgerFeignClient;
@@ -531,7 +529,7 @@ public class SteadyExceedRateServiceImpl implements SteadyExceedRateService {
*/ */
private List<LimitRatePO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) { private List<LimitRatePO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) {
List<LimitRatePO> limitRatePOS = new ArrayList<>(); List<LimitRatePO> limitRatePOS = new ArrayList<>();
List<RStatLimitRateDPO> limitRates = rateDService.list(new LambdaQueryWrapper<RStatLimitRateDPO>() List<RStatLimitRateDPO> limitRates = rateDMapper.selectList(new LambdaQueryWrapper<RStatLimitRateDPO>()
.in(RStatLimitRateDPO::getLineId, lineIndexes) .in(RStatLimitRateDPO::getLineId, lineIndexes)
.eq(RStatLimitRateDPO::getPhasicType, InfluxDBTableConstant.PHASE_TYPE_T) .eq(RStatLimitRateDPO::getPhasicType, InfluxDBTableConstant.PHASE_TYPE_T)
.ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime))) .ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))

View File

@@ -13,12 +13,12 @@ import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO; import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam; import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.vo.LineDetailVO; import com.njcn.device.pq.pojo.vo.LineDetailVO;
import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.mapper.SteadyQualifyMapper; import com.njcn.harmonic.mapper.SteadyQualifyMapper;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyCensusVO; import com.njcn.harmonic.pojo.vo.SteadyQualifyCensusVO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyDetailVO; import com.njcn.harmonic.pojo.vo.SteadyQualifyDetailVO;
import com.njcn.harmonic.pojo.vo.SteadyQualifyVO; import com.njcn.harmonic.pojo.vo.SteadyQualifyVO;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService;
import com.njcn.harmonic.service.SteadyQualifyService; import com.njcn.harmonic.service.SteadyQualifyService;
import com.njcn.harmonic.utils.PubUtils; import com.njcn.harmonic.utils.PubUtils;
import com.njcn.supervision.api.UserLedgerFeignClient; import com.njcn.supervision.api.UserLedgerFeignClient;
@@ -45,7 +45,7 @@ public class SteadyQualifyServiceImpl implements SteadyQualifyService {
private final SteadyQualifyMapper steadyQualifyMapper; private final SteadyQualifyMapper steadyQualifyMapper;
private final IRStatLimitRateDService rateDService; private final RStatLimitRateDMapper rStatLimitRateDMapper;
private final UserLedgerFeignClient userLedgerFeignClient; private final UserLedgerFeignClient userLedgerFeignClient;
@@ -543,7 +543,7 @@ public class SteadyQualifyServiceImpl implements SteadyQualifyService {
* @param endTime * @param endTime
*/ */
private List<RStatLimitRateDPO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) { private List<RStatLimitRateDPO> getQualifiesRate(List<String> lineIndexes, String startTime, String endTime) {
return rateDService.list(new LambdaQueryWrapper<RStatLimitRateDPO>() return rStatLimitRateDMapper.selectList(new LambdaQueryWrapper<RStatLimitRateDPO>()
.in(RStatLimitRateDPO::getLineId, lineIndexes) .in(RStatLimitRateDPO::getLineId, lineIndexes)
.eq(RStatLimitRateDPO::getPhasicType, "T") .eq(RStatLimitRateDPO::getPhasicType, "T")
.ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime))) .ge(StrUtil.isNotBlank(startTime), RStatLimitRateDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))

View File

@@ -1,9 +1,6 @@
package com.njcn.harmonic.service.majornetwork.impl; package com.njcn.harmonic.service.majornetwork.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.param.StatisticsBizBaseParam; import com.njcn.common.pojo.param.StatisticsBizBaseParam;
@@ -16,7 +13,7 @@ import com.njcn.harmonic.pojo.param.RMpPartHarmonicDetailQueryParam;
import com.njcn.harmonic.pojo.po.RMpPartHarmonicDetailD; import com.njcn.harmonic.pojo.po.RMpPartHarmonicDetailD;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO; import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.vo.RMpPartHarmonicDetailIconVO; import com.njcn.harmonic.pojo.vo.RMpPartHarmonicDetailIconVO;
import com.njcn.harmonic.rstatlimitrate.service.IRStatLimitRateDService; import com.njcn.harmonic.service.IRStatLimitRateDService;
import com.njcn.harmonic.service.majornetwork.RMpPartHarmonicDetailDService; import com.njcn.harmonic.service.majornetwork.RMpPartHarmonicDetailDService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;

View File

@@ -33,7 +33,7 @@ import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.MonitorLimitRateVO; import com.njcn.harmonic.pojo.vo.MonitorLimitRateVO;
import com.njcn.harmonic.pojo.vo.PwLimitDataVO; import com.njcn.harmonic.pojo.vo.PwLimitDataVO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO; import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.IRStatLimitTargetDService; import com.njcn.harmonic.service.IRStatLimitTargetDService;
import com.njcn.harmonic.service.majornetwork.RStatLimitService; import com.njcn.harmonic.service.majornetwork.RStatLimitService;
import com.njcn.system.pojo.enums.StatisticsEnum; import com.njcn.system.pojo.enums.StatisticsEnum;

View File

@@ -3,7 +3,7 @@ package com.njcn.harmonic.service.report;
import com.njcn.harmonic.pojo.param.ReportSearchParam; import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp; import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.vo.ReportTreeVO; import com.njcn.harmonic.pojo.vo.ReportTreeVO;
import com.njcn.harmonic.pojo.vo.SysDeptTempVO; import com.njcn.harmonic.pojo.vo.SysDeptTempVO;

View File

@@ -1,5 +1,6 @@
package com.njcn.harmonic.service.report.impl; package com.njcn.harmonic.service.report.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
@@ -20,10 +21,13 @@ import com.njcn.csdevice.api.WlRecordFeignClient;
import com.njcn.csdevice.pojo.po.WlRecord; import com.njcn.csdevice.pojo.po.WlRecord;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient; import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit; import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.device.pq.pojo.vo.PqsDeviceUnitVo;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.common.service.CustomReportTableService;
import com.njcn.harmonic.enums.HarmonicResponseEnum; import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.mapper.DeptTempMapper; import com.njcn.harmonic.mapper.DeptTempMapper;
import com.njcn.harmonic.mapper.EleEpdMapper; import com.njcn.harmonic.mapper.EleEpdMapper;
import com.njcn.harmonic.mapper.ExcelRptTempMapper; import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO; import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.harmonic.pojo.param.ReportSearchParam; import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.param.ReportTemplateParam; import com.njcn.harmonic.pojo.param.ReportTemplateParam;
@@ -39,7 +43,7 @@ import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.harmonic.pojo.po.ExcelRptTemp; import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.po.SysDeptTemp; import com.njcn.harmonic.pojo.po.SysDeptTemp;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.harmonic.pojo.vo.ReportTreeVO; import com.njcn.harmonic.pojo.vo.ReportTreeVO;
import com.njcn.harmonic.pojo.vo.SysDeptTempVO; import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
import com.njcn.harmonic.service.report.CustomReportService; import com.njcn.harmonic.service.report.CustomReportService;
@@ -98,10 +102,12 @@ public class CustomReportServiceImpl implements CustomReportService {
private final CsCommTerminalFeignClient csCommTerminalFeignClient; private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final CustomReportTableService customReportTableService;
private final WlRecordFeignClient wlRecordFeignClient; private final WlRecordFeignClient wlRecordFeignClient;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1); private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
private final String CELL_DATA = "celldata"; private final String CELL_DATA = "celldata";
private final String V = "v"; private final String V = "v";
private final String STR_ONE = "#"; private final String STR_ONE = "#";
@@ -114,15 +120,20 @@ public class CustomReportServiceImpl implements CustomReportService {
@Override @Override
public void getCustomReport(ReportSearchParam reportSearchParam, HttpServletResponse response) { public void getCustomReport(ReportSearchParam reportSearchParam, HttpServletResponse response) {
TimeInterval timeInterval = new TimeInterval(); TimeInterval timeInterval = new TimeInterval();
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
if (Objects.isNull(reportSearchParam.getCustomType())) { if (Objects.isNull(reportSearchParam.getCustomType())) {
//通用报表 //通用报表
analyzeReport(reportSearchParam, excelRptTemp, response); PqsDeviceUnit deviceUnit = commTerminalGeneralClient.lineUnitDetail(reportSearchParam.getLineId()).getData();
DeviceUnitCommDTO deviceUnitCommDTO = BeanUtil.copyProperties(deviceUnit, DeviceUnitCommDTO.class);
Map<String,String> finalTerminalMap = convertKeysToUpperCase(commTerminalGeneralClient.getCustomDetailByLineId(reportSearchParam.getLineId()).getData());
customReportTableService.getCustomReport(reportSearchParam,finalTerminalMap,deviceUnitCommDTO, response);
} else { } else {
//浙江无线报表 //浙江无线报表
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
analyzeReportZhejiang(reportSearchParam, excelRptTemp, response); analyzeReportZhejiang(reportSearchParam, excelRptTemp, response);
} }
@@ -859,6 +870,7 @@ public class CustomReportServiceImpl implements CustomReportService {
* @date 2023/10/8 * @date 2023/10/8
*/ */
/*
private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, HttpServletResponse response) { private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, HttpServletResponse response) {
//定义一个线程集合 //定义一个线程集合
List<Future<?>> futures = new ArrayList<>(); List<Future<?>> futures = new ArrayList<>();
@@ -1029,13 +1041,14 @@ public class CustomReportServiceImpl implements CustomReportService {
downReport(jsonArray, response); downReport(jsonArray, response);
} }
*/
/** /**
* 解析模板 * 解析模板
* @author cdf * @author cdf
* @date 2023/10/20 * @date 2023/10/20
*/ */
private void parseTemplate(JSONArray jsonArray, List<ReportTemplateDTO> reportTemplateDTOList, List<ReportTemplateDTO> reportLimitList, List<ReportTemplateDTO> terminalList) { /* private void parseTemplate(JSONArray jsonArray, List<ReportTemplateDTO> reportTemplateDTOList, List<ReportTemplateDTO> reportLimitList, List<ReportTemplateDTO> terminalList) {
try { try {
//通过文件服务器获取 //通过文件服务器获取
jsonArray.forEach(item -> { jsonArray.forEach(item -> {
@@ -1103,7 +1116,7 @@ public class CustomReportServiceImpl implements CustomReportService {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON); throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
} }
} }
*/
/** /**
* 获取测点限值 * 获取测点限值
@@ -1167,6 +1180,115 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
/**
* 对多测点数据进行计算求出一组数据
* @param method
* @param allList
* @return
*/
private Map<String, Object> dealResultMap(String method, List<Map<String, Object>> allList) {
Map<String, Object> resultMap = new HashMap<>();
// 遍历列表中的每个Map
if (method.equals(InfluxDbSqlConstant.MIN)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) > value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.MAX) || method.equals(InfluxDbSqlConstant.PERCENTILE)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) < value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.AVG)) {
Map<String, Double> sumMap = new HashMap<>();
Map<String, Integer> countMap = new HashMap<>();
// 遍历列表中的每个Map
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 更新累计和
sumMap.put(key, sumMap.getOrDefault(key, 0.0) + value);
// 更新计数
countMap.put(key, countMap.getOrDefault(key, 0) + 1);
}
}
}
// 计算平均值并存储到结果Map中
for (String key : sumMap.keySet()) {
double sum = sumMap.get(key);
int count = countMap.get(key);
double average = BigDecimal.valueOf(sum / count).setScale(3, RoundingMode.HALF_UP).doubleValue();
resultMap.put(key, average);
}
}
return resultMap;
}
/**
* 处理指标超标结论
*/
private void dealTargetResult
(Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) {
assNoPassMap.forEach((key, val) -> {
limitTargetMapX.remove(key);
if ("Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
val.setValue("±" + val.getValue());
}
String expend = "";
if(Objects.nonNull(val.getLowValue())){
expend = val.getLowValue()+",";
}
if (val.getOverLimitFlag() == 1) {
val.setValue("不合格 (" + expend+val.getValue() + ")");
} else {
val.setValue("合格 (" + expend+val.getValue() + ")");
}
endList.add(val);
});
limitTargetMapX.forEach((key, val) -> {
if (Objects.isNull(val.getOverLimitFlag())) {
val.setValue("/");
} else {
val.setValue("合格");
}
endList.add(val);
});
}
private void analyzeReportZhejiang(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, HttpServletResponse response) { private void analyzeReportZhejiang(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, HttpServletResponse response) {
//指标 //指标
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>(); List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
@@ -1438,178 +1560,6 @@ public class CustomReportServiceImpl implements CustomReportService {
endList.addAll(data); endList.addAll(data);
} }
/**
* 对多测点数据进行计算求出一组数据
* @param method
* @param allList
* @return
*/
private Map<String, Object> dealResultMap(String method, List<Map<String, Object>> allList) {
Map<String, Object> resultMap = new HashMap<>();
// 遍历列表中的每个Map
if (method.equals(InfluxDbSqlConstant.MIN)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) > value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.MAX) || method.equals(InfluxDbSqlConstant.PERCENTILE)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) < value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.AVG)) {
Map<String, Double> sumMap = new HashMap<>();
Map<String, Integer> countMap = new HashMap<>();
// 遍历列表中的每个Map
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 更新累计和
sumMap.put(key, sumMap.getOrDefault(key, 0.0) + value);
// 更新计数
countMap.put(key, countMap.getOrDefault(key, 0) + 1);
}
}
}
// 计算平均值并存储到结果Map中
for (String key : sumMap.keySet()) {
double sum = sumMap.get(key);
int count = countMap.get(key);
double average = BigDecimal.valueOf(sum / count).setScale(3, RoundingMode.HALF_UP).doubleValue();
resultMap.put(key, average);
}
}
return resultMap;
}
private void dealExcelResult(JSONArray
jsonArray, Map<String, List<ReportTemplateDTO>> assMap, Map<String, String> unit,Map<String,String> finalTerminalMap) {
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get(CELL_DATA);
itemArr.forEach((it) -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
//获取到1列
JSONObject data = (JSONObject) it;
JSONObject son = (JSONObject) data.get(V);
if (son.containsKey(V)) {
String v = son.getStr(V);
//数据格式:$HA[_25]#B#max#classId$ 或 $HA[_25]#max#classId$
if (v.charAt(0) == '$' && v.contains(STR_ONE)) {
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_TWO, ""));
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if (Objects.nonNull(rDto.get(0).getOverLimitFlag()) && rDto.get(0).getOverLimitFlag() == 1) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '%' && v.contains(STR_ONE)) {
//指标合格情况
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_FOUR, ""));
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if ("不合格".equals(str)) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '&') {
//结论
String tem = v.replace(STR_THREE, "");
if (Objects.nonNull(finalTerminalMap)) {
if ("statis_time".equals(tem)) {
// son.set(V, reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + InfluxDbSqlConstant.END_TIME);
} else {
//台账信息
son.set(V, finalTerminalMap.getOrDefault(tem, "/"));
}
}
} else if (v.charAt(0) == '@' && v.contains(STR_ONE)) {
//解决数据单位问题 @指标#类型@
String replace = v.replace("@", "");
son.set(V, unit.getOrDefault(replace, "/"));
}
}
}
});
});
}
/**
* 处理指标超标结论
*/
private void dealTargetResult
(Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) {
assNoPassMap.forEach((key, val) -> {
limitTargetMapX.remove(key);
if ("Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
val.setValue("±" + val.getValue());
}
String expend = "";
if(Objects.nonNull(val.getLowValue())){
expend = val.getLowValue()+",";
}
if (val.getOverLimitFlag() == 1) {
val.setValue("不合格 (" + expend+val.getValue() + ")");
} else {
val.setValue("合格 (" + expend+val.getValue() + ")");
}
endList.add(val);
});
limitTargetMapX.forEach((key, val) -> {
if (Objects.isNull(val.getOverLimitFlag())) {
val.setValue("/");
} else {
val.setValue("合格");
}
endList.add(val);
});
}
/** /**
* 解析模板 * 解析模板
* *
@@ -1689,6 +1639,74 @@ public class CustomReportServiceImpl implements CustomReportService {
} }
} }
private void dealExcelResult(JSONArray
jsonArray, Map<String, List<ReportTemplateDTO>> assMap, Map<String, String> unit,Map<String,String> finalTerminalMap) {
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get(CELL_DATA);
itemArr.forEach((it) -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
//获取到1列
JSONObject data = (JSONObject) it;
JSONObject son = (JSONObject) data.get(V);
if (son.containsKey(V)) {
String v = son.getStr(V);
//数据格式:$HA[_25]#B#max#classId$ 或 $HA[_25]#max#classId$
if (v.charAt(0) == '$' && v.contains(STR_ONE)) {
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_TWO, ""));
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if (Objects.nonNull(rDto.get(0).getOverLimitFlag()) && rDto.get(0).getOverLimitFlag() == 1) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '%' && v.contains(STR_ONE)) {
//指标合格情况
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_FOUR, ""));
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if ("不合格".equals(str)) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '&') {
//结论
String tem = v.replace(STR_THREE, "");
if (Objects.nonNull(finalTerminalMap)) {
if ("statis_time".equals(tem)) {
// son.set(V, reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + InfluxDbSqlConstant.END_TIME);
} else {
//台账信息
son.set(V, finalTerminalMap.getOrDefault(tem, "/"));
}
}
} else if (v.charAt(0) == '@' && v.contains(STR_ONE)) {
//解决数据单位问题 @指标#类型@
String replace = v.replace("@", "");
son.set(V, unit.getOrDefault(replace, "/"));
}
}
}
});
});
}
public static boolean isInteger(String str) { public static boolean isInteger(String str) {
try { try {
Integer.parseInt(str); Integer.parseInt(str);

View File

@@ -13,17 +13,15 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.pms.api.LineIntegrityDataClient; import com.njcn.device.pms.api.LineIntegrityDataClient;
import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.MonitorClient;
import com.njcn.device.pms.api.PmsMidLedgerClient;
import com.njcn.device.pms.pojo.param.DataQualityDetailsParam; import com.njcn.device.pms.pojo.param.DataQualityDetailsParam;
import com.njcn.device.pms.pojo.po.Monitor; import com.njcn.device.pms.pojo.po.Monitor;
import com.njcn.device.pq.pojo.po.RStatIntegrityD; import com.njcn.device.pq.pojo.po.RStatIntegrityD;
import com.njcn.harmonic.mapper.RStatDataVDMapper; import com.njcn.harmonic.common.mapper.RStatDataVDMapper;
import com.njcn.harmonic.mapper.upload.*; import com.njcn.harmonic.mapper.upload.*;
import com.njcn.harmonic.pojo.dto.upload.PqEvaluationCreateDTO; import com.njcn.harmonic.pojo.dto.upload.PqEvaluationCreateDTO;
import com.njcn.harmonic.pojo.dto.upload.RDimUpDTO; import com.njcn.harmonic.pojo.dto.upload.RDimUpDTO;
@@ -35,7 +33,7 @@ import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.upload.*; import com.njcn.harmonic.pojo.po.upload.*;
import com.njcn.harmonic.pojo.vo.upload.DimBusBarVO; import com.njcn.harmonic.pojo.vo.upload.DimBusBarVO;
import com.njcn.harmonic.pojo.vo.upload.UploadEvaluationDataVo; import com.njcn.harmonic.pojo.vo.upload.UploadEvaluationDataVo;
import com.njcn.harmonic.rstatlimitrate.mapper.RStatLimitRateDMapper; import com.njcn.harmonic.mapper.RStatLimitRateDMapper;
import com.njcn.harmonic.service.upload.IEvaluationDataService; import com.njcn.harmonic.service.upload.IEvaluationDataService;
import com.njcn.harmonic.service.upload.IRUploadDataLogService; import com.njcn.harmonic.service.upload.IRUploadDataLogService;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;

View File

@@ -35,11 +35,11 @@ spring:
- data-id: share-config.yaml - data-id: share-config.yaml
refresh: true refresh: true
#数据中心使用 #数据中心使用
# - data-Id: share-config-datasource-db.yaml - data-Id: share-config-datasource-db.yaml
# refresh: true
#PMS使用
- data-Id: share-config-harmonic-db.yaml
refresh: true refresh: true
#PMS使用
# - data-Id: share-config-harmonic-db.yaml
# refresh: true
main: main:
allow-bean-definition-overriding: true allow-bean-definition-overriding: true
servlet: servlet:

View File

@@ -24,6 +24,11 @@
<artifactId>harmonic-api</artifactId> <artifactId>harmonic-api</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>system-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency> <dependency>
<groupId>com.njcn</groupId> <groupId>com.njcn</groupId>
<artifactId>cs-device-api</artifactId> <artifactId>cs-device-api</artifactId>
@@ -37,4 +42,4 @@
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -1,20 +1,17 @@
package com.njcn.harmonic.mapper; package com.njcn.harmonic.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.harmonic.pojo.param.ReportSearchParam; import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp; import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.pojo.vo.ReportTemplateVO; import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO; import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.user.pojo.dto.DeptDTO;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* pqs * pqs

View File

@@ -0,0 +1,137 @@
package com.njcn.harmonic.common.mapper;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.vo.ReportValue;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 谐波报告查询
*/
public interface MonitorCommReportMapper {
/**
* 获取电流有效值
* @return
*/
List<ReportValue> getVirtualDataI(@Param("param") ReportQueryParam param);
/**
* 获取电压有效值
* @return
*/
List<ReportValue> getVirtualDataV(@Param("param") ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param);
/**
* CP95条数
* @param param
* @return
*/
Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param);
List<ReportValue> getVVirtualData(@Param("param")ReportQueryParam param);
/**
* 获取有功功率
* @param param
* @return
*/
List<ReportValue> getPowerP(@Param("param")ReportQueryParam param);
/**
* 无功功率
* @param param
* @return
*/
List<ReportValue> getPowerQ(@Param("param")ReportQueryParam param);
/**
* 视在功率
* @param param
* @return
*/
List<ReportValue> getPowerS(@Param("param")ReportQueryParam param);
/**
* 功率因数
* @param param
* @return
*/
List<ReportValue> getPF(@Param("param")ReportQueryParam param);
/**
* 短时闪变
* @param param
* @return
*/
List<ReportValue> getFlickerData(@Param("param")ReportQueryParam param);
/**
* 长时闪变
* @param param
* @return
*/
List<ReportValue> getLFlickerData(@Param("param")ReportQueryParam param);
/**
* 电压负偏差
* @param param
* @return
*/
List<ReportValue> getUVdeviationData(@Param("param")ReportQueryParam param);
/**
* 电压正偏差
* @param param
* @return
*/
List<ReportValue> getLVdeviationData(@Param("param")ReportQueryParam param);
/**
* 获取电压畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataV(@Param("param")ReportQueryParam param);
/**
* 获取电流畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionDataI(@Param("param")ReportQueryParam param);
/**
*频率
* @param param
* @return
*/
List<ReportValue> getFrequencyData(@Param("param")ReportQueryParam param);
/**
*频率
* @param param
* @return
*/
List<ReportValue> getDEVFrequencyData(@Param("param")ReportQueryParam param);
/**
* 负序电流
* @param param
* @return
*/
List<ReportValue> getINegData(@Param("param")ReportQueryParam param);
}

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.mapper; package com.njcn.harmonic.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO; import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;

View File

@@ -1,9 +1,7 @@
package com.njcn.harmonic.mapper; package com.njcn.harmonic.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO; import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.mapper; package com.njcn.harmonic.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO; import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO;

View File

@@ -1,8 +1,7 @@
package com.njcn.harmonic.mapper; package com.njcn.harmonic.common.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.harmonic.pojo.po.RStatDataVD; import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.mapper.ExcelRptTempMapper"> <mapper namespace="com.njcn.harmonic.common.mapper.ExcelRptTempMapper">
<select id="getReportTemplateListPage" resultType="ReportTemplateVO"> <select id="getReportTemplateListPage" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
select select
a.id, a.id,
a.name, a.name,
@@ -23,7 +23,7 @@
</if> </if>
</select> </select>
<select id="getReportTemplateList" resultType="ReportTemplateVO"> <select id="getReportTemplateList" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
SELECT SELECT
a.id, a.id,
a.NAME, a.NAME,
@@ -40,7 +40,7 @@
a.state = 1 a.state = 1
</select> </select>
<select id="getReportTemplateByDept" resultType="ReportTemplateVO"> <select id="getReportTemplateByDept" resultType="com.njcn.harmonic.common.pojo.vo.ReportTemplateVO">
SELECT SELECT
DISTINCT DISTINCT
a.id, a.id,
@@ -53,10 +53,6 @@
LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id LEFT JOIN sys_dept_temp b ON a.Id = b.temp_id
WHERE WHERE
a.activation = 1 a.activation = 1
and b.dept_id in
<foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
#{item}
</foreach>
order by a.sort asc order by a.sort asc
</select> </select>
</mapper> </mapper>

View File

@@ -0,0 +1,467 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.harmonic.common.mapper.MonitorCommReportMapper">
<select id="getVirtualDataI" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN rms END ) AS cp95Value
FROM
r_stat_data_i_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getVirtualDataV" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN rms END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getTotalCP95Day" resultType="java.lang.Integer">
SELECT
count( rms ) total
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getTotalPltCP95Day" resultType="java.lang.Integer">
SELECT
count( plt ) total
FROM
r_stat_data_plt_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getTotalPstCP95Day" resultType="java.lang.Integer">
SELECT
count( pst ) total
FROM
r_stat_data_flicker_d
<where>
phasic_type IN ( 'A' )
AND value_type = "CP95"
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
</select>
<select id="getVVirtualData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN rms_lvr END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN rms_lvr END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN rms_lvr END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN rms_lvr END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getPowerP" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN p END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN p END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN p END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN p END ) AS cp95Value
FROM
r_stat_data_harmpower_p_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getPF" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN pf END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN pf END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN pf END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN pf END ) AS cp95Value
FROM
r_stat_data_harmpower_p_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getPowerQ" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN q END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN q END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN q END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN q END ) AS cp95Value
FROM
r_stat_data_harmpower_q_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getPowerS" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN s END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN s END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN s END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN s END ) AS cp95Value
FROM
r_stat_data_harmpower_s_d
<where>
phasic_type IN ( 'A', 'B', 'C' ,'T')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<!-- 短闪字段错了-->
<select id="getFlickerData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN pst END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN pst END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN pst END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN pst END ) AS cp95Value
FROM
r_stat_data_flicker_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<!-- 长闪表查错了-->
<select id="getLFlickerData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN plt END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN plt END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN plt END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN plt END ) AS cp95Value
FROM
r_stat_data_plt_d
<where>
phasic_type IN ( 'A', 'B', 'C')
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type
</select>
<select id="getUVdeviationData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN vu_dev END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN vu_dev END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN vu_dev END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN vu_dev END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getLVdeviationData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN vl_dev END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN vl_dev END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN vl_dev END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN vl_dev END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getDistortionDataV" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN v_thd END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN v_thd END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN v_thd END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN v_thd END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getDistortionDataI" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN i_thd END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN i_thd END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN i_thd END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN i_thd END ) AS cp95Value
FROM
r_stat_data_i_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getFrequencyData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN freq END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN freq END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN freq END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN freq END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type = 'T'
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getDEVFrequencyData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN freq_dev END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN freq_dev END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN freq_dev END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN freq_dev END ) AS cp95Value
FROM
r_stat_data_v_d
<where>
phasic_type = 'T'
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
<select id="getINegData" resultType="com.njcn.harmonic.pojo.vo.ReportValue">
SELECT
phasic_type AS phaseType,
AVG( CASE WHEN value_type = 'AVG' THEN i_neg END ) AS meanValue,
MIN( CASE WHEN value_type = 'MIN' THEN i_neg END ) AS minValue,
MAX( CASE WHEN value_type = 'MAX' THEN i_neg END ) AS fmaxValue,
MAX( CASE WHEN value_type = 'CP95' THEN i_neg END ) AS cp95Value
FROM
r_stat_data_i_d
<where>
phasic_type IN ( 'A', 'B', 'C' )
and quality_flag = 0
<if test="param.startTime != null and param.startTime != ''">
and time >= #{param.startTime}
</if>
<if test="param.endTime != null and param.endTime != ''">
and time &lt;= #{param.endTime}
</if>
<if test="param.lineId != null and param.lineId != ''">
and line_id = #{param.lineId}
</if>
</where>
GROUP BY
phasic_type;
</select>
</mapper>

View File

@@ -0,0 +1,117 @@
package com.njcn.harmonic.common.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Data
public class DeviceUnitCommDTO {
private static final long serialVersionUID = 1L;
@TableId(value = "DEV_INDEX")
@ApiModelProperty(value = "终端编号")
private String devIndex;
@TableField("UNIT_FREQUENCY")
@ApiModelProperty(value = "频率")
private String unitFrequency = "Hz";
@TableField("UNIT_FREQUENCY_DEV")
@ApiModelProperty(value = "频率偏差")
private String unitFrequencyDev = "Hz";
@TableField("PHASE_VOLTAGE")
@ApiModelProperty(value = "相电压有效值")
private String phaseVoltage = "kV";
@TableField("LINE_VOLTAGE")
@ApiModelProperty(value = "线电压有效值")
private String lineVoltage = "kV";
@TableField("VOLTAGE_DEV")
@ApiModelProperty(value = "电压上偏差")
private String voltageDev = "%";
@TableField("UVOLTAGE_DEV")
@ApiModelProperty(value = "电压下偏差")
private String uvoltageDev = "%";
@TableField("I_EFFECTIVE")
@ApiModelProperty(value = "电流有效值")
private String ieffective = "A";
@TableField("SINGLE_P")
@ApiModelProperty(value = "单相有功功率")
private String singleP = "kW";
@TableField("SINGLE_VIEW_P")
@ApiModelProperty(value = "单相视在功率")
private String singleViewP = "kVA";
@TableField("SINGLE_NO_P")
@ApiModelProperty(value = "单相无功功率")
private String singleNoP = "kVar";
@TableField("TOTAL_ACTIVE_P")
@ApiModelProperty(value = "总有功功率")
private String totalActiveP = "kW";
@TableField("TOTAL_VIEW_P")
@ApiModelProperty(value = "总视在功率")
private String totalViewP = "kVA";
@TableField("TOTAL_NO_P")
@ApiModelProperty(value = "总无功功率")
private String totalNoP = "kVar";
@TableField("V_FUND_EFFECTIVE")
@ApiModelProperty(value = "相(线)电压基波有效值")
private String vfundEffective = "kV";
@TableField("I_FUND")
@ApiModelProperty(value = "基波电流")
private String ifund = "A";
@TableField("FUND_ACTIVE_P")
@ApiModelProperty(value = "基波有功功率")
private String fundActiveP = "kW";
@TableField("FUND_NO_P")
@ApiModelProperty(value = "基波无功功率")
private String fundNoP = "kVar";
@TableField("V_DISTORTION")
@ApiModelProperty(value = "电压总谐波畸变率")
private String vdistortion = "%";
@TableField("V_HARMONIC_RATE")
@ApiModelProperty(value = "250次谐波电压含有率")
private String vharmonicRate = "%";
@TableField("I_HARMONIC")
@ApiModelProperty(value = "250次谐波电流有效值")
private String iharmonic = "A";
@TableField("P_HARMONIC")
@ApiModelProperty(value = "250次谐波有功功率")
private String pharmonic = "kW";
@TableField("I_IHARMONIC")
@ApiModelProperty(value = "0.549.5次间谐波电流有效值")
private String iiharmonic = "A";
@TableField("POSITIVE_V")
@ApiModelProperty(value = "正序电压")
private String positiveV = "kV";
@TableField("NO_POSITIVE_V")
@ApiModelProperty(value = "零序负序电压")
private String noPositiveV = "V";
}

View File

@@ -0,0 +1,134 @@
package com.njcn.harmonic.common.pojo.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Data
public class HarmLineDetailDataCommDTO {
private String lineId;
@ApiModelProperty(name = "id",value = "监测点序号")
private Integer id;
@ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName;
@ApiModelProperty(name = "areaName",value = "工程名称")
private String areaName;
@ApiModelProperty(name = "gdName",value = "单位")
private String gdName;
@ApiModelProperty(name = "bdName",value = "部门")
private String bdName;
@ApiModelProperty(name = "scale",value = "电压等级")
private String scale;
@ApiModelProperty(name = "manufacturer",value = "厂家")
private String manufacturer;
@ApiModelProperty(name = "devId",value = "终端Id")
private String devId;
@ApiModelProperty(name = "devName",value = "终端名称")
private String devName;
@ApiModelProperty(name = "ip",value = "网络参数")
private String ip;
@ApiModelProperty(name = "runFlag",value = "终端运行状态")
private String runFlag;
@ApiModelProperty(name = "comFlag",value = "通讯状态")
private String comFlag;
@ApiModelProperty(name = "loadType",value = "干扰源类型")
private String loadType;
@ApiModelProperty(name = "businessType",value = "行业类型")
private String businessType;
@ApiModelProperty(name = "objName",value = "监测点对象名称")
private String objName;
@ApiModelProperty(name = "ptType",value = "接线方式")
private String ptType;
@ApiModelProperty(name = "pt",value = "PT变比")
private String pt;
@ApiModelProperty(name = "ct",value = "CT变比")
private String ct;
@ApiModelProperty(name = "standardCapacity",value = "基准容量MVA")
private Float standardCapacity;
@ApiModelProperty(name = "shortCapacity",value = "最小短路容量MVA")
private Float shortCapacity;
@ApiModelProperty(name = "devCapacity",value = "供电设备容量MVA")
private Float devCapacity;
@ApiModelProperty(name = "dealCapacity",value = "用户协议容量MVA")
private Float dealCapacity;
@ApiModelProperty(name = "powerFlag",value = "电网标志0-电网侧1-非电网侧)")
private Integer powerFlag;
/**
* 测量间隔1-10分钟
*/
@ApiModelProperty(name = "timeInterval",value = "测量间隔1-10分钟")
private Integer timeInterval;
/**
* 监测点拥有者
*/
@ApiModelProperty(name = "owner",value = "监测点拥有者")
private String owner;
/**
* 拥有者职务
*/
@ApiModelProperty(name = "ownerDuty",value = "拥有者职务")
private String ownerDuty;
/**
* 拥有者联系方式
*/
@ApiModelProperty(name = "ownerTel",value = "拥有者联系方式")
private String ownerTel;
/**
* 接线图
*/
@ApiModelProperty(name = "wiringDiagram",value = "接线图")
private String wiringDiagram;
@ApiModelProperty(name = "ptPhaseType",value = "监测点接线相别0单相,1三相默认三相")
private Integer ptPhaseType;
@ApiModelProperty(name = "投运日期")
private LocalDate loginTime;
@ApiModelProperty(name = "最新数据时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
@ApiModelProperty(name = "监测对象信息ID")
private String objId;
@ApiModelProperty(name = "对象类型大类")
private String bigObjType;
}

View File

@@ -0,0 +1,870 @@
package com.njcn.harmonic.common.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.io.Serializable;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
@Data
public class OverLimitInfoCommDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 监测点序号
*/
private String id;
/**
* 频率限值
*/
private Float freqDev;
/**
* 电压波动
*/
private Float voltageFluctuation;
/**
* 电压上偏差限值
*/
private Float voltageDev;
/**
* 电压下偏差限值
*/
private Float uvoltageDev;
/**
* 三相电压不平衡度限值
*/
private Float ubalance;
/**
* 短时电压不平衡度限值
*/
private Float shortUbalance;
/**
* 闪变限值
*/
private Float flicker;
/**
* 电压总谐波畸变率限值
*/
private Float uaberrance;
/**
* 负序电流限值
*/
private Float iNeg;
/**
* 2次谐波电压限值
*/
@TableField("uharm_2")
private Float uharm2;
/**
* 3次谐波电压限值
*/
@TableField("uharm_3")
private Float uharm3;
/**
* 4次谐波电压限值
*/
@TableField("uharm_4")
private Float uharm4;
/**
* 5次谐波电压限值
*/
@TableField("uharm_5")
private Float uharm5;
/**
* 6次谐波电压限值
*/
@TableField("uharm_6")
private Float uharm6;
/**
* 7次谐波电压限值
*/
@TableField("uharm_7")
private Float uharm7;
/**
* 8次谐波电压限值
*/
@TableField("uharm_8")
private Float uharm8;
/**
* 9次谐波电压限值
*/
@TableField("uharm_9")
private Float uharm9;
/**
* 10次谐波电压限值
*/
@TableField("uharm_10")
private Float uharm10;
/**
* 11次谐波电压限值
*/
@TableField("uharm_11")
private Float uharm11;
/**
* 12次谐波电压限值
*/
@TableField("uharm_12")
private Float uharm12;
/**
* 13次谐波电压限值
*/
@TableField("uharm_13")
private Float uharm13;
/**
* 14次谐波电压限值
*/
@TableField("uharm_14")
private Float uharm14;
/**
* 15次谐波电压限值
*/
@TableField("uharm_15")
private Float uharm15;
/**
* 16次谐波电压限值
*/
@TableField("uharm_16")
private Float uharm16;
/**
* 17次谐波电压限值
*/
@TableField("uharm_17")
private Float uharm17;
/**
* 18次谐波电压限值
*/
@TableField("uharm_18")
private Float uharm18;
/**
* 19次谐波电压限值
*/
@TableField("uharm_19")
private Float uharm19;
/**
* 20次谐波电压限值
*/
@TableField("uharm_20")
private Float uharm20;
/**
* 21次谐波电压限值
*/
@TableField("uharm_21")
private Float uharm21;
/**
* 22次谐波电压限值
*/
@TableField("uharm_22")
private Float uharm22;
/**
* 23次谐波电压限值
*/
@TableField("uharm_23")
private Float uharm23;
/**
* 24次谐波电压限值
*/
@TableField("uharm_24")
private Float uharm24;
/**
* 25次谐波电压限值
*/
@TableField("uharm_25")
private Float uharm25;
/**
* 2次谐波电压限值
*/
@TableField("uharm_26")
private Float uharm26;
/**
* 3次谐波电压限值
*/
@TableField("uharm_27")
private Float uharm27;
/**
* 4次谐波电压限值
*/
@TableField("uharm_28")
private Float uharm28;
/**
* 5次谐波电压限值
*/
@TableField("uharm_29")
private Float uharm29;
/**
* 6次谐波电压限值
*/
@TableField("uharm_30")
private Float uharm30;
/**
* 7次谐波电压限值
*/
@TableField("uharm_31")
private Float uharm31;
/**
* 8次谐波电压限值
*/
@TableField("uharm_32")
private Float uharm32;
/**
* 9次谐波电压限值
*/
@TableField("uharm_33")
private Float uharm33;
/**
* 10次谐波电压限值
*/
@TableField("uharm_34")
private Float uharm34;
/**
* 11次谐波电压限值
*/
@TableField("uharm_35")
private Float uharm35;
/**
* 12次谐波电压限值
*/
@TableField("uharm_36")
private Float uharm36;
/**
* 13次谐波电压限值
*/
@TableField("uharm_37")
private Float uharm37;
/**
* 14次谐波电压限值
*/
@TableField("uharm_38")
private Float uharm38;
/**
* 15次谐波电压限值
*/
@TableField("uharm_39")
private Float uharm39;
/**
* 16次谐波电压限值
*/
@TableField("uharm_40")
private Float uharm40;
/**
* 17次谐波电压限值
*/
@TableField("uharm_41")
private Float uharm41;
/**
* 18次谐波电压限值
*/
@TableField("uharm_42")
private Float uharm42;
/**
* 19次谐波电压限值
*/
@TableField("uharm_43")
private Float uharm43;
/**
* 20次谐波电压限值
*/
@TableField("uharm_44")
private Float uharm44;
/**
* 21次谐波电压限值
*/
@TableField("uharm_45")
private Float uharm45;
/**
* 22次谐波电压限值
*/
@TableField("uharm_46")
private Float uharm46;
/**
* 23次谐波电压限值
*/
@TableField("uharm_47")
private Float uharm47;
/**
* 24次谐波电压限值
*/
@TableField("uharm_48")
private Float uharm48;
/**
* 25次谐波电压限值
*/
@TableField("uharm_49")
private Float uharm49;
/**
* 50次谐波电压限值
*/
@TableField("uharm_50")
private Float uharm50;
/**
* 2次谐波电流限值
*/
@TableField("iharm_2")
private Float iharm2;
/**
* 3次谐波电流限值
*/
@TableField("iharm_3")
private Float iharm3;
/**
* 4次谐波电流限值
*/
@TableField("iharm_4")
private Float iharm4;
/**
* 5次谐波电流限值
*/
@TableField("iharm_5")
private Float iharm5;
/**
* 6次谐波电流限值
*/
@TableField("iharm_6")
private Float iharm6;
/**
* 7次谐波电流限值
*/
@TableField("iharm_7")
private Float iharm7;
/**
* 8次谐波电流限值
*/
@TableField("iharm_8")
private Float iharm8;
/**
* 9次谐波电流限值
*/
@TableField("iharm_9")
private Float iharm9;
/**
* 10次谐波电流限值
*/
@TableField("iharm_10")
private Float iharm10;
/**
* 11次谐波电流限值
*/
@TableField("iharm_11")
private Float iharm11;
/**
* 12次谐波电流限值
*/
@TableField("iharm_12")
private Float iharm12;
/**
* 13次谐波电流限值
*/
@TableField("iharm_13")
private Float iharm13;
/**
* 14次谐波电流限值
*/
@TableField("iharm_14")
private Float iharm14;
/**
* 15次谐波电流限值
*/
@TableField("iharm_15")
private Float iharm15;
/**
* 16次谐波电流限值
*/
@TableField("iharm_16")
private Float iharm16;
/**
* 17次谐波电流限值
*/
@TableField("iharm_17")
private Float iharm17;
/**
* 18次谐波电流限值
*/
@TableField("iharm_18")
private Float iharm18;
/**
* 19次谐波电流限值
*/
@TableField("iharm_19")
private Float iharm19;
/**
* 20次谐波电流限值
*/
@TableField("iharm_20")
private Float iharm20;
/**
* 21次谐波电流限值
*/
@TableField("iharm_21")
private Float iharm21;
/**
* 22次谐波电流限值
*/
@TableField("iharm_22")
private Float iharm22;
/**
* 23次谐波电流限值
*/
@TableField("iharm_23")
private Float iharm23;
/**
* 24次谐波电流限值
*/
@TableField("iharm_24")
private Float iharm24;
/**
* 25次谐波电流限值
*/
@TableField("iharm_25")
private Float iharm25;
/**
* 2次谐波电压限值
*/
@TableField("iharm_26")
private Float iharm26;
/**
* 3次谐波电压限值
*/
@TableField("iharm_27")
private Float iharm27;
/**
* 4次谐波电压限值
*/
@TableField("iharm_28")
private Float iharm28;
/**
* 5次谐波电压限值
*/
@TableField("iharm_29")
private Float iharm29;
/**
* 6次谐波电压限值
*/
@TableField("iharm_30")
private Float iharm30;
/**
* 7次谐波电压限值
*/
@TableField("iharm_31")
private Float iharm31;
/**
* 8次谐波电压限值
*/
@TableField("iharm_32")
private Float iharm32;
/**
* 9次谐波电压限值
*/
@TableField("iharm_33")
private Float iharm33;
/**
* 10次谐波电压限值
*/
@TableField("iharm_34")
private Float iharm34;
/**
* 11次谐波电压限值
*/
@TableField("iharm_35")
private Float iharm35;
/**
* 12次谐波电压限值
*/
@TableField("iharm_36")
private Float iharm36;
/**
* 13次谐波电压限值
*/
@TableField("iharm_37")
private Float iharm37;
/**
* 14次谐波电压限值
*/
@TableField("iharm_38")
private Float iharm38;
/**
* 15次谐波电压限值
*/
@TableField("iharm_39")
private Float iharm39;
/**
* 16次谐波电压限值
*/
@TableField("iharm_40")
private Float iharm40;
/**
* 17次谐波电压限值
*/
@TableField("iharm_41")
private Float iharm41;
/**
* 18次谐波电压限值
*/
@TableField("iharm_42")
private Float iharm42;
/**
* 19次谐波电压限值
*/
@TableField("iharm_43")
private Float iharm43;
/**
* 20次谐波电压限值
*/
@TableField("iharm_44")
private Float iharm44;
/**
* 21次谐波电压限值
*/
@TableField("iharm_45")
private Float iharm45;
/**
* 22次谐波电压限值
*/
@TableField("iharm_46")
private Float iharm46;
/**
* 23次谐波电压限值
*/
@TableField("iharm_47")
private Float iharm47;
/**
* 24次谐波电压限值
*/
@TableField("iharm_48")
private Float iharm48;
/**
* 25次谐波电压限值
*/
@TableField("iharm_49")
private Float iharm49;
/**
* 50次谐波电压限值
*/
@TableField("iharm_50")
private Float iharm50;
/**
* 0.5次间谐波电压限值
*/
@TableField("inuharm_1")
private Float inuharm1;
/**
* 1.5次间谐波电压限值
*/
@TableField("inuharm_2")
private Float inuharm2;
/**
* 2.5次间谐波电压限值
*/
@TableField("inuharm_3")
private Float inuharm3;
/**
* 3.5次间谐波电压限值
*/
@TableField("inuharm_4")
private Float inuharm4;
/**
* 4.5次间谐波电压限值
*/
@TableField("inuharm_5")
private Float inuharm5;
/**
* 5.5次间谐波电压限值
*/
@TableField("inuharm_6")
private Float inuharm6;
/**
* 6.5次间谐波电压限值
*/
@TableField("inuharm_7")
private Float inuharm7;
/**
* 7.5次间谐波电压限值
*/
@TableField("inuharm_8")
private Float inuharm8;
/**
* 8.5次间谐波电压限值
*/
@TableField("inuharm_9")
private Float inuharm9;
/**
* 9.5次间谐波电压限值
*/
@TableField("inuharm_10")
private Float inuharm10;
/**
* 10.5次间谐波电压限值
*/
@TableField("inuharm_11")
private Float inuharm11;
/**
* 11.5次间谐波电压限值
*/
@TableField("inuharm_12")
private Float inuharm12;
/**
* 12.5次间谐波电压限值
*/
@TableField("inuharm_13")
private Float inuharm13;
/**
* 13.5次间谐波电压限值
*/
@TableField("inuharm_14")
private Float inuharm14;
/**
* 14.5次间谐波电压限值
*/
@TableField("inuharm_15")
private Float inuharm15;
/**
* 15.5次间谐波电压限值
*/
@TableField("inuharm_16")
private Float inuharm16;
public OverLimitInfoCommDTO(){}
public void buildIHarm(Float[] iHarmTem){
this.iharm2= iHarmTem[0];
this.iharm4= iHarmTem[2];
this.iharm6= iHarmTem[4];
this.iharm8= iHarmTem[6];
this.iharm10= iHarmTem[8];
this.iharm12= iHarmTem[10];
this.iharm14= iHarmTem[12];
this.iharm16= iHarmTem[14];
this.iharm18= iHarmTem[16];
this.iharm20= iHarmTem[18];
this.iharm22= iHarmTem[20];
this.iharm24= iHarmTem[22];
this.iharm26= iHarmTem[24];
this.iharm28= iHarmTem[26];
this.iharm30= iHarmTem[28];
this.iharm32= iHarmTem[30];
this.iharm34= iHarmTem[32];
this.iharm36= iHarmTem[34];
this.iharm38= iHarmTem[36];
this.iharm40= iHarmTem[38];
this.iharm42= iHarmTem[40];
this.iharm44= iHarmTem[42];
this.iharm46= iHarmTem[44];
this.iharm48= iHarmTem[46];
this.iharm50= iHarmTem[48];
this.iharm3= iHarmTem[1];
this.iharm5= iHarmTem[3];
this.iharm7= iHarmTem[5];
this.iharm9= iHarmTem[7];
this.iharm11= iHarmTem[9];
this.iharm13= iHarmTem[11];
this.iharm15= iHarmTem[13];
this.iharm17= iHarmTem[15];
this.iharm19= iHarmTem[17];
this.iharm21= iHarmTem[19];
this.iharm23= iHarmTem[21];
this.iharm25= iHarmTem[23];
this.iharm27= iHarmTem[25];
this.iharm29= iHarmTem[27];
this.iharm31= iHarmTem[29];
this.iharm33= iHarmTem[31];
this.iharm35= iHarmTem[33];
this.iharm37= iHarmTem[35];
this.iharm39= iHarmTem[37];
this.iharm41= iHarmTem[39];
this.iharm43= iHarmTem[41];
this.iharm45= iHarmTem[43];
this.iharm47= iHarmTem[45];
this.iharm49= iHarmTem[47];
}
public void buildUharm(Float resultEven,Float resultOdd){
this.uharm2=resultEven;
this.uharm4=resultEven;
this.uharm6=resultEven;
this.uharm8=resultEven;
this.uharm10=resultEven;
this.uharm12=resultEven;
this.uharm14=resultEven;
this.uharm16=resultEven;
this.uharm18=resultEven;
this.uharm20=resultEven;
this.uharm22=resultEven;
this.uharm24=resultEven;
this.uharm26=resultEven;
this.uharm28=resultEven;
this.uharm30=resultEven;
this.uharm32=resultEven;
this.uharm34=resultEven;
this.uharm36=resultEven;
this.uharm38=resultEven;
this.uharm40=resultEven;
this.uharm42=resultEven;
this.uharm44=resultEven;
this.uharm46=resultEven;
this.uharm48=resultEven;
this.uharm50=resultEven;
this.uharm3=resultOdd;
this.uharm5=resultOdd;
this.uharm7=resultOdd;
this.uharm9=resultOdd;
this.uharm11=resultOdd;
this.uharm13=resultOdd;
this.uharm15=resultOdd;
this.uharm17=resultOdd;
this.uharm19=resultOdd;
this.uharm21=resultOdd;
this.uharm23=resultOdd;
this.uharm25=resultOdd;
this.uharm27=resultOdd;
this.uharm29=resultOdd;
this.uharm31=resultOdd;
this.uharm33=resultOdd;
this.uharm35=resultOdd;
this.uharm37=resultOdd;
this.uharm39=resultOdd;
this.uharm41=resultOdd;
this.uharm43=resultOdd;
this.uharm45=resultOdd;
this.uharm47=resultOdd;
this.uharm49=resultOdd;
}
}

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.pojo.vo; package com.njcn.harmonic.common.pojo.vo;
import com.njcn.db.bo.BaseEntity; import com.njcn.db.bo.BaseEntity;
import lombok.Data; import lombok.Data;

View File

@@ -0,0 +1,27 @@
package com.njcn.harmonic.common.service;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
* pqs
*
* @author cdf
* @date 2026/1/15
*/
public interface CustomReportTableService {
/**
* 替换报表数据并返回
*
* @param reportSearchParam 请求参数
* @param response
* @author qijian
* @date 2022/10/18
*/
void getCustomReport(ReportSearchParam reportSearchParam, Map<String,String> newMap, DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response);
}

View File

@@ -0,0 +1,96 @@
package com.njcn.harmonic.common.service;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.vo.ReportValue;
import java.util.List;
/**
* 谐波报告
*/
public interface MonitorCommReportService {
/**
* 限值
* @param param
* @return
*/
/* OverLimitInfo getOverLimitData(ReportQueryParam param);
*/
/**
* 基波增幅
* @param param
* @return
*/
List<ReportValue> getVirtualData(ReportQueryParam param);
/**
* 功率
* @param param
* @return
*/
List<ReportValue> getPowerData(ReportQueryParam param);
/**
* 闪变
* @param param
* @return
*/
List<ReportValue> getFlickerData(ReportQueryParam param);
/**
* 电压偏差
* @param param
* @return
*/
List<ReportValue> getVdeviation(ReportQueryParam param);
/**
* 畸变率
* @param param
* @return
*/
List<ReportValue> getDistortionData(ReportQueryParam param);
/**
* 频率
* @param param
* @return
*/
List<ReportValue> getFrequencyData(ReportQueryParam param);
/**
* 三相不平衡
* @param param
* @return
*/
List<ReportValue> getThreephase(ReportQueryParam param);
/**
* 谐波电流
* @param param
* @return
*/
List<ReportValue> getICurrent(ReportQueryParam param);
/**
* 谐波电压
* @param param
* @return
*/
List<ReportValue> getVoltageRate(ReportQueryParam param);
/**
* 间谐波
* @param param
* @return
*/
List<ReportValue> getInharmVeRate(ReportQueryParam param);
/**
* 负序电流
* @param param
* @return
*/
List<ReportValue> getINegDataRate(ReportQueryParam param);
}

View File

@@ -0,0 +1,29 @@
package com.njcn.harmonic.common.service;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.common.pojo.dto.HarmLineDetailDataCommDTO;
import com.njcn.harmonic.common.pojo.dto.OverLimitInfoCommDTO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
/**
* pqs
*
* @author cdf
* @date 2026/1/17
*/
public interface MonitorHarmonicReportService {
void exportWorld(HttpServletResponse response,
String startTime,
String endTime,
Integer type,
String lineIndex,
String name,
String reportNumber,
String crmName,
Boolean isUrl,
MultipartFile file,
HarmLineDetailDataCommDTO lineDto, OverLimitInfoCommDTO overLimitData, DeviceUnitCommDTO deviceUnit);
}

View File

@@ -0,0 +1,778 @@
package com.njcn.harmonic.common.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.extension.toolkit.SqlRunner;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
import com.njcn.harmonic.common.pojo.dto.DeviceUnitCommDTO;
import com.njcn.harmonic.enums.HarmonicResponseEnum;
import com.njcn.harmonic.pojo.dto.ReportTemplateDTO;
import com.njcn.harmonic.pojo.param.ReportSearchParam;
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
import com.njcn.harmonic.common.mapper.ExcelRptTempMapper;
import com.njcn.harmonic.common.service.CustomReportTableService;
import com.njcn.influx.constant.InfluxDbSqlConstant;
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
import com.njcn.oss.enums.OssResponseEnum;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* pqs
*
* @author cdf
* @date 2026/1/15
*/
@Service
@RequiredArgsConstructor
@Slf4j
@DS("sjzx")
public class CustomReportTableServiceImpl implements CustomReportTableService {
private final ExcelRptTempMapper excelRptTempMapper;
private final EpdFeignClient epdFeignClient;
private final FileStorageUtil fileStorageUtil;
private final DicDataFeignClient dicDataFeignClient;
private final CommTerminalGeneralClient commTerminalGeneralClient;
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
private final String CELL_DATA = "celldata";
private final String V = "v";
private final String STR_ONE = "#";
private final String STR_TWO = "$";
private final String STR_THREE = "&";
private final String STR_FOUR = "%";
private final String UVOLTAGE_DEV = "UVOLTAGE_DEV";
private final String VOLTAGE_DEV = "VOLTAGE_DEV";
@Override
public void getCustomReport(ReportSearchParam reportSearchParam,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
TimeInterval timeInterval = new TimeInterval();
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
if (Objects.isNull(excelRptTemp)) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_ACTIVE);
}
if (Objects.isNull(reportSearchParam.getCustomType())) {
//通用报表
analyzeReport(reportSearchParam, excelRptTemp, newMap,deviceUnitCommDTO,response);
log.info("报表执行时间{}秒", timeInterval.intervalSecond());
}
}
/**
* 处理
*
* @author cdf
* @date 2023/10/8
*/
private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
//定义一个线程集合
List<Future<?>> futures = new ArrayList<>();
//指标
List<ReportTemplateDTO> reportTemplateDTOList = new ArrayList<>();
//限值
List<ReportTemplateDTO> reportLimitList = new ArrayList<>();
//台账
List<ReportTemplateDTO> terminalList = new ArrayList<>();
JSONArray jsonArray;
try (InputStream fileStream = fileStorageUtil.getFileStream(excelRptTemp.getContent())) {
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
} catch (Exception e) {
if(e instanceof BusinessException){
throw new BusinessException(e.getMessage());
}else {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
}
//查询不分相别的指标
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
if(Objects.isNull(dictData)){
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
}
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
//处理指标是否合格
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
Map<String, Float> limitMap = overLimitDeal(reportLimitList, reportSearchParam);
//存放限值指标的map
Map<String, ReportTemplateDTO> limitTargetMapX = reportLimitList.stream().collect(Collectors.toMap(ReportTemplateDTO::getItemName, Function.identity()));
List<ReportTemplateDTO> endList = new CopyOnWriteArrayList<>();
if (CollUtil.isNotEmpty(reportTemplateDTOList)) {
//开始组织sql
reportTemplateDTOList = new LinkedHashSet<>(reportTemplateDTOList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
Map<String, List<ReportTemplateDTO>> classMap = reportTemplateDTOList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getResourceId));
//定义存放越限指标的map
Map<String, ReportTemplateDTO> assNoPassMap = new HashMap<>();
classMap.forEach((classKey, templateValue) -> {
Map<String, List<ReportTemplateDTO>> valueTypeMap = templateValue.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getStatMethod));
//每张表开启一个独立线程查询
futures.add(executorService.submit(() -> {
DynamicDataSourceContextHolder.push("sjzx");
//avg.max,min,cp95
try {
valueTypeMap.forEach((valueTypeKey, valueTypeVal) -> {
//相别分组
Map<String, List<ReportTemplateDTO>> phaseMap = valueTypeVal.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getPhase));
phaseMap.forEach((phaseKey, phaseVal) -> {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
assSqlByMysql(phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
}
});
});
}finally {
DynamicDataSourceContextHolder.poll();
}
}));
});
// 等待所有任务完成
for (Future<?> future : futures) {
try {
future.get(); // 这会阻塞直到任务完成或抛出异常
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
log.error("自定义报表多线程查询流程出错!错误信息{}",e.getMessage());
}
}
//处理指标最终判定合格还是不合格
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
}
resultAssemble(endList,reportSearchParam,newMap,deviceUnitCommDTO,jsonArray);
//导出自定义报表
downReport(jsonArray, response);
}
/**
* 解析模板
* @author cdf
* @date 2023/10/20
*/
private void parseTemplate(JSONArray jsonArray, List<ReportTemplateDTO> reportTemplateDTOList, List<ReportTemplateDTO> reportLimitList, List<ReportTemplateDTO> terminalList) {
try {
//通过文件服务器获取
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get(CELL_DATA);
itemArr.forEach((it) -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
//获取到1列
JSONObject data = (JSONObject) it;
JSONObject son = (JSONObject) data.get(V);
if (son.containsKey(V)) {
String v = son.getStr(V);
//数据格式:$HA[_25]#B#max#classId$ 或 $HA[_25]#max#classId$
if (v.charAt(0) == '$' && v.contains(STR_ONE)) {
//剔除前后$
v = v.replace(STR_TWO, "");
//封装ReportTemplateDTO
ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO();
reportTemplateDTO.setItemName(v.toUpperCase());
//根据#分割数据
String[] vItem = v.split(STR_ONE);
if (vItem.length == 5) {
//$HA[_25]#B#max#classId$
reportTemplateDTO.setTemplateName(vItem[0].toUpperCase());
reportTemplateDTO.setPhase(vItem[1].substring(0, 1).toUpperCase());
reportTemplateDTO.setStatMethod(vItem[2].toUpperCase());
reportTemplateDTO.setResourceId(vItem[3].toUpperCase());
reportTemplateDTO.setLimitName(vItem[4].toUpperCase());
} else if (vItem.length == 4) {
//$HA[_25]#max#classId$
reportTemplateDTO.setTemplateName(vItem[0].toUpperCase());
reportTemplateDTO.setPhase("T");
reportTemplateDTO.setStatMethod(vItem[1].toUpperCase());
reportTemplateDTO.setResourceId(vItem[2].toUpperCase());
reportTemplateDTO.setLimitName(vItem[3].toUpperCase());
}
reportTemplateDTOList.add(reportTemplateDTO);
} else if (v.charAt(0) == '%' && v.contains(STR_ONE)) {
//封装指标结论ReportTemplateDTO
ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO();
v = v.replace(STR_FOUR, "");
reportTemplateDTO.setItemName(v.toUpperCase());
//根据#分割数据
String[] vItem = v.split(STR_ONE);
if (vItem.length == 3) {
reportTemplateDTO.setTemplateName(vItem[0].toUpperCase());
reportTemplateDTO.setStatMethod(vItem[1].toUpperCase());
reportTemplateDTO.setResourceId(vItem[2].toUpperCase());
}
reportLimitList.add(reportTemplateDTO);
} else if (v.charAt(0) == '&') {
//封装ReportTemplateDTO
ReportTemplateDTO reportTemplateDTO = new ReportTemplateDTO();
v = v.replace(STR_THREE, "");
reportTemplateDTO.setItemName(v.toUpperCase());
reportTemplateDTO.setTemplateName(v.toUpperCase());
terminalList.add(reportTemplateDTO);
}
}
}
});
});
} catch (Exception e) {
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
}
}
/**
* 获取测点限值
*
* @author cdf
* @date 2023/10/23
*/
private Map<String, Float> overLimitDeal(List<ReportTemplateDTO> reportLimitList, ReportSearchParam
reportSearchParam) {
Map<String, Float> limitMap = new HashMap<>();
if (CollUtil.isNotEmpty(reportLimitList)) {
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
for (int i = 0; i < reportLimitList.size(); i++) {
if (i == reportLimitList.size() - 1) {
sql.append(UVOLTAGE_DEV).append(StrUtil.COMMA);
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.C_SPACE);
} else {
sql.append(reportLimitList.get(i).getTemplateName()).append(StrUtil.COMMA);
}
}
sql.append(InfluxDbSqlConstant.FROM).append(reportLimitList.get(0).getResourceId()).append(InfluxDbSqlConstant.WHERE).append("id ='").append(reportSearchParam.getLineId()).append("'");
limitMap = excelRptTempMapper.dynamicSqlMap(sql.toString());
if (Objects.isNull(limitMap)) {
throw new BusinessException("当前报表测点限值缺失!");
}
for (ReportTemplateDTO item : reportLimitList) {
if (limitMap.containsKey(item.getTemplateName())) {
if(item.getTemplateName().equalsIgnoreCase(VOLTAGE_DEV)){
item.setLowValue(limitMap.get(UVOLTAGE_DEV).toString());
}
item.setValue(limitMap.get(item.getTemplateName()).toString());
}
}
}
limitMap = convertKeysToUpperCase(limitMap);
return limitMap;
}
/**
* 报告下载
*/
private void downReport(JSONArray jsonArray, HttpServletResponse response) {
InputStream reportStream = IoUtil.toStream(jsonArray.toString(), CharsetUtil.UTF_8);
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;filename=" + "aa");
OutputStream toClient = null;
try {
toClient = new BufferedOutputStream(response.getOutputStream());
//通过IOUtils对接输入输出流实现文件下载
IOUtils.copy(reportStream, toClient);
toClient.flush();
} catch (Exception e) {
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_STREAM_ERROR);
} finally {
IOUtils.closeQuietly(reportStream);
IOUtils.closeQuietly(toClient);
}
}
/**
* 对多测点数据进行计算求出一组数据
* @param method
* @param allList
* @return
*/
private Map<String, Object> dealResultMap(String method, List<Map<String, Object>> allList) {
Map<String, Object> resultMap = new HashMap<>();
// 遍历列表中的每个Map
if (method.equals(InfluxDbSqlConstant.MIN)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) > value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.MAX) || method.equals(InfluxDbSqlConstant.PERCENTILE)) {
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 检查结果Map中是否已包含该键
if (!resultMap.containsKey(key) || (double) resultMap.get(key) < value) {
// 如果不包含或当前值更大则更新结果Map
resultMap.put(key, value);
}
}
}
}
} else if (method.equals(InfluxDbSqlConstant.AVG)) {
Map<String, Double> sumMap = new HashMap<>();
Map<String, Integer> countMap = new HashMap<>();
// 遍历列表中的每个Map
for (Map<String, Object> map : allList) {
// 遍历当前Map的键值对
for (Map.Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
if (Objects.nonNull(entry.getValue()) && !key.equals("time")) {
double value = (double) entry.getValue();
// 更新累计和
sumMap.put(key, sumMap.getOrDefault(key, 0.0) + value);
// 更新计数
countMap.put(key, countMap.getOrDefault(key, 0) + 1);
}
}
}
// 计算平均值并存储到结果Map中
for (String key : sumMap.keySet()) {
double sum = sumMap.get(key);
int count = countMap.get(key);
double average = BigDecimal.valueOf(sum / count).setScale(3, RoundingMode.HALF_UP).doubleValue();
resultMap.put(key, average);
}
}
return resultMap;
}
/**
* 处理指标超标结论
*/
private void dealTargetResult
(Map<String, ReportTemplateDTO> assNoPassMap, Map<String, ReportTemplateDTO> limitTargetMapX, List<ReportTemplateDTO> endList) {
assNoPassMap.forEach((key, val) -> {
limitTargetMapX.remove(key);
if ("Freq_Dev".toUpperCase().equals(val.getTemplateName())) {
val.setValue("±" + val.getValue());
}
String expend = "";
if(Objects.nonNull(val.getLowValue())){
expend = val.getLowValue()+",";
}
if (val.getOverLimitFlag() == 1) {
val.setValue("不合格 (" + expend+val.getValue() + ")");
} else {
val.setValue("合格 (" + expend+val.getValue() + ")");
}
endList.add(val);
});
limitTargetMapX.forEach((key, val) -> {
if (Objects.isNull(val.getOverLimitFlag())) {
val.setValue("/");
} else {
val.setValue("合格");
}
endList.add(val);
});
}
/**
* @param data 同类型的cell模板
* @param sql 单个cell模板
* @param endList 用于返回最终组装好的数据类似data
* @param limitMap 指标是否合格模板
* @param assNoPassMap 用于存储不合格的指标
* @date 2023/10/20
*/
private void assSqlByMysql(List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
//sql拼接示例select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
if (InfluxDbSqlConstant.CP95.equals(method)) {
for (int i = 0; i < data.size(); i++) {
if (i == data.size() - 1) {
sql.append(InfluxDbSqlConstant.MAX)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\""+data.get(i).getItemName()+"\"");
} else {
sql.append(InfluxDbSqlConstant.MAX)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
}
}
} else {
for (int i = 0; i < data.size(); i++) {
if (i == data.size() - 1) {
sql.append(method)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\""+data.get(i).getItemName()+"\"");
} else {
sql.append(method)
.append(InfluxDbSqlConstant.LBK)
.append(data.get(i).getTemplateName())
.append(InfluxDbSqlConstant.RBK)
.append(InfluxDbSqlConstant.AS)
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
}
}
}
//拼接表名
sql.append(StrPool.C_SPACE)
.append(InfluxDbSqlConstant.FROM)
.append(data.get(0).getResourceId());
sql.append(InfluxDbSqlConstant.WHERE)
.append(InfluxDBTableConstant.LINE_ID)
.append(InfluxDbSqlConstant.EQ)
.append(InfluxDbSqlConstant.QM)
.append(reportSearchParam.getLineId())
.append(InfluxDbSqlConstant.QM);
//相别特殊处理
if (!InfluxDBTableConstant.NO_PHASE.equals(data.get(0).getPhase())) {
sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDBTableConstant.PHASIC_TYPE)
.append(InfluxDbSqlConstant.EQ)
.append(InfluxDbSqlConstant.QM)
.append(data.get(0).getPhase())
.append(InfluxDbSqlConstant.QM);
}
sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDBTableConstant.VALUE_TYPE)
.append(InfluxDbSqlConstant.EQ)
.append(InfluxDbSqlConstant.QM)
.append(data.get(0).getStatMethod())
.append(InfluxDbSqlConstant.QM);
//频率和频率偏差仅统计T相
if (noPhaseList.contains(data.get(0).getTemplateName())) {
if(data.get(0).getTemplateName().equalsIgnoreCase("v_unbalance")){
System.out.println(44);
}
sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDBTableConstant.PHASIC_TYPE)
.append(InfluxDbSqlConstant.EQ)
.append(InfluxDbSqlConstant.QM)
.append(InfluxDBTableConstant.PHASE_TYPE_T)
.append(InfluxDbSqlConstant.QM);
}
//时间范围处理
sql.append(InfluxDbSqlConstant.AND)
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.GE).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getStartTime()).append(InfluxDbSqlConstant.START_TIME).append(InfluxDbSqlConstant.QM)
.append(InfluxDbSqlConstant.AND)
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.LT).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getEndTime()).append(InfluxDbSqlConstant.END_TIME).append(InfluxDbSqlConstant.QM);
System.out.println(sql);
List<Map<String, Object>> mapList = SqlRunner.DEFAULT.selectList(sql.toString());
if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) {
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
} else {
//兼容达梦数据库方法
Map<String, Object> map = convertKeysToUpperCase(mapList.get(0));
for (ReportTemplateDTO item : data) {
if (map.containsKey(item.getItemName())) {
double v = Double.parseDouble(map.get(item.getItemName()).toString());
item.setValue(String.format("%.3f", v));
if (overLimitMap.containsKey(item.getLimitName())) {
Float tagVal = overLimitMap.get(item.getLimitName());
if(item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)){
//对电压偏差特殊处理
Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV);
if (v > tagVal || v<tagVal_U) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
}else {
if (v > tagVal) {
item.setOverLimitFlag(1);
} else {
item.setOverLimitFlag(0);
}
}
}
//判断是否越限
if (!limitMap.isEmpty()) {
String key = item.getLimitName() + STR_ONE + item.getStatMethod() + "#PQ_OVERLIMIT";
if (limitMap.containsKey(key)) {
ReportTemplateDTO tem = limitMap.get(key);
double limitVal = Double.parseDouble(tem.getValue());
if(VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())){
//针对电压偏差特殊处理
double limitLowVal = Double.parseDouble(tem.getLowValue());
if (v > limitVal || v<limitLowVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
}else {
//其他指标
if (v > limitVal) {
tem.setOverLimitFlag(1);
assNoPassMap.put(key, tem);
} else if (!assNoPassMap.containsKey(key)) {
tem.setOverLimitFlag(0);
assNoPassMap.put(key, tem);
}
}
}
}
} else {
item.setValue("/");
}
}
}
endList.addAll(data);
}
/**
* 数据单位信息
*/
private Map<String, String> unitMap(DeviceUnitCommDTO deviceUnit) {
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
Map<String, String> unit = new HashMap<>();
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
for (String s : list) {
//有效值
if (s.equals(DicDataEnum.EFFECTIVE.getCode())) {
unit.put(s + "#i", deviceUnit.getIeffective());
unit.put(s + "#v", deviceUnit.getLineVoltage());
}
//功率
if (s.equals(DicDataEnum.POWER.getCode())) {
unit.put(s + "#p", deviceUnit.getTotalActiveP());
unit.put(s + "#q", deviceUnit.getTotalNoP());
unit.put(s + "#s", deviceUnit.getTotalViewP());
}
//畸变率
if (s.equals(DicDataEnum.DISTORTION.getCode())) {
unit.put(s + "#v", deviceUnit.getVdistortion());
}
//电压偏差
if (s.equals(DicDataEnum.VOLTAGE.getCode())) {
unit.put(s + "#v", deviceUnit.getVoltageDev());
}
//频率
if (s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())) {
unit.put(s + "#freq", deviceUnit.getUnitFrequency());
unit.put(s + "#freqDev", deviceUnit.getUnitFrequencyDev());
}
//三项不平衡度
if (s.equals(DicDataEnum.UNBALANCE.getCode())) {
unit.put(s + "#v", STR_FOUR);
unit.put(s + "#vPos", deviceUnit.getPositiveV());
unit.put(s + "#vNeg", deviceUnit.getNoPositiveV());
unit.put(s + "#vZero", deviceUnit.getNoPositiveV());
unit.put(s + "#i", STR_FOUR);
unit.put(s + "#iPos", "A");
unit.put(s + "#iNeg", "A");
unit.put(s + "#iZero", "A");
}
//基波
if (s.equals(DicDataEnum.FUND.getCode())) {
unit.put(s + "#i", deviceUnit.getIfund());
unit.put(s + "#v", deviceUnit.getVfundEffective());
}
}
return unit;
}
/**
* 处理最终结果
* @author cdf
* @date 2026/1/16
*/
public void resultAssemble(List<ReportTemplateDTO> endList,ReportSearchParam reportSearchParam,Map<String,String> finalTerminalMap,DeviceUnitCommDTO deviceUnitCommDTO,JSONArray jsonArray){
if (CollUtil.isNotEmpty(endList)) {
//数据单位信息
Map<String, String> unit = unitMap(deviceUnitCommDTO);
//进行反向赋值到模板
//1、根据itemName分组
Map<String, List<ReportTemplateDTO>> assMap = endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
//2、把itemName的value赋给v和m
jsonArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
JSONArray itemArr = (JSONArray) jsonObject.get(CELL_DATA);
itemArr.forEach((it) -> {
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
//获取到1列
JSONObject data = (JSONObject) it;
JSONObject son = (JSONObject) data.get(V);
if (son.containsKey(V)) {
String v = son.getStr(V);
//数据格式:$HA[_25]#B#max#classId$ 或 $HA[_25]#max#classId$
if (v.charAt(0) == '$' && v.contains(STR_ONE)) {
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_TWO, "").toUpperCase());
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if (Objects.nonNull(rDto.get(0).getOverLimitFlag()) && rDto.get(0).getOverLimitFlag() == 1) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '%' && v.contains(STR_ONE)) {
//指标合格情况
String str = "";
List<ReportTemplateDTO> rDto = assMap.get(v.replace(STR_FOUR, "").toUpperCase());
if (Objects.nonNull(rDto)) {
str = rDto.get(0).getValue();
//没有值,赋"/"
if (StringUtils.isBlank(str)) {
str = "/";
}
son.set(V, str);
if ("不合格".equals(str)) {
son.set("fc", "#990000");
}
}
} else if (v.charAt(0) == '&') {
//结论
String tem = v.replace(STR_THREE, "").toUpperCase();
if (finalTerminalMap.size()>0) {
if ("STATIS_TIME".equals(tem)) {
//如何时间是大于当前时间则用当前时间
String localTime = InfluxDbSqlConstant.END_TIME;
LocalDate localDate = LocalDateTimeUtil.parseDate(reportSearchParam.getEndTime(), DatePattern.NORM_DATE_PATTERN);
LocalDate nowDate = LocalDate.now();
if (nowDate.isAfter(localDate)) {
son.set(V, reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + reportSearchParam.getEndTime() + localTime);
} else {
localTime = " " + LocalTime.now().format(DatePattern.NORM_TIME_FORMATTER);
son.set(V, reportSearchParam.getStartTime() + InfluxDbSqlConstant.START_TIME + "_" + nowDate + localTime);
}
} else {
//台账信息
son.set(V, finalTerminalMap.getOrDefault(tem, "/"));
}
}
}
//解决数据单位问题 @指标#类型@
if (v.charAt(0) == '@' && v.contains(STR_ONE)) {
String replace = v.replace("@", "");
son.set(V, unit.getOrDefault(replace, "/"));
}
}
}
});
});
}
}
/**
* map key转大写
*/
public <V> Map<String, V> convertKeysToUpperCase(Map<String, V> originalMap) {
Map<String, V> newMap = new HashMap<>();
for (Map.Entry<String, V> entry : originalMap.entrySet()) {
newMap.put(entry.getKey().toUpperCase(), entry.getValue());
}
return newMap;
}
}

View File

@@ -0,0 +1,690 @@
package com.njcn.harmonic.common.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.RStatDataVD;
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO;
import com.njcn.harmonic.pojo.vo.ReportValue;
import com.njcn.harmonic.common.mapper.*;
import com.njcn.harmonic.common.service.MonitorCommReportService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author wr
*/
@Service
@RequiredArgsConstructor
@DS("sjzx")
@Slf4j
public class MonitorCommReportServiceImpl implements MonitorCommReportService {
private final MonitorCommReportMapper reportMapper;
private final RStatDataVDMapper statDataVDMapper;
private final RStatDataHarmRateVDMapper rStatDataHarmRateVDMapper;
private final RStatDataIDMapper rStatDataIDMapper;
private final RStatDataInharmVDMapper rStatDataInharmVDMapper;
/* @Override
public OverLimitInfo getOverLimitData(ReportQueryParam param) {
OverLimitInfo overLimitInfo = new OverLimitInfo();
//查询时间段内共有多少条记录,并*0.95取整处理用来计算CP95值 降序*0.05进一位计算
double count = 0;
double pstCount = 0;
double pltCount = 0;
if (param.getB()) {
count = Math.ceil(1);
pltCount = Math.ceil(1);
pstCount = Math.ceil(1);
} else {
count = Math.ceil(reportMapper.getTotalCP95Day(param).intValue() * 0.05);
pltCount = Math.ceil(reportMapper.getTotalPltCP95Day(param).intValue() * 0.05);
pstCount = Math.ceil(reportMapper.getTotalPstCP95Day(param).intValue() * 0.05);
}
overLimitInfo.setCount(count);
overLimitInfo.setPltCount(pltCount);
overLimitInfo.setPstCount(pstCount);
return overLimitInfo;
}
*/
@Override
public List<ReportValue> getVirtualData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
// 获取电流有效值
List<ReportValue> listI = reportMapper.getVirtualDataI(param);
//获取电压有效值
List<ReportValue> listV = reportMapper.getVirtualDataV(param);
//获取线电压有效值
List<ReportValue> listVV = reportMapper.getVVirtualData(param);
RegroupDataComm.regroupData(listV, true);
RegroupDataComm.regroupData(listI, true);
RegroupDataComm.regroupData(listVV, true);
list.addAll(listV);
list.addAll(listI);
list.addAll(listVV);
return list;
}
@Override
public List<ReportValue> getPowerData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取有功功率
List<ReportValue> listP = reportMapper.getPowerP(param);
//获取无功功率
List<ReportValue> listQ = reportMapper.getPowerQ(param);
//获取视在功率
List<ReportValue> listS = reportMapper.getPowerS(param);
//获取功率因数
List<ReportValue> listF = reportMapper.getPF(param);
RegroupDataComm.regroupData(listP, true, false);
RegroupDataComm.regroupData(listQ, true, false);
RegroupDataComm.regroupData(listS, true, false);
RegroupDataComm.regroupData(listF, true, false);
list.addAll(listP);
list.addAll(listQ);
list.addAll(listS);
list.addAll(listF);
return list;
}
@Override
public List<ReportValue> getFlickerData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//短时闪变
List<ReportValue> listFlicker = reportMapper.getFlickerData(param);
//长时闪变
List<ReportValue> listLFlicker = reportMapper.getLFlickerData(param);
RegroupDataComm.regroupData(listFlicker, true);
RegroupDataComm.regroupData(listLFlicker, true);
list.addAll(listFlicker);
list.addAll(listLFlicker);
return list;
}
@Override
public List<ReportValue> getVdeviation(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电压偏差
List<ReportValue> listU = reportMapper.getUVdeviationData(param);
List<ReportValue> listL = reportMapper.getLVdeviationData(param);
RegroupDataComm.regroupData(listU, true);
RegroupDataComm.regroupData(listL, true);
list.addAll(listU);
list.addAll(listL);
return list;
}
@Override
public List<ReportValue> getDistortionData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电压畸变率
List<ReportValue> listU = reportMapper.getDistortionDataV(param);
//获取电流畸变率
List<ReportValue> listI = reportMapper.getDistortionDataI(param);
//添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中
RegroupDataComm.regroupData(listU, true);
RegroupDataComm.regroupData(listI, true);
list.addAll(listU);
list.addAll(listI);
return list;
}
@Override
public List<ReportValue> getFrequencyData(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
List<ReportValue> listFre = reportMapper.getFrequencyData(param);
List<ReportValue> listFreDEV = reportMapper.getDEVFrequencyData(param);
RegroupDataComm.regroupData(listFre, true);
RegroupDataComm.regroupData(listFreDEV, true);
list.addAll(listFre);
list.addAll(listFreDEV);
return list;
}
@Override
public List<ReportValue> getThreephase(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//电压三相不平衡度
List<ReportValue> listV = dataV(param, Arrays.asList("T"), 1, 5, true, 0);
//电流三相不平衡度
List<ReportValue> listI = dataI(param, Arrays.asList("T"), 1, 5, true, 0);
if (CollUtil.isNotEmpty(listV)) {
list.addAll(listV);
} else {
regroupData(list);
}
if (CollUtil.isNotEmpty(listI)) {
list.addAll(listI);
} else {
regroupData(list);
}
return list;
}
@Override
public List<ReportValue> getICurrent(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//获取电流幅值,包含基波
List<ReportValue> listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0);
if (CollUtil.isEmpty(listI)) {
for (int i = 0; i < 50; i++) {
RegroupDataComm.regroupData(list, true, true);
}
} else {
list.addAll(listI);
}
return list;
}
@Override
public List<ReportValue> getVoltageRate(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//这里获取的是电压有效值不是V1
//获取基波电压幅值单位kV
List<ReportValue> listV = dataV(param, Arrays.asList("A", "B", "C"), 1, 2, false, 5);
if (CollUtil.isEmpty(listV)) {
RegroupDataComm.regroupData(list, true, true);
} else {
list.addAll(listV);
}
//获取电压含有率,不包含基波
List<ReportValue> listRate = dataHarmV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1);
if (CollUtil.isEmpty(listRate)) {
for (int i = 0; i < 49; i++) {
RegroupDataComm.regroupData(list, true, true);
}
} else {
list.addAll(listRate);
}
//获取电压畸变率
List<ReportValue> listU = reportMapper.getDistortionDataV(param);
RegroupDataComm.regroupData(listU, true);
list.addAll(listU);
return list;
}
@Override
public List<ReportValue> getInharmVeRate(ReportQueryParam param) {
List<RStatDataInharmVDPO> inharm = rStatDataInharmVDMapper.selectList(new LambdaQueryWrapper<RStatDataInharmVDPO>()
.eq(RStatDataInharmVDPO::getLineId, param.getLineId())
.in(RStatDataInharmVDPO::getPhaseType, Arrays.asList("A", "B", "C"))
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataInharmVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataInharmVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataInharmVDPO>> collect = inharm.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getPhaseType));
collect.forEach((key, value) -> {
Map<String, List<RStatDataInharmVDPO>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getValueType));
for (int i = 1; i < 17; i++) {
ReportValue reportValue = new ReportValue();
String attribute = "v" + i;
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataInV(valueTypeMap.get(max), max, attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataInV(valueTypeMap.get(avg), avg, attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataInV(valueTypeMap.get(min), min, attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataInV(valueTypeMap.get(cp95), cp95, attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
}
});
if (CollUtil.isEmpty(a)) {
for (int i = 1; i < 17; i++) {
RegroupDataComm.regroupData(a, true, true);
}
}
return a;
}
@Override
public List<ReportValue> getINegDataRate(ReportQueryParam param) {
List<ReportValue> list = new ArrayList<>();
//负序电流
List<ReportValue> iNegData = reportMapper.getINegData(param);
RegroupDataComm.regroupData(iNegData, true);
list.addAll(iNegData);
return list;
}
//赋值默认值
private void regroupData(List<ReportValue> list) {
for (int i = 0; i < 4; i++) {
List<ReportValue> list1 = new ArrayList<>();
RegroupDataComm.regroupData(list1, false);
list.addAll(list1);
}
}
/**
* 电压信息
*
* @param param 查询条件
* @param valueTypes 区分类别 例如"A","B","C"
* @param num 循环开始
* @param size 循环结束
* @param fly 否是启用获取属性电压
* @param index 获取属性位置名称
* @return
*/
private List<ReportValue> dataV(ReportQueryParam param, List<String> valueTypes, Integer num, Integer size, Boolean fly, Integer index) {
List<RStatDataVD> rStatDataVDS = statDataVDMapper.selectList(new LambdaQueryWrapper<RStatDataVD>()
.eq(RStatDataVD::getLineId, param.getLineId())
.in(CollUtil.isNotEmpty(valueTypes), RStatDataVD::getPhasicType, valueTypes)
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataVD>> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataVD::getPhasicType));
collect.forEach((key, value) -> {
Map<String, List<RStatDataVD>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataVD::getValueType));
for (int i = num; i < size; i++) {
ReportValue reportValue = new ReportValue();
String attribute = "";
if (fly) {
if (index == 0) {
attribute = attributeV(i);
} else {
attribute = attributeV(index);
}
} else {
attribute = "v" + i;
}
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataV(valueTypeMap.get(max), max, attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataV(valueTypeMap.get(avg), avg, attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataV(valueTypeMap.get(min), min, attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataV(valueTypeMap.get(cp95), cp95, attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
}
});
return a;
}
/**
* 电压信息
*
* @param param 查询条件
* @param valueTypes 区分类别 例如"A","B","C"
* @param num 循环开始
* @param size 循环结束
* @param fly 否是启用获取属性电压
* @param index 获取属性位置名称
* @return
*/
private List<ReportValue> dataHarmV(ReportQueryParam param, List<String> valueTypes, Integer num, Integer size, Boolean fly, Integer index) {
List<RStatDataHarmrateVDPO> harmRateVDPOS = rStatDataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
.eq(RStatDataHarmrateVDPO::getLineId, param.getLineId())
.in(CollUtil.isNotEmpty(valueTypes), RStatDataHarmrateVDPO::getPhaseType, valueTypes)
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataHarmrateVDPO>> collect = harmRateVDPOS.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getPhaseType));
//格式错误之前数据50A,50B50C,应该是50ABC
for (int i = num; i < size; i++) {
int finalI = i;
collect.forEach((key, value) -> {
Map<String, List<RStatDataHarmrateVDPO>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataHarmrateVDPO::getValueType));
ReportValue reportValue = new ReportValue();
String attribute = "";
if (fly) {
if (index == 0) {
attribute = attributeV(finalI);
} else {
attribute = attributeV(index);
}
} else {
attribute = "v" + finalI;
}
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataHarmV(valueTypeMap.get(max), max, attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataHarmV(valueTypeMap.get(avg), avg, attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataHarmV(valueTypeMap.get(min), min, attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataHarmV(valueTypeMap.get(cp95), cp95, attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
});
}
return a;
}
/**
* 电压反射取属性值
*
* @param value
* @param name
* @return
*/
private List<Float> reflectDataV(List<RStatDataVD> value, String name, String attribute) {
Field field = null;
try {
field = RStatDataVD.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
BigDecimal o = null;
try {
o = (BigDecimal) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
private List<Float> reflectDataHarmV(List<RStatDataHarmrateVDPO> value, String name, String attribute) {
Field field = null;
try {
field = RStatDataHarmrateVDPO.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
Double o = null;
try {
o = (Double) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
/**
* 电压反射取属性值
*
* @param value
* @param name
* @return
*/
private List<Float> reflectDataInV(List<RStatDataInharmVDPO> value, String name, String attribute) {
Field field;
try {
field = RStatDataInharmVDPO.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
Double o;
try {
o = (Double) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
/**
* 电流信息
*
* @param param
* @return
*/
private List<ReportValue> dataI(ReportQueryParam param, List<String> valueTypes, Integer num, Integer size, Boolean fly, Integer index) {
List<RStatDataIDPO> rStatDataVDS = rStatDataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
.eq(RStatDataIDPO::getLineId, param.getLineId())
.in(CollUtil.isNotEmpty(valueTypes), RStatDataIDPO::getPhaseType, valueTypes)
.ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime())))
.le(StrUtil.isNotBlank(param.getEndTime()), RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime())))
);
String max = "MAX";
String avg = "AVG";
String min = "MIN";
String cp95 = "CP95";
List<ReportValue> a = new ArrayList<>();
Map<String, List<RStatDataIDPO>> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataIDPO::getPhaseType));
//格式错误之前数据50A,50B50C,应该是50ABC
for (int i = num; i < size; i++) {
int finalI = i;
collect.forEach((key, value) -> {
Map<String, List<RStatDataIDPO>> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataIDPO::getValueType));
ReportValue reportValue = new ReportValue();
String attribute = "";
if (fly) {
if (index == 0) {
attribute = attributeI(finalI);
} else {
attribute = attributeI(index);
}
} else {
attribute = "i" + finalI;
}
if (valueTypeMap.containsKey(max)) {
List<Float> aa = reflectDataI(valueTypeMap.get(max), max, attribute);
reportValue.setPhaseType(key);
Float maxNum = aa.stream().distinct().max(Float::compareTo).get();
reportValue.setFmaxValue(maxNum);
}
if (valueTypeMap.containsKey(avg)) {
List<Float> aa = reflectDataI(valueTypeMap.get(avg), avg, attribute);
reportValue.setPhaseType(key);
Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue));
reportValue.setMeanValue(avgNum.floatValue());
}
if (valueTypeMap.containsKey(min)) {
List<Float> aa = reflectDataI(valueTypeMap.get(min), min, attribute);
reportValue.setPhaseType(key);
double minNum = aa.stream().distinct().min(Float::compareTo).get();
reportValue.setMinValue((float) minNum);
}
if (valueTypeMap.containsKey(cp95)) {
List<Float> aa = reflectDataI(valueTypeMap.get(cp95), cp95, attribute);
reportValue.setPhaseType(key);
List<Float> cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList());
reportValue.setCp95Value(cp95Num.get(0).floatValue());
}
a.add(reportValue);
});
}
return a;
}
/**
* 电流反射取属性值
*
* @param value
* @param name
* @return
*/
private List<Float> reflectDataI(List<RStatDataIDPO> value, String name, String attribute) {
Field field = null;
try {
field = RStatDataIDPO.class.getDeclaredField(attribute);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
field.setAccessible(true);
Field finalField = field;
return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> {
Double o = null;
try {
o = (Double) finalField.get(temp);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
return o.floatValue();
}).collect(Collectors.toList());
}
/**
* 获取属性电压
*
* @param i
* @return
*/
private String attributeV(Integer i) {
String str = null;
switch (i) {
case 1:
str = "vUnbalance";
break;
case 2:
str = "vPos";
break;
case 3:
str = "vNeg";
break;
case 4:
str = "vZero";
break;
case 5:
str = "v1";
break;
default:
break;
}
return str;
}
/**
* 获取属性电流
*
* @param i
* @return
*/
private String attributeI(Integer i) {
String str = null;
switch (i) {
case 1:
str = "iUnbalance";
break;
case 2:
str = "iPos";
break;
case 3:
str = "iNeg";
break;
case 4:
str = "iZero";
break;
default:
break;
}
return str;
}
}

View File

@@ -1,10 +1,10 @@
package com.njcn.harmonic.service.impl; package com.njcn.harmonic.common.service.impl;
import com.njcn.harmonic.pojo.vo.ReportValue; import com.njcn.harmonic.pojo.vo.ReportValue;
import java.util.List; import java.util.List;
public class RegroupData { public class RegroupDataComm {
public static void regroupData(List<ReportValue> list, boolean... b) { public static void regroupData(List<ReportValue> list, boolean... b) {
if (1 == b.length || (2 == b.length && b[1] == false)) { if (1 == b.length || (2 == b.length && b[1] == false)) {
if (0 < list.size()) { if (0 < list.size()) {

Some files were not shown because too many files have changed in this diff Show More