细节调整
This commit is contained in:
@@ -26,6 +26,8 @@ public class WaveDataDTO implements Serializable {
|
|||||||
private List<List<Float>> listWaveData;
|
private List<List<Float>> listWaveData;
|
||||||
//波形RMS值
|
//波形RMS值
|
||||||
private List<List<Float>> listRmsData;
|
private List<List<Float>> listRmsData;
|
||||||
|
//RMS最小值
|
||||||
|
private List<List<Float>> listRmsMinData;
|
||||||
//波形对应的相别数量
|
//波形对应的相别数量
|
||||||
private Integer iPhasic;
|
private Integer iPhasic;
|
||||||
//接线方式(0.星型接法;1.三角型接法;2.开口三角型接法)
|
//接线方式(0.星型接法;1.三角型接法;2.开口三角型接法)
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import com.njcn.common.pojo.dto.wave.*;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,13 +92,21 @@ public class AnalyWave {
|
|||||||
********************************/
|
********************************/
|
||||||
double iWave = 0 ;
|
double iWave = 0 ;
|
||||||
int nPhasic = 0;// 相别
|
int nPhasic = 0;// 相别
|
||||||
|
List<List<Float>> listRmsMin =new ArrayList<>();//存放RMS值的最小值
|
||||||
if(lstWave.size() > 0){
|
if(lstWave.size() > 0){
|
||||||
nPhasic = comtradeCfgDTO.getNPhasic();
|
nPhasic = comtradeCfgDTO.getNPhasic();
|
||||||
//ComtradeCfg.nAnalogNum为值的个数(-1的原因是一个存的是时间)
|
//ComtradeCfg.nAnalogNum为值的个数(-1的原因是一个存的是时间)
|
||||||
iWave = Math.floor((lstWave.get(0).size() -1) / nPhasic);
|
iWave = Math.floor((lstWave.get(0).size() -1) / nPhasic);
|
||||||
List<Float> tmpListRms;
|
List<Float> tmpListRms;
|
||||||
|
List<Float> tmpListRmsMin;
|
||||||
|
//增加RMS的最小值
|
||||||
|
double fMinTime = 0.0 , fMinValue = 0.0;
|
||||||
|
|
||||||
//每一项一项计算
|
//每一项一项计算
|
||||||
for(int j = 0; j < iWave; j ++){
|
for(int j = 0; j < iWave; j ++){
|
||||||
|
// 实例化
|
||||||
|
tmpListRmsMin = new ArrayList<>();
|
||||||
|
|
||||||
double fSumA = 0.0, fSumB= 0.0, fSumC = 0.0;
|
double fSumA = 0.0, fSumB= 0.0, fSumC = 0.0;
|
||||||
double fValidA = 0.0, fValidB = 0.0, fValidC = 0.0;
|
double fValidA = 0.0, fValidB = 0.0, fValidC = 0.0;
|
||||||
//循环原始数据
|
//循环原始数据
|
||||||
@@ -123,8 +133,22 @@ public class AnalyWave {
|
|||||||
}
|
}
|
||||||
fValidA = Math.sqrt(fSumA / HalfTs);
|
fValidA = Math.sqrt(fSumA / HalfTs);
|
||||||
|
|
||||||
tmpListRms.add((float) fValidA);
|
tmpListRms.add((float) (Math.round(fValidA * 100)) / 100);
|
||||||
listRms.set(i,tmpListRms);
|
listRms.set(i,tmpListRms);
|
||||||
|
|
||||||
|
// 最小值判断
|
||||||
|
if (i >= HalfTs){
|
||||||
|
if(i == HalfTs){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(fValidA < fMinValue){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2);
|
fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2);
|
||||||
@@ -138,9 +162,27 @@ public class AnalyWave {
|
|||||||
fValidA = Math.sqrt(fSumA / HalfTs);
|
fValidA = Math.sqrt(fSumA / HalfTs);
|
||||||
fValidB = Math.sqrt(fSumB / HalfTs);
|
fValidB = Math.sqrt(fSumB / HalfTs);
|
||||||
|
|
||||||
tmpListRms.add((float) fValidA);
|
tmpListRms.add((float) (Math.round(fValidA * 100)) / 100);
|
||||||
tmpListRms.add((float) fValidB);
|
tmpListRms.add((float) (Math.round(fValidB * 100)) / 100);
|
||||||
listRms.set(i,tmpListRms);
|
listRms.set(i,tmpListRms);
|
||||||
|
|
||||||
|
// 最小值判断
|
||||||
|
if (i >= HalfTs){
|
||||||
|
if(i == HalfTs){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(fValidA < fMinValue){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
if(fValidB < fMinValue){
|
||||||
|
fMinValue = fValidB;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2);
|
fSumA += Math.pow(tmpListValue.get(1 + nPhasic * j), 2);
|
||||||
@@ -157,14 +199,41 @@ public class AnalyWave {
|
|||||||
fValidB = Math.sqrt(fSumB / HalfTs);
|
fValidB = Math.sqrt(fSumB / HalfTs);
|
||||||
fValidC = Math.sqrt(fSumC / HalfTs);
|
fValidC = Math.sqrt(fSumC / HalfTs);
|
||||||
|
|
||||||
tmpListRms.add((float) fValidA);
|
tmpListRms.add((float) (Math.round(fValidA * 100)) / 100);
|
||||||
tmpListRms.add((float) fValidB);
|
tmpListRms.add((float) (Math.round(fValidB * 100)) / 100);
|
||||||
tmpListRms.add((float) fValidC);
|
tmpListRms.add((float) (Math.round(fValidC * 100)) / 100);
|
||||||
listRms.set(i,tmpListRms);
|
listRms.set(i,tmpListRms);
|
||||||
|
|
||||||
|
// 最小值判断
|
||||||
|
if (i >= HalfTs){
|
||||||
|
if(i == HalfTs){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if(fValidA < fMinValue){
|
||||||
|
fMinValue = fValidA;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
if(fValidB < fMinValue){
|
||||||
|
fMinValue = fValidB;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
if(fValidC < fMinValue){
|
||||||
|
fMinValue = fValidC;
|
||||||
|
fMinTime = tmpListValue.get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//增加最小值时间,最小值
|
||||||
|
tmpListRmsMin.add((float)fMinTime);//获取时间
|
||||||
|
tmpListRmsMin.add((float)(Math.round(fMinValue * 100)) / 100);//获取时间
|
||||||
|
listRmsMin.add(tmpListRmsMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
//过滤前一个周波
|
//过滤前一个周波
|
||||||
@@ -199,6 +268,7 @@ public class AnalyWave {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
waveDataDTO.setListRmsData(listRms);
|
waveDataDTO.setListRmsData(listRms);
|
||||||
|
waveDataDTO.setListRmsMinData(listRmsMin);//RMS最小值
|
||||||
|
|
||||||
return waveDataDTO;
|
return waveDataDTO;
|
||||||
}
|
}
|
||||||
@@ -381,7 +451,7 @@ public class AnalyWave {
|
|||||||
|
|
||||||
long a = comtradeCfgDTO.getTimeStart().getTime();
|
long a = comtradeCfgDTO.getTimeStart().getTime();
|
||||||
long b = comtradeCfgDTO.getTimeTrige().getTime();
|
long b = comtradeCfgDTO.getTimeTrige().getTime();
|
||||||
int c = (int) (a - b);
|
int c = (int) (b - a);
|
||||||
if (c >= 90 && c <= 110) {
|
if (c >= 90 && c <= 110) {
|
||||||
comtradeCfgDTO.setNPush(100);
|
comtradeCfgDTO.setNPush(100);
|
||||||
} else if (c >= 190 && c <= 210) {
|
} else if (c >= 190 && c <= 210) {
|
||||||
@@ -1107,11 +1177,24 @@ public class AnalyWave {
|
|||||||
* iFlag == 2 App抽点要求,采样率抽点成32
|
* iFlag == 2 App抽点要求,采样率抽点成32
|
||||||
* iFlag == 3 高级算法原始波形(大于32)
|
* iFlag == 3 高级算法原始波形(大于32)
|
||||||
********************************************************/
|
********************************************************/
|
||||||
|
/** 输出格式: 2014-5-05 00:00:00 大写H为24小时制 */
|
||||||
|
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
String s = null;
|
||||||
|
Date d = new Date();
|
||||||
|
s = sdf.format(d);
|
||||||
|
System.out.println(s);
|
||||||
|
|
||||||
AnalyWave analyWave = new AnalyWave();
|
AnalyWave analyWave = new AnalyWave();
|
||||||
// 获取瞬时波形
|
// 获取瞬时波形
|
||||||
WaveDataDTO waveDataDTO = analyWave.getComtrade("C:\\Users\\陈超\\Desktop\\Comtrade\\192.168.0.58\\222.CFG", 1);//获取原始波形值
|
WaveDataDTO waveDataDTO = analyWave.getComtrade("D:\\Comtrade\\00-B7-8D-00-EA-4A\\PQMonitor_PQM1_001341_20220627_063159_104_WAV.CFG", 1);//获取原始波形值
|
||||||
|
d = new Date();
|
||||||
|
s = sdf.format(d);
|
||||||
|
System.out.println(s);
|
||||||
// 获取RMS波形
|
// 获取RMS波形
|
||||||
WaveDataDTO waveDataDTO1 = analyWave.getValidData(waveDataDTO);
|
WaveDataDTO waveDataDTO1 = analyWave.getValidData(waveDataDTO);
|
||||||
|
d = new Date();
|
||||||
|
s = sdf.format(d);
|
||||||
|
System.out.println(s);
|
||||||
// 获取特征值
|
// 获取特征值
|
||||||
List<EigenvalueDTO> lstEigenvalueDTO = analyWave.getEigenvalue(waveDataDTO,true);
|
List<EigenvalueDTO> lstEigenvalueDTO = analyWave.getEigenvalue(waveDataDTO,true);
|
||||||
String str = "";
|
String str = "";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.njcn.event.service.Impl;
|
package com.njcn.event.service.Impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.dto.wave.WaveDataDTO;
|
||||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
@@ -55,7 +56,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
|
|
||||||
private final EventDetailService eventDetailService;
|
private final EventDetailService eventDetailService;
|
||||||
|
|
||||||
private final EventBaseConfig eventBaseConfig;
|
private final GeneralInfo generalInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
||||||
@@ -64,14 +65,16 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
page.setCurrent(transientParam.getPageNum());
|
page.setCurrent(transientParam.getPageNum());
|
||||||
List<TransientVO> transientVOS = new ArrayList<>();
|
List<TransientVO> transientVOS = new ArrayList<>();
|
||||||
transientParam.setServerName(ServerEnum.HARMONIC.getName());
|
transientParam.setServerName(ServerEnum.HARMONIC.getName());
|
||||||
|
//按部门分类的实际运行终端综合信息
|
||||||
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalRunDeviceInfo(transientParam).getData();
|
||||||
if (!CollectionUtils.isEmpty(deviceList)) {
|
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<>();
|
List<String> lineList = new ArrayList<>();
|
||||||
for (int i = 0; i < lists.size(); i++) {
|
for (int i = 0; i < LineIndexes.size(); i++) {
|
||||||
List<String> strings1 = lists.get(i);
|
List<String> lineIds = LineIndexes.get(i);
|
||||||
for (int a = 0; a < strings1.size(); a++) {
|
for (int a = 0; a < lineIds.size(); a++) {
|
||||||
lineList.add(strings1.get(a));
|
lineList.add(lineIds.get(a));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(lineList)) {
|
if (!CollectionUtils.isEmpty(lineList)) {
|
||||||
@@ -86,9 +89,9 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
// List<List<EventDetail>> partition = Lists.partition(eventDetailData, transientParam.getPageSize());
|
// List<List<EventDetail>> partition = Lists.partition(eventDetailData, transientParam.getPageSize());
|
||||||
// List<EventDetail> detailList = partition.get(transientParam.getPageNum() - 1);
|
// List<EventDetail> detailList = partition.get(transientParam.getPageNum() - 1);
|
||||||
if (!CollectionUtils.isEmpty(eventDetailData)) {
|
if (!CollectionUtils.isEmpty(eventDetailData)) {
|
||||||
List<String> collect = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
List<String> lineIds = eventDetailData.stream().map(EventDetail::getLineId).collect(Collectors.toList());
|
||||||
collect = collect.stream().distinct().collect(Collectors.toList());
|
lineIds = lineIds.stream().distinct().collect(Collectors.toList());
|
||||||
List<TransientVO> transientData = transientMapper.getTransientData(collect);
|
List<TransientVO> transientData = transientMapper.getTransientData(lineIds);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (EventDetail eventDetail : eventDetailData) {
|
for (EventDetail eventDetail : eventDetailData) {
|
||||||
if (!Objects.isNull(eventDetail)) {
|
if (!Objects.isNull(eventDetail)) {
|
||||||
@@ -126,15 +129,14 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
transientVO.setTrigType("录波");
|
transientVO.setTrigType("录波");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Double value = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
Double eventValue = new BigDecimal(eventDetail.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
transientVO.setEventValue(new BigDecimal(value * 100).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue());
|
transientVO.setEventValue(new BigDecimal(eventValue * 100).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue());
|
||||||
transientVO.setEventValues(100 - transientVO.getEventValue());
|
transientVO.setEventValues(100 - transientVO.getEventValue());
|
||||||
transientVO.setPersistTime((Float.parseFloat(eventDetail.getPersistTime().toString())) / 1000);
|
transientVO.setPersistTime((Float.parseFloat(eventDetail.getPersistTime().toString())) / 1000);
|
||||||
|
|
||||||
Float eventValue = Float.parseFloat(eventDetail.getEventValue().toString());
|
transientVO.setYZD(getYZD(Float.parseFloat(eventDetail.getPersistTime().toString()),
|
||||||
Float persistTime = Float.parseFloat(eventDetail.getPersistTime().toString());
|
Float.parseFloat(eventDetail.getEventValue().toString()))
|
||||||
|
);
|
||||||
transientVO.setYZD(getYZD(persistTime, eventValue));
|
|
||||||
transientVOS.add(transientVO);
|
transientVOS.add(transientVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,7 +176,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
// waveDataVO.setName("变电站名称: "+ substation +" 监测点名称: "+ name +" 发生时刻: "+ timeId +" 暂降幅值: "+ v +"% 持续时间: "+ persistTime +"s");
|
// waveDataVO.setName("变电站名称: "+ substation +" 监测点名称: "+ name +" 发生时刻: "+ timeId +" 暂降幅值: "+ v +"% 持续时间: "+ persistTime +"s");
|
||||||
// waveDataVO.setTargetName("相电压有效值");
|
// waveDataVO.setTargetName("相电压有效值");
|
||||||
AnalyWave analyWave = new AnalyWave();
|
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())) {
|
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -196,9 +198,9 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
List<String> lineId = waveFileParam.getLineId();
|
List<String> lineId = waveFileParam.getLineId();
|
||||||
List<String> timeId = waveFileParam.getTimeId();
|
List<String> timeId = waveFileParam.getTimeId();
|
||||||
copyTempData(timeId, lineId);
|
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 {
|
try {
|
||||||
// path是指欲下载的文件的路径。
|
// path是指欲下载的文件的路径。
|
||||||
File file = new File(zipPath);
|
File file = new File(zipPath);
|
||||||
@@ -225,7 +227,7 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
delFile(zipPath);
|
delFile(zipPath);
|
||||||
deleteDirectoryLegacyIO(new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade"));
|
deleteDirectoryLegacyIO(new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade"));
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,17 +244,17 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
}
|
}
|
||||||
String ip = lineDetailData.getIp();
|
String ip = lineDetailData.getIp();
|
||||||
String waveName = eventDetailByTime.getWaveName();
|
String waveName = eventDetailByTime.getWaveName();
|
||||||
File srcCFGFile = new File(eventBaseConfig.getWavePath() + "\\" + ip + "\\" + waveName + ".CFG");
|
File srcCFGFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG");
|
||||||
File srcDATFile = new File(eventBaseConfig.getWavePath() + "\\" + ip + "\\" + waveName + ".DAT");
|
File srcDATFile = new File(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".DAT");
|
||||||
if (!srcCFGFile.exists() && !srcDATFile.exists()) {
|
if (!srcCFGFile.exists() && !srcDATFile.exists()) {
|
||||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
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();
|
temp.mkdirs();
|
||||||
// File cfg = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\a1234567890\\"+srcCFGFile.getName());
|
// 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 dat = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\a1234567890\\"+srcDATFile.getName());
|
||||||
File cfg = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\" + ip + "\\" + srcCFGFile.getName());
|
File cfg = new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade" + File.separator + ip + File.separator + srcCFGFile.getName());
|
||||||
File dat = new File("C:\\Users\\陈超\\Desktop\\YSWJ\\comtrade\\" + ip + "\\" + srcDATFile.getName());
|
File dat = new File(generalInfo.getBusinessTempPath() + File.separator + "comtrade" + File.separator + ip + File.separator + srcDATFile.getName());
|
||||||
|
|
||||||
writeFile(srcCFGFile, cfg);
|
writeFile(srcCFGFile, cfg);
|
||||||
writeFile(srcDATFile, dat);
|
writeFile(srcDATFile, dat);
|
||||||
@@ -274,8 +276,6 @@ public class TransientServiceImpl implements TransientService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================================================
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将文件夹及文件夹包含的内容压缩成zip文件
|
* 将文件夹及文件夹包含的内容压缩成zip文件
|
||||||
* (为了解决中文乱码的问题,ZipOutputStream用org.apache.tools.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;
|
||||||
public static String downloadWaveMoreFile(List<String> pathList) {
|
// //待压缩的多个源文件
|
||||||
List<File> list = new ArrayList<>();
|
// File f1 = new File(path+".CFG");
|
||||||
for (String string : pathList) {
|
// File f2 = new File(path+".DAT");
|
||||||
String path = string;
|
// list.add(f1);
|
||||||
//待压缩的多个源文件
|
// list.add(f2);
|
||||||
File f1 = new File(path + ".CFG");
|
// }
|
||||||
File f2 = new File(path + ".DAT");
|
// File[] srcfile = list.toArray(new File[0]);
|
||||||
list.add(f1);
|
// String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\新下载的波形文件.zip";
|
||||||
list.add(f2);
|
// //压缩后的文件存放路径
|
||||||
}
|
// File zipfile = new File(zipPath);
|
||||||
File[] srcfile = list.toArray(new File[0]);
|
// zipFiles(srcfile, zipfile);
|
||||||
String zipPath = "C:\\Users\\陈超\\Desktop\\YSWJ\\新下载的波形文件.zip";
|
// return zipPath;
|
||||||
//压缩后的文件存放路径
|
// }
|
||||||
File zipfile = new File(zipPath);
|
//
|
||||||
zipFiles(srcfile, zipfile);
|
// /**
|
||||||
return zipPath;
|
// * 压缩多个文件成一个zip文件
|
||||||
}
|
// * @param srcfile:源文件列表
|
||||||
|
// * @param zipfile:压缩后的文件
|
||||||
/**
|
// */
|
||||||
* 压缩多个文件成一个zip文件
|
// public static void zipFiles(File[] srcfile, File zipfile) {
|
||||||
*
|
// byte[] buf = new byte[1024];
|
||||||
* @param srcfile:源文件列表
|
// try {
|
||||||
* @param zipfile:压缩后的文件
|
// //ZipOutputStream类:完成文件或文件夹的压缩
|
||||||
*/
|
// ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
|
||||||
public static void zipFiles(File[] srcfile, File zipfile) {
|
// for (int i = 0; i < srcfile.length; i++) {
|
||||||
byte[] buf = new byte[1024];
|
// FileInputStream in = new FileInputStream(srcfile[i]);
|
||||||
try {
|
// out.putNextEntry(new ZipEntry(srcfile[i].getName()));
|
||||||
//ZipOutputStream类:完成文件或文件夹的压缩
|
// int len;
|
||||||
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));
|
// while ((len = in.read(buf)) > 0) {
|
||||||
for (int i = 0; i < srcfile.length; i++) {
|
// out.write(buf, 0, len);
|
||||||
FileInputStream in = new FileInputStream(srcfile[i]);
|
// }
|
||||||
out.putNextEntry(new ZipEntry(srcfile[i].getName()));
|
// out.closeEntry();
|
||||||
int len;
|
// in.close();
|
||||||
while ((len = in.read(buf)) > 0) {
|
// }
|
||||||
out.write(buf, 0, len);
|
// out.close();
|
||||||
}
|
// System.out.println("压缩完成.");
|
||||||
out.closeEntry();
|
// } catch (Exception e) {
|
||||||
in.close();
|
// e.printStackTrace();
|
||||||
}
|
// }
|
||||||
out.close();
|
// }
|
||||||
System.out.println("压缩完成.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除文件(夹)和空文件夹
|
* 删除文件(夹)和空文件夹
|
||||||
|
|||||||
Reference in New Issue
Block a user