zbj//1.离线波形计算pt值和ct值
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package com.njcn.event.service.majornetwork.Impl;
|
||||
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.event.pojo.dto.wave.AnalogDTO;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.service.majornetwork.AutonomeWaveService;
|
||||
import com.njcn.event.utils.WaveUtil;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -15,6 +17,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -34,9 +37,9 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
|
||||
@Override
|
||||
public WaveDataDTO uploadFileAndViewWave(MultipartFile file1, MultipartFile file2) throws IOException {
|
||||
//测试路径
|
||||
File dir = new File("C:\\Users\\User\\Desktop\\wave");
|
||||
// dir = new File("C:\\Users\\User\\Desktop\\wave");
|
||||
//真实路径
|
||||
// File dir = new File(generalInfo.getBusinessTempPath() + File.separator + "wave");
|
||||
File dir = new File(generalInfo.getBusinessTempPath() + File.separator + "wave");
|
||||
|
||||
String cfgPath, datPath;
|
||||
if (!dir.exists()) {
|
||||
@@ -57,7 +60,8 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
|
||||
InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath));
|
||||
InputStream datInputStream = Files.newInputStream(Paths.get(datPath));
|
||||
WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1);
|
||||
return waveUtil.getValidData(comtrade);
|
||||
WaveDataDTO validData = waveUtil.getValidData(comtrade);
|
||||
return countPtCt(validData);
|
||||
} else {
|
||||
//使用本地的波形文件进行测试
|
||||
File dat = new File(dir + File.separator + fileName1);
|
||||
@@ -69,7 +73,37 @@ public class AutonomeWaveServiceImpl implements AutonomeWaveService {
|
||||
InputStream cfgInputStream = Files.newInputStream(Paths.get(cfgPath));
|
||||
InputStream datInputStream = Files.newInputStream(Paths.get(datPath));
|
||||
WaveDataDTO comtrade = waveUtil.getComtrade(cfgInputStream, datInputStream, 1);
|
||||
return waveUtil.getValidData(comtrade);
|
||||
WaveDataDTO validData = waveUtil.getValidData(comtrade);
|
||||
return countPtCt(validData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算pt值和ct值
|
||||
*/
|
||||
private WaveDataDTO countPtCt(WaveDataDTO waveDataDTO){
|
||||
//取出集合
|
||||
List<AnalogDTO> lstAnalogDTO = waveDataDTO.getComtradeCfgDTO().getLstAnalogDTO();
|
||||
AnalogDTO ptParam = null;
|
||||
for (AnalogDTO analogDTO : lstAnalogDTO) {
|
||||
if (StringUtils.isNotBlank(analogDTO.getSzUnitName())&& analogDTO.getSzUnitName().contains("V")){
|
||||
ptParam = analogDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
AnalogDTO ctParam = null;
|
||||
for (AnalogDTO analogDTO : lstAnalogDTO) {
|
||||
if (StringUtils.isNotBlank(analogDTO.getSzUnitName())&& analogDTO.getSzUnitName().contains("A")){
|
||||
ctParam = analogDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
double pt1 = Double.parseDouble(ptParam.getFPrimary().toString());
|
||||
double pt2 = Double.parseDouble(ptParam.getFSecondary().toString());
|
||||
double ct1 = Double.parseDouble(ctParam.getFPrimary().toString());
|
||||
double ct2 = Double.parseDouble(ctParam.getFSecondary().toString());
|
||||
waveDataDTO.setPt(pt1 / pt2);
|
||||
waveDataDTO.setCt(ct1 / ct2);
|
||||
return waveDataDTO;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user