88 Commits

Author SHA1 Message Date
xy
79cec4e21b feat(event): 新增压降落点区域判定功能
- 在EventAnalysisService中添加determineDropZone方法用于判定压降落点区域
- 实现压降落点区域判定逻辑,支持A/B/C/D四个区域的分类判断
- 添加精确的数值范围匹配算法,使用BigDecimal确保计算精度
- 集成日志记录功能,便于问题排查和监控
- 在RedisUtil中新增scanKeysByPattern方法支持模糊查询key功能
- 优化代码结构,移除冗余的导入包和空行
- 更新类级别的注解配置,添加@Slf4j注解支持日志功能
2026-05-27 18:10:15 +08:00
hzj
615fe78d61 辽宁稳态指标超标明细等页面丰富查询条件; 2026-05-22 14:05:53 +08:00
hzj
5fff0890e8 数据清洗移动包修改 2026-05-21 15:15:24 +08:00
hzj
f5e134b194 数据清洗移动包修改 2026-05-21 15:00:13 +08:00
hzj
291a20649e 添加控制task是否执行配置business:task-enabled: false为true是执行,false不执行,缺省默认为true只行,只有没有前置微服务版本配置false; 2026-05-21 11:11:38 +08:00
hzj
7eef16599f 台账模版导入功能修复 2026-05-20 15:58:48 +08:00
xy
11750a4f3a fix(service): 修正电力参数默认相位设置
- 将新增记录时的默认相位从"M"改为"T"
- 将更新记录时的默认相位从"M"改为"T"
- 确保相位字段在空值情况下统一使用"T"作为默认值
2026-05-20 14:18:03 +08:00
hzj
e6332f1c51 装置文件系统访问 2026-05-15 13:36:51 +08:00
cdf
23d87aecc8 修改自定义报表适配分钟/统计数据查询 2026-05-14 17:05:43 +08:00
xy
eff784e94e feat(mq): 添加治理心跳过期处理消息功能 2026-05-14 09:20:42 +08:00
hzj
eed647d3d1 高级算法异常抛出 2026-04-30 12:25:25 +08:00
hzj
4a5fde6a47 设备退运bug修复 2026-04-27 16:23:53 +08:00
hzj
82ab1de5b9 Merge remote-tracking branch 'origin/main' 2026-04-27 16:21:16 +08:00
hzj
ecc56dd2f6 暂态原因算法bug修复 2026-04-27 16:19:43 +08:00
xy
39ae7412a8 微调 2026-04-27 15:33:08 +08:00
xy
52677f84dc fix(utils): 修复JNA调用动态库的路径和错误处理问题
- 移除硬编码的文件后缀名,根据操作系统自动识别.dll或.so文件
- 修正Linux系统下的库文件命名规则,移除多余的"_dll"后缀
- 添加对文件扩展名的条件判断,在Windows下确保.dll后缀
- 添加动态库加载成功后的路径打印功能
2026-04-27 15:32:39 +08:00
cdf
abdb855919 注释prepareboot模块无用代码 2026-04-23 15:11:07 +08:00
cdf
64bcbfff91 注释prepareboot模块无用代码 2026-04-23 14:56:12 +08:00
wr
499eee6784 redis工具类优化 2026-04-23 14:37:24 +08:00
caozehui
c58bd87a78 微调 2026-04-23 09:11:02 +08:00
caozehui
0902f92838 Merge remote-tracking branch 'origin/main' 2026-04-23 08:53:24 +08:00
xy
87818db6f3 微调 2026-04-21 16:00:46 +08:00
caozehui
850b3174a2 云前置文件文件目录功能 2026-04-20 13:43:26 +08:00
aad5943d64 fix(waveform): 修复录波文件处理中的RMS段逻辑错误
- 在RateDTO初始化时设置bRMSFlag默认值为false,确保16~31点/周波段按普通抽点处理
- 修复RMS段与普通抽点的控制流程分离,避免共享取模条件导致的逻辑混乱
- 优化RMS段处理逻辑,添加周波索引推进机制防止重复处理
- 修复2点/周波时半周波位置的采样点切换逻辑
- 添加段末尾对齐机制,确保外层循环能稳定跳转到下一段起点
- 更新测试文件路径配置,使用新的测试数据文件
2026-04-17 15:44:18 +08:00
cdf
9c467310d5 用能添加mqtt支持 2026-04-16 14:19:33 +08:00
cdf
ca3b125424 用能添加mqtt支持 2026-04-16 14:08:05 +08:00
hzj
0c5c9bf067 删除MQTT相关代码 2026-04-16 13:47:30 +08:00
hzj
c692282ea4 bug修复 2026-04-15 10:43:46 +08:00
232e84aad3 波形解析的电流一次值转二次值调整 2026-04-15 10:20:48 +08:00
xy
59f2588488 生成文件自定义文件名称 2026-04-14 19:07:11 +08:00
hzj
46f521c7a7 谐波频谱查询Influxdb分钟数据修改成查询mysql统计数据 2026-04-10 13:32:36 +08:00
hzj
6d69027e16 数据完整性页面添加字段objname 监测对象 2026-04-09 15:41:14 +08:00
hzj
1afed2c9a4 数据完整性页面添加字段objname 监测对象 2026-04-09 15:40:38 +08:00
hzj
9bb250bdb9 优化查询 2026-04-09 09:05:56 +08:00
hzj
d33b3637a5 暂态事件推送由MQTT切换成Websocket 2026-04-09 09:05:02 +08:00
hzj
f50f11b159 优化前置下线装置状态翻转 2026-04-09 08:57:12 +08:00
xy
30984aa908 暂态事件波形解析代码调整 2026-04-08 19:27:57 +08:00
wr
39cfffbf7e Merge remote-tracking branch 'origin/main' 2026-04-02 10:45:08 +08:00
wr
1aad1aa86b 1.解决冀北阿里云Nacos版本兼容问题
2.解决配置bootstrap.yml兼容问题
2026-04-02 10:40:11 +08:00
xy
fa500ca600 1、报表、报告新增物联方法
2、公共方法添加
2026-04-01 20:25:08 +08:00
xy
7b9fb1628b App稳态、暂态报告功能支持 2026-03-25 13:28:46 +08:00
fcddc064f6 清除不必要的代码 2026-03-24 19:57:03 +08:00
cdf
37c5e9cbf8 暂降hdr文件生成上传oss 2026-03-24 13:06:23 +08:00
cdf
a08c7db24d 暂降hdr文件生成上传oss 2026-03-24 13:05:38 +08:00
cdf
9225e82edb 区域报告模板bug修改 2026-03-23 13:03:32 +08:00
cdf
e8cd6da8a0 通用台账查询接口调整 2026-03-23 09:19:03 +08:00
cdf
559620ab66 所有模块开启nacos鉴权 2026-03-21 14:31:59 +08:00
cdf
f0b3b81e65 所有模块开启nacos鉴权 2026-03-21 14:27:37 +08:00
cdf
475ca820c8 设备秘钥bug 2026-03-18 17:55:46 +08:00
wr
c0db2cf961 微调 2026-03-05 19:42:57 +08:00
wr
4e95159e01 技术监督用户信息迁移 2026-03-05 19:32:43 +08:00
wr
eec2560fd2 技术监督用户信息迁移 2026-03-05 19:32:03 +08:00
wr
94037d588b 暂态事件报告功能下载 2026-02-28 15:30:35 +08:00
01a77fa92d 1.暂降事件报告 2026-02-27 09:40:12 +08:00
9d9150e418 Merge remote-tracking branch 'origin/main' 2026-02-27 09:35:44 +08:00
ee1ca85a5d 1.暂降事件报告 2026-02-27 09:35:38 +08:00
wr
2c3c716607 河北算法调整 2026-02-26 15:41:16 +08:00
wr
e1d17c63a2 微调 2026-02-26 08:38:03 +08:00
hzj
6234ac8ce9 系统配置合并 2026-02-11 14:34:33 +08:00
6c91774200 1.报告模板bug 2026-02-11 13:31:06 +08:00
fc951e913c 1.微调 2026-02-10 16:32:34 +08:00
d138d4353f 1.用户对象管理业务迁移 2026-02-10 14:48:04 +08:00
aecee4de49 1.用户对象管理业务迁移 2026-02-10 14:36:12 +08:00
hzj
fd04c21997 修改驾驶舱bug 2026-02-10 09:22:04 +08:00
08d8b5b488 Merge remote-tracking branch 'origin/main' 2026-02-09 16:14:05 +08:00
82457bc9c2 1.解决修改台账bug 2026-02-09 16:13:53 +08:00
hzj
63330a04a6 电能质量污区图bug 2026-02-09 16:11:14 +08:00
hzj
ad45661c3c 稳态合格率报告bug 2026-02-09 14:47:27 +08:00
wr
23de6313a6 Merge remote-tracking branch 'origin/main' 2026-02-06 15:09:30 +08:00
wr
7a5ef040bb 冀北数据周报 2026-02-06 15:09:17 +08:00
xy
140ed85108 报表优化 2026-02-06 09:57:15 +08:00
hzj
99ab77dcf0 暂降原因暂降类型那边没兼容大小写后缀 2026-02-03 13:42:28 +08:00
hzj
c772c9cd81 修改定版bug 2026-02-02 16:36:30 +08:00
cdf
996ec87ea8 适配达梦 2026-02-01 13:53:43 +08:00
hzj
b6eaff3b1e 修改定版bug 2026-01-30 14:58:15 +08:00
hzj
56bf5bb7c9 修改bug 2026-01-30 10:17:13 +08:00
wr
7410d32241 Merge remote-tracking branch 'origin/main' 2026-01-29 14:15:18 +08:00
wr
41ba37b723 河北数据中台业务参数调整 2026-01-29 10:30:13 +08:00
wr
3f77d30cfd 1.监测点异常统计报表调整 2026-01-28 11:26:52 +08:00
cdf
f71f87ced4 一键分配装置前置进程 2026-01-28 10:39:18 +08:00
xy
32295f60c0 报表添加接线方式、一二次值判断 2026-01-28 08:43:04 +08:00
hzj
d2945b0fb2 bug修改 2026-01-27 15:33:15 +08:00
hzj
133766a2c7 bug修改 2026-01-27 13:47:35 +08:00
xy
2a5a5087ad 微调 2026-01-26 19:30:33 +08:00
xy
4edb27d20b Merge remote-tracking branch 'origin/main' 2026-01-26 19:28:47 +08:00
xy
71d6636be0 物联短信发送调整 2026-01-26 19:28:37 +08:00
hzj
8ccdb84ea9 Merge remote-tracking branch 'origin/main' 2026-01-26 15:04:32 +08:00
hzj
5389903ed7 暂态模块bug修改 2026-01-26 15:02:25 +08:00
269 changed files with 16957 additions and 8238 deletions

View File

@@ -39,6 +39,7 @@
</snapshotRepository>
</distributionManagement>
<properties>
<spring.profiles.active>sjzx</spring.profiles.active>
<!--中间件目标地址-->
<!-- <middle.server.url>10.95.53.49</middle.server.url>-->
<middle.server.url>192.168.1.103</middle.server.url>
@@ -51,7 +52,7 @@
<!--nacos开启鉴权后的用户名-->
<nacos.username>nacos</nacos.username>
<!--nacos的ip:port-->
<nacos.password>nacos</nacos.password>
<nacos.password>njcnpqs</nacos.password>
<!--服务器发布内容为空-->
<nacos.namespace>hswbpm</nacos.namespace>
<!-- <nacos.namespace>30c701c4-2a94-49d9-82e1-76aa9456573f</nacos.namespace>-->

View File

@@ -2,8 +2,14 @@ package com.njcn.advance.api;
import com.njcn.advance.api.fallback.EventWaveAnalysisFeignClientFallbackFactory;
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -27,4 +33,7 @@ public interface EventWaveAnalysisFeignClient {
*/
@PostMapping("analysis")
HttpResult<EntityAdvancedData> analysis(@RequestParam("eventIndex") String eventIndex);
@PostMapping("analysisWlEvent")
HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex);
}

View File

@@ -32,6 +32,12 @@ public class EventWaveAnalysisFeignClientFallbackFactory implements FallbackFact
log.error("{}异常,降级处理,异常为:{}", "波形高级分析", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<EntityAdvancedData> analysisWlEvent(String eventIndex) {
log.error("{}异常,降级处理,异常为:{}", "物联测点波形高级分析异常", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -73,4 +73,10 @@ public class EventAnalysisDTO {
* 1 正常计算
*/
private Integer typeFlag = 1;
/**
* 文件全路径
* 适配物联的暂态事件解析 物联那边事件的路径是全路径,不需要拼接,这个参数可为空
*/
private String wlFilePath;
}

View File

@@ -26,8 +26,6 @@ import java.util.*;
public class AnalyWave {
/*****************************************
* 解析comtrate文件工具类
* author yexb根据Ww算法装换
@@ -94,7 +92,7 @@ public class AnalyWave {
** ** strFilePath *** cfg文件路径
* *** auth *** 读取方式 null则使用本地读取方式读取
******************************************/
public AnalyWaveModel.tagDataValue readComtrade(List<String> temCfgList,byte[] array, int iFlag) {
public AnalyWaveModel.tagDataValue readComtrade(List<String> temCfgList, byte[] array, int iFlag) {
//初始化参数
ComtradeCfg = new AnalyWaveModel.tagComtradeCfg();
RatesCfg = new AnalyWaveModel.tagRates();
@@ -163,148 +161,145 @@ public class AnalyWave {
iterable.next();
String[] strTempArray;// 读取cfg文件
try {
nFreq = 0f;//WW 2019-11-14
String strFileLine = iterable.next();
nFreq = 0f;//WW 2019-11-14
String strFileLine = iterable.next();
strTempArray = strFileLine.split(",");
for (int i = 0; i < strTempArray.length; i++) {
switch (i) {
case 0:// 总个数
ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]);
break;
case 1:// 模拟量的个数
{
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
ComtradeCfg.nAnalogNum = Integer.parseInt(str);
}
break;
case 2:// 开关量的个数
{
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
ComtradeCfg.nDigitalNum = Integer.parseInt(str);
}
break;
}
}
// 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道
for (int i = 0; i < ComtradeCfg.nChannelNum; i++) {
AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg();
ComtradeCfg.OneChannleCfg.add(OneChannlecfg);
strFileLine = iterable.next();
strTempArray = strFileLine.split(",");
// 配置总共13项
for (int j = 0; j < strTempArray.length; j++) {
switch (j) {
case 0:// 通道序号
OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]);
break;
case 1:// 通道名称
OneChannlecfg.szChannleName = strTempArray[j];
break;
case 2:// 相位名称
OneChannlecfg.szPhasicName = strTempArray[j];
break;
case 3:// 监视的通道名称
OneChannlecfg.szMonitoredChannleName = strTempArray[j];
break;
case 4:// 通道的单位
OneChannlecfg.szUnitName = strTempArray[j];
break;
case 5:// 通道的系数
OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]);
break;
case 6:// 通道的偏移量
OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]);
break;
case 7:// 起始采样时间的偏移量
OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]);
break;
case 8:// 采样值的最小值
OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]);
break;
case 9:// 采样值的最大值
OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]);
break;
case 10:// 一次变比
OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]);
break;
case 11:// 二次变比
OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]);
break;
case 12:// 一次值还是二次值标志
OneChannlecfg.szValueType = strTempArray[j];
break;
}
}
}
// 采样频率
strFileLine = iterable.next();
float fFreq = Float.parseFloat(strFileLine);
nFreq = (float) fFreq;//WW 2019-11-14
// 采样段数
strFileLine = iterable.next();
int nRates = Integer.parseInt(strFileLine);
RatesCfg.nRates = nRates;
// 获得每段的采样率
long nOffset = 0;
for (int i = 0; i < nRates; i++) {
strFileLine = iterable.next();
strTempArray = strFileLine.split(",");
for (int i = 0; i < strTempArray.length; i++) {
switch (i) {
case 0:// 总个数
ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]);
AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate();
RatesCfg.OneRate.add(OneRate);
for (int j = 0; j < strTempArray.length; j++) {
switch (j) {
case 0:// 单周波采样点数
OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14
break;
case 1:// 总点数 //这里的strTemp是一个偏移量
OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset);
nOffset += OneRate.nSampleNum;
break;
case 1:// 模拟量的个数
{
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
ComtradeCfg.nAnalogNum = Integer.parseInt(str);
}
break;
case 2:// 开关量的个数
{
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
ComtradeCfg.nDigitalNum = Integer.parseInt(str);
}
break;
}
}
}
// 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道
for (int i = 0; i < ComtradeCfg.nChannelNum; i++) {
AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg();
ComtradeCfg.OneChannleCfg.add(OneChannlecfg);
strFileLine = iterable.next();
strTempArray = strFileLine.split(",");
// 配置总共13项
for (int j = 0; j < strTempArray.length; j++) {
switch (j) {
case 0:// 通道序号
OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]);
break;
case 1:// 通道名称
OneChannlecfg.szChannleName = strTempArray[j];
break;
case 2:// 相位名称
OneChannlecfg.szPhasicName = strTempArray[j];
break;
case 3:// 监视的通道名称
OneChannlecfg.szMonitoredChannleName = strTempArray[j];
break;
case 4:// 通道的单位
OneChannlecfg.szUnitName = strTempArray[j];
break;
case 5:// 通道的系数
OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]);
break;
case 6:// 通道的偏移量
OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]);
break;
case 7:// 起始采样时间的偏移量
OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]);
break;
case 8:// 采样值的最小值
OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]);
break;
case 9:// 采样值的最大值
OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]);
break;
case 10:// 一次变比
OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]);
break;
case 11:// 二次变比
OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]);
break;
case 12:// 一次值还是二次值标志
OneChannlecfg.szValueType = strTempArray[j];
break;
}
}
}
// 采样频率
strFileLine = iterable.next();
float fFreq = Float.parseFloat(strFileLine);
nFreq = (float) fFreq;//WW 2019-11-14
// 采样段数
strFileLine = iterable.next();
int nRates = Integer.parseInt(strFileLine);
RatesCfg.nRates = nRates;
// 获得每段的采样率
long nOffset = 0;
for (int i = 0; i < nRates; i++) {
strFileLine = iterable.next();
strTempArray = strFileLine.split(",");
AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate();
RatesCfg.OneRate.add(OneRate);
for (int j = 0; j < strTempArray.length; j++) {
switch (j) {
case 0:// 单周波采样点数
OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14
break;
case 1:// 总点数 //这里的strTemp是一个偏移量
OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset);
nOffset += OneRate.nSampleNum;
break;
}
}
}
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
// 波形起始时间
strFileLine = iterable.next();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
TimeTrige = sdf.parse(strFileLine);
// 暂态触发时间
strFileLine = iterable.next();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
TimeWave = sdf.parse(strFileLine);
Calendar calendar = Calendar.getInstance();
calendar.setTime(TimeWave);
firstMs = calendar.get(Calendar.MILLISECOND);
firstTime = calendar.getTime();
long a = TimeWave.getTime();
long b = TimeTrige.getTime();
int c = (int) (a - b);
if (c >= 90 && c <= 110) {
iPush = 100;
} else if (c >= 190 && c <= 210) {
iPush = 200;
}
// 赋值编码格式(二进制)
strBinType = iterable.next().toUpperCase();
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
// 波形起始时间
strFileLine = iterable.next();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
TimeTrige = sdf.parse(strFileLine);
// 暂态触发时间
strFileLine = iterable.next();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
TimeWave = sdf.parse(strFileLine);
Calendar calendar = Calendar.getInstance();
calendar.setTime(TimeWave);
firstMs = calendar.get(Calendar.MILLISECOND);
firstTime = calendar.getTime();
long a = TimeWave.getTime();
long b = TimeTrige.getTime();
int c = (int) (a - b);
if (c >= 90 && c <= 110) {
iPush = 100;
} else if (c >= 190 && c <= 210) {
iPush = 200;
}
// 赋值编码格式(二进制)
strBinType = iterable.next().toUpperCase();
} catch (Exception e) {
e.printStackTrace();
logger.error("读取文件内容出错"+e.getMessage());
logger.error("读取文件内容出错" + e.getMessage());
return false;
}finally {
} finally {
}
@@ -319,15 +314,8 @@ public class AnalyWave {
private List<List<Float>> AnalyseComtradeDat(byte[] array, int iFlag) {
float xValueAll = 0;//初始化xValue的值
boolean blxValue = false;//判断是否首次登陆
List<List<Float>> listWaveData = new ArrayList<>();//返回数据
try {
// 计算每个单独的数据块的大小 4字节的序号 4字节的时间 2字节的值
// 示例中的排布是 4字节的序号 4字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节)
// IC(2字节)
@@ -470,7 +458,7 @@ public class AnalyWave {
{
if (ComtradeCfg.OneChannleCfg.get(j).fPrimary != 0.0f)//根据cfg内的变比将一次值转换成二次值
{
fValue = ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary;
fValue = fValue * ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary;
} else {
fValue = fValue;
}
@@ -500,7 +488,7 @@ public class AnalyWave {
} catch (Exception e) {
logger.error("读取文件出错:" + e.getMessage());
return listWaveData;
}finally {
} finally {
}

View File

@@ -47,7 +47,7 @@ import java.util.List;
* angle_diff_cn C相相位负跳变
* bph_max_value 不平衡度(单位%
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonIgnoreProperties(ignoreUnknown = true,value = {"pointer"})
public class BackData extends Structure {
public int qvvr_cata_cause[] = new int[256];
public int qvvr_phasetype[] = new int[256];

View File

@@ -23,8 +23,13 @@ public class CauseStruct extends Structure {
public static class ByValue extends CauseStruct implements Structure.ByValue {
}
// @Override
// protected List<String> getFieldOrder() { // 返回值填入的顺序
// return Arrays.asList(new String[] { "cause", "no_cal" });
// }
@Override
protected List<String> getFieldOrder() { // 返回值填入的顺序
return Arrays.asList(new String[] { "cause", "no_cal" });
protected List<String> getFieldOrder() {
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "threshold", "cause", "no_cal");
}
}

View File

@@ -35,8 +35,13 @@ public class Rect extends Structure {
}
// @Override
// protected List<String> getFieldOrder() {
// return Arrays.asList(new String[] { "evt_num","evt_buf" });
// }
@Override
protected List<String> getFieldOrder() {
return Arrays.asList(new String[] { "evt_num","evt_buf" });
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "evt_num", "evt_buf");
}
}

View File

@@ -34,7 +34,6 @@ public class EventWaveAnalysisController extends BaseController {
private final EventWaveAnalysisService eventWaveAnalysisService;
@PostMapping("analysis")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("波形高级分析")
@@ -43,6 +42,15 @@ public class EventWaveAnalysisController extends BaseController {
String methodDescribe = getMethodDescribe("analysis");
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysis(eventIndex);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
}
@PostMapping("analysisWlEvent")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("物联事件波形高级分析")
@ApiImplicitParam(name = "eventIndex", value = "暂降事件id", required = true)
public HttpResult<EntityAdvancedData> analysisWlEvent(@RequestParam("eventIndex") String eventIndex) {
String methodDescribe = getMethodDescribe("analysisWlEvent");
EntityAdvancedData entityAdvancedData = eventWaveAnalysisService.analysisWlEvent(eventIndex);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, entityAdvancedData, methodDescribe);
}
}

View File

@@ -1,11 +1,14 @@
package com.njcn.advance.event.service.impl;
import cn.hutool.core.util.StrUtil;
import com.njcn.advance.enums.EnumEvt;
import com.njcn.advance.event.cause.jna.QvvrCauseDLL;
import com.njcn.advance.event.cause.model.DataFeature;
import com.njcn.advance.event.type.jna.*;
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
import com.njcn.advance.event.service.IEventAdvanceService;
import com.njcn.advance.pojo.dto.waveAnalysis.Rect;
import com.njcn.advance.utils.Utils;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.event.file.component.WaveFileComponent;
@@ -18,6 +21,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.List;
@@ -44,11 +48,12 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
public EventAnalysisDTO analysisCauseAndType(EventAnalysisDTO eventAnalysis) {
WaveDataDTO waveDataDTO;
String waveName = eventAnalysis.getWaveName();
String wlFilePath = eventAnalysis.getWlFilePath();
String cfgPath, datPath, cfgPath2, datPath2;
String ip = eventAnalysis.getIp();
if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
cfgPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
datPath = Objects.isNull(wlFilePath) ? generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
log.info("本地磁盘波形文件路径----" + cfgPath);
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
@@ -57,11 +62,11 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
}
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
} else {
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
cfgPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG : wlFilePath + GeneralConstant.CFG;
datPath = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT : wlFilePath + GeneralConstant.DAT;
//适配文件后缀小写
cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
cfgPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase() : wlFilePath + GeneralConstant.CFG.toLowerCase();
datPath2 = Objects.isNull(wlFilePath) ? OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase() : wlFilePath + GeneralConstant.DAT.toLowerCase();
log.info("文件服务器波形文件路径----" + cfgPath);
try (
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
@@ -70,7 +75,7 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
}
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
} catch (Exception e) {
try {
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
@@ -122,6 +127,21 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
}
}
}
String str = WriteData2File(typeDataStruct);
if (Objects.isNull(wlFilePath)) {
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH;
String hdrName = waveName + GeneralConstant.HDR_LOWER;
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
} else {
// comtrade/00:B7:8D:00:A8:7A/PQMonitor_PQM1_00100_20260204_162453_071_WAV.hdr
String fullPath = wlFilePath + GeneralConstant.HDR_LOWER;
int lastSlashIndex = fullPath.lastIndexOf('/');
String hdrPath = fullPath.substring(0, lastSlashIndex + 1);
String hdrName = fullPath.substring(lastSlashIndex + 1);
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
}
//上传HR
eventAnalysis.setType(globalFaultType);
} else {
eventAnalysis.setType(DataFeature.TYPE10);
@@ -158,4 +178,306 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
System.out.println("cause:" + eventAnalysis);
return eventAnalysis;
}
public String WriteData2File(QvvrDLL.QvvrDataStruct rect) throws Exception {
StringBuilder stringBuilder = new StringBuilder("{" + EnumEvt.NEWLINE.getProperty());
/**
* @写入返回事件总数
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.EVT_NUM.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_num), 1));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.EVT_BUF.getProperty()) + "[");
/**
* @写入返回事件参数
*/
for (int i = 0; i < rect.evt_num; i++) {
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(2));
/**
* @波形起始点
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_A.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_a), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_B.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_b), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.POW_C.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].POW_c), 3));
/**
* @跳变段电压变化率
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VA.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Va), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VB.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Vb), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.VOLTAGECHANGE_VC.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].Voltagechange_Vc), 3));
/**
* @持续时间
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.HOLD_TIME_RMS.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].hold_time_rms), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.HOLD_TIME_DQ.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(rect.evt_buf[i].hold_time_dq), 3));
/**
* @分段数目
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.SEG_T_NUM.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].SEG_T_num), 3));
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.SEG_T_IDX.getProperty()));
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(3));
for (int j = 0; j < rect.evt_buf[i].SEG_T_num; j++) {
stringBuilder.append(EnumEvt.setEvtProperty(Utils.int2String(j)));
if (rect.evt_buf[i].SEG_T_num - 1 == j) {
stringBuilder.append(Utils.int2String(rect.evt_buf[i].SEG_T_idx[j]));
} else {
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].SEG_T_idx[j]), 4));
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @特征幅值
*/
stringBuilder.append(EnumEvt.setEvtProperty(EnumEvt.U_MIN_NUM.getProperty()));
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(rect.evt_buf[i].u_min_num), 3));
/**
* @最小值位置
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ORDER_MIN_IDX.getProperty(), null,
rect.evt_buf[i].order_min_idx[k]);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @A相电压特征值
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.UA_MIN.getProperty(), rect.evt_buf[i].ua_min[k], null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @B相电压特征值
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.UB_MIN.getProperty(), rect.evt_buf[i].ub_min[k], null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @C相电压特征值
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.UC_MIN.getProperty(), rect.evt_buf[i].uc_min[k], null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @三相电压特征值
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.U3_MIN.getProperty(), rect.evt_buf[i].u3_min[k], null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @A相相位正跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_AP.getProperty(), rect.evt_buf[i].angle_diff_ap[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @B相相位正跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_BP.getProperty(), rect.evt_buf[i].angle_diff_bp[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @C相相位正跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_CP.getProperty(), rect.evt_buf[i].angle_diff_cp[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @A相相位负跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_AN.getProperty(), rect.evt_buf[i].angle_diff_an[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @B相相位负跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_BN.getProperty(), rect.evt_buf[i].angle_diff_bn[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @C相相位负跳变
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.ANGLE_DIFF_CN.getProperty(), rect.evt_buf[i].angle_diff_cn[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @不平衡度
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.BPH_MAX_VALUE.getProperty(), rect.evt_buf[i].bph_max_value[k],
null);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @暂降原因
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_CATA_CAUSE.getProperty(), null,
rect.evt_buf[i].qvvr_cata_cause[k]);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @暂降类型
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_CATA_TYPE.getProperty(), null,
rect.evt_buf[i].qvvr_cata_type[k]);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(3), 3));
/**
* @暂降相别
*/
for (int k = 0; k < rect.evt_buf[i].u_min_num; k++) {
setEigenVlaue(k, stringBuilder, EnumEvt.QVVR_PHASETYPE.getProperty(), null,
rect.evt_buf[i].qvvr_phasetype[k]);
if (rect.evt_buf[i].u_min_num - 1 == k) {
stringBuilder.delete(stringBuilder.lastIndexOf(","), stringBuilder.length() - 1);
}
}
stringBuilder.append(EnumEvt.setClose(3));
if (rect.evt_num - 1 == i) {
stringBuilder.append(EnumEvt.setClose(2));
stringBuilder.append("]" + EnumEvt.ENTER.getProperty());
} else {
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(2), 2));
}
}
stringBuilder.append("}");
return stringBuilder.toString();
}
/**
* @特征值处理
*/
public void setEigenVlaue(int len, StringBuilder stringBuilder, String string, Float f, Integer integer) {
if (0 == len) {
stringBuilder.append(EnumEvt.setEvtProperty(string));
stringBuilder.append(EnumEvt.setNewLine() + EnumEvt.setTab(3));
}
stringBuilder.append(EnumEvt.setEvtProperty(Integer.toString(len)));
if (null == f) {
stringBuilder.append(EnumEvt.setEnter(Utils.int2String(integer.intValue()), 4));
} else {
stringBuilder.append(EnumEvt.setEnter(Utils.float2String(f.floatValue()), 4));
}
}
}

