治理绘图调整
This commit is contained in:
@@ -481,7 +481,7 @@ public class LineGenerator {
|
||||
instantOption.setLegend(new Legend().setData(new String[]{a, b, c}).setLeft("10px"));
|
||||
}
|
||||
//上下左右的图内间距
|
||||
instantOption.setGrid(new Grid().setTop("60px").setLeft("55px").setRight("40px").setBottom("10%"));
|
||||
instantOption.setGrid(new Grid().setTop("60px").setLeft("70px").setRight("40px").setBottom("10%"));
|
||||
//横坐标
|
||||
instantOption.setXAxis(new ValueAxis().setName("ms")
|
||||
.setMax(df2.format(aValue.get(0).get(0)))
|
||||
|
||||
@@ -62,11 +62,10 @@ public class WaveFileComponent {
|
||||
// 给相别幅值
|
||||
waveDataDTO.setIPhasic(comtradeCfgDTO.getNPhasic());
|
||||
// 组装解析抬头
|
||||
List<String> lstWaveTitle = getWaveTitle(comtradeCfgDTO);
|
||||
getWaveTitle(waveDataDTO,comtradeCfgDTO);
|
||||
// 解析.dat文件
|
||||
List<List<Float>> listWaveData = getComtradeDat(comtradeCfgDTO, datStream, iType);
|
||||
waveDataDTO.setComtradeCfgDTO(comtradeCfgDTO);
|
||||
waveDataDTO.setWaveTitle(lstWaveTitle);
|
||||
waveDataDTO.setListWaveData(listWaveData);
|
||||
//add by hongawen,将暂态触发起始时间记录下来
|
||||
waveDataDTO.setTime(DateUtil.format(comtradeCfgDTO.getFirstTime(), DatePattern.NORM_DATETIME_PATTERN).concat(StrPool.DOT)+comtradeCfgDTO.getFirstMs());
|
||||
@@ -1188,12 +1187,14 @@ public class WaveFileComponent {
|
||||
* param tmpComtradeCfgDTO 文件路径
|
||||
* return 返回List<String>返回数据格式说明
|
||||
**********************************/
|
||||
private List<String> getWaveTitle(ComtradeCfgDTO comtradeCfgDTO) {
|
||||
private void getWaveTitle(WaveDataDTO waveDataDTO, ComtradeCfgDTO comtradeCfgDTO) {
|
||||
//编辑数据标题 YXB2020-10-09 去除相别为N相的数据//存储数据标题
|
||||
List<String> tmpWaveTitle = new ArrayList<>();
|
||||
List<String> channelName = new ArrayList<>();
|
||||
// 模拟量通道记录类
|
||||
AnalogDTO analogDTO;
|
||||
tmpWaveTitle.add("Time");
|
||||
channelName.add("/");
|
||||
String strUnit;
|
||||
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||
analogDTO = comtradeCfgDTO.getLstAnalogDTO().get(j);
|
||||
@@ -1205,9 +1206,11 @@ public class WaveFileComponent {
|
||||
strUnit = "U";
|
||||
}
|
||||
tmpWaveTitle.add(strUnit + analogDTO.getSzPhasicName().toUpperCase() + "相");
|
||||
channelName.add(analogDTO.getSzChannleName());
|
||||
}
|
||||
}
|
||||
return tmpWaveTitle;
|
||||
waveDataDTO.setWaveTitle(tmpWaveTitle);
|
||||
waveDataDTO.setChannelNames(channelName);
|
||||
}
|
||||
|
||||
/*********************************
|
||||
|
||||
@@ -40,6 +40,134 @@ public class WavePicComponent {
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
/***
|
||||
* 绘制瞬时波形图治理
|
||||
* @author hongawen
|
||||
* @date 2023/9/21 15:32
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateInstantImageZl(List<WaveDataDetail> waveDataDetails) {
|
||||
String firstPic = null, secondPic = null, thirdPic = null, forthPic = null;
|
||||
for (WaveDataDetail waveDataDetail : waveDataDetails) {
|
||||
if (waveDataDetail.getChannelName().toUpperCase().startsWith("SU")) {
|
||||
firstPic = drawPicUtil.drawWavePic("电压-电网侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("SI")) {
|
||||
thirdPic = drawPicUtil.drawWavePic("电流-电网侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("LU")) {
|
||||
secondPic = drawPicUtil.drawWavePic("电压-负载侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else {
|
||||
forthPic = drawPicUtil.drawWavePic("电流-负载侧", waveDataDetail.getInstantData().getAValue(),
|
||||
waveDataDetail.getInstantData().getBValue(), waveDataDetail.getInstantData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getInstantData().getMax(), waveDataDetail.getInstantData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
}
|
||||
}
|
||||
return composeImageZl(firstPic, secondPic, thirdPic, forthPic);
|
||||
}
|
||||
|
||||
/***
|
||||
* 绘制RMS波形图治理
|
||||
* @author hongawen
|
||||
* @date 2023/9/21 15:32
|
||||
* @return String 文件地址
|
||||
*/
|
||||
public String generateRmsImageZl(List<WaveDataDetail> waveDataDetails) {
|
||||
String firstPic = null, secondPic = null, thirdPic = null, forthPic = null;
|
||||
for (WaveDataDetail waveDataDetail : waveDataDetails) {
|
||||
if (waveDataDetail.getChannelName().toUpperCase().startsWith("SU")) {
|
||||
firstPic = drawPicUtil.drawWavePic("电压-电网侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("SI")) {
|
||||
thirdPic = drawPicUtil.drawWavePic("电流-电网侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else if (waveDataDetail.getChannelName().toUpperCase().startsWith("LU")) {
|
||||
secondPic = drawPicUtil.drawWavePic("电压-负载侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
} else {
|
||||
forthPic = drawPicUtil.drawWavePic("电流-负载侧", waveDataDetail.getRmsData().getAValue(),
|
||||
waveDataDetail.getRmsData().getBValue(), waveDataDetail.getRmsData().getCValue(),
|
||||
waveDataDetail.getUnit(), waveDataDetail.getRmsData().getMax(), waveDataDetail.getRmsData().getMin(),
|
||||
waveDataDetail.getA(), waveDataDetail.getB(), waveDataDetail.getC(),
|
||||
waveDataDetail.getColors(), waveDataDetail.getIsOpen()
|
||||
);
|
||||
}
|
||||
}
|
||||
return composeImageZl(firstPic, secondPic, thirdPic, forthPic);
|
||||
}
|
||||
|
||||
/***
|
||||
* 合并4个原图
|
||||
* @author hongawen
|
||||
* @date 2023/9/28 14:45
|
||||
* @return String
|
||||
*/
|
||||
private String composeImageZl(String firstPic, String secondPic, String thirdPic, String forthPic) {
|
||||
try {
|
||||
//第一张图片 base64截取删除前缀data:image/png;base64,
|
||||
BufferedImage imageOne = ImgUtil.toBufferedImage(ImgUtil.toImage(firstPic.substring(22)), ImgUtil.IMAGE_TYPE_PNG);
|
||||
int width = imageOne.getWidth();
|
||||
int height = imageOne.getHeight();
|
||||
int[] imageArrayOne = new int[width * height];
|
||||
imageArrayOne = imageOne.getRGB(0, 0, width, height, imageArrayOne, 0, width);
|
||||
//第二张图片 base64截取删除前缀data:image/png;base64,
|
||||
BufferedImage imageTwo = ImgUtil.toBufferedImage(ImgUtil.toImage(secondPic.substring(22)), ImgUtil.IMAGE_TYPE_PNG);
|
||||
int[] ImageArrayTwo = new int[width * height];
|
||||
ImageArrayTwo = imageTwo.getRGB(0, 0, width, height, ImageArrayTwo, 0, width);
|
||||
//第三张图片 base64截取删除前缀data:image/png;base64,
|
||||
BufferedImage imageThree = ImgUtil.toBufferedImage(ImgUtil.toImage(thirdPic.substring(22)), ImgUtil.IMAGE_TYPE_PNG);
|
||||
int[] ImageArrayThree = new int[width * height];
|
||||
ImageArrayThree = imageThree.getRGB(0, 0, width, height, ImageArrayThree, 0, width);
|
||||
//第四张图片 base64截取删除前缀data:image/png;base64,
|
||||
BufferedImage imageForth = ImgUtil.toBufferedImage(ImgUtil.toImage(forthPic.substring(22)), ImgUtil.IMAGE_TYPE_PNG);
|
||||
int[] ImageArrayForth = new int[width * height];
|
||||
ImageArrayForth = imageForth.getRGB(0, 0, width, height, ImageArrayForth, 0, width);
|
||||
//新图片
|
||||
BufferedImage imageNew = new BufferedImage(width, height * 4, BufferedImage.TYPE_INT_RGB);
|
||||
BufferedImageGraphicsConfig config = BufferedImageGraphicsConfig.getConfig(imageNew);
|
||||
imageNew = config.createCompatibleImage(width, height * 4, Transparency.TRANSLUCENT);
|
||||
imageNew.setRGB(0, 0, width, height, imageArrayOne, 0, width);
|
||||
imageNew.setRGB(0, height, width, height, ImageArrayTwo, 0, width);
|
||||
imageNew.setRGB(0, height * 2, width, height, ImageArrayThree, 0, width);
|
||||
imageNew.setRGB(0, height * 3, width, height, ImageArrayForth, 0, width);
|
||||
String resultImg = ImgUtil.toBase64(imageNew, ImgUtil.IMAGE_TYPE_PNG);
|
||||
byte[] bytes = Base64.getDecoder().decode(resultImg);
|
||||
return fileStorageUtil.uploadStream(new ByteArrayInputStream(bytes), OssPath.EVENT_WAVE_PIC, FileUtil.generateFileName("png"));
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(WaveFileResponseEnum.COMPOSE_PIC_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 绘制瞬时波形图
|
||||
* @author hongawen
|
||||
|
||||
@@ -23,6 +23,8 @@ public class WaveDataDetail {
|
||||
|
||||
private String c ="C相";
|
||||
|
||||
private String channelName;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Boolean isOpen = false;
|
||||
|
||||
@@ -23,6 +23,8 @@ public class WaveDataDTO implements Serializable {
|
||||
private ComtradeCfgDTO comtradeCfgDTO;
|
||||
//波形对应的标题
|
||||
private List<String> waveTitle;
|
||||
//波形对应的通道标题
|
||||
private List<String> channelNames;
|
||||
//波形对应的值
|
||||
private List<List<Float>> listWaveData;
|
||||
//波形RMS值
|
||||
|
||||
@@ -21,6 +21,8 @@ public class WaveUtil {
|
||||
public static List<WaveDataDetail> filterWaveData(WaveDataDTO waveDataDTO) {
|
||||
List<WaveDataDetail> waveDataDetails = new ArrayList<>();
|
||||
List<String> waveTitle = waveDataDTO.getWaveTitle();
|
||||
//通道名称,针对治理项目波形文件处理
|
||||
List<String> channelNames = waveDataDTO.getChannelNames();
|
||||
boolean openTri = waveDataDTO.getPtType() == 2;
|
||||
/************ 一个图形的相别决定了图形个数 Modify by yexb -----start ***********/
|
||||
Integer iPhase = waveDataDTO.getIPhasic();
|
||||
@@ -38,6 +40,7 @@ public class WaveUtil {
|
||||
colors.add("#DAA520");
|
||||
colors.add("#fff");
|
||||
colors.add("#fff");
|
||||
waveDataDetail.setChannelName(channelNames.get(i + 1));
|
||||
break;
|
||||
case 2:
|
||||
waveDataDetail.setA(waveTitle.get(i * 2 + 1).substring(1));
|
||||
@@ -46,6 +49,7 @@ public class WaveUtil {
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#fff");
|
||||
waveDataDetail.setChannelName(channelNames.get(i * 2 + 1));
|
||||
break;
|
||||
case 3:
|
||||
waveDataDetail.setA(waveTitle.get(i * 3 + 1).substring(1));
|
||||
@@ -54,6 +58,7 @@ public class WaveUtil {
|
||||
colors.add("#DAA520");
|
||||
colors.add("#2E8B57");
|
||||
colors.add("#A52a2a");
|
||||
waveDataDetail.setChannelName(channelNames.get(i * 3 + 1));
|
||||
break;
|
||||
}
|
||||
waveDataDetail.setColors(colors);
|
||||
|
||||
Reference in New Issue
Block a user