暂降报告修改
This commit is contained in:
@@ -112,7 +112,6 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
try {
|
try {
|
||||||
QvvrDLL.INSTANCE.qvvr_fun(typeDataStruct);
|
QvvrDLL.INSTANCE.qvvr_fun(typeDataStruct);
|
||||||
System.out.println("调用qvvrdll成功-----------");
|
System.out.println("调用qvvrdll成功-----------");
|
||||||
|
|
||||||
if (typeDataStruct.evt_num > 0) {
|
if (typeDataStruct.evt_num > 0) {
|
||||||
// 全局比较找出最小三相电压特征值
|
// 全局比较找出最小三相电压特征值
|
||||||
float globalMinVoltage = Float.MAX_VALUE;
|
float globalMinVoltage = Float.MAX_VALUE;
|
||||||
@@ -127,6 +126,13 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//上传HR
|
||||||
|
eventAnalysis.setType(globalFaultType);
|
||||||
|
} else {
|
||||||
|
eventAnalysis.setType(DataFeature.TYPE10);
|
||||||
|
}
|
||||||
String str = WriteData2File(typeDataStruct);
|
String str = WriteData2File(typeDataStruct);
|
||||||
if (Objects.isNull(wlFilePath)) {
|
if (Objects.isNull(wlFilePath)) {
|
||||||
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH;
|
String hdrPath = OssPath.WAVE_DIR + ip+StrUtil.SLASH;
|
||||||
@@ -140,12 +146,6 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
String hdrName = fullPath.substring(lastSlashIndex + 1);
|
String hdrName = fullPath.substring(lastSlashIndex + 1);
|
||||||
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
fileStorageUtil.uploadStreamSpecifyName(new ByteArrayInputStream(str.getBytes()),hdrPath,hdrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//上传HR
|
|
||||||
eventAnalysis.setType(globalFaultType);
|
|
||||||
} else {
|
|
||||||
eventAnalysis.setType(DataFeature.TYPE10);
|
|
||||||
}
|
|
||||||
System.out.println("结束qvvrdll方法调用-----------");
|
System.out.println("结束qvvrdll方法调用-----------");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
eventAnalysis.setType(DataFeature.TYPE10);
|
eventAnalysis.setType(DataFeature.TYPE10);
|
||||||
@@ -458,6 +458,10 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(2), 2));
|
stringBuilder.append(EnumEvt.setEnter(EnumEvt.setClose(2), 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(rect.evt_num==0){
|
||||||
|
stringBuilder.append("]");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
stringBuilder.append("}");
|
stringBuilder.append("}");
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
|||||||
causeStruct.smp_len = pitchList.size();
|
causeStruct.smp_len = pitchList.size();
|
||||||
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
causeStruct.smp_rate = (int) wavePitchData.getnOneWaveNum();
|
||||||
|
|
||||||
String hdrStr = waveUtils.getFile(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.HDR);
|
String hdrStr = waveUtils.getFile(OssPath.WAVE_DIR + lineDetailDataVO.getIp() + StrUtil.SLASH + rmpEventDetailPO.getWavePath() + GeneralConstant.HDR_LOWER);
|
||||||
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
JSONObject jsonObject = JSONObject.fromObject(hdrStr);
|
||||||
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
translateData(jsonObject, rmpEventDetailPO.getStartTime(), entityAdvancedData);
|
||||||
|
|
||||||
@@ -628,7 +628,7 @@ public class EventWaveAnalysisServiceImpl implements EventWaveAnalysisService {
|
|||||||
|
|
||||||
entityAdvancedData.backNumber = len;
|
entityAdvancedData.backNumber = len;
|
||||||
//初始化EntityAdvancedData的BackData数据
|
//初始化EntityAdvancedData的BackData数据
|
||||||
len = (len == 0 ? 1 : len);
|
// len = (len == 0 ? 1 : len);
|
||||||
entityAdvancedData.evt_buf = new BackData[len];
|
entityAdvancedData.evt_buf = new BackData[len];
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
entityAdvancedData.evt_buf[i] = new BackData();
|
entityAdvancedData.evt_buf[i] = new BackData();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import java.io.IOException;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xxy
|
* @author xxy
|
||||||
@@ -237,7 +238,7 @@ public class ReportController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/createEventReport")
|
@PostMapping("/createEventReport")
|
||||||
@ApiOperation("暂态事件报告导出")
|
@ApiOperation("暂态事件报告导出")
|
||||||
public void createEventReport(@RequestBody @Validated List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException {
|
public void createEventReport(@RequestBody @Validated List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException, ExecutionException, InterruptedException {
|
||||||
commMonitorEventReportService.createEventReport(index,response);
|
commMonitorEventReportService.createEventReport(index,response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pqs
|
* pqs
|
||||||
@@ -25,7 +26,7 @@ public interface CommMonitorEventReportService {
|
|||||||
* 暂态事件报告
|
* 暂态事件报告
|
||||||
* @param index
|
* @param index
|
||||||
*/
|
*/
|
||||||
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException;
|
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException, ExecutionException, InterruptedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂态事件报告存储,返回文件路径
|
* 暂态事件报告存储,返回文件路径
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
|||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@@ -60,6 +61,7 @@ import java.net.URLEncoder;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -86,7 +88,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
private final FileStorageUtil fileStorageUtil;
|
private final FileStorageUtil fileStorageUtil;
|
||||||
private final LineFeignClient lineFeignClient;
|
private final LineFeignClient lineFeignClient;
|
||||||
private final EventCauseFeignClient eventCauseFeignClient;
|
private final EventCauseFeignClient eventCauseFeignClient;
|
||||||
|
@Resource(name="asyncExecutor")
|
||||||
|
private Executor executor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监测点导出word
|
* 监测点导出word
|
||||||
@@ -600,8 +603,10 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
/**
|
/**
|
||||||
* 生成暂降事件报告
|
* 生成暂降事件报告
|
||||||
*/
|
*/
|
||||||
public void createEventReport(List<String> eventIndex, HttpServletResponse response) throws IOException, InvalidFormatException {
|
@Override
|
||||||
|
public void createEventReport(List<String> eventIndex, HttpServletResponse response) throws IOException, InvalidFormatException, ExecutionException, InterruptedException {
|
||||||
WordUtil wordUtil = new WordUtil();
|
WordUtil wordUtil = new WordUtil();
|
||||||
|
// 创建专用的线程池(建议大小为CPU核心数或稍大,这里设为3个并行任务)
|
||||||
for (String index : eventIndex) {
|
for (String index : eventIndex) {
|
||||||
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
||||||
List<AreaLineInfoVO> lineDetail = lineFeignClient.getBaseLineAreaInfo(Stream.of(detail.getLineId()).collect(Collectors.toList())).getData();
|
List<AreaLineInfoVO> lineDetail = lineFeignClient.getBaseLineAreaInfo(Stream.of(detail.getLineId()).collect(Collectors.toList())).getData();
|
||||||
@@ -612,18 +617,42 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
if (ObjUtil.isNull(waveData)) {
|
if (ObjUtil.isNull(waveData)) {
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
|
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
|
||||||
} else {
|
} else {
|
||||||
//获取瞬时波形
|
// 使用 CompletableFuture 并行执行三个耗时操作
|
||||||
|
CompletableFuture<String> instantFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
|
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
|
||||||
InputStream instantStream = fileStorageUtil.getFileStream(instantPath);
|
try (InputStream instantStream = fileStorageUtil.getFileStream(instantPath)) {
|
||||||
String imageShun64 = cn.hutool.core.codec.Base64.encode(instantStream);
|
return cn.hutool.core.codec.Base64.encode(instantStream);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("生成瞬时波形失败", e);
|
||||||
|
}
|
||||||
|
}, executor);
|
||||||
|
|
||||||
wordUtil.translateShun(index, imageShun64);
|
CompletableFuture<String> rmsFuture = CompletableFuture.supplyAsync(() -> {
|
||||||
//获取rms波形
|
|
||||||
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
|
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
|
||||||
InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath);
|
try (InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath)) {
|
||||||
String rmsShun64 = cn.hutool.core.codec.Base64.encode(rmsStream);
|
return cn.hutool.core.codec.Base64.encode(rmsStream);
|
||||||
wordUtil.translateRms(index, rmsShun64);
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("生成RMS波形失败", e);
|
||||||
|
}
|
||||||
|
}, executor);
|
||||||
|
|
||||||
|
CompletableFuture<List<EventEigDetail>> eigFuture = CompletableFuture.supplyAsync(() ->
|
||||||
|
waveService.eventDetailEigenvalue(index, line.getPtType()), executor
|
||||||
|
);
|
||||||
|
|
||||||
|
// 等待所有异步任务完成并获取结果(无超时,但可加)
|
||||||
|
CompletableFuture<Void> allFutures = CompletableFuture.allOf(instantFuture, rmsFuture, eigFuture);
|
||||||
|
allFutures.join(); // 阻塞直到三个任务都完成
|
||||||
|
|
||||||
|
// 获取结果(此时所有任务已完成,get()不会阻塞)
|
||||||
|
String imageShun64 = instantFuture.get();
|
||||||
|
String rmsShun64 = rmsFuture.get();
|
||||||
|
List<EventEigDetail> eventDetailEigenvalue = eigFuture.get();
|
||||||
|
// 主线程顺序调用 WordUtil 方法(保证线程安全)
|
||||||
|
wordUtil.translateShun(index, imageShun64);
|
||||||
|
wordUtil.translateRms(index, rmsShun64);
|
||||||
|
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
|
||||||
|
// 设置事件基本信息(不涉及耗时操作)
|
||||||
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
|
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
|
||||||
eventInfoList.setLineName(line.getLineName());
|
eventInfoList.setLineName(line.getLineName());
|
||||||
eventInfoList.setGdName(line.getGdName());
|
eventInfoList.setGdName(line.getGdName());
|
||||||
@@ -637,9 +666,6 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
eventInfoList.setMs(detail.getFirstMs());
|
eventInfoList.setMs(detail.getFirstMs());
|
||||||
eventInfoList.setEventValue(detail.getFeatureAmplitude());
|
eventInfoList.setEventValue(detail.getFeatureAmplitude());
|
||||||
wordUtil.setEventInfoList(index, eventInfoList);
|
wordUtil.setEventInfoList(index, eventInfoList);
|
||||||
List<EventEigDetail> eventDetailEigenvalue = waveService.eventDetailEigenvalue(index,line.getPtType());
|
|
||||||
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wordUtil.createReport(eventIndex);
|
wordUtil.createReport(eventIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user