View File

@@ -11,4 +11,6 @@ import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
public interface EventWaveAnalysisService {
EntityAdvancedData analysis(String eventIndex);
EntityAdvancedData analysisWlEvent(String eventIndex);
}

View File

@@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.govern.voltage.SgMachineMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
import com.njcn.advance.pojo.param.govern.voltage.SgUserParam;
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
import com.njcn.advance.pojo.po.govern.voltage.SgUser;
import com.njcn.advance.pojo.vo.govern.voltage.SgMachineVO;
import com.njcn.advance.service.govern.voltage.ISgMachineService;
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
@@ -56,12 +58,34 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
@Override
public String addMachine(SgMachineParam sgMachineParam) {
SgMachine sgMachine = new SgMachine();
checkMachineName(sgMachineParam, false);
BeanUtil.copyProperties(sgMachineParam, sgMachine);
//默认为正常状态
sgMachine.setState(DataStateEnum.ENABLE.getCode());
this.save(sgMachine);
return sgMachine.getId();
}
/**
* 校验参数,检查是否存在相同名称的业务用户
*/
private void checkMachineName(SgMachineParam sgMachineParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgMachine> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgMachine::getName, sgMachineParam.getName())
.eq(SgMachine::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (sgMachineParam instanceof SgMachineParam.SgMachineUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgMachine::getId, ((SgMachineParam.SgMachineUpdateParam) sgMachineParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
/**
* 更新设备
@@ -70,6 +94,8 @@ public class SgMachineServiceImpl extends ServiceImpl<SgMachineMapper, SgMachine
@Override
public boolean updateSgMachine(SgMachineParam.SgMachineUpdateParam updateParam) {
SgMachine sgMachine = new SgMachine();
checkMachineName(updateParam, true);
BeanUtil.copyProperties(updateParam, sgMachine);
return this.updateById(sgMachine);
}

View File

@@ -2,12 +2,15 @@ package com.njcn.advance.service.govern.voltage.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.advance.enums.AdvanceResponseEnum;
import com.njcn.advance.mapper.govern.voltage.SgSensitiveUnitMapper;
import com.njcn.advance.pojo.param.govern.voltage.SgMachineParam;
import com.njcn.advance.pojo.param.govern.voltage.SgSensitiveUnitParam;
import com.njcn.advance.pojo.po.govern.voltage.SgMachine;
import com.njcn.advance.pojo.po.govern.voltage.SgSensitiveUnit;
import com.njcn.advance.pojo.vo.govern.voltage.SgSensitiveUnitVO;
import com.njcn.advance.service.govern.voltage.ISgSensitiveUnitService;
@@ -54,12 +57,34 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
@Override
public String addSensitiveUnit(SgSensitiveUnitParam sgSensitiveUnitParam) {
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
checkSensitiveUnitName(sgSensitiveUnitParam, false);
BeanUtil.copyProperties(sgSensitiveUnitParam, sgSensitiveUnit);
//默认为正常状态
sgSensitiveUnit.setState(DataStateEnum.ENABLE.getCode());
this.save(sgSensitiveUnit);
return sgSensitiveUnit.getId();
}
/**
* 校验参数,检查是否存在相同名称的业务用户
*/
private void checkSensitiveUnitName(SgSensitiveUnitParam sgSensitiveUnitParam, boolean isExcludeSelf) {
LambdaQueryWrapper<SgSensitiveUnit> sgUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
sgUserLambdaQueryWrapper
.eq(SgSensitiveUnit::getName, sgSensitiveUnitParam.getName())
.eq(SgSensitiveUnit::getState, DataStateEnum.ENABLE.getCode());
//更新的时候,需排除当前记录
if (isExcludeSelf) {
if (sgSensitiveUnitParam instanceof SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) {
sgUserLambdaQueryWrapper.ne(SgSensitiveUnit::getId, ((SgSensitiveUnitParam.SgSensitiveUnitUpdateParam) sgSensitiveUnitParam).getId());
}
}
int countByAccount = this.count(sgUserLambdaQueryWrapper);
//大于等于1个则表示重复
if (countByAccount >= 1) {
throw new BusinessException(AdvanceResponseEnum.SG_USER_NAME_REPEAT);
}
}
/**
* 更新元器件
@@ -69,6 +94,8 @@ public class SgSensitiveUnitServiceImpl extends ServiceImpl<SgSensitiveUnitMappe
@Override
public boolean updateSgSensitiveUnit(SgSensitiveUnitParam.SgSensitiveUnitUpdateParam updateParam) {
SgSensitiveUnit sgSensitiveUnit = new SgSensitiveUnit();
checkSensitiveUnitName(updateParam, true);
BeanUtil.copyProperties(updateParam, sgSensitiveUnit);
return this.updateById(sgSensitiveUnit);
}

View File

@@ -48,6 +48,7 @@ import io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -511,7 +512,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
lambdaQueryWrapper.like(RmpEventDetailAssPO::getContentDes, baseParam.getSearchValue());
}
lambdaQueryWrapper.between(RmpEventDetailAssPO::getTimeId, timeV.get(0), timeV.get(1))
.orderByAsc(RmpEventDetailAssPO::getTimeId);
.orderByDesc(RmpEventDetailAssPO::getTimeId);
return rmpEventDetailAssMapper.selectPage(new Page<>(PageFactory.getPageNum(baseParam), PageFactory.getPageSize(baseParam)), lambdaQueryWrapper);
}
@@ -733,7 +734,7 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
List<AdvanceEventDetailVO> advanceEventDetailVOLsit = querySagEventsAll(startTime, endTime);
advanceEventDetailVOLsit = advanceEventDetailVOLsit.stream().filter(temp-> StringUtils.isNotEmpty(temp.getAdvanceType())).collect(Collectors.toList());
for (AdvanceEventDetailVO advanceEventDetailVO : advanceEventDetailVOLsit) { // 获取监测点线路序号
//母线id
String nodePhysics = advanceEventDetailVO.getVoltageId();

View File

@@ -2,13 +2,16 @@ package com.njcn.advance.service.impl;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.advance.enums.EnumEvt;
import com.njcn.advance.mapper.RmpEventAdvanceMapper;
import com.njcn.advance.pojo.dto.waveAnalysis.*;
import com.njcn.advance.service.EventWaveAnalysisService;
import com.njcn.advance.utils.*;
import com.njcn.advance.utils.JnaCallBalance;
import com.njcn.advance.utils.JnaCallDllOrSo;
import com.njcn.advance.utils.Utils;
import com.njcn.advance.utils.WaveUtils;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.api.LineFeignClient;
@@ -26,7 +29,10 @@ import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -81,7 +87,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG);
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
} catch (Exception e) {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
try {
inputStreamCfg = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
inputStreamDat = fileStorageUtil.getFileStream(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
} catch (Exception e1) {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
}
}
//读取
@@ -164,17 +176,13 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
causeStruct.smp_len = pitchList.size();
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
String hdrStr = waveUtils.getFile(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.HDR);
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
if (rmpEventDetailPO.getDealFlag() != 1) {
//如果存在三个文件但是没有调用dll/so计算
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
}
@@ -208,6 +216,171 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
return entityAdvancedData;
}
@Override
public EntityAdvancedData analysisWlEvent(String eventIndex) {
TimeInterval timeInterval = new TimeInterval();
//调用方法获取暂降事件详情
RmpEventDetailPO rmpEventDetailPO = rmpEventAdvanceMapper.selectById(eventIndex);
EntityAdvancedData entityAdvancedData;
if (Objects.isNull(rmpEventDetailPO.getFileFlag())) {
throw new BusinessException("系统检测到波形文件未从装置招到本地,请联系管理员");
}
if (rmpEventDetailPO.getFileFlag() == 1) {
//获取所有暂态原因
List<DictData> dicDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
Map<Integer, DictData> eventTypeMap = dicDataList.stream().collect(Collectors.toMap(DictData::getAlgoDescribe, Function.identity()));
InputStream inputStreamCfg;
InputStream inputStreamDat;
try {
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath()+ GeneralConstant.CFG);
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT);
} catch (Exception e) {
try {
inputStreamCfg = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.CFG.toLowerCase());
inputStreamDat = fileStorageUtil.getFileStream(rmpEventDetailPO.getWavePath() + GeneralConstant.DAT.toLowerCase());
} catch (Exception e1) {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
}
}
//读取
BufferedReader bufferedReader;
InputStreamReader read = null;
String strFileLine;
byte[] array = {};
List<String> temCfgList = new ArrayList<>();
try {
// 判断文件是否存在
array = IoUtil.readBytes(inputStreamDat);
// 考虑到编码格式
read = new InputStreamReader(inputStreamCfg, StandardCharsets.UTF_8);
bufferedReader = new BufferedReader(read);
while ((strFileLine = bufferedReader.readLine()) != null) {
temCfgList.add(strFileLine);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (read != null) {
read.close();
}
if (inputStreamDat != null) {
inputStreamDat.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
//原始波形
WaveData waveOriginalData = getWavedata(rmpEventDetailPO, temCfgList, array, 3);
List<List<Float>> originalList = waveOriginalData.getSunData();
entityAdvancedData = new EntityAdvancedData(originalList.size());
for (int i = 0; i < originalList.size(); i++) {
//坐标轴
entityAdvancedData.smp_x[i] = originalList.get(i).get(0);
entityAdvancedData.smp_a[i] = originalList.get(i).get(1);
entityAdvancedData.smp_b[i] = originalList.get(i).get(2);
entityAdvancedData.smp_c[i] = originalList.get(i).get(3);
}
entityAdvancedData.smp_len = originalList.size();
//抽点方法计算波形
WaveData wavePitchData = getWavedata(rmpEventDetailPO, temCfgList, array, 0);
List<List<Float>> pitchList = wavePitchData.getSunData();
// 将获取到的数据填充到结构体内
Rect rect = new Rect();
CauseStruct causeStruct = new CauseStruct();
for (int i = 0; i < pitchList.size(); i++) {
rect.smp_va[i] = pitchList.get(i).get(1);
causeStruct.smp_va[i] = pitchList.get(i).get(1);
rect.smp_vb[i] = pitchList.get(i).get(2);
causeStruct.smp_vb[i] = pitchList.get(i).get(2);
rect.smp_vc[i] = pitchList.get(i).get(3);
causeStruct.smp_vc[i] = pitchList.get(i).get(3);
}
rect.smp_len = pitchList.size();
//超过60s的波形直接抛异常给上面处理
/*
* 波形最大值计算
*/
int MAX_LENGTH = 128 * 3000;
if (rect.smp_len >= MAX_LENGTH) {
throw new BusinessException("波形超过60S");
}
rect.smp_rate = (int) wavePitchData.getnOneWaveNum();
causeStruct.smp_len = pitchList.size();
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
if (rmpEventDetailPO.getDealFlag() != 1) {
//如果存在三个文件但是没有调用dll/so计算
getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
} else {
//已经处理过了那就根据id获取暂降原因
String reason = rmpEventDetailPO.getAdvanceReason();
List<DictData> reasonList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
Map<String, DictData> eventReasonMap = reasonList.stream().collect(Collectors.toMap(DictData::getId, Function.identity()));
if (ObjectUtil.isNotNull(eventReasonMap.get(reason))) {
entityAdvancedData.sagReason[0] = eventReasonMap.get(reason).getName();
}
}
String hdrStr = null;
try {
hdrStr = waveUtils.getFile(rmpEventDetailPO.getWavePath() + GeneralConstant.HDR.toLowerCase());
} catch (Exception e) {
log.error("读取文件服务器波形数据异常:{}",e.getMessage());
}
if (hdrStr != null) {
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
}
// if (rmpEventDetailPO.getDealFlag() != 1) {
// //如果存在三个文件但是没有调用dll/so计算
// getDataFromDLL(rmpEventDetailPO, waveOriginalData, rect, entityAdvancedData, causeStruct);
// }
/****************************************************************
* 根据返回的结果计算,获取暂降类型描述
****************************************************************/
if (entityAdvancedData.backNumber > 0) {
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
entityAdvancedData.sagType[i] = eventTypeMap.get(entityAdvancedData.evt_buf[i].qvvr_cata_type[0]).getName();
switch (entityAdvancedData.evt_buf[i].qvvr_phasetype[0]) {
case 1:
entityAdvancedData.sagPhaseType[i] = "单相";
break;
case 2:
entityAdvancedData.sagPhaseType[i] = "两相";
break;
case 3:
entityAdvancedData.sagPhaseType[i] = "三相";
break;
default:
break;
}
}
}
} else {
throw new BusinessException("暂降cfg,dat文件缺失,请联系管理员");
}
log.info("高级算法波形计算" + timeInterval.interval());
return entityAdvancedData;
}
/**
* 事件未进行高级算法处理系统调用dll处理并保存结果
@@ -352,7 +525,7 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
if (StrUtil.isBlank(rmpEventDetailPOQuery.getAdvanceReason())) {
//暂降原因计算
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_dll_cause");
JnaCallDllOrSo jnaCallDllReason = new JnaCallBalance("qvvr_cause_dll");
jnaCallDllReason.setPath();
JnaCallBalance.Balancelibrary CAUSE = JnaCallBalance.Balancelibrary.INSTANTCE;

View File

@@ -1,11 +1,11 @@
package com.njcn.advance.utils;
import cn.hutool.core.io.resource.ClassPathResource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import java.io.*;
import java.net.URLDecoder;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
/**
* pqs
@@ -20,21 +20,20 @@ public class JnaCallDllOrSo {
public JnaCallDllOrSo(String name) {
super();
String suffix = ".dll";
try {
String os = System.getProperty("os.name");
// windows操作系统为1 否则为0
int beginIndex = os != null && os.startsWith("Windows") ? 1 : 0;
String nameDll;
if (beginIndex == 0) {
//linux操作系统
nameDll = "lib" + name + "_dll";
suffix = ".so";
nameDll = "lib" + name + ".so";
} else {
nameDll = name;
if (!name.endsWith(".dll")) {
nameDll = name + ".dll";
}
}
String tem = "/usr/local/dllFile/"+ nameDll.concat(suffix);
String tem = "/usr/local/dllFile/"+ nameDll;
File dockerFile = new File(tem);
if(!dockerFile.exists()){
boolean f = dockerFile.getParentFile().mkdirs();
@@ -42,7 +41,11 @@ public class JnaCallDllOrSo {
System.out.println("文件夹创建:"+f);
System.out.println("文件创建:"+d);
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(nameDll.concat(suffix))) {
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream(nameDll)) {
if (inputStream == null) {
log.error("找不到资源文件: {}", nameDll);
throw new FileNotFoundException("找不到资源文件: " + nameDll);
}
try (FileOutputStream outputStream = new FileOutputStream(dockerFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
@@ -53,9 +56,11 @@ public class JnaCallDllOrSo {
}
}
this.path = dockerFile.getAbsolutePath();
System.out.println("动态库路径: " + this.path);
} catch (Exception e) {
log.error("调用高级算法文件异常,异常信息如下:");
log.error(e.getMessage());
log.error(e.getMessage(), e);
throw new RuntimeException("加载动态库失败: " + e.getMessage(), e);
}

View File

@@ -0,0 +1,56 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10211
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
username: @nacos.username@
password: @nacos.password@
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.advance.pojo

View File

@@ -0,0 +1,61 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10211
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.advance.pojo
mqtt:
client-id: @artifactId@${random.value}

View File

@@ -1,57 +1,3 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10211
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-Id: share-config-datasource-db.yaml
refresh: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.advance.pojo
mqtt:
client-id: @artifactId@${random.value}
profiles:
active: sjzx

View File

@@ -0,0 +1,52 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10214
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
username: @nacos.username@
password: @nacos.password@
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.user.pojo

View File

@@ -0,0 +1,57 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10214
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.user.pojo
mqtt:
client-id: @artifactId@${random.value}

View File

@@ -1,53 +1,3 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10214
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-Id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.user.pojo
mqtt:
client-id: @artifactId@${random.value}
profiles:
active: @spring.profiles.active@

View File

@@ -88,7 +88,7 @@ public class BpmSignParam extends BaseEntity implements Serializable {
private String name;
@ApiModelProperty("标识key")
private String key;
private String signKey;
}

View File

@@ -67,8 +67,8 @@ public class BpmCategoryServiceImpl extends ServiceImpl<BpmCategoryMapper, BpmCa
@Override
public Page<BpmCategoryVO> getCategoryPage(BpmCategoryParam.BpmCategoryQueryParam bpmCategoryQueryParam) {
QueryWrapper<BpmCategoryVO> categoryVOQueryWrapper = new QueryWrapper<>();
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getName())) {
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getName());
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getSearchValue())) {
categoryVOQueryWrapper.like("bpm_category.name", bpmCategoryQueryParam.getSearchValue());
}
if (StrUtil.isNotBlank(bpmCategoryQueryParam.getCode())) {

View File

@@ -106,8 +106,8 @@ public class BpmSignServiceImpl extends ServiceImpl<BpmSignMapper, BpmSign> impl
bpmSignVOQueryWrapper.like("bpm_sign.name", bpmSignQueryParam.getName());
}
if (StrUtil.isNotBlank(bpmSignQueryParam.getKey())) {
bpmSignVOQueryWrapper.like("bpm_sign.signKey", bpmSignQueryParam.getKey());
if (StrUtil.isNotBlank(bpmSignQueryParam.getSignKey())) {
bpmSignVOQueryWrapper.like("bpm_sign.sign_key", bpmSignQueryParam.getSignKey());
}
bpmSignVOQueryWrapper.eq("bpm_sign.state", DataStateEnum.ENABLE.getCode());
bpmSignVOQueryWrapper.orderByAsc("bpm_sign.sort");

View File

@@ -0,0 +1,71 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10321
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Shanghai
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
username: @nacos.username@
password: @nacos.password@
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
flowable:
database-schema-update: false
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
async-executor-activate: false
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
type-aliases-package: com.njcn.bpm.pojo
gw:
url: dwzyywzt-pms3-proxy.com
code: 13B9B47F1E483324E05338297A0A0595

View File

@@ -0,0 +1,76 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10321
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Shanghai
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
username: @nacos.username@
password: @nacos.password@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: bpm-config.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
flowable:
database-schema-update: false
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
async-executor-activate: false
#项目日志的配置
logging:
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
type-aliases-package: com.njcn.bpm.pojo
gw:
url: dwzyywzt-pms3-proxy.com
code: 13B9B47F1E483324E05338297A0A0595
mqtt:
client-id: @artifactId@${random.value}

View File

@@ -1,72 +1,3 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10321
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Shanghai
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-Id: bpm-config.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
max-file-size: 100MB
max-request-size: 100MB
flowable:
database-schema-update: false
db-history-used: true # flowable6 默认 true 生成信息表,无需手动设置
check-process-definitions: false # 设置为 false禁用 /resources/processes 自动部署 BPMN XML 流程
history-level: full # full保存历史数据的最高级别可保存全部流程相关细节包括流程流转各节点参数
async-executor-activate: false
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
type-aliases-package: com.njcn.bpm.pojo
gw:
url: dwzyywzt-pms3-proxy.com
code: 13B9B47F1E483324E05338297A0A0595
mqtt:
client-id: @artifactId@${random.value}
profiles:
active: @spring.profiles.active@

View File

@@ -97,11 +97,11 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<!--mqtt相关依赖-->
<dependency>
<groupId>com.github.tocrhz</groupId>
<artifactId>mqtt-spring-boot-starter</artifactId>
</dependency>
<!-- &lt;!&ndash;mqtt相关依赖&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.github.tocrhz</groupId>-->
<!-- <artifactId>mqtt-spring-boot-starter</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->

View File

@@ -75,9 +75,9 @@ public interface PatternRegex {
String ROLE_REGEX = "^[a-zA-Z][a-zA-Z0-9]{2,50}$";
/**
* 部门名称由汉字组成长度为0-20
* 部门名称由汉字组成长度为0-32 前端统一32了这边改下长度
*/
String DEPT_NAME_REGEX = "^[\\u4e00-\\u9fa5]{1,20}$";
String DEPT_NAME_REGEX = "^[\\u4e00-\\u9fa5]{1,32}$";
/**
* 字典名称包括中文、数字、字母、罗马数字、括号以及点号
@@ -258,7 +258,7 @@ public interface PatternRegex {
/**
* 任意字符长度在1-20位常用于名称、编码等常规录入
*/
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,20}$";
String ALL_CHAR_1_20 = "^[-_A-Za-z0-9\\u4e00-\\u9fa5]{1,32}$";
String SPECIALCHARACTER ="[<>%'%;()&+/\\\\-\\\\\\\\_|@*?#$!,.]|html";

View File

