Compare commits
2 Commits
9d9150e418
...
2026-02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94037d588b | ||
| 01a77fa92d |
@@ -47,7 +47,7 @@ import java.util.List;
|
|||||||
* angle_diff_cn C相相位负跳变
|
* angle_diff_cn C相相位负跳变
|
||||||
* bph_max_value 不平衡度(单位%)
|
* bph_max_value 不平衡度(单位%)
|
||||||
*/
|
*/
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true,value = {"pointer"})
|
||||||
public class BackData extends Structure {
|
public class BackData extends Structure {
|
||||||
public int qvvr_cata_cause[] = new int[256];
|
public int qvvr_cata_cause[] = new int[256];
|
||||||
public int qvvr_phasetype[] = new int[256];
|
public int qvvr_phasetype[] = new int[256];
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ public class AreaLineInfoVO implements Serializable {
|
|||||||
@ApiModelProperty(name = "pt2",value = "pt2")
|
@ApiModelProperty(name = "pt2",value = "pt2")
|
||||||
private Integer pt2;
|
private Integer pt2;
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "ptType",value = "接线类型(0:星型接法;1:三角型接法;2:开口三角型接法)")
|
||||||
|
private Integer ptType;
|
||||||
|
|
||||||
@ApiModelProperty(name = "objName",value = "对象名称")
|
@ApiModelProperty(name = "objName",value = "对象名称")
|
||||||
private String objName;
|
private String objName;
|
||||||
|
|
||||||
|
|||||||
@@ -557,6 +557,7 @@
|
|||||||
detail.ct2,
|
detail.ct2,
|
||||||
detail.pt1,
|
detail.pt1,
|
||||||
detail.pt2,
|
detail.pt2,
|
||||||
|
detail.PT_Type as ptType,
|
||||||
detail.obj_name,
|
detail.obj_name,
|
||||||
detail.Dev_Capacity deviceCapacity,
|
detail.Dev_Capacity deviceCapacity,
|
||||||
detail.Short_Capacity,
|
detail.Short_Capacity,
|
||||||
|
|||||||
@@ -234,4 +234,10 @@ public class ReportController extends BaseController {
|
|||||||
reportService.getPmsAreaReport(areaReportParam, response);
|
reportService.getPmsAreaReport(areaReportParam, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/createEventReport")
|
||||||
|
@ApiOperation("暂态事件报告导出")
|
||||||
|
public void createEventReport(@RequestBody @Validated List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException {
|
||||||
|
commMonitorEventReportService.createEventReport(index,response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package com.njcn.event.common.mapper;
|
package com.njcn.event.common.mapper;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.njcn.event.pojo.dto.EventCount;
|
import com.njcn.event.pojo.dto.EventCount;
|
||||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
import com.njcn.event.pojo.vo.RmpEventDetailVO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package com.njcn.event.common.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description:
|
||||||
|
* @Author: wr
|
||||||
|
* @Date: 2023/11/1 13:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EventInfoDetailVO implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty("监测点名称")
|
||||||
|
private String lineName;
|
||||||
|
|
||||||
|
@ApiModelProperty("供电公司名称")
|
||||||
|
private String gdName;
|
||||||
|
|
||||||
|
@ApiModelProperty("变电站名称")
|
||||||
|
private String bdzName;
|
||||||
|
|
||||||
|
@ApiModelProperty("终端名称")
|
||||||
|
private String devName;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压等级")
|
||||||
|
private String scale;
|
||||||
|
|
||||||
|
@ApiModelProperty("ip")
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
@ApiModelProperty("暂降事件id")
|
||||||
|
private String eventDetailIndex;
|
||||||
|
|
||||||
|
@ApiModelProperty("触发时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS")
|
||||||
|
private LocalDateTime timeID;
|
||||||
|
|
||||||
|
@ApiModelProperty("持续时间")
|
||||||
|
private Double persistTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("处理结果第一条事件发生时间毫秒")
|
||||||
|
private Double ms;
|
||||||
|
|
||||||
|
@ApiModelProperty("特征幅值")
|
||||||
|
private Double eventValue;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告状态")
|
||||||
|
private int report;
|
||||||
|
|
||||||
|
@ApiModelProperty("评价")
|
||||||
|
private int evaluate;
|
||||||
|
|
||||||
|
@ApiModelProperty("报告路径")
|
||||||
|
private String reportPath;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,8 +2,11 @@ package com.njcn.event.common.service;
|
|||||||
|
|
||||||
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
import com.njcn.event.common.pojo.dto.LineDetailDataCommDTO;
|
||||||
import com.njcn.event.pojo.param.ExportParam;
|
import com.njcn.event.pojo.param.ExportParam;
|
||||||
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* pqs
|
* pqs
|
||||||
@@ -16,6 +19,9 @@ public interface CommMonitorEventReportService {
|
|||||||
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
void getLineExport(ExportParam exportParam, LineDetailDataCommDTO lineDetailDataCommDTO, HttpServletResponse response);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 暂态事件报告
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
void createEventReport(List<String> index, HttpServletResponse response) throws IOException, InvalidFormatException;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.njcn.event.common.service;
|
package com.njcn.event.common.service;
|
||||||
|
|
||||||
import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||||
|
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||||
|
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||||
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: cdf
|
* @Author: cdf
|
||||||
@@ -9,6 +15,14 @@ import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
|||||||
*/
|
*/
|
||||||
public interface WaveService {
|
public interface WaveService {
|
||||||
|
|
||||||
//通过优化后的方式获取波形数据
|
/**
|
||||||
WaveData getWavedata(String eventIndex, int flag);
|
* 通过优化后的方式获取波形数据
|
||||||
|
* @param
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line);
|
||||||
|
|
||||||
|
|
||||||
|
List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package com.njcn.event.common.service.impl;
|
package com.njcn.event.common.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.device.pms.api.MonitorClient;
|
|
||||||
import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.device.pq.api.LineFeignClient;
|
||||||
|
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||||
import com.njcn.echarts.pojo.constant.PicCommonData;
|
import com.njcn.echarts.pojo.constant.PicCommonData;
|
||||||
import com.njcn.echarts.util.DrawPicUtil;
|
import com.njcn.echarts.util.DrawPicUtil;
|
||||||
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
||||||
@@ -18,36 +19,34 @@ import com.njcn.event.common.service.CommMonitorEventReportService;
|
|||||||
import com.njcn.event.common.service.EventAnalysisService;
|
import com.njcn.event.common.service.EventAnalysisService;
|
||||||
import com.njcn.event.common.service.EventReportService;
|
import com.njcn.event.common.service.EventReportService;
|
||||||
import com.njcn.event.common.service.WaveService;
|
import com.njcn.event.common.service.WaveService;
|
||||||
|
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||||
import com.njcn.event.common.utils.WordUtil;
|
import com.njcn.event.common.utils.WordUtil;
|
||||||
import com.njcn.event.common.utils.WordUtils;
|
import com.njcn.event.common.utils.WordUtils;
|
||||||
|
import com.njcn.event.file.component.WavePicComponent;
|
||||||
import com.njcn.event.file.pojo.bo.WaveDataDetail;
|
import com.njcn.event.file.pojo.bo.WaveDataDetail;
|
||||||
|
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||||
|
import com.njcn.event.file.utils.WaveUtil;
|
||||||
import com.njcn.event.pojo.param.ExportParam;
|
import com.njcn.event.pojo.param.ExportParam;
|
||||||
import com.njcn.event.pojo.param.StatisticsParam;
|
import com.njcn.event.pojo.param.StatisticsParam;
|
||||||
import com.njcn.event.pojo.po.EventDetail;
|
import com.njcn.event.pojo.po.EventDetail;
|
||||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
import com.njcn.event.pojo.vo.*;
|
import com.njcn.event.pojo.vo.*;
|
||||||
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
import com.njcn.system.api.DicDataFeignClient;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
import com.njcn.system.enums.DicDataEnum;
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
import com.njcn.system.enums.DicDataTypeEnum;
|
import com.njcn.system.enums.DicDataTypeEnum;
|
||||||
import com.njcn.system.pojo.po.DictData;
|
import com.njcn.system.pojo.po.DictData;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
|
||||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth;
|
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 org.springframework.util.CollectionUtils;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
@@ -57,6 +56,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,16 +72,15 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
|
|
||||||
|
|
||||||
private final DicDataFeignClient dicDataFeignClient;
|
private final DicDataFeignClient dicDataFeignClient;
|
||||||
|
|
||||||
private final EventReportService eventReportService;
|
private final EventReportService eventReportService;
|
||||||
//调用暂降密度接口
|
|
||||||
private final EventAnalysisService eventAnalysisService;
|
private final EventAnalysisService eventAnalysisService;
|
||||||
|
|
||||||
private final RmpEventDetailMapper rmpEventDetailMapper;
|
private final RmpEventDetailMapper rmpEventDetailMapper;
|
||||||
|
|
||||||
private final WaveService waveService;
|
private final WaveService waveService;
|
||||||
|
|
||||||
private final DrawPicUtil drawPicUtil;
|
private final DrawPicUtil drawPicUtil;
|
||||||
|
private final WavePicComponent wavePicComponent;
|
||||||
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
private final LineFeignClient lineFeignClient;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 监测点导出word
|
* 监测点导出word
|
||||||
@@ -226,7 +225,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
EventDetail eventDetail = plot.get(j);
|
EventDetail eventDetail = plot.get(j);
|
||||||
String s = eventDetail.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
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() + "");
|
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++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -369,7 +368,7 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
} else {
|
} else {
|
||||||
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
for (int j = 0; j < reasonTypeTime.size(); j++) {
|
||||||
TimeVO timeVO = reasonTypeTime.get(j);
|
TimeVO timeVO = reasonTypeTime.get(j);
|
||||||
insertRow(doc, table1, centerParagraph, false,timeVO.getFulltime(), timeVO.getTimes());
|
insertRow(doc, table1, centerParagraph, false, timeVO.getFulltime(), timeVO.getTimes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
two++;
|
two++;
|
||||||
@@ -468,8 +467,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||||
doc.write(outputStream);
|
doc.write(outputStream);
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL,"导出监测点暂降报告异常");
|
throw new BusinessException(CommonResponseEnum.FAIL, "导出监测点暂降报告异常");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -528,14 +527,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setCellStyle(HSSFCell cellname, String value, HSSFCellStyle style) {
|
|
||||||
cellname.setCellValue(value);
|
|
||||||
cellname.setCellStyle(style);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param document 文档
|
* @param document 文档
|
||||||
* @param image 图片base64
|
* @param image 图片base64
|
||||||
* @param name 图片名
|
* @param name 图片名
|
||||||
@@ -552,8 +545,8 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
byte[] bytes = Base64.getDecoder().decode(image);
|
byte[] bytes = Base64.getDecoder().decode(image);
|
||||||
InputStream in = new ByteArrayInputStream(bytes);
|
InputStream in = new ByteArrayInputStream(bytes);
|
||||||
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
|
createRun.addPicture(in, 5, name, Units.toEMU(410), Units.toEMU(170));
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error("在word中创建图片异常:",e);
|
log.error("在word中创建图片异常:", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,92 +593,61 @@ public class CommMonitorEventReportServiceImpl implements CommMonitorEventReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/* *//**
|
|
||||||
* 生成暂降事件报告
|
* 生成暂降事件报告
|
||||||
*//*
|
*/
|
||||||
public void createEventReport(List<String> index) {
|
public void createEventReport(List<String> eventIndex, HttpServletResponse response) throws IOException, InvalidFormatException {
|
||||||
try {
|
|
||||||
WordUtil wordUtil = new WordUtil();
|
WordUtil wordUtil = new WordUtil();
|
||||||
for (int i = 0; i < index.size(); i++) {
|
for (String index : eventIndex) {
|
||||||
WaveData waveData = waveService.getWavedata(index.get(i), 1);
|
RmpEventDetailPO detail = rmpEventDetailMapper.selectById(index);
|
||||||
|
List<AreaLineInfoVO> lineDetail = lineFeignClient.getBaseLineAreaInfo(Stream.of(detail.getLineId()).collect(Collectors.toList())).getData();
|
||||||
|
AreaLineInfoVO line = lineDetail.get(0);
|
||||||
|
WaveDataDTO waveData = waveService.getWavedata(detail, line);
|
||||||
//数据筛选,如果是双路电压的话,会存在2个波形数据
|
//数据筛选,如果是双路电压的话,会存在2个波形数据
|
||||||
List<WaveDataDetail> waveDataDetails = waveService.filteWaveData(waveData);
|
List<WaveDataDetail> waveDataDetails = WaveUtil.filterWaveData(waveData);
|
||||||
if (waveData.getSunData().isEmpty()) {
|
if (ObjUtil.isNull(waveData)) {
|
||||||
throw new BusinessException(CommonResponseEnum.FAIL,"没有波形数据");
|
throw new BusinessException(CommonResponseEnum.FAIL, "没有波形数据");
|
||||||
} else {
|
} else {
|
||||||
String time = waveData.getTime();
|
//获取瞬时波形
|
||||||
time = time.replace(" ", "%20");
|
String instantPath = wavePicComponent.generateImageShun(waveData, waveDataDetails);
|
||||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue() + "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
InputStream instantStream = fileStorageUtil.getFileStream(instantPath);
|
||||||
|
String imageShun64 = cn.hutool.core.codec.Base64.encode(instantStream);
|
||||||
|
|
||||||
List<String> shun = new ArrayList<>();
|
wordUtil.translateShun(index, imageShun64);
|
||||||
List<String> rms = new ArrayList<>();
|
//获取rms波形
|
||||||
if (waveDataDetails.size() == 1) {
|
String rmsPath = wavePicComponent.generateImageRms(waveData, waveDataDetails);
|
||||||
shun.add(waveService.createShunTitle(title, waveDataDetails.get(0)));
|
InputStream rmsStream = fileStorageUtil.getFileStream(rmsPath);
|
||||||
rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0)));
|
String rmsShun64 = cn.hutool.core.codec.Base64.encode(rmsStream);
|
||||||
} else {
|
wordUtil.translateRms(index, rmsShun64);
|
||||||
shun.add(waveService.createShunTitle(title, waveDataDetails.get(0)));
|
|
||||||
rms.add(waveService.createRMSTitle(title, waveDataDetails.get(0)));
|
EventInfoDetailVO eventInfoList = new EventInfoDetailVO();
|
||||||
for (int n = 1; n < waveDataDetails.size(); n++) {
|
eventInfoList.setLineName(line.getLineName());
|
||||||
shun.add(waveService.createShun(waveDataDetails.get(n)));
|
eventInfoList.setGdName(line.getGdName());
|
||||||
rms.add(waveService.createRMS(waveDataDetails.get(n)));
|
eventInfoList.setBdzName(line.getSubName());
|
||||||
}
|
eventInfoList.setDevName(line.getDeviceName());
|
||||||
}
|
eventInfoList.setScale(line.getVoltageScale());
|
||||||
wordUtil.translateShun(i, shun);
|
eventInfoList.setIp(line.getIp());
|
||||||
wordUtil.translateRms(i, rms);
|
eventInfoList.setEventDetailIndex(detail.getEventId());
|
||||||
List<EventEigDetail> eventDetailEigenvalue = eventDetailService.eventDetailEigenvalue(index.get(i));
|
eventInfoList.setTimeID(detail.getStartTime());
|
||||||
wordUtil.setEventDetailEigenvalue(i, eventDetailEigenvalue);
|
eventInfoList.setPersistTime(detail.getDuration());
|
||||||
EventInfoDetail eventInfoList = .eventDetailBaseInfoByIndex(index.get(i));
|
eventInfoList.setMs(detail.getFirstMs());
|
||||||
wordUtil.setEventInfoList(i, eventInfoList);
|
eventInfoList.setEventValue(detail.getFeatureAmplitude());
|
||||||
}
|
wordUtil.setEventInfoList(index, eventInfoList);
|
||||||
}
|
List<EventEigDetail> eventDetailEigenvalue = waveService.eventDetailEigenvalue(index,line.getPtType());
|
||||||
wordUtil.createReport(index.size());
|
wordUtil.setEventDetailEigenvalue(index, eventDetailEigenvalue);
|
||||||
|
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm");// 报告时分秒格式
|
|
||||||
String fileName = "暂降事件报告_" + formatter.format(new Date()) + ".docx";
|
|
||||||
//读取配置文件
|
|
||||||
Properties pros = PubUtils.readProperties(getClass().getClassLoader(), "java.properties");
|
|
||||||
String tmpPath = pros.get("TMP_PATH").toString() + File.separator + "eventreoprt";
|
|
||||||
tmpPath = ClearPathUtil.cleanString(tmpPath);
|
|
||||||
OutputStream os = null;
|
|
||||||
File tmpfile = new File(tmpPath);
|
|
||||||
if (!tmpfile.exists()) {
|
|
||||||
tmpfile.mkdir();
|
|
||||||
}
|
}
|
||||||
tmpPath = tmpPath + File.separator + fileName;
|
|
||||||
tmpPath = ClearPathUtil.cleanString(tmpPath);
|
|
||||||
File tmp = new File(tmpPath);
|
|
||||||
if (tmp.exists()) {
|
|
||||||
tmp.delete();
|
|
||||||
}
|
}
|
||||||
PubUtils.createFile(tmpPath);
|
wordUtil.createReport(eventIndex);
|
||||||
try {
|
try {
|
||||||
os = new FileOutputStream(tmpPath);
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
if (null != wordUtil.getDocument()) {
|
String fileName = URLEncoder.encode("暂降事件报告_" + DateUtil.format(new Date(),DatePattern.NORM_DATE_PATTERN)+ ".docx", "UTF-8");
|
||||||
wordUtil.getDocument().write(os);
|
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||||
session.setAttribute("eventFilePath", tmpPath);
|
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||||
session.setAttribute("eventFileName", fileName);
|
wordUtil.getDocument().write(outputStream);
|
||||||
}
|
outputStream.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
session.setAttribute("eventFilePath", "");
|
throw new BusinessException(CommonResponseEnum.FAIL, "导出暂降事件报告异常");
|
||||||
session.setAttribute("eventFileName", "");
|
|
||||||
logger.error("输出暂态事件报告异常,原因为:" + e.toString());
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (os != null) {
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("关闭流异常,原因为:" + e.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
logger.error("生成事件报告失败,方法名为:getEventReport,异常为:" + e.toString());
|
|
||||||
result = PubUtils.assignmentResult(null, 500, "生成事件报告出错,请联系管理员");
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,213 +1,125 @@
|
|||||||
//package com.njcn.event.common.service.impl;
|
package com.njcn.event.common.service.impl;
|
||||||
//
|
|
||||||
//import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
//import com.njcn.advance.pojo.dto.waveAnalysis.AnalyWave;
|
import cn.hutool.core.util.StrUtil;
|
||||||
//import com.njcn.advance.pojo.dto.waveAnalysis.WaveData;
|
import com.njcn.advance.api.EventWaveAnalysisFeignClient;
|
||||||
//import com.njcn.common.config.GeneralInfo;
|
import com.njcn.advance.pojo.dto.waveAnalysis.EntityAdvancedData;
|
||||||
//import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
//import com.njcn.device.pq.api.LineFeignClient;
|
import com.njcn.common.utils.PubUtils;
|
||||||
//import com.njcn.device.pq.pojo.po.line.LineInfoVO;
|
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||||
//import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||||
//import com.njcn.event.common.mapper.RmpEventDetailMapper;
|
import com.njcn.event.common.service.WaveService;
|
||||||
//import com.njcn.event.common.service.WaveService;
|
import com.njcn.event.file.component.WaveFileComponent;
|
||||||
//import com.njcn.event.file.component.WaveFileComponent;
|
import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
||||||
//import com.njcn.event.file.pojo.dto.WaveDataDTO;
|
import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
||||||
//import com.njcn.event.file.pojo.enums.WaveFileResponseEnum;
|
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||||
//import com.njcn.event.file.utils.WaveUtil;
|
import com.njcn.oss.constant.GeneralConstant;
|
||||||
//import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.oss.constant.OssPath;
|
||||||
//import com.njcn.oss.constant.GeneralConstant;
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
//import com.njcn.oss.constant.OssPath;
|
import com.njcn.system.api.DicDataFeignClient;
|
||||||
//import com.njcn.oss.utils.FileStorageUtil;
|
import lombok.RequiredArgsConstructor;
|
||||||
//import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
||||||
//import org.apache.commons.lang3.StringUtils;
|
|
||||||
//import org.springframework.stereotype.Service;
|
import java.io.InputStream;
|
||||||
//
|
import java.util.*;
|
||||||
//import java.io.File;
|
|
||||||
//import java.io.InputStream;
|
|
||||||
//import java.math.BigDecimal;
|
/**
|
||||||
//import java.math.RoundingMode;
|
* @Author: cdf
|
||||||
//import java.text.SimpleDateFormat;
|
* @CreateTime: 2026-02-26
|
||||||
//import java.util.List;
|
* @Description:
|
||||||
//import java.util.Objects;
|
*/
|
||||||
//import java.util.stream.Collectors;
|
@Service
|
||||||
//import java.util.stream.Stream;
|
@RequiredArgsConstructor
|
||||||
//
|
@Slf4j
|
||||||
///**
|
public class WaveServiceImpl implements WaveService {
|
||||||
// * @Author: cdf
|
|
||||||
// * @CreateTime: 2026-02-26
|
private final WaveFileComponent waveFileComponent;
|
||||||
// * @Description:
|
private final FileStorageUtil fileStorageUtil;
|
||||||
// */
|
private final EventWaveAnalysisFeignClient eventWaveAnalysisFeignClient;
|
||||||
//@Service
|
|
||||||
//@RequiredArgsConstructor
|
/**
|
||||||
//@Slf4j
|
* 根据暂降事件索引获取波形数据
|
||||||
//public class WaveServiceImpl implements WaveService {
|
* 注:当前只考虑本地的波形文件
|
||||||
//
|
*
|
||||||
// private final RmpEventDetailMapper rmpEventDetailMapper;
|
* @param eventDetail 暂态事件
|
||||||
//
|
* @param line 监测点
|
||||||
// private final WaveFileComponent waveFileComponent;
|
*/
|
||||||
//
|
@Override
|
||||||
// private final GeneralInfo generalInfo;
|
public WaveDataDTO getWavedata(RmpEventDetailPO eventDetail, AreaLineInfoVO line) {
|
||||||
//
|
WaveDataDTO waveDataDTO = null;
|
||||||
// private final FileStorageUtil fileStorageUtil;
|
if (ObjectUtil.isNotEmpty(line)) {
|
||||||
// private final LineFeignClient lineFeignClient;
|
String waveName = eventDetail.getWavePath();
|
||||||
//
|
if (StrUtil.isBlank(waveName)) {
|
||||||
//
|
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||||
// /**
|
}
|
||||||
// * 根据暂降事件索引获取波形数据
|
String wavePath = OssPath.WAVE_DIR + line.getIp() + StrUtil.SLASH + waveName;
|
||||||
// * 注:当前只考虑本地的波形文件
|
try (
|
||||||
// *
|
InputStream cfgStream = fileStorageUtil.getFileStream(wavePath + GeneralConstant.CFG);
|
||||||
// * @param eventIndex 事件索引
|
InputStream datStream = fileStorageUtil.getFileStream(wavePath + GeneralConstant.DAT)
|
||||||
// * @param flag 抽点方式
|
) {
|
||||||
// */
|
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||||
// @Override
|
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||||
// public WaveData getWavedata(String eventIndex, int flag) {
|
}
|
||||||
// WaveData waveData = new WaveData();
|
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
||||||
// RmpEventDetailPO eventDetail = rmpEventDetailMapper.selectById(eventIndex);
|
} catch (Exception e) {
|
||||||
// if (Objects.nonNull(eventDetail)) {
|
try {
|
||||||
// //获取PT变比
|
InputStream cfgStreamLower = fileStorageUtil.getFileStream(wavePath + GeneralConstant.CFG_LOWER);
|
||||||
// List<AreaLineInfoVO> lineInfoVOList = lineFeignClient.getBaseLineAreaInfo(Stream.of(eventDetail.getLineId()).collect(Collectors.toList())).getData();
|
InputStream datStreamLower = fileStorageUtil.getFileStream(wavePath + GeneralConstant.DAT_LOWER);
|
||||||
// AreaLineInfoVO line = lineInfoVOList.get(0);
|
if (Objects.isNull(cfgStreamLower) || Objects.isNull(datStreamLower)) {
|
||||||
// waveData.setLineName(line.getLineName());
|
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||||
// /*********** Modify by xuyang 添加变电站名称---Start **************/
|
}
|
||||||
// waveData.setSubName(line.getSubName());
|
waveDataDTO = waveFileComponent.getComtrade(cfgStreamLower, datStreamLower, 1);
|
||||||
// /*********** Modify by xuyang ---End **************/
|
} catch (Exception e1) {
|
||||||
// waveData.setEventValue(BigDecimal.valueOf(eventDetail.getFeatureAmplitude()*100).setScale(2, RoundingMode.HALF_UP).floatValue());
|
throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
||||||
// waveData.setPersistTime(BigDecimal.valueOf(eventDetail.getDuration()*100).setScale(3, RoundingMode.HALF_UP).floatValue());
|
}
|
||||||
// waveData.setTrigeTime(AnalyWave.getTimeWave());
|
}
|
||||||
// if (Objects.nonNull(line)) {
|
waveDataDTO = waveFileComponent.getValidData(waveDataDTO);
|
||||||
// float pt1 = line.getPt1();
|
waveDataDTO.setPtType(line.getPtType());
|
||||||
// float pt2 = line.getPt2();
|
waveDataDTO.setPt(line.getPt1() * 1.0 / line.getPt2());
|
||||||
// float pt = (pt1) / (pt2);
|
waveDataDTO.setCt(line.getCt1() * 1.0 / line.getCt2());
|
||||||
// waveData.setPt(pt);
|
waveDataDTO.setMonitorName(line.getLineName());
|
||||||
// float ct1 = line.getCt1();
|
}
|
||||||
// float ct2 = line.getCt2();
|
return waveDataDTO;
|
||||||
// float ct = (ct1) / (ct2);
|
}
|
||||||
// waveData.setCt(ct);
|
|
||||||
// //获取接线方式
|
@Override
|
||||||
// if (line.getVHarmonicValue() != 0) {
|
public List<EventEigDetail> eventDetailEigenvalue(String eventDetailIndex,Integer ptType) {
|
||||||
// //赋值abc三相名称
|
List<EventEigDetail> eventInfoDetails = new ArrayList<>();
|
||||||
// if (lineDetail.getPtType() == 2) {
|
EntityAdvancedData entityAdvancedData = eventWaveAnalysisFeignClient.analysis(eventDetailIndex).getData() ;
|
||||||
// waveData.setOpen(true);
|
if (entityAdvancedData.backNumber != -1) {
|
||||||
// }
|
for (int i = 0; i < entityAdvancedData.backNumber; i++) {
|
||||||
// }
|
EventEigDetail eventEigDetail = new EventEigDetail();
|
||||||
// }
|
eventEigDetail.setHold_time_dq(entityAdvancedData.evt_buf[i].hold_time_dq * 1000);
|
||||||
// //严重度
|
eventEigDetail.setPow_a(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_a));
|
||||||
// Float yzd = eventDetail.getSeverity();
|
eventEigDetail.setPow_b(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_b));
|
||||||
// if (null == yzd || yzd == 0.0) {
|
eventEigDetail.setPow_c(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].POW_c));
|
||||||
// // 前去计算严重度
|
|
||||||
// yzd = Float.parseFloat(getYzd(eventDetail.getPersistTime(), eventDetail.getEventValue()));
|
eventEigDetail.setVoltagechange_Va(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Va / 1000));
|
||||||
// eventDetail.setSeverity(yzd);
|
eventEigDetail.setVoltagechange_Vb(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vb / 1000));
|
||||||
// //回填严重度到数据库中
|
eventEigDetail.setVoltagechange_Vc(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].Voltagechange_Vc / 1000));
|
||||||
// updateEventDeatilYzd(eventDetail);
|
|
||||||
// }
|
|
||||||
// waveData.setYzd(yzd);
|
eventEigDetail.setUa_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||||
// //暂降发生时间
|
eventEigDetail.setUb_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ub_min[0]));
|
||||||
// String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(eventDetail.getTimeId()) + "." + PubUtils.getMs(eventDetail.getMs());
|
eventEigDetail.setUc_min(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].ua_min[0]));
|
||||||
// waveData.setTime(time);
|
|
||||||
// //暂降类型
|
eventEigDetail.setAngle_diff_ap(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_ap[0]));
|
||||||
// // 获取暂降类型的数据字典 暂降类型
|
eventEigDetail.setAngle_diff_bp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_bp[0]));
|
||||||
// List<DicData> voltageType = redisCacheUtil.getVoltageType();
|
eventEigDetail.setAngle_diff_cp(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].angle_diff_cp[0]));
|
||||||
// for (DicData dicData : voltageType) {
|
|
||||||
// if (dicData.getDicIndex().equals(eventDetail.getEventType())) {
|
eventEigDetail.setBph_max_value(PubUtils.floatRound(2, entityAdvancedData.evt_buf[i].bph_max_value[0]));
|
||||||
// waveData.setWaveType(dicData.getDicName());
|
eventEigDetail.setSagReason(entityAdvancedData.sagReason[0]);//暂降原因,暂降原因都一样
|
||||||
// break;
|
eventEigDetail.setSagType(entityAdvancedData.sagType[i]);//暂降类型
|
||||||
// }
|
eventInfoDetails.add(eventEigDetail);
|
||||||
// }
|
eventEigDetail.setPttype(ptType);
|
||||||
// if (Integer.parseInt(eventDetail.getFileFlag()) == 1) {
|
}
|
||||||
// //根据暂降事件,返回波形文件名
|
} else {
|
||||||
// LineInfoVO ip = lineFeignClient.getLineInfoVO(eventIndex);
|
eventInfoDetails = null;
|
||||||
// if (StringUtils.isBlank(ip)) {
|
}
|
||||||
// return waveData;
|
return eventInfoDetails;
|
||||||
// }
|
}
|
||||||
// String path = appConfig.getWavePath();
|
|
||||||
// path = path + File.separator + ip;
|
|
||||||
// String waveName = getWaveName(eventDetail, path);
|
}
|
||||||
// String pathTemp = path + File.separator + waveName;
|
|
||||||
// File file = new File(pathTemp);
|
|
||||||
// // 判断文件是否存在
|
|
||||||
// if (file.isFile() && file.exists()) {
|
|
||||||
// System.out.println(pathTemp + "路径下,文件找到了");
|
|
||||||
// //CFG文件路径 pathTemp
|
|
||||||
// //获取波形的瞬时值、RMS值数据
|
|
||||||
// AnalyWave analyWave = new AnalyWave();
|
|
||||||
// WaveDataDTO tagDataValue = waveRead(eventDetail.getWavePath(),ip);
|
|
||||||
// List<List<Float>> shunWave = tagDataValue.getListWaveData();//获取瞬时波形值
|
|
||||||
// List<List<Float>> rmsWave = tagDataValue.getListRmsData();//RMS值波形
|
|
||||||
// waveData.setnOneWaveNum(analyWave.getnOneWaveNum());
|
|
||||||
// waveData.setSunData(shunWave);
|
|
||||||
// waveData.setTmpWaveTitle(tagDataValue.getWaveTitle());
|
|
||||||
// waveData.setFirstMs(analyWave.getFirstMs());
|
|
||||||
// waveData.setFirstTime(analyWave.getFirstTime());
|
|
||||||
// waveData.setRmsData(rmsWave);
|
|
||||||
// waveData.setRatesCfg(analyWave.getRatesCfg());
|
|
||||||
// /*********** Modify by yexibao ---Start **************/
|
|
||||||
// waveData.setiPhasic(tagDataValue.getIPhasic());
|
|
||||||
// /*********** Modify by yexibao ---End **************/
|
|
||||||
// List<String> tmpWaveTitle = tagDataValue.getWaveTitle();
|
|
||||||
// /*********** Modify by yexibao ---Start **************/
|
|
||||||
// for (int i = 0; i < tagDataValue.getIPhasic(); i++) {
|
|
||||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("A") > -1)
|
|
||||||
// waveData.setA(tmpWaveTitle.get(i + 1).substring(1));
|
|
||||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("B") > -1)
|
|
||||||
// waveData.setB(tmpWaveTitle.get(i + 1).substring(1));
|
|
||||||
// if (tmpWaveTitle.get(i + 1).substring(1).indexOf("C") > -1)
|
|
||||||
// waveData.setC(tmpWaveTitle.get(i + 1).substring(1));
|
|
||||||
// }
|
|
||||||
// /*********** Modify by yexibao ---End **************/
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// System.out.println(pathTemp + "路径下,文件找不到了");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return waveData;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// public WaveDataDTO waveRead(String waveName,String ip){
|
|
||||||
// WaveDataDTO waveDataDTO;
|
|
||||||
// String cfgPath, datPath, cfgPath2, datPath2;
|
|
||||||
// if (generalInfo.getBusinessWaveFileStorage() == GeneralConstant.LOCAL_DISK) {
|
|
||||||
// cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
|
||||||
// datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
|
||||||
// log.info("本地磁盘波形文件路径----" + cfgPath);
|
|
||||||
// InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath(cfgPath);
|
|
||||||
// InputStream datStream = waveFileComponent.getFileInputStreamByFilePath(datPath);
|
|
||||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
|
||||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
|
||||||
// }
|
|
||||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
|
||||||
// } else {
|
|
||||||
// cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
|
||||||
// datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
|
||||||
// //适配文件后缀小写
|
|
||||||
// cfgPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG.toLowerCase();
|
|
||||||
// datPath2 = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT.toLowerCase();
|
|
||||||
// log.info("文件服务器波形文件路径----" + cfgPath);
|
|
||||||
// try (
|
|
||||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
|
||||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath)
|
|
||||||
// ) {
|
|
||||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
|
||||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
|
||||||
// }
|
|
||||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// try {
|
|
||||||
// InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
|
||||||
// InputStream datStream = fileStorageUtil.getFileStream(datPath2);
|
|
||||||
// if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
|
||||||
// throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
|
||||||
// }
|
|
||||||
// waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
|
||||||
// } catch (Exception e1) {
|
|
||||||
// throw new BusinessException(WaveFileResponseEnum.WAVE_DATA_INVALID);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return waveDataDTO;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ package com.njcn.event.common.utils;
|
|||||||
|
|
||||||
|
|
||||||
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
import com.njcn.event.common.pojo.dto.EventEigDetail;
|
||||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
import com.njcn.event.common.pojo.dto.EventInfoDetailVO;
|
||||||
import net.sf.json.JSONArray;
|
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Units;
|
import org.apache.poi.util.Units;
|
||||||
import org.apache.poi.xwpf.usermodel.*;
|
import org.apache.poi.xwpf.usermodel.*;
|
||||||
@@ -14,22 +13,22 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class WordUtil {
|
public class WordUtil {
|
||||||
private Map<Integer, List<byte[]>> listShunPic = new HashMap<>();
|
private Map<String, List<byte[]>> listShunPic = new HashMap<>();
|
||||||
private Map<Integer, List<byte[]>> listRmsPic = new HashMap<>();
|
private Map<String, List<byte[]>> listRmsPic = new HashMap<>();
|
||||||
private XWPFDocument document;
|
private XWPFDocument document;
|
||||||
private Map<Integer, List<EventEigDetail>> eventDetailEigenvalue = new HashMap<>();
|
private Map<String, List<EventEigDetail>> eventDetailEigenvalue = new HashMap<>();
|
||||||
private Map<Integer, RmpEventDetailPO> eventInfoList = new HashMap<>();
|
private Map<String, EventInfoDetailVO> eventInfoList = new HashMap<>();
|
||||||
|
|
||||||
public void setEventInfoList(Integer index, RmpEventDetailPO eventInfoList) {
|
public void setEventInfoList(String index, EventInfoDetailVO eventInfoList) {
|
||||||
RmpEventDetailPO tmp = eventInfoList == null ? new RmpEventDetailPO() : eventInfoList;
|
EventInfoDetailVO tmp = eventInfoList == null ? new EventInfoDetailVO() : eventInfoList;
|
||||||
this.eventInfoList.put(index, tmp);
|
this.eventInfoList.put(index, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEventDetailEigenvalue(Integer index, List<EventEigDetail> eventDetailEigenvalue) {
|
public void setEventDetailEigenvalue(String index, List<EventEigDetail> eventDetailEigenvalue) {
|
||||||
List<EventEigDetail> tmp = eventDetailEigenvalue == null ? new ArrayList<>() : eventDetailEigenvalue;
|
List<EventEigDetail> tmp = eventDetailEigenvalue == null ? new ArrayList<>() : eventDetailEigenvalue;
|
||||||
this.eventDetailEigenvalue.put(index, tmp);
|
this.eventDetailEigenvalue.put(index, tmp);
|
||||||
}
|
}
|
||||||
@@ -42,35 +41,29 @@ public class WordUtil {
|
|||||||
this.document = new XWPFDocument();
|
this.document = new XWPFDocument();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translateShun(Integer index, List<String> strPic) {
|
public void translateShun(String index, String strShunPic) {
|
||||||
BASE64Decoder decoder = new BASE64Decoder();
|
BASE64Decoder decoder = new BASE64Decoder();
|
||||||
List<byte[]> tmp = new ArrayList<>();
|
List<byte[]> tmp = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < strPic.size(); i++) {
|
|
||||||
try {
|
try {
|
||||||
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
|
byte[] buffer = decoder.decodeBuffer(strShunPic);
|
||||||
tmp.add(buffer);
|
tmp.add(buffer);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
listShunPic.put(index, tmp);
|
listShunPic.put(index, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void translateRms(Integer index, List<String> strPic) {
|
public void translateRms(String index, String strRmsPic) {
|
||||||
BASE64Decoder decoder = new BASE64Decoder();
|
BASE64Decoder decoder = new BASE64Decoder();
|
||||||
List<byte[]> tmp = new ArrayList<>();
|
List<byte[]> tmp = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < strPic.size(); i++) {
|
|
||||||
try {
|
try {
|
||||||
byte[] buffer = decoder.decodeBuffer(strPic.get(i));
|
byte[] buffer = decoder.decodeBuffer(strRmsPic);
|
||||||
tmp.add(buffer);
|
tmp.add(buffer);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
|
||||||
listRmsPic.put(index, tmp);
|
listRmsPic.put(index, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createReport(Integer length) throws IOException, InvalidFormatException {
|
public void createReport(List<String> eventIndex) throws IOException, InvalidFormatException {
|
||||||
setHeadingStyle(this.document);
|
setHeadingStyle(this.document);
|
||||||
|
|
||||||
// 添加标题
|
// 添加标题
|
||||||
@@ -89,32 +82,26 @@ public class WordUtil {
|
|||||||
titleParagraph = getLeftParagraph(this.document);
|
titleParagraph = getLeftParagraph(this.document);
|
||||||
titleParagraphDateRun = titleParagraph.createRun();
|
titleParagraphDateRun = titleParagraph.createRun();
|
||||||
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
|
addParagraph(titleParagraphDateRun, "宋体", 10, "000000", "【申明】本公司保留对报告的修改权,恕不另行通知,敬请关注最新版本。", false);
|
||||||
for (int m = 0; m < length; m++) {
|
for (int m = 0; m < eventIndex.size(); m++) {
|
||||||
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(m);
|
String eventId = eventIndex.get(m);
|
||||||
|
List<EventEigDetail> eventDetailEigenvaluetmp = this.eventDetailEigenvalue.get(eventId);
|
||||||
SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
String time = eventInfoList.get(eventId).getTimeID().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
|
||||||
String time = sdfs.format(eventInfoList.get(m).getStartTime());
|
createTitle(document, (m + 1) + ". " + time, "标题 1", 0, 20);
|
||||||
createTitle(document, String.valueOf(m+1) + ". " +time, "标题 1", 0, 20);
|
createTitle(document, (m + 1) + "." + "1. 基本信息", "标题 2", 0, 15);
|
||||||
createTitle(document, String.valueOf(m+1) + "." +"1. 基本信息", "标题 2", 0, 15);
|
|
||||||
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
|
XWPFParagraph introductionContentParagraph = getLeftParagraph(document);
|
||||||
introductionContentParagraph.setIndentationFirstLine(200);
|
introductionContentParagraph.setIndentationFirstLine(200);
|
||||||
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
|
XWPFRun introductionContentRun = introductionContentParagraph.createRun();
|
||||||
addParagraph(introductionContentRun, "宋体", 11, "000000",
|
addParagraph(introductionContentRun, "宋体", 11, "000000", eventInfoList.get(eventId).getGdName() + "," + eventInfoList.get(eventId).getBdzName() + ",网络参数:" + eventInfoList.get(eventId).getIp() + "," + eventInfoList.get(eventId).getLineName() + "于" + time + "发生暂降事件,特征幅值:" + (eventInfoList.get(eventId).getEventValue()) + "%,持续时间:" + eventInfoList.get(eventId).getPersistTime() + "s。", false);
|
||||||
eventInfoList.get(m).getGdName() + "," + eventInfoList.get(m).getBdzName() + ",网络参数:" + eventInfoList.get(m).getIp()
|
createTitle(document, (m + 1) + "." + "2. 波形图", "标题 2", 0, 15);
|
||||||
+ "," + eventInfoList.get(m).getLineName() + "于" + time + "发生暂降事件,特征幅值:"
|
createTitle(document, (m + 1) + "." + "2.1 瞬时波形图", "标题 3", 200, 11);
|
||||||
+ String.valueOf(eventInfoList.get(m).getEventValue()) + "%,持续时间:" + eventInfoList.get(m).getPersistTime()
|
for (int shun = 0; shun < listShunPic.get(eventId).size(); shun++) {
|
||||||
+ "s。",
|
createPic(document, "瞬时波形" + (shun), listShunPic.get(eventId).get(shun));
|
||||||
false);
|
|
||||||
createTitle(document, String.valueOf(m+1) + "." +"2. 波形图", "标题 2", 0, 15);
|
|
||||||
createTitle(document, String.valueOf(m+1) + "." +"2.1 瞬时波形图", "标题 3", 200, 11);
|
|
||||||
for(int shun = 0;shun< listShunPic.get(m).size();shun++){
|
|
||||||
createPic(document, "瞬时波形"+String.valueOf(shun), listShunPic.get(m).get(shun));
|
|
||||||
}
|
}
|
||||||
createTitle(document, String.valueOf(m+1) + "." +"2.2 RMS波形图", "标题 3", 200, 11);
|
createTitle(document, (m + 1) + "." + "2.2 RMS波形图", "标题 3", 200, 11);
|
||||||
for(int rms = 0;rms< listRmsPic.get(m).size();rms++){
|
for (int rms = 0; rms < listRmsPic.get(eventId).size(); rms++) {
|
||||||
createPic(document, "RMS波形"+String.valueOf(rms), listRmsPic.get(m).get(rms));
|
createPic(document, "RMS波形" + (eventId), listRmsPic.get(eventId).get(rms));
|
||||||
}
|
}
|
||||||
createTitle(document, String.valueOf(m+1) + "." +"3. 多特征值", "标题 2", 0, 15);
|
createTitle(document, (m + 1) + "." + "3. 多特征值", "标题 2", 0, 15);
|
||||||
|
|
||||||
XWPFParagraph value = getLeftParagraph(document);
|
XWPFParagraph value = getLeftParagraph(document);
|
||||||
XWPFRun valuex = value.createRun();
|
XWPFRun valuex = value.createRun();
|
||||||
@@ -133,37 +120,13 @@ public class WordUtil {
|
|||||||
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
|
addParagraph(valuex, "宋体", 11, "000000", "分段" + (i + 1) + "多特征值", true);
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
valuex = value.createRun();
|
valuex = value.createRun();
|
||||||
addParagraph(valuex, "宋体", 11, "000000",
|
addParagraph(valuex, "宋体", 11, "000000", "波形起始点相位(°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getPow_a() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getPow_b() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getPow_c())), false);
|
||||||
"波形起始点相位(°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getPow_a() + " "
|
|
||||||
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getPow_b() + " "
|
|
||||||
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
|
|
||||||
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getPow_c())),
|
|
||||||
false);
|
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
valuex = value.createRun();
|
valuex = value.createRun();
|
||||||
addParagraph(valuex, "宋体", 11, "000000",
|
addParagraph(valuex, "宋体", 11, "000000", "跳变段电压变化率(V/ms):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())), false);
|
||||||
"跳变段电压变化率(V/ms):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Va() + " "
|
|
||||||
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Vb() + " "
|
|
||||||
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
|
|
||||||
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getVoltagechange_Vc())),
|
|
||||||
false);
|
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
valuex = value.createRun();
|
valuex = value.createRun();
|
||||||
addParagraph(valuex, "宋体", 11, "000000",
|
addParagraph(valuex, "宋体", 11, "000000", "相位跳变(°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " " + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " " + ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? "" : ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相" + eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())), false);
|
||||||
"相位跳变(°):" + (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "A" : "AB") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_ap() + " "
|
|
||||||
+ (eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "B" : "BC") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_bp() + " "
|
|
||||||
+ ((eventDetailEigenvaluetmp.get(0).getPttype() == 2) ? ""
|
|
||||||
: ((eventDetailEigenvaluetmp.get(0).getPttype() == 0 ? "C" : "CA") + "相"
|
|
||||||
+ eventDetailEigenvaluetmp.get(i).getAngle_diff_cp())),
|
|
||||||
false);
|
|
||||||
/*
|
/*
|
||||||
* addLine(value, 1); valuex = value.createRun();
|
* addLine(value, 1); valuex = value.createRun();
|
||||||
* addParagraph(valuex, "宋体", 11, "000000", "特征幅值(V):A相" +
|
* addParagraph(valuex, "宋体", 11, "000000", "特征幅值(V):A相" +
|
||||||
@@ -178,19 +141,18 @@ public class WordUtil {
|
|||||||
*/
|
*/
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
valuex = value.createRun();
|
valuex = value.createRun();
|
||||||
addParagraph(valuex, "宋体", 11, "000000",
|
addParagraph(valuex, "宋体", 11, "000000", "不平衡度(%):" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
|
||||||
"不平衡度(%):" + eventDetailEigenvaluetmp.get(i).getBph_max_value(), false);
|
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
valuex = value.createRun();
|
valuex = value.createRun();
|
||||||
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(),
|
addParagraph(valuex, "宋体", 11, "000000", "暂降类型:" + eventDetailEigenvaluetmp.get(i).getSagType(), false);
|
||||||
false);
|
|
||||||
addLine(value, 1);
|
addLine(value, 1);
|
||||||
}
|
}
|
||||||
|
addLine(value, 1);
|
||||||
}
|
}
|
||||||
|
System.out.println("11");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPic(XWPFDocument document, String name, byte[] base64Info)
|
public void createPic(XWPFDocument document, String name, byte[] base64Info) throws IOException, InvalidFormatException {
|
||||||
throws IOException, InvalidFormatException {
|
|
||||||
XWPFParagraph picParagraph = getCenterParagraph(document);
|
XWPFParagraph picParagraph = getCenterParagraph(document);
|
||||||
XWPFRun createRun = picParagraph.createRun();
|
XWPFRun createRun = picParagraph.createRun();
|
||||||
InputStream in = new ByteArrayInputStream(base64Info);
|
InputStream in = new ByteArrayInputStream(base64Info);
|
||||||
@@ -213,8 +175,7 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 返回指定格式的段落 居中型
|
* 返回指定格式的段落 居中型
|
||||||
*
|
*
|
||||||
* @param document
|
* @param document 文档对象
|
||||||
* 文档对象
|
|
||||||
*/
|
*/
|
||||||
public XWPFParagraph getCenterParagraph(XWPFDocument document) {
|
public XWPFParagraph getCenterParagraph(XWPFDocument document) {
|
||||||
XWPFParagraph paragraph = document.createParagraph();
|
XWPFParagraph paragraph = document.createParagraph();
|
||||||
@@ -227,8 +188,7 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 返回指定格式的段落 居左型
|
* 返回指定格式的段落 居左型
|
||||||
*
|
*
|
||||||
* @param document
|
* @param document 文档对象
|
||||||
* 文档对象
|
|
||||||
*/
|
*/
|
||||||
public XWPFParagraph getLeftParagraph(XWPFDocument document) {
|
public XWPFParagraph getLeftParagraph(XWPFDocument document) {
|
||||||
XWPFParagraph paragraph = document.createParagraph();
|
XWPFParagraph paragraph = document.createParagraph();
|
||||||
@@ -240,10 +200,8 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 添加换行符
|
* 添加换行符
|
||||||
*
|
*
|
||||||
* @param paragraph
|
* @param paragraph 指定段落
|
||||||
* 指定段落
|
* @param amount 行数
|
||||||
* @param amount
|
|
||||||
* 行数
|
|
||||||
*/
|
*/
|
||||||
public void addLine(XWPFParagraph paragraph, Integer amount) {
|
public void addLine(XWPFParagraph paragraph, Integer amount) {
|
||||||
XWPFRun run = paragraph.createRun();
|
XWPFRun run = paragraph.createRun();
|
||||||
@@ -256,19 +214,13 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 添加段落文本
|
* 添加段落文本
|
||||||
*
|
*
|
||||||
* @param run
|
* @param run 文本执行对象
|
||||||
* 文本执行对象
|
* @param fontFamily 字体类型
|
||||||
* @param fontFamily
|
* @param fontSize 字体大小
|
||||||
* 字体类型
|
* @param backgroundColor 字体颜色
|
||||||
* @param fontSize
|
* @param bold 是否加粗
|
||||||
* 字体大小
|
|
||||||
* @param backgroundColor
|
|
||||||
* 字体颜色
|
|
||||||
* @param bold
|
|
||||||
* 是否加粗
|
|
||||||
*/
|
*/
|
||||||
public void addParagraph(XWPFRun run, String fontFamily, Integer fontSize, String backgroundColor, String message,
|
public void addParagraph(XWPFRun run, String fontFamily, Integer fontSize, String backgroundColor, String message, boolean bold) {
|
||||||
boolean bold) {
|
|
||||||
run.setText(message);
|
run.setText(message);
|
||||||
run.setColor(backgroundColor);
|
run.setColor(backgroundColor);
|
||||||
run.setFontSize(fontSize);
|
run.setFontSize(fontSize);
|
||||||
@@ -279,12 +231,9 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 增加自定义标题样式。这里用的是stackoverflow的源码
|
* 增加自定义标题样式。这里用的是stackoverflow的源码
|
||||||
*
|
*
|
||||||
* @param docxDocument
|
* @param docxDocument 目标文档
|
||||||
* 目标文档
|
* @param strStyleId 样式名称
|
||||||
* @param strStyleId
|
* @param headingLevel 样式级别
|
||||||
* 样式名称
|
|
||||||
* @param headingLevel
|
|
||||||
* 样式级别
|
|
||||||
*/
|
*/
|
||||||
public void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
|
public void addCustomHeadingStyle(XWPFDocument docxDocument, String strStyleId, int headingLevel) {
|
||||||
|
|
||||||
@@ -338,12 +287,9 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 给表格添加一行数据
|
* 给表格添加一行数据
|
||||||
*
|
*
|
||||||
* @param paragraph
|
* @param paragraph 段落对象
|
||||||
* 段落对象
|
* @param row 行对象
|
||||||
* @param row
|
* @param data 不定长度的数据
|
||||||
* 行对象
|
|
||||||
* @param data
|
|
||||||
* 不定长度的数据
|
|
||||||
*/
|
*/
|
||||||
public void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
|
public void setExcelContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
|
||||||
for (int i = 0; i < data.length; i++) {
|
for (int i = 0; i < data.length; i++) {
|
||||||
@@ -358,12 +304,9 @@ public class WordUtil {
|
|||||||
/**
|
/**
|
||||||
* 添加表头标题一行数据
|
* 添加表头标题一行数据
|
||||||
*
|
*
|
||||||
* @param paragraph
|
* @param paragraph 段落对象
|
||||||
* 段落对象
|
* @param row 行对象
|
||||||
* @param row
|
* @param data 不定长度的数据
|
||||||
* 行对象
|
|
||||||
* @param data
|
|
||||||
* 不定长度的数据
|
|
||||||
*/
|
*/
|
||||||
public void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
|
public void setExcelHeadContent(XWPFParagraph paragraph, XWPFTableRow row, String... data) {
|
||||||
XWPFRun run = paragraph.createRun();
|
XWPFRun run = paragraph.createRun();
|
||||||
@@ -395,290 +338,5 @@ public class WordUtil {
|
|||||||
return year + "年" + month + "月" + day + "日";
|
return year + "年" + month + "月" + day + "日";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createWave(WaveData waveData) throws Exception {
|
|
||||||
HashMap<String, Object> datas = new HashMap<>();
|
|
||||||
List<List<Float>> sunData = waveData.getSunData();
|
|
||||||
int iphasic =waveData.getiPhasic();
|
|
||||||
float pt = waveData.getPt() / 1000;
|
|
||||||
float ifmax = 0f, ifmin = 0f;
|
|
||||||
List<List<Float>> adata = new ArrayList<>();
|
|
||||||
List<List<Float>> bdata = new ArrayList<>();
|
|
||||||
List<List<Float>> cdata = new ArrayList<>();
|
|
||||||
|
|
||||||
if (sunData.size() > 0) {
|
|
||||||
ifmax = sunData.get(0).get(1) * pt;
|
|
||||||
ifmin = sunData.get(0).get(1) * pt;
|
|
||||||
}
|
|
||||||
List<String> colors =new ArrayList<>();
|
|
||||||
|
|
||||||
for (int i = 0; i < sunData.size(); i++) {
|
|
||||||
float x = sunData.get(i).get(0);
|
|
||||||
if(iphasic==1){
|
|
||||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
ifmax = ifmax > shunFirstA ? ifmax : shunFirstA;
|
|
||||||
ifmin = ifmin < shunFirstA ? ifmin : shunFirstA;
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#fff");
|
|
||||||
colors.add("#fff");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", "");
|
|
||||||
datas.put("c", "");
|
|
||||||
}else if(iphasic==2){
|
|
||||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
|
||||||
float shunFirstB = sunData.get(i).get(2) * pt;
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
|
|
||||||
List<Float> b = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstB);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bdata.add(b);
|
|
||||||
|
|
||||||
ifmax = getMaxTwo(ifmax, shunFirstA, shunFirstB);
|
|
||||||
ifmin = getMinTwo(ifmin, shunFirstA, shunFirstB);
|
|
||||||
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#2E8B57");
|
|
||||||
colors.add("#fff");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", waveData.getB());
|
|
||||||
datas.put("c", "");
|
|
||||||
|
|
||||||
}else if(iphasic==3){
|
|
||||||
float shunFirstA = sunData.get(i).get(1) * pt;
|
|
||||||
float shunFirstB = sunData.get(i).get(2) * pt;
|
|
||||||
float shunFirstC = sunData.get(i).get(3) * pt;
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
|
|
||||||
List<Float> b = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstB);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bdata.add(b);
|
|
||||||
|
|
||||||
List<Float> c = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(shunFirstC);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
cdata.add(c);
|
|
||||||
ifmax = getMax(ifmax, shunFirstA, shunFirstB, shunFirstC);
|
|
||||||
ifmin = getMin(ifmin, shunFirstA, shunFirstB, shunFirstC);
|
|
||||||
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#2E8B57");
|
|
||||||
colors.add("#A52a2a");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", waveData.getB());
|
|
||||||
datas.put("c", waveData.getC());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String time = waveData.getTime();
|
|
||||||
time = time.replace(" ", "%20");
|
|
||||||
float severity = waveData.getYzd();
|
|
||||||
String strSeverity = String.valueOf(severity);
|
|
||||||
String type = waveData.getWaveType();
|
|
||||||
|
|
||||||
if (severity < 0) {
|
|
||||||
strSeverity = "/";
|
|
||||||
type = "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue()
|
|
||||||
+ "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
|
||||||
|
|
||||||
|
|
||||||
datas.put("title", title);
|
|
||||||
datas.put("adata", JSONArray.fromObject(adata).toString());
|
|
||||||
datas.put("bdata", JSONArray.fromObject(bdata).toString());
|
|
||||||
datas.put("cdata", JSONArray.fromObject(cdata).toString());
|
|
||||||
datas.put("unit", "kV");
|
|
||||||
datas.put("max", String.valueOf(ifmax));
|
|
||||||
datas.put("min", String.valueOf(ifmin));
|
|
||||||
datas.put("colors", JSONArray.fromObject(colors).toString());
|
|
||||||
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
|
|
||||||
|
|
||||||
|
|
||||||
String option = FreemarkerUtil.generateString("wave.ftl", "com/pqs9200/template", datas);
|
|
||||||
return EchartsUtil.generateEchartsBase64(option, "3003");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String createRms(WaveData waveData) throws IOException, TemplateException {
|
|
||||||
List<List<Float>> rmsData = waveData.getRmsData();
|
|
||||||
HashMap<String, Object> datas = new HashMap<>();
|
|
||||||
int iphasic =waveData.getiPhasic();
|
|
||||||
float pt = waveData.getPt() / 1000;
|
|
||||||
List<List<Float>> adata = new ArrayList<>();
|
|
||||||
List<List<Float>> bdata = new ArrayList<>();
|
|
||||||
List<List<Float>> cdata = new ArrayList<>();
|
|
||||||
|
|
||||||
List<String> colors =new ArrayList<>();
|
|
||||||
for (int i = 0; i < rmsData.size(); i++) {
|
|
||||||
float x = rmsData.get(i).get(0);
|
|
||||||
if(iphasic==1){
|
|
||||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#fff");
|
|
||||||
colors.add("#fff");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", "");
|
|
||||||
datas.put("c", "");
|
|
||||||
}else if(iphasic==2){
|
|
||||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
|
||||||
float rmsFirstB = rmsData.get(i).get(2) * pt;
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
|
|
||||||
List<Float> b = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstB);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bdata.add(b);
|
|
||||||
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#2E8B57");
|
|
||||||
colors.add("#fff");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", waveData.getB());
|
|
||||||
datas.put("c", "");
|
|
||||||
}else if(iphasic==3){
|
|
||||||
float rmsFirstA = rmsData.get(i).get(1) * pt;
|
|
||||||
float rmsFirstB = rmsData.get(i).get(2) * pt;
|
|
||||||
float rmsFirstC = rmsData.get(i).get(3) * pt;
|
|
||||||
|
|
||||||
List<Float> a = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstA);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
adata.add(a);
|
|
||||||
|
|
||||||
List<Float> b = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstB);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
bdata.add(b);
|
|
||||||
|
|
||||||
List<Float> c = new ArrayList() {
|
|
||||||
{
|
|
||||||
add(x);
|
|
||||||
add(rmsFirstC);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
cdata.add(c);
|
|
||||||
|
|
||||||
colors.add("#DAA520");
|
|
||||||
colors.add("#2E8B57");
|
|
||||||
colors.add("#A52a2a");
|
|
||||||
|
|
||||||
datas.put("a", waveData.getA());
|
|
||||||
datas.put("b", waveData.getB());
|
|
||||||
datas.put("c", waveData.getC());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String time = waveData.getTime();
|
|
||||||
time = time.replace(" ", "%20"); // 时分秒
|
|
||||||
float severity = waveData.getYzd();
|
|
||||||
String strSeverity = String.valueOf(severity);
|
|
||||||
String type = waveData.getWaveType();
|
|
||||||
|
|
||||||
if (severity < 0) {
|
|
||||||
strSeverity = "/";
|
|
||||||
type = "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
String title = "监测点名称:" + waveData.getLineName() + "%20发生时刻:" + time + "%20特征幅值:" + waveData.getEventValue()
|
|
||||||
+ "%25%20持续时间:" + waveData.getPersistTime() + "s";
|
|
||||||
|
|
||||||
|
|
||||||
datas.put("title", title);
|
|
||||||
datas.put("adata", JSONArray.fromObject(adata).toString());
|
|
||||||
datas.put("bdata", JSONArray.fromObject(bdata).toString());
|
|
||||||
datas.put("cdata", JSONArray.fromObject(cdata).toString());
|
|
||||||
datas.put("unit", "kV");
|
|
||||||
datas.put("colors", JSONArray.fromObject(colors).toString());
|
|
||||||
datas.put("cshow", Boolean.toString(!waveData.getOpenTri()));
|
|
||||||
|
|
||||||
String option = FreemarkerUtil.generateString("rms.ftl", "com/pqs9200/template", datas);
|
|
||||||
return EchartsUtil.generateEchartsBase64(option, "3003");
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getMin(float temp, float tempA, float tempB, float tempC) {
|
|
||||||
temp = temp < tempA ? temp : tempA;
|
|
||||||
temp = temp < tempB ? temp : tempB;
|
|
||||||
temp = temp < tempC ? temp : tempC;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getMinTwo(float temp, float tempA, float tempB) {
|
|
||||||
temp = temp < tempA ? temp : tempA;
|
|
||||||
temp = temp < tempB ? temp : tempB;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getMax(float temp, float tempA, float tempB, float tempC) {
|
|
||||||
temp = temp > tempA ? temp : tempA;
|
|
||||||
temp = temp > tempB ? temp : tempB;
|
|
||||||
temp = temp > tempC ? temp : tempC;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private float getMaxTwo(float temp, float tempA, float tempB) {
|
|
||||||
temp = temp > tempA ? temp : tempA;
|
|
||||||
temp = temp > tempB ? temp : tempB;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user