Compare commits
42 Commits
39cfffbf7e
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
749c1d954c | ||
| 6089be6b4a | |||
| eb89472670 | |||
| 56cd9a05c3 | |||
| aafd32c7fc | |||
| 79cec4e21b | |||
|
|
615fe78d61 | ||
|
|
5fff0890e8 | ||
|
|
f5e134b194 | ||
|
|
291a20649e | ||
|
|
7eef16599f | ||
| 11750a4f3a | |||
|
|
e6332f1c51 | ||
| 23d87aecc8 | |||
| eff784e94e | |||
|
|
eed647d3d1 | ||
|
|
4a5fde6a47 | ||
|
|
82ab1de5b9 | ||
|
|
ecc56dd2f6 | ||
| 39ae7412a8 | |||
| 52677f84dc | |||
| abdb855919 | |||
| 64bcbfff91 | |||
|
|
499eee6784 | ||
|
|
c58bd87a78 | ||
|
|
0902f92838 | ||
| 87818db6f3 | |||
|
|
850b3174a2 | ||
| aad5943d64 | |||
| 9c467310d5 | |||
| ca3b125424 | |||
|
|
0c5c9bf067 | ||
|
|
c692282ea4 | ||
| 232e84aad3 | |||
| 59f2588488 | |||
|
|
46f521c7a7 | ||
|
|
6d69027e16 | ||
|
|
1afed2c9a4 | ||
|
|
9bb250bdb9 | ||
|
|
d33b3637a5 | ||
|
|
f50f11b159 | ||
| 30984aa908 |
@@ -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();
|
||||
@@ -297,14 +295,11 @@ public class AnalyWave {
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,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);
|
||||
|
||||
@@ -223,6 +223,10 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
||||
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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class GenerateCode {
|
||||
|
||||
private static final String TARGET_DIR = "D://code";
|
||||
|
||||
private static final String DB_URL = "jdbc:mysql://192.168.1.24:13306/pqsinfo_ln";
|
||||
private static final String DB_URL = "jdbc:mysql://192.168.1.103:13306/pqsinfo_zl";
|
||||
// private static final String DB_URL = "jdbc:oracle:thin:@192.168.1.170:1521:pqsbase";
|
||||
|
||||
private static final String USERNAME = "root";
|
||||
@@ -30,8 +30,8 @@ public class GenerateCode {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Module> modules = Stream.of(
|
||||
new Module("cdf", "com.njcn.device", "", Stream.of(
|
||||
"pq_icd_path"
|
||||
new Module("xy", "com.njcn.csdevice", "", Stream.of(
|
||||
"cs_alarm_set"
|
||||
).collect(Collectors.toList()), "")
|
||||
).collect(Collectors.toList());
|
||||
generateJavaFile(modules);
|
||||
|
||||
@@ -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>
|
||||
<!-- <!–mqtt相关依赖–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.tocrhz</groupId>-->
|
||||
<!-- <artifactId>mqtt-spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package com.njcn.echarts.json;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.json.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.njcn.echarts.pojo.bo.TolerateData;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import org.icepear.echarts.Option;
|
||||
@@ -29,7 +25,6 @@ import org.icepear.echarts.render.Engine;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,6 +38,17 @@ import java.util.stream.Collectors;
|
||||
public class LineGenerator {
|
||||
|
||||
private final static Engine ENGINE = new Engine();
|
||||
// null段在图表上的固定视觉宽度(数据点数量)
|
||||
private static final int NULL_PLACEHOLDER_COUNT = 90;
|
||||
// 压缩结果
|
||||
private static class CompressedResult {
|
||||
// 压缩后的数据
|
||||
List<List<Float>> data;
|
||||
// 每个null段的[起始索引, 结束索引](占位点范围)
|
||||
List<int[]> nullRegionIndices;
|
||||
// null段边界处的真实x值(entry, exit交替)
|
||||
List<Float> nullBoundaryRealXValues;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
@@ -529,6 +535,478 @@ public class LineGenerator {
|
||||
return ENGINE.renderJsonOption(instantOption);
|
||||
}
|
||||
|
||||
public static String generateWaveOption(String title, List<List<Float>> aValue, List<List<Float>> bValue, List<List<Float>> cValue, String unit, Float max, Float min, String a, String b, String c, List<String> colors, Boolean isOpen, Double lastTime, List<Float> sharedNullBoundaryXValues, Integer nPush) {
|
||||
DecimalFormat df1 = new DecimalFormat("#.00");
|
||||
// 压缩null数据:如果有共享边界则用共享边界,否则独立压缩
|
||||
CompressedResult aCompressed;
|
||||
CompressedResult bCompressed;
|
||||
CompressedResult cCompressed;
|
||||
if (sharedNullBoundaryXValues != null && !sharedNullBoundaryXValues.isEmpty()) {
|
||||
aCompressed = compressNullDataWithSharedBoundaries(aValue, sharedNullBoundaryXValues);
|
||||
bCompressed = compressNullDataWithSharedBoundaries(bValue, sharedNullBoundaryXValues);
|
||||
cCompressed = compressNullDataWithSharedBoundaries(cValue, sharedNullBoundaryXValues);
|
||||
} else {
|
||||
aCompressed = compressNullData(aValue);
|
||||
bCompressed = compressNullData(bValue);
|
||||
cCompressed = compressNullData(cValue);
|
||||
}
|
||||
|
||||
Option instantOption = new Option();
|
||||
//取消渲染动画
|
||||
instantOption.setAnimation(false);
|
||||
//背景色
|
||||
instantOption.setBackgroundColor(PicCommonData.PIC_BACK_COLOR);
|
||||
//标题
|
||||
instantOption.setTitle(new Title()
|
||||
.setText(title)
|
||||
.setLeft(PicCommonData.CENTER)
|
||||
.setTextStyle(new Label().setFontSize(14))
|
||||
);
|
||||
//配置颜色
|
||||
instantOption.setColor(colors.toArray(new String[colors.size()]));
|
||||
//配置图例
|
||||
if (isOpen) {
|
||||
instantOption.setLegend(new Legend().setData(new String[]{a, b}).setLeft("10px"));
|
||||
} else {
|
||||
instantOption.setLegend(new Legend().setData(new String[]{a, b, c}).setLeft("10px"));
|
||||
}
|
||||
//上下左右的图内间距
|
||||
instantOption.setGrid(new Grid().setTop("60px").setLeft("70px").setRight("40px").setBottom("10%"));
|
||||
//横坐标(使用压缩后的数据)
|
||||
instantOption.setXAxis(new ValueAxis().setName("ms")
|
||||
.setSplitLine(new SplitLine().setShow(false))
|
||||
.setAxisLine(new AxisLine().setOnZero(false))
|
||||
.setType("category")
|
||||
.setMinInterval(1)
|
||||
);
|
||||
//纵坐标
|
||||
instantOption.setYAxis(new ValueAxis()
|
||||
.setName(unit)
|
||||
.setMax(df1.format(max * 1.1))
|
||||
.setMin(df1.format(min * 1.1))
|
||||
.setPosition(PicCommonData.LEFT)
|
||||
.setAxisLine(new AxisLine().setShow(false).setOnZero(false))
|
||||
);
|
||||
//数据信息(使用压缩后的数据)
|
||||
LineSeries aSeries = new LineSeries()
|
||||
.setName(a)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setConnectNulls(false)
|
||||
.setData(aCompressed.data);
|
||||
LineSeries bSeries = new LineSeries()
|
||||
.setName(b)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setConnectNulls(false)
|
||||
.setData(bCompressed.data);
|
||||
LineSeries cSeries = new LineSeries()
|
||||
.setName(c)
|
||||
.setSmooth(true)
|
||||
.setSymbol("none")
|
||||
.setConnectNulls(false)
|
||||
.setData(cCompressed.data);
|
||||
instantOption.setSeries(new LineSeries[]{aSeries, bSeries, cSeries});
|
||||
|
||||
// 渲染基础JSON
|
||||
String jsonStr = ENGINE.renderJsonOption(instantOption);
|
||||
cn.hutool.json.JSONObject optionJson = JSONUtil.parseObj(jsonStr);
|
||||
cn.hutool.json.JSONArray seriesArray = optionJson.getJSONArray("series");
|
||||
|
||||
// 隐藏x轴默认标签,设置boundaryGap=false,只通过markLine显示关键节点
|
||||
Object xAxisRaw = optionJson.get("xAxis");
|
||||
cn.hutool.json.JSONObject xAxisJson;
|
||||
if (xAxisRaw instanceof cn.hutool.json.JSONArray) {
|
||||
xAxisJson = ((cn.hutool.json.JSONArray) xAxisRaw).getJSONObject(0);
|
||||
} else {
|
||||
xAxisJson = (cn.hutool.json.JSONObject) xAxisRaw;
|
||||
}
|
||||
cn.hutool.json.JSONObject axisLabelJson = new cn.hutool.json.JSONObject();
|
||||
axisLabelJson.set("show", false);
|
||||
xAxisJson.set("axisLabel", axisLabelJson);
|
||||
xAxisJson.set("boundaryGap", false);
|
||||
|
||||
// 添加null markLine/markArea(基于压缩后的数据)
|
||||
addNullMarkLinesForCategoryAxis(seriesArray.getJSONObject(0), aCompressed, lastTime);
|
||||
addNullMarkLinesForCategoryAxis(seriesArray.getJSONObject(1), bCompressed, lastTime);
|
||||
addNullMarkLinesForCategoryAxis(seriesArray.getJSONObject(2), cCompressed, lastTime);
|
||||
// 在第一个series追加自定义横坐标标签markLine
|
||||
addAxisLabelMarkLines(seriesArray.getJSONObject(0), aCompressed, lastTime, nPush);
|
||||
return optionJson.toString();
|
||||
}
|
||||
|
||||
/** 提取null边界的真实x值,供其他数据集共享使用 */
|
||||
public static List<Float> extractNullBoundaryXValues(List<List<Float>> data) {
|
||||
List<Integer> boundaries = findNullSegmentBoundaryIndices(data);
|
||||
List<Float> xValues = new ArrayList<>();
|
||||
for (int idx : boundaries) {
|
||||
xValues.add(data.get(idx).get(0));
|
||||
}
|
||||
return xValues;
|
||||
}
|
||||
|
||||
/** 使用共享的null边界x值来压缩数据,确保不同数据集压缩结果结构一致 */
|
||||
private static CompressedResult compressNullDataWithSharedBoundaries(List<List<Float>> originalData, List<Float> sharedBoundaryXValues) {
|
||||
if (sharedBoundaryXValues == null || sharedBoundaryXValues.isEmpty()) {
|
||||
return compressNullData(originalData);
|
||||
}
|
||||
|
||||
// 用共享的x值找到本数据集中对应的索引
|
||||
List<Integer> boundaries = new ArrayList<>();
|
||||
for (Float x : sharedBoundaryXValues) {
|
||||
boundaries.add(findClosestValidIndex(originalData, x));
|
||||
}
|
||||
|
||||
CompressedResult result = new CompressedResult();
|
||||
result.data = new ArrayList<>();
|
||||
result.nullRegionIndices = new ArrayList<>();
|
||||
result.nullBoundaryRealXValues = new ArrayList<>(sharedBoundaryXValues);
|
||||
|
||||
int srcIdx = 0;
|
||||
for (int b = 0; b < boundaries.size(); b += 2) {
|
||||
int entryBoundary = boundaries.get(b);
|
||||
int exitBoundary = boundaries.get(b + 1);
|
||||
|
||||
while (srcIdx <= entryBoundary) {
|
||||
result.data.add(originalData.get(srcIdx));
|
||||
srcIdx++;
|
||||
}
|
||||
|
||||
int nullStartIdx = result.data.size();
|
||||
float entryX = sharedBoundaryXValues.get(b);
|
||||
float exitX = sharedBoundaryXValues.get(b + 1);
|
||||
|
||||
for (int p = 0; p < NULL_PLACEHOLDER_COUNT; p++) {
|
||||
List<Float> point = new ArrayList<>();
|
||||
point.add(entryX + (exitX - entryX) * p / NULL_PLACEHOLDER_COUNT);
|
||||
point.add(null);
|
||||
result.data.add(point);
|
||||
}
|
||||
|
||||
int nullEndIdx = result.data.size() - 1;
|
||||
result.nullRegionIndices.add(new int[]{nullStartIdx, nullEndIdx});
|
||||
|
||||
srcIdx = exitBoundary;
|
||||
}
|
||||
|
||||
while (srcIdx < originalData.size()) {
|
||||
result.data.add(originalData.get(srcIdx));
|
||||
srcIdx++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 压缩null数据:删除所有null数据点,替换为固定NULL_PLACEHOLDER_COUNT个占位点
|
||||
* 这样null段在图表上永远只占固定视觉宽度,前后有效数据正常展开
|
||||
*/
|
||||
private static CompressedResult compressNullData(List<List<Float>> originalData) {
|
||||
List<Integer> boundaries = findNullSegmentBoundaryIndices(originalData);
|
||||
|
||||
CompressedResult result = new CompressedResult();
|
||||
result.data = new ArrayList<>();
|
||||
result.nullRegionIndices = new ArrayList<>();
|
||||
result.nullBoundaryRealXValues = new ArrayList<>();
|
||||
|
||||
if (boundaries.isEmpty()) {
|
||||
result.data.addAll(originalData);
|
||||
return result;
|
||||
}
|
||||
|
||||
int srcIdx = 0;
|
||||
for (int b = 0; b < boundaries.size(); b += 2) {
|
||||
// 最后一个有效点的索引(null段入口边界)
|
||||
int entryBoundary = boundaries.get(b);
|
||||
// 第一个恢复有效点的索引(null段出口边界)
|
||||
int exitBoundary = boundaries.get(b + 1);
|
||||
|
||||
// 复制有效数据:从srcIdx到entryBoundary
|
||||
while (srcIdx <= entryBoundary) {
|
||||
result.data.add(originalData.get(srcIdx));
|
||||
srcIdx++;
|
||||
}
|
||||
|
||||
// 记录边界真实x值
|
||||
result.nullBoundaryRealXValues.add(originalData.get(entryBoundary).get(0));
|
||||
result.nullBoundaryRealXValues.add(originalData.get(exitBoundary).get(0));
|
||||
|
||||
// 插入固定数量的null占位点
|
||||
int nullStartIdx = result.data.size();
|
||||
float entryX = originalData.get(entryBoundary).get(0);
|
||||
float exitX = originalData.get(exitBoundary).get(0);
|
||||
|
||||
for (int p = 0; p < NULL_PLACEHOLDER_COUNT; p++) {
|
||||
List<Float> point = new ArrayList<>();
|
||||
point.add(entryX + (exitX - entryX) * p / NULL_PLACEHOLDER_COUNT);
|
||||
point.add(null);
|
||||
result.data.add(point);
|
||||
}
|
||||
|
||||
int nullEndIdx = result.data.size() - 1;
|
||||
result.nullRegionIndices.add(new int[]{nullStartIdx, nullEndIdx});
|
||||
|
||||
// 跳过原始null数据点,srcIdx跳到exitBoundary
|
||||
srcIdx = exitBoundary;
|
||||
}
|
||||
|
||||
// 复制最后一个null段之后的剩余有效数据
|
||||
while (srcIdx < originalData.size()) {
|
||||
result.data.add(originalData.get(srcIdx));
|
||||
srcIdx++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在压缩数据中查找最接近目标x值的有效数据点索引(跳过null点)
|
||||
*/
|
||||
private static int findClosestValidIndex(List<List<Float>> data, float targetX) {
|
||||
int closestIdx = -1;
|
||||
float minDiff = Float.MAX_VALUE;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Float y = data.get(i).get(1);
|
||||
if (y == null) continue;
|
||||
float diff = Math.abs(data.get(i).get(0) - targetX);
|
||||
if (diff < minDiff) {
|
||||
minDiff = diff;
|
||||
closestIdx = i;
|
||||
}
|
||||
}
|
||||
return closestIdx;
|
||||
}
|
||||
|
||||
private static void addAxisLabelMarkLines(cn.hutool.json.JSONObject seriesObj, CompressedResult compressed, Double lastTime, Integer nPush) {
|
||||
boolean hasNull = !compressed.nullRegionIndices.isEmpty();
|
||||
|
||||
// 收集需要标注的横坐标位置:[数据索引, 显示的时间值]
|
||||
List<int[]> labelPositions = new ArrayList<>();
|
||||
// 开头ms(始终显示)
|
||||
labelPositions.add(new int[]{findClosestValidIndex(compressed.data, -nPush), -nPush});
|
||||
// 0ms(始终显示)
|
||||
labelPositions.add(new int[]{findClosestValidIndex(compressed.data, 0f), 0});
|
||||
// npush ms(仅在有null时显示)
|
||||
if (hasNull) {
|
||||
labelPositions.add(new int[]{findClosestValidIndex(compressed.data, nPush), nPush});
|
||||
}
|
||||
// null段边界真实时间值(仅在有null时显示)
|
||||
if (hasNull) {
|
||||
for (Float realX : compressed.nullBoundaryRealXValues) {
|
||||
int idx = findClosestValidIndex(compressed.data, realX);
|
||||
if (idx >= 0) {
|
||||
labelPositions.add(new int[]{idx, (int) Math.round(realX)});
|
||||
}
|
||||
}
|
||||
}
|
||||
// lastTime(始终显示)
|
||||
if (lastTime != null) {
|
||||
labelPositions.add(new int[]{findClosestValidIndex(compressed.data, lastTime.floatValue()), lastTime.intValue()});
|
||||
}
|
||||
|
||||
// 最后一组数据(始终显示,数据结束位置横坐标)
|
||||
if (lastTime != null) {
|
||||
float lastTime20 = lastTime.floatValue() + nPush;
|
||||
int lastTime20Idx = findClosestValidIndex(compressed.data, lastTime20);
|
||||
if (lastTime20Idx >= 0) {
|
||||
labelPositions.add(new int[]{(lastTime20Idx-2), (int) Math.round(lastTime20)});
|
||||
}
|
||||
}
|
||||
|
||||
// 获取或创建markLine
|
||||
cn.hutool.json.JSONObject existingMarkLine = seriesObj.getJSONObject("markLine");
|
||||
cn.hutool.json.JSONArray markLineData;
|
||||
|
||||
if (existingMarkLine == null) {
|
||||
// 无null的情况:自己创建markLine,包含虚线和横坐标标签
|
||||
markLineData = new cn.hutool.json.JSONArray();
|
||||
|
||||
// x=0 虚线
|
||||
int zeroIdx = findClosestValidIndex(compressed.data, 0f);
|
||||
if (zeroIdx >= 0) {
|
||||
cn.hutool.json.JSONObject zeroLine = new cn.hutool.json.JSONObject();
|
||||
zeroLine.set("xAxis", zeroIdx);
|
||||
cn.hutool.json.JSONObject zeroLabel = new cn.hutool.json.JSONObject();
|
||||
zeroLabel.set("show", false);
|
||||
zeroLine.set("label", zeroLabel);
|
||||
markLineData.add(zeroLine);
|
||||
}
|
||||
// lastTime 虚线
|
||||
if (lastTime != null) {
|
||||
int lastTimeIdx = findClosestValidIndex(compressed.data, lastTime.floatValue());
|
||||
if (lastTimeIdx >= 0) {
|
||||
cn.hutool.json.JSONObject lastTimeLine = new cn.hutool.json.JSONObject();
|
||||
lastTimeLine.set("xAxis", lastTimeIdx);
|
||||
cn.hutool.json.JSONObject lastTimeLabelObj = new cn.hutool.json.JSONObject();
|
||||
lastTimeLabelObj.set("show", false);
|
||||
lastTimeLine.set("label", lastTimeLabelObj);
|
||||
markLineData.add(lastTimeLine);
|
||||
}
|
||||
}
|
||||
|
||||
// 先收集所有标签到markLineData
|
||||
for (int[] pos : labelPositions) {
|
||||
cn.hutool.json.JSONObject line = new cn.hutool.json.JSONObject();
|
||||
line.set("xAxis", pos[0]);
|
||||
cn.hutool.json.JSONObject lineLineStyle = new cn.hutool.json.JSONObject();
|
||||
lineLineStyle.set("width", 0);
|
||||
line.set("lineStyle", lineLineStyle);
|
||||
cn.hutool.json.JSONObject lineLabel = new cn.hutool.json.JSONObject();
|
||||
lineLabel.set("show", true);
|
||||
lineLabel.set("formatter", String.valueOf(pos[1]));
|
||||
lineLabel.set("position", "start");
|
||||
lineLabel.set("color", "#333");
|
||||
lineLabel.set("fontSize", 10);
|
||||
line.set("label", lineLabel);
|
||||
markLineData.add(line);
|
||||
}
|
||||
// 最后一次性设置到markLine和series
|
||||
existingMarkLine = new cn.hutool.json.JSONObject();
|
||||
existingMarkLine.set("symbol", new String[]{"none", "none"});
|
||||
cn.hutool.json.JSONObject lineStyle = new cn.hutool.json.JSONObject();
|
||||
lineStyle.set("type", "dashed");
|
||||
lineStyle.set("color", "#999");
|
||||
lineStyle.set("width", 1);
|
||||
existingMarkLine.set("lineStyle", lineStyle);
|
||||
cn.hutool.json.JSONObject globalLabel = new cn.hutool.json.JSONObject();
|
||||
globalLabel.set("show", false);
|
||||
existingMarkLine.set("label", globalLabel);
|
||||
existingMarkLine.set("data", markLineData);
|
||||
seriesObj.set("markLine", existingMarkLine);
|
||||
} else {
|
||||
// 有null的情况:追加标签到已有的markLine
|
||||
markLineData = existingMarkLine.getJSONArray("data");
|
||||
for (int[] pos : labelPositions) {
|
||||
cn.hutool.json.JSONObject line = new cn.hutool.json.JSONObject();
|
||||
line.set("xAxis", pos[0]);
|
||||
cn.hutool.json.JSONObject lineLineStyle = new cn.hutool.json.JSONObject();
|
||||
lineLineStyle.set("width", 0);
|
||||
line.set("lineStyle", lineLineStyle);
|
||||
cn.hutool.json.JSONObject lineLabel = new cn.hutool.json.JSONObject();
|
||||
lineLabel.set("show", true);
|
||||
lineLabel.set("formatter", String.valueOf(pos[1]));
|
||||
lineLabel.set("position", "start");
|
||||
lineLabel.set("color", "#333");
|
||||
lineLabel.set("fontSize", 10);
|
||||
line.set("label", lineLabel);
|
||||
markLineData.add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Integer> findNullSegmentBoundaryIndices(List<List<Float>> data) {
|
||||
List<Integer> indices = new ArrayList<>();
|
||||
boolean inNullSegment = false;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
Float y = data.get(i).get(1);
|
||||
if (y == null) {
|
||||
if (!inNullSegment) {
|
||||
indices.add(i > 0 ? i - 1 : i);
|
||||
inNullSegment = true;
|
||||
}
|
||||
} else {
|
||||
if (inNullSegment) {
|
||||
indices.add(i);
|
||||
inNullSegment = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inNullSegment) {
|
||||
indices.add(data.size() - 1);
|
||||
}
|
||||
return indices;
|
||||
}
|
||||
|
||||
private static void addNullMarkLinesForCategoryAxis(cn.hutool.json.JSONObject seriesObj, CompressedResult compressed, Double lastTime) {
|
||||
if (compressed.nullRegionIndices.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
cn.hutool.json.JSONArray markLineData = new cn.hutool.json.JSONArray();
|
||||
// x=0 虚线
|
||||
int zeroIdx = findClosestValidIndex(compressed.data, 0f);
|
||||
if (zeroIdx >= 0) {
|
||||
cn.hutool.json.JSONObject zeroLine = new cn.hutool.json.JSONObject();
|
||||
zeroLine.set("xAxis", zeroIdx);
|
||||
cn.hutool.json.JSONObject zeroLabel = new cn.hutool.json.JSONObject();
|
||||
zeroLabel.set("show", false);
|
||||
zeroLine.set("label", zeroLabel);
|
||||
markLineData.add(zeroLine);
|
||||
}
|
||||
// null段边界的垂直虚线
|
||||
for (int r = 0; r < compressed.nullRegionIndices.size(); r++) {
|
||||
int[] region = compressed.nullRegionIndices.get(r);
|
||||
int nullStartIdx = region[0]; // 第一个占位点索引
|
||||
int nullEndIdx = region[1]; // 最后一个占位点索引
|
||||
|
||||
// 入口虚线:nullStartIdx - 1(null前最后一个有效数据点)
|
||||
cn.hutool.json.JSONObject entryLine = new cn.hutool.json.JSONObject();
|
||||
entryLine.set("xAxis", nullStartIdx - 1);
|
||||
cn.hutool.json.JSONObject entryLabel = new cn.hutool.json.JSONObject();
|
||||
entryLabel.set("show", false);
|
||||
entryLine.set("label", entryLabel);
|
||||
markLineData.add(entryLine);
|
||||
|
||||
// 出口虚线:nullEndIdx(null后第一个有效数据点)
|
||||
cn.hutool.json.JSONObject exitLine = new cn.hutool.json.JSONObject();
|
||||
exitLine.set("xAxis", nullEndIdx);
|
||||
cn.hutool.json.JSONObject exitLabel = new cn.hutool.json.JSONObject();
|
||||
exitLabel.set("show", false);
|
||||
exitLine.set("label", exitLabel);
|
||||
markLineData.add(exitLine);
|
||||
}
|
||||
// 时间持续时间结束的数据点
|
||||
if (lastTime != null) {
|
||||
int lastTimeIdx = findClosestValidIndex(compressed.data, lastTime.floatValue());
|
||||
if (lastTimeIdx >= 0) {
|
||||
cn.hutool.json.JSONObject lastTimeLine = new cn.hutool.json.JSONObject();
|
||||
lastTimeLine.set("xAxis", lastTimeIdx);
|
||||
cn.hutool.json.JSONObject lastTimeLabel = new cn.hutool.json.JSONObject();
|
||||
lastTimeLabel.set("show", false);
|
||||
lastTimeLine.set("label", lastTimeLabel);
|
||||
markLineData.add(lastTimeLine);
|
||||
}
|
||||
}
|
||||
|
||||
cn.hutool.json.JSONObject markLine = new cn.hutool.json.JSONObject();
|
||||
markLine.set("symbol", new String[]{"none", "none"});
|
||||
cn.hutool.json.JSONObject lineStyle = new cn.hutool.json.JSONObject();
|
||||
lineStyle.set("type", "dashed");
|
||||
lineStyle.set("color", "#999");
|
||||
lineStyle.set("width", 1);
|
||||
markLine.set("lineStyle", lineStyle);
|
||||
cn.hutool.json.JSONObject globalLabel = new cn.hutool.json.JSONObject();
|
||||
globalLabel.set("show", false);
|
||||
markLine.set("label", globalLabel);
|
||||
markLine.set("data", markLineData);
|
||||
seriesObj.set("markLine", markLine);
|
||||
|
||||
// markArea - 灰色背景覆盖null区域(从入口边界到出口边界)
|
||||
cn.hutool.json.JSONArray markAreaData = new cn.hutool.json.JSONArray();
|
||||
for (int r = 0; r < compressed.nullRegionIndices.size(); r++) {
|
||||
int[] region = compressed.nullRegionIndices.get(r);
|
||||
int nullStartIdx = region[0];
|
||||
int nullEndIdx = region[1];
|
||||
|
||||
cn.hutool.json.JSONArray areaPair = new cn.hutool.json.JSONArray();
|
||||
cn.hutool.json.JSONObject start = new cn.hutool.json.JSONObject();
|
||||
start.set("xAxis", nullStartIdx - 1); // 从入口边界有效数据点
|
||||
cn.hutool.json.JSONObject end = new cn.hutool.json.JSONObject();
|
||||
end.set("xAxis", nullEndIdx); // 到出口边界有效数据点
|
||||
areaPair.add(start);
|
||||
areaPair.add(end);
|
||||
markAreaData.add(areaPair);
|
||||
}
|
||||
cn.hutool.json.JSONObject markArea = new cn.hutool.json.JSONObject();
|
||||
cn.hutool.json.JSONObject itemStyle = new cn.hutool.json.JSONObject();
|
||||
itemStyle.set("color", "rgba(180, 180, 180, 0.2)");
|
||||
itemStyle.set("borderWidth", 0);
|
||||
markArea.set("itemStyle", itemStyle);
|
||||
markArea.set("data", markAreaData);
|
||||
seriesObj.set("markArea", markArea);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param title 标题
|
||||
* @param values 数据值
|
||||
|
||||
@@ -10,9 +10,10 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -55,10 +56,9 @@ public class DrawPicUtil {
|
||||
return Objects.requireNonNull(picResult.getBody()).indexOf("image/png") > 0 ? picResult.getBody() : "";
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制波形图
|
||||
* @author hongawen
|
||||
* 绘制波形图
|
||||
* @date 2023/6/21 11:01
|
||||
* @return String base64数据
|
||||
*/
|
||||
@@ -77,6 +77,11 @@ public class DrawPicUtil {
|
||||
return drawPic(instantJson, width, height);
|
||||
}
|
||||
|
||||
public String drawWavePic(String title, List<List<Float>> aValue, List<List<Float>> bValue, List<List<Float>> cValue, String unit, Float max, Float min, String a, String b, String c, List<String> colors, Boolean isOpen, Double lastTime, List<Float> sharedNullBoundaryXValues,Integer nPush) {
|
||||
String instantJson = LineGenerator.generateWaveOption(title, aValue, bValue, cValue, unit, max, min, a, b, c, colors, isOpen, lastTime, sharedNullBoundaryXValues,nPush);
|
||||
return drawPic(instantJson, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制itic曲线图
|
||||
|
||||
@@ -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 默认是 false,16~31 点/周波段也应按普通抽点处理
|
||||
tmpRateDTO.bRMSFlag = false;
|
||||
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
|
||||
if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
||||
//YXB 2025-08-27
|
||||
@@ -547,12 +709,7 @@ public class WaveFileComponent {
|
||||
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());*/
|
||||
|
||||
nnInd++;
|
||||
// }
|
||||
}
|
||||
// 偏移量,采样间隔
|
||||
long nOffSet = 0, nWaveSpan;
|
||||
@@ -560,7 +717,6 @@ public class WaveFileComponent {
|
||||
float fValue, dfValue;
|
||||
// 计算不同块的采样率
|
||||
int nIndex = 0;
|
||||
// 将最低采样率替换到本段录波内
|
||||
// .CFG中采样率
|
||||
RateDTO tmpRateDTO;
|
||||
// nBlockNum 总循环次数
|
||||
@@ -575,46 +731,29 @@ public class WaveFileComponent {
|
||||
}
|
||||
}
|
||||
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||
//YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
||||
if (newLstRate.get(nIndex).bRMSFlag == true) {
|
||||
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
||||
// C# 原实现中 RMS 段与普通抽点是两条独立控制流,不能挂在同一个取模条件下
|
||||
if (Boolean.TRUE.equals(newLstRate.get(nIndex).bRMSFlag)) {
|
||||
//计算本段补点采样间隔
|
||||
nWaveSpan = newLstRate.get(nIndex).getNOneSample() / tmpRateDTO.getNOneSample();
|
||||
} else {
|
||||
// 计算本段抽点采样间隔
|
||||
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
}
|
||||
|
||||
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
||||
// 判断是否到了需要抽的采样点
|
||||
if (i % nWaveSpan == 0) {
|
||||
// 计算每个通道的值
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
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 ;// 开始补点的起点
|
||||
int segmentEndIndex = (int) (nOffSet + tmpRateDTO.getNSampleNum() - 1);
|
||||
for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
|
||||
for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
|
||||
//最多只有半波有效值,也就是每周波是1个或者2个点,然后去补最少16个点
|
||||
// 2 点/周波时,半周波位置需要切换到该周波的第二个原始采样点
|
||||
if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
|
||||
i++;
|
||||
}
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
tmpWaveData = new ArrayList<>();
|
||||
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();
|
||||
|
||||
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
|
||||
/*************************
|
||||
@@ -659,7 +798,7 @@ public class WaveFileComponent {
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
@@ -684,12 +823,25 @@ public class WaveFileComponent {
|
||||
//把每个单独的值赋予到整体里面去
|
||||
listWaveData.add(tmpWaveData);
|
||||
}
|
||||
// 把每个单独的值赋予到整体里面去
|
||||
// 本周波处理完成后,推进到下一周波的原始采样点
|
||||
if (iWaveTemp < (allWaveTemp - 1)) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 某些文件的段点数并不是原始每周波点数的整倍数。
|
||||
// RMS 段处理完成后,强制把原始游标对齐到当前段末尾,
|
||||
// 这样外层 for 的下一次自增才能稳定落到下一段起点,避免重复进入同一 RMS 段。
|
||||
i = segmentEndIndex;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 计算本段抽点采样间隔
|
||||
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||
// 判断是否到了需要抽的采样点
|
||||
if (i % nWaveSpan == 0) {
|
||||
// 计算每个通道的值
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
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")) {
|
||||
@@ -742,7 +894,7 @@ public class WaveFileComponent {
|
||||
{
|
||||
//根据cfg内的变比,将一次值转换成二次值
|
||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||
fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||
} else {
|
||||
fValue = fValue;
|
||||
}
|
||||
@@ -768,6 +920,204 @@ public class WaveFileComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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();
|
||||
// 判断是否到了需要抽的采样点
|
||||
if (i % nWaveSpan == 0) {
|
||||
// 计算每个通道的值
|
||||
//存储局部数据集合,包含了时间,A,B,C三相
|
||||
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();
|
||||
@@ -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);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.njcn.event.file.component;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.FileUtil;
|
||||
import com.njcn.echarts.json.LineGenerator;
|
||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||
import com.njcn.echarts.util.DrawPicUtil;
|
||||
import com.njcn.event.file.pojo.bo.WaveDataDetail;
|
||||
@@ -12,21 +11,17 @@ import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import sun.awt.image.BufferedImageGraphicsConfig;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -49,36 +44,39 @@ public class WavePicComponent {
|
||||
* @date 2023/9/21 15:32
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateInstantImageZl(List<WaveDataDetail> waveDataDetails) {
|
||||
public String generateInstantImageZl(Integer nPush, List<WaveDataDetail> waveDataDetails, Double lastTime) {
|
||||
String firstPic = null, secondPic = null, thirdPic = null, forthPic = null;
|
||||
WaveDataDetail waveDataDetail0 = waveDataDetails.get(0);
|
||||
// 从instantData提取null边界x值,作为共享参考(与Shun图保持一致)
|
||||
List<Float> sharedNullBoundaries = LineGenerator.extractNullBoundaryXValues(waveDataDetail0.getInstantData().getAValue());
|
||||
for (WaveDataDetail waveDataDetail : waveDataDetails) {
|
||||
if (waveDataDetail.getChannelName().toUpperCase().startsWith("SU")) {
|
||||
firstPic = drawPicUtil.drawWavePic("电压-电网侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("SI")) {
|
||||
thirdPic = drawPicUtil.drawWavePic("电流-电网侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("LU")) {
|
||||
secondPic = drawPicUtil.drawWavePic("电压-负载侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else {
|
||||
forthPic = drawPicUtil.drawWavePic("电流-负载侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -91,36 +89,39 @@ public class WavePicComponent {
|
||||
* @date 2023/9/21 15:32
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateRmsImageZl(List<WaveDataDetail> waveDataDetails) {
|
||||
public String generateRmsImageZl(Integer nPush, List<WaveDataDetail> waveDataDetails, Double lastTime) {
|
||||
String firstPic = null, secondPic = null, thirdPic = null, forthPic = null;
|
||||
WaveDataDetail waveDataDetail0 = waveDataDetails.get(0);
|
||||
// 从instantData提取null边界x值,作为共享参考(与Shun图保持一致)
|
||||
List<Float> sharedNullBoundaries = LineGenerator.extractNullBoundaryXValues(waveDataDetail0.getInstantData().getAValue());
|
||||
for (WaveDataDetail waveDataDetail : waveDataDetails) {
|
||||
if (waveDataDetail.getChannelName().toUpperCase().startsWith("SU")) {
|
||||
firstPic = drawPicUtil.drawWavePic("电压-电网侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("SI")) {
|
||||
thirdPic = drawPicUtil.drawWavePic("电流-电网侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("LU")) {
|
||||
secondPic = drawPicUtil.drawWavePic("电压-负载侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
} else {
|
||||
forthPic = drawPicUtil.drawWavePic("电流-负载侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(),lastTime,sharedNullBoundaries,nPush
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -209,6 +210,47 @@ public class WavePicComponent {
|
||||
return picPath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制瞬时波形图 App端用来绘制图片,会去掉部分数据,只保留开始数据 结束数据
|
||||
* @author xy
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateImageShun(Integer nPush, List<WaveDataDetail> waveDataDetails, Double lastTime) {
|
||||
String picPath = null;
|
||||
WaveDataDetail waveDataDetail = waveDataDetails.get(0);
|
||||
// 从instantData提取null边界x值,作为共享参考
|
||||
List<Float> sharedNullBoundaries = LineGenerator.extractNullBoundaryXValues(waveDataDetail.getInstantData().getAValue());
|
||||
|
||||
String firstPic = drawPicUtil.drawWavePic(getTitle(waveDataDetail.getChannelName()), waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(), lastTime, sharedNullBoundaries,nPush
|
||||
);
|
||||
String secondPic;
|
||||
if (waveDataDetails.size() == 1) {
|
||||
if (firstPic.contains(PicCommonData.PNG_PREFIX)) {
|
||||
firstPic = firstPic.replace(PicCommonData.PNG_PREFIX, "");
|
||||
}
|
||||
byte[] bytes = Base64.getDecoder().decode(firstPic);
|
||||
picPath = fileStorageUtil.uploadStream(new ByteArrayInputStream(bytes), OssPath.EVENT_WAVE_PIC, FileUtil.generateFileName("png"));
|
||||
} else if (waveDataDetails.size() == 2) {
|
||||
waveDataDetail = waveDataDetails.get(1);
|
||||
secondPic = drawPicUtil.drawWavePic(getTitle(waveDataDetail.getChannelName()), waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(), lastTime, sharedNullBoundaries,nPush
|
||||
);
|
||||
picPath = composeImage(firstPic, secondPic);
|
||||
}
|
||||
return picPath;
|
||||
}
|
||||
|
||||
public String getTitle(String channelName) {
|
||||
return channelName.toUpperCase().startsWith("U1") ? "电压" : "电流";
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制RMS波形图
|
||||
* @author hongawen
|
||||
@@ -248,6 +290,44 @@ public class WavePicComponent {
|
||||
return picPath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制RMS波形图 App端用来绘制图片,会去掉部分数据,只保留开始数据 结束数据
|
||||
* @author xy
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateImageRms(Integer nPush, List<WaveDataDetail> waveDataDetails, Double lastTime) {
|
||||
String picPath = null;
|
||||
WaveDataDetail waveDataDetail = waveDataDetails.get(0);
|
||||
|
||||
// 从instantData提取null边界x值,作为共享参考(与Shun图保持一致)
|
||||
List<Float> sharedNullBoundaries = LineGenerator.extractNullBoundaryXValues(waveDataDetail.getInstantData().getAValue());
|
||||
|
||||
String firstPic = drawPicUtil.drawWavePic(getTitle(waveDataDetail.getChannelName()), waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(), lastTime, sharedNullBoundaries,nPush
|
||||
);
|
||||
String secondPic;
|
||||
if (waveDataDetails.size() == 1) {
|
||||
if (firstPic.contains(PicCommonData.PNG_PREFIX)) {
|
||||
firstPic = firstPic.replace(PicCommonData.PNG_PREFIX, "");
|
||||
}
|
||||
byte[] bytes = Base64.getDecoder().decode(firstPic);
|
||||
picPath = fileStorageUtil.uploadStream(new ByteArrayInputStream(bytes), OssPath.EVENT_WAVE_PIC, FileUtil.generateFileName("png"));
|
||||
} else if (waveDataDetails.size() == 2) {
|
||||
waveDataDetail = waveDataDetails.get(1);
|
||||
secondPic = drawPicUtil.drawWavePic(getTitle(waveDataDetail.getChannelName()), waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen(), lastTime, sharedNullBoundaries,nPush
|
||||
);
|
||||
picPath = composeImage(firstPic, secondPic);
|
||||
}
|
||||
return picPath;
|
||||
}
|
||||
|
||||
/***
|
||||
* 合成图片
|
||||
* @author hongawen
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -80,6 +81,12 @@ public class WaveUtil {
|
||||
//根据相别来确认标题的名称
|
||||
for (int m = 0; m < iPhase; m++) {
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("A")) {
|
||||
if (Objects.isNull(sunData.get(j).get(iPhase * i + m + 1))) {
|
||||
sAValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpShunFirstA = sunData.get(j).get(iPhase * i + m + 1) * xishu;
|
||||
shunFirstA = tmpShunFirstA;
|
||||
sAValue.add(new ArrayList<Float>() {{
|
||||
@@ -87,7 +94,14 @@ public class WaveUtil {
|
||||
add(tmpShunFirstA);
|
||||
}});
|
||||
}
|
||||
}
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("B")) {
|
||||
if (Objects.isNull(sunData.get(j).get(iPhase * i + m + 1))) {
|
||||
sBValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpShunFirstB = sunData.get(j).get(iPhase * i + m + 1) * xishu;
|
||||
shunFirstB = tmpShunFirstB;
|
||||
sBValue.add(new ArrayList<Float>() {{
|
||||
@@ -95,7 +109,14 @@ public class WaveUtil {
|
||||
add(tmpShunFirstB);
|
||||
}});
|
||||
}
|
||||
}
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("C")) {
|
||||
if (Objects.isNull(sunData.get(j).get(iPhase * i + m + 1))) {
|
||||
sCValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpShunFirstC = sunData.get(j).get(iPhase * i + m + 1) * xishu;
|
||||
shunFirstC = tmpShunFirstC;
|
||||
sCValue.add(new ArrayList<Float>() {{
|
||||
@@ -104,6 +125,7 @@ public class WaveUtil {
|
||||
}});
|
||||
}
|
||||
}
|
||||
}
|
||||
sfMax = getMax(sfMax, shunFirstA, shunFirstB, shunFirstC);
|
||||
if (openTri) {
|
||||
sfMin = getMinOpen(sfMin, shunFirstA, shunFirstC);
|
||||
@@ -124,6 +146,12 @@ public class WaveUtil {
|
||||
//根据相别来确认标题的名称
|
||||
for (int m = 0; m < iPhase; m++) {
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("A")) {
|
||||
if (Objects.isNull(rmsData.get(k).get(iPhase * i + m + 1))) {
|
||||
rAValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpRmsFirstA = rmsData.get(k).get(iPhase * i + m + 1) * xishu;
|
||||
rmsFirstA = tmpRmsFirstA;
|
||||
rAValue.add(new ArrayList<Float>() {{
|
||||
@@ -131,7 +159,14 @@ public class WaveUtil {
|
||||
add(tmpRmsFirstA);
|
||||
}});
|
||||
}
|
||||
}
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("B")) {
|
||||
if (Objects.isNull(rmsData.get(k).get(iPhase * i + m + 1))) {
|
||||
rBValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpRmsFirstB = rmsData.get(k).get(iPhase * i + m + 1) * xishu;
|
||||
rmsFirstB = tmpRmsFirstB;
|
||||
rBValue.add(new ArrayList<Float>() {{
|
||||
@@ -139,7 +174,15 @@ public class WaveUtil {
|
||||
add(tmpRmsFirstB);
|
||||
}});
|
||||
}
|
||||
|
||||
}
|
||||
if (waveTitle.get(iPhase * i + m + 1).substring(1).contains("C")) {
|
||||
if (Objects.isNull(rmsData.get(k).get(iPhase * i + m + 1))) {
|
||||
rCValue.add(new ArrayList<Float>() {{
|
||||
add(x);
|
||||
add(null);
|
||||
}});
|
||||
} else {
|
||||
float tmpRmsFirstC = rmsData.get(k).get(iPhase * i + m + 1) * xishu;
|
||||
rmsFirstC = tmpRmsFirstC;
|
||||
rCValue.add(new ArrayList<Float>() {{
|
||||
@@ -148,6 +191,7 @@ public class WaveUtil {
|
||||
}});
|
||||
}
|
||||
}
|
||||
}
|
||||
rfMax = getMax(sfMax, rmsFirstA, rmsFirstB, rmsFirstC);
|
||||
if (openTri) {
|
||||
rfMin = getMinOpen(sfMin, rmsFirstA, rmsFirstC);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
// 生成下拉列表
|
||||
// 只对(x,x)单元格有效
|
||||
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);
|
||||
// // 生成下拉列表
|
||||
// // 只对(x,x)单元格有效
|
||||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -115,4 +115,8 @@ public interface AppRedisKey {
|
||||
* 补召文件
|
||||
*/
|
||||
String MAKE_UP_FILES = "makeUpFilesKey:";
|
||||
|
||||
String COMMON_REQUEST = "commonRequestKey:";
|
||||
|
||||
String COMMON_RESOPNSE = "commonResponseKey:";
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.njcn.web.utils;
|
||||
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.*;
|
||||
@@ -149,7 +152,8 @@ public class RestTemplateUtil {
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType) {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType);
|
||||
Object actualBody = convertHutoolJsonToStandard(requestBody);
|
||||
return restTemplate.postForEntity(url, actualBody, responseType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,7 +166,8 @@ public class RestTemplateUtil {
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType, Object... uriVariables) {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
|
||||
Object actualBody = convertHutoolJsonToStandard(requestBody);
|
||||
return restTemplate.postForEntity(url, actualBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +180,21 @@ public class RestTemplateUtil {
|
||||
* @return ResponseEntity 响应对象封装类
|
||||
*/
|
||||
public static <T> ResponseEntity<T> post(String url, Object requestBody, Class<T> responseType, Map<String, ?> uriVariables) {
|
||||
return restTemplate.postForEntity(url, requestBody, responseType, uriVariables);
|
||||
Object actualBody = convertHutoolJsonToStandard(requestBody);
|
||||
return restTemplate.postForEntity(url, actualBody, responseType, uriVariables);
|
||||
}
|
||||
|
||||
private static Object convertHutoolJsonToStandard(Object requestBody) {
|
||||
if (requestBody instanceof JSONObject || requestBody instanceof JSONArray) {
|
||||
try {
|
||||
com.fasterxml.jackson.databind.ObjectMapper objectMapper = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
return objectMapper.readValue(JSONUtil.toJsonStr(requestBody), Object.class);
|
||||
} catch (Exception e) {
|
||||
log.warn("Hutool JSON转标准结构失败,尝试直接使用字符串", e);
|
||||
return requestBody;
|
||||
}
|
||||
}
|
||||
return requestBody;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 = "电压等级")
|
||||
|
||||
@@ -25,6 +25,9 @@ public class MonitorCommLedgerInfoDTO implements Serializable {
|
||||
|
||||
private String busBarName;
|
||||
|
||||
private String objName;
|
||||
|
||||
|
||||
private String voltageLevel;
|
||||
|
||||
private String shortCapacity;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -105,6 +105,9 @@ public class LineDetailVO implements Serializable {
|
||||
@ApiModelProperty(name = "终端厂家")
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(name = "终端厂家")
|
||||
private String objId;
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -116,6 +116,9 @@ public class DeviceOnlineRate {
|
||||
@ApiModelProperty("监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty("监测对象")
|
||||
private String objName;
|
||||
|
||||
@ApiModelProperty("监测点运行状态")
|
||||
private String runFlag;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 中记录初始状态(可选)
|
||||
// 返回 DeferredResult,Spring 将挂起此请求
|
||||
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 中记录初始状态(可选)
|
||||
// 返回 DeferredResult,Spring 将挂起此请求
|
||||
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 中记录初始状态(可选)
|
||||
// 返回 DeferredResult,Spring 将挂起此请求
|
||||
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 中记录初始状态(可选)
|
||||
// 返回 DeferredResult,Spring 将挂起此请求
|
||||
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 中记录初始状态(可选)
|
||||
// 返回 DeferredResult,Spring 将挂起此请求
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,12 +19,12 @@ 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -139,7 +139,7 @@ public class RunManageServiceImpl implements RunManageService {
|
||||
List<String> devIndexes = generalDeviceDTOList.stream().flatMap(list -> list.getDeviceIndexes().stream()).collect(Collectors.toList());
|
||||
List<String> manuList = runManageParam.getManufacturer().stream().map(SimpleDTO::getId).collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(devIndexes)) {
|
||||
throw new BusinessException("当前部门没有装置台账");
|
||||
return new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam));
|
||||
}
|
||||
return deviceMapper.getRunManageDevList(new Page<>(PageFactory.getPageNum(runManageParam), PageFactory.getPageSize(runManageParam)),devIndexes, runManageParam.getComFlag(), runManageParam.getRunFlag(), manuList, runManageParam.getSearchValue());
|
||||
}
|
||||
|
||||
@@ -37,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;
|
||||
@@ -74,6 +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.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;
|
||||
@@ -140,6 +143,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
private final DeviceProcessService deviceProcessService;
|
||||
private final ProduceFeignClient produceFeignClient;
|
||||
private final UserLedgerService userLedgerService;
|
||||
private final PqDevTypeService pqDevTypeService;
|
||||
|
||||
@Value("${oracle.isSync}")
|
||||
private Boolean isSync;
|
||||
@@ -853,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);
|
||||
@@ -959,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();
|
||||
@@ -1725,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[]{}));
|
||||
@@ -1754,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
|
||||
@@ -2723,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<>();
|
||||
//任意集合数据为空,不处理
|
||||
@@ -2838,10 +2857,16 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
}
|
||||
//处理终端类型
|
||||
DictData devTypeDicData = dicDataFeignClient.getDicDataByName(terminalBaseExcel.getDevType()).getData();
|
||||
PqDevType one = new PqDevType();
|
||||
if (Objects.isNull(devTypeDicData)) {
|
||||
//上边逻辑不删兼容旧版本,新版本查询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();
|
||||
BeanUtils.copyProperties(terminalBaseExcel, device);
|
||||
@@ -2850,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());
|
||||
@@ -2859,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());
|
||||
@@ -2886,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;
|
||||
@@ -2963,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);
|
||||
@@ -3851,6 +3890,15 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
}
|
||||
//设备删除找不到设备名称,重日志截取
|
||||
if (Objects.equals(temp.getOperateType(), Param.DEL)) {
|
||||
//删除有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); // 设备名称
|
||||
@@ -3859,6 +3907,12 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
String nodeId = nodeNameMap.get(nodeName).getId();
|
||||
pqsTerminalPushLogDTO.setNodeId(nodeId);
|
||||
pqsTerminalPushLogDTO.setNodeName(nodeName);
|
||||
}else {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
//如果存在说明设备未被删除,不存在说明有一条删除日志,直接return;
|
||||
if (lineMap.containsKey(deviceId)) {
|
||||
|
||||
@@ -3,9 +3,6 @@ package com.njcn.device.device.controller;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
import com.github.tocrhz.mqtt.annotation.NamedValue;
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.dto.SimpleDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
@@ -27,12 +24,10 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -57,132 +52,132 @@ public class DeviceController extends BaseController {
|
||||
|
||||
private final GeneralDeviceService generalDeviceService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketLine")
|
||||
@ApiOperation("获取监测点定值信息")
|
||||
public HttpResult<String> socketLine(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
String methodDescribe = getMethodDescribe("socketLine");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentLine(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateSocketLine")
|
||||
@ApiOperation("修改监测点定值信息")
|
||||
public HttpResult<String> updateSocketLine(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
String methodDescribe = getMethodDescribe("updateSocketLine");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentLineData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDev")
|
||||
@ApiOperation("获取终端定值信息")
|
||||
public HttpResult<String> socketDev(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
String methodDescribe = getMethodDescribe("socketDev");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentDev(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateSocketDev")
|
||||
@ApiOperation("修改终端定值信息")
|
||||
public HttpResult<String> updateSocketDev(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
String methodDescribe = getMethodDescribe("updateSocketDev");
|
||||
if(StrUtil.isBlank(param.getIp())){
|
||||
param.setIp(RequestUtil.getRealIp());
|
||||
}
|
||||
String s = iDeviceService.sentDevData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDevProperty")
|
||||
@ApiOperation("获取终端性能信息")
|
||||
public HttpResult<String> socketDevProperty(String devID) {
|
||||
String methodDescribe = getMethodDescribe("socketDevProperty");
|
||||
String s = iDeviceService.socketDevProperty(devID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/socketDevPropertyClose")
|
||||
@ApiOperation("终端性能关闭")
|
||||
public HttpResult<String> socketDevPropertyClose(String devID) {
|
||||
String methodDescribe = getMethodDescribe("socketDevPropertyClose");
|
||||
String s = iDeviceService.socketDevPropertyClose(devID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/realTimeData")
|
||||
@ApiOperation("监测点实时数据查看")
|
||||
public HttpResult<String> realTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("realTimeData");
|
||||
String s = iDeviceService.realTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/heartRealTimeData")
|
||||
@ApiOperation("监测实施数据心跳")
|
||||
public HttpResult<String> heartRealTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("heartRealTimeData");
|
||||
String s = iDeviceService.heartRealTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/closeRealTimeData")
|
||||
@ApiOperation("监测点实施数据关闭")
|
||||
public HttpResult<String> closeRealTimeData(String lineID) {
|
||||
String methodDescribe = getMethodDescribe("closeRealTimeData");
|
||||
String s = iDeviceService.closeRealTimeData(lineID);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/getDevUpgrades")
|
||||
@ApiOperation("终端版本升级")
|
||||
public HttpResult<String> getDevUpgrades(@RequestBody @Validated ConstantValueParam.Upgrades param) {
|
||||
String methodDescribe = getMethodDescribe("getDevUpgrades");
|
||||
String s = iDeviceService.getDevUpgrades(param.getList(),param.getEdIndex());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/closeUpgrades")
|
||||
@ApiOperation("终端升级取消")
|
||||
public HttpResult<String> closeUpgrades(@RequestBody List<String> devList) {
|
||||
String methodDescribe = getMethodDescribe("closeUpgrades");
|
||||
String s = iDeviceService.closeUpgrades(devList);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/restartDev")
|
||||
@ApiOperation("重启装置命令")
|
||||
public HttpResult<String> restartDev(@RequestBody List<String> devList) {
|
||||
String methodDescribe = getMethodDescribe("restartDev");
|
||||
String s = iDeviceService.restartDev(devList);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
}
|
||||
@MqttSubscribe(value = "/zl/devData/{devID}",qos = 1)
|
||||
public void responseRtData(String topic, @NamedValue("devID") String pageId, MqttMessage message, @Payload String payload) {
|
||||
Console.log("receive from : {}", topic);
|
||||
Console.log("receive from : {}", pageId);
|
||||
Console.log("message : {}", message.getPayload());
|
||||
Console.log("message payload : {}", new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
Console.log("string payload : {}", payload);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketLine")
|
||||
// @ApiOperation("获取监测点定值信息")
|
||||
// public HttpResult<String> socketLine(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
// String methodDescribe = getMethodDescribe("socketLine");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentLine(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/updateSocketLine")
|
||||
// @ApiOperation("修改监测点定值信息")
|
||||
// public HttpResult<String> updateSocketLine(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
// String methodDescribe = getMethodDescribe("updateSocketLine");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentLineData(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDev")
|
||||
// @ApiOperation("获取终端定值信息")
|
||||
// public HttpResult<String> socketDev(@RequestBody @Validated ConstantValueParam.Constant param) {
|
||||
// String methodDescribe = getMethodDescribe("socketDev");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentDev(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/updateSocketDev")
|
||||
// @ApiOperation("修改终端定值信息")
|
||||
// public HttpResult<String> updateSocketDev(@RequestBody @Validated ConstantValueParam.ValueData param) {
|
||||
// String methodDescribe = getMethodDescribe("updateSocketDev");
|
||||
// if(StrUtil.isBlank(param.getIp())){
|
||||
// param.setIp(RequestUtil.getRealIp());
|
||||
// }
|
||||
// String s = iDeviceService.sentDevData(param);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDevProperty")
|
||||
// @ApiOperation("获取终端性能信息")
|
||||
// public HttpResult<String> socketDevProperty(String devID) {
|
||||
// String methodDescribe = getMethodDescribe("socketDevProperty");
|
||||
// String s = iDeviceService.socketDevProperty(devID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/socketDevPropertyClose")
|
||||
// @ApiOperation("终端性能关闭")
|
||||
// public HttpResult<String> socketDevPropertyClose(String devID) {
|
||||
// String methodDescribe = getMethodDescribe("socketDevPropertyClose");
|
||||
// String s = iDeviceService.socketDevPropertyClose(devID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/realTimeData")
|
||||
// @ApiOperation("监测点实时数据查看")
|
||||
// public HttpResult<String> realTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("realTimeData");
|
||||
// String s = iDeviceService.realTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/heartRealTimeData")
|
||||
// @ApiOperation("监测实施数据心跳")
|
||||
// public HttpResult<String> heartRealTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("heartRealTimeData");
|
||||
// String s = iDeviceService.heartRealTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/closeRealTimeData")
|
||||
// @ApiOperation("监测点实施数据关闭")
|
||||
// public HttpResult<String> closeRealTimeData(String lineID) {
|
||||
// String methodDescribe = getMethodDescribe("closeRealTimeData");
|
||||
// String s = iDeviceService.closeRealTimeData(lineID);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/getDevUpgrades")
|
||||
// @ApiOperation("终端版本升级")
|
||||
// public HttpResult<String> getDevUpgrades(@RequestBody @Validated ConstantValueParam.Upgrades param) {
|
||||
// String methodDescribe = getMethodDescribe("getDevUpgrades");
|
||||
// String s = iDeviceService.getDevUpgrades(param.getList(),param.getEdIndex());
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/closeUpgrades")
|
||||
// @ApiOperation("终端升级取消")
|
||||
// public HttpResult<String> closeUpgrades(@RequestBody List<String> devList) {
|
||||
// String methodDescribe = getMethodDescribe("closeUpgrades");
|
||||
// String s = iDeviceService.closeUpgrades(devList);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
//
|
||||
// @OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
// @PostMapping("/restartDev")
|
||||
// @ApiOperation("重启装置命令")
|
||||
// public HttpResult<String> restartDev(@RequestBody List<String> devList) {
|
||||
// String methodDescribe = getMethodDescribe("restartDev");
|
||||
// String s = iDeviceService.restartDev(devList);
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe);
|
||||
// }
|
||||
// @MqttSubscribe(value = "/zl/devData/{devID}",qos = 1)
|
||||
// public void responseRtData(String topic, @NamedValue("devID") String pageId, MqttMessage message, @Payload String payload) {
|
||||
// Console.log("receive from : {}", topic);
|
||||
// Console.log("receive from : {}", pageId);
|
||||
// Console.log("message : {}", message.getPayload());
|
||||
// Console.log("message payload : {}", new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||
// Console.log("string payload : {}", payload);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/updateDevCheckTime")
|
||||
|
||||
@@ -19,113 +19,113 @@ import java.util.List;
|
||||
public interface IDeviceService extends IService<Device> {
|
||||
|
||||
|
||||
/***
|
||||
* @Description: mqtt获取外部定值
|
||||
* @param param
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 10:17
|
||||
*/
|
||||
String sentLine(ConstantValueParam.Constant param);
|
||||
|
||||
/***
|
||||
* @Description: mqtt修改外部定值
|
||||
* @param param
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 11:07
|
||||
*/
|
||||
String sentLineData(ConstantValueParam.ValueData param);
|
||||
|
||||
/**
|
||||
* @param param
|
||||
* @Description: mqtt获取内部定值
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 14:51
|
||||
*/
|
||||
String sentDev(ConstantValueParam.Constant param);
|
||||
|
||||
/**
|
||||
* @param param
|
||||
* @Description: mqtt修改内部定值
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/14 14:51
|
||||
*/
|
||||
String sentDevData(ConstantValueParam.ValueData param);
|
||||
|
||||
/**
|
||||
* @param devID
|
||||
* @Description: 终端性能查看
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 11:27
|
||||
*/
|
||||
String socketDevProperty(String devID);
|
||||
|
||||
/**
|
||||
* @param devID
|
||||
* @Description: 终端性能关闭
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:13
|
||||
*/
|
||||
String socketDevPropertyClose(String devID);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测点实时数据查看
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:13
|
||||
*/
|
||||
String realTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测实施数据心跳
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:14
|
||||
*/
|
||||
String heartRealTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* @param lineIndex
|
||||
* @Description: 监测点实施数据关闭
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/15 16:14
|
||||
*/
|
||||
String closeRealTimeData(String lineIndex);
|
||||
|
||||
/**
|
||||
* 终端版本升级,批量升级条件必须是相同终端系列的终端才能升级
|
||||
*
|
||||
* @param list
|
||||
* @param edIndex
|
||||
* @return
|
||||
*/
|
||||
String getDevUpgrades(List<String> list, String edIndex);
|
||||
|
||||
/**
|
||||
* @param devList
|
||||
* @Description: 终端升级取消
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/17 9:24
|
||||
*/
|
||||
String closeUpgrades(List<String> devList);
|
||||
|
||||
/**
|
||||
* @param devList
|
||||
* @Description: 重启装置命令
|
||||
* @return: java.lang.String
|
||||
* @Author: wr
|
||||
* @Date: 2023/8/17 9:24
|
||||
*/
|
||||
String restartDev(List<String> devList);
|
||||
// /***
|
||||
// * @Description: mqtt获取外部定值
|
||||
// * @param param
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 10:17
|
||||
// */
|
||||
// String sentLine(ConstantValueParam.Constant param);
|
||||
//
|
||||
// /***
|
||||
// * @Description: mqtt修改外部定值
|
||||
// * @param param
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 11:07
|
||||
// */
|
||||
// String sentLineData(ConstantValueParam.ValueData param);
|
||||
//
|
||||
// /**
|
||||
// * @param param
|
||||
// * @Description: mqtt获取内部定值
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 14:51
|
||||
// */
|
||||
// String sentDev(ConstantValueParam.Constant param);
|
||||
//
|
||||
// /**
|
||||
// * @param param
|
||||
// * @Description: mqtt修改内部定值
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/14 14:51
|
||||
// */
|
||||
// String sentDevData(ConstantValueParam.ValueData param);
|
||||
//
|
||||
// /**
|
||||
// * @param devID
|
||||
// * @Description: 终端性能查看
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 11:27
|
||||
// */
|
||||
// String socketDevProperty(String devID);
|
||||
//
|
||||
// /**
|
||||
// * @param devID
|
||||
// * @Description: 终端性能关闭
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:13
|
||||
// */
|
||||
// String socketDevPropertyClose(String devID);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测点实时数据查看
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:13
|
||||
// */
|
||||
// String realTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测实施数据心跳
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:14
|
||||
// */
|
||||
// String heartRealTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param lineIndex
|
||||
// * @Description: 监测点实施数据关闭
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/15 16:14
|
||||
// */
|
||||
// String closeRealTimeData(String lineIndex);
|
||||
//
|
||||
// /**
|
||||
// * 终端版本升级,批量升级条件必须是相同终端系列的终端才能升级
|
||||
// *
|
||||
// * @param list
|
||||
// * @param edIndex
|
||||
// * @return
|
||||
// */
|
||||
// String getDevUpgrades(List<String> list, String edIndex);
|
||||
//
|
||||
// /**
|
||||
// * @param devList
|
||||
// * @Description: 终端升级取消
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/17 9:24
|
||||
// */
|
||||
// String closeUpgrades(List<String> devList);
|
||||
//
|
||||
// /**
|
||||
// * @param devList
|
||||
// * @Description: 重启装置命令
|
||||
// * @return: java.lang.String
|
||||
// * @Author: wr
|
||||
// * @Date: 2023/8/17 9:24
|
||||
// */
|
||||
// String restartDev(List<String> devList);
|
||||
|
||||
/**
|
||||
* @param devId 装置id
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.njcn.device.device.service.impl;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -14,16 +10,11 @@ import com.njcn.device.device.mapper.DeviceMapper;
|
||||
import com.njcn.device.device.service.IDeviceService;
|
||||
import com.njcn.device.device.service.ProgramVersionService;
|
||||
import com.njcn.device.line.mapper.LineMapper;
|
||||
import com.njcn.device.pq.pojo.advanced.*;
|
||||
import com.njcn.device.pq.pojo.param.ConstantValueParam;
|
||||
import com.njcn.device.pq.pojo.po.DevVersion;
|
||||
|
||||
import com.njcn.device.pq.pojo.po.Device;
|
||||
import com.njcn.device.pq.pojo.po.Line;
|
||||
import com.njcn.device.pq.pojo.po.Version;
|
||||
|
||||
import com.njcn.device.pq.pojo.vo.DevStatusNumVO;
|
||||
import com.njcn.device.pq.pojo.vo.DeviceIpRVO;
|
||||
import com.njcn.device.utils.SocketClient;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -45,360 +36,360 @@ import java.util.stream.Collectors;
|
||||
public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> implements IDeviceService {
|
||||
|
||||
private final LineMapper lineMapper;
|
||||
private final SocketClient socketClient;
|
||||
// private final SocketClient socketClient;
|
||||
private final DevVersionMapper devVersionMapper;
|
||||
private final ProgramVersionService programVersionService;
|
||||
|
||||
@Value("${socket.port:60000}")
|
||||
private Integer socketPort;
|
||||
|
||||
@Override
|
||||
public String sentLine(ConstantValueParam.Constant param) {
|
||||
try {
|
||||
//获取根据监测点获取终端信息
|
||||
UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
//拼接属性
|
||||
ContValueRVO upParamVO = new ContValueRVO();
|
||||
ContValueVO valueVO = new ContValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setLineid(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "获取定值失败";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentLineData(ConstantValueParam.ValueData param) {
|
||||
try {
|
||||
//获取根据监测点获取终端信息
|
||||
UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
ContUpdateValueRVO upParamVO = new ContUpdateValueRVO();
|
||||
ContUpdateValueVO valueVO = new ContUpdateValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setLineid(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
float[] intArr;
|
||||
if (StrUtil.isBlank(param.getInterValue())) {
|
||||
intArr = new float[0];
|
||||
} else {
|
||||
String[] valueArr = param.getInterValue().split(",");
|
||||
intArr = new float[valueArr.length];
|
||||
for (int i = 0; i < valueArr.length; i++) {
|
||||
intArr[i] = Float.parseFloat(valueArr[i]);
|
||||
}
|
||||
}
|
||||
valueVO.setValue(intArr);
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "运行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentDev(ConstantValueParam.Constant param) {
|
||||
try {
|
||||
Line line = lineMapper.selectById(param.getId());
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(line.getId());
|
||||
upDevVO.setDevName(line.getName());
|
||||
String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
ContValueRVO upParamVO = new ContValueRVO();
|
||||
ContValueVO valueVO = new ContValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setIndex(param.getId());
|
||||
valueVO.setHander(param.getHander());
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "获取定值失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sentDevData(ConstantValueParam.ValueData param) {
|
||||
try {
|
||||
Line line = lineMapper.selectById(param.getId());
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(line.getId());
|
||||
upDevVO.setDevName(line.getName());
|
||||
String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
ContUpdateDevValueRVO upParamVO = new ContUpdateDevValueRVO();
|
||||
ContUpdateDevValueVO valueVO = new ContUpdateDevValueVO();
|
||||
valueVO.setType(param.getType());
|
||||
valueVO.setIndex(line.getId());
|
||||
valueVO.setHander(String.valueOf(param.getHander()));
|
||||
int[] intArr;
|
||||
if (StrUtil.isBlank(param.getInterValue())) {
|
||||
intArr = new int[0];
|
||||
} else {
|
||||
String[] valueArr = param.getInterValue().split(",");
|
||||
intArr = new int[valueArr.length];
|
||||
for (int i = 0; i < valueArr.length; i++) {
|
||||
intArr[i] = Integer.parseInt(valueArr[i]);
|
||||
}
|
||||
}
|
||||
valueVO.setInterValue(intArr);
|
||||
JSONObject jsonStr = new JSONObject(valueVO);
|
||||
Integer len = jsonStr.toString().length();
|
||||
upParamVO.setLen(len.toString());
|
||||
upParamVO.setData(valueVO);
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
|
||||
List<UpDevVO> devList = new ArrayList<>();
|
||||
devList.add(upDevVO);
|
||||
return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
} catch (Exception e) {
|
||||
return "运行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String socketDevProperty(String devID) {
|
||||
String host = lineMapper.getNodeIp(devID,1);
|
||||
if(StrUtil.isBlank(host)){
|
||||
return "前置ip获取失败";
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("type","190");
|
||||
map.put("index",devID);
|
||||
map.put("hander","1");
|
||||
jsonObject.set("data", map);
|
||||
Integer len = jsonObject.get("data").toString().length();
|
||||
jsonObject.set("len", len.toString());
|
||||
socketClient.showProperty(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
return "终端性能获取成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String socketDevPropertyClose(String devID) {
|
||||
String host = lineMapper.getNodeIp(devID,1);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("type", "190");
|
||||
map.put("index", devID);
|
||||
map.put("hander", "0");
|
||||
jsonObject.set("data", map);
|
||||
Integer len = jsonObject.get("data").toString().length();
|
||||
jsonObject.set("len", len.toString());
|
||||
socketClient.closeDevSocket(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
return "执行成功";
|
||||
}catch (Exception e){
|
||||
return "执行失败";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String realTimeData(String lineIndex) {
|
||||
//查询前置ip
|
||||
String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
if(StrUtil.isBlank(host)){
|
||||
return "设备前置机服务器配置异常,请联系管理员";
|
||||
}else {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("LineId", lineIndex);
|
||||
jsonObject.set("type", 0);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len",0);
|
||||
jsonObject1.set("data",jsonObject);
|
||||
socketClient.realTimeData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
}
|
||||
return "请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String heartRealTimeData(String lineIndex) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("LineId", lineIndex);
|
||||
jsonObject.set("type", 1);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
socketClient.heartRealData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
return "实时数据心跳请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeRealTimeData(String lineIndex) {
|
||||
socketClient.closeRealData(lineIndex);
|
||||
return "关闭实时数据请求成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDevUpgrades(List<String> list, String edIndex) {
|
||||
List<DeviceIpRVO> resTemlist = new ArrayList<>();
|
||||
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(list);
|
||||
//判断设备版本号
|
||||
Integer isExit = devVersionMapper.selectCount(new LambdaQueryWrapper<DevVersion>()
|
||||
.eq(DevVersion::getVersionId,edIndex)
|
||||
.in(DevVersion::getLineId,list)
|
||||
.eq(DevVersion::getState,1)
|
||||
);
|
||||
if (isExit > 0) {
|
||||
return "请勿选择相同版本号升级";
|
||||
}
|
||||
if (!CollectionUtil.isEmpty(relist)) {
|
||||
Version version = programVersionService.getById(edIndex);
|
||||
String series = version.getDevType();
|
||||
//判断设备是否存在相同型号
|
||||
for (DeviceIpRVO deviceIpRVO : relist) {
|
||||
if (!series.equals(deviceIpRVO.getDevSeries())) {
|
||||
return "当前装置版本系列与目标版本系列不相同";
|
||||
}
|
||||
}
|
||||
|
||||
//判断是否断开
|
||||
if (relist.stream().filter(w -> w.getComFlag() == 0).findAny().isPresent()) {
|
||||
return "存在通讯中断设备";
|
||||
}
|
||||
|
||||
|
||||
Set<String> set = new HashSet<>();
|
||||
for (DeviceIpRVO d : relist) {
|
||||
set.add(d.getIp());
|
||||
}
|
||||
Iterator<String> iterator = set.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
List<UpDevVO> devIndex = new ArrayList<>();
|
||||
DeviceIpRVO deviceIpRVO = new DeviceIpRVO();
|
||||
String ip = iterator.next();
|
||||
for (DeviceIpRVO d : relist) {
|
||||
UpDevVO upDevVO = new UpDevVO();
|
||||
upDevVO.setDevIndex(d.getDevIndex());
|
||||
upDevVO.setDevName(d.getDevName());
|
||||
if (ip.equals(d.getIp())) {
|
||||
devIndex.add(upDevVO);
|
||||
}
|
||||
}
|
||||
deviceIpRVO.setIp(ip);
|
||||
deviceIpRVO.setDevlist(devIndex);
|
||||
resTemlist.add(deviceIpRVO);
|
||||
}
|
||||
} else {
|
||||
return "存在未知错误";
|
||||
}
|
||||
for (DeviceIpRVO deviceIpRVO : resTemlist) {
|
||||
String ip = deviceIpRVO.getIp();
|
||||
List<UpDevVO> devlist = deviceIpRVO.getDevlist();
|
||||
UpDataVO upDataVO = new UpDataVO();
|
||||
UpParamVO upParamVO = new UpParamVO();
|
||||
upDataVO.setTerminal(devlist);
|
||||
upDataVO.setType("180");
|
||||
upDataVO.setEdIndex(edIndex);
|
||||
upDataVO.setUserIndex(RequestUtil.getUserIndex());
|
||||
JSONObject jsonstr = new JSONObject(upDataVO);
|
||||
Integer len = jsonstr.toString().length();
|
||||
upParamVO.setData(upDataVO);
|
||||
upParamVO.setLen(len.toString());
|
||||
JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
String str = jsonObject.toString();
|
||||
socketClient.sentUpgrades(str, ip, socketPort, RequestUtil.getLoginName(), edIndex, devlist);
|
||||
}
|
||||
return "运行成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String closeUpgrades(List<String> devList) {
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
if(CollectionUtil.isEmpty(relist)){
|
||||
return "前置机为空";
|
||||
}else {
|
||||
List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
for(String ip: nodeIp){
|
||||
List<DeviceIpRVO> devLl= relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
if(CollectionUtil.isEmpty(devLl)){
|
||||
return "出错啦";
|
||||
}
|
||||
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
for(DeviceIpRVO devRVO:devLl){
|
||||
JSONObject dev = new JSONObject();
|
||||
dev.put("devIndex",devRVO.getDevIndex());
|
||||
dev.put("devName",devRVO.getDevName());
|
||||
list.add(dev);
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("terminal", list);
|
||||
jsonObject.set("type", 182);
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
socketClient.cancelUp(jsonObject1.toString(),ip,socketPort,devLl.size());
|
||||
}
|
||||
}
|
||||
return "取消命令发送成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String restartDev(List<String> devList) {
|
||||
List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
if(CollUtil.isEmpty(relist)){
|
||||
return "前置机为空";
|
||||
}else {
|
||||
List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
for(String ip: nodeIp){
|
||||
List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(devLl)){
|
||||
return "出错啦";
|
||||
}
|
||||
|
||||
List<JSONObject> list = new ArrayList<>();
|
||||
List<String> devIn = new ArrayList<>();
|
||||
for(DeviceIpRVO devRVO:devLl){
|
||||
devIn.add(devRVO.getDevIndex());
|
||||
JSONObject dev = new JSONObject();
|
||||
dev.set("devIndex", devRVO.getDevIndex());
|
||||
dev.set("devName", devRVO.getDevName());
|
||||
list.add(dev);
|
||||
}
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("terminal", list);
|
||||
jsonObject.set("type", 181);
|
||||
jsonObject.set("userIndex", RequestUtil.getUserIndex());
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.set("len", 0);
|
||||
jsonObject1.set("data", jsonObject);
|
||||
|
||||
socketClient.restartDev(jsonObject1.toString(),ip,socketPort,devIn);
|
||||
}
|
||||
}
|
||||
return "命令发送成功";
|
||||
}
|
||||
// @Override
|
||||
// public String sentLine(ConstantValueParam.Constant param) {
|
||||
// try {
|
||||
// //获取根据监测点获取终端信息
|
||||
// UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
// //拼接属性
|
||||
// ContValueRVO upParamVO = new ContValueRVO();
|
||||
// ContValueVO valueVO = new ContValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setLineid(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "获取定值失败";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentLineData(ConstantValueParam.ValueData param) {
|
||||
// try {
|
||||
// //获取根据监测点获取终端信息
|
||||
// UpDevVO upDevVO = lineMapper.getDevInfo(param.getId());
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(upDevVO.getDevIndex(),0);
|
||||
// ContUpdateValueRVO upParamVO = new ContUpdateValueRVO();
|
||||
// ContUpdateValueVO valueVO = new ContUpdateValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setLineid(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// float[] intArr;
|
||||
// if (StrUtil.isBlank(param.getInterValue())) {
|
||||
// intArr = new float[0];
|
||||
// } else {
|
||||
// String[] valueArr = param.getInterValue().split(",");
|
||||
// intArr = new float[valueArr.length];
|
||||
// for (int i = 0; i < valueArr.length; i++) {
|
||||
// intArr[i] = Float.parseFloat(valueArr[i]);
|
||||
// }
|
||||
// }
|
||||
// valueVO.setValue(intArr);
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentLine(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "运行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentDev(ConstantValueParam.Constant param) {
|
||||
// try {
|
||||
// Line line = lineMapper.selectById(param.getId());
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(line.getId());
|
||||
// upDevVO.setDevName(line.getName());
|
||||
// String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
// ContValueRVO upParamVO = new ContValueRVO();
|
||||
// ContValueVO valueVO = new ContValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setIndex(param.getId());
|
||||
// valueVO.setHander(param.getHander());
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "获取定值失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String sentDevData(ConstantValueParam.ValueData param) {
|
||||
// try {
|
||||
// Line line = lineMapper.selectById(param.getId());
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(line.getId());
|
||||
// upDevVO.setDevName(line.getName());
|
||||
// String host = lineMapper.getNodeIp(line.getId(),1);
|
||||
// ContUpdateDevValueRVO upParamVO = new ContUpdateDevValueRVO();
|
||||
// ContUpdateDevValueVO valueVO = new ContUpdateDevValueVO();
|
||||
// valueVO.setType(param.getType());
|
||||
// valueVO.setIndex(line.getId());
|
||||
// valueVO.setHander(String.valueOf(param.getHander()));
|
||||
// int[] intArr;
|
||||
// if (StrUtil.isBlank(param.getInterValue())) {
|
||||
// intArr = new int[0];
|
||||
// } else {
|
||||
// String[] valueArr = param.getInterValue().split(",");
|
||||
// intArr = new int[valueArr.length];
|
||||
// for (int i = 0; i < valueArr.length; i++) {
|
||||
// intArr[i] = Integer.parseInt(valueArr[i]);
|
||||
// }
|
||||
// }
|
||||
// valueVO.setInterValue(intArr);
|
||||
// JSONObject jsonStr = new JSONObject(valueVO);
|
||||
// Integer len = jsonStr.toString().length();
|
||||
// upParamVO.setLen(len.toString());
|
||||
// upParamVO.setData(valueVO);
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
//
|
||||
// List<UpDevVO> devList = new ArrayList<>();
|
||||
// devList.add(upDevVO);
|
||||
// return socketClient.sentDZDev(param.getIp(), str, host, socketPort, "wr", devList);
|
||||
// } catch (Exception e) {
|
||||
// return "运行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String socketDevProperty(String devID) {
|
||||
// String host = lineMapper.getNodeIp(devID,1);
|
||||
// if(StrUtil.isBlank(host)){
|
||||
// return "前置ip获取失败";
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// Map<String,String> map = new HashMap<>();
|
||||
// map.put("type","190");
|
||||
// map.put("index",devID);
|
||||
// map.put("hander","1");
|
||||
// jsonObject.set("data", map);
|
||||
// Integer len = jsonObject.get("data").toString().length();
|
||||
// jsonObject.set("len", len.toString());
|
||||
// socketClient.showProperty(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
// return "终端性能获取成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String socketDevPropertyClose(String devID) {
|
||||
// String host = lineMapper.getNodeIp(devID,1);
|
||||
// try {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// Map<String, String> map = new HashMap<>();
|
||||
// map.put("type", "190");
|
||||
// map.put("index", devID);
|
||||
// map.put("hander", "0");
|
||||
// jsonObject.set("data", map);
|
||||
// Integer len = jsonObject.get("data").toString().length();
|
||||
// jsonObject.set("len", len.toString());
|
||||
// socketClient.closeDevSocket(jsonObject.toString(),host,socketPort,RequestUtil.getLoginName());
|
||||
// return "执行成功";
|
||||
// }catch (Exception e){
|
||||
// return "执行失败";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String realTimeData(String lineIndex) {
|
||||
// //查询前置ip
|
||||
// String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
// if(StrUtil.isBlank(host)){
|
||||
// return "设备前置机服务器配置异常,请联系管理员";
|
||||
// }else {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("LineId", lineIndex);
|
||||
// jsonObject.set("type", 0);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len",0);
|
||||
// jsonObject1.set("data",jsonObject);
|
||||
// socketClient.realTimeData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
// }
|
||||
// return "请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String heartRealTimeData(String lineIndex) {
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("LineId", lineIndex);
|
||||
// jsonObject.set("type", 1);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
// String host = lineMapper.getNodeIp(lineIndex,0);
|
||||
// socketClient.heartRealData(jsonObject1.toString(),host,socketPort,lineIndex);
|
||||
// return "实时数据心跳请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String closeRealTimeData(String lineIndex) {
|
||||
// socketClient.closeRealData(lineIndex);
|
||||
// return "关闭实时数据请求成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String getDevUpgrades(List<String> list, String edIndex) {
|
||||
// List<DeviceIpRVO> resTemlist = new ArrayList<>();
|
||||
//
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(list);
|
||||
// //判断设备版本号
|
||||
// Integer isExit = devVersionMapper.selectCount(new LambdaQueryWrapper<DevVersion>()
|
||||
// .eq(DevVersion::getVersionId,edIndex)
|
||||
// .in(DevVersion::getLineId,list)
|
||||
// .eq(DevVersion::getState,1)
|
||||
// );
|
||||
// if (isExit > 0) {
|
||||
// return "请勿选择相同版本号升级";
|
||||
// }
|
||||
// if (!CollectionUtil.isEmpty(relist)) {
|
||||
// Version version = programVersionService.getById(edIndex);
|
||||
// String series = version.getDevType();
|
||||
// //判断设备是否存在相同型号
|
||||
// for (DeviceIpRVO deviceIpRVO : relist) {
|
||||
// if (!series.equals(deviceIpRVO.getDevSeries())) {
|
||||
// return "当前装置版本系列与目标版本系列不相同";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //判断是否断开
|
||||
// if (relist.stream().filter(w -> w.getComFlag() == 0).findAny().isPresent()) {
|
||||
// return "存在通讯中断设备";
|
||||
// }
|
||||
//
|
||||
//
|
||||
// Set<String> set = new HashSet<>();
|
||||
// for (DeviceIpRVO d : relist) {
|
||||
// set.add(d.getIp());
|
||||
// }
|
||||
// Iterator<String> iterator = set.iterator();
|
||||
// while (iterator.hasNext()) {
|
||||
// List<UpDevVO> devIndex = new ArrayList<>();
|
||||
// DeviceIpRVO deviceIpRVO = new DeviceIpRVO();
|
||||
// String ip = iterator.next();
|
||||
// for (DeviceIpRVO d : relist) {
|
||||
// UpDevVO upDevVO = new UpDevVO();
|
||||
// upDevVO.setDevIndex(d.getDevIndex());
|
||||
// upDevVO.setDevName(d.getDevName());
|
||||
// if (ip.equals(d.getIp())) {
|
||||
// devIndex.add(upDevVO);
|
||||
// }
|
||||
// }
|
||||
// deviceIpRVO.setIp(ip);
|
||||
// deviceIpRVO.setDevlist(devIndex);
|
||||
// resTemlist.add(deviceIpRVO);
|
||||
// }
|
||||
// } else {
|
||||
// return "存在未知错误";
|
||||
// }
|
||||
// for (DeviceIpRVO deviceIpRVO : resTemlist) {
|
||||
// String ip = deviceIpRVO.getIp();
|
||||
// List<UpDevVO> devlist = deviceIpRVO.getDevlist();
|
||||
// UpDataVO upDataVO = new UpDataVO();
|
||||
// UpParamVO upParamVO = new UpParamVO();
|
||||
// upDataVO.setTerminal(devlist);
|
||||
// upDataVO.setType("180");
|
||||
// upDataVO.setEdIndex(edIndex);
|
||||
// upDataVO.setUserIndex(RequestUtil.getUserIndex());
|
||||
// JSONObject jsonstr = new JSONObject(upDataVO);
|
||||
// Integer len = jsonstr.toString().length();
|
||||
// upParamVO.setData(upDataVO);
|
||||
// upParamVO.setLen(len.toString());
|
||||
// JSONObject jsonObject = new JSONObject(upParamVO);
|
||||
// String str = jsonObject.toString();
|
||||
// socketClient.sentUpgrades(str, ip, socketPort, RequestUtil.getLoginName(), edIndex, devlist);
|
||||
// }
|
||||
// return "运行成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String closeUpgrades(List<String> devList) {
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
// if(CollectionUtil.isEmpty(relist)){
|
||||
// return "前置机为空";
|
||||
// }else {
|
||||
// List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
// for(String ip: nodeIp){
|
||||
// List<DeviceIpRVO> devLl= relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
// if(CollectionUtil.isEmpty(devLl)){
|
||||
// return "出错啦";
|
||||
// }
|
||||
//
|
||||
// List<JSONObject> list = new ArrayList<>();
|
||||
// for(DeviceIpRVO devRVO:devLl){
|
||||
// JSONObject dev = new JSONObject();
|
||||
// dev.put("devIndex",devRVO.getDevIndex());
|
||||
// dev.put("devName",devRVO.getDevName());
|
||||
// list.add(dev);
|
||||
// }
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("terminal", list);
|
||||
// jsonObject.set("type", 182);
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
// socketClient.cancelUp(jsonObject1.toString(),ip,socketPort,devLl.size());
|
||||
// }
|
||||
// }
|
||||
// return "取消命令发送成功";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String restartDev(List<String> devList) {
|
||||
// List<DeviceIpRVO> relist = lineMapper.getDevicesIp(devList);
|
||||
// if(CollUtil.isEmpty(relist)){
|
||||
// return "前置机为空";
|
||||
// }else {
|
||||
// List<String> nodeIp = relist.stream().map(DeviceIpRVO::getIp).distinct().collect(Collectors.toList());
|
||||
// for(String ip: nodeIp){
|
||||
// List<DeviceIpRVO> devLl = relist.stream().filter(item->item.getIp().equals(ip)).collect(Collectors.toList());
|
||||
// if(CollUtil.isEmpty(devLl)){
|
||||
// return "出错啦";
|
||||
// }
|
||||
//
|
||||
// List<JSONObject> list = new ArrayList<>();
|
||||
// List<String> devIn = new ArrayList<>();
|
||||
// for(DeviceIpRVO devRVO:devLl){
|
||||
// devIn.add(devRVO.getDevIndex());
|
||||
// JSONObject dev = new JSONObject();
|
||||
// dev.set("devIndex", devRVO.getDevIndex());
|
||||
// dev.set("devName", devRVO.getDevName());
|
||||
// list.add(dev);
|
||||
// }
|
||||
//
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// jsonObject.set("terminal", list);
|
||||
// jsonObject.set("type", 181);
|
||||
// jsonObject.set("userIndex", RequestUtil.getUserIndex());
|
||||
// JSONObject jsonObject1 = new JSONObject();
|
||||
// jsonObject1.set("len", 0);
|
||||
// jsonObject1.set("data", jsonObject);
|
||||
//
|
||||
// socketClient.restartDev(jsonObject1.toString(),ip,socketPort,devIn);
|
||||
// }
|
||||
// }
|
||||
// return "命令发送成功";
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateDevCheckTime(String devId, String thisTimeCheck, String nextTimeCheck) {
|
||||
|
||||
@@ -88,7 +88,9 @@
|
||||
voltage.name busBarname,
|
||||
pq_voltage.scale voltageLevel,
|
||||
bd.name bdName,
|
||||
gd.name gdName
|
||||
gd.name gdName,
|
||||
supervision_user_report.project_name objName
|
||||
|
||||
from pq_dept_line pq_dept_line
|
||||
inner join pq_line point on pq_dept_line.line_id = point.id
|
||||
inner join pq_line_detail lineDetail on point.id = lineDetail.id
|
||||
@@ -98,6 +100,7 @@
|
||||
inner join pq_device device on dev.id = device.id
|
||||
inner join pq_line bd on dev.pid = bd.id
|
||||
inner join pq_line gd on bd.pid = gd.id
|
||||
left join supervision_user_report on lineDetail.Obj_Id = supervision_user_report.id
|
||||
where device.Dev_Model = 1
|
||||
and point.state = 1
|
||||
and device.Dev_Data_Type in
|
||||
|
||||
@@ -1559,7 +1559,8 @@
|
||||
vg.Scale as voltageLevel,
|
||||
voltage.name as volName,
|
||||
lineDetail.Power_Flag powerFlag,
|
||||
lineDetail.Run_Flag lineRunType
|
||||
lineDetail.Run_Flag lineRunType,
|
||||
lineDetail.Obj_Id objId
|
||||
FROM
|
||||
pq_line voltage,
|
||||
pq_line device,
|
||||
|
||||
@@ -45,6 +45,7 @@ import com.njcn.influx.imapper.PqsCommunicateMapper;
|
||||
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.supervision.pojo.vo.user.NewUserReportVO;
|
||||
import com.njcn.supervision.pojo.vo.user.UserReportVO;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
@@ -616,6 +617,11 @@ public class LineServiceImpl extends ServiceImpl<LineMapper, Line> implements Li
|
||||
lineLineDTO.setLinename(lineName);
|
||||
lineLineDTO.setNum(lineDetail.getNum());
|
||||
lineLineDTO.setObjName(lineDetail.getObjName());
|
||||
lineLineDTO.setObjId(lineDetail.getObjId());
|
||||
if(StringUtils.isNotEmpty(lineDetail.getObjId())){
|
||||
UserReportVO userReportVO = userLedgerService.getUserReportById(lineDetail.getObjId());
|
||||
lineLineDTO.setObjName2(userReportVO.getProjectName());
|
||||
}
|
||||
lineLineDTO.setLoadType(dicDataFeignClient.getDicDataById(lineDetail.getLoadType()).getData().getName());
|
||||
//电压使用母线电压
|
||||
lineLineDTO.setVoltageLevel(dicDataFeignClient.getDicDataById(voltage.getScale()).getData().getName());
|
||||
|
||||
@@ -13,10 +13,12 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.common.mapper.SuperDataMapper;
|
||||
import com.njcn.device.common.service.GeneralDeviceService;
|
||||
import com.njcn.device.device.mapper.DevFuctionMapper;
|
||||
import com.njcn.device.device.service.DeviceProcessService;
|
||||
import com.njcn.device.device.service.IDevMealService;
|
||||
import com.njcn.device.device.service.IDevStrategyService;
|
||||
import com.njcn.device.device.service.IDeviceService;
|
||||
import com.njcn.device.line.service.LineService;
|
||||
import com.njcn.device.pq.constant.Param;
|
||||
import com.njcn.device.pq.enums.LineBaseEnum;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.param.*;
|
||||
@@ -84,6 +86,7 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
||||
|
||||
private final CldStatisticsFlowMapper cldStatisticsFlowMapper;
|
||||
private final LineService lineService;
|
||||
private final DeviceProcessService deviceProcessService;
|
||||
|
||||
@Override
|
||||
public List<TerminalMaintainVO> getTerminalMainList(TerminalMainQueryParam terminalMainQueryParam) {
|
||||
@@ -184,14 +187,14 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
||||
if (device.getRunFlag() == 0) {
|
||||
newFlag = "投运";
|
||||
} else if (device.getRunFlag() == 1) {
|
||||
newFlag = "热备用";
|
||||
newFlag = "检修";
|
||||
} else if (device.getRunFlag() == 2) {
|
||||
newFlag = "停运";
|
||||
}
|
||||
if (device1.getRunFlag() == 0) {
|
||||
oldFlag = "投运";
|
||||
} else if (device1.getRunFlag() == 1) {
|
||||
oldFlag = "热备用";
|
||||
oldFlag = "检修";
|
||||
} else if (device1.getRunFlag() == 2) {
|
||||
oldFlag = "停运";
|
||||
}
|
||||
@@ -205,7 +208,19 @@ public class TerminalMaintainServiceImpl implements TerminalMaintainService {
|
||||
terminalLogsNew.setObjIndex(device.getId());
|
||||
terminalLogsNew.setTerminalDescribe(sb.toString());
|
||||
terminalLogsNew.setIsPush(0);
|
||||
terminalLogsNew.setOperateType("update");
|
||||
if(device.getRunFlag() == 0&&device1.getRunFlag()!=0){
|
||||
terminalLogsNew.setOperateType(Param.DEL);
|
||||
|
||||
}
|
||||
if(device1.getRunFlag() == 0&&device.getRunFlag()!=0){
|
||||
terminalLogsNew.setOperateType(Param.ADD);
|
||||
//判断device是否绑定进程号;
|
||||
DeviceProcess deviceProcess = new DeviceProcess();
|
||||
deviceProcess.setId(device1.getId());
|
||||
deviceProcess.setProcessNo(1);
|
||||
|
||||
deviceProcessService.saveOrUpdate(deviceProcess);
|
||||
}
|
||||
terminalLogsNew.setLogsType(data.getId());
|
||||
terminalLogsNew.setTerminalType(LineBaseEnum.DEVICE_LEVEL.getCode());
|
||||
terminalLogsNew.setState(DataStateEnum.ENABLE.getCode());
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,8 @@
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -56,6 +56,12 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--mqtt相关依赖-->
|
||||
<dependency>
|
||||
<groupId>com.github.tocrhz</groupId>
|
||||
<artifactId>mqtt-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
|
||||
@@ -143,7 +143,7 @@ public class AreaInfoServiceImpl implements AreaInfoService {
|
||||
)
|
||||
.ge(StringUtils.isNotBlank(deviceInfoParam.getSearchBeginTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(deviceInfoParam.getSearchBeginTime())))
|
||||
.le(StringUtils.isNotBlank(deviceInfoParam.getSearchEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(deviceInfoParam.getSearchEndTime())))
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime));
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime).last("limit 100"));
|
||||
EventDetailNew eventDetailNew;
|
||||
for (RmpEventDetailPO eventDetail : eventDetails) {
|
||||
eventDetailNew = BeanUtil.copyProperties(eventDetail, EventDetailNew.class);
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
<version>2.7.12</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -20,6 +20,13 @@ public interface CommMonitorEventReportService {
|
||||
|
||||
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 暂降事件报告
|
||||
* @param exportParam
|
||||
* @param lineDetailDataCommDTO
|
||||
* @param response
|
||||
*/
|
||||
void getWlLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 暂态事件报告
|
||||
@@ -32,5 +39,5 @@ public interface CommMonitorEventReportService {
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map);
|
||||
String saveStableEventReport(List<String> index, Map<String, AreaLineInfoVO> map, String fileName);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.event.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.param.EventBaseParam;
|
||||
import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -79,8 +79,6 @@ public interface EventAnalysisService {
|
||||
*/
|
||||
Page<WaveTypeVO> getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*监测点事件波形下载
|
||||
* @author zbj
|
||||
@@ -88,6 +86,20 @@ public interface EventAnalysisService {
|
||||
*/
|
||||
//HttpServletResponse downloadMonitorEventWaveFile(WaveFileParam waveFileParam, HttpServletResponse response) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 判定压降落点区域
|
||||
* <p>
|
||||
* 入参:
|
||||
* eventValue 特征幅值(百分比形式,如 "80.5" 表示 80.5%),内部 /100 得到 VVm(0~1)
|
||||
* persistTime 持续时间(秒)
|
||||
* <p>
|
||||
* 优先规则:
|
||||
* 1) 持续时间 < 0.001 秒 或 VVm = 0 → A区
|
||||
* 2) 按区间表逐行匹配(左闭右开 [下限, 上限))
|
||||
* 3) 都不匹配返回 null,由调用方走兜底
|
||||
*
|
||||
* @return 区域名(A区/B区/C区/D区);解析失败或未匹配返回 null
|
||||
*/
|
||||
String determineDropZone(String eventValue, String persistTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -479,6 +479,389 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getWlLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailData, HttpServletResponse response) {
|
||||
//创建word文档(poi生成word)
|
||||
XWPFDocument doc = new XWPFDocument(); //创建Word文件
|
||||
//设置标题样式
|
||||
WordUtils.setHeadingStyle(doc);
|
||||
XWPFParagraph p = doc.createParagraph(); //新建一个段落
|
||||
//设置对齐
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
p.setVerticalAlignment(TextAlignment.CENTER);
|
||||
XWPFRun r = p.createRun();//创建段落文本
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.addBreak();
|
||||
r.setText("");
|
||||
r.setBold(true);//设置为粗体
|
||||
r.setFontSize(14);//字体大小
|
||||
r.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r1 = p.createRun();//创建段落文本
|
||||
r1.setText("电压暂降事件分析报告");
|
||||
r1.setBold(true);//设置为粗体
|
||||
r1.setFontSize(36);//字体大小
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
r1.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r2 = p.createRun();//创建段落文本
|
||||
//获取当前时间
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy 年 MM 月 dd 日");
|
||||
String time = dateFormat.format(date);
|
||||
|
||||
r2.setText("日期: " + time);
|
||||
r2.setBold(true);//设置为粗体
|
||||
r2.setFontSize(14);//字体大小
|
||||
|
||||
r2.addBreak();
|
||||
r2.addBreak();
|
||||
r2.addBreak();
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun r3 = p.createRun();//创建段落文本
|
||||
r3.setText("电压暂降事件区域报告");
|
||||
r3.setFontSize(24);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "1. 引言", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r5 = p.createRun();//创建段落文本
|
||||
r5.setText("对所选中区间内电压暂降事件进行分析,能够直观清晰查看响应的暂降事件信息。");
|
||||
r5.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "2. 报告分析对象", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r7 = p.createRun();//创建段落文本
|
||||
r7.setText(exportParam.getLineName());
|
||||
r7.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "3. 报告分析时间", "标题 1", 0, 15);
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.BOTH);
|
||||
XWPFRun r9 = p.createRun();//创建段落文本
|
||||
r9.setText(exportParam.getSearchBeginTime() + " 至 " + exportParam.getSearchEndTime());
|
||||
r9.setFontSize(11);//字体大小
|
||||
|
||||
p = doc.createParagraph(); //新建一个段落
|
||||
p.setAlignment(ParagraphAlignment.LEFT);
|
||||
createTitle(doc, "4. 总汇信息", "标题 1", 0, 15);
|
||||
|
||||
//查询参数
|
||||
StatisticsParam param = new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(), exportParam.getFlag());
|
||||
//获取暂降原因字典
|
||||
List<DictData> reasonData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_REASON.getName()).getData();
|
||||
//获取暂降类型字典
|
||||
List<DictData> typeData = dicDataFeignClient.getDicDataByTypeName(DicDataTypeEnum.EVENT_TYPE.getName()).getData();
|
||||
//influxdb查询结果(pqs_eventdetail表)
|
||||
List<EventDetail> info = info(param, true);
|
||||
|
||||
//记录数
|
||||
int i = 1;
|
||||
//1.监测点信息
|
||||
if (exportParam.isXq()) {
|
||||
createTitle(doc, "4." + i + " 监测点信息", "标题 2", 200, 15);
|
||||
XWPFTable table = createTable(doc);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
insertRow(doc, table, centerParagraph, true, "项目", "描述");
|
||||
insertRow(doc, table, centerParagraph, false, "监测点名称", lineDetailData.getLineName());
|
||||
insertRow(doc, table, centerParagraph, false, "电压等级", lineDetailData.getScale());
|
||||
insertRow(doc, table, centerParagraph, false, "PT变比", lineDetailData.getPt());
|
||||
insertRow(doc, table, centerParagraph, false, "CT变比", lineDetailData.getCt());
|
||||
insertRow(doc, table, centerParagraph, false, "协议容量", lineDetailData.getDealCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "设备容量", lineDetailData.getDevCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "最小短路容量", lineDetailData.getShortCapacity() + "");
|
||||
insertRow(doc, table, centerParagraph, false, "接线方式", lineDetailData.getPtType());
|
||||
if (exportParam.getType() == 0) {
|
||||
insertRow(doc, table, centerParagraph, false, "基准容量", lineDetailData.getStandardCapacity() + "");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//2.暂降事件暂降事件列表和暂降点图
|
||||
//2.1.判断列表和点图是否是要导出
|
||||
if (exportParam.isLb() || exportParam.isSjdF47() || exportParam.isSjdITIC()) {
|
||||
List<EventDetail> plot = eventReportService.getPlot(info, reasonData, typeData);
|
||||
//暂降事件列表
|
||||
if (exportParam.isLb()) {
|
||||
createTitle(doc, "4." + i + " 暂降事件列表", "标题 2", 200, 15);
|
||||
XWPFTable table = createTable(doc);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
insertRow(doc, table, centerParagraph, true, "序号", "暂降发生时刻", "暂降幅值(%)", "持续时间(s)", "暂降类型", "暂降原因", "严重度");
|
||||
for (int j = 0; j < plot.size(); j++) {
|
||||
EventDetail eventDetail = plot.get(j);
|
||||
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
|
||||
insertRow(doc, table, centerParagraph, false, j + 1 + "", s, BigDecimal.valueOf(eventDetail.getFeatureAmplitude() * 100).setScale(2, RoundingMode.HALF_UP).toString(), eventDetail.getDuration() + "", Objects.isNull(eventDetail.getAdvanceType()) ? "/" : eventDetail.getAdvanceType(), Objects.isNull(eventDetail.getAdvanceReason()) ? "/" : eventDetail.getAdvanceReason(), Objects.isNull(eventDetail.getSeverity()) ? "/" : eventDetail.getSeverity() + "");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//暂降事件点图
|
||||
if (exportParam.isSjdF47() || exportParam.isSjdITIC()) {
|
||||
ArrayList<List<Double>> ass = getAss(plot);
|
||||
createTitle(doc, "4." + i + " 暂降事件点图", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
if (exportParam.isSjdITIC()) {
|
||||
createTitle(doc, "4." + i + "." + two + " ITIC 曲线", "标题 3", 400, 15);
|
||||
String itic = drawPicUtil.drawItic(ass);
|
||||
createPic(doc, itic, "ITIC曲线");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isSjdF47()) {
|
||||
createTitle(doc, "4." + i + "." + two + " F47 曲线", "标题 3", 400, 15);
|
||||
String f47 = drawPicUtil.drawF47(ass);
|
||||
createPic(doc, f47, "SEMI F47曲线");
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//3.暂降密度
|
||||
if (exportParam.isMdbg() || exportParam.isMdtx()) {
|
||||
createTitle(doc, "4." + i + " 暂降密度", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
if (exportParam.isMdtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 暂降密度点图", "标题 3", 400, 15);
|
||||
Integer[][] eventDensityData = eventReportService.getCoords(info);
|
||||
String str = drawPicUtil.drawEventDensity(eventDensityData);
|
||||
createPic(doc, str, "暂降密度图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isMdbg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " DISDIP 表格:国际发配电联盟(UNIPEDE)", "标题 3", 400, 15);
|
||||
// List<DISDIPVO> eventDisdip = eventAnalysisService.eventDisdip(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<DISDIPVO> eventDisdip = eventReportService.eventDisdip(info);
|
||||
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "剩余电压", "20ms", "100ms", "500ms", "1s", "3s", "20s", "60s", "180s");
|
||||
for (int j = 0; j < eventDisdip.size(); j++) {
|
||||
DISDIPVO disdipvo = eventDisdip.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, disdipvo.getName(), disdipvo.getTwentyMs(), disdipvo.getOneHundredMs(), disdipvo.getFiveHundredMs(), disdipvo.getOneS(), disdipvo.getThreeS(), disdipvo.getTwentyS(), disdipvo.getSixtyS(), disdipvo.getOneEightyS());
|
||||
}
|
||||
two++;
|
||||
createTitle(doc, "4." + i + "." + two + " IEC 61000-4-11:(用电终端的电压暂降抗度)", "标题 3", 400, 15);
|
||||
// List<IEC411VO> iec411VOS = eventAnalysisService.IEC411(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<IEC411VO> iec411VOS = eventReportService.IEC411(info);
|
||||
XWPFTable table2 = createTable(doc);
|
||||
insertRow(doc, table2, centerParagraph, true, "剩余电压", "10~20ms", "20~100ms", "0.1~0.2s", "0.2~0.5s", "0.5~1s", ">1s");
|
||||
for (int j = 0; j < iec411VOS.size(); j++) {
|
||||
IEC411VO iec411VO = iec411VOS.get(j);
|
||||
insertRow(doc, table2, centerParagraph, false, iec411VO.getName(), iec411VO.getTenTwentyMs(), iec411VO.getTwentyOneHundredMs(), iec411VO.getZeroPiontOneTwoS(), iec411VO.getZeroPiontTwoFiveS(), iec411VO.getZeroPiontFive1S(), iec411VO.getGreater1S());
|
||||
}
|
||||
two++;
|
||||
createTitle(doc, "4." + i + "." + two + " IEC 61000-2-8:(公共电网电压暂降测量统计)", "标题 3", 400, 15);
|
||||
// List<IEC28VO> iec28VOS = eventAnalysisService.IEC28(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
List<IEC28VO> iec28VOS = eventReportService.IEC28(info);
|
||||
XWPFTable table3 = createTable(doc);
|
||||
insertRow(doc, table3, centerParagraph, true, "剩余电压", "0.02~0.1s", "0.1~0.25s", "0.25~0.5s", "0.5s~1s", "1~3s", "3~20s", "20~60s", "60~180s");
|
||||
for (int j = 0; j < iec28VOS.size(); j++) {
|
||||
IEC28VO iec28VO = iec28VOS.get(j);
|
||||
insertRow(doc, table3, centerParagraph, false, iec28VO.getName(), iec28VO.getQ(), iec28VO.getW(), iec28VO.getE(), iec28VO.getR(), iec28VO.getT(), iec28VO.getY(), iec28VO.getU(), iec28VO.getI());
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//4.暂降幅值概率分布
|
||||
if (exportParam.isGlfbfz() || exportParam.isGlfbsj()) {
|
||||
createTitle(doc, "4." + i + " 暂降幅值概率分布图", "标题 2", 200, 15);
|
||||
// ProbabilityVO probabilityVO = eventAnalysisService.getProbabilityDistribution(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
ProbabilityVO probabilityVO = eventReportService.getProbabilityDistribution(info);
|
||||
int two = 1;
|
||||
if (exportParam.isGlfbfz()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 暂降幅值的概率分函数", "标题 3", 400, 15);
|
||||
List<String> ybardata = probabilityVO.getPereventvalue();
|
||||
List<String> ylinedata = probabilityVO.getEventvalue();
|
||||
String fz = drawPicUtil.drawEventAmplitude(ylinedata, ybardata);
|
||||
createPic(doc, fz, "暂降幅值的概率分布函数");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isGlfbsj()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 持续时间的概率分函数", "标题 3", 400, 15);
|
||||
List<String> ybardata = probabilityVO.getPersisttime();
|
||||
List<String> ylinedata = probabilityVO.getSisttime();
|
||||
String sj = drawPicUtil.drawPersistentTime(ylinedata, ybardata);
|
||||
createPic(doc, sj, "持续时间的概率分布函数");
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//5.月份统计
|
||||
if (exportParam.isTjbg() || exportParam.isTjtx()) {
|
||||
createTitle(doc, "4." + i + " 月份统计", "标题 2", 200, 15);
|
||||
int two = 1;
|
||||
List<TimeVO> reasonTypeTime = eventAnalysisService.getReasonTypeTime(param);
|
||||
//暂时时间端按月查询不能查询
|
||||
// List<TimeVO> reasonTypeTime = eventReportService.getReasonTypeTime(param,null);
|
||||
if (exportParam.isTjtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 月份统计图", "标题 3", 400, 15);
|
||||
List<Integer> count = new ArrayList<>();
|
||||
List<String> name = new ArrayList<>();
|
||||
if (exportParam.getFlag() == 0) {
|
||||
for (TimeVO timeVO : reasonTypeTime) {
|
||||
name.add(timeVO.getMonth() + "");
|
||||
count.add(Integer.parseInt(timeVO.getTimes()));
|
||||
}
|
||||
} else {
|
||||
for (TimeVO timeVO : reasonTypeTime) {
|
||||
name.add(timeVO.getDay() + "");
|
||||
count.add(Integer.parseInt(timeVO.getTimes()));
|
||||
}
|
||||
}
|
||||
String yftj = drawPicUtil.drawMonth(name, count, reasonTypeTime.get(0).getYear(), exportParam.getFlag());
|
||||
createPic(doc, yftj, "月份统计图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isTjbg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " 时间统计表格", "标题 3", 400, 15);
|
||||
|
||||
XWPFTable table1 = createTable(doc);
|
||||
if (exportParam.getFlag() == 0) {
|
||||
insertRow(doc, table1, centerParagraph, true, "时间(月)", "电压暂降次数");
|
||||
} else {
|
||||
insertRow(doc, table1, centerParagraph, true, "时间(天)", "电压暂降次数");
|
||||
}
|
||||
if (exportParam.getFlag() == 0) {
|
||||
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
||||
TimeVO timeVO = reasonTypeTime.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, timeVO.getMonth(), timeVO.getTimes());
|
||||
}
|
||||
} else {
|
||||
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
||||
TimeVO timeVO = reasonTypeTime.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, timeVO.getFulltime(), timeVO.getTimes());
|
||||
}
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
//6.原因统计
|
||||
//6.1整合提出查询语句
|
||||
Boolean fly = exportParam.isYybg() || exportParam.isYytx() || exportParam.isLxbg() || exportParam.isLxtx();
|
||||
if (fly) {
|
||||
List<DictData> tempDictType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
List<String> typeIds = tempDictType.stream().filter(x -> DicDataEnum.VOLTAGE_DIP.getCode().equals(x.getCode()) || DicDataEnum.SHORT_INTERRUPTIONS.getCode().equals(x.getCode()))
|
||||
.map(DictData::getId).collect(Collectors.toList());
|
||||
List<EventDetail> tempInfo = info.stream().filter(temp -> typeIds.contains(temp.getEventType())).collect(Collectors.toList());
|
||||
StatisticVO statistic = eventReportService.getStatistic(tempInfo, reasonData, typeData);
|
||||
if (exportParam.isYybg() || exportParam.isYytx()) {
|
||||
createTitle(doc, "4." + i + " 原因统计", "标题 2", 200, 15);
|
||||
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
int two = 1;
|
||||
if (exportParam.isYytx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 原因统计图", "标题 3", 400, 15);
|
||||
List<String> xdata = new ArrayList<>();
|
||||
List<Map<String, Object>> reasonList = new ArrayList<>();
|
||||
|
||||
List<ReasonsVO> reason = statistic.getReason();
|
||||
for (ReasonsVO reasonsVO : reason) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("value", reasonsVO.getTimes());
|
||||
map.put("name", reasonsVO.getReason());
|
||||
reasonList.add(map);
|
||||
xdata.add(reasonsVO.getReason());
|
||||
}
|
||||
String tr = drawPicUtil.drawReason(xdata, reasonList);
|
||||
createPic(doc, tr, "暂降原因图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isYybg()) {
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
createTitle(doc, "4." + i + "." + two + " 原因统计表格", "标题 3", 400, 15);
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
|
||||
List<ReasonsVO> reason = statistic.getReason();
|
||||
for (int j = 0; j < reason.size(); j++) {
|
||||
ReasonsVO reasonsVO = reason.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, reasonsVO.getReason(), reasonsVO.getTimes() + "");
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//7.类型统计
|
||||
if (exportParam.isLxbg() || exportParam.isLxtx()) {
|
||||
createTitle(doc, "4." + i + " 类型统计", "标题 2", 200, 15);
|
||||
// StatisticVO statistic = eventAnalysisService.getStatistic(new StatisticsParam(exportParam.getLineId(), exportParam.getSearchBeginTime(), exportParam.getSearchEndTime(),exportParam.getFlag()));
|
||||
int two = 1;
|
||||
if (exportParam.isLxtx()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 类型统计图", "标题 3", 400, 15);
|
||||
List<String> xdata = new ArrayList<>();
|
||||
List<TypesVO> types = statistic.getTypes();
|
||||
|
||||
List<Map<String, Object>> reasonList = new ArrayList<>();
|
||||
for (TypesVO type : types) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("value", type.getTimes());
|
||||
map.put("name", type.getType());
|
||||
reasonList.add(map);
|
||||
xdata.add(type.getType());
|
||||
}
|
||||
String tr = drawPicUtil.drawType(xdata, reasonList);
|
||||
createPic(doc, tr, "暂降类型图");
|
||||
two++;
|
||||
}
|
||||
if (exportParam.isLxbg()) {
|
||||
createTitle(doc, "4." + i + "." + two + " 类型统计表格", "标题 3", 400, 15);
|
||||
XWPFParagraph centerParagraph = WordUtils.getCenterParagraph(doc);
|
||||
XWPFTable table1 = createTable(doc);
|
||||
insertRow(doc, table1, centerParagraph, true, "暂降原因", "电压暂降次数");
|
||||
List<TypesVO> types = statistic.getTypes();
|
||||
for (int j = 0; j < types.size(); j++) {
|
||||
TypesVO typesVO = types.get(j);
|
||||
insertRow(doc, table1, centerParagraph, false, typesVO.getType(), typesVO.getTimes() + "");
|
||||
}
|
||||
two++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
String fileName = URLEncoder.encode(exportParam.getLineName() + ".docx", "UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
doc.write(outputStream);
|
||||
outputStream.close();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "导出监测点暂降报告异常");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建标题
|
||||
@@ -598,6 +981,23 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
return BeanUtil.copyToList(info, EventDetail.class);
|
||||
}
|
||||
|
||||
private List<EventDetail> info(StatisticsParam statisticsParam, Boolean dip) {
|
||||
// 构建查询条件
|
||||
LambdaQueryWrapper<RmpEventDetailPO> queryWrapper = new LambdaQueryWrapper<RmpEventDetailPO>()
|
||||
.eq(RmpEventDetailPO::getMeasurementPointId, statisticsParam.getLineIndex())
|
||||
.ge(StrUtil.isNotBlank(statisticsParam.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(statisticsParam.getStartTime())))
|
||||
.le(StrUtil.isNotBlank(statisticsParam.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(statisticsParam.getEndTime())))
|
||||
.orderByDesc(RmpEventDetailPO::getStartTime);
|
||||
if (dip) {
|
||||
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
List<String> typeList = data.stream().filter(it->it.getCode().equals(DicDataEnum.VOLTAGE_DIP.getCode()) || it.getCode().equals(DicDataEnum.SHORT_INTERRUPTIONS.getCode())).map(DictData::getId).collect(Collectors.toList()); List<TimeVO> list = new ArrayList<>();
|
||||
queryWrapper.in(RmpEventDetailPO::getEventType, typeList);
|
||||
}
|
||||
// 数据暂降查询
|
||||
List<RmpEventDetailPO> info = rmpEventDetailMapper.selectList(queryWrapper);
|
||||
return BeanUtil.copyToList(info, EventDetail.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成暂降事件报告
|
||||
@@ -658,7 +1058,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map) {
|
||||
public String saveStableEventReport(List<String> eventIndex, Map<String, AreaLineInfoVO> map, String fileName) {
|
||||
WordUtil wordUtil = new WordUtil();
|
||||
for (String index : eventIndex) {
|
||||
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
||||
@@ -709,7 +1109,12 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
||||
}
|
||||
try {
|
||||
InputStream inputStream = wordUtil.createReport2(eventIndex);
|
||||
String filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, "暂降事件报告.docx");
|
||||
String filePath;
|
||||
if (Objects.isNull(fileName)) {
|
||||
filePath = fileStorageUtil.uploadStream(inputStream, OssPath.APP_EVENT_REPORT, null);
|
||||
} else {
|
||||
filePath = fileStorageUtil.uploadStreamSpecifyName(inputStream, OssPath.APP_EVENT_REPORT, fileName);
|
||||
}
|
||||
return filePath;
|
||||
} catch (IOException | InvalidFormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
||||
@@ -4,7 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
@@ -13,6 +12,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.common.service.EventDetailService;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||
@@ -21,19 +21,20 @@ import com.njcn.event.pojo.param.StatisticsParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.ParseException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
@@ -51,6 +52,7 @@ import java.util.zip.ZipOutputStream;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
|
||||
// 定义阈值常量(单位:百分比)
|
||||
@@ -1727,6 +1729,75 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String determineDropZone(String eventValue, String persistTime) {
|
||||
if (eventValue == null || eventValue.trim().isEmpty()
|
||||
|| persistTime == null || persistTime.trim().isEmpty()) {
|
||||
log.warn("判定压降落点区域入参为空,eventValue={}, persistTime={}", eventValue, persistTime);
|
||||
return null;
|
||||
}
|
||||
BigDecimal vvm;
|
||||
BigDecimal vvtm;
|
||||
try {
|
||||
// params[3] 是百分比(如 "80.5"),/100 得到 0~1 的 VVm
|
||||
vvm = new BigDecimal(eventValue.trim()).divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP);
|
||||
vvtm = new BigDecimal(persistTime.trim());
|
||||
} catch (Exception e) {
|
||||
log.error("判定压降落点区域入参解析失败,eventValue={}, persistTime={}", eventValue, persistTime, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 1) 超短脉冲 或 完全失压 默认 A 区
|
||||
if (vvtm.compareTo(new BigDecimal("0.001")) < 0
|
||||
|| vvm.compareTo(BigDecimal.ZERO) == 0) {
|
||||
return "A区";
|
||||
}
|
||||
|
||||
// 2) 区间表(左闭右开)
|
||||
// A区
|
||||
if (inRange(vvm, "0.9", "1") && inRange(vvtm, "0.001", "60")) {
|
||||
return "A区";
|
||||
}
|
||||
if (inRange(vvm, "0", "0.9") && inRange(vvtm, "0.001", "0.05")) {
|
||||
return "A区";
|
||||
}
|
||||
// B区
|
||||
if (inRange(vvm, "0.5", "0.7") && inRange(vvtm, "0.05", "0.2")) {
|
||||
return "B区";
|
||||
}
|
||||
if (inRange(vvm, "0.7", "0.8") && inRange(vvtm, "0.05", "0.5")) {
|
||||
return "B区";
|
||||
}
|
||||
if (inRange(vvm, "0.8", "0.9") && inRange(vvtm, "0.05", "60")) {
|
||||
return "B区";
|
||||
}
|
||||
// C区
|
||||
if (inRange(vvm, "0", "0.5") && inRange(vvtm, "0.05", "1")) {
|
||||
return "C区";
|
||||
}
|
||||
if (inRange(vvm, "0.5", "0.7") && inRange(vvtm, "0.2", "1")) {
|
||||
return "C区";
|
||||
}
|
||||
if (inRange(vvm, "0.7", "0.8") && inRange(vvtm, "0.5", "1")) {
|
||||
return "C区";
|
||||
}
|
||||
// D区
|
||||
if (inRange(vvm, "0", "0.8") && inRange(vvtm, "1", "60")) {
|
||||
return "D区";
|
||||
}
|
||||
|
||||
log.warn("压降落点区域未匹配任何规则,eventValue={}, persistTime={}", eventValue, persistTime);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 左闭右开区间判断:lowerInclusive ≤ value < upperExclusive
|
||||
*/
|
||||
private boolean inRange(BigDecimal value, String lowerInclusive, String upperExclusive) {
|
||||
return value.compareTo(new BigDecimal(lowerInclusive)) >= 0
|
||||
&& value.compareTo(new BigDecimal(upperExclusive)) < 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 监测点事件波形下载
|
||||
|
||||
@@ -7,7 +7,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
//import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
@@ -18,6 +18,7 @@ import com.njcn.device.pq.pojo.po.DeptLine;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||
import com.njcn.event.common.websocket.WebSocketServer;
|
||||
import com.njcn.event.pojo.vo.SendEventVO;
|
||||
import com.njcn.event.utils.EventUtil;
|
||||
import com.njcn.event.pojo.dto.EventDeatilDTO;
|
||||
@@ -29,7 +30,9 @@ import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
@@ -44,6 +47,7 @@ import java.math.RoundingMode;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
@@ -57,11 +61,14 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final MqttPublisher publisher;
|
||||
// private final MqttPublisher publisher;
|
||||
|
||||
private final WebSocketServer webSocketServer;
|
||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
private final LineFeignClient lineFeignClient;
|
||||
private final DeptLineFeignClient deptLineFeignClient;
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
@Override
|
||||
@@ -168,6 +175,7 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
//如果不为空,说明是二次上传波形文件了;
|
||||
String reason,type;
|
||||
if(!StringUtils.isEmpty(rmpEventDetailPO.getWavePath())){
|
||||
try {
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(rmpEventDetailPO.getLineId()).getData();
|
||||
String ip = lineDetailData.getIp();
|
||||
EventAnalysisDTO eventAnalysisDTO = new EventAnalysisDTO();
|
||||
@@ -198,7 +206,9 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
}
|
||||
rmpEventDetailPO.setAdvanceReason(advancereason.getId());
|
||||
rmpEventDetailPO.setAdvanceType(advanceType.getId());
|
||||
|
||||
}catch (Exception e){
|
||||
rmpEventDetailPO.setDealFlag(0);
|
||||
}
|
||||
}
|
||||
//默认都是其他
|
||||
// DictData reason = dicDataFeignClient.getDicDataByCode(DicDataEnum.RESON_REST.getCode()).getData();
|
||||
@@ -306,6 +316,9 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
String[] idsArray = deptInfo.getPids().split(",");
|
||||
dept.addAll(Arrays.asList(idsArray));
|
||||
});
|
||||
List<String> deptList = dept.stream().collect(Collectors.toList());
|
||||
|
||||
List<User> data = userFeignClient.getUserInfoByDeptIds(deptList).getData();
|
||||
SendEventVO vo = new SendEventVO();
|
||||
vo.setDeptList(dept);
|
||||
vo.setTime(po.getStartTime());
|
||||
@@ -317,7 +330,10 @@ public class EventDetailServiceImpl extends ServiceImpl<RmpEventDetailMapper, Rm
|
||||
vo.setLineName(lineInfoVOList.get(0).getLineName());
|
||||
vo.setPowerCompany(lineInfoVOList.get(0).getGdName());
|
||||
vo.setSubstation(lineInfoVOList.get(0).getSubName());
|
||||
publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
|
||||
for (User datum : data) {
|
||||
webSocketServer.sendMessageToUser(datum.getId(),PubUtils.obj2json(vo));
|
||||
}
|
||||
// publisher.send("/sendEvent", PubUtils.obj2json(vo), 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.event.common.websocket;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 15:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
public class WebSocketConfig {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通信文本消息和二进制缓存区大小
|
||||
* 避免对接 第三方 报文过大时,Websocket 1009 错误
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Bean
|
||||
public ServletServerContainerFactoryBean createWebSocketContainer() {
|
||||
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
|
||||
// 在此处设置bufferSize
|
||||
container.setMaxTextMessageBufferSize(10240000);
|
||||
container.setMaxBinaryMessageBufferSize(10240000);
|
||||
container.setMaxSessionIdleTimeout(15 * 60000L);
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.njcn.event.common.websocket;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/12/13 15:11【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@ServerEndpoint(value = "/event/{userId}")
|
||||
public class WebSocketServer {
|
||||
|
||||
private static final ConcurrentHashMap<String, Session> sessions = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, Long> lastHeartbeatTime = new ConcurrentHashMap<>();
|
||||
private static final ConcurrentHashMap<String, ScheduledExecutorService> heartbeatExecutors = new ConcurrentHashMap<>();
|
||||
private static final long HEARTBEAT_TIMEOUT = 60; // 60秒超时
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("userId") String userId) {
|
||||
if (StrUtil.isNotBlank(userId)) {
|
||||
sessions.put(userId, session);
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "连接成功");
|
||||
System.out.println("用户 " + userId + " 已连接");
|
||||
|
||||
// 启动心跳检测
|
||||
startHeartbeat(session, userId);
|
||||
} else {
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.VIOLATED_POLICY, "用户ID不能为空"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session, @PathParam("userId") String userId) {
|
||||
if ("alive".equalsIgnoreCase(message)) {
|
||||
// 更新最后心跳时间
|
||||
lastHeartbeatTime.put(userId, System.currentTimeMillis());
|
||||
sendMessage(session, "over");
|
||||
} else {
|
||||
// 处理业务消息
|
||||
System.out.println("收到用户 " + userId + " 的消息: " + message);
|
||||
// TODO: 处理业务逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session, CloseReason closeReason, @PathParam("userId") String userId) {
|
||||
// 移除用户并取消心跳检测
|
||||
sessions.remove(userId);
|
||||
lastHeartbeatTime.remove(userId);
|
||||
ScheduledExecutorService executor = heartbeatExecutors.remove(userId);
|
||||
if (executor != null) {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
System.out.println("用户 " + userId + " 已断开连接,状态码: " + closeReason.getCloseCode());
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable throwable, @PathParam("userId") String userId) {
|
||||
System.out.println("用户 " + userId + " 发生错误: " + throwable.getMessage());
|
||||
try {
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.UNEXPECTED_CONDITION, "发生错误"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessageToUser(String userId, String message) {
|
||||
Session session = sessions.get(userId);
|
||||
if (session != null && session.isOpen()) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
} else {
|
||||
System.out.println("webSocket用户 " + userId + " 不在线或会话已关闭");
|
||||
}
|
||||
}
|
||||
|
||||
private final Object lock = new Object();
|
||||
|
||||
public void sendMessageToAll(String message) {
|
||||
sessions.forEach((userId, session) -> {
|
||||
System.out.println("给用户推送消息" + userId);
|
||||
if (session.isOpen()) {
|
||||
synchronized (lock) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息给用户 " + userId + " 失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendMessage(Session session, String message) {
|
||||
try {
|
||||
session.getBasicRemote().sendText(message);
|
||||
} catch (IOException e) {
|
||||
System.out.println("发送消息失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void startHeartbeat(Session session, String userId) {
|
||||
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
heartbeatExecutors.put(userId, executor);
|
||||
|
||||
// 定期检查心跳
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
long lastTime = lastHeartbeatTime.getOrDefault(userId, 0L);
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
// 如果超过30秒没有收到心跳
|
||||
if (currentTime - lastTime > HEARTBEAT_TIMEOUT * 1000) {
|
||||
try {
|
||||
System.out.println("用户 " + userId + " 心跳超时,关闭连接");
|
||||
session.close(new CloseReason(CloseReason.CloseCodes.NORMAL_CLOSURE, "心跳超时"));
|
||||
} catch (IOException e) {
|
||||
System.out.println("关闭用户 " + userId + " 连接时出错: " + e.getMessage());
|
||||
}
|
||||
executor.shutdown();
|
||||
heartbeatExecutors.remove(userId);
|
||||
}
|
||||
}, 0, 5, TimeUnit.SECONDS); // 每5秒检查一次
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,283 @@
|
||||
#当前服务的基本信息
|
||||
microservice:
|
||||
ename: @artifactId@
|
||||
name: "@name@"
|
||||
version: @version@
|
||||
sentinel:
|
||||
url: @sentinel.url@
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10215
|
||||
spring:
|
||||
profiles:
|
||||
active: @spring.profiles.active@
|
||||
application:
|
||||
name: @artifactId@
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
#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
|
||||
gateway:
|
||||
globalcors:
|
||||
corsConfigurations:
|
||||
'[/**]':
|
||||
allowCredentials: true
|
||||
exposedHeaders: "Content-Disposition,Content-Type,Cache-Control"
|
||||
allowedHeaders: "*"
|
||||
allowedOrigins: "*"
|
||||
allowedMethods: "*"
|
||||
discovery:
|
||||
locator:
|
||||
# 开启自动代理 (自动装载从配置中心serviceId)
|
||||
enabled: true
|
||||
# 服务id为true --> 这样小写服务就可访问了
|
||||
lower-case-service-id: true
|
||||
routes:
|
||||
- id: pqs-auth
|
||||
uri: lb://pqs-auth
|
||||
predicates:
|
||||
- Path=/pqs-auth/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: user-boot
|
||||
uri: lb://user-boot
|
||||
predicates:
|
||||
- Path=/user-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: device-boot
|
||||
uri: lb://device-boot
|
||||
predicates:
|
||||
- Path=/device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: system-boot
|
||||
uri: lb://system-boot
|
||||
predicates:
|
||||
- Path=/system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-boot
|
||||
uri: lb://harmonic-boot
|
||||
predicates:
|
||||
- Path=/harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: energy-boot
|
||||
uri: lb://energy-boot
|
||||
predicates:
|
||||
- Path=/energy-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: event-boot
|
||||
uri: lb://event-boot
|
||||
predicates:
|
||||
- Path=/event-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: quality-boot
|
||||
uri: lb://quality-boot
|
||||
predicates:
|
||||
- Path=/quality-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: harmonic-prepare
|
||||
uri: lb://harmonic-prepare
|
||||
predicates:
|
||||
- Path=/harmonic-prepare/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: process-boot
|
||||
uri: lb://process-boot
|
||||
predicates:
|
||||
- Path=/process-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: prepare-boot
|
||||
uri: lb://prepare-boot
|
||||
predicates:
|
||||
- Path=/prepare-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: algorithm-boot
|
||||
uri: lb://algorithm-boot
|
||||
predicates:
|
||||
- Path=/algorithm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: access-boot
|
||||
uri: lb://access-boot
|
||||
predicates:
|
||||
- Path=/access-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-device-boot
|
||||
uri: lb://cs-device-boot
|
||||
predicates:
|
||||
- Path=/cs-device-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-system-boot
|
||||
uri: lb://cs-system-boot
|
||||
predicates:
|
||||
- Path=/cs-system-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-warn-boot
|
||||
uri: lb://cs-warn-boot
|
||||
predicates:
|
||||
- Path=/cs-warn-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-harmonic-boot
|
||||
uri: lb://cs-harmonic-boot
|
||||
predicates:
|
||||
- Path=/cs-harmonic-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: advance-boot
|
||||
uri: lb://advance-boot
|
||||
predicates:
|
||||
- Path=/advance-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: bpm-boot
|
||||
uri: lb://bpm-boot
|
||||
predicates:
|
||||
- Path=/bpm-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: supervision-boot
|
||||
uri: lb://supervision-boot
|
||||
predicates:
|
||||
- Path=/supervision-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
- id: cs-report-boot
|
||||
uri: lb://cs-report-boot
|
||||
predicates:
|
||||
- Path=/cs-report-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
#河北国网总部调用省侧接口,路径总部统一规定
|
||||
- id: hb_pms_down
|
||||
uri: lb://harmonic-boot
|
||||
predicates:
|
||||
- Path=/IndexAnalysis/**
|
||||
- Path=/pms-tech-powerquality-start/**
|
||||
- id: zl-event-boot
|
||||
uri: lb://zl-event-boot
|
||||
predicates:
|
||||
- Path=/zl-event-boot/**
|
||||
filters:
|
||||
- SwaggerHeaderFilter
|
||||
- StripPrefix=1
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
#config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
|
||||
whitelist:
|
||||
urls:
|
||||
- /user-boot/user/generateSm2Key
|
||||
- /user-boot/theme/getTheme
|
||||
- /user-boot/user/updateFirstPassword
|
||||
- /user-boot/appUser/authCode
|
||||
- /user-boot/appUser/register
|
||||
- /user-boot/appUser/resetPsd
|
||||
- /pqs-auth/oauth/logout
|
||||
- /pqs-auth/oauth/token
|
||||
- /pqs-auth/oauth/autoLogin
|
||||
- /pqs-auth/auth/getImgCode
|
||||
- /pqs-auth/oauth/getPublicKey
|
||||
- /pqs-auth/judgeToken/heBei
|
||||
- /pqs-auth/judgeToken/guangZhou
|
||||
|
||||
- /webjars/**
|
||||
- /actuator/**
|
||||
- /doc.html
|
||||
- /swagger-resources/**
|
||||
- /*/v2/api-docs
|
||||
- /favicon.ico
|
||||
- /system-boot/theme/getTheme
|
||||
- /system-boot/image/toStream
|
||||
- /system-boot/file/download
|
||||
- /cs-system-boot/appinfo/queryAppInfoByType
|
||||
- /system-boot/dictType/dictDataCache
|
||||
- /system-boot/file/**
|
||||
- /system-boot/area/**
|
||||
- /bpm-boot/**
|
||||
- /harmonic-boot/comAccess/getComAccessData
|
||||
- /harmonic-boot/harmonic/getHistoryResult
|
||||
- /event-boot/transient/getTransientAnalyseWave
|
||||
# - /**
|
||||
#开始
|
||||
# - /advance-boot/**
|
||||
# - /device-boot/**
|
||||
# - /system-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /energy-boot/**
|
||||
# - /event-boot/**
|
||||
# - /quality-boot/**
|
||||
# - /harmonic-prepare/**
|
||||
# - /process-boot/**
|
||||
# - /bpm-boot/**
|
||||
# - /system-boot/**
|
||||
# - /supervision-boot/**
|
||||
# - /user-boot/**
|
||||
# - /harmonic-boot/**
|
||||
# - /cs-device-boot/**
|
||||
#结束
|
||||
- /user-boot/user/listAllUserByDeptId
|
||||
- /IndexAnalysis/**
|
||||
#mqtt:
|
||||
# client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ public class ReportSearchParam {
|
||||
//目前用于区分不同系统资源,null默认 1.无线系统,配合cs-device
|
||||
private Integer resourceType;
|
||||
|
||||
//区分统计数据还是分钟数据,null默认统计数据 0.统计数据 1.分钟数据
|
||||
private Integer isStatisticData;
|
||||
|
||||
//浙江无线报表特殊标识 null为通用报表 1.浙江无线报表
|
||||
private Integer customType;
|
||||
|
||||
|
||||
@@ -17,4 +17,6 @@ public class AreaHarmReportParam {
|
||||
|
||||
private String deptId;
|
||||
|
||||
private String scale;
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.device.biz.commApi.CommLineClient;
|
||||
import com.njcn.device.biz.pojo.dto.LineALLInfoDTO;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.api.UserLedgerFeignClient;
|
||||
@@ -48,6 +50,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
@@ -83,7 +86,7 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
|
||||
private final EventDetailFeignClient eventDetailFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final UserLedgerFeignClient userLedgerFeignClient;
|
||||
|
||||
private final CommLineClient commLineClient;
|
||||
@Override
|
||||
public Page<OverAreaLimitVO> getAreaData(OverAreaVO param) {
|
||||
Page<OverAreaLimitVO> page = new Page<>();
|
||||
@@ -301,8 +304,31 @@ public class AnalyzeServiceImpl implements IAnalyzeService {
|
||||
lineList.addAll(item.getLineIndexes());
|
||||
});
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
page = targetMapper.getSumLimitTargetPage(page, lineList, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),
|
||||
List<String> filterLineList = new ArrayList<>();
|
||||
|
||||
if(CollectionUtil.isNotEmpty(lineList)){
|
||||
//根据searchvalue过滤
|
||||
String searchvalue=param.getSearchValue();
|
||||
List<LineALLInfoDTO> data = commLineClient.getLineAllDetailList(lineList).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(searchvalue))
|
||||
|| (objName2 != null && objName2.contains(searchvalue))
|
||||
|| (subStationName != null && subStationName.contains(searchvalue));
|
||||
}).map(dto -> dto.getLineLineDTO() != null ? dto.getLineLineDTO().getLineId() : null)
|
||||
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(filterLineList)) {
|
||||
page = targetMapper.getSumLimitTargetPage(page, filterLineList, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime())),
|
||||
DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
|
||||
List<MonitorOverLimitVO> pageRecords = page.getRecords();
|
||||
if (CollectionUtils.isEmpty(pageRecords)) {
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.njcn.harmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.harmonic.common.mapper.RStatDataHarmRateVDMapper;
|
||||
import com.njcn.harmonic.common.mapper.RStatDataIDMapper;
|
||||
import com.njcn.harmonic.constant.Param;
|
||||
import com.njcn.harmonic.mapper.RStatDataHarmRateIDMapper;
|
||||
import com.njcn.harmonic.pojo.param.HarmInHarmParam;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateIDPO;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataHarmrateVDPO;
|
||||
import com.njcn.harmonic.pojo.po.day.RStatDataIDPO;
|
||||
import com.njcn.harmonic.pojo.vo.HarmInHarmVO;
|
||||
import com.njcn.harmonic.service.HarmInHarmService;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
@@ -21,6 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -41,7 +50,8 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
||||
|
||||
private final IDataIService dataIService;
|
||||
|
||||
|
||||
private final RStatDataHarmRateVDMapper dataHarmRateVDMapper;
|
||||
private final RStatDataIDMapper dataIDMapper;
|
||||
@Override
|
||||
public HarmInHarmVO getHarmInHarmData(HarmInHarmParam harmInHarmParam) {
|
||||
HarmInHarmVO harmInHarmVO = new HarmInHarmVO();
|
||||
@@ -77,33 +87,70 @@ public class HarmInHarmServiceImpl implements HarmInHarmService {
|
||||
List<Float> floatList = new ArrayList<>();
|
||||
if (StrUtil.isNotBlank(lineId)) {
|
||||
if (harmState == 0) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||
influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
||||
.eq(DataHarmRateV::getLineId, lineId)
|
||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
||||
if (Objects.nonNull(dataHarmRateV)) {
|
||||
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmRateV.class);
|
||||
// influxQueryWrapper.meanSamePrefixAndSuffix("v_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||
// .eq(DataHarmRateV::getLineId, lineId)
|
||||
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
// DataHarmRateV dataHarmRateV = dataHarmRateVService.getMeanAllTimesData(influxQueryWrapper);
|
||||
// if (Objects.nonNull(dataHarmRateV)) {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
||||
// }
|
||||
// }else {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(null);
|
||||
// }
|
||||
// }
|
||||
//转换成查mysql统计数据,分钟数据没有值
|
||||
List<RStatDataHarmrateVDPO> harmV = dataHarmRateVDMapper.selectList(new LambdaQueryWrapper<RStatDataHarmrateVDPO>()
|
||||
.eq(RStatDataHarmrateVDPO::getLineId, lineId)
|
||||
.eq(RStatDataHarmrateVDPO::getValueType,"CP95")
|
||||
.in(RStatDataHarmrateVDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||
.ge(RStatDataHarmrateVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(RStatDataHarmrateVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
|
||||
if (Objects.nonNull(harmV)) {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(PubUtils.getValueByMethodDouble(dataHarmRateV, "getV", i).floatValue());
|
||||
floatList.add(PubUtils.getValueByMethodDouble(harmV,RStatDataHarmrateVDPO.class, "getV", i).floatValue());
|
||||
}
|
||||
}else {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
.between(DataHarmRateV::getTime, startTime, endTime)
|
||||
.eq(DataHarmRateV::getLineId, lineId)
|
||||
.eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
.ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
||||
if (Objects.nonNull(dataI)) {
|
||||
// InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
// influxQueryWrapper.meanSamePrefixAndSuffix("i_", "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1))
|
||||
// .between(DataHarmRateV::getTime, startTime, endTime)
|
||||
// .eq(DataHarmRateV::getLineId, lineId)
|
||||
// .eq(DataHarmRateV::getValueType, InfluxDBTableConstant.CP95)
|
||||
// .ne(DataHarmRateV::getPhaseType, InfluxDBTableConstant.PHASE_TYPE_T);
|
||||
// DataI dataI = dataIService.getMeanAllTimesData(influxQueryWrapper);
|
||||
// if (Objects.nonNull(dataI)) {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
||||
// }
|
||||
// }else {
|
||||
// for (int i = 2; i < 51; i++) {
|
||||
// floatList.add(null);
|
||||
// }
|
||||
// }
|
||||
|
||||
//转换成查mysql统计数据,分钟数据没有值
|
||||
List<RStatDataIDPO> harmI = dataIDMapper.selectList(new LambdaQueryWrapper<RStatDataIDPO>()
|
||||
.eq(RStatDataIDPO::getLineId, lineId)
|
||||
.eq(RStatDataIDPO::getValueType,"CP95")
|
||||
.in(RStatDataIDPO::getPhaseType, Arrays.asList("A","B","C"))
|
||||
.ge(RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(startTime)))
|
||||
.le(RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(endTime)))
|
||||
);
|
||||
if (Objects.nonNull(harmI)) {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
floatList.add(PubUtils.getValueByMethodDouble(dataI, "getI", i).floatValue());
|
||||
floatList.add(PubUtils.getValueByMethodDouble(harmI,RStatDataIDPO.class, "getI", i).floatValue());
|
||||
}
|
||||
}else {
|
||||
for (int i = 2; i < 51; i++) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
@@ -132,7 +133,7 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
tableList.add(new ArrayList<>());
|
||||
|
||||
// 1. 台账表格
|
||||
List<String[]> ledgerTable = buildLedgerTable(param.getDeptId());
|
||||
List<String[]> ledgerTable = buildLedgerTable(param.getDeptId(),param.getScale());
|
||||
if(CollUtil.isEmpty(ledgerTable)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"当前部门不存在在运监测点");
|
||||
}
|
||||
@@ -145,7 +146,7 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
List<OverAreaLimitVO> qualityData = getPowerQualityData(param);
|
||||
if (CollUtil.isNotEmpty(qualityData)) {
|
||||
// 构建监控点名称映射
|
||||
Map<String, String> monitorNameMap = buildMonitorNameMap(param.getDeptId());
|
||||
Map<String, String> monitorNameMap = buildMonitorNameMap(param.getDeptId(),param.getScale());
|
||||
|
||||
// 过滤有效数据(在线监控数>0)
|
||||
List<OverAreaLimitVO> validData = qualityData.stream()
|
||||
@@ -176,8 +177,8 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
/**
|
||||
* 构建台账表格
|
||||
*/
|
||||
private List<String[]> buildLedgerTable(String deptId) {
|
||||
List<MonitorCommLedgerInfoDTO> ledgerList = getLedgerInfo(deptId);
|
||||
private List<String[]> buildLedgerTable(String deptId, String scale) {
|
||||
List<MonitorCommLedgerInfoDTO> ledgerList = getLedgerInfo(deptId,scale);
|
||||
if (CollUtil.isEmpty(ledgerList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@@ -190,7 +191,7 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
MonitorCommLedgerInfoDTO ledger = ledgerList.get(i);
|
||||
return new String[]{
|
||||
String.valueOf(i + 1),
|
||||
ledger.getMonitorName(),
|
||||
StringUtils.hasText(ledger.getObjName())? ledger.getObjName()+"_"+ledger.getMonitorName():ledger.getMonitorName(),
|
||||
ledger.getBdName(),
|
||||
ledger.getBusBarName(),
|
||||
voltageLevelMap.getOrDefault(ledger.getVoltageLevel(), ""),
|
||||
@@ -750,10 +751,14 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
/**
|
||||
* 获取台账信息
|
||||
*/
|
||||
private List<MonitorCommLedgerInfoDTO> getLedgerInfo(String deptId) {
|
||||
private List<MonitorCommLedgerInfoDTO> getLedgerInfo(String deptId, String scale) {
|
||||
DeptGetLineParam param = new DeptGetLineParam();
|
||||
param.setDeptId(deptId);
|
||||
return commTerminalGeneralClient.deptGetLineInfo(param).getData();
|
||||
List<MonitorCommLedgerInfoDTO> data = commTerminalGeneralClient.deptGetLineInfo(param).getData();
|
||||
if(StringUtils.hasText(scale)){
|
||||
data=data.stream().filter(temp->Objects.equals(scale,temp.getVoltageLevel())).collect(Collectors.toList());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -770,12 +775,13 @@ public class AreaHarmonicServiceImpl implements AreaHarmonicService {
|
||||
/**
|
||||
* 构建监控点名称映射
|
||||
*/
|
||||
private Map<String, String> buildMonitorNameMap(String deptId) {
|
||||
List<MonitorCommLedgerInfoDTO> ledgerList = getLedgerInfo(deptId);
|
||||
private Map<String, String> buildMonitorNameMap(String deptId, String scale) {
|
||||
List<MonitorCommLedgerInfoDTO> ledgerList = getLedgerInfo(deptId, scale);
|
||||
return ledgerList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
MonitorCommLedgerInfoDTO::getMonitorId,
|
||||
MonitorCommLedgerInfoDTO::getMonitorName
|
||||
temp-> StringUtils.hasText(temp.getObjName())? temp.getObjName()+"_"+temp.getMonitorName():temp.getMonitorName()
|
||||
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Data;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* 装置数据单位配置类
|
||||
* @author cdf
|
||||
* @date 2026/1/17
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.njcn.harmonic.pojo.param.ReportSearchParam;
|
||||
import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -44,7 +45,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
@@ -72,6 +73,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
|
||||
|
||||
private final String CELL_DATA = "celldata";
|
||||
@@ -90,7 +92,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}};
|
||||
|
||||
@Override
|
||||
public void getCustomReport(ReportSearchParam reportSearchParam,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||
public void getCustomReport(ReportSearchParam reportSearchParam, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(reportSearchParam.getTempId());
|
||||
if (Objects.isNull(excelRptTemp)) {
|
||||
@@ -98,7 +100,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
if (Objects.isNull(reportSearchParam.getCustomType())) {
|
||||
//通用报表
|
||||
analyzeReport(reportSearchParam, excelRptTemp, newMap,deviceUnitCommDTO,response);
|
||||
analyzeReport(reportSearchParam, excelRptTemp, newMap, deviceUnitCommDTO, response);
|
||||
|
||||
log.info("报表执行时间{}秒", timeInterval.intervalSecond());
|
||||
}
|
||||
@@ -118,7 +120,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
return filePath;
|
||||
}
|
||||
|
||||
private String analyzeReport2(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
private String analyzeReport2(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
//定义一个线程集合
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
@@ -133,23 +135,23 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
|
||||
} catch (Exception e) {
|
||||
if(e instanceof BusinessException){
|
||||
if (e instanceof BusinessException) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}else {
|
||||
} else {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
}
|
||||
//查询不分相别的指标
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
if(Objects.isNull(dictData)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||
if (Objects.isNull(dictData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "字典类型模板缺少!");
|
||||
}
|
||||
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList = epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
|
||||
Map<String, String> tMap = new HashMap<>();
|
||||
eleEpdPqdList.forEach(item->{
|
||||
eleEpdPqdList.forEach(item -> {
|
||||
String phase;
|
||||
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||
phase = item.getPhase();
|
||||
@@ -165,8 +167,8 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
});
|
||||
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it -> "T".equals(it.getPhase()) || "M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it -> StrUtil.isNotBlank(it.getOtherName())).map(it -> it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
|
||||
//处理指标是否合格
|
||||
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
@@ -194,18 +196,18 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assSqlByMysql(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
} finally {
|
||||
DynamicDataSourceContextHolder.poll();
|
||||
}
|
||||
}));
|
||||
@@ -217,53 +219,53 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
future.get(); // 这会阻塞直到任务完成或抛出异常
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}",e.getMessage());
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//处理指标最终判定合格还是不合格
|
||||
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
|
||||
}
|
||||
resultAssemble2(endList,reportSearchParam,newMap,deviceUnitCommDTO,jsonArray,dataMap);
|
||||
resultAssemble2(endList, reportSearchParam, newMap, deviceUnitCommDTO, jsonArray, dataMap);
|
||||
//存储自定义报表
|
||||
return saveReport(jsonArray,dataMap);
|
||||
return saveReport(jsonArray, dataMap);
|
||||
}
|
||||
|
||||
public void resultAssemble2(List<ReportTemplateDTO> endList, ReportSearchParam reportSearchParam, Map<String, String> finalTerminalMap, DeviceUnitCommDTO deviceUnitCommDTO, JSONArray jsonArray,Map<String, Object> dataMap) {
|
||||
public void resultAssemble2(List<ReportTemplateDTO> endList, ReportSearchParam reportSearchParam, Map<String, String> finalTerminalMap, DeviceUnitCommDTO deviceUnitCommDTO, JSONArray jsonArray, Map<String, Object> dataMap) {
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
Map<String, String> unit = this.unitMap(deviceUnitCommDTO);
|
||||
Map<String, List<ReportTemplateDTO>> assMap = (Map)endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
Map<String, List<ReportTemplateDTO>> assMap = (Map) endList.stream().collect(Collectors.groupingBy(ReportTemplateDTO::getItemName));
|
||||
jsonArray.forEach((item) -> {
|
||||
JSONObject jsonObject = (JSONObject)item;
|
||||
JSONArray itemArr = (JSONArray)jsonObject.get("celldata");
|
||||
JSONObject jsonObject = (JSONObject) item;
|
||||
JSONArray itemArr = (JSONArray) jsonObject.get("celldata");
|
||||
itemArr.forEach((it) -> {
|
||||
if (Objects.nonNull(it) && !"null".equals(it.toString())) {
|
||||
JSONObject data = (JSONObject)it;
|
||||
JSONObject son = (JSONObject)data.get("v");
|
||||
JSONObject data = (JSONObject) it;
|
||||
JSONObject son = (JSONObject) data.get("v");
|
||||
if (son.containsKey("v")) {
|
||||
String v = son.getStr("v");
|
||||
String tem;
|
||||
List rDto;
|
||||
if (v.charAt(0) == '$' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("$", "").toUpperCase());
|
||||
rDto = (List) assMap.get(v.replace("$", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
tem = ((ReportTemplateDTO) rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
|
||||
son.set("v", tem);
|
||||
dataMap.put(v, tem);
|
||||
if (Objects.nonNull(((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag()) && ((ReportTemplateDTO)rDto.get(0)).getOverLimitFlag() == 1) {
|
||||
if (Objects.nonNull(((ReportTemplateDTO) rDto.get(0)).getOverLimitFlag()) && ((ReportTemplateDTO) rDto.get(0)).getOverLimitFlag() == 1) {
|
||||
son.set("fc", "#990000");
|
||||
}
|
||||
}
|
||||
} else if (v.charAt(0) == '%' && v.contains("#")) {
|
||||
tem = "";
|
||||
rDto = (List)assMap.get(v.replace("%", "").toUpperCase());
|
||||
rDto = (List) assMap.get(v.replace("%", "").toUpperCase());
|
||||
if (Objects.nonNull(rDto)) {
|
||||
tem = ((ReportTemplateDTO)rDto.get(0)).getValue();
|
||||
tem = ((ReportTemplateDTO) rDto.get(0)).getValue();
|
||||
if (StringUtils.isBlank(tem)) {
|
||||
tem = "/";
|
||||
}
|
||||
@@ -310,7 +312,6 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String saveReport(JSONArray jsonArray, Map<String, Object> dataMap) {
|
||||
String filePath = "";
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
@@ -412,21 +413,21 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
style.setFont(font);
|
||||
style.setWrapText(true);
|
||||
|
||||
if (Objects.equals(cell.getStringCellValue(),"非谐波统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电压统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电流统计报表")) {
|
||||
if (Objects.equals(cell.getStringCellValue(), "非谐波统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(), "谐波电压统计报表")
|
||||
|| Objects.equals(cell.getStringCellValue(), "谐波电流统计报表")) {
|
||||
font.setFontHeightInPoints((short) 18);
|
||||
font.setBold(true);
|
||||
}
|
||||
if (Objects.equals(cell.getStringCellValue(),"有效值")
|
||||
|| Objects.equals(cell.getStringCellValue(),"功率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"电压闪变")
|
||||
|| Objects.equals(cell.getStringCellValue(),"畸变率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"电压偏差")
|
||||
|| Objects.equals(cell.getStringCellValue(),"频率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"三相不平衡度")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电压含有率")
|
||||
|| Objects.equals(cell.getStringCellValue(),"谐波电流幅值")) {
|
||||
if (Objects.equals(cell.getStringCellValue(), "有效值")
|
||||
|| Objects.equals(cell.getStringCellValue(), "功率")
|
||||
|| Objects.equals(cell.getStringCellValue(), "电压闪变")
|
||||
|| Objects.equals(cell.getStringCellValue(), "畸变率")
|
||||
|| Objects.equals(cell.getStringCellValue(), "电压偏差")
|
||||
|| Objects.equals(cell.getStringCellValue(), "频率")
|
||||
|| Objects.equals(cell.getStringCellValue(), "三相不平衡度")
|
||||
|| Objects.equals(cell.getStringCellValue(), "谐波电压含有率")
|
||||
|| Objects.equals(cell.getStringCellValue(), "谐波电流幅值")) {
|
||||
font.setFontHeightInPoints((short) 15);
|
||||
font.setBold(true);
|
||||
}
|
||||
@@ -564,7 +565,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
* @date 2023/10/8
|
||||
*/
|
||||
|
||||
private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp,Map<String,String> newMap,DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||
private void analyzeReport(ReportSearchParam reportSearchParam, ExcelRptTemp excelRptTemp, Map<String, String> newMap, DeviceUnitCommDTO deviceUnitCommDTO, HttpServletResponse response) {
|
||||
//定义一个线程集合
|
||||
List<Future<?>> futures = new ArrayList<>();
|
||||
//指标
|
||||
@@ -578,23 +579,23 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
jsonArray = new JSONArray(new JSONTokener(fileStream, new JSONConfig()));
|
||||
parseTemplate(jsonArray, reportTemplateDTOList, reportLimitList, terminalList);
|
||||
} catch (Exception e) {
|
||||
if(e instanceof BusinessException){
|
||||
if (e instanceof BusinessException) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
}else {
|
||||
} else {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
}
|
||||
//查询不分相别的指标
|
||||
DictData dictData = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(), DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
if(Objects.isNull(dictData)){
|
||||
throw new BusinessException(CommonResponseEnum.FAIL,"字典类型模板缺少!");
|
||||
if (Objects.isNull(dictData)) {
|
||||
throw new BusinessException(CommonResponseEnum.FAIL, "字典类型模板缺少!");
|
||||
}
|
||||
List<EleEpdPqd> eleEpdPqdList = epdFeignClient.dictMarkByDataType(dictData.getId()).getData();
|
||||
Map<String, String> tableMap = eleEpdPqdList.stream().collect(Collectors.toMap(EleEpdPqd::getResourcesId, EleEpdPqd::getClassId, (oldValue, newValue) -> oldValue));
|
||||
|
||||
DictData epdDic = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.EPD.getCode(),DicDataTypeEnum.CS_DATA_TYPE.getCode()).getData();
|
||||
List<EleEpdPqd> eleEpdPqdList= epdFeignClient.dictMarkByDataType(epdDic.getId()).getData();
|
||||
|
||||
Map<String, String> tMap = new HashMap<>();
|
||||
eleEpdPqdList.forEach(item->{
|
||||
eleEpdPqdList.forEach(item -> {
|
||||
String phase;
|
||||
if (Objects.isNull(PHASE_MAPPING.get(item.getPhase()))) {
|
||||
phase = item.getPhase();
|
||||
@@ -610,8 +611,8 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
});
|
||||
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it->"T".equals(it.getPhase())||"M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it->StrUtil.isNotBlank(it.getOtherName())).map(it->it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
eleEpdPqdList = eleEpdPqdList.stream().filter(it -> "M".equals(it.getPhase())).collect(Collectors.toList());
|
||||
List<String> noPhaseList = eleEpdPqdList.stream().filter(it -> StrUtil.isNotBlank(it.getOtherName())).map(it -> it.getOtherName().toUpperCase()).collect(Collectors.toList());
|
||||
|
||||
//处理指标是否合格
|
||||
reportLimitList = new LinkedHashSet<>(reportLimitList).stream().sorted(Comparator.comparing(ReportTemplateDTO::getItemName)).collect(Collectors.toList());
|
||||
@@ -639,18 +640,18 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
phaseMap.forEach((phaseKey, phaseVal) -> {
|
||||
StringBuilder sql = new StringBuilder(InfluxDbSqlConstant.SELECT);
|
||||
if (InfluxDbSqlConstant.MAX.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assembleSqlAndQuery(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.MAX, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList, tableMap);
|
||||
} else if (InfluxDbSqlConstant.MIN.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assembleSqlAndQuery(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.MIN, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList, tableMap);
|
||||
} else if (InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assembleSqlAndQuery(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.AVG_WEB, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList,tableMap);
|
||||
} else if (InfluxDbSqlConstant.CP95.equalsIgnoreCase(valueTypeKey)) {
|
||||
assSqlByMysql(tMap,newMap.get("LEVEL"),newMap.get("PT"),newMap.get("CT"),phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap,noPhaseList);
|
||||
assembleSqlAndQuery(tMap, newMap.get("LEVEL"), newMap.get("PT"), newMap.get("CT"), phaseVal, sql, endList, InfluxDbSqlConstant.CP95, reportSearchParam, limitTargetMapX, limitMap, assNoPassMap, noPhaseList,tableMap);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}finally {
|
||||
} finally {
|
||||
DynamicDataSourceContextHolder.poll();
|
||||
}
|
||||
}));
|
||||
@@ -662,22 +663,22 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
future.get(); // 这会阻塞直到任务完成或抛出异常
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}",e.getMessage());
|
||||
log.error("自定义报表多线程查询流程出错!错误信息{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//处理指标最终判定合格还是不合格
|
||||
dealTargetResult(assNoPassMap, limitTargetMapX, endList);
|
||||
}
|
||||
resultAssemble(endList,reportSearchParam,newMap,deviceUnitCommDTO,jsonArray);
|
||||
resultAssemble(endList, reportSearchParam, newMap, deviceUnitCommDTO, jsonArray);
|
||||
//导出自定义报表
|
||||
downReport(jsonArray, response);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 解析模板
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
@@ -780,7 +781,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
for (ReportTemplateDTO item : reportLimitList) {
|
||||
if (limitMap.containsKey(item.getTemplateName())) {
|
||||
|
||||
if(item.getTemplateName().equalsIgnoreCase(VOLTAGE_DEV)){
|
||||
if (item.getTemplateName().equalsIgnoreCase(VOLTAGE_DEV)) {
|
||||
item.setLowValue(limitMap.get(UVOLTAGE_DEV).toString());
|
||||
}
|
||||
item.setValue(limitMap.get(item.getTemplateName()).toString());
|
||||
@@ -815,6 +816,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
|
||||
/**
|
||||
* 对多测点数据进行计算求出一组数据
|
||||
*
|
||||
* @param method
|
||||
* @param allList
|
||||
* @return
|
||||
@@ -884,7 +886,6 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 处理指标超标结论
|
||||
*/
|
||||
@@ -897,13 +898,13 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
|
||||
String expend = "";
|
||||
if(Objects.nonNull(val.getLowValue())){
|
||||
expend = val.getLowValue()+",";
|
||||
if (Objects.nonNull(val.getLowValue())) {
|
||||
expend = val.getLowValue() + ",";
|
||||
}
|
||||
if (val.getOverLimitFlag() == 1) {
|
||||
val.setValue("不合格 (" + expend+val.getValue() + ")");
|
||||
val.setValue("不合格 (" + expend + val.getValue() + ")");
|
||||
} else {
|
||||
val.setValue("合格 (" + expend+val.getValue() + ")");
|
||||
val.setValue("合格 (" + expend + val.getValue() + ")");
|
||||
}
|
||||
endList.add(val);
|
||||
});
|
||||
@@ -935,15 +936,15 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
return ratio;
|
||||
}
|
||||
|
||||
public String appendData(Map<String,String> tMap,String name, double pt, double ct) {
|
||||
public String appendData(Map<String, String> tMap, String name, double pt, double ct) {
|
||||
String result;
|
||||
String format = tMap.get(name);
|
||||
if (Objects.equals(format, "*PT")) {
|
||||
result = "*"+pt+"/1000";
|
||||
result = "*" + pt + "/1000";
|
||||
} else if (Objects.equals(format, "*CT")) {
|
||||
result = "*"+ct;
|
||||
result = "*" + ct;
|
||||
} else if (Objects.equals(format, "*PT*CT")) {
|
||||
result = "*"+pt+"*"+ct+"/1000";
|
||||
result = "*" + pt + "*" + ct + "/1000";
|
||||
} else {
|
||||
result = "";
|
||||
}
|
||||
@@ -958,7 +959,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
* @param assNoPassMap 用于存储不合格的指标
|
||||
* @date 2023/10/20
|
||||
*/
|
||||
private void assSqlByMysql(Map<String,String> tMap, String dataLevel, String pt, String ct, List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap,List<String> noPhaseList) {
|
||||
private void assSqlByMysql(Map<String, String> tMap, String dataLevel, String pt, String ct, List<ReportTemplateDTO> data, StringBuilder sql, List<ReportTemplateDTO> endList, String method, ReportSearchParam reportSearchParam, Map<String, ReportTemplateDTO> limitMap, Map<String, Float> overLimitMap, Map<String, ReportTemplateDTO> assNoPassMap, List<String> noPhaseList) {
|
||||
//sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
||||
if (InfluxDbSqlConstant.CP95.equals(method)) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
@@ -967,17 +968,17 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"");
|
||||
.append("\"" + data.get(i).getItemName() + "\"");
|
||||
} else {
|
||||
sql.append(InfluxDbSqlConstant.MAX)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -987,17 +988,17 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"");
|
||||
.append("\"" + data.get(i).getItemName() + "\"");
|
||||
} else {
|
||||
sql.append(method)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName()+data.get(i).getPhase()+data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS)
|
||||
.append("\""+data.get(i).getItemName()+"\"").append(StrUtil.COMMA);
|
||||
.append("\"" + data.get(i).getItemName() + "\"").append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1035,9 +1036,6 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
|
||||
//频率和频率偏差仅统计T相
|
||||
if (noPhaseList.contains(data.get(0).getTemplateName())) {
|
||||
if(data.get(0).getTemplateName().equalsIgnoreCase("v_unbalance")){
|
||||
System.out.println(44);
|
||||
}
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.PHASIC_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
@@ -1050,9 +1048,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.GE).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getStartTime()).append(InfluxDbSqlConstant.START_TIME).append(InfluxDbSqlConstant.QM)
|
||||
.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.LT).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getEndTime()).append(InfluxDbSqlConstant.END_TIME).append(InfluxDbSqlConstant.QM);
|
||||
|
||||
System.out.println(sql);
|
||||
|
||||
List<Map<String, Object>> mapList = SqlRunner.DEFAULT.selectList(sql.toString());
|
||||
if (CollUtil.isEmpty(mapList) || Objects.isNull(mapList.get(0))) {
|
||||
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
|
||||
@@ -1066,16 +1062,16 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
if (overLimitMap.containsKey(item.getLimitName())) {
|
||||
Float tagVal = overLimitMap.get(item.getLimitName());
|
||||
|
||||
if(item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)){
|
||||
if (item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)) {
|
||||
//对电压偏差特殊处理
|
||||
Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV);
|
||||
if (v > tagVal || v<tagVal_U) {
|
||||
if (v > tagVal || v < tagVal_U) {
|
||||
item.setOverLimitFlag(1);
|
||||
} else {
|
||||
item.setOverLimitFlag(0);
|
||||
}
|
||||
|
||||
}else {
|
||||
} else {
|
||||
if (v > tagVal) {
|
||||
item.setOverLimitFlag(1);
|
||||
} else {
|
||||
@@ -1091,18 +1087,18 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
ReportTemplateDTO tem = limitMap.get(key);
|
||||
double limitVal = Double.parseDouble(tem.getValue());
|
||||
|
||||
if(VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())){
|
||||
if (VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())) {
|
||||
//针对电压偏差特殊处理
|
||||
double limitLowVal = Double.parseDouble(tem.getLowValue());
|
||||
|
||||
if (v > limitVal || v<limitLowVal) {
|
||||
if (v > limitVal || v < limitLowVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
assNoPassMap.put(key, tem);
|
||||
} else if (!assNoPassMap.containsKey(key)) {
|
||||
tem.setOverLimitFlag(0);
|
||||
assNoPassMap.put(key, tem);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
//其他指标
|
||||
if (v > limitVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
@@ -1123,6 +1119,251 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
}
|
||||
|
||||
|
||||
private void assembleSqlAndQuery(Map<String, String> tMap, String dataLevel, String pt, String ct,
|
||||
List<ReportTemplateDTO> data, StringBuilder sql,
|
||||
List<ReportTemplateDTO> endList, String method,
|
||||
ReportSearchParam reportSearchParam,
|
||||
Map<String, ReportTemplateDTO> limitMap,
|
||||
Map<String, Float> overLimitMap,
|
||||
Map<String, ReportTemplateDTO> assNoPassMap,
|
||||
List<String> noPhaseList,
|
||||
Map<String, String> tableMap) {
|
||||
// sql拼接示例:select MAX(IHA2) as IHA2 from power_quality_data where Phase = 'A' and LineId='1324564568' and Stat_Method='max' tz('Asia/Shanghai')
|
||||
|
||||
// 处理CP95或PERCENTILE特殊情况
|
||||
boolean isCp95 = InfluxDbSqlConstant.CP95.equals(method);
|
||||
boolean isAvg = InfluxDbSqlConstant.AVG_WEB.equals(method);
|
||||
String aggregateFunc;
|
||||
// 执行查询
|
||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||
if (Objects.isNull(reportSearchParam.getIsStatisticData()) || reportSearchParam.getIsStatisticData() == 0) {
|
||||
aggregateFunc = isCp95 ? InfluxDbSqlConstant.MAX : method;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
sql.append(aggregateFunc)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "");
|
||||
if (i == data.size() - 1) {
|
||||
sql.append(InfluxDbSqlConstant.AS).append("\"").append(data.get(i).getItemName()).append("\"");
|
||||
} else {
|
||||
sql.append(InfluxDbSqlConstant.AS).append("\"").append(data.get(i).getItemName()).append("\"").append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
//拼接表名
|
||||
sql.append(StrPool.C_SPACE).append(InfluxDbSqlConstant.FROM).append(data.get(0).getResourceId());
|
||||
|
||||
sql.append(InfluxDbSqlConstant.WHERE)
|
||||
.append(InfluxDBTableConstant.LINE_ID)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(reportSearchParam.getLineId())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
|
||||
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.VALUE_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(data.get(0).getStatMethod())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
|
||||
|
||||
//相别特殊处理
|
||||
if (noPhaseList.contains(data.get(0).getTemplateName())) {
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.PHASIC_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(InfluxDBTableConstant.PHASE_TYPE_T)
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
}else {
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.PHASIC_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(data.get(0).getPhase())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
}
|
||||
//时间范围处理
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.GE).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getStartTime()).append(InfluxDbSqlConstant.START_TIME).append(InfluxDbSqlConstant.QM)
|
||||
.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.LT).append(InfluxDbSqlConstant.QM).append(reportSearchParam.getEndTime()).append(InfluxDbSqlConstant.END_TIME).append(InfluxDbSqlConstant.QM);
|
||||
System.out.println(sql);
|
||||
mapList = SqlRunner.DEFAULT.selectList(sql.toString());
|
||||
} else if (reportSearchParam.getIsStatisticData() == 1) {
|
||||
//查分钟数据
|
||||
if (isCp95) {
|
||||
// InfluxDB的PERCENTILE特殊处理
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
sql.append(method)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName().toLowerCase())
|
||||
.append(InfluxDbSqlConstant.NUM_95)
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(InfluxDbSqlConstant.AS).append(InfluxDbSqlConstant.DQM)
|
||||
.append(data.get(i).getItemName()).append(InfluxDbSqlConstant.DQM);
|
||||
if (i != data.size() - 1) {
|
||||
sql.append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aggregateFunc = isAvg ? InfluxDbSqlConstant.AVG:method;
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
sql.append(aggregateFunc)
|
||||
.append(InfluxDbSqlConstant.LBK)
|
||||
.append(data.get(i).getTemplateName().toLowerCase())
|
||||
.append(InfluxDbSqlConstant.RBK)
|
||||
.append(Objects.equals(dataLevel, "Secondary") ? " " + appendData(tMap, data.get(i).getTemplateName() + data.get(i).getPhase() + data.get(0).getResourceId(), getData(pt), getData(ct)) : "")
|
||||
.append(InfluxDbSqlConstant.AS).append("\"").append(data.get(i).getItemName()).append("\"");
|
||||
if (i != data.size() - 1) {
|
||||
sql.append(StrUtil.COMMA);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 拼接表名
|
||||
sql.append(StrPool.C_SPACE).append(InfluxDbSqlConstant.FROM).append(StrPool.C_SPACE);
|
||||
if (Objects.nonNull(reportSearchParam.getResourceType()) && reportSearchParam.getResourceType() == 1) {
|
||||
sql.append(data.get(0).getClassId().replace("data", "day"));
|
||||
} else {
|
||||
sql.append(tableMap.get(data.get(0).getResourceId().toLowerCase()).toLowerCase());
|
||||
}
|
||||
|
||||
// 拼接WHERE条件
|
||||
sql.append(InfluxDbSqlConstant.WHERE)
|
||||
.append(InfluxDBTableConstant.LINE_ID)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(reportSearchParam.getLineId())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
|
||||
// InfluxDB特殊处理:data_flicker、data_fluc、data_plt 无 value_type
|
||||
String classTable = tableMap.get(data.get(0).getResourceId().toLowerCase());
|
||||
if (!InfluxDBTableConstant.DATA_FLICKER.equals(classTable)
|
||||
&& !InfluxDBTableConstant.DATA_FLUC.equals(classTable)
|
||||
&& !InfluxDBTableConstant.DATA_PLT.equals(classTable)) {
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.VALUE_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(data.get(0).getStatMethod())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
}
|
||||
|
||||
// 相别特殊处理
|
||||
if (!noPhaseList.contains(data.get(0).getPhase())) {
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDBTableConstant.PHASIC_TYPE)
|
||||
.append(InfluxDbSqlConstant.EQ)
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(data.get(0).getPhase())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
}
|
||||
|
||||
// 时间范围处理
|
||||
sql.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.GE)
|
||||
.append(InfluxDbSqlConstant.QM).append(reportSearchParam.getStartTime())
|
||||
.append(InfluxDbSqlConstant.QM)
|
||||
.append(InfluxDbSqlConstant.AND)
|
||||
.append(InfluxDbSqlConstant.TIME).append(InfluxDbSqlConstant.LT)
|
||||
.append(InfluxDbSqlConstant.QM).append(reportSearchParam.getEndTime())
|
||||
.append(InfluxDbSqlConstant.QM);
|
||||
|
||||
// InfluxDB需要添加时区
|
||||
sql.append(InfluxDbSqlConstant.TZ);
|
||||
System.out.println(sql);
|
||||
mapList = influxDbUtils.getMapResult(sql.toString());
|
||||
}
|
||||
// 处理查询结果
|
||||
fetchData(mapList, data, limitMap, overLimitMap, assNoPassMap, endList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void fetchData(List<Map<String, Object>> mapList,
|
||||
List<ReportTemplateDTO> data, Map<String,
|
||||
ReportTemplateDTO> limitMap,
|
||||
Map<String, Float> overLimitMap,
|
||||
Map<String, ReportTemplateDTO> assNoPassMap,
|
||||
List<ReportTemplateDTO> endList) {
|
||||
// 处理查询结果
|
||||
if (CollUtil.isEmpty(mapList)) {
|
||||
data = data.stream().peek(item -> item.setValue("/")).collect(Collectors.toList());
|
||||
} else {
|
||||
// 兼容达梦数据库方法
|
||||
Map<String, Object> map = convertKeysToUpperCase(mapList.get(0));
|
||||
for (ReportTemplateDTO item : data) {
|
||||
if (map.containsKey(item.getItemName())) {
|
||||
double v = Double.parseDouble(map.get(item.getItemName()).toString());
|
||||
item.setValue(String.format("%.3f", v));
|
||||
|
||||
// 处理overLimitMap越限判断
|
||||
if (overLimitMap != null && overLimitMap.containsKey(item.getLimitName())) {
|
||||
Float tagVal = overLimitMap.get(item.getLimitName());
|
||||
|
||||
if (item.getLimitName() != null && item.getLimitName().equalsIgnoreCase(UVOLTAGE_DEV)) {
|
||||
// 对电压偏差特殊处理
|
||||
Float tagVal_U = overLimitMap.get(UVOLTAGE_DEV);
|
||||
if (v > tagVal || v < tagVal_U) {
|
||||
item.setOverLimitFlag(1);
|
||||
} else {
|
||||
item.setOverLimitFlag(0);
|
||||
}
|
||||
} else {
|
||||
if (v > tagVal) {
|
||||
item.setOverLimitFlag(1);
|
||||
} else {
|
||||
item.setOverLimitFlag(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否越限(limitMap处理)
|
||||
if (limitMap != null && !limitMap.isEmpty()) {
|
||||
String key = item.getLimitName() + STR_ONE + item.getStatMethod() + "#PQ_OVERLIMIT";
|
||||
if (limitMap.containsKey(key)) {
|
||||
ReportTemplateDTO tem = limitMap.get(key);
|
||||
double limitVal = Double.parseDouble(tem.getValue());
|
||||
|
||||
if (VOLTAGE_DEV.equalsIgnoreCase(tem.getLimitName())) {
|
||||
// 针对电压偏差特殊处理
|
||||
double limitLowVal = Double.parseDouble(tem.getLowValue());
|
||||
if (v > limitVal || v < limitLowVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
if (assNoPassMap != null) {
|
||||
assNoPassMap.put(key, tem);
|
||||
}
|
||||
} else if (assNoPassMap != null && !assNoPassMap.containsKey(key)) {
|
||||
tem.setOverLimitFlag(0);
|
||||
assNoPassMap.put(key, tem);
|
||||
}
|
||||
} else {
|
||||
// 其他指标
|
||||
if (v > limitVal) {
|
||||
tem.setOverLimitFlag(1);
|
||||
if (assNoPassMap != null) {
|
||||
assNoPassMap.put(key, tem);
|
||||
}
|
||||
} else if (assNoPassMap != null && !assNoPassMap.containsKey(key)) {
|
||||
tem.setOverLimitFlag(0);
|
||||
assNoPassMap.put(key, tem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.setValue("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (endList != null) {
|
||||
endList.addAll(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据单位信息
|
||||
*/
|
||||
@@ -1179,10 +1420,11 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
|
||||
/**
|
||||
* 处理最终结果
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2026/1/16
|
||||
*/
|
||||
public void resultAssemble(List<ReportTemplateDTO> endList,ReportSearchParam reportSearchParam,Map<String,String> finalTerminalMap,DeviceUnitCommDTO deviceUnitCommDTO,JSONArray jsonArray){
|
||||
public void resultAssemble(List<ReportTemplateDTO> endList, ReportSearchParam reportSearchParam, Map<String, String> finalTerminalMap, DeviceUnitCommDTO deviceUnitCommDTO, JSONArray jsonArray) {
|
||||
if (CollUtil.isNotEmpty(endList)) {
|
||||
//数据单位信息
|
||||
Map<String, String> unit = unitMap(deviceUnitCommDTO);
|
||||
@@ -1233,7 +1475,7 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
} else if (v.charAt(0) == '&') {
|
||||
//结论
|
||||
String tem = v.replace(STR_THREE, "").toUpperCase();
|
||||
if (finalTerminalMap.size()>0) {
|
||||
if (finalTerminalMap.size() > 0) {
|
||||
if ("STATIS_TIME".equals(tem)) {
|
||||
//如何时间是大于当前时间则用当前时间
|
||||
String localTime = InfluxDbSqlConstant.END_TIME;
|
||||
@@ -1275,4 +1517,9 @@ public class CustomReportTableServiceImpl implements CustomReportTableService {
|
||||
return newMap;
|
||||
}
|
||||
|
||||
// 5. 添加线程池销毁方法
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
package com.njcn.system.api;
|
||||
|
||||
|
||||
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 com.njcn.system.api.fallback.CsStatistiacalFeignClientFallbackFactory;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
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;
|
||||
@@ -35,10 +39,12 @@ public interface CsStatisticalSetFeignClient {
|
||||
HttpResult<CsStatisticalSetVO> queryStatistical(@RequestParam("id")String id);
|
||||
|
||||
@PostMapping("/queryStatisticalSelect")
|
||||
HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestParam("id")String id);
|
||||
|
||||
|
||||
@ApiOperation("根据统计类型id组查询已绑定指标")
|
||||
HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestBody List<String> list);
|
||||
|
||||
@PostMapping("/queryStatisticalById")
|
||||
@ApiOperation("根据id查询数据")
|
||||
HttpResult<List<CsStatisticalSetPO>> queryStatisticalById(@RequestBody List<String> list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,12 +3,8 @@ package com.njcn.system.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.system.api.AreaFeignClient;
|
||||
import com.njcn.system.api.ConfigFeignClient;
|
||||
import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.pojo.dto.AreaTreeDTO;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.system.pojo.po.Config;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
import com.njcn.system.utils.SystemEnumUtil;
|
||||
@@ -56,9 +52,16 @@ public class CsStatistiacalFeignClientFallbackFactory implements FallbackFactory
|
||||
throw new BusinessException(finalExceptionEnum); }
|
||||
|
||||
@Override
|
||||
public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(String id) {
|
||||
public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据统计类型id查询已绑定指标下拉框",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum); }
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsStatisticalSetPO>> queryStatisticalById(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据id查询数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>energy-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
|
||||
@@ -6,13 +6,11 @@ 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.system.pojo.param.CsStatisticalSetAddParam;
|
||||
import com.njcn.system.pojo.po.CsStatisticalSetPO;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
|
||||
import com.njcn.system.service.CsStatisticalSetPOService;
|
||||
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -64,17 +62,22 @@ public class CsStatisticalSetController extends BaseController {
|
||||
@PostMapping("/queryStatisticalSelect")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("根据统计类型id组查询已绑定指标")
|
||||
public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestParam("id")String id){
|
||||
public HttpResult<List<EleEpdPqd>> queryStatisticalSelect(@RequestBody List<String> list){
|
||||
log.info("根据模板录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("EleEpdPqd");
|
||||
List<EleEpdPqd> result = csStatisticalSetPOService.queryStatisticalSelect(id);
|
||||
String methodDescribe = getMethodDescribe("queryStatisticalSelect");
|
||||
List<EleEpdPqd> result = csStatisticalSetPOService.queryStatisticalSelect(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@PostMapping("/queryStatisticalById")
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("根据id查询数据")
|
||||
public HttpResult<List<CsStatisticalSetPO>> queryStatisticalById(@RequestBody List<String> list){
|
||||
log.info("根据模板录入字典数据");
|
||||
String methodDescribe = getMethodDescribe("queryStatisticalById");
|
||||
List<CsStatisticalSetPO> result = csStatisticalSetPOService.queryStatisticalById(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,5 +23,7 @@ public interface CsStatisticalSetPOService extends IMppService<CsStatisticalSetP
|
||||
|
||||
CsStatisticalSetVO queryStatistical(String id);
|
||||
|
||||
List<EleEpdPqd> queryStatisticalSelect(String id);
|
||||
List<EleEpdPqd> queryStatisticalSelect(List<String> list);
|
||||
|
||||
List<CsStatisticalSetPO> queryStatisticalById(List<String> list);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -108,9 +111,9 @@ public class CsStatisticalSetPOServiceImpl extends MppServiceImpl<CsStatisticalS
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EleEpdPqd> queryStatisticalSelect(String id) {
|
||||
public List<EleEpdPqd> queryStatisticalSelect(List<String> list) {
|
||||
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
||||
queryWrap.lambda().eq(CsStatisticalSetPO::getStatisicalId, id);
|
||||
queryWrap.lambda().in(CsStatisticalSetPO::getStatisicalId, list);
|
||||
List<CsStatisticalSetPO> result = this.baseMapper.selectList(queryWrap);
|
||||
List<String> collect = result.stream().map(CsStatisticalSetPO::getTargetId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
@@ -118,6 +121,13 @@ public class CsStatisticalSetPOServiceImpl extends MppServiceImpl<CsStatisticalS
|
||||
}
|
||||
return epdPqdService.listByIds(collect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsStatisticalSetPO> queryStatisticalById(List<String> list) {
|
||||
QueryWrapper<CsStatisticalSetPO> queryWrap = new QueryWrapper<>();
|
||||
queryWrap.lambda().in(CsStatisticalSetPO::getStatisicalId, list);
|
||||
return this.baseMapper.selectList(queryWrap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
eleEpdPqd.setStatMethod(String.join(",", eleEpdPqdParam.getStatMethod()));
|
||||
}
|
||||
if (Objects.isNull(eleEpdPqdParam.getPhase())){
|
||||
eleEpdPqd.setPhase("M");
|
||||
eleEpdPqd.setPhase("T");
|
||||
}
|
||||
eleEpdPqd.setStatus(1);
|
||||
boolean result = this.save(eleEpdPqd);
|
||||
@@ -118,7 +118,7 @@ public class EleEpdPqdServiceImpl extends ServiceImpl<EleEpdPqdMapper, EleEpdPqd
|
||||
eleEpdPqd.setStatMethod(String.join(",", updateParam.getStatMethod()));
|
||||
}
|
||||
if (Objects.isNull(updateParam.getPhase())){
|
||||
eleEpdPqd.setPhase("M");
|
||||
eleEpdPqd.setPhase("T");
|
||||
}
|
||||
boolean result = this.updateById(eleEpdPqd);
|
||||
if (result) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FrontLogsCleanTaskRunner implements TimerTaskRunner {
|
||||
QueryWrapper<PqFrontLogsChild> queryWrapper = new QueryWrapper<>();
|
||||
QueryWrapper<PqFrontLogs> pqFrontLogsQueryWrapper = new QueryWrapper<>();
|
||||
LocalDate calDate;
|
||||
if(StrUtil.isBlank(date)){
|
||||
if(!StrUtil.isBlank(date)){
|
||||
calDate = LocalDate.parse(date, DatePattern.NORM_DATE_FORMATTER);
|
||||
|
||||
}else {
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:母线算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class GeneraTrixTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
}else {
|
||||
baseParam.setDataDate(date);
|
||||
}
|
||||
liteFlowFeignClient.generaTrixExecutor(baseParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:母线算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class GeneraTrixTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// }else {
|
||||
// baseParam.setDataDate(date);
|
||||
// }
|
||||
// liteFlowFeignClient.generaTrixExecutor(baseParam);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:监测点算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class MeasurementHourTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
//由于是按小时跑的,前端其他算法都是按天跑的,因此修改参数
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setRepair(false);
|
||||
baseParam.setDataDate(DateUtil.now());
|
||||
}else {
|
||||
baseParam.setRepair(true);
|
||||
baseParam.setBeginTime(date+ " 00:00:00");
|
||||
baseParam.setEndTime(date+ " 24:00:00");
|
||||
}
|
||||
liteFlowFeignClient.measurementPointExecutorByHour(baseParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:监测点算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class MeasurementHourTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// //由于是按小时跑的,前端其他算法都是按天跑的,因此修改参数
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setRepair(false);
|
||||
// baseParam.setDataDate(DateUtil.now());
|
||||
// }else {
|
||||
// baseParam.setRepair(true);
|
||||
// baseParam.setBeginTime(date+ " 00:00:00");
|
||||
// baseParam.setEndTime(date+ " 24:00:00");
|
||||
// }
|
||||
// liteFlowFeignClient.measurementPointExecutorByHour(baseParam);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -21,8 +20,6 @@ import org.springframework.stereotype.Component;
|
||||
@RequiredArgsConstructor
|
||||
public class MeasurementTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
private final LiteFlowAlgorithmFeignClient liteFlowAlgorithmFeignClient;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:监测点算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OrgSubStationTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
}else {
|
||||
baseParam.setDataDate(date);
|
||||
}
|
||||
liteFlowFeignClient.orgSubStationExecutor(baseParam);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:监测点算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class OrgSubStationTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// }else {
|
||||
// baseParam.setDataDate(date);
|
||||
// }
|
||||
// liteFlowFeignClient.orgSubStationExecutor(baseParam);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:单位监测点算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class OrgTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowAlgorithmFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
}else {
|
||||
baseParam.setDataDate(date);
|
||||
}
|
||||
liteFlowFeignClient.orgPointExecutor(baseParam);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
//import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:单位监测点算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class OrgTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowAlgorithmFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// }else {
|
||||
// baseParam.setDataDate(date);
|
||||
// }
|
||||
// liteFlowFeignClient.orgPointExecutor(baseParam);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类的介绍:变电站母线算法执行链定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/6 9:35
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PmsDimTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
if(StrUtil.isBlank(date)){
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
}else {
|
||||
baseParam.setDataDate(date);
|
||||
}
|
||||
liteFlowFeignClient.pmsDimExecutor(baseParam);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:变电站母线算法执行链定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/6 9:35
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class PmsDimTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// }else {
|
||||
// baseParam.setDataDate(date);
|
||||
// }
|
||||
// liteFlowFeignClient.pmsDimExecutor(baseParam);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.prepare.harmonic.api.upload.DimBusGlobalFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2024/4/17
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class PmsRunStatisticTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final DimBusGlobalFeignClient dimBusGlobalFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
if(StrUtil.isBlank(date)){
|
||||
date = DateUtil.format(DateUtil.yesterday(),DatePattern.NORM_DATE_PATTERN);
|
||||
}
|
||||
dimBusGlobalFeignClient.runLedgerStatistic(date);
|
||||
dimBusGlobalFeignClient.dimBusUpEveryDay(date);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
//import com.njcn.prepare.harmonic.api.upload.DimBusGlobalFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * pqs
|
||||
// *
|
||||
// * @author cdf
|
||||
// * @date 2024/4/17
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class PmsRunStatisticTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final DimBusGlobalFeignClient dimBusGlobalFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// if(StrUtil.isBlank(date)){
|
||||
// date = DateUtil.format(DateUtil.yesterday(),DatePattern.NORM_DATE_PATTERN);
|
||||
// }
|
||||
// dimBusGlobalFeignClient.runLedgerStatistic(date);
|
||||
// dimBusGlobalFeignClient.dimBusUpEveryDay(date);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.prepare.harmonic.api.newalgorithm.PmsStatisticsSpecialMonitorFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:专项分析-台账统计定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/08 11:23
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class PmsStatisticsSpecialMonitorTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final PmsStatisticsSpecialMonitorFeignClient pmsStatisticsSpecialMonitorFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
log.info(LocalDateTime.now()+"专项分析-台账统计调度开始");
|
||||
LineParam lineParam = new LineParam();
|
||||
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
pmsStatisticsSpecialMonitorFeignClient.pmsStatisticsSpecialMonitorHandler(lineParam);
|
||||
}
|
||||
|
||||
public String prepareTimeDeal(String command) {
|
||||
if (StrUtil.isBlank(command)) {
|
||||
log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
int nowMonth = calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/9/20
|
||||
*/
|
||||
public void commDefineDate(String command, LineParam lineParam) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String begin;
|
||||
String end;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date temDate = calendar.getTime();
|
||||
switch (command) {
|
||||
case BizParamConstant.STAT_BIZ_DAY:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_WEEK:
|
||||
begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_MONTH:
|
||||
begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_YEAR:
|
||||
begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
break;
|
||||
default:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
}
|
||||
lineParam.setBeginTime(begin);
|
||||
lineParam.setEndTime(end);
|
||||
lineParam.setDataDate(begin.substring(0, 10));
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
//import com.njcn.prepare.harmonic.api.newalgorithm.PmsStatisticsSpecialMonitorFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:专项分析-台账统计定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/08 11:23
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class PmsStatisticsSpecialMonitorTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final PmsStatisticsSpecialMonitorFeignClient pmsStatisticsSpecialMonitorFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// log.info(LocalDateTime.now()+"专项分析-台账统计调度开始");
|
||||
// LineParam lineParam = new LineParam();
|
||||
// lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
// pmsStatisticsSpecialMonitorFeignClient.pmsStatisticsSpecialMonitorHandler(lineParam);
|
||||
// }
|
||||
//
|
||||
// public String prepareTimeDeal(String command) {
|
||||
// if (StrUtil.isBlank(command)) {
|
||||
// log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
// return null;
|
||||
// }
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
// int nowMonth = calendar.get(Calendar.MONTH);
|
||||
// calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
// calendar.set(Calendar.MINUTE, 0);
|
||||
// calendar.set(Calendar.SECOND, 0);
|
||||
// calendar.set(Calendar.MILLISECOND, 0);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
// }
|
||||
// log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
// return sdf.format(calendar.getTime());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
// *
|
||||
// * @author cdf
|
||||
// * @date 2023/9/20
|
||||
// */
|
||||
// public void commDefineDate(String command, LineParam lineParam) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String begin;
|
||||
// String end;
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// Date temDate = calendar.getTime();
|
||||
// switch (command) {
|
||||
// case BizParamConstant.STAT_BIZ_DAY:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_WEEK:
|
||||
// begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
// end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_MONTH:
|
||||
// begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
// end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
// begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
// end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_YEAR:
|
||||
// begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
// end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
// break;
|
||||
// default:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// }
|
||||
// lineParam.setBeginTime(begin);
|
||||
// lineParam.setEndTime(end);
|
||||
// lineParam.setDataDate(begin.substring(0, 10));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.prepare.harmonic.api.newalgorithm.RMpEmissionFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:发射特性定时任务
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/20 13:55
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class RMpEmissionTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final RMpEmissionFeignClient rMpEmissionFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
log.info(LocalDateTime.now()+"发射特性调度开始");
|
||||
LineParam lineParam = new LineParam();
|
||||
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
rMpEmissionFeignClient.rMpEmissionMHandler(lineParam);
|
||||
}
|
||||
|
||||
public String prepareTimeDeal(String command) {
|
||||
if (StrUtil.isBlank(command)) {
|
||||
log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
int nowMonth = calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/9/20
|
||||
*/
|
||||
public void commDefineDate(String command, LineParam lineParam) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String begin;
|
||||
String end;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date temDate = calendar.getTime();
|
||||
switch (command) {
|
||||
case BizParamConstant.STAT_BIZ_DAY:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_WEEK:
|
||||
begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_MONTH:
|
||||
begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_YEAR:
|
||||
begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
break;
|
||||
default:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
}
|
||||
lineParam.setBeginTime(begin);
|
||||
lineParam.setEndTime(end);
|
||||
lineParam.setDataDate(begin.substring(0, 10));
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
//import com.njcn.prepare.harmonic.api.newalgorithm.RMpEmissionFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:发射特性定时任务
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/20 13:55
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class RMpEmissionTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final RMpEmissionFeignClient rMpEmissionFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// log.info(LocalDateTime.now()+"发射特性调度开始");
|
||||
// LineParam lineParam = new LineParam();
|
||||
// lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
// rMpEmissionFeignClient.rMpEmissionMHandler(lineParam);
|
||||
// }
|
||||
//
|
||||
// public String prepareTimeDeal(String command) {
|
||||
// if (StrUtil.isBlank(command)) {
|
||||
// log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
// return null;
|
||||
// }
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
// int nowMonth = calendar.get(Calendar.MONTH);
|
||||
// calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
// calendar.set(Calendar.MINUTE, 0);
|
||||
// calendar.set(Calendar.SECOND, 0);
|
||||
// calendar.set(Calendar.MILLISECOND, 0);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
// }
|
||||
// log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
// return sdf.format(calendar.getTime());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
// *
|
||||
// * @author cdf
|
||||
// * @date 2023/9/20
|
||||
// */
|
||||
// public void commDefineDate(String command, LineParam lineParam) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String begin;
|
||||
// String end;
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// Date temDate = calendar.getTime();
|
||||
// switch (command) {
|
||||
// case BizParamConstant.STAT_BIZ_DAY:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_WEEK:
|
||||
// begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
// end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_MONTH:
|
||||
// begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
// end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
// begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
// end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_YEAR:
|
||||
// begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
// end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
// break;
|
||||
// default:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// }
|
||||
// lineParam.setBeginTime(begin);
|
||||
// lineParam.setEndTime(end);
|
||||
// lineParam.setDataDate(begin.substring(0, 10));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.prepare.harmonic.api.newalgorithm.RMpInfluenceFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/20 14:12
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class RMpInfluenceTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final RMpInfluenceFeignClient rMpInfluenceFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
log.info(LocalDateTime.now()+"影响特性调度开始");
|
||||
LineParam lineParam = new LineParam();
|
||||
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
rMpInfluenceFeignClient.rMpInfluenceMHandler(lineParam);
|
||||
}
|
||||
|
||||
public String prepareTimeDeal(String command) {
|
||||
if (StrUtil.isBlank(command)) {
|
||||
log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
int nowMonth = calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/9/20
|
||||
*/
|
||||
public void commDefineDate(String command, LineParam lineParam) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String begin;
|
||||
String end;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date temDate = calendar.getTime();
|
||||
switch (command) {
|
||||
case BizParamConstant.STAT_BIZ_DAY:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_WEEK:
|
||||
begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_MONTH:
|
||||
begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_YEAR:
|
||||
begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
break;
|
||||
default:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
}
|
||||
lineParam.setBeginTime(begin);
|
||||
lineParam.setEndTime(end);
|
||||
lineParam.setDataDate(begin.substring(0, 10));
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
//import com.njcn.prepare.harmonic.api.newalgorithm.RMpInfluenceFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/20 14:12
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class RMpInfluenceTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final RMpInfluenceFeignClient rMpInfluenceFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// log.info(LocalDateTime.now()+"影响特性调度开始");
|
||||
// LineParam lineParam = new LineParam();
|
||||
// lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
// rMpInfluenceFeignClient.rMpInfluenceMHandler(lineParam);
|
||||
// }
|
||||
//
|
||||
// public String prepareTimeDeal(String command) {
|
||||
// if (StrUtil.isBlank(command)) {
|
||||
// log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
// return null;
|
||||
// }
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
// int nowMonth = calendar.get(Calendar.MONTH);
|
||||
// calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
// calendar.set(Calendar.MINUTE, 0);
|
||||
// calendar.set(Calendar.SECOND, 0);
|
||||
// calendar.set(Calendar.MILLISECOND, 0);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
// }
|
||||
// log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
// return sdf.format(calendar.getTime());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
// *
|
||||
// * @author cdf
|
||||
// * @date 2023/9/20
|
||||
// */
|
||||
// public void commDefineDate(String command, LineParam lineParam) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String begin;
|
||||
// String end;
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// Date temDate = calendar.getTime();
|
||||
// switch (command) {
|
||||
// case BizParamConstant.STAT_BIZ_DAY:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_WEEK:
|
||||
// begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
// end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_MONTH:
|
||||
// begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
// end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
// begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
// end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_YEAR:
|
||||
// begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
// end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
// break;
|
||||
// default:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// }
|
||||
// lineParam.setBeginTime(begin);
|
||||
// lineParam.setEndTime(end);
|
||||
// lineParam.setDataDate(begin.substring(0, 10));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
* 每日定时统计河北两级贯通接口主网数据,用于后续定时上送国网
|
||||
* @author cdf
|
||||
* @date 2024/2/22
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class UploadGwOrgAllRunner implements TimerTaskRunner {
|
||||
|
||||
private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
BaseParam baseParam = new BaseParam();
|
||||
baseParam.setFullChain(true);
|
||||
baseParam.setRepair(false);
|
||||
baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
liteFlowFeignClient.uploadOrgExecutor(baseParam);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import com.njcn.prepare.harmonic.api.liteflow.LiteFlowFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.bo.BaseParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * pqs
|
||||
// * 每日定时统计河北两级贯通接口主网数据,用于后续定时上送国网
|
||||
// * @author cdf
|
||||
// * @date 2024/2/22
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class UploadGwOrgAllRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final LiteFlowFeignClient liteFlowFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// BaseParam baseParam = new BaseParam();
|
||||
// baseParam.setFullChain(true);
|
||||
// baseParam.setRepair(false);
|
||||
// baseParam.setDataDate(DateUtil.yesterday().toString(DatePattern.NORM_DATE_PATTERN));
|
||||
// liteFlowFeignClient.uploadOrgExecutor(baseParam);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package com.njcn.system.timer.tasks.energy;
|
||||
|
||||
|
||||
import com.njcn.energy.pojo.api.EleAirStrategyFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AirControllerRunner implements TimerTaskRunner {
|
||||
|
||||
private final EleAirStrategyFeignClient eleAirStrategyFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
eleAirStrategyFeignClient.dealAirStrategyId("close");
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks.energy;
|
||||
//
|
||||
//
|
||||
//import com.njcn.energy.pojo.api.EleAirStrategyFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class AirControllerRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final EleAirStrategyFeignClient eleAirStrategyFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// eleAirStrategyFeignClient.dealAirStrategyId("close");
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.njcn.system.timer.tasks.energy;
|
||||
|
||||
import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class EleIntegrityRunner implements TimerTaskRunner {
|
||||
|
||||
private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
energyStatisticFeignClient.eleIntegrityJobHandler();
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks.energy;
|
||||
//
|
||||
//import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class EleIntegrityRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// energyStatisticFeignClient.eleIntegrityJobHandler();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package com.njcn.system.timer.tasks.energy;
|
||||
|
||||
import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class EleOnlineRateRunner implements TimerTaskRunner {
|
||||
|
||||
private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
energyStatisticFeignClient.eleOnlineRateJobHandler();
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks.energy;
|
||||
//
|
||||
//import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class EleOnlineRateRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// energyStatisticFeignClient.eleOnlineRateJobHandler();
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.njcn.system.timer.tasks.energy;
|
||||
|
||||
|
||||
import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class EnergyStatisticRunner implements TimerTaskRunner {
|
||||
|
||||
private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
|
||||
energyStatisticFeignClient.electricCalJob();
|
||||
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks.energy;
|
||||
//
|
||||
//
|
||||
//import com.njcn.energy.pojo.api.EnergyStatisticFeignClient;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//public class EnergyStatisticRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final EnergyStatisticFeignClient energyStatisticFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
//
|
||||
// energyStatisticFeignClient.electricCalJob();
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
package com.njcn.system.timer.tasks.report;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.harmonic.api.ReportFeignClient;
|
||||
import com.njcn.prepare.harmonic.api.line.CustomReportFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 自定义报表预处理
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class CustomReportRunner implements TimerTaskRunner {
|
||||
|
||||
private final CustomReportFeignClient customReportFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
LineParam lineParam = new LineParam();
|
||||
if(StrUtil.isNotBlank(date)){
|
||||
lineParam.setDataDate(date);
|
||||
}else {
|
||||
DateTime dealDate = DateUtil.yesterday();
|
||||
String end = DateUtil.format(dealDate, DatePattern.NORM_DATE_PATTERN);
|
||||
lineParam.setDataDate(end);
|
||||
}
|
||||
customReportFeignClient.batchReport(lineParam);
|
||||
}
|
||||
}
|
||||
//package com.njcn.system.timer.tasks.report;
|
||||
//
|
||||
//import cn.hutool.core.date.DatePattern;
|
||||
//import cn.hutool.core.date.DateTime;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.harmonic.api.ReportFeignClient;
|
||||
//import com.njcn.prepare.harmonic.api.line.CustomReportFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * 自定义报表预处理
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class CustomReportRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final CustomReportFeignClient customReportFeignClient;
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// LineParam lineParam = new LineParam();
|
||||
// if(StrUtil.isNotBlank(date)){
|
||||
// lineParam.setDataDate(date);
|
||||
// }else {
|
||||
// DateTime dealDate = DateUtil.yesterday();
|
||||
// String end = DateUtil.format(dealDate, DatePattern.NORM_DATE_PATTERN);
|
||||
// lineParam.setDataDate(end);
|
||||
// }
|
||||
// customReportFeignClient.batchReport(lineParam);
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,113 +1,113 @@
|
||||
package com.njcn.system.timer.tasks;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.prepare.harmonic.api.specialanalysis.SpecialAnalysisFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
import com.njcn.system.timer.TimerTaskRunner;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/12/20 14:15
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class specialAnalysisIndexOverviewTaskRunner implements TimerTaskRunner {
|
||||
|
||||
private final SpecialAnalysisFeignClient specialAnalysisFeignClient;
|
||||
|
||||
@Override
|
||||
public void action(String date) {
|
||||
log.info(LocalDateTime.now()+"专项分析-指标总览开始执行");
|
||||
LineParam lineParam = new LineParam();
|
||||
lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
specialAnalysisFeignClient.hanlder(lineParam);
|
||||
}
|
||||
|
||||
public String prepareTimeDeal(String command) {
|
||||
if (StrUtil.isBlank(command)) {
|
||||
log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
return null;
|
||||
}
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
int nowMonth = calendar.get(Calendar.MONTH);
|
||||
calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
} else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
}
|
||||
log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
return sdf.format(calendar.getTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/9/20
|
||||
*/
|
||||
public void commDefineDate(String command, LineParam lineParam) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String begin;
|
||||
String end;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
Date temDate = calendar.getTime();
|
||||
switch (command) {
|
||||
case BizParamConstant.STAT_BIZ_DAY:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_WEEK:
|
||||
begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_MONTH:
|
||||
begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
break;
|
||||
case BizParamConstant.STAT_BIZ_YEAR:
|
||||
begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
break;
|
||||
default:
|
||||
begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
break;
|
||||
}
|
||||
lineParam.setBeginTime(begin);
|
||||
lineParam.setEndTime(end);
|
||||
lineParam.setDataDate(begin.substring(0, 10));
|
||||
}
|
||||
|
||||
}
|
||||
//package com.njcn.system.timer.tasks;
|
||||
//
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
//import com.njcn.prepare.harmonic.api.specialanalysis.SpecialAnalysisFeignClient;
|
||||
//import com.njcn.prepare.harmonic.pojo.param.LineParam;
|
||||
//import com.njcn.system.timer.TimerTaskRunner;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.time.LocalDateTime;
|
||||
//import java.util.Calendar;
|
||||
//import java.util.Date;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * 类的介绍:
|
||||
// *
|
||||
// * @author xuyang
|
||||
// * @version 1.0.0
|
||||
// * @createTime 2023/12/20 14:15
|
||||
// */
|
||||
//@Component
|
||||
//@RequiredArgsConstructor
|
||||
//@Slf4j
|
||||
//public class specialAnalysisIndexOverviewTaskRunner implements TimerTaskRunner {
|
||||
//
|
||||
// private final SpecialAnalysisFeignClient specialAnalysisFeignClient;
|
||||
//
|
||||
// @Override
|
||||
// public void action(String date) {
|
||||
// log.info(LocalDateTime.now()+"专项分析-指标总览开始执行");
|
||||
// LineParam lineParam = new LineParam();
|
||||
// lineParam.setType(Integer.valueOf(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// lineParam.setDataDate(this.prepareTimeDeal(BizParamConstant.STAT_BIZ_MONTH));
|
||||
// this.commDefineDate(BizParamConstant.STAT_BIZ_MONTH,lineParam);
|
||||
// specialAnalysisFeignClient.hanlder(lineParam);
|
||||
// }
|
||||
//
|
||||
// public String prepareTimeDeal(String command) {
|
||||
// if (StrUtil.isBlank(command)) {
|
||||
// log.error(LocalDateTime.now() + "xxl调度任务参数未设置");
|
||||
// return null;
|
||||
// }
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// if (Objects.equals(BizParamConstant.STAT_BIZ_DAY, command)) {
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_MONTH, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_QUARTER, command)) {
|
||||
// int nowMonth = calendar.get(Calendar.MONTH);
|
||||
// calendar.set(Calendar.MONTH, nowMonth - (nowMonth % 3));
|
||||
// calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||
// calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
// calendar.set(Calendar.MINUTE, 0);
|
||||
// calendar.set(Calendar.SECOND, 0);
|
||||
// calendar.set(Calendar.MILLISECOND, 0);
|
||||
// } else if (Objects.equals(BizParamConstant.STAT_BIZ_YEAR, command)) {
|
||||
// calendar.set(Calendar.DAY_OF_YEAR, 1);
|
||||
// }
|
||||
// log.info("job调度时间:" + sdf.format(calendar.getTime()));
|
||||
// return sdf.format(calendar.getTime());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据xxl-job的参数,生成一个任务的起始时间和结束时间
|
||||
// *
|
||||
// * @author cdf
|
||||
// * @date 2023/9/20
|
||||
// */
|
||||
// public void commDefineDate(String command, LineParam lineParam) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// String begin;
|
||||
// String end;
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// calendar.add(Calendar.DAY_OF_MONTH, -1);
|
||||
// Date temDate = calendar.getTime();
|
||||
// switch (command) {
|
||||
// case BizParamConstant.STAT_BIZ_DAY:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_WEEK:
|
||||
// begin = sdf.format(DateUtil.beginOfWeek(temDate));
|
||||
// end = sdf.format(DateUtil.endOfWeek(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_MONTH:
|
||||
// begin = sdf.format(DateUtil.beginOfMonth(temDate));
|
||||
// end = sdf.format(DateUtil.endOfMonth(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_QUARTER:
|
||||
// begin = sdf.format(DateUtil.beginOfQuarter(temDate));
|
||||
// end = sdf.format(DateUtil.endOfQuarter(temDate));
|
||||
// break;
|
||||
// case BizParamConstant.STAT_BIZ_YEAR:
|
||||
// begin = sdf.format(DateUtil.beginOfYear(temDate));
|
||||
// end = sdf.format(DateUtil.endOfYear(temDate));
|
||||
// break;
|
||||
// default:
|
||||
// begin = sdf.format(DateUtil.beginOfDay(temDate));
|
||||
// end = sdf.format(DateUtil.endOfDay(temDate));
|
||||
// break;
|
||||
// }
|
||||
// lineParam.setBeginTime(begin);
|
||||
// lineParam.setEndTime(end);
|
||||
// lineParam.setDataDate(begin.substring(0, 10));
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.user.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.user.api.fallback.SmsSendClientFallbackFactory;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.USER, path = "/sms", fallbackFactory = SmsSendClientFallbackFactory.class,contextId = "sms")
|
||||
public interface SmsSendFeignClient {
|
||||
|
||||
@PostMapping("/send/simple")
|
||||
@ApiOperation("发送短信(简化参数)")
|
||||
HttpResult<String> sendSmsSimple(@RequestParam("receiver") String receiver
|
||||
, @RequestParam("content") String content
|
||||
, @RequestParam("messageType") String messageType);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.user.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.user.api.SmsSendFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class SmsSendClientFallbackFactory implements FallbackFactory<SmsSendFeignClient> {
|
||||
@Override
|
||||
public SmsSendFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new SmsSendFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<String> sendSmsSimple(String receiver, String content, String messageType) {
|
||||
log.error("{}异常,降级处理,异常为:{}","发送短信(简化参数)数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.user.pojo.dto;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-03-31
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统凭证请求 DTO
|
||||
*
|
||||
* @author msgpush
|
||||
*/
|
||||
@Data
|
||||
public class CredentialReqDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 上游系统名称
|
||||
*/
|
||||
@NotEmpty(message = "上游系统名称不能为空")
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 密钥(用于生成凭证)
|
||||
*/
|
||||
@NotEmpty(message = "密钥不能为空")
|
||||
private String secretKey;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.user.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class SendResult implements Serializable {
|
||||
|
||||
private final boolean success;
|
||||
private final String messageId;
|
||||
private final String failReason;
|
||||
private final boolean isTimeOut;
|
||||
private final boolean unauthorized;
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user