@@ -15,6 +15,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import lombok.Data;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.math.BigDecimal;
@@ -32,6 +33,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.lang.Integer.parseInt;
@@ -281,6 +283,30 @@ public class PubUtils {
}
}
/**
* 用于获取对象中前缀一样后缀为2~50的属性值
*
* @param methodPrefix 方法前缀
* @param number 方法后缀
* @return 对象属性值
*/
public static Double getValueByMethodDouble(List data ,Class clazz, String methodPrefix, Integer number) {
try {
Method method = clazz.getMethod(methodPrefix + number);
OptionalDouble average = data.stream().mapToDouble(temp -> {
try {
return (Double) method.invoke(temp);
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
}
}).average();
return average.orElse(0.0);
} catch (Exception e) {
throw new BusinessException(CommonResponseEnum.REFLECT_METHOD_EXCEPTION);
}
}
public static List<String> getStartTimeEndTime(String beginDate, String endDate) throws Exception {

View File

@@ -33,6 +33,8 @@ public class PieGenerator {
Option reasonOption = new Option();
//取消渲染动画
reasonOption.setAnimation(false);
String[] colorArr = {"#526ADE", "#00BFF5","#FFBF00","#77DA63","#D5FF6B"};
reasonOption.setColor(colorArr);
//背景色
reasonOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
//标题

View File

@@ -57,8 +57,8 @@ public class DrawPicUtil {
/***
* 绘制波形图
* @author hongawen
* 绘制波形图
* @date 2023/6/21 11:01
* @return String base64数据
*/

View File

@@ -3,11 +3,9 @@ package com.njcn.event.file.component;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.wave.BitConverter;
import com.njcn.event.file.pojo.dto.*;
@@ -16,11 +14,13 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.awt.*;
import java.io.*;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
/**
* @author hongawen
@@ -81,6 +81,46 @@ public class WaveFileComponent {
return waveDataDTO;
}
public WaveDataDTO getComtradeNoAddPoints(InputStream cfgStream, InputStream datStream, int iType) {
WaveDataDTO waveDataDTO = new WaveDataDTO();
// 首先判断文件路径是否为空
// 读取cfg文件
ComtradeCfgDTO comtradeCfgDTO = getComtradeCfgNoAddPoints(cfgStream);
// 为空或者未找到结束符号
if (comtradeCfgDTO == null || !"BINARY".equalsIgnoreCase(comtradeCfgDTO.getStrBinType())) {
throw new BusinessException(WaveFileResponseEnum.CFG_DATA_ERROR);
}
/*****根据通道号计算相别** add by yexb -----Start****
* 1、判断是否是3的倍数是3的倍数则是3相
* 2、假如不是3的倍数 是1的倍数则是单相
********************************************************/
if (comtradeCfgDTO.getNAnalogNum() % 3 == 0) {
comtradeCfgDTO.setNPhasic(3);
} else {
comtradeCfgDTO.setNPhasic(1);
}
// 给相别数量赋值
waveDataDTO.setIPhasic(comtradeCfgDTO.getNPhasic());
// 组装解析抬头
getWaveTitle(waveDataDTO, comtradeCfgDTO);
// 解析.dat文件
List<List<Float>> listWaveData = getComtradeDatNoAddPoints(comtradeCfgDTO, datStream, iType);
waveDataDTO.setComtradeCfgDTO(comtradeCfgDTO);
waveDataDTO.setListWaveData(listWaveData);
//add by hongawen,将暂态触发起始时间记录下来
waveDataDTO.setTime(DateUtil.format(comtradeCfgDTO.getTimeTrige(), DatePattern.NORM_DATETIME_MS_PATTERN));
/*****根据通道号计算相别** add by yexb -----end****/
return waveDataDTO;
}
/*********************************
* 根据波形数据算出rms值数据
* param waveDataDTO 瞬时波形包含了CFG配置文件
@@ -472,6 +512,127 @@ public class WaveFileComponent {
return comtradeCfgDTO;
}
private ComtradeCfgDTO getComtradeCfgNoAddPoints(InputStream cfgStream) {
ComtradeCfgDTO comtradeCfgDTO = new ComtradeCfgDTO();
try (InputStreamReader read = new InputStreamReader(cfgStream, CharsetUtil.CHARSET_GBK); BufferedReader bufferedReader = new BufferedReader(read);) {
// 第一行不关心仅仅是一些描述类的信息
String strFileLine = bufferedReader.readLine();
// 第二行需要关心第二个(模拟量的个数)和第三个参数(开关量的个数)
strFileLine = bufferedReader.readLine();
// 按“,”进行分割
String[] strTempArray = strFileLine.split(StrUtil.COMMA);
// 总个数
comtradeCfgDTO.setNChannelNum(Integer.parseInt(strTempArray[0]));
// 模拟量的个数
comtradeCfgDTO.setNAnalogNum(Integer.parseInt(strTempArray[1].substring(0, strTempArray[1].length() - 1)));
// 开关量的个数
comtradeCfgDTO.setNDigitalNum(Integer.parseInt(strTempArray[2].substring(0, strTempArray[2].length() - 1)));
// 从第三行开始的ComtradeCfg.nChannelNum行是模拟量通道和数字量通道
List<AnalogDTO> lstAnalogDTO = new ArrayList<>();
comtradeCfgDTO.setLstAnalogDTO(lstAnalogDTO);
for (int i = 0; i < comtradeCfgDTO.getNChannelNum(); i++) {
AnalogDTO analogDTO = new AnalogDTO();
lstAnalogDTO.add(analogDTO);
strFileLine = bufferedReader.readLine();
strTempArray = strFileLine.split(StrUtil.COMMA);
//通道序号
analogDTO.setNIndex(Integer.parseInt(strTempArray[0]));
// 通道名称
analogDTO.setSzChannleName(strTempArray[1]);
// 相位名称
analogDTO.setSzPhasicName(strTempArray[2]);
// 监视的通道名称
analogDTO.setSzMonitoredChannleName(strTempArray[3]);
// 通道的单位
analogDTO.setSzUnitName(strTempArray[4]);
// 通道的系数
analogDTO.setFCoefficent(Float.parseFloat(strTempArray[5]));
// 通道的偏移量
analogDTO.setFOffset(Float.parseFloat(strTempArray[6]));
// 起始采样时间的偏移量
analogDTO.setFTimeOffset(Float.parseFloat(strTempArray[7]));
// 采样值的最小值
analogDTO.setNMin(Integer.parseInt(strTempArray[8]));
// 采样值的最大值
analogDTO.setNMax(Integer.parseInt(strTempArray[9]));
// 一次变比
analogDTO.setFPrimary(Float.parseFloat(strTempArray[10]));
// 二次变比
analogDTO.setFSecondary(Float.parseFloat(strTempArray[11]));
// 一次值还是二次值标志
analogDTO.setSzValueType(strTempArray[12]);
}
//WW 2019-11-14 // 采样频率
String freqLine = bufferedReader.readLine();
int nFreq;
try {
// 先尝试解析为double再四舍五入为整数以兼容"50.00"这样的格式
nFreq = (int) Math.round(Double.parseDouble(freqLine));
} catch (NumberFormatException e) {
// 如果失败则使用原来的整数解析方式
nFreq = Integer.parseInt(freqLine);
}
// 获取采样段数
strFileLine = bufferedReader.readLine();
int nRates = Integer.parseInt(strFileLine);
comtradeCfgDTO.setNRates(nRates);
// 获得每段的采样率 //采样率
List<RateDTO> lstRate = new ArrayList<>();
int nOffset = 0;
for (int i = 0; i < nRates; i++) {
strFileLine = bufferedReader.readLine();
strTempArray = strFileLine.split(StrUtil.COMMA);
RateDTO rateDTO = new RateDTO();
// 单周波采样点数 //WW 2019-11-14
double doubleValue = Double.parseDouble(strTempArray[0]); // 解析为 double
int result = (int) (doubleValue / nFreq); // 强制转换为 int
rateDTO.setNOneSample(result);
// 总点数 //这里的strTemp是一个偏移量
rateDTO.setNSampleNum((Integer.parseInt(strTempArray[1]) - nOffset));
nOffset = rateDTO.getNSampleNum();
lstRate.add(rateDTO);
}
comtradeCfgDTO.setLstRate(lstRate);
// 增加读取波形起始时间个结束时间
String timeFormat = "dd/MM/yyyy,HH:mm:ss.SSS";
// 波形起始时间
strFileLine = bufferedReader.readLine();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
comtradeCfgDTO.setTimeStart(DateUtil.parse(strFileLine, timeFormat));
// 暂态触发时间
strFileLine = bufferedReader.readLine();
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
comtradeCfgDTO.setTimeTrige(DateUtil.parse(strFileLine, timeFormat));
// 获取触发时间的时间 + 毫秒
Calendar calendar = DateUtil.calendar(comtradeCfgDTO.getTimeTrige());
comtradeCfgDTO.setFirstMs(calendar.get(Calendar.MILLISECOND));
comtradeCfgDTO.setFirstTime(calendar.getTime());
long a = comtradeCfgDTO.getTimeStart().getTime();
long b = comtradeCfgDTO.getTimeTrige().getTime();
int c = (int) (b - a);
if (c >= 90 && c <= 110) {
comtradeCfgDTO.setNPush(100);
} else if (c >= 190 && c <= 210) {
comtradeCfgDTO.setNPush(200);
}
// 赋值编码格式(二进制)
comtradeCfgDTO.setStrBinType(bufferedReader.readLine().toUpperCase());
} catch (Exception e) {
// 解析.cfg文件出错
comtradeCfgDTO = null;
}
return comtradeCfgDTO;
}
/*********************************
* 读取dat方法
* param strFilePath .dat访问路径
@@ -511,13 +672,14 @@ public class WaveFileComponent {
//抽点后新的的采样率
List<RateDTO> newLstRate = new ArrayList<>();
for (int iRate = 0; iRate < comtradeCfgDTO.getNRates(); iRate++) {
// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
// 计算本段录波总共有多少波形
nWaveNum = comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum() / comtradeCfgDTO.getLstRate().get(iRate).getNOneSample();
//设置总波形大小
comtradeCfgDTO.setNAllWaveNum(comtradeCfgDTO.getNAllWaveNum() + nWaveNum);
// 将最低采样率替换到本段录波内
RateDTO tmpRateDTO = new RateDTO();
// C# 原实现中 bool 默认是 false16~31 点/周波段也应按普通抽点处理
tmpRateDTO.bRMSFlag = false;
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
//YXB 2025-08-27
@@ -547,12 +709,299 @@ public class WaveFileComponent {
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
}
nnInd++;
}
// 偏移量,采样间隔
long nOffSet = 0, nWaveSpan;
//两个点之间的时间差
float fValue, dfValue;
// 计算不同块的采样率
int nIndex = 0;
// .CFG中采样率
RateDTO tmpRateDTO;
// nBlockNum 总循环次数
for (int i = 0; i < nBlockNum; i++) {
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
// 判断是否进入下一段
if (i == tmpRateDTO.getNSampleNum() + nOffSet) {
nOffSet += tmpRateDTO.getNSampleNum();
nIndex++;
if (nIndex == nnInd) {
break;
}
}
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
// C# 原实现中 RMS 段与普通抽点是两条独立控制流,不能挂在同一个取模条件下
if (Boolean.TRUE.equals(newLstRate.get(nIndex).bRMSFlag)) {
//计算本段补点采样间隔
nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
// 计算有多少个周波
long allWaveTemp = newLstRate.get(nIndex).getNSampleNum() / newLstRate.get(nIndex).getNOneSample();
// 本段需要补多少点
long allempSample = newLstRate.get(nIndex).getNOneSample();
int segmentEndIndex = (int) (nOffSet + tmpRateDTO.getNSampleNum() - 1);
for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
// 2 点/周波时,半周波位置需要切换到该周波的第二个原始采样点
if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
i++;
}
//存储局部数据集合包含了时间ABC三相
List<Float> tmpWaveData = new ArrayList<>();
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
break;
}
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
//WW 2019-11-14
/*************************
* 1、接口返回的默认是二次值
* 2、P是一次值 S是二次值
* 3、S(二次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
* 4、P(一次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
*************************/
//P是一次值 S是二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
fValue = fValue * 1000.0f;
} else {
fValue = fValue;
}
}
//P是一次值 S是二次值
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
//判断单位是V还是kV
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
} else //还有可能是 电流单位是A
{
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
}
//xValue前移量假如是第一次时候则需要前移
if (!blxValue && j == 0) {
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
blxValue = true;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
} else if (j == 0) {
xValueAll += (float) dfValue / nWaveSpan;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
}
//不同通道yValue的值都需要增加最终成ABC三相 //每个通道的值
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
}
//把每个单独的值赋予到整体里面去
listWaveData.add(tmpWaveData);
}
// 本周波处理完成后,推进到下一周波的原始采样点
if (iWaveTemp < (allWaveTemp - 1)) {
i++;
}
}
// 某些文件的段点数并不是原始每周波点数的整倍数。
// RMS 段处理完成后,强制把原始游标对齐到当前段末尾,
// 这样外层 for 的下一次自增才能稳定落到下一段起点,避免重复进入同一 RMS 段。
i = segmentEndIndex;
continue;
}
// 计算本段抽点采样间隔
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
// 判断是否到了需要抽的采样点
if (i % nWaveSpan == 0) {
// 计算每个通道的值
//存储局部数据集合包含了时间ABC三相
List<Float> tmpWaveData = new ArrayList<>();
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
//数据只有电压ABC三相数据不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
break;
}
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
//WW 2019-11-14
/**************************
* 1、接口返回的默认是二次值
* 2、P是一次值 S是二次值
* 3、S(二次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
* 4、P(一次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
**************************/
//P是一次值 S是二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
fValue = fValue * 1000.0f;
} else {
fValue = fValue;
}
}
//P是一次值 S是二次值
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
//判断单位是V还是kV
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
} else //还有可能是 电流单位是A
{
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
}
//xValue前移量假如是第一次时候则需要前移
if (!blxValue && j == 0) {
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
blxValue = true;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
} else if (j == 0) {
xValueAll += (float) nWaveSpan * dfValue;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
}
//不同通道yValue的值都需要增加最终成ABC三相 //每个通道的值
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
}
//把每个单独的值赋予到整体里面去
listWaveData.add(tmpWaveData);
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
}
return listWaveData;
}
private List<List<Float>> getComtradeDatNoAddPoints(ComtradeCfgDTO comtradeCfgDTO, InputStream datStream, int iType) {
//返回数据如果仅仅做展示后期考虑换String类型降低内存开销
List<List<Float>> listWaveData = new ArrayList<>();
//初始化xValue的值
float xValueAll = 0;
//判断是否首次登陆
boolean blxValue = false;
byte[] datArray;
try {
datArray = IoUtil.readBytes(datStream);
if (ArrayUtil.isEmpty(datArray)) {
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
}
// 计算每个单独的数据块的大小 4个字节的序号 4个字节的时间 2个字节的值
// 示例中的排布是 4个字节的序号 4个字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节) IC(2字节)
int nDigSize = (comtradeCfgDTO.getNDigitalNum() % 16) > 0 ? (comtradeCfgDTO.getNDigitalNum() / 16 + 1) * 2 : comtradeCfgDTO.getNDigitalNum() / 16 * 2;
int nBlockSize = 2 * Integer.SIZE / 8 + comtradeCfgDTO.getNAnalogNum() * 2 + nDigSize;
// 总长度除以每个块的大小
int nBlockNum = (int)Math.floor(datArray.length / nBlockSize);
// 获取采样率
int finalSampleRate = getFinalWaveSample(comtradeCfgDTO.getLstRate(), iType);
if (finalSampleRate != -1) {
//设置最终采样率
comtradeCfgDTO.setFinalSampleRate(finalSampleRate);
// 计算转换后的采样率
int nnInd = 0;
// 抽点后总共多少点数据
int nWaveNum;
//抽点后新的的采样率
List<RateDTO> newLstRate = new ArrayList<>();
for (int iRate = 0; iRate < comtradeCfgDTO.getNRates(); iRate++) {
if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
// 计算本段录波总共有多少波形
nWaveNum = comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum() / comtradeCfgDTO.getLstRate().get(iRate).getNOneSample();
//设置总波形大小
comtradeCfgDTO.setNAllWaveNum(comtradeCfgDTO.getNAllWaveNum() + nWaveNum);
// 将最低采样率替换到本段录波内
RateDTO tmpRateDTO = new RateDTO();
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
// //YXB 2025-08-27
// tmpRateDTO.bRMSFlag = false;
// }
// //如果采样是全波有效值或者半波有效值,需要去补足周波点数 YXB 2025-08-27
// else if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() <= 2) {
// //YXB 2025-08-27
// tmpRateDTO.bRMSFlag = true;
// }
newLstRate.add(tmpRateDTO);
//iFlag =3 一定不进行抽点算法
if (iType != 3) {
//true 抽点算法(当前采样率跟统一采样率不一样则是抽点,否则是未抽点)
if (!Objects.equals(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample(), comtradeCfgDTO.getFinalSampleRate())) {
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getFinalSampleRate());
// 计算本段录波按照最低采样点应该有多少录波
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getFinalSampleRate() * nWaveNum);
} else {
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
// 计算本段录波按照最低采样点应该有多少录波
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
}
} else {
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
// 计算本段录波按照最低采样点应该有多少录波
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
}
// 正常的配置中采样率
/* comtradeCfgDTO.getLstRate().get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
comtradeCfgDTO.getLstRate().get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum());*/
comtradeCfgDTO.getLstRate().get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
comtradeCfgDTO.getLstRate().get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum());
nnInd++;
// }
}
}
// 偏移量,采样间隔
long nOffSet = 0, nWaveSpan;
@@ -574,15 +1023,16 @@ public class WaveFileComponent {
break;
}
}
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
//YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
if (newLstRate.get(nIndex).bRMSFlag == true) {
//计算本段补点采样间隔
nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
} else {
// 计算本段抽点采样间隔
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
}
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
// tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
// //YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
// if (newLstRate.get(nIndex).bRMSFlag == true) {
// //计算本段补点采样间隔
// nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
// } else {
// // 计算本段抽点采样间隔
// nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
// }
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
// 判断是否到了需要抽的采样点
@@ -590,182 +1040,82 @@ public class WaveFileComponent {
// 计算每个通道的值
//存储局部数据集合包含了时间ABC三相
List<Float> tmpWaveData = new ArrayList<>();
//YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
if (newLstRate.get(nIndex).bRMSFlag == true) {
// 计算有多少个周波
long allWaveTemp = newLstRate.get(nIndex).getNSampleNum() / newLstRate.get(nIndex).getNOneSample();
// 本段需要补多少点
long allempSample = newLstRate.get(nIndex).getNOneSample();
//int iStartWaveTemp = i ;// 开始补点的起点
for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
//最多只有半波有效值也就是每周波是1个或者2个点然后去补最少16个点
if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
i++;
}
//存储局部数据集合包含了时间ABC三相
tmpWaveData = new ArrayList<>();
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
//数据只有电压ABC三相数据不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
break;
}
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
//数据只有电压ABC三相数据不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
break;
}
if((i * nBlockSize + 2 * 4 + j * 2) == 2437568){
System.out.println(55);
}
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
//WW 2019-11-14
/*************************
* 1、接口返回的默认是二次值
* 2、P是一次值 S是二次值
* 3、S(二次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
* 4、P(一次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
*************************/
//P是一次值 S是二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
fValue = fValue * 1000.0f;
} else {
fValue = fValue;
}
}
//P是一次值 S是二次值
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
//判断单位是V还是kV
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
} else //还有可能是 电流单位是A
{
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
}
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
//xValue前移量假如是第一次时候则需要前移
if (!blxValue && j == 0) {
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
blxValue = true;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
} else if (j == 0) {
xValueAll += (float) dfValue / nWaveSpan;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
}
//不同通道yValue的值都需要增加最终成ABC三相 //每个通道的值
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
}
//把每个单独的值赋予到整体里面去
listWaveData.add(tmpWaveData);
}
// 把每个单独的值赋予到整体里面去
if (iWaveTemp < (allWaveTemp - 1)) {
i++;
//WW 2019-11-14
/**************************
* 1、接口返回的默认是二次值
* 2、P是一次值 S是二次值
* 3、S(二次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
* 4、P(一次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
**************************/
//P是一次值 S是二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
fValue = fValue * 1000.0f;
} else {
fValue = fValue;
}
}
} else {
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
//数据只有电压ABC三相数据不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
break;
}
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
//WW 2019-11-14
/**************************
* 1、接口返回的默认是二次值
* 2、P是一次值 S是二次值
* 3、S(二次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
* 4、P(一次值)情况下:
* ①、单位为"V"时候则直接等于;
* ②、单位为"kV"时候需要乘以1000
**************************/
//P是一次值 S是二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
fValue = fValue * 1000.0f;
//P是一次值 S是二次值
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
//P是一次值 S是二次值
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
//判断单位是V还是kV
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
//判断单位是V还是kV
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
//判断单位是V还是kV
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
} else //还有可能是 电流单位是A
{
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
} else //还有可能是 电流单位是A
{
//根据cfg内的变比将一次值转换成二次值
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
fValue = fValue *comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
} else {
fValue = fValue;
}
}
//xValue前移量假如是第一次时候则需要前移
if (!blxValue && j == 0) {
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
blxValue = true;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
} else if (j == 0) {
xValueAll += (float) nWaveSpan * dfValue;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
}
//不同通道yValue的值都需要增加最终成ABC三相 //每个通道的值
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
}
//把每个单独的值赋予到整体里面去
listWaveData.add(tmpWaveData);
//xValue前移量假如是第一次时候则需要前移
if (!blxValue && j == 0) {
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
blxValue = true;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
} else if (j == 0) {
xValueAll += (float) nWaveSpan * dfValue;
//只增加一个xValue的值 //增加时间值
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
}
//不同通道yValue的值都需要增加最终成ABC三相 //每个通道的值
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
}
//把每个单独的值赋予到整体里面去
listWaveData.add(tmpWaveData);
}
}
}
@@ -1370,10 +1720,10 @@ public class WaveFileComponent {
s = sdf.format(d);
System.out.println(s);
WaveFileComponent waveFileComponent = new WaveFileComponent();
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("F:\\PQ_PQLD3_9_20250821_081038_640.cfg");
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("F:\\PQ_PQLD3_9_20250821_081038_640.dat");
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.CFG");
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.DAT");
// 获取瞬时波形 //获取原始波形值
WaveDataDTO waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
WaveDataDTO waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
d = new Date();
s = sdf.format(d);
System.out.println(s);

View File

@@ -1,5 +1,7 @@
package com.njcn.microservice.listener;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import org.slf4j.LoggerFactory;
@@ -34,33 +36,46 @@ public class NacosLogbackConfigLoader implements SpringApplicationRunListener, A
@Override
public void environmentPrepared(ConfigurableEnvironment environment) {
/* String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
String projectName = environment.getProperty("microservice.ename");
String logLevel = environment.getProperty("logging.level.root");
String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
HttpHeaders headers = new HttpHeaders();
headers.set("cndl408125hawen", "lanxia201");
HttpEntity<String> entity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
String logbackConfigContent = response.getBody();
//替换项目名称
logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
// 应用获取到的Logback配置
applyLogbackConfig(logbackConfigContent);
}*/
String active = environment.getProperty("spring.profiles.active");
if(!"jb".equalsIgnoreCase(active)){
String serverAddr = environment.getProperty("spring.cloud.nacos.config.server-addr");
String namespace = environment.getProperty("spring.cloud.nacos.config.namespace");
String projectName = environment.getProperty("microservice.ename");
String logLevel = environment.getProperty("logging.level.root");
String url = String.format("http://%s/nacos/v1/cs/configs?tenant=%s&group=DEFAULT_GROUP&dataId=logback.xml", serverAddr, namespace);
HttpHeaders headers = new HttpHeaders();
headers.set("cndl408125hawen", "lanxia201");
HttpEntity<String> entity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
if (response.getStatusCode().is2xxSuccessful()) {
String logbackConfigContent = response.getBody();
//替换项目名称
logbackConfigContent = logbackConfigContent.replace("projectDefaultName",projectName);
logbackConfigContent = logbackConfigContent.replace("logDefaultLevel",logLevel);
// 应用获取到的Logback配置
applyLogbackConfig(logbackConfigContent,logLevel);
}
}
}
private void applyLogbackConfig(String logbackConfigContent) {
private void applyLogbackConfig(String logbackConfigContent,String logLevel) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(logbackConfigContent.getBytes(StandardCharsets.UTF_8))) {
configurator.doConfigure(inputStream);
Logger root = context.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
if("debug".equalsIgnoreCase(logLevel)){
root.setLevel(Level.DEBUG);
}
if("info".equalsIgnoreCase(logLevel)){
root.setLevel(Level.INFO);
}
if("error".equalsIgnoreCase(logLevel)){
root.setLevel(Level.ERROR);
}
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -77,10 +77,39 @@ public interface BusinessTopic {
*/
String REPLY_RECALL_TOPIC = "reply_recall_Topic";
/**
* 治理心跳过期处理主题
*/
String HEARTBEAT_TIMEOUT_TOPIC = "heartbeat_timeout_topic";
/********************************数据中心*********************************/
String RMP_EVENT_DETAIL_TOPIC = "rmpEventDetailTopic";
// /**
// * 云前置文件信息请求主题
// */
// String FILE_INFO_REQUEST_TOPIC = "fileInfoRequestTopic";
//
// /**
// * 云前置文件信息响应主题
// */
// String FILE_INFO_RESPONSE_TOPIC = "fileInfoResponseTopic";
//
// /**
// * 云前置文件下载请求主题
// */
// String FILE_DOWNLOAD_REQUEST_TOPIC = "fileDownloadRequestTopic";
// /**
// * 云前置文件下载响应主题
// */
// String FILE_DOWNLOAD_RESPONSE_TOPIC = "fileDownloadResponseTopic";
String CLOUD_TOPIC = "Cloud_Topic";
String CLOUD_REPLY_TOPIC = "Cloud_Reply_Topic";
interface AppDataTag {
@@ -124,4 +153,17 @@ public interface BusinessTopic {
String STREAM_TAG = "streamInfo";
}
interface HeartTag {
/**
* apf 心跳
*/
String APF_TAG = "apf";
/**
* cld 心跳
*/
String CLD_TAG = "cld";
}
}

View File

@@ -0,0 +1,27 @@
package com.njcn.mq.message;
import com.njcn.middle.rocket.domain.BaseMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* @author xy
*/
@Data
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class HeartbeatTimeoutMessage extends BaseMessage implements Serializable {
private static final long serialVersionUID = 1L;
private String nDid;
private Long timestamp;
private Integer delayLevel;
}

View File

@@ -1,6 +1,6 @@
package com.njcn.mq.template;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.alibaba.fastjson.JSON;
import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;
@@ -25,7 +25,7 @@ public class BZEventMessageTemplate extends RocketMQEnhanceTemplate {
public SendResult sendMember(Object message, String tag) {
BaseMessage baseMessage = new BaseMessage();
baseMessage.setSource(BusinessResource.WEB_RESOURCE);
baseMessage.setMessageBody(new Gson().toJson(message));
baseMessage.setMessageBody(JSON.toJSONString(message));
return send(BusinessTopic.ASK_RECALL_TOPIC,tag,baseMessage);
}
}

View File

@@ -1,6 +1,6 @@
package com.njcn.mq.template;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.google.gson.Gson;
import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;

View File

@@ -1,6 +1,6 @@
package com.njcn.mq.template;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.google.gson.Gson;
import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;

View File

@@ -0,0 +1,29 @@
package com.njcn.mq.template;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;
import com.njcn.mq.constant.BusinessTopic;
import com.njcn.mq.message.HeartbeatTimeoutMessage;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/8/11 15:28
*/
@Component
public class HeartbeatTimeoutMessageTemplate extends RocketMQEnhanceTemplate {
public HeartbeatTimeoutMessageTemplate(RocketMQTemplate template) {
super(template);
}
public SendResult sendMember(HeartbeatTimeoutMessage heartbeatTimeoutMessage) {
heartbeatTimeoutMessage.setSource(BusinessResource.WEB_RESOURCE);
return send(BusinessTopic.HEARTBEAT_TIMEOUT_TOPIC, BusinessTopic.HeartTag.APF_TAG, heartbeatTimeoutMessage, heartbeatTimeoutMessage.getDelayLevel());
}
}

View File

@@ -1,6 +1,6 @@
package com.njcn.mq.template;
import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.google.gson.Gson;
import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import com.njcn.mq.constant.BusinessResource;

View File

@@ -12,6 +12,8 @@ public interface OssPath {
*/
String WAVE_DIR="comtrade/";
String WAVE_FILE="wave/";
/***
* 下载文件
*/
@@ -167,4 +169,14 @@ public interface OssPath {
*/
String CONFIGURATIONNAME = "configuration.json";
/**
* APP 稳态报告路径
*/
String APP_HARMONIC_REPORT = "app/report/harmonic/";
/**
* APP 暂态报告路径
*/
String APP_EVENT_REPORT = "app/report/event/";
}

View File

@@ -2,9 +2,12 @@ package com.njcn.oss.utils;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.aliyun.oss.OSS;
import com.njcn.ali.oss.config.AliYunOssConfig;
import com.njcn.ali.oss.util.AliYunOssUtils;
import com.njcn.common.config.GeneralInfo;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.huawei.obs.config.HuaweiObsProperties;
import com.njcn.huawei.obs.util.OBSUtil;
import com.njcn.minioss.bo.MinIoUploadResDTO;
import com.njcn.minioss.config.MinIossProperties;
@@ -12,6 +15,8 @@ import com.njcn.minioss.util.MinIoUtils;
import com.njcn.oss.constant.GeneralConstant;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.enums.OssResponseEnum;
import com.obs.services.ObsClient;
import com.obs.services.model.PutObjectRequest;
import io.minio.*;
import io.minio.messages.Item;
import lombok.RequiredArgsConstructor;
@@ -70,6 +75,11 @@ public class FileStorageUtil {
*/
private final AliYunOssUtils aliYunOssUtils;
private final HuaweiObsProperties huaweiObsProperties;
private final OSS ossClient;
private final AliYunOssConfig ossConfig;
/***
* 上传MultipartFile文件
@@ -442,4 +452,62 @@ public class FileStorageUtil {
return file;
}
public void mkdir(String directoryPath) {
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
this.createDirectoryHW(directoryPath);
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.MINIO_OSS) {
minIoUtils.createDirectory(minIossProperties.getBucket(), directoryPath);
} else if (generalInfo.getBusinessFileStorage() == GeneralConstant.AliYUN_OSS) {
this.createDirectoryAli(directoryPath);
} else {
}
}
/**
* 华为文件服务器创建空目录
*
* @param dirPath
*/
private void createDirectoryHW(String dirPath) {
ObsClient obsClient = null;
try {
obsClient = this.huaweiObsProperties.getInstance();
String bucketName = this.huaweiObsProperties.getObs().getBucket();
// 确保路径以 / 结尾
String directoryKey = dirPath.endsWith("/") ? dirPath : dirPath + "/";
// 创建空对象作为目录占位符
InputStream emptyStream = new ByteArrayInputStream(new byte[0]);
PutObjectRequest request = new PutObjectRequest(bucketName, directoryKey, emptyStream);
obsClient.putObject(request);
log.info("已创建目录占位符:" + directoryKey);
} catch (Exception e) {
throw new RuntimeException("创建目录失败" + dirPath, e);
} finally {
this.huaweiObsProperties.destroy(obsClient);
}
}
/**
* 阿里云文件服务器创建空目录
*
* @param dirPath
*/
public void createDirectoryAli(String dirPath) {
try {
// 确保路径以 / 结尾,表示目录
String directoryKey = dirPath.endsWith("/") ? dirPath : dirPath + "/";
// 创建空输入流作为目录占位符
ByteArrayInputStream emptyStream = new ByteArrayInputStream(new byte[0]);
this.ossClient.putObject(this.ossConfig.getBucket(), directoryKey, emptyStream);
} catch (Exception e) {
throw new RuntimeException("创建目录失败:" + dirPath, e);
}
}
}

View File

@@ -239,18 +239,47 @@ public class ExcelUtil {
* @param strings 下拉内容
*/
public static void selectList(Workbook workbook, int firstCol, int lastCol, String[] strings) {
Sheet sheet = workbook.getSheetAt(0);
// 生成下拉列表
// 只对(xx)单元格有效
CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(2, 65535, firstCol, lastCol);
// 生成下拉框内容
DataValidationHelper dvHelper = sheet.getDataValidationHelper();
XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
dvHelper.createExplicitListConstraint(strings);
XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(
dvConstraint, cellRangeAddressList);
// 对sheet页生效
sheet.addValidationData(validation);
// Sheet sheet = workbook.getSheetAt(0);
// // 生成下拉列表
// // 只对(xx)单元格有效
// CellRangeAddressList cellRangeAddressList = new CellRangeAddressList(2, 65535, firstCol, lastCol);
// // 生成下拉框内容
// DataValidationHelper dvHelper = sheet.getDataValidationHelper();
// XSSFDataValidationConstraint dvConstraint = (XSSFDataValidationConstraint)
// dvHelper.createExplicitListConstraint(strings);
// XSSFDataValidation validation = (XSSFDataValidation) dvHelper.createValidation(
// dvConstraint, cellRangeAddressList);
// // 对sheet页生效
// sheet.addValidationData(validation);
Sheet targetSheet = workbook.getSheetAt(0);
// ===================== 关键每个下拉用唯一名称的隐藏Sheet =====================
String uniqueHiddenName = "dropdown_" + firstCol + "_" + lastCol + "_" + System.currentTimeMillis();
Sheet hiddenSheet = workbook.createSheet(uniqueHiddenName);
// 隐藏数据源Sheet
workbook.setSheetHidden(workbook.getSheetIndex(hiddenSheet), true);
// 写入选项到隐藏Sheet
for (int i = 0; i < strings.length; i++) {
Row row = hiddenSheet.createRow(i);
Cell cell = row.createCell(0);
cell.setCellValue(strings[i]);
}
// 构造引用公式(无长度限制)
String formula = uniqueHiddenName + "!$A$1:$A$" + strings.length;
// 下拉作用范围第3行 ~ 65536行
CellRangeAddressList range = new CellRangeAddressList(2, 65535, firstCol, lastCol);
DataValidationHelper helper = targetSheet.getDataValidationHelper();
DataValidationConstraint constraint = helper.createFormulaListConstraint(formula);
DataValidation validation = helper.createValidation(constraint, range);
// 必加:防止下拉冲突、不显示
validation.setShowErrorBox(true);
validation.setShowPromptBox(true);
targetSheet.addValidationData(validation);
}
/**

View File

@@ -4,13 +4,15 @@ import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.net.URLEncoder;
import java.util.Objects;
/**
* @author hongawen
@@ -76,6 +78,59 @@ public class PoiUtil {
fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8);
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setContentType("application/octet-stream;charset=" + CharsetUtil.UTF_8);
//将带*号的列变成红色
Sheet sheetAt = workbook.getSheetAt(0);
//获取列数
int physicalNumberOfCells = sheetAt.getRow(0).getPhysicalNumberOfCells();
//没有表格标题,只有表格头
for (int i = 0; i < 2; i++) {
//获取行
Row row = sheetAt.getRow(i);
if (Objects.isNull(row)) {
continue;
}
for (int j = 0; j < physicalNumberOfCells; j++) {
//获取单元格对象
Cell cell = row.getCell(j);
//获取单元格样式对象
CellStyle cellStyle = workbook.createCellStyle();
//获取单元格内容对象
Font font = workbook.createFont();
font.setFontHeightInPoints((short) 12);
//一定要装入 样式中才会生效
cellStyle.setFont(font);
//设置居中对齐
cellStyle.setAlignment(HorizontalAlignment.CENTER);
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//设置单元格字体颜色
cell.setCellStyle(cellStyle);
//获取当前值
String stringCellValue = cell.getStringCellValue();
if (stringCellValue.contains("*")) {
// 创建一个富文本
XSSFRichTextString xssfRichTextString = new XSSFRichTextString(stringCellValue);
int startIndex = stringCellValue.indexOf("*");
int entIndex = stringCellValue.lastIndexOf("*");
if (entIndex != 0) {
Font font3 = workbook.createFont();
font3.setFontHeightInPoints((short) 12);
font3.setColor(Font.COLOR_NORMAL);
xssfRichTextString.applyFont(0, entIndex, font3);
}
//设置带*样式
Font font1 = workbook.createFont();
font1.setFontHeightInPoints((short) 12);
font1.setColor(Font.COLOR_RED);
xssfRichTextString.applyFont(startIndex, entIndex + 1, font1);
//其他样式
Font font2 = workbook.createFont();
font2.setFontHeightInPoints((short) 12);
font2.setColor(Font.COLOR_NORMAL);
xssfRichTextString.applyFont(entIndex + 1, stringCellValue.length(), font2);
cell.setCellValue(xssfRichTextString);
}
}
}
workbook.write(outputStream);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -115,4 +115,8 @@ public interface AppRedisKey {
* 补召文件
*/
String MAKE_UP_FILES = "makeUpFilesKey:";
String COMMON_REQUEST = "commonRequestKey:";
String COMMON_RESOPNSE = "commonResponseKey:";
}

View File

@@ -2,9 +2,7 @@ package com.njcn.redis.utils;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
@@ -325,13 +323,54 @@ public class RedisUtil {
* @return
*/
public List<?> getLikeListAllValues(String key) {
List<Object> info=new ArrayList<>();
for (String s : redisTemplate.keys(key + "*")) {
List<Object> info = new ArrayList<>();
// 使用 SCAN 替代 keys解决 Tair 禁用 KEYS 命令的问题
Set<String> keys = redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
Set<String> keySet = new HashSet<>();
ScanOptions options = ScanOptions.scanOptions()
.match(key + "*")
.count(1000)
.build();
try (Cursor<byte[]> cursor = connection.scan(options)) {
while (cursor.hasNext()) {
keySet.add(new String(cursor.next()));
}
} catch (Exception e) {
throw new RuntimeException("Redis SCAN 模糊查询失败", e);
}
return keySet;
});
for (String s : keys) {
info.add(redisTemplate.opsForValue().get(s));
}
return info;
}
/**
* 根据key模糊查询,并取出所有符合条件的key集合
* @return
*/
public Set<String> scanKeysByPattern(String pattern, int count) {
Set<String> keys = new HashSet<>();
ScanOptions options = ScanOptions.scanOptions()
.match(pattern)
.count(count)
.build();
try (Cursor<byte[]> cursor = redisTemplate.getConnectionFactory()
.getConnection()
.scan(options)) {
while (cursor.hasNext()) {
keys.add(new String(cursor.next()));
}
} catch (Exception e) {
throw new RuntimeException("扫描Redis keys失败", e);
}
return keys;
}
/**
* 数据切库
* @param dbIndex

View File

@@ -59,6 +59,7 @@ public class Knife4jSwaggerConfig {
"com.njcn.prepare.harmonic.controller",
"com.njcn.prepare.event.controller",
"com.njcn.device.pq.controller",
"com.njcn.device.terminal.controller",
"com.njcn.device.pms.controller",
"com.njcn.auth.controller",
"com.njcn.system.controller",
@@ -74,6 +75,7 @@ public class Knife4jSwaggerConfig {
"com.njcn.cswarn.controller",
"com.njcn.csharmonic.controller",
"com.njcn.cssystem.controller",
"com.njcn.csreport.controller",
"com.njcn.advance.controller",
"com.njcn.stat.controller",
"com.njcn.rt.controller",
@@ -86,7 +88,9 @@ public class Knife4jSwaggerConfig {
"com.njcn.dataProcess",
"com.njcn.migration",
"com.njcn.harmonic.rstatlimitrate.controller",
"com.njcn.device.device.controller"
"com.njcn.device.device.controller",
"com.njcn.device.userledger.controller",
"com.njcn.migration.read.controller"
)
.collect(Collectors.toList());
List<GrantType> grantTypes = new ArrayList<>();

View File

@@ -19,7 +19,7 @@ public interface ValidMessage {
String NAME_NOT_BLANK = "名称不能为空请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误存在特殊符号或超过20字符请检查name参数";
String NAME_FORMAT_ERROR = "名称格式错误,存在特殊符号或超过32字符请检查name参数";
String INDUSTRY_NOT_BLANK = "行业不能为空请检查industry参数";
String INDUSTRY_FORMAT_ERROR = "行业格式错误请检查industry参数";

View File

@@ -1,9 +1,9 @@
package com.njcn.web.utils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.net.URI;
@@ -15,8 +15,11 @@ import java.util.Map;
* @createDate 2019-02-08
*
*/
@Component
public class RestTemplateUtil {
private static final Logger log = LoggerFactory.getLogger(RestTemplateUtil.class);
private static final RestTemplate restTemplate = new RestTemplate();
// ----------------------------------GET-------------------------------------------------------
@@ -263,6 +266,24 @@ public class RestTemplateUtil {
return restTemplate.exchange(url, HttpMethod.POST, requestEntity, responseType, uriVariables);
}
public <T> ResponseEntity<T> post(String url, Object requestBody, HttpHeaders headers, Class<T> responseType) {
try {
if (headers == null) {
headers = new HttpHeaders();
}
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Object> entity = new HttpEntity<>(requestBody, headers);
log.info("发送POST请求到: {}", url);
ResponseEntity<T> response = restTemplate.postForEntity(url, entity, responseType);
log.info("POST请求响应状态: {}", response.getStatusCode());
return response;
} catch (Exception e) {
log.error("POST请求异常: {}", e.getMessage(), e);
throw e;
}
}
// ----------------------------------PUT-------------------------------------------------------
/**

View File

@@ -0,0 +1,16 @@
package com.njcn.device.biz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2025-11-17
*/
public interface PqSensitiveUserMapper extends BaseMapper<PqSensitiveUser> {
}

View File

@@ -41,6 +41,11 @@ public class LineALLInfoDTO {
private Integer num;
@ApiModelProperty(name = "objName",value = "监测点对象名称")
private String objName;
@ApiModelProperty(name = "objName",value = "电网侧监测点对象名称Id")
private String objId;
@ApiModelProperty(name = "objName",value = "电网侧监测点对象名称")
private String objName2;
@ApiModelProperty(name = "loadType",value = "监测对象类型")
private String loadType;
@ApiModelProperty(name = "voltageLevel",value = "电压等级")

View File

@@ -0,0 +1,62 @@
package com.njcn.device.biz.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
/**
* @Author: cdf
* @CreateTime: 2026-02-10
* @Description:
*/
@Getter
@Setter
@TableName("pq_sensitive_user")
public class PqSensitiveUser extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId(value = "id",type = ASSIGN_ID)
private String id;
/**
* 敏感用户名称
*/
private String name;
/**
* 敏感负荷类型
*/
private String loadType;
/**
* 用户协议容量
*/
private Double userAgreementCapacity;
/**
* 装机容量
*/
private Double installedCapacity;
/**
* 所属厂站名称
*/
private String substationName;
/**
* 排序
*/
private Integer sort;
}

View File

@@ -0,0 +1,67 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10202
max-http-header-size: 1048576
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
username: @nacos.username@
password: @nacos.password@
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-Id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
#上传文件总的最大值
max-request-size: 200MB
#上传文件的最大值
max-file-size: 200MB
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
#是否是冀北设备台账树
isJb: false
oracle:
isSync: false
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine

View File

@@ -0,0 +1,72 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10202
max-http-header-size: 1048576
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
username: @nacos.username@
password: @nacos.password@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
#上传文件总的最大值
max-request-size: 200MB
#上传文件的最大值
max-file-size: 200MB
#项目日志的配置
logging:
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
#是否是冀北设备台账树
isJb: false
mqtt:
client-id: @artifactId@${random.value}
oracle:
isSync: false
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine

View File

@@ -1,68 +1,3 @@
#当前服务的基本信息
microservice:
ename: @artifactId@
name: '@name@'
version: @version@
sentinel:
url: @sentinel.url@
gateway:
url: @gateway.url@
server:
port: 10202
max-http-header-size: 1048576
#feign接口开启服务熔断降级处理
feign:
sentinel:
enabled: true
spring:
application:
name: @artifactId@
#nacos注册中心以及配置中心的指定
cloud:
nacos:
discovery:
ip: @service.server.url@
server-addr: @nacos.url@
namespace: @nacos.namespace@
config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml
shared-configs:
- data-id: share-config.yaml
refresh: true
- data-Id: share-config-datasource-db.yaml
refresh: true
main:
allow-bean-definition-overriding: true
servlet:
multipart:
#上传文件总的最大值
max-request-size: 200MB
#上传文件的最大值
max-file-size: 200MB
#项目日志的配置
#项目日志的配置
logging:
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
level:
root: info
#mybatis配置信息
mybatis-plus:
#别名扫描
type-aliases-package: com.njcn.device.pq.pojo,com.njcn.device.pms.pojo,com.njcn.device.biz.pojo.dto
#是否是冀北设备台账树
isJb: false
mqtt:
client-id: @artifactId@${random.value}
oracle:
isSync: false
syncLedgerLineUrl: http://localhost:8082/export/syncLedgerLine
syncLedgerUpdateLine: http://localhost:8082/export/syncLedgerUpdateLine
syncLedgerDeleteLine: http://localhost:8082/export/syncLedgerDeleteLine
profiles:
active: @spring.profiles.active@

View File

@@ -27,6 +27,12 @@
<artifactId>pqs-influx</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>supervision-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,45 @@
package com.njcn.device.pq.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.pq.api.fallback.UserLedgerFeignClientFallbackFactory;
import com.njcn.supervision.pojo.param.SensitiveUserParam;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 流程实例 Api 接口
*
*/
@FeignClient(value = ServerInfo.DEVICE, path = "/userReport", fallbackFactory = UserLedgerFeignClientFallbackFactory.class)
public interface UserLedgerFeignClient {
@PostMapping("/selectUserList")
HttpResult<List<UserLedgerVO>> selectUserList(@RequestBody UserReportParam userReportParam);
@GetMapping("/selectUserInfo")
HttpResult<UserLedgerVO> selectUserInfo(@RequestParam("id") String id);
@PostMapping(value = "/bindUserStation")
HttpResult<List<UserLedgerVO>> bindUserStation(@RequestParam("userId")String userId,@RequestParam("stationId")String stationId);
@PostMapping("/getUserReportByIds")
HttpResult<List<NewUserReportVO>> getUserReportByIds(@RequestBody List<String> ids);
@PostMapping("/getSensitiveUserByDept")
@ApiOperation("根据部门获取敏感用户信息")
HttpResult<List<UserReportPO>> getSensitiveUserByDept(@RequestBody @Validated SensitiveUserParam param) ;
}

View File

@@ -1,10 +1,12 @@
package com.njcn.supervision.api.fallback;
package com.njcn.device.pq.api.fallback;
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.supervision.api.UserLedgerFeignClient;
import com.njcn.device.pq.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.param.SensitiveUserParam;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.supervision.utils.SupervisionEnumUtil;
@@ -52,6 +54,12 @@ public class UserLedgerFeignClientFallbackFactory implements FallbackFactory<Use
log.error("{}异常,降级处理,异常为:{}", "根据ids获取非电网侧用户信息", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<UserReportPO>> getSensitiveUserByDept(SensitiveUserParam param) {
log.error("{}异常,降级处理,异常为:{}", "根据部门获取敏感用户信息异常", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -22,65 +22,65 @@ import java.math.BigDecimal;
public class TerminalBaseExcel implements Serializable {
@Excel(name = "项目", width = 15)
@Excel(name = "*项目", width = 15)
@NotBlank(message = DeviceValidMessage.PROJECT_NAME_NOT)
@Pattern(regexp = PatternRegex.DEPT_NAME_REGEX, message = DeviceValidMessage.PROJECT_NAME_RULE)
private String projectName;
@Excel(name = "工程", width = 15)
@Excel(name = "*省份", width = 15)
@NotBlank(message = DeviceValidMessage.PROVINCE_NAME_NOT)
private String provinceName;
@Excel(name = "单位", width = 15)
@Excel(name = "*供电公司", width = 15)
@NotBlank(message = "供电公司名称")
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = "供电公司名称违规")
private String gdName;
@Excel(name = "部门", width = 15)
@Excel(name = "*变电站", width = 15)
@NotBlank(message = "变电站名称不可为空")
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = "变电站名称违规")
private String substationName;
@Excel(name = "部门电压等级", width = 15)
@NotBlank(message = "电压等级不可为空")
@Excel(name = "*变电站电压等级", width = 15)
@NotBlank(message = "变电站电压等级不可为空")
private String subStationScale;
@Excel(name = "经度", width = 15)
@Excel(name = "*经度", width = 15)
private BigDecimal lng;
@Excel(name = "纬度", width = 15)
@Excel(name = "*纬度", width = 15)
private BigDecimal lat;
@Excel(name = "终端", width = 15)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = "设备名称违规")
@Excel(name = "*装置名称", width = 15)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = "装置名称违规")
private String deviceName;
@Excel(name = "终端模型", replace = {"虚拟设备_0", "实际设备_1", "离线设备_2"}, width = 15)
@Excel(name = "*终端模型", replace = {"虚拟设备_0", "实际设备_1", "离线设备_2"}, width = 15)
@NotNull(message = "设备模型不能为空")
private Integer devModel;
@Excel(name = "数据类型", replace = {"暂态系统_0", "稳态系统_1", "双系统_2"}, width = 15)
@Excel(name = "*数据类型", replace = {"暂态系统_0", "稳态系统_1", "双系统_2"}, width = 15)
@NotNull(message = "数据类型不能为空")
private Integer devDataType;
@Excel(name = "运行状态", replace = {"投运_0", "热备用_1", "停运_2"}, width = 15)
@Excel(name = "*运行状态", replace = {"投运_0", "热备用_1", "停运_2"}, width = 15)
@NotNull(message = "运行状态不能为空")
private Integer runFlag;
@Excel(name = "终端厂家", width = 15)
@Excel(name = "*终端厂家", width = 15)
@NotBlank(message = "终端厂家不能为空")
private String manufacturer;
@Excel(name = "设备型号", width = 15)
@Excel(name = "*设备型号", width = 15)
@NotBlank(message = "设备型号不能为空")
private String devType;
@Excel(name = "网络参数", width = 15)
@Excel(name = "*网络参数", width = 15)
@NotBlank(message = "设备网络参数不能为空")
private String ip;
@Excel(name = "端口", width = 15)
@Excel(name = "*端口", width = 15)
@Range(min = 1, max = 100000, message = "端口号违规")
@NotNull(message = "设备端口号不能为空")
private Integer port;
@@ -91,15 +91,15 @@ public class TerminalBaseExcel implements Serializable {
@Excel(name = "终端秘钥", width = 15)
private String devKey;
@Excel(name = "召唤标志",replace = {"周期触发_0", "变为触发_1"}, width = 15)
@Excel(name = "*召唤标志",replace = {"周期触发_0", "变为触发_1"}, width = 15)
@NotNull(message = "召唤标志不为空")
private Integer callFlag;
@Excel(name = "前置名称", width = 15)
@Excel(name = "*前置名称", width = 15)
@NotBlank(message = "前置名称不能为空")
private String nodeName;
@Excel(name = "前置类型", width = 15)
@Excel(name = "*前置类型", width = 15)
@NotBlank(message = "前置类型不能为空")
private String frontType;
@@ -109,71 +109,71 @@ public class TerminalBaseExcel implements Serializable {
@Excel(name = "SIM卡号", width = 15)
private String sim;
@Excel(name = "母线", width = 15)
@Excel(name = "*母线", width = 15)
@NotBlank(message = "母线名称不能为空")
private String subvName;
@Excel(name = "母线号", width = 15)
@Excel(name = "*母线号", width = 15)
@NotNull(message = "母线号不为空")
private Integer subvNum;
@Excel(name = "母线电压等级", width = 15)
@Excel(name = "*母线电压等级", width = 15)
@NotBlank(message = "母线电压等级不能为空")
private String subvScale;
@Excel(name = "母线模型", replace = {"虚拟母线_0", "实际母线_1"}, width = 15)
@Excel(name = "*母线模型", replace = {"虚拟母线_0", "实际母线_1"}, width = 15)
@NotNull(message = "母线模型不为空")
private Integer subvModel;
@Excel(name = "监测点名称", width = 15)
@Excel(name = "*监测点名称", width = 15)
@NotBlank(message = "监测点名称不能为空")
private String lineName;
@Excel(name = "监测点线路号", width = 15)
@Excel(name = "*监测点线路号", width = 15)
@NotNull(message = "监测点线路号不为空")
private Integer lineNum;
@Excel(name = "监测点等级", width = 15)
@Excel(name = "*监测点等级", width = 15)
private String lineGrade;
@Excel(name = "pt", width = 20)
@Excel(name = "*pt(格式pt1/pt2)", width = 20)
@NotBlank(message = "pt不能为空")
private String pt;
@Excel(name = "ct", width = 20)
@Excel(name = "*ct(格式ct1/ct2)", width = 20)
@NotBlank(message = "ct不能为空")
private String ct;
@Excel(name = "设备容量", width = 15)
@Excel(name = "*设备容量", width = 15)
@NotNull(message = "设备容量不为空")
private Float devCapacity;
@Excel(name = "短路容量", width = 15)
@Excel(name = "*短路容量", width = 15)
@NotNull(message = "短路容量不为空")
private Float shortCapacity;
@Excel(name = "基准容量", width = 15)
@Excel(name = "*基准容量", width = 15)
@NotNull(message = "基准容量不为空")
private Float standardCapacity;
@Excel(name = "协议容量", width = 15)
@Excel(name = "*协议容量", width = 15)
@NotNull(message = "协议容量不为空")
private Float dealCapacity;
@Excel(name = "接线方式", replace = {"星型接法_0", "三角型接法_1", "开口三角型接法_2"}, width = 15)
@Excel(name = "*接线方式", replace = {"星型接法_0", "三角型接法_1", "开口三角型接法_2"}, width = 15)
@NotNull(message = "接线方式不为空")
private Integer ptType;
@Excel(name = "测量间隔", width = 15)
@Excel(name = "*测量间隔", width = 15)
@NotNull(message = "测量间隔不为空")
private Integer timeInterval;
@Excel(name = "干扰源类型", width = 15)
@Excel(name = "*干扰源类型", width = 15)
@NotBlank(message = "干扰源类型不为空")
private String loadType;
@Excel(name = "行业类型", width = 15)
@Excel(name = "*行业类型", width = 15)
@NotBlank(message = "行业类型不为空")
private String businessType;
@@ -183,11 +183,11 @@ public class TerminalBaseExcel implements Serializable {
@Excel(name = "监测点对象名称", width = 15)
private String objName;
@Excel(name = "电网侧标志", replace = {"电网侧_0", "非电网侧_1"}, width = 15)
@Excel(name = "*电网侧标志", replace = {"电网侧_0", "非电网侧_1"}, width = 15)
@NotNull(message = "电网侧标志不为空")
private Integer powerFlag;
@Excel(name = "人为干预统计", replace = {"不参与统计_0", "参与统计_1"}, width = 15)
@Excel(name = "*人为干预统计", replace = {"不参与统计_0", "参与统计_1"}, width = 15)
@NotNull(message = "统计标志不为空")
private Integer statFlag;

View File

@@ -0,0 +1,19 @@
package com.njcn.device.pq.pojo.param;
import lombok.Data;
/**
* Description:请求装置文件系统参数
* Date: 2026/04/30 上午 10:51【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
public class AskFileSysParam {
private String devId;
private String path;
private String remotePath;
}

View File

@@ -0,0 +1,76 @@
package com.njcn.device.pq.pojo.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author: cdf
* @CreateTime: 2025-12-02
* @Description:
*/
@Data
public class PqSensitiveUserParam {
/**
* 敏感用户名称
*/
@NotBlank(message = "用户名称不可为空")
@ApiModelProperty(name = "name",value = "用户名称不可为空")
private String name;
/**
* 敏感负荷类型
*/
@NotBlank(message = "敏感负荷类型不可为空")
@ApiModelProperty(name = "loadType",value = "敏感负荷类型")
private String loadType;
/**
* 用户协议容量
*/
@Range(min = 0,max = 10000000 )
@ApiModelProperty(name = "userAgreementCapacity",value = "用户协议容量")
private Double userAgreementCapacity;
/**
* 装机容量
*/
@Range(min = 0,max = 10000000 )
@ApiModelProperty(name = "installedCapacity",value = "装机容量")
private Double installedCapacity;
/**
* 所属厂站名称
*/
@NotBlank(message = "所属厂站名称不可为空")
@ApiModelProperty(name = "substationName",value = "所属厂站名称")
private String substationName;
/**
* 排序
*/
@NotNull(message = "排序不可为空")
@ApiModelProperty(name = "sort",value = "排序")
private Integer sort;
@Data
@EqualsAndHashCode(callSuper = true)
public static class UpdatePqSensitiveUserParam extends PqSensitiveUserParam{
/**
* id
*/
@NotBlank(message = "id不可为空")
@ApiModelProperty(name = "id",value = "id")
private String id;
}
}

View File

@@ -1,6 +1,8 @@
package com.njcn.device.pq.pojo.po;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
@@ -17,6 +19,7 @@ import java.io.Serializable;
public class DeviceProcess implements Serializable {
private static final long serialVersionUID = 1L;
//设备id
@TableId("Id")
private String id;
//设备设备所在前置机进程号
private Integer processNo;

View File

@@ -63,6 +63,9 @@ public class AreaLineInfoVO implements Serializable {
@ApiModelProperty(name = "pt2",value = "pt2")
private Integer pt2;
@ApiModelProperty(name = "ptType",value = "接线类型(0:星型接法;1:三角型接法;2:开口三角型接法)")
private Integer ptType;
@ApiModelProperty(name = "objName",value = "对象名称")
private String objName;

View File

@@ -105,6 +105,9 @@ public class LineDetailVO implements Serializable {
@ApiModelProperty(name = "终端厂家")
private String manufacturer;
@ApiModelProperty(name = "终端厂家")
private String objId;
}
@Data

View File

@@ -0,0 +1,52 @@
package com.njcn.device.pq.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author wr
* @description
* @date 2026/2/2 15:16
*/
@Data
public class LineInfoMonitorIdVO {
@ApiModelProperty(name = "lineId",value = "监测点id")
private String lineId;
@ApiModelProperty(name = "gdName",value = "供电公司名称")
private String gdName;
@ApiModelProperty(name = "lineName",value = "监测点名称")
private String lineName;
@ApiModelProperty(name = "loadType",value = "干扰源类型")
private String loadType;
@ApiModelProperty(name = "objName",value = "对象名称")
private String objName;
@ApiModelProperty(name = "subName",value = "变电站名称")
private String subName;
@ApiModelProperty(name = "powerSubstationName", value = "电网侧变电站")
private String powerSubstationName;
@ApiModelProperty(name = "deviceId",value = "装置Id")
private String deviceId;
@ApiModelProperty(name = "deviceName",value = "装置名称")
private String deviceName;
@ApiModelProperty(name = "ip",value = "装置ip")
private String ip;
@ApiModelProperty(name = "manufacturer",value = "供应商名称")
private String manufacturer;
@ApiModelProperty(name = "monitorId",value = "国网ID")
private String monitorId;
@ApiModelProperty(name = "powerFlag",value = "电网标志0-电网侧1-非电网侧)")
private Integer powerFlag;
}

View File

@@ -0,0 +1,64 @@
package com.njcn.device.pq.pojo.vo;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author xy
* @since 2025-11-17
*/
@Data
public class PqSensitiveUserVo implements Serializable{
private static final long serialVersionUID = 1L;
/**
* id
*/
private String id;
/**
* 敏感用户名称
*/
private String name;
/**
* 敏感负荷类型
*/
private String loadType;
/**
* 排序
*/
private Integer sort;
/**
* 是否监测
*/
private String isMonitor;
/**
* 是否治理
*/
private String isGovern;
/**
* 用户协议容量
*/
private Double userAgreementCapacity;
/**
* 装机容量
*/
private Double installedCapacity;
/**
* 所属厂站名称
*/
private String substationName;
}

View File

@@ -59,4 +59,7 @@ public class RunTimeVO implements Serializable {
@ApiModelProperty(name = "onlineEvaluate",value = "在线率评价")
private Double onlineEvaluate;
@ApiModelProperty(name = "objName",value = "用户对象名称")
private String objName;
}

View File

@@ -116,6 +116,9 @@ public class DeviceOnlineRate {
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("监测对象")
private String objName;
@ApiModelProperty("监测点运行状态")
private String runFlag;

View File

@@ -0,0 +1,44 @@
package com.njcn.device.pq.pojo.vo.dataClean;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @version 1.0.0
* @author: chenchao
* @date: 2022/07/18 11:04
*/
@Getter
@Setter
@EqualsAndHashCode
public class CityDataExcel implements Serializable {
@ExcelProperty(value = "单位")
private String deptName;
@ExcelProperty(value = "监测终端数量")
private BigDecimal deviceNum;
@ExcelProperty(value = "监测点个数")
private BigDecimal lineNum;
@ExcelProperty(value = "在线率(%")
private BigDecimal onlineRate;
@ExcelProperty(value = "完整率(%")
private BigDecimal integrity;
@ExcelProperty(value = "问题监测点")
private BigDecimal abnormalNum;
@ExcelProperty(value = "问题监测点")
private List<String> abnormalList;
}

View File

@@ -3,11 +3,14 @@ package com.njcn.device.pq.pojo.vo.dataClean;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* @version 1.0.0
@@ -70,9 +73,15 @@ public class DataVerifyExcel implements Serializable {
@Excel(name = "厂商")
private String manufacturer;
@ColumnWidth(20)
@ExcelProperty(value = "电网标志")
@Excel(name = "电网标志")
@ApiModelProperty(name = "powerFlag",value = "电网标志")
private String powerFlag;
@ColumnWidth(20)
@ExcelProperty(value = "总指标异常时间")
@Excel(name = "")
@Excel(name = "指标异常时间")
private Integer allTime;
@ColumnWidth(20)
@@ -191,4 +200,33 @@ public class DataVerifyExcel implements Serializable {
private Integer riseTime;
// 字段名 ↔ Excel列名 映射
public static final Map<String, String> FIELD_COLUMN_MAP = new HashMap<>();
static {
// 按代码中字段顺序整理,确保一一对应
FIELD_COLUMN_MAP.put("freqTime", "频率");
FIELD_COLUMN_MAP.put("freqDevTime", "频率偏差");
FIELD_COLUMN_MAP.put("vRmsTime", "相电压有效值");
FIELD_COLUMN_MAP.put("vPosTime", "正序电压");
FIELD_COLUMN_MAP.put("vNegTime", "负序电压");
FIELD_COLUMN_MAP.put("vZeroTime", "零序电压");
FIELD_COLUMN_MAP.put("vUnbalanceTime", "电压不平衡度");
FIELD_COLUMN_MAP.put("rmsLvrTime", "线电压有效值");
FIELD_COLUMN_MAP.put("vuDevTime", "电压正偏差");
FIELD_COLUMN_MAP.put("vlDevTime", "电压负偏差");
FIELD_COLUMN_MAP.put("vThdTime", "电压总谐波畸变率");
FIELD_COLUMN_MAP.put("vTime", "相电压基波有效值");
FIELD_COLUMN_MAP.put("iRmsTime", "电流有效值");
FIELD_COLUMN_MAP.put("pltTime", "长时闪变");
FIELD_COLUMN_MAP.put("vInharmTime", "间谐波电压含有率");
FIELD_COLUMN_MAP.put("vHarmTime", "谐波电压含有率");
FIELD_COLUMN_MAP.put("pfTime", "功率因数");
FIELD_COLUMN_MAP.put("vPhasicTime", "谐波电压相角");
FIELD_COLUMN_MAP.put("v1PhasicTime", "谐波电压基波相角");
FIELD_COLUMN_MAP.put("flucTime", "电压波动");
FIELD_COLUMN_MAP.put("pstTime", "短时闪变");
FIELD_COLUMN_MAP.put("dipTime", "电压暂降");
FIELD_COLUMN_MAP.put("riseTime", "电压暂升");
}
}

View File

@@ -0,0 +1,54 @@
package com.njcn.device.pq.pojo.vo.dataClean;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @version 1.0.0
* @author: chenchao
* @date: 2022/07/18 11:04
*/
@Getter
@Setter
@EqualsAndHashCode
public class LineDataExcel implements Serializable {
@ExcelProperty(value = "序号")
private BigDecimal lineNum;
@ExcelProperty(value = "监测点名称")
private String lineName;
@ExcelProperty(value = "所属部门")
private String deptName;
@ExcelProperty(value = "接入电网侧变电站名")
private String powerSubstationName;
@ExcelProperty(value = "监测点对象名称")
private String objName;
@ExcelProperty(value = "装置编号")
private String deviceName;
@ExcelProperty(value = "IP地址")
private String ip;
@ExcelProperty(value = "终端厂家")
private String manufacturer;
@ExcelProperty(value = "在线率")
private BigDecimal onlineRate;
@ExcelProperty(value = "数据完整性")
private BigDecimal integrity;
@ExcelProperty(value = "国网ID")
private BigDecimal monitorId;
}

View File

@@ -0,0 +1,107 @@
package com.njcn.device.pq.utils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjUtil;
import com.njcn.device.pq.pojo.vo.dataClean.CityDataExcel;
import com.njcn.device.pq.pojo.vo.dataClean.LineDataExcel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author wr
* @description
* @date 2026/2/2 10:13
*/
public class DataLineExcelUtil {
/**
* 创建监测点信息表头
* @param FlyMonitorId
* @return
*/
public static List<List<String>> lineHeader(Boolean FlyMonitorId) {
List<List<String>> header = new ArrayList<>();
header.add(Collections.singletonList("序号"));
header.add(Collections.singletonList("监测点名称"));
header.add(Collections.singletonList("所属部门"));
header.add(Collections.singletonList("接入电网侧变电站名"));
header.add(Collections.singletonList("监测点对象名称"));
header.add(Collections.singletonList("装置编号"));
header.add(Collections.singletonList("IP地址"));
header.add(Collections.singletonList("终端厂家"));
header.add(Collections.singletonList("在线率"));
header.add(Collections.singletonList("数据完整性"));
if(FlyMonitorId){
header.add(Collections.singletonList("国网ID"));
}
return header;
}
/**
* 监测点信息表头数据写入
* @param data
* @return
*/
public static List<List<Object>> lineBody(List<LineDataExcel> data) {
List<List<Object>> result = new ArrayList<>();
if(CollUtil.isNotEmpty(data)){
for (LineDataExcel datum : data) {
ArrayList<Object> row = ListUtil.toList(datum.getLineNum(),
datum.getLineName(),
datum.getDeptName(),
datum.getPowerSubstationName(),
datum.getObjName(),
datum.getDeviceName(),
datum.getIp(),
datum.getManufacturer(),
datum.getOnlineRate(),
datum.getIntegrity());
if(ObjUtil.isNotNull(datum.getMonitorId())){
row.add(datum.getMonitorId());
}
result.add(row);
}
}
// 插入一个空行
result.add(Collections.emptyList());
return result;
}
/**
* 创建地市信息表头
* @return
*/
public static List<List<String>> cityHeader() {
List<List<String>> header = new ArrayList<>();
header.add(Collections.singletonList("单位"));
header.add(Collections.singletonList("监测终端数量"));
header.add(Collections.singletonList("监测点个数"));
header.add(Collections.singletonList("在线率(%"));
header.add(Collections.singletonList("完整率(%"));
header.add(Collections.singletonList("问题监测点"));
return header;
}
public static List<List<Object>> cityBody(List<CityDataExcel> data) {
List<List<Object>> result = new ArrayList<>();
if(CollUtil.isNotEmpty(data)){
for (CityDataExcel datum : data) {
ArrayList<Object> row = ListUtil.toList(datum.getDeptName(),
datum.getDeviceNum(),
datum.getLineNum(),
datum.getOnlineRate(),
datum.getIntegrity(),
datum.getAbnormalNum());
result.add(row);
}
}
// 插入一个空行
result.add(Collections.emptyList());
return result;
}
}

View File

@@ -0,0 +1,237 @@
package com.njcn.device.pq.utils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.metadata.style.WriteFont;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.njcn.device.pq.pojo.vo.dataClean.DataVerifyExcel;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.util.*;
/**
* 修复版按数据量动态排序Excel列解决列挤在一行的问题
* 关键改动:表头构建方式 + 列宽匹配逻辑
*/
public class FixedDynamicExcelExport {
public static void main(String[] args) throws Exception {
// 1. 模拟测试数据(相电压数据量最多,频率次之,频率偏差最少)
List<DataVerifyExcel> dataList = EasyExcel.read("F:\\usr\\response.xlsx")
.head(DataVerifyExcel.class)
.doReadAllSync();
// 2. 导出Excel替换为你的本地路径比如桌面
dataList.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
);
exportExcelByDataSize(dataList, "D:/dynamic_excel_fixed.xlsx");
System.out.println("导出完成!打开桌面的「测试导出.xlsx」查看效果");
}
/**
* 核心方法按数据量排序导出Excel
*/
public static void exportExcelByDataSize(List<DataVerifyExcel> dataList, String outputPath) throws Exception {
// 步骤1统计每个字段的有效数据量
Map<String, Integer> fieldCount = countValidData(dataList);
// 步骤2按数据量降序排序字段名
List<String> sortedFields = sortFields(fieldCount);
// 步骤3构建正确的动态表头
List<List<String>> head = buildCorrectHead(sortedFields);
// 步骤4构建对应顺序的行数据
List<List<Object>> data = buildRowData(dataList, sortedFields);
// 步骤5导出Excel含列宽设置
try (FileOutputStream out = new FileOutputStream(outputPath)) {
EasyExcel.write(out)
.head(head)
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(new FreezeHeaderHandler()) // 用修复后的表头
.sheet("数据统计")
.doWrite(data);
}
}
public static Map<String, List> exportExcelByDataSize(List<DataVerifyExcel> dataList) {
Map<String, List> map = new HashMap<>(2);
Map<String, Integer> fieldCount = countValidData(dataList);
List<String> sortedFields = sortFields(fieldCount);
map.put("head", buildCorrectHead(sortedFields));
map.put("data", buildRowData(dataList, sortedFields));
return map;
}
public static class FreezeHeaderHandler implements SheetWriteHandler {
@Override
public void beforeSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
// 表格创建前无需操作
}
@Override
public void afterSheetCreate(WriteWorkbookHolder writeWorkbookHolder, WriteSheetHolder writeSheetHolder) {
Sheet sheet = writeSheetHolder.getSheet();
// freezePane(c, r)c=冻结列数r=冻结行数这里r=1表示冻结第1行表头c=0表示不冻结列
// 比如 freezePane(1, 1) 表示冻结第一列+第一行
sheet.createFreezePane(0, 1);
}
}
public static HorizontalCellStyleStrategy writeCenterStyle() {
// 内容的策略
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置 自动换行
contentWriteCellStyle.setWrapped(true);
//设置 垂直居中
contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
//设置 水平居中
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
//设置边框样式
contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);
contentWriteCellStyle.setBorderTop(BorderStyle.THIN);
contentWriteCellStyle.setBorderRight(BorderStyle.THIN);
contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);
WriteFont bodyWriteFont = new WriteFont();
bodyWriteFont.setFontHeightInPoints((short) 11);
bodyWriteFont.setBold(false);
bodyWriteFont.setFontName("宋体");
contentWriteCellStyle.setWriteFont(bodyWriteFont);
// 头部
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 设置字体居中
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont headWriteFont = new WriteFont();
// 设置字体大小为20
headWriteFont.setFontHeightInPoints((short) 11);
headWriteFont.setBold(false);
headWriteFont.setFontName("宋体");
headWriteCellStyle.setWriteFont(headWriteFont);
return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
}
// ★ 修复点1构建正确的表头每个列名独立成List
private static List<List<String>> buildCorrectHead(List<String> allFields) {
List<List<String>> head = new ArrayList<>();
head.add(Collections.singletonList("供电公司"));
head.add(Collections.singletonList("所属变电站"));
head.add(Collections.singletonList("终端名称"));
head.add(Collections.singletonList("监测点名称"));
head.add(Collections.singletonList("IP"));
head.add(Collections.singletonList("干扰源类型"));
head.add(Collections.singletonList("监测对象名称"));
head.add(Collections.singletonList("电网侧变电站"));
head.add(Collections.singletonList("厂商"));
head.add(Collections.singletonList("电网标志"));
head.add(Collections.singletonList("总指标异常时间"));
List<String> sortedFields = allFields.subList(11, allFields.size());
for (String field : sortedFields) {
// 每个列名单独封装成ListEasyExcel才能识别为不同列
head.add(Collections.singletonList(DataVerifyExcel.FIELD_COLUMN_MAP.get(field)));
}
return head;
}
// 统计有效数据量(无改动,保留)
private static Map<String, Integer> countValidData(List<DataVerifyExcel> dataList) {
// 1. 初始化计数字典反射自动提取所有Time结尾的Integer字段初始值0
Map<String, Integer> countMap = initCountMap();
// 2. 判空,避免空指针异常
if (dataList == null || dataList.isEmpty()) {
return countMap;
}
// 3. 获取DataStatistic类的所有字段
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
try {
// 4. 遍历每个数据对象
for (DataVerifyExcel data : dataList) {
// 5. 遍历每个字段,累加数值
for (Field field : fields) {
// 过滤条件Integer类型 + 以Time结尾
if (field.getType() == Integer.class && field.getName().endsWith("Time") ) {
if(!field.getName().equals("allTime")){
// 设置可访问私有字段
field.setAccessible(true);
// 获取当前对象的该字段值
Integer value = (Integer) field.get(data);
// 非空则累加
if (value != null) {
String fieldName = field.getName();
countMap.put(fieldName, countMap.get(fieldName) + value);
}
}
}
}
}
} catch (IllegalAccessException e) {
// 捕获反射访问异常,便于排查问题
throw new RuntimeException("统计字段时反射访问失败", e);
}
return countMap;
}
// 反射初始化计数字典(复用之前的逻辑)
private static Map<String, Integer> initCountMap() {
Map<String, Integer> countMap = new HashMap<>();
Field[] fields = DataVerifyExcel.class.getDeclaredFields();
for (Field field : fields) {
if (field.getType() == Integer.class && field.getName().endsWith("Time")) {
if(!field.getName().equals("allTime")){
countMap.put(field.getName(), 0);
}
}
}
return countMap;
}
// 按数据量排序字段(无改动,保留)
private static List<String> sortFields(Map<String, Integer> fieldCount) {
List<String> fields = new ArrayList<>(fieldCount.keySet());
fields.sort((f1, f2) -> fieldCount.get(f2) - fieldCount.get(f1)); // 降序
List<String> fieldAlls=new ArrayList<>();
fieldAlls.add("city");
fieldAlls.add("stationName");
fieldAlls.add("devName");
fieldAlls.add("lineName");
fieldAlls.add("ip");
fieldAlls.add("loadType");
fieldAlls.add("objName");
fieldAlls.add("powerSubstationName");
fieldAlls.add("manufacturer");
fieldAlls.add("powerFlag");
fieldAlls.add("allTime");
fieldAlls.addAll(fields);
return fieldAlls;
}
// 构建行数据(无改动,保留)
private static List<List<Object>> buildRowData(List<DataVerifyExcel> dataList, List<String> sortedFields) {
List<List<Object>> rows = new ArrayList<>();
for (DataVerifyExcel data : dataList) {
List<Object> row = new ArrayList<>();
for (String field : sortedFields) {
try {
Field f = DataVerifyExcel.class.getDeclaredField(field);
f.setAccessible(true);
row.add(f.get(data));
} catch (Exception e) {
throw new RuntimeException("导出异常数据转换异常:"+e);
}
}
rows.add(row);
}
return rows;
}
}

View File

@@ -1,6 +1,8 @@
package com.njcn.device.pq.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
@@ -155,6 +157,10 @@ public class DataVerifyController extends BaseController {
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
if(StrUtil.isNotBlank(monitorBaseParam.getSearchBeginTime())&&StrUtil.isNotBlank(monitorBaseParam.getSearchEndTime())){
monitorBaseParam.setSearchBeginTime(DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())).toString());
monitorBaseParam.setSearchEndTime(DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())).toString());
}
iPqDataVerifyBakService.dataVerifyExcel(response, monitorBaseParam);
}

View File

@@ -0,0 +1,113 @@
package com.njcn.device.pq.controller;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.device.pq.pojo.param.PqSensitiveUserParam;
import com.njcn.device.pq.pojo.vo.PqSensitiveUserVo;
import com.njcn.device.pqUser.service.IPqSensitiveUserService;
import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2025-11-17
*/
@Slf4j
@RestController
@RequestMapping("/pqSensitiveUser")
@Api(tags = "敏感负荷用户管理")
@AllArgsConstructor
public class PqSensitiveUserController extends BaseController {
private final IPqSensitiveUserService pqSensitiveUserService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getList")
@ApiOperation("获取敏感负荷用户列表")
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
public HttpResult<Page<PqSensitiveUserVo>> getList(@RequestBody BaseParam param) {
String methodDescribe = getMethodDescribe("getList");
Page<PqSensitiveUserVo> page = pqSensitiveUserService.getList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getListByIds")
@ApiOperation("根据id集合获取敏感负荷用户列表")
@ApiImplicitParam(name = "ids", value = "id集合")
public HttpResult<List<PqSensitiveUser>> getListByIds(@RequestParam(name = "ids", required = false) List<String> ids) {
String methodDescribe = getMethodDescribe("getListByIds");
List<PqSensitiveUser> list;
list = pqSensitiveUserService.list(
new LambdaQueryWrapper<PqSensitiveUser>().in(PqSensitiveUser::getId, ids)
);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
/**
* 新增用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@PostMapping("/save")
@ApiOperation("新增用户对象")
public HttpResult<Boolean> save(@RequestBody @Validated PqSensitiveUserParam pqSensitiveUserParam) {
String methodDescribe = getMethodDescribe("save");
pqSensitiveUserService.save(pqSensitiveUserParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
/**
* 修改用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("修改用户对象")
public HttpResult<Boolean> update(@RequestBody @Validated PqSensitiveUserParam.UpdatePqSensitiveUserParam pqSensitiveUserParam) {
String methodDescribe = getMethodDescribe("update");
pqSensitiveUserService.update(pqSensitiveUserParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
/**
* 删除用户对象
*/
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE)
@PostMapping("/delete")
@ApiOperation("删除用户对象")
@ApiImplicitParam(name = "ids", value = "id集合")
public HttpResult<Boolean> delete(@RequestBody List<String> ids) {
String methodDescribe = getMethodDescribe("delete");
pqSensitiveUserService.removeByIds(ids);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
}
}

View File

@@ -6,14 +6,14 @@ package com.njcn.device.pq.controller;
* @Description: 异常告警数据指标范围
*/
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
import com.njcn.algorithm.pojo.param.DataCleanParam;
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.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.device.pq.service.ReasonableRangeService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;

View File

@@ -42,6 +42,17 @@ public class RunManageController extends BaseController {
private final RunManageService runManageService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLineLedgerComm")
@ApiOperation("监测点台账信息")
@ApiImplicitParam(name = "runManageParam", value = "监测点台账参数", required = true)
public HttpResult<Page<RunManageVO>> getLineLedgerComm(@RequestBody @Validated RunManageParam runManageParam) {
String methodDescribe = getMethodDescribe("getLineLedgerComm");
Page<RunManageVO> res = runManageService.getLineLedgerComm(runManageParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getLineLedger")
@ApiOperation("监测点台账信息")
@@ -54,18 +65,18 @@ public class RunManageController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getRuntimeData")
@ApiOperation("终端台账信息")
@ApiOperation("终端台账信息(通用)")
@ApiImplicitParam(name = "runManageParam", value = "终端台账参数", required = true)
public HttpResult<List<RunTimeVO>> getRuntimeData(@RequestBody @Validated RunManageParam runManageParam) {
public HttpResult<Page<RunTimeVO>> getRuntimeData(@RequestBody @Validated RunManageParam runManageParam) {
String methodDescribe = getMethodDescribe("getRuntimeData");
List<RunTimeVO> result = runManageService.getRuntimeDetail(runManageParam);
Page<RunTimeVO> result = runManageService.getRuntimeDetail(runManageParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDeviceLedger")
@ApiOperation("获取基本的终端台账信息")
@ApiOperation("获取基本的终端台账信息(冀北)")
@ApiImplicitParam(name = "runManageParam", value = "终端台账参数", required = true)
public HttpResult<Page<RunTimeVO>> getDeviceLedger(@RequestBody @Validated RunManageParam runManageParam) {
String methodDescribe = getMethodDescribe("getRuntimeData");

View File

@@ -0,0 +1,181 @@
package com.njcn.device.pq.controller.file;
import cn.hutool.core.date.TimeInterval;
import cn.hutool.core.util.IdUtil;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.device.device.service.DeviceProcessService;
import com.njcn.device.device.service.IDeviceService;
import com.njcn.device.pq.pojo.param.AskFileSysParam;
import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.po.DeviceProcess;
import com.njcn.message.api.ProduceFeignClient;
import com.njcn.message.message.AskFileSysMessage;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
/**
* Description:
* Date: 2026/04/29 上午 11:41【需求编号】
*
* @author clam
* @version V1.0.0
*/
@RestController
@RequestMapping("/dir")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "装置文件系统")
public class DirectoryController extends BaseController {
private final ProduceFeignClient produceFeignClient;
private final PendingRequestManager pendingRequestManager;
private final IDeviceService iDeviceService;
private final DeviceProcessService deviceProcessService;
@PostMapping("/list")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("获取装置文件目录")
public DeferredResult<Object> listDirectory(@RequestBody AskFileSysParam askFileSysParam) {
String methodDescribe = getMethodDescribe("listDirectory");
long timeoutMs = 15000L; // 15 秒超时
// 构造指令 body
Device device = iDeviceService.getById(askFileSysParam.getDevId());
DeviceProcess deviceProcess = deviceProcessService.getById(askFileSysParam.getDevId());
// 发送 MQ 指令,获取 msgId
AskFileSysMessage askFileSysMessage = new AskFileSysMessage();
askFileSysMessage.setGuid(IdUtil.simpleUUID());
askFileSysMessage.setNodeId(device.getNodeId());
askFileSysMessage.setProcessNo(deviceProcess.getProcessNo());
askFileSysMessage.setDevId(askFileSysParam.getDevId());
askFileSysMessage.setType(0);
askFileSysMessage.setPath(askFileSysParam.getPath());
produceFeignClient.askFileSys(askFileSysMessage);
// 创建挂起请求
DeferredResult<Object> deferredResult = pendingRequestManager.createPendingRequest(askFileSysMessage.getGuid(), timeoutMs);
// 可额外在 Redis 中记录初始状态(可选)
// 返回 DeferredResultSpring 将挂起此请求
return deferredResult;
}
@PostMapping("/downLoadFile")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("获取装置文件文件")
public DeferredResult<Object> downLoadFile(@RequestBody AskFileSysParam askFileSysParam) {
String methodDescribe = getMethodDescribe("downLoadFile");
long timeoutMs = 15000L; // 15 秒超时
// 构造指令 body
Device device = iDeviceService.getById(askFileSysParam.getDevId());
DeviceProcess deviceProcess = deviceProcessService.getById(askFileSysParam.getDevId());
// 发送 MQ 指令,获取 msgId
AskFileSysMessage askFileSysMessage = new AskFileSysMessage();
askFileSysMessage.setGuid(IdUtil.simpleUUID());
askFileSysMessage.setNodeId(device.getNodeId());
askFileSysMessage.setProcessNo(deviceProcess.getProcessNo());
askFileSysMessage.setDevId(askFileSysParam.getDevId());
askFileSysMessage.setType(1);
askFileSysMessage.setPath(askFileSysParam.getPath());
produceFeignClient.askFileSys(askFileSysMessage);
// 创建挂起请求
DeferredResult<Object> deferredResult = pendingRequestManager.createPendingRequest(askFileSysMessage.getGuid(), timeoutMs);
// 可额外在 Redis 中记录初始状态(可选)
// 返回 DeferredResultSpring 将挂起此请求
return deferredResult;
}
@PostMapping("/upLoadFile")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("上传装置文件文件")
public DeferredResult<Object> upLoadFile(@RequestBody AskFileSysParam askFileSysParam) {
String methodDescribe = getMethodDescribe("upLoadFile");
long timeoutMs = 15000L; // 15 秒超时
// 构造指令 body
Device device = iDeviceService.getById(askFileSysParam.getDevId());
DeviceProcess deviceProcess = deviceProcessService.getById(askFileSysParam.getDevId());
// 发送 MQ 指令,获取 msgId
AskFileSysMessage askFileSysMessage = new AskFileSysMessage();
askFileSysMessage.setGuid(IdUtil.simpleUUID());
askFileSysMessage.setNodeId(device.getNodeId());
askFileSysMessage.setProcessNo(deviceProcess.getProcessNo());
askFileSysMessage.setDevId(askFileSysParam.getDevId());
askFileSysMessage.setType(2);
askFileSysMessage.setPath(askFileSysParam.getPath());
askFileSysMessage.setRemotePath(askFileSysParam.getRemotePath());
produceFeignClient.askFileSys(askFileSysMessage);
// 创建挂起请求
DeferredResult<Object> deferredResult = pendingRequestManager.createPendingRequest(askFileSysMessage.getGuid(), timeoutMs);
// 可额外在 Redis 中记录初始状态(可选)
// 返回 DeferredResultSpring 将挂起此请求
return deferredResult;
}
@PostMapping("/delete")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("装置目录,文件删除")
public DeferredResult<Object> delete(@RequestBody AskFileSysParam askFileSysParam) {
String methodDescribe = getMethodDescribe("delete");
long timeoutMs = 15000L; // 15 秒超时
// 构造指令 body
Device device = iDeviceService.getById(askFileSysParam.getDevId());
DeviceProcess deviceProcess = deviceProcessService.getById(askFileSysParam.getDevId());
// 发送 MQ 指令,获取 msgId
AskFileSysMessage askFileSysMessage = new AskFileSysMessage();
askFileSysMessage.setGuid(IdUtil.simpleUUID());
askFileSysMessage.setNodeId(device.getNodeId());
askFileSysMessage.setProcessNo(deviceProcess.getProcessNo());
askFileSysMessage.setDevId(askFileSysParam.getDevId());
askFileSysMessage.setType(3);
askFileSysMessage.setPath(askFileSysParam.getPath());
askFileSysMessage.setRemotePath(askFileSysParam.getRemotePath());
produceFeignClient.askFileSys(askFileSysMessage);
// 创建挂起请求
DeferredResult<Object> deferredResult = pendingRequestManager.createPendingRequest(askFileSysMessage.getGuid(), timeoutMs);
// 可额外在 Redis 中记录初始状态(可选)
// 返回 DeferredResultSpring 将挂起此请求
return deferredResult;
}
@PostMapping("/restart")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("装置重启")
public DeferredResult<Object> restart(@RequestBody AskFileSysParam askFileSysParam) {
String methodDescribe = getMethodDescribe("restart");
long timeoutMs = 15000L; // 15 秒超时
// 构造指令 body
Device device = iDeviceService.getById(askFileSysParam.getDevId());
DeviceProcess deviceProcess = deviceProcessService.getById(askFileSysParam.getDevId());
// 发送 MQ 指令,获取 msgId
AskFileSysMessage askFileSysMessage = new AskFileSysMessage();
askFileSysMessage.setGuid(IdUtil.simpleUUID());
askFileSysMessage.setNodeId(device.getNodeId());
askFileSysMessage.setProcessNo(deviceProcess.getProcessNo());
askFileSysMessage.setDevId(askFileSysParam.getDevId());
askFileSysMessage.setPath("reboot");
askFileSysMessage.setType(4);
produceFeignClient.askFileSys(askFileSysMessage);
// 创建挂起请求
DeferredResult<Object> deferredResult = pendingRequestManager.createPendingRequest(askFileSysMessage.getGuid(), timeoutMs);
// 可额外在 Redis 中记录初始状态(可选)
// 返回 DeferredResultSpring 将挂起此请求
return deferredResult;
}
}

View File

@@ -0,0 +1,61 @@
package com.njcn.device.pq.controller.file;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.HttpResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult;
import java.util.concurrent.ConcurrentHashMap;
@Component
@Slf4j
public class PendingRequestManager {
@Autowired
private RedisTemplate<String, Object> redisTemplate;
// 本地映射msgId -> DeferredResult主要用于超时清理和主动完成
private final ConcurrentHashMap<String, DeferredResult<Object>> deferredResultMap = new ConcurrentHashMap<>();
// 创建挂起请求
public DeferredResult<Object> createPendingRequest(String msgId, long timeoutMs) {
DeferredResult<Object> deferredResult = new DeferredResult<>(timeoutMs);
// 超时回调
deferredResult.onTimeout(() -> {
// 清理 Redis 中的等待记录
redisTemplate.delete("pending:" + msgId);
deferredResultMap.remove(msgId);
deferredResult.setErrorResult(new BusinessException("前置超时...."));
});
// 完成回调(正常或异常后移出本地映射)
deferredResult.onCompletion(() -> deferredResultMap.remove(msgId));
deferredResultMap.put(msgId, deferredResult);
return deferredResult;
}
// 收到 Redis 通知后,根据 msgId 完成请求
public void completeRequest(String msgId) {
if (deferredResultMap.containsKey(msgId)) {
DeferredResult<Object> deferredResult = deferredResultMap.get(msgId);
// 从 Redis 中获取结果内容
String key = "pending:" + msgId;
Object result = redisTemplate.opsForValue().get(key);
if (result != null) {
deferredResult.setResult( HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result,""));
} else {
log.info("Receive notification for unknown msgId: " + msgId);
deferredResult.setErrorResult(new BusinessException("前置未返回结果"));
}
// 清理 Redis 中的记录(可选,利用过期时间自动删除也可)
redisTemplate.delete(key);
} else {
// 可能请求已超时被移除了,仅记录日志即可
log.info("Receive notification for unknown msgId: " + msgId);
}
}
}

View File

@@ -0,0 +1,20 @@
package com.njcn.device.pq.controller.file;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
import java.nio.charset.StandardCharsets;
@Component
public class RedisMessageSubscriber implements MessageListener {
@Autowired
private PendingRequestManager pendingRequestManager;
@Override
public void onMessage(Message message, byte[] pattern) {
String msgId = new String(message.getBody(), StandardCharsets.UTF_8);
pendingRequestManager.completeRequest(msgId);
}
}

View File

@@ -0,0 +1,44 @@
package com.njcn.device.pq.controller.file;
import com.njcn.redis.config.RedisConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;
import org.springframework.data.redis.connection.MessageListener;
import java.nio.charset.StandardCharsets;
/**
* Description:
* Date: 2026/04/29 下午 3:37【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Configuration
@Import(RedisConfig.class) // 引入公共配置
public class RedisSubscriptionConfig {
@Bean
public RedisMessageListenerContainer redisContainer(
RedisConnectionFactory connectionFactory,
MessageListenerAdapter resultListenerAdapter) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.addMessageListener(resultListenerAdapter, new ChannelTopic("result_ready_channel"));
return container;
}
@Bean
public MessageListenerAdapter resultListenerAdapter(RedisMessageSubscriber subscriber) {
return new MessageListenerAdapter(subscriber, "onMessage");
}
}

View File

@@ -10,9 +10,11 @@ import com.njcn.device.node.mapper.NodeMapper;
import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.po.DeviceProcess;
import com.njcn.device.pq.pojo.po.Node;
import com.njcn.message.constant.RedisKeyPrefix;
import com.njcn.redis.utils.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -21,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -33,6 +36,7 @@ import java.util.stream.Collectors;
@Component
@EnableScheduling
@RequiredArgsConstructor
@ConditionalOnProperty(name = "business.task-enabled", havingValue = "true", matchIfMissing = true)
public class DeviceComflagTasks {
private final NodeMapper nodeMapper;
private final IDeviceService iDeviceService;
@@ -63,8 +67,17 @@ public class DeviceComflagTasks {
pqsCommunicateDto.setTime(LocalDateTimeUtil.now().format(DatePattern.NORM_DATETIME_FORMATTER));
pqsCommunicateDto.setDevId(temp);
pqsCommunicateDto.setType(0);
//获取之前设备状态
String devFalg =redisUtil.getStringByKey(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(temp));
if(StringUtils.isBlank(devFalg)||(!Objects.equals(Integer.valueOf(devFalg),pqsCommunicateDto.getType()))){
//状态翻转
redisUtil.saveByKey(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(temp),pqsCommunicateDto.getType()+"");
pqsCommunicateFeignClient.insertion(pqsCommunicateDto) ;
}
pqsCommunicateFeignClient.insertion(pqsCommunicateDto) ;
});
}

View File

@@ -1,7 +1,7 @@
package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
import com.njcn.algorithm.pojo.po.PqReasonableRange;
/**
* <p>

View File

@@ -15,6 +15,7 @@
STATUS = 1
</select>
<select id="sortTransformer" resultType="java.lang.Integer">
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer order by update_time desc
select IFNULL(max(pqs_transformer.sort),0) from pqs_transformer
<!-- order by update_time desc-->
</select>
</mapper>

View File

@@ -1,6 +1,5 @@
package com.njcn.device.pq.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
import com.njcn.device.pq.pojo.po.DataVerify;
@@ -10,7 +9,6 @@ import com.njcn.device.pq.pojo.vo.dataClean.PowerQualityIndicatorsVO;
import com.njcn.device.pq.pojo.vo.dataClean.VerifyMonitorVO;
import java.util.List;
import java.util.Map;
/**
* <p>
@@ -22,19 +20,6 @@ import java.util.Map;
*/
public interface IDataVerifyService extends IService<DataVerify> {
VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam);
List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam);
List<DetailAbnormalVO> monitorAbnormalTable(MonitorBaseParam monitorBaseParam);
List<DetailAbnormalVO.DetailAbnormalInnerVO> monitorAbnormalTableDetail(MonitorBaseParam monitorBaseParam);
VerifyMonitorVO getMonitorLimitData(MonitorBaseParam monitorBaseParam);
List<PowerQualityIndicatorsVO> getMonitorLimitDataDay(MonitorBaseParam monitorBaseParam);
@@ -43,6 +28,5 @@ public interface IDataVerifyService extends IService<DataVerify> {
DetailAbnormalVO.DetailLimitCountVO monitorLimitTableDetail(MonitorBaseParam monitorBaseParam);
DetailAbnormalVO.Assess limitTableDetail(MonitorBaseParam monitorBaseParam);
}

View File

@@ -1,9 +1,10 @@
package com.njcn.device.pq.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
import com.njcn.algorithm.pojo.param.DataCleanParam;
import com.njcn.algorithm.pojo.po.PqReasonableRange;
import java.util.List;

View File

@@ -15,6 +15,9 @@ import java.util.List;
* @date 2022/3/30
*/
public interface RunManageService {
Page<RunManageVO> getLineLedgerComm(RunManageParam runManageParam);
/**
* 获取监测点台账信息
* @param runManageParam 参数
@@ -27,7 +30,7 @@ public interface RunManageService {
* @param runManageParam 参数
* @return 结果
*/
List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam);
Page<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam);
Page<RunTimeVO> getDeviceLedger(RunManageParam runManageParam);

View File

@@ -9,20 +9,17 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.algorithm.pojo.api.PqReasonableRangeFeignClient;
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
import com.njcn.algorithm.pojo.param.DataCleanParam;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.dataProcess.api.DataLimitRateDetailFeignClient;
import com.njcn.dataProcess.api.DataLimitRateFeignClient;
import com.njcn.dataProcess.api.DataLimitTargetFeignClient;
import com.njcn.dataProcess.api.PqReasonableRangeFeignClient;
import com.njcn.dataProcess.enums.DataCleanEnum;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.DataLimitRateDetailDto;
import com.njcn.dataProcess.pojo.dto.DataLimitRateDto;
import com.njcn.dataProcess.pojo.dto.DataLimitTargetDto;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.device.biz.enums.DeviceResponseEnum;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.biz.pojo.po.Overlimit;
import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.line.service.DeptLineService;
@@ -31,13 +28,11 @@ import com.njcn.device.pq.mapper.DataVerifyMapper;
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
import com.njcn.device.pq.pojo.po.DataVerify;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.device.pq.pojo.vo.dataClean.*;
import com.njcn.device.pq.service.CommTerminalService;
import com.njcn.device.pq.service.IDataVerifyService;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum;
@@ -51,7 +46,6 @@ import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
@@ -76,7 +70,6 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
private final CommTerminalService commTerminalService;
private final LineMapper lineMapper;
private final DictTreeFeignClient dictTreeFeignClient;
private final UserLedgerFeignClient userLedgerFeignClient;
private final PqReasonableRangeFeignClient pqReasonableRangeFeignClient;
private final DataLimitTargetFeignClient dataLimitTargetFeignClient;
private final DataLimitRateFeignClient dataLimitRateFeignClient;
@@ -86,121 +79,6 @@ public class DataVerifyServiceImpl extends ServiceImpl<DataVerifyMapper, DataVer
private final DeptLineService deptLineService;
@Override
public VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
if (CollUtil.isEmpty(monitorIds)) {
throw new BusinessException(DeviceResponseEnum.QUERY_LINE_DATA_EMPTY);
}
List<DataVerify> dataVerifyList = commQuery(monitorIds, monitorBaseParam);
VerifyMonitorVO verifyMonitorVO = new VerifyMonitorVO();
verifyMonitorVO.setRunNum(monitorIds.size());
verifyMonitorVO.setAbnormalNum(dataVerifyList.stream().collect(Collectors.groupingBy(DataVerify::getLineId)).size());
verifyMonitorVO.setMapList(getRangeAbnormalMonitor(monitorBaseParam, dataVerifyList));
verifyMonitorVO.setTargetList(getAbnormalTarget(dataVerifyList));
verifyMonitorVO.setMonitorAlarmInfo(getAbnormalTable(dataVerifyList, monitorBaseParam));
return verifyMonitorVO;
}
@Override
public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
List<DataVerify> dataVerifyList = commQuery(monitorIds, monitorBaseParam);
return getAbnormalTable(dataVerifyList, monitorBaseParam);
}
@Override
public List<DetailAbnormalVO> monitorAbnormalTable(MonitorBaseParam monitorBaseParam) {
List<DetailAbnormalVO> result = new ArrayList<>();
List<LineDevGetDTO> lineDetailList = lineMapper.getMonitorListDetail(monitorBaseParam.getMonitorIds());
Map<String, LineDevGetDTO> lineDetailMap = lineDetailList.stream().collect(Collectors.toMap(LineDevGetDTO::getPointId, Function.identity()));
LambdaQueryWrapper<DataVerify> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(DataVerify::getTime, DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())),
DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchEndTime())))
.in(DataVerify::getLineId, monitorBaseParam.getMonitorIds()).orderByAsc(DataVerify::getTime);
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
String[] target = monitorBaseParam.getTargetKey().split(SEPARATOR);
lambdaQueryWrapper.eq(DataVerify::getIndexCode, target[0]).eq(DataVerify::getIndexTable, target[1]);
}
List<DataVerify> dataVerifyList = this.list(lambdaQueryWrapper);
Map<String, List<DataVerify>> dataMap = dataVerifyList.stream().collect(Collectors.groupingBy(it -> it.getTime().format(DATE_FORMAT)));
dataMap.forEach((dateStr, data) -> {
Map<String, List<DataVerify>> lineMap = data.stream().collect(Collectors.groupingBy(DataVerify::getLineId));
lineMap.forEach((lineId, lineList) -> {
long count = lineList.stream().map(DataVerify::getTime).distinct().count();
DetailAbnormalVO detailAbnormalVO = new DetailAbnormalVO();
LineDevGetDTO lineDevGetDTO = lineDetailMap.get(lineId);
detailAbnormalVO.setTimeSum("");
detailAbnormalVO.setDate(dateStr);
detailAbnormalVO.setMonitorName(lineDevGetDTO.getPointName());
detailAbnormalVO.setMonitorId(lineDevGetDTO.getPointId());
detailAbnormalVO.setTargetKey(monitorBaseParam.getTargetKey());
result.add(detailAbnormalVO);
});
});
return result;
}
@Override
public List<DetailAbnormalVO.DetailAbnormalInnerVO> monitorAbnormalTableDetail(MonitorBaseParam monitorBaseParam) {
Map<String, PqReasonableRangeDto> dtoMap = getStandRange();
List<DetailAbnormalVO.DetailAbnormalInnerVO> result = new ArrayList<>();
LambdaQueryWrapper<DataVerify> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(DataVerify::getTime, DateUtil.beginOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())), DateUtil.endOfDay(DateUtil.parse(monitorBaseParam.getSearchBeginTime())))
.in(DataVerify::getLineId, monitorBaseParam.getMonitorIds()).orderByAsc(DataVerify::getTime);
if (StrUtil.isNotBlank(monitorBaseParam.getTargetKey())) {
String[] queryTarget = monitorBaseParam.getTargetKey().split(SEPARATOR);
lambdaQueryWrapper.eq(DataVerify::getIndexCode, queryTarget[0]).eq(DataVerify::getIndexTable, queryTarget[1]);
}
List<DataVerify> dataVerifyList = this.list(lambdaQueryWrapper);
Map<LocalDateTime, List<DataVerify>> listMap = dataVerifyList.stream().collect(Collectors.groupingBy(DataVerify::getTime, TreeMap::new,
Collectors.toList()));
listMap.forEach((time, timeList) -> {
Map<String, List<DataVerify>> indexMap = timeList.stream().collect(Collectors.groupingBy(it -> it.getIndexCode() + SEPARATOR + it.getIndexTable() + SEPARATOR + it.getIndexName()));
indexMap.forEach((target, list) -> {
String[] temKey = target.split(SEPARATOR);
PqReasonableRangeDto pqReasonableRangeDto = dtoMap.get(temKey[0] + SEPARATOR + temKey[1]);
String unit;
if (StrUtil.isNotBlank(pqReasonableRangeDto.getUnit())) {
unit = pqReasonableRangeDto.getUnit();
} else {
unit = "";
}
Map<String, List<DataVerify>> phaseMap = list.stream().collect(Collectors.groupingBy(DataVerify::getPhasicType));
phaseMap.forEach((phaseKey, valueList) -> {
DetailAbnormalVO.DetailAbnormalInnerVO vo = new DetailAbnormalVO.DetailAbnormalInnerVO();
vo.setTime(time.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
vo.setTargetName(temKey[2]);
vo.setTargetKey(temKey[0] + temKey[1]);
vo.setPhaseType(phaseKey);
vo.setRangeDesc(pqReasonableRangeDto.getMinValue() + unit + " ~ " + pqReasonableRangeDto.getMaxValue() + unit);
valueList.forEach(it -> {
switch (it.getValueType()) {
case "AVG":
vo.setAvg(it.getAbnormalValue().toString());
break;
case "MAX":
vo.setMax(it.getAbnormalValue().toString());
break;
case "MIN":
vo.setMin(it.getAbnormalValue().toString());
break;
case "CP95":
vo.setCp95(it.getAbnormalValue().toString());
break;
}
});
result.add(vo);
});
});
});
return result;
}
@Override
public VerifyMonitorVO getMonitorLimitData(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);

View File

@@ -29,10 +29,10 @@ import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.service.DeviceRunEvaluateService;
import com.njcn.device.pq.service.IPqDataVerifyCountService;
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.harmonic.api.RStatLimitRateDClient;
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
@@ -64,7 +64,7 @@ public class DeviceRunEvaluateServiceImpl implements DeviceRunEvaluateService {
private final RStatOnlinerateDMapper onLineRateDMapper;
private final RStatIntegrityDMapper integrityDMapper;
private final LineMapper lineMapper;
private final UserLedgerFeignClient userLedgerFeignClient;
private final UserLedgerService userLedgerService;
private final DeptLineService deptLineService;
private final GeneralDeviceService deviceService;
private final OnLineRateMapper onLineRateMapper;
@@ -523,7 +523,7 @@ public class DeviceRunEvaluateServiceImpl implements DeviceRunEvaluateService {
private Map<String, NewUserReportVO> getUserLedgerByObjIds(List<String> objIds) {
List<NewUserReportVO> userReportVOList = userLedgerFeignClient.getUserReportByIds(objIds).getData();
List<NewUserReportVO> userReportVOList = userLedgerService.getUserReportByIds(objIds);
return userReportVOList.stream().collect(Collectors.toMap(NewUserReportVO::getId, Function.identity()));
}

View File

@@ -3,7 +3,6 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.config.GeneralInfo;
@@ -28,8 +27,8 @@ import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
import com.njcn.device.pq.service.LineIntegrityDataService;
import com.njcn.device.pq.utils.DataStatisticsUtil;
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.harmonic.pojo.vo.IntegrityIconVO;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.pojo.enums.StatisticsEnum;
@@ -38,8 +37,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.Collator;
import java.util.*;
import java.util.function.Function;
@@ -59,18 +56,12 @@ import java.util.stream.Stream;
public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataMapper, LineIntegrityDataVO> implements LineIntegrityDataService {
private final LineIntegrityDataMapper lineIntegrityDataMapper;
private final AlarmClient alarmClient;
private final GeneralDeviceService generalDeviceService;
private final RStatIntegrityDMapper rStatIntegrityDMapper;
private final GeneralInfo generalInfo;
private final GeneralDeviceInfoClient generalDeviceInfoClient;
private final UserLedgerFeignClient userLedgerFeignClient;
private final UserLedgerService userLedgerService;
/**
* 监测点数据完整性
@@ -88,7 +79,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
if (CollectionUtil.isNotEmpty(generalDeviceDTOList)) {
Map<String, UserLedgerVO> userLedgerVOMap;
if (lineIntegrityDataParam.isUserLedger()) {
List<UserLedgerVO> userLedgerVOList = userLedgerFeignClient.selectUserList(new UserReportParam()).getData();
List<UserLedgerVO> userLedgerVOList = userLedgerService.selectUserList(new UserReportParam());
userLedgerVOMap = userLedgerVOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));
} else {
userLedgerVOMap = new HashMap<>();
@@ -101,12 +92,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
if (CollectionUtil.isEmpty(alarmStrategyVos)) {
throw new BusinessException(DeviceResponseEnum.QUERY_ALARMSTRATEGY_DATA_EMPTY);
}
List<AlarmStrategyVO> alarmAlgoDescribe = lineIntegrityDataMapper.getAlarmAlgoDescribe(alarmStrategyVos);
Map<Integer, Integer> mapAlarm = alarmAlgoDescribe.stream().collect(Collectors.toMap(AlarmStrategyVO::getAlgoDescribe, AlarmStrategyVO::getIntegrityValue));
Map<String, Integer> mapA = alarmStrategyVos.stream().collect(Collectors.toMap(AlarmStrategyVO::getId, AlarmStrategyVO::getIntegrityValue));
// 遍历集合
for (GeneralDeviceDTO generalDeviceDTO : generalDeviceDTOList) {

View File

@@ -4,6 +4,7 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.*;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
@@ -11,38 +12,49 @@ import cn.hutool.json.JSONConfig;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONTokener;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.WriteTable;
import com.alibaba.excel.write.style.column.SimpleColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.algorithm.pojo.api.PqReasonableRangeFeignClient;
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
import com.njcn.algorithm.pojo.param.DataCleanParam;
import com.njcn.common.pojo.dto.SimpleDTO;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.dataProcess.api.PqReasonableRangeFeignClient;
import com.njcn.dataProcess.enums.DataCleanEnum;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.device.common.mapper.onlinerate.OnLineRateMapper;
import com.njcn.device.common.service.GeneralDeviceService;
import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.line.service.DeptLineService;
import com.njcn.device.pq.constant.Param;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.mapper.PqDataVerifyBakMapper;
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
import com.njcn.device.pq.pojo.param.DeviceInfoParam;
import com.njcn.device.pq.pojo.param.OnlineRateParam;
import com.njcn.device.pq.pojo.param.dataClean.MonitorBaseParam;
import com.njcn.device.pq.pojo.po.DeptLine;
import com.njcn.device.pq.pojo.po.PqDataVerifyBak;
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.device.pq.pojo.vo.*;
import com.njcn.device.pq.pojo.vo.dataClean.*;
import com.njcn.device.pq.service.CommTerminalService;
import com.njcn.device.pq.service.IPqDataVerifyBakService;
import com.njcn.device.pq.utils.DataLineExcelUtil;
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.system.api.DictTreeFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -51,6 +63,9 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.exportExcelByDataSize;
import static com.njcn.device.pq.utils.FixedDynamicExcelExport.writeCenterStyle;
/**
* <p>
* 服务实现类
@@ -70,9 +85,11 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
private final PqReasonableRangeFeignClient pqReasonableRangeFeignClient;
private final LineMapper lineMapper;
private final DictTreeFeignClient dictTreeFeignClient;
private final UserLedgerFeignClient userLedgerFeignClient;
private final FileStorageUtil fileStorageUtil;
private final DeptLineService deptLineService;
private final GeneralDeviceService deviceService;
private final RStatIntegrityDMapper integrityDMapper;
private final OnLineRateMapper onLineRateMapper;
@Override
public VerifyMonitorVO getMonitorVerifyData(MonitorBaseParam monitorBaseParam) {
@@ -178,6 +195,9 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
@Override
public List<PowerQualityIndicatorsVO> getMonitorVerifyDay(MonitorBaseParam monitorBaseParam) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
if (CollectionUtils.isEmpty(monitorIds)) {
return new ArrayList<>();
}
List<PqDataVerifyBak> dataVerifyList = baseDataVerifyQuery(monitorIds, monitorBaseParam);
return getAbnormalTable(dataVerifyList, monitorBaseParam);
}
@@ -371,35 +391,226 @@ public class PqDataVerifyBakServiceImpl extends ServiceImpl<PqDataVerifyBakMappe
@Override
public void dataVerifyExcel(HttpServletResponse response, MonitorBaseParam monitorBaseParam) throws IOException {
if (StrUtil.isNotBlank(monitorBaseParam.getDeptId())) {
List<String> monitorIds = commTerminalService.getRunMonitorByDept(monitorBaseParam);
monitorBaseParam.setMonitorIds(monitorIds);
}
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam);
List<String> ids = dataVerifyExcels.stream().map(DataVerifyExcel::getLineId).collect(Collectors.toList());
List<AreaLineInfoVO> areaLineInfoVOList = lineMapper.getBaseLineAreaInfo(ids, null, null);
Map<String, AreaLineInfoVO> map = areaLineInfoVOList.stream().collect(Collectors.toMap(AreaLineInfoVO::getLineId, Function.identity()));
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) {
if (map.containsKey(dataVerifyExcel.getLineId())) {
AreaLineInfoVO areaLineInfoVO = map.get(dataVerifyExcel.getLineId());
dataVerifyExcel.setCity(areaLineInfoVO.getGdName());
dataVerifyExcel.setLineName(areaLineInfoVO.getLineName());
dataVerifyExcel.setLoadType(areaLineInfoVO.getLoadType());
dataVerifyExcel.setObjName(areaLineInfoVO.getObjName());
dataVerifyExcel.setStationName(areaLineInfoVO.getSubName());
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName());
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName());
dataVerifyExcel.setIp(areaLineInfoVO.getIp());
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
DeviceInfoParam param = new DeviceInfoParam();
param.setDeptIndex(monitorBaseParam.getDeptId());
param.setStatisticalType(new SimpleDTO());
//获取终端台账类信息
List<GeneralDeviceDTO> deviceInfo = deviceService.getDeviceInfo(param, Arrays.asList(0), Arrays.asList(1));
List<String> lineIds = deviceInfo.stream().flatMap(x -> x.getLineIndexes().stream()).distinct().collect(Collectors.toList());
List<String> devIds = deviceInfo.stream().flatMap(x -> x.getDeviceIndexes().stream()).distinct().collect(Collectors.toList());
List<LineInfoMonitorIdVO> areaLineInfoVOList = lineMapper.getBaseLineInfoMonitorIdInfo(lineIds);
List<LineInfoMonitorIdVO> monitorLine = areaLineInfoVOList.stream().filter(x -> StrUtil.isNotBlank(x.getMonitorId())).collect(Collectors.toList());
List<LineInfoMonitorIdVO> gridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 0).collect(Collectors.toList());
List<LineInfoMonitorIdVO> nonGridSide = areaLineInfoVOList.stream().filter(x -> x.getPowerFlag() == 1).collect(Collectors.toList());
OnlineRateParam onlineRateParam = new OnlineRateParam();
onlineRateParam.setIds(devIds);
onlineRateParam.setStartTime(monitorBaseParam.getSearchBeginTime());
onlineRateParam.setEndTime(monitorBaseParam.getSearchEndTime());
//完整率
List<RStatIntegrityVO> integrityList = integrityDMapper.getLineIntegrityRateInfo(lineIds,
monitorBaseParam.getSearchBeginTime(),
monitorBaseParam.getSearchEndTime());
//获取所有终端在线率
List<RStatOnlineRateVO> onlineRateByDev = onLineRateMapper.getOnlineRateByDevIds(onlineRateParam);
List<CityDataExcel> cityData1 = new ArrayList<>();
List<CityDataExcel> cityData2 = new ArrayList<>();
List<CityDataExcel> cityData3 = new ArrayList<>();
for (GeneralDeviceDTO dto : deviceInfo) {
cityData1.add(addCityDataExcel(dto, monitorLine, onlineRateByDev, integrityList));
cityData2.add(addCityDataExcel(dto, gridSide, onlineRateByDev, integrityList));
cityData3.add(addCityDataExcel(dto, nonGridSide, onlineRateByDev, integrityList));
}
monitorBaseParam.setMonitorIds(lineIds);
List<DataVerifyExcel> dataVerifyExcels = this.baseMapper.selectDataVerifySum(monitorBaseParam);
Map<String, LineInfoMonitorIdVO> lineInfomap = areaLineInfoVOList.stream().collect(Collectors.toMap(LineInfoMonitorIdVO::getLineId, Function.identity()));
for (DataVerifyExcel dataVerifyExcel : dataVerifyExcels) {
if (lineInfomap.containsKey(dataVerifyExcel.getLineId())) {
LineInfoMonitorIdVO areaLineInfoVO = lineInfomap.get(dataVerifyExcel.getLineId());
dataVerifyExcel.setCity(areaLineInfoVO.getGdName());
dataVerifyExcel.setLineName(areaLineInfoVO.getLineName());
dataVerifyExcel.setLoadType(areaLineInfoVO.getLoadType());
dataVerifyExcel.setObjName(areaLineInfoVO.getObjName());
dataVerifyExcel.setStationName(areaLineInfoVO.getSubName());
dataVerifyExcel.setPowerSubstationName(areaLineInfoVO.getPowerSubstationName());
dataVerifyExcel.setDevName(areaLineInfoVO.getDeviceName());
dataVerifyExcel.setIp(areaLineInfoVO.getIp());
dataVerifyExcel.setPowerFlag(areaLineInfoVO.getPowerFlag() == 0 ? "电网侧" : "非电网侧");
dataVerifyExcel.setManufacturer(areaLineInfoVO.getManufacturer());
}
}
dataVerifyExcels.sort(Comparator
.comparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
.thenComparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName() + "_" + item.getDevName())
);
Map<String, List> map = exportExcelByDataSize(dataVerifyExcels);
// 步骤5导出Excel含列宽设置
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream())
.registerWriteHandler(new SimpleColumnWidthStyleStrategy(20))
.registerWriteHandler(writeCenterStyle()).build();
WriteSheet writeSheet0 = EasyExcel.writerSheet("监测点异常指标统计").build();
WriteTable writeTable0 = EasyExcel.writerTable(0).needHead(Boolean.TRUE).head(map.get("head")).build();
excelWriter.write(map.get("data"), writeSheet0, writeTable0);
Map<Integer, List<CityDataExcel>> cityData = new HashMap<>();
cityData.put(1, cityData1);
cityData.put(2, cityData2);
cityData.put(3, cityData3);
Map<Integer, List<LineDataExcel>> lineData = new HashMap<>();
addLineDataExcel(cityData1, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 1);
addLineDataExcel(cityData2, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 2);
addLineDataExcel(cityData3, areaLineInfoVOList, onlineRateByDev, integrityList, lineData, 3);
excelExtracted(excelWriter, "数据质量", new HashMap<>(), cityData, true);
excelExtracted(excelWriter, "数据质量表格", lineData, new HashMap<>(), false);
excelWriter.finish();
}
}
private void addLineDataExcel(List<CityDataExcel> cityData1, List<LineInfoMonitorIdVO> areaLineInfoVOList, List<RStatOnlineRateVO> onlineRateByDev, List<RStatIntegrityVO> integrityList, Map<Integer, List<LineDataExcel>> lineData, Integer num) {
List<LineDataExcel> lineDataExcels1 = new ArrayList<>();
List<String> lineData1 = cityData1.stream().flatMap(x -> x.getAbnormalList().stream()).collect(Collectors.toList());
List<LineInfoMonitorIdVO> lineInfoData1 = areaLineInfoVOList.stream().filter(x -> lineData1.contains(x.getLineId())).collect(Collectors.toList());
LineDataExcel lineDataExcel;
for (int i = 0; i < lineInfoData1.size(); i++) {
LineInfoMonitorIdVO dto = lineInfoData1.get(i);
lineDataExcel = new LineDataExcel();
lineDataExcel.setLineNum(BigDecimal.valueOf((i + 1)));
lineDataExcel.setLineName(dto.getLineName());
lineDataExcel.setDeptName(dto.getDeviceName());
lineDataExcel.setPowerSubstationName(dto.getPowerSubstationName());
lineDataExcel.setObjName(dto.getObjName());
lineDataExcel.setDeviceName(dto.getDeviceName());
lineDataExcel.setIp(dto.getIp());
lineDataExcel.setManufacturer(dto.getManufacturer());
lineDataExcel.setOnlineRate(onLineRate(onlineRateByDev, Arrays.asList(dto.getDeviceId())));
lineDataExcel.setIntegrity(integrity(integrityList, Arrays.asList(dto.getLineId())));
if (num == 1) {
lineDataExcel.setMonitorId(new BigDecimal(dto.getMonitorId()));
}
lineDataExcels1.add(lineDataExcel);
}
lineData.put(num, lineDataExcels1);
}
private CityDataExcel addCityDataExcel(GeneralDeviceDTO dto, List<LineInfoMonitorIdVO> monitorLine, List<RStatOnlineRateVO> onlineRateByDev, List<RStatIntegrityVO> integrityList) {
CityDataExcel data = new CityDataExcel();
List<String> monitorLineList = monitorLine.stream()
.filter(x -> dto.getLineIndexes().contains(x.getLineId()))
.map(LineInfoMonitorIdVO::getLineId)
.distinct()
.collect(Collectors.toList());
List<String> devList = monitorLine.stream()
.filter(x -> dto.getDeviceIndexes().contains(x.getDeviceId()))
.map(LineInfoMonitorIdVO::getDeviceId)
.distinct()
.collect(Collectors.toList());
data.setDeptName(dto.getName());
data.setDeviceNum(BigDecimal.valueOf(devList.size()));
data.setLineNum(BigDecimal.valueOf(monitorLineList.size()));
data.setOnlineRate(onLineRate(onlineRateByDev, devList));
data.setIntegrity(integrity(integrityList, monitorLineList));
List<String> abnormalList = integrityList.stream()
.filter(x -> ObjUtil.isNotNull(x.getIntegrityRate()))
.filter(x -> x.getIntegrityRate().compareTo(BigDecimal.ZERO) == 0)
.filter(x -> monitorLineList.contains(x.getLineIndex()))
.map(RStatIntegrityVO::getLineIndex)
.distinct()
.collect(Collectors.toList());
data.setAbnormalNum(BigDecimal.valueOf(abnormalList.size()));
data.setAbnormalList(abnormalList);
return data;
}
private BigDecimal integrity(List<RStatIntegrityVO> integrityList, List<String> lineIds) {
//监测完整率
List<RStatIntegrityVO> integrityDS = integrityList.stream().filter(x -> lineIds.contains(x.getLineIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(integrityDS)) {
double realTime = integrityDS.stream().mapToDouble(RStatIntegrityVO::getRealTime).sum();
double dueTime = integrityDS.stream().mapToDouble(RStatIntegrityVO::getDueTime).sum();
if (dueTime == 0) {
return new BigDecimal(0);
}
return NumberUtil.round(Math.min(realTime * 100.0 / dueTime, 100), 2);
} else {
return new BigDecimal(0);
}
}
private BigDecimal onLineRate(List<RStatOnlineRateVO> onlineRateByDev, List<String> devIds) {
//终端在线率
List<RStatOnlineRateVO> onlineRateDS = onlineRateByDev.stream().filter(x -> devIds.contains(x.getDevIndex())).collect(Collectors.toList());
if (CollUtil.isNotEmpty(onlineRateDS)) {
double onlineTime = onlineRateDS.stream().mapToDouble(RStatOnlineRateVO::getOnlineMin).sum();
double offlineTime = onlineRateDS.stream().mapToDouble(RStatOnlineRateVO::getOfflineMin).sum();
if ((onlineTime + offlineTime) == 0) {
return new BigDecimal(0);
}
return NumberUtil.round(Math.min(onlineTime * 100.0 / (onlineTime + offlineTime), 100), 2);
} else {
return new BigDecimal(0);
}
}
private void excelExtracted(ExcelWriter excelWriter, String sheetName, Map<Integer, List<LineDataExcel>> lineData, Map<Integer, List<CityDataExcel>> cityData, Boolean fly) {
// 构建sheet页--表示不加表头
WriteSheet writeSheet = EasyExcel.writerSheet(sheetName).needHead(Boolean.FALSE).build();
// 表头的数量
int num = 0;
Boolean first = false;
// 模拟写5张表
for (int i = 1; i < 4; i++) {
String name = "";
if (i == 1) {
if (fly) {
name = "一类监测点";
} else {
name = "冀北公司一类监测点数据质量问题";
}
first = true;
}
if (i == 2) {
if (fly) {
name = "电网侧";
} else {
name = "冀北公司电网侧监测点数据质量问题(不包含一类监测点)";
}
first = false;
}
if (i == 3) {
if (fly) {
name = "非电网侧";
} else {
name = "冀北公司非电网侧问题监测点(不包含一类监测点)";
}
first = false;
}
String finalName = name;
List<List<String>> contentHeader;
if (fly) {
contentHeader = DataLineExcelUtil.cityHeader();
} else {
contentHeader = DataLineExcelUtil.lineHeader(first);
}
List<List<String>> nameHeader = contentHeader.stream().map(item -> Collections.singletonList(finalName)).collect(Collectors.toList());
// 这里必须指定需要头table 会继承sheet的配置sheet配置了不需要table 默认也是不需要
// 创建一个表头
WriteTable writeTable1 = EasyExcel.writerTable(num).needHead(Boolean.TRUE).head(nameHeader).build();
excelWriter.write(new ArrayList<>(), writeSheet, writeTable1);
//创建数据
WriteTable writeTable2 = EasyExcel.writerTable(num + 1).needHead(Boolean.TRUE).head(contentHeader).build();
List<List<Object>> body;
if (fly) {
body = DataLineExcelUtil.cityBody(cityData.get(i));
} else {
body = DataLineExcelUtil.lineBody(lineData.get(i));
}
excelWriter.write(body, writeSheet, writeTable2);
// 插入两次表头加2
num = num + 2;
}
Set<String> excludeColumnFiledNames = new HashSet<>(1);
excludeColumnFiledNames.add("lineId");
dataVerifyExcels.sort(Comparator.comparing((DataVerifyExcel item) -> item.getCity() + "_" + item.getStationName()+"_"+item.getDevName())
.thenComparing(DataVerifyExcel::getAllTime, Comparator.reverseOrder())
);
EasyExcel.write(response.getOutputStream(), DataVerifyExcel.class)
.excludeColumnFiledNames(excludeColumnFiledNames).sheet("sheet")
.doWrite(dataVerifyExcels);
}

View File

@@ -119,7 +119,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
}
private void addList(TflgployParam param, PqsTflgploy tflgploy, boolean save, List<PqsTflgployass> info) {
if(save){
// if(save){
List<String> tfIndexs = param.getTfIndexs();
if(CollUtil.isNotEmpty(tfIndexs)){
PqsTflgployass ass;
@@ -129,7 +129,7 @@ public class PqsTflgployServiceImpl extends ServiceImpl<PqsTflgployMapper, PqsTf
ass.setTfIndex(tfIndex);
info.add(ass);
}
}
// }
}
}

View File

@@ -2,12 +2,15 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.LineALLInfoDTO;
import com.njcn.device.common.service.GeneralDeviceService;
import com.njcn.device.line.mapper.LineDetailMapper;
import com.njcn.device.line.mapper.LineMapper;
@@ -30,7 +33,11 @@ import com.njcn.device.pq.pojo.vo.RStatIntegrityVO;
import com.njcn.device.pq.pojo.vo.common.DeviceOnlineRate;
import com.njcn.device.pq.service.IRStatIntegrityDService;
import com.njcn.device.rstatintegrity.mapper.RStatIntegrityDMapper;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -61,6 +68,8 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
private final LineDetailMapper lineDetailMapper;
private final GeneralDeviceService deviceService;
private final LineService lineService;
private final UserLedgerService userLedgerService;
private final CommLineClient commLineClient;
@Override
public Float getTotalIntegrityByLineIds(LineBaseQueryParam param) {
@@ -141,6 +150,9 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
@Override
public DeviceOnlineRate getData(DeviceInfoParam.BusinessParam param) {
DeviceOnlineRate rate = new DeviceOnlineRate();
//BusinessParam的searchvalue只匹配监测点名称现在要匹配电站监测点监测点对象名称所以穿空再添加过滤逻辑
String tempSearchValue=param.getSearchValue();
param.setSearchValue("");
//获取终端台账类信息
List<GeneralDeviceDTO> deviceInfo = deviceService.getDeviceInfo(param, null, Collections.singletonList(1));
if (CollUtil.isNotEmpty(deviceInfo)) {
@@ -149,29 +161,74 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
.stream()
.distinct()
.collect(Collectors.toList());
rate.setTotalNum(lineIds.size());
//获取所有监测点的数据完整性
List<RStatIntegrityVO> lineIntegrityRateInfo = rStatIntegrityDMapper.getLineIntegrityRateInfo(lineIds, param.getSearchBeginTime(), param.getSearchEndTime());
//获取所有监测点信息信息
List<LineDetailVO.Detail> LineInfoByIds = lineService.getLineDetailByIds(lineIds);
List<String> filterLineList = new ArrayList<>();
rate.setBelowNum(CollUtil.isNotEmpty(lineIntegrityRateInfo) ? calculateIntegrityRate(lineIntegrityRateInfo, 90, lineIds.size()) : lineIds.size());
rate.setTotalOnlineRate(calculateIntegrityRate(lineIntegrityRateInfo, lineIds).doubleValue()>100.0?BigDecimal.valueOf(100.0) : calculateIntegrityRate(lineIntegrityRateInfo, lineIds));
if(CollectionUtil.isNotEmpty(lineIds)){
//根据searchvalue过滤
List<LineALLInfoDTO> data = commLineClient.getLineAllDetailList(lineIds).getData();
filterLineList= data.stream()
.filter(dto -> {
LineALLInfoDTO.LineLineDTO lineDTO = dto.getLineLineDTO();
String linename = lineDTO != null ? lineDTO.getLinename() : null;
String objName2 = lineDTO != null ? lineDTO.getObjName2() : null;
LineALLInfoDTO.LineSubStationDTO subStationDTO = dto.getLineSubStationDTO();
String subStationName = subStationDTO != null ? subStationDTO.getSubStationName() : null;
// 大小写敏感的模糊匹配(相当于 MySQL 的 LIKE '%keyword%'
return (linename != null && linename.contains(tempSearchValue))
|| (objName2 != null && objName2.contains(tempSearchValue))
|| (subStationName != null && subStationName.contains(tempSearchValue));
}).map(dto -> dto.getLineLineDTO() != null ? dto.getLineLineDTO().getLineId() : null)
.collect(Collectors.toList());
}
rate.setTotalNum(filterLineList.size());
List<String> finalFilterLineList = filterLineList;
//根据过滤后监测点过滤
deviceInfo= deviceInfo.stream()
.filter(dto -> {
List<String> original = dto.getLineIndexes();
if (original == null || original.isEmpty()) {
return false;
}
// 计算交集
List<String> intersection = original.stream()
.filter(finalFilterLineList::contains)
.collect(Collectors.toList());
if (intersection.isEmpty()) {
return false;
}
// 更新当前 DTO 的 lineIndexes 为交集
dto.setLineIndexes(intersection);
return true;
})
.collect(Collectors.toList()); //获取所有监测点的数据完整性
List<RStatIntegrityVO> lineIntegrityRateInfo = rStatIntegrityDMapper.getLineIntegrityRateInfo(filterLineList, param.getSearchBeginTime(), param.getSearchEndTime());
//获取所有监测点信息信息
List<LineDetailVO.Detail> LineInfoByIds = lineService.getLineDetailByIds(filterLineList);
rate.setBelowNum(CollUtil.isNotEmpty(lineIntegrityRateInfo) ? calculateIntegrityRate(lineIntegrityRateInfo, 90, filterLineList.size()) : lineIds.size());
rate.setTotalOnlineRate(calculateIntegrityRate(lineIntegrityRateInfo, filterLineList).doubleValue()>100.0?BigDecimal.valueOf(100.0) : calculateIntegrityRate(lineIntegrityRateInfo, lineIds));
List<DeviceOnlineRate.CitDetail> citDetailList = new ArrayList<>();
DeviceOnlineRate.CitDetail citDetail;
DeviceOnlineRate.LineDetail detail;
//用户侧监测点 监测对象
List<UserLedgerVO> userLedgerVOS = userLedgerService.selectUserList(new UserReportParam());
Map<String, String> objMap = userLedgerVOS.stream().collect(Collectors.toMap(UserLedgerVO::getId, UserLedgerVO::getProjectName));
for (GeneralDeviceDTO dto : deviceInfo) {
//获取部门终端集合
List<RStatIntegrityVO> citDevOnRate = lineIntegrityRateInfo.stream().filter(x -> dto.getLineIndexes().contains(x.getLineIndex())).collect(Collectors.toList());
Map<String, BigDecimal> onlineRateByDevMap = citDevOnRate.stream()
.collect(Collectors.toMap(RStatIntegrityVO::getLineIndex, RStatIntegrityVO::getIntegrityRate));
citDetail = new DeviceOnlineRate.CitDetail();
List<LineDetailVO.Detail> lineDetail = LineInfoByIds.stream().filter(x -> dto.getLineIndexes().contains(x.getLineId())).collect(Collectors.toList());
citDetail.setCitName(dto.getName());
citDetail.setCitTotalNum(dto.getLineIndexes().size());
citDetail.setCitBelowNum(CollUtil.isNotEmpty(citDevOnRate) ? calculateIntegrityRate(citDevOnRate, 90, dto.getLineIndexes().size()) : dto.getLineIndexes().size());
citDetail.setCitTotalOnlineRate(calculateIntegrityRate(lineIntegrityRateInfo, dto.getLineIndexes()).doubleValue()>100.0?BigDecimal.valueOf(100.0):calculateIntegrityRate(lineIntegrityRateInfo, dto.getLineIndexes()));
List<DeviceOnlineRate.LineDetail> detailList = new ArrayList<>();
List<LineDetailVO.Detail> lineDetail = LineInfoByIds.stream().filter(x -> dto.getLineIndexes().contains(x.getLineId())).collect(Collectors.toList());
for (LineDetailVO.Detail line : lineDetail) {
detail = new DeviceOnlineRate.LineDetail();
detail.setCit(line.getDeptName());
@@ -184,6 +241,8 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
detail.setRunFlag(RunFlagEnum.getRunFlagRemarkByStatus(Integer.valueOf(line.getLineRunType())));
detail.setLineId(line.getLineId());
detail.setLineName(line.getLineName());
//用户侧监测点 监测对象
detail.setObjName(StringUtils.isBlank(line.getObjId())?"/":objMap.get(line.getObjId()));
detail.setLatestTime(line.getTimeID());
detail.setIntegrity(onlineRateByDevMap.getOrDefault(line.getLineId(), BigDecimal.valueOf(0)).doubleValue()>100.0?BigDecimal.valueOf(100.0):onlineRateByDevMap.getOrDefault(line.getLineId(), BigDecimal.valueOf(0)));
detailList.add(detail);

View File

@@ -3,10 +3,11 @@ package com.njcn.device.pq.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.dataProcess.param.DataCleanParam;
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
import com.njcn.algorithm.pojo.param.DataCleanParam;
import com.njcn.algorithm.pojo.po.PqReasonableRange;
import com.njcn.device.pq.mapper.ReasonableRangeMapper;
import com.njcn.device.pq.service.ReasonableRangeService;
import org.springframework.beans.BeanUtils;

View File

@@ -25,7 +25,7 @@ import com.njcn.device.pq.pojo.vo.RunManageVO;
import com.njcn.device.pq.pojo.vo.RunTimeVO;
import com.njcn.device.pq.pojo.vo.TerminalLedgerVO;
import com.njcn.device.pq.service.RunManageService;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
@@ -70,7 +70,34 @@ public class RunManageServiceImpl implements RunManageService {
private final LineDetailMapper lineDetailMapper;
private final UserLedgerFeignClient userLedgerFeignClient;
private final UserLedgerService userLedgerService;
/**
* 通用监测点台账,区别冀北版本的
* @author cdf
* @date 2026/3/22
*/
@Override
public Page<RunManageVO> getLineLedgerComm(RunManageParam runManageParam) {
Page<RunManageVO> pageResult = new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam));
List<String> lineIndexes ;
if(CollUtil.isNotEmpty(runManageParam.getIds())){
lineIndexes =runManageParam.getIds();
}else{
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
deviceInfoParam.setServerName("pqs-common");
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, null, Stream.of(1).collect(Collectors.toList()));
lineIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
}
if(CollectionUtil.isEmpty(lineIndexes)){
return pageResult;
}
pageResult = deviceMapper.getRunManageCommList(new Page<>(PageFactory.getPageNum(runManageParam),PageFactory.getPageSize(runManageParam)),lineIndexes, runManageParam.getComFlag(),Objects.isNull(runManageParam.getRunFlag())?new ArrayList<>():runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
return pageResult;
}
@Override
public List<RunManageVO> getLineLedger(RunManageParam runManageParam) {
@@ -86,10 +113,10 @@ public class RunManageServiceImpl implements RunManageService {
lineIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getLineIndexes().stream()).collect(Collectors.toList());
}
if (!CollectionUtils.isEmpty(lineIndexes)) {
resultList = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(),runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
resultList = deviceMapper.getRunManageList(lineIndexes, runManageParam.getComFlag(),Objects.isNull(runManageParam.getRunFlag())?new ArrayList<>():runManageParam.getRunFlag(), Objects.isNull(runManageParam.getSearchValue())?null:runManageParam.getSearchValue());
if(CollUtil.isNotEmpty(resultList)){
List<String> objIds = resultList.stream().map(RunManageVO::getObjId).collect(Collectors.toList());
Map<String,NewUserReportVO> runManageVOMap = userLedgerFeignClient.getUserReportByIds(objIds).getData().stream().collect(Collectors.toMap(NewUserReportVO::getId,Function.identity()));
Map<String,NewUserReportVO> runManageVOMap = userLedgerService.getUserReportByIds(objIds).stream().collect(Collectors.toMap(NewUserReportVO::getId,Function.identity()));
resultList.forEach(it->{
if(StrUtil.isNotBlank(it.getObjId())){
if(runManageVOMap.containsKey(it.getObjId())){
@@ -103,34 +130,18 @@ public class RunManageServiceImpl implements RunManageService {
}
@Override
public List<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
List<RunTimeVO> runManageDevList = new ArrayList<>();
public Page<RunTimeVO> getRuntimeDetail(RunManageParam runManageParam) {
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
BeanUtil.copyProperties(runManageParam, deviceInfoParam);
deviceInfoParam.setServerName("pqs-common");
List<GeneralDeviceDTO> generalDeviceDTOList = generalDeviceService.getDeviceInfo(deviceInfoParam, runManageParam.getRunFlag(), Stream.of(1).collect(Collectors.toList()));
if (!CollectionUtils.isEmpty(generalDeviceDTOList)) {
List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getDeviceIndexes().stream()).collect(Collectors.toList());
DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (StrUtil.isNotBlank(runManageParam.getSearchBeginTime()) && StrUtil.isNotBlank(runManageParam.getSearchEndTime())) {
runManageParam.setSearchBeginTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchBeginTime()))));
runManageParam.setSearchEndTime(bf.format(DateUtil.beginOfDay(DateUtil.parse(runManageParam.getSearchEndTime()))));
}
List<String> manuList = runManageParam.getManufacturer().stream().map(SimpleDTO::getId).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(devIndexes)) {
runManageDevList = deviceMapper.getRunManageDevList(devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(), manuList, runManageParam.getSearchValue());
List<LineInfluxDbOnlineVO> lineInfluxDbOnlineVOList = deviceMapper.getOnlineEvaluate(devIndexes, runManageParam.getSearchBeginTime(), runManageParam.getSearchEndTime());
Map<String, LineInfluxDbOnlineVO> map = lineInfluxDbOnlineVOList.stream().collect(Collectors.toMap(LineInfluxDbOnlineVO::getDevIndex, Function.identity()));
runManageDevList = runManageDevList.stream().peek(item -> item.setOnlineEvaluate(!map.containsKey(item.getId()) ? 3.14159 : NumberUtil.round(map.get(item.getId()).getOnlineRate(), 4).doubleValue())).collect(Collectors.toList());
String evaluate = runManageParam.getEvaluate();
if (StrUtil.isNotBlank(evaluate)) {
runManageDevList = runManageDevList.stream().filter(x -> filterOnlineEvaluate(evaluate, x.getOnlineEvaluate())).collect(Collectors.toList());
}
if (CollectionUtil.isEmpty(devIndexes)) {
return new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam));
}
}
return runManageDevList;
return deviceMapper.getRunManageDevList(new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam)),devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(), manuList, runManageParam.getSearchValue());
}
@Override

View File

@@ -23,14 +23,13 @@ import com.njcn.device.pq.pojo.po.LineDetail;
import com.njcn.device.pq.pojo.vo.DeptLineTreeVO;
import com.njcn.device.pq.pojo.vo.TerminalTree;
import com.njcn.device.pq.service.TerminalTreeService;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.pojo.enums.StatisticsEnum;
import com.njcn.system.pojo.po.Area;
import com.njcn.user.api.DeptFeignClient;
import com.njcn.user.pojo.po.Dept;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -66,7 +65,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
private final TreeMapper treeMapper;
private final UserLedgerFeignClient userLedgerFeignClient;
private final UserLedgerService userLedgerService;
/**
* 台账页面终端树
@@ -114,7 +113,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
UserReportParam userReportParam = new UserReportParam();
List<UserLedgerVO> userReportPOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
List<UserLedgerVO> userReportPOList = userLedgerService.selectUserList(userReportParam);
userReportPOList = userReportPOList.stream().filter(it -> StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
Map<String, List<UserLedgerVO>> userMap = userReportPOList.stream().collect(Collectors.groupingBy(UserLedgerVO::getStationId));
@@ -194,13 +193,16 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
});
UserLedgerVO userReportPO = userLedgerVOMap.get(objId);
if (Objects.isNull(userReportPO)) {
System.out.println(map);
}
TerminalTree terminalTree = new TerminalTree();
terminalTree.setName(userReportPO.getProjectName());
terminalTree.setId(userReportPO.getId());
terminalTree.setPid(userReportPO.getStationId());
if (Objects.isNull(userReportPO)) {
terminalTree.setName("用户对象缺失");
terminalTree.setId(objId);
terminalTree.setPid("");
}else {
terminalTree.setName(userReportPO.getProjectName());
terminalTree.setId(userReportPO.getId());
terminalTree.setPid(userReportPO.getStationId());
}
terminalTree.setPowerFlag(1);
terminalTree.setLevel(LineBaseEnum.USER_LEVEL.getCode());
terminalTree.setChildren(temDevList);
@@ -272,7 +274,7 @@ public class TerminalTreeServiceImpl implements TerminalTreeService {
} else {
// 获取用户
UserReportParam userReportParam = new UserReportParam();
List<UserLedgerVO> userReportPOList = userLedgerFeignClient.selectUserList(userReportParam).getData();
List<UserLedgerVO> userReportPOList = userLedgerService.selectUserList(userReportParam);
userReportPOList = userReportPOList.stream().filter(it -> StrUtil.isNotBlank(it.getStationId())).collect(Collectors.toList());
Map<String, UserLedgerVO> userMap = userReportPOList.stream().collect(Collectors.toMap(UserLedgerVO::getId, Function.identity()));

View File

@@ -29,12 +29,7 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>supervision-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>

View File

@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.text.StrBuilder;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
@@ -36,6 +37,7 @@ import com.njcn.device.device.mapper.DeviceMapper;
import com.njcn.device.device.service.DeviceBakService;
import com.njcn.device.device.service.DeviceProcessService;
import com.njcn.device.device.service.NodeDeviceService;
import com.njcn.device.device.service.PqDevTypeService;
import com.njcn.device.line.mapper.DeptLineMapper;
import com.njcn.device.line.mapper.LineDetailMapper;
import com.njcn.device.line.mapper.LineMapper;
@@ -60,6 +62,7 @@ import com.njcn.device.pq.utils.DeviceUtil;
import com.njcn.device.substation.mapper.SubstationMapper;
import com.njcn.device.subvoltage.mapper.VoltageMapper;
import com.njcn.device.terminal.mapper.PqsTerminalLogsMapper;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.device.utils.ExcelStyleUtil;
import com.njcn.message.api.ProduceFeignClient;
import com.njcn.message.constant.DeviceRebootType;
@@ -72,7 +75,8 @@ import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.poi.excel.ExcelUtil;
import com.njcn.poi.util.PoiUtil;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.supervision.api.UserLedgerFeignClient;
import com.njcn.supervision.pojo.param.user.UserReportParam;
import com.njcn.supervision.pojo.po.user.UserReportPO;
import com.njcn.supervision.pojo.vo.user.UserLedgerVO;
import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DicDataFeignClient;
@@ -96,10 +100,10 @@ import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -138,7 +142,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
private final NodeDeviceService nodeDeviceService;
private final DeviceProcessService deviceProcessService;
private final ProduceFeignClient produceFeignClient;
private final UserLedgerFeignClient userLedgerFeignClient;
private final UserLedgerService userLedgerService;
private final PqDevTypeService pqDevTypeService;
@Value("${oracle.isSync}")
private Boolean isSync;
@@ -681,6 +686,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
BeanUtils.copyProperties(updateDeviceParam, deviceDetail);
deviceDetail.setId(updateDeviceParam.getDevIndex());
coderM3d(deviceDetail, true);
deviceDetail.setLoginTime(LocalDate.parse(updateDeviceParam.getLoginTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
deviceDetail.setThisTimeCheck(LocalDate.parse(updateDeviceParam.getThisTimeCheck(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
deviceDetail.setNextTimeCheck(LocalDate.parse(updateDeviceParam.getNextTimeCheck(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)));
this.updateById(device);
deviceMapper.updateById(deviceDetail);
@@ -849,7 +857,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (!Objects.equals(lineDetail.getCt1(), lineDetailRes.getCt1()) || !Objects.equals(lineDetail.getCt2(), lineDetailRes.getCt2())
|| !Objects.equals(lineDetail.getPt1(), lineDetailRes.getPt1()) || !Objects.equals(lineDetail.getPt2(), lineDetailRes.getPt2())
|| !Objects.equals(lineDetail.getDevCapacity(), lineDetailRes.getDevCapacity()) || !Objects.equals(lineDetail.getShortCapacity(), lineDetailRes.getShortCapacity())
|| !Objects.equals(lineDetail.getStandardCapacity(), lineDetailRes.getStandardCapacity()) || !Objects.equals(lineDetail.getDealCapacity(), lineDetailRes.getDealCapacity())) {
|| !Objects.equals(lineDetail.getStandardCapacity(), lineDetailRes.getStandardCapacity()) || !Objects.equals(lineDetail.getDealCapacity(), lineDetailRes.getDealCapacity())
|| !Objects.equals(lineDetail.getPtType(), lineDetailRes.getPtType())) {
//获取用户信息
String index = RequestUtil.getUserIndex();
queryUpdateAndInsertLog(userName, index, lineDetail, lineDetailRes);
@@ -881,11 +890,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
private void coderM3d(Device deviceDetail, Boolean updateFlag) {
if (updateFlag) {
Device deviceRes = deviceMapper.selectById(deviceDetail.getId());
if (StrUtil.isNotBlank(deviceDetail.getDevKey()) && !deviceRes.getDevKey().equals(deviceDetail.getDevKey())) {
if (!Objects.equals(deviceRes.getDevKey(),deviceDetail.getDevKey())) {
deviceDetail.setDevKey(DeviceUtil.encodeString(devCD, deviceDetail.getDevKey()));
}
if (StrUtil.isNotBlank(deviceDetail.getSeries()) && !deviceRes.getSeries().equals(deviceDetail.getSeries())) {
if (!Objects.equals(deviceRes.getSeries(),deviceDetail.getSeries())) {
deviceDetail.setSeries(DeviceUtil.encodeString(devCD, deviceDetail.getSeries()));
}
} else {
@@ -896,7 +904,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
deviceDetail.setSeries(DeviceUtil.encodeString(devCD, deviceDetail.getSeries()));
}
}
}
private void decoderM3d(Device deviceDetail) {
@@ -957,6 +964,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
sbNew.append("协议容量: ").append(newLine.getDealCapacity()).append(";");
sbOld.append("协议容量: ").append(oldLine.getDealCapacity()).append(";");
}
//接线方式
if (!Objects.equals(newLine.getPtType(), oldLine.getPtType())) {
sbNew.append("接线方式: ").append(newLine.getPtType()).append(";");
sbOld.append("接线方式: ").append(oldLine.getPtType()).append(";");
}
sb.append(sbNew).append(sbOld);
HttpResult<DictData> dicDataByCode = dicDataFeignClient.getDicDataByCode(DicDataEnum.LINE_PARAMETER.getCode());
DictData data = dicDataByCode.getData();
@@ -984,7 +996,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
Line obj;
if (level == 700) {
obj = new Line();
UserLedgerVO userLedgerVO = userLedgerFeignClient.selectUserInfo(id).getData();
UserLedgerVO userLedgerVO = userLedgerService.selectUserInfo(id);
if (Objects.nonNull(userLedgerVO)) {
obj.setId(userLedgerVO.getId());
obj.setLevel(LineBaseEnum.USER_LEVEL.getCode());
@@ -1723,18 +1735,24 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
List<DictData> businessList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.BUSINESS_TYPE.getName()).getData();
List<DictData> loadTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.INTERFERENCE_SOURCE_TYPE.getName()).getData();
List<DictData> manufacturerList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_MANUFACTURER.getName()).getData();
List<DictData> devTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_TYPE.getName()).getData();
// List<DictData> devTypeList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_TYPE.getName()).getData();
List<PqDevType> devTypeList = pqDevTypeService.list(new LambdaQueryWrapper<PqDevType>()
.eq(PqDevType::getState, DataStateEnum.ENABLE.getCode())
.orderByDesc(PqDevType::getCreateTime));
List<DictData> frontList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.FRONT_TYPE.getName()).getData();
List<DictData> scaleList = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
List<UserLedgerVO> userLedgerVOS = userLedgerService.selectUserList(new UserReportParam());
List<Node> nodeList = nodeService.nodeAllList();
ExcelUtil.selectList(workbook, 4, 4, scaleList.stream().map(DictData::getName).collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 40, 40, userLedgerVOS.stream().map(UserLedgerVO::getProjectName).collect(Collectors.toList()).toArray(new String[]{}));
//这里是自己加的 带下拉框的代码
ExcelUtil.selectList(workbook, 8, 8, new String[]{"虚拟设备", "实际设备", "离线设备"});
ExcelUtil.selectList(workbook, 9, 9, new String[]{"暂态系统", "稳态系统", "双系统"});
ExcelUtil.selectList(workbook, 10, 10, new String[]{"投运", "热备用", "停运"});
ExcelUtil.selectList(workbook, 11, 11, manufacturerList.stream().map(DictData::getName).collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 12, 12, devTypeList.stream().map(DictData::getName).collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 12, 12, devTypeList.stream().map(PqDevType::getName).collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 17, 17, new String[]{"周期触发", "变为触发"});
ExcelUtil.selectList(workbook, 18, 18, nodeList.stream().map(Node::getName).collect(Collectors.toList()).toArray(new String[]{}));
ExcelUtil.selectList(workbook, 19, 19, frontList.stream().map(DictData::getName).collect(Collectors.toList()).toArray(new String[]{}));
@@ -1752,6 +1770,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
ExcelUtil.selectList(workbook, 41, 41, new String[]{"电网侧", "非电网侧"});
ExcelUtil.selectList(workbook, 42, 42, new String[]{"不参与统计", "参与统计"});
PoiUtil.exportFileByWorkbook(workbook, "台账导入模板.xlsx", response);
}
@Override
@@ -2721,6 +2741,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
* @author cdf
* @date 2022/5/18
*/
@Transactional(rollbackFor = Exception.class)
private void saveTerminalBase(List<TerminalBaseExcel> terminalBaseExcels) {
List<TerminalBaseExcel.TerminalBaseExcelMsg> terminalBaseExcelMsgs = new ArrayList<>();
//任意集合数据为空,不处理
@@ -2836,9 +2857,15 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
//处理终端类型
DictData devTypeDicData = dicDataFeignClient.getDicDataByName(terminalBaseExcel.getDevType()).getData();
PqDevType one = new PqDevType();
if (Objects.isNull(devTypeDicData)) {
terminalBaseExcelMsgs.add(assembleBaseMsg(terminalBaseExcel, "字典装置型号不存在"));
continue;
//上边逻辑不删兼容旧版本新版本查询pq_dev_type
one = pqDevTypeService.lambdaQuery().eq(PqDevType::getName, terminalBaseExcel.getDevType()).eq(PqDevType::getState, DataStateEnum.ENABLE.getCode()).one();
if(Objects.isNull(one)){
terminalBaseExcelMsgs.add(assembleBaseMsg(terminalBaseExcel, "字典装置型号不存在"));
continue;
}
}
this.baseMapper.insert(temp);
Device device = new Device();
@@ -2848,7 +2875,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
device.setIp(terminalBaseExcel.getIp());
device.setNodeId(node.getId());
device.setFrontType(frontTypeDicData.getId());
device.setDevType(devTypeDicData.getId());
device.setDevType(Objects.isNull(devTypeDicData)?one.getId():devTypeDicData.getId());
device.setComFlag(0);
device.setCheckFlag(1);
device.setLoginTime(LocalDate.now());
@@ -2857,7 +2884,11 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
device.setUpdateTime(LocalDateTime.now());
device.setElectroplate(0);
device.setOnTime(1);
//处理装置识别码秘钥
coderM3d(device, false);
deviceMapper.insert(device);
//分配前置进程
nodeDeviceService.oneKeyDistribution(node.getId());
}
//添加终端索引
pids.add(temp.getId());
@@ -2884,6 +2915,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
//处理电压等级字典表
DictData subvScale = dicDataFeignClient.getDicDataByNameAndType(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
if (Objects.isNull(subvScale)) {
terminalBaseExcelMsgs.add(assembleBaseMsg(terminalBaseExcel, "字典电压等级:" + terminalBaseExcel.getSubStationScale() + "不存在"));
continue;
@@ -2961,8 +2993,17 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
lineDetail.setPt2(Float.valueOf(pt[1]));
lineDetail.setCt1(Float.valueOf(ct[0]));
lineDetail.setCt2(Float.valueOf(ct[1]));
if(StringUtils.isNoneBlank(terminalBaseExcel.getObjName())){
UserReportPO one = userLedgerService.lambdaQuery().eq(UserReportPO::getProjectName, terminalBaseExcel.getObjName())
.eq(UserReportPO::getState, DataStateEnum.ENABLE.getCode()).one();
if(Objects.nonNull(one)){
lineDetail.setObjId(one.getId());
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
}
}
DictData dictData = dicDataFeignClient.getDicDataByNameAndType(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
lineDetailMapper.insert(lineDetail);
Overlimit overlimit = COverlimitUtil.globalAssemble(Float.parseFloat(dictData.getValue()), terminalBaseExcel.getDealCapacity(), terminalBaseExcel.getDevCapacity(), terminalBaseExcel.getShortCapacity(), null, null);
@@ -3849,14 +3890,29 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
//设备删除找不到设备名称,重日志截取
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);
//删除有2种情况1.设备删除2设备状态修改
if (lineMap.containsKey(deviceId)) {
pqsTerminalPushLogDTO.setDevName(lineMap.get(deviceId).getName());
String nodeId = deviceMap.get(deviceId).getNodeId();
pqsTerminalPushLogDTO.setNodeId(nodeId);
pqsTerminalPushLogDTO.setNodeName(nodeMap.containsKey(nodeId)?nodeMap.get(nodeId).getName():"删除前置");
}else {
if(temp.getTerminalDescribe().contains("前置信息")){
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;
}
}
} else {
//如果存在说明设备未被删除不存在说明有一条删除日志直接return
if (lineMap.containsKey(deviceId)) {

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