细节调整
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.njcn.event.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -55,7 +56,7 @@ public class TransientServiceImpl implements TransientService {
|
||||
|
||||
private final EventDetailService eventDetailService;
|
||||
|
||||
private final EventBaseConfig eventBaseConfig;
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
@Override
|
||||
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
||||
@@ -64,14 +65,16 @@ public class TransientServiceImpl implements TransientService {
|
||||
page.setCurrent(transientParam.getPageNum());
|
||||
List<TransientVO> transientVOS = new ArrayList<>();
|
||||
transientParam.setServerName(ServerEnum.HARMONIC.getName());
|
||||
//按部门分类的实际运行终端综合信息
|
||||
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
||||
if (!CollectionUtils.isEmpty(deviceList)) {
|
||||
List<List<String>> lists = deviceList.stream().map(GeneralDeviceDTO::getLineIndexes).collect(Collectors.toList());
|
||||
//获取按终端分类的监测点索引集合
|
||||
List<List<String>> LineIndexes = deviceList.stream().map(GeneralDeviceDTO::getLineIndexes).collect(Collectors.toList());
|
||||
List<String> lineList = new ArrayList<>();
|
||||
for (int i = 0; i < lists.size(); i++) {
|
||||
List<String> strings1 = lists.get(i);
|
||||
for (int a = 0; a < strings1.size(); a++) {
|
||||
lineList.add(strings1.get(a));
|
||||
for (int i = 0; i < LineIndexes.size(); i++) {
|
||||
List<String> lineIds = LineIndexes.get(i);
|
||||
for (int a = 0; a < lineIds.size(); a++) {
|
||||
lineList.add(lineIds.get(a));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(lineList)) {
|
||||
@@ -86,9 +89,9 @@ public class TransientServiceImpl implements TransientService {
|
||||
// List<List<EventDetail>> partition = Lists.partition(eventDetailData, transientParam.getPageSize());
|
||||
// List<EventDetail> detailList = partition.get(transientParam.getPageNum() - 1);
|
||||
if (!CollectionUtils.isEmpty(eventDetailData)) {
|
||||
List<String> collect = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
||||
collect = collect.stream().distinct().collect(Collectors.toList());
|
||||
List<TransientVO> transientData = transientMapper.getTransientData(collect);
|
||||
List<String> lineIds = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
||||
lineIds = lineIds.stream().distinct().collect(Collectors.toList());
|
||||
List<TransientVO> transientData = transientMapper.getTransientData(lineIds);
|
||||
int i = 1;
|
||||
for (EventDetail eventDetail : eventDetailData) {
|
||||
if (!Objects.isNull(eventDetail)) {
|
||||
@@ -126,15 +129,14 @@ public class TransientServiceImpl implements TransientService {
|
||||
transientVO.setTrigType("录波");
|
||||
break;
|
||||
}
|
||||
Double value = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
transientVO.setEventValue(new BigDecimal(value * 100).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||
Double eventValue = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
transientVO.setEventValue(new BigDecimal(eventValue * 100).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||
transientVO.setEventValues(100 - transientVO.getEventValue());
|
||||
transientVO.setPersistTime((Float.parseFloat(eventDetail.getPersistTime().toString())) / 1000);
|
||||
|
||||
Float eventValue = Float.parseFloat(eventDetail.getEventValue().toString());
|
||||
Float persistTime = Float.parseFloat(eventDetail.getPersistTime().toString());
|
||||
|
||||
transientVO.setYZD(getYZD(persistTime, eventValue));
|
||||
transientVO.setYZD(getYZD(Float.parseFloat(eventDetail.getPersistTime().toString()),
|
||||
Float.parseFloat(eventDetail.getEventValue().toString()))
|
||||
);
|
||||
transientVOS.add(transientVO);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +176,7 @@ public class TransientServiceImpl implements TransientService {
|
||||
// waveDataVO.setName("变电站名称: "+ substation +" 监测点名称: "+ name +" 发生时刻: "+ timeId +" 暂降幅值: "+ v +"% 持续时间: "+ persistTime +"s");
|
||||
// waveDataVO.setTargetName("相电压有效值");
|
||||
AnalyWave analyWave = new AnalyWave();
|
||||
WaveDataDTO comtrade = analyWave.getComtrade(eventBaseConfig.getWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
||||
WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}
|
||||
@@ -196,9 +198,9 @@ public class TransientServiceImpl implements TransientService {
|
||||
List<String> lineId = waveFileParam.getLineId();
|
||||
List<String> timeId = waveFileParam.getTimeId();
|
||||
copyTempData(timeId, lineId);
|
||||
zipCompress(new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade"));
|
||||
zipCompress(new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade"));
|
||||
|
||||
String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade.zip";
|
||||
String zipPath = generalInfo.getBusinessTempPath() + File.separator + "comtrade.zip";
|
||||
try {
|
||||
// path是指欲下载的文件的路径。
|
||||
File file = new File(zipPath);
|
||||
@@ -225,7 +227,7 @@ public class TransientServiceImpl implements TransientService {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
delFile(zipPath);
|
||||
deleteDirectoryLegacyIO(new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade"));
|
||||
deleteDirectoryLegacyIO(new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade"));
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -242,17 +244,17 @@ public class TransientServiceImpl implements TransientService {
|
||||
}
|
||||
String ip = lineDetailData.getIp();
|
||||
String waveName = eventDetailByTime.getWaveName();
|
||||
File srcCFGFile = new File(eventBaseConfig.getWavePath() + "\\" + ip + "\\" + waveName + ".CFG");
|
||||
File srcDATFile = new File(eventBaseConfig.getWavePath() + "\\" + ip + "\\" + waveName + ".DAT");
|
||||
File srcCFGFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG");
|
||||
File srcDATFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".DAT");
|
||||
if (!srcCFGFile.exists() && !srcDATFile.exists()) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}
|
||||
File temp = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\" + ip);
|
||||
File temp = new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade" + File.separator + ip);
|
||||
temp.mkdirs();
|
||||
// File cfg = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\a1234567890\\"+srcCFGFile.getName());
|
||||
// File dat = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\a1234567890\\"+srcDATFile.getName());
|
||||
File cfg = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\" + ip + "\\" + srcCFGFile.getName());
|
||||
File dat = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\" + ip + "\\" + srcDATFile.getName());
|
||||
File cfg = new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade" + File.separator + ip + File.separator + srcCFGFile.getName());
|
||||
File dat = new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade" + File.separator + ip + File.separator + srcDATFile.getName());
|
||||
|
||||
writeFile(srcCFGFile, cfg);
|
||||
writeFile(srcDATFile, dat);
|
||||
@@ -274,8 +276,6 @@ public class TransientServiceImpl implements TransientService {
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================================================
|
||||
|
||||
/**
|
||||
* 将文件夹及文件夹包含的内容压缩成zip文件
|
||||
* (为了解决中文乱码的问题,ZipOutputStream用org.apache.tools.zip.*)
|
||||
@@ -387,56 +387,51 @@ public class TransientServiceImpl implements TransientService {
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================================================
|
||||
|
||||
/**
|
||||
* 处理文件路径和指定压缩包位置
|
||||
*/
|
||||
public static String downloadWaveMoreFile(List<String> pathList) {
|
||||
List<File> list = new ArrayList<>();
|
||||
for (String string : pathList) {
|
||||
String path = string;
|
||||
//待压缩的多个源文件
|
||||
File f1 = new File(path + ".CFG");
|
||||
File f2 = new File(path + ".DAT");
|
||||
list.add(f1);
|
||||
list.add(f2);
|
||||
}
|
||||
File[] srcfile = list.toArray(new File[0]);
|
||||
String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\新下载的波形文件.zip";
|
||||
//压缩后的文件存放路径
|
||||
File zipfile = new File(zipPath);
|
||||
zipFiles(srcfile, zipfile);
|
||||
return zipPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 压缩多个文件成一个zip文件
|
||||
*
|
||||
* @param srcfile:源文件列表
|
||||
* @param zipfile:压缩后的文件
|
||||
*/
|
||||
public static void zipFiles(File[] srcfile, File zipfile) {
|
||||
byte[] buf = new byte[1024];
|
||||
try {
|
||||
//ZipOutputStream类:完成文件或文件夹的压缩
|
||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
|
||||
for (int i = 0; i < srcfile.length; i++) {
|
||||
FileInputStream in = new FileInputStream(srcfile[i]);
|
||||
out.putNextEntry(new ZipEntry(srcfile[i].getName()));
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0) {
|
||||
out.write(buf, 0, len);
|
||||
}
|
||||
out.closeEntry();
|
||||
in.close();
|
||||
}
|
||||
out.close();
|
||||
System.out.println("压缩完成.");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// /**处理文件路径和指定压缩包位置 */
|
||||
// public static String downloadWaveMoreFile(List<String> pathList) {
|
||||
// List<File> list = new ArrayList<>();
|
||||
// for (String string: pathList) {
|
||||
// String path = string;
|
||||
// //待压缩的多个源文件
|
||||
// File f1 = new File(path+".CFG");
|
||||
// File f2 = new File(path+".DAT");
|
||||
// list.add(f1);
|
||||
// list.add(f2);
|
||||
// }
|
||||
// File[] srcfile = list.toArray(new File[0]);
|
||||
// String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\新下载的波形文件.zip";
|
||||
// //压缩后的文件存放路径
|
||||
// File zipfile = new File(zipPath);
|
||||
// zipFiles(srcfile, zipfile);
|
||||
// return zipPath;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 压缩多个文件成一个zip文件
|
||||
// * @param srcfile:源文件列表
|
||||
// * @param zipfile:压缩后的文件
|
||||
// */
|
||||
// public static void zipFiles(File[] srcfile, File zipfile) {
|
||||
// byte[] buf = new byte[1024];
|
||||
// try {
|
||||
// //ZipOutputStream类:完成文件或文件夹的压缩
|
||||
// ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
|
||||
// for (int i = 0; i < srcfile.length; i++) {
|
||||
// FileInputStream in = new FileInputStream(srcfile[i]);
|
||||
// out.putNextEntry(new ZipEntry(srcfile[i].getName()));
|
||||
// int len;
|
||||
// while ((len = in.read(buf)) > 0) {
|
||||
// out.write(buf, 0, len);
|
||||
// }
|
||||
// out.closeEntry();
|
||||
// in.close();
|
||||
// }
|
||||
// out.close();
|
||||
// System.out.println("压缩完成.");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 删除文件(夹)和空文件夹
|
||||
|
||||
Reference in New Issue
Block a user