1.稳态监测点报告bug修改

This commit is contained in:
2026-01-09 16:00:57 +08:00
parent 875d114733
commit 22c8ff3b22
4 changed files with 125 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.controller; package com.njcn.harmonic.controller.report;
import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DatePattern;
@@ -6,7 +6,7 @@ import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.njcn.common.pojo.constant.PatternRegex; import cn.hutool.core.util.StrUtil;
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.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
@@ -22,7 +22,6 @@ import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.enums.EventResponseEnum; import com.njcn.event.enums.EventResponseEnum;
import com.njcn.harmonic.pojo.param.ReportQueryParam; import com.njcn.harmonic.pojo.param.ReportQueryParam;
import com.njcn.harmonic.pojo.po.report.EnumPass; import com.njcn.harmonic.pojo.po.report.EnumPass;
import com.njcn.harmonic.pojo.po.report.OverLimitInfo;
import com.njcn.harmonic.pojo.po.report.Pass; import com.njcn.harmonic.pojo.po.report.Pass;
import com.njcn.harmonic.pojo.po.report.ReportTarget; import com.njcn.harmonic.pojo.po.report.ReportTarget;
import com.njcn.harmonic.pojo.vo.ReportValue; import com.njcn.harmonic.pojo.vo.ReportValue;
@@ -34,7 +33,6 @@ 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 com.njcn.system.pojo.po.Theme; import com.njcn.system.pojo.po.Theme;
import com.njcn.web.constant.ValidMessage;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -45,12 +43,13 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -242,7 +241,7 @@ public class ExportModelController extends BaseController {
reportmap.put("$btype$", btype); reportmap.put("$btype$", btype);
reportmap.put("$ctype$", ctype); reportmap.put("$ctype$", ctype);
Map<String, Object> header = new HashMap<>(16); /* Map<String, Object> header = new HashMap<>(16);
if (ObjectUtil.isNotEmpty(file)) { if (ObjectUtil.isNotEmpty(file)) {
byte[] bytes = file.getBytes(); byte[] bytes = file.getBytes();
if(bytes.length>0){ if(bytes.length>0){
@@ -289,8 +288,12 @@ public class ExportModelController extends BaseController {
header.put("height", 250); header.put("height", 250);
header.put("type", contentType); header.put("type", contentType);
header.put("content", data); header.put("content", data);
}
}*/
// ======== 修复后的图片处理核心逻辑 ========
Map<String, Object> header = handleImageData(file, picPathResource);
reportmap.put("$image$", header);
reportmap.put("$image$", header); reportmap.put("$image$", header);
getVirtualData(param); getVirtualData(param);
@@ -454,31 +457,31 @@ public class ExportModelController extends BaseController {
if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) { if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} else if (vaveValue < vminValue) { } else if (vaveValue < vminValue) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} else if (vcp95Value < vminValue) { } else if (vcp95Value < vminValue) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} else if (!(imaxValue >= iminValue && imaxValue >= iaveValue && imaxValue >= icp95Value)) { } else if (!(imaxValue >= iminValue && imaxValue >= iaveValue && imaxValue >= icp95Value)) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} else if (iaveValue < iminValue) { } else if (iaveValue < iminValue) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} else if (icp95Value < iminValue) { } else if (icp95Value < iminValue) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName
+ "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + "基波电压/电流数据存在异常(不是数值类型)。"; strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + "基波电压/电流数据存在异常(不是数值类型)。\r\n";
break; break;
} }
} }
@@ -502,7 +505,12 @@ public class ExportModelController extends BaseController {
new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"), new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"),
DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒")}); DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒")});
// 报告编号 // 报告编号
reportmap.put("$number$", reportNumber); if(StrUtil.isNotBlank(reportNumber)){
reportmap.put("$number$", reportNumber);
}else {
reportmap.put("$number$", "");
}
// 客户名称 // 客户名称
reportmap.put("$titlePoint$", crmName); reportmap.put("$titlePoint$", crmName);
// 报告生成时间 // 报告生成时间
@@ -637,7 +645,6 @@ public class ExportModelController extends BaseController {
// 值错误判断 // 值错误判断
try { try {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
tmpstrMap = "A";
switch (i) { switch (i) {
case 0: case 0:
tmpstrMap = "A"; tmpstrMap = "A";
@@ -673,13 +680,13 @@ public class ExportModelController extends BaseController {
if("".equals(strResultVdeviationdataValue)){ if("".equals(strResultVdeviationdataValue)){
if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) { if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) {
strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName
+ "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (vaveValue < vminValue) { } else if (vaveValue < vminValue) {
strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName
+ "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (vcp95Value < vminValue) { } else if (vcp95Value < vminValue) {
strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName
+ "电压偏差数据数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "电压偏差数据数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} }
} }
@@ -726,7 +733,7 @@ public class ExportModelController extends BaseController {
} }
} catch (Exception e) { } catch (Exception e) {
strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + "电压偏差数据存在异常(不是数值类型)。"; strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + "电压偏差数据存在异常(不是数值类型)。\r\n";
} }
// //
@@ -782,7 +789,7 @@ public class ExportModelController extends BaseController {
cp95Value = Double.parseDouble(valueOfFreValue.getCp95Value().toString()); cp95Value = Double.parseDouble(valueOfFreValue.getCp95Value().toString());
limit = Math.abs(Double.parseDouble(valueOfFreLimit)); limit = Math.abs(Double.parseDouble(valueOfFreLimit));
} catch (Exception e) { } catch (Exception e) {
strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + "频率偏差数据存在异常(不是数值类型)。"; strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + "频率偏差数据存在异常(不是数值类型)。\r\n";
} }
if (Math.abs(maxValue) > limit) { if (Math.abs(maxValue) > limit) {
@@ -800,13 +807,13 @@ public class ExportModelController extends BaseController {
if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) {
strResultFreValue += "注意:从上表中可以看出" + strLineBaseName strResultFreValue += "注意:从上表中可以看出" + strLineBaseName
+ "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (aveValue < minValue) { } else if (aveValue < minValue) {
strResultFreValue += "注意:从上表中可以看出" + strLineBaseName strResultFreValue += "注意:从上表中可以看出" + strLineBaseName
+ "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (cp95Value < minValue) { } else if (cp95Value < minValue) {
strResultFreValue += "注意:从上表中可以看出" + strLineBaseName strResultFreValue += "注意:从上表中可以看出" + strLineBaseName
+ "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} }
if ("".equals(tmpstrResultFre)) { if ("".equals(tmpstrResultFre)) {
@@ -816,9 +823,9 @@ public class ExportModelController extends BaseController {
} else { } else {
// 三张大表取值 // 三张大表取值
reportmap.put("$FV0R$", "不合格"); reportmap.put("$FV0R$", "不合格");
strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。"; strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。\r\n";
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit
+ deviceUnit.getUnitFrequencyDev() + ")的要求。"; + deviceUnit.getUnitFrequencyDev() + ")的要求。\r\n";
} }
reportmap.put("$ResultFre$", strResultFre); reportmap.put("$ResultFre$", strResultFre);
@@ -856,7 +863,7 @@ public class ExportModelController extends BaseController {
cp95Value = Double.parseDouble(valueOfThree.getCp95Value().toString()); cp95Value = Double.parseDouble(valueOfThree.getCp95Value().toString());
limit = Double.parseDouble(valueOfThreeLimit); limit = Double.parseDouble(valueOfThreeLimit);
} catch (Exception e) { } catch (Exception e) {
strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + "三相电压不平衡度数据存在异常(不是数值类型)。"; strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + "三相电压不平衡度数据存在异常(不是数值类型)。\r\n";
} }
if (cp95Value > limit) { if (cp95Value > limit) {
// 三张大表取值 // 三张大表取值
@@ -869,13 +876,13 @@ public class ExportModelController extends BaseController {
if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) {
strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName
+ "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (aveValue < minValue) { } else if (aveValue < minValue) {
strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName
+ "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} else if (cp95Value < minValue) { } else if (cp95Value < minValue) {
strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName
+ "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。"; + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值2、平均值>=最小值3、95%概率值>=最小值)。\r\n";
} }
if ("".equals(tmpstrResultThree)) { if ("".equals(tmpstrResultThree)) {
@@ -910,7 +917,7 @@ public class ExportModelController extends BaseController {
fmaxValue3 = Double.parseDouble(plt3.getFmaxValue().toString()); fmaxValue3 = Double.parseDouble(plt3.getFmaxValue().toString());
flickerLimit = Double.parseDouble(valueOfFlickerLimit); flickerLimit = Double.parseDouble(valueOfFlickerLimit);
} catch (Exception e) { } catch (Exception e) {
strResultFlickerValue += "注意:从上表中可以看出" + strLineBaseName + "长时闪变数据存在异常(不是数值类型)。"; strResultFlickerValue += "注意:从上表中可以看出" + strLineBaseName + "长时闪变数据存在异常(不是数值类型)。\r\n";
} }
if (fmaxValue1 > flickerLimit) { if (fmaxValue1 > flickerLimit) {
if (!"".equals(tmpstrResultFlicker)) if (!"".equals(tmpstrResultFlicker))
@@ -1093,7 +1100,7 @@ public class ExportModelController extends BaseController {
aveValue = Double.parseDouble(strCurrentC); aveValue = Double.parseDouble(strCurrentC);
limit = Double.parseDouble(strLimit); limit = Double.parseDouble(strLimit);
} catch (Exception e) { } catch (Exception e) {
strResultVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电压含有率95%概率值数据存在异常(不是数值类型)。"; strResultVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + (i+1)+"谐波电压含有率95%概率值数据存在异常(不是数值类型)。\r\n";
} }
String tmpstrResult = ""; String tmpstrResult = "";
@@ -1132,16 +1139,16 @@ public class ExportModelController extends BaseController {
} }
// 判断单个结论是否存在 // 判断单个结论是否存在
if (!"".equals(tmpstrResult)) { if (!"".equals(tmpstrResult)) {
tmpstrResultVoltageRate += (i + 1) + "次谐波电压含有率95%概率值" + tmpstrResult + ";"; tmpstrResultVoltageRate += (i + 1) + "次谐波电压含有率95%概率值" + tmpstrResult + ";\r\n";
} }
} }
// 假如为空则所有的都满足 // 假如为空则所有的都满足
if ("".equals(tmpstrResultVoltageRate)) { if ("".equals(tmpstrResultVoltageRate)) {
strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。"; strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。\r\n";
} else { } else {
strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。"; strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。\r\n";
strResultVoltageRate += "从上表中可以看出" + strLineBaseName + tmpstrResultVoltageRate + "均不满足国标限值要求。"; strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "\r\n"+tmpstrResultVoltageRate + "均不满足国标限值要求。\r\n";
} }
/************************************************************** /**************************************************************
@@ -1187,7 +1194,7 @@ public class ExportModelController extends BaseController {
cp95ValueC = Math.abs(Double.parseDouble(distortion3.getCp95Value().toString())); cp95ValueC = Math.abs(Double.parseDouble(distortion3.getCp95Value().toString()));
limit = Math.abs(Double.parseDouble(distortionLimit)); limit = Math.abs(Double.parseDouble(distortionLimit));
} catch (Exception e) { } catch (Exception e) {
strResultDistortionValue += "注意:从上表中可以看出" + strLineBaseName + "电压总谐波畸变率(THD)数据存在异常(不是数值类型)。"; strResultDistortionValue += "注意:从上表中可以看出" + strLineBaseName + "电压总谐波畸变率(THD)数据存在异常(不是数值类型)。\r\n";
} }
// 限值判断 // 限值判断
if (cp95ValueA > limit) { if (cp95ValueA > limit) {
@@ -1223,17 +1230,20 @@ public class ExportModelController extends BaseController {
// 三张大表取值 // 三张大表取值
reportmap.put("$TV0R_C$", "合格"); reportmap.put("$TV0R_C$", "合格");
} }
strError += strResultVoltageRateValue + strResultDistortionValue;
// 假如为空则所有的都满足 // 假如为空则所有的都满足
if ("".equals(tmpstrResultDistortion)) { if ("".equals(tmpstrResultDistortion) && "".equals(strResultDistortionValue)) {
strResultDistortion += "电压总谐波畸变率(THD)95%概率值均满足国标限值要求。"; strResultDistortion += "电压总谐波畸变率(THD)95%概率值均满足国标限值要求。\r\n";
reportmap.put("$ResultVoltageRateValue$", "");
} else { } else {
strAnalysis += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; strAnalysis += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。\r\n";
strResultDistortion += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; strResultDistortion += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。\r\n";
reportmap.put("$ResultVoltageRateValue$", strError);
} }
reportmap.put("$ResultVoltageRate$", strResultVoltageRate + strResultDistortion); reportmap.put("$ResultVoltageRate$", strResultVoltageRate + strResultDistortion);
reportmap.put("$ResultVoltageRateValue$", strResultVoltageRateValue + strResultDistortionValue);
strError += strResultVoltageRateValue + strResultDistortionValue;
/************************************************************** /**************************************************************
**** 谐波电流幅值 **** 谐波电流幅值
@@ -1283,7 +1293,7 @@ public class ExportModelController extends BaseController {
aveValue = Double.parseDouble(strCurrentC); aveValue = Double.parseDouble(strCurrentC);
limit = Double.parseDouble(strLimit); limit = Double.parseDouble(strLimit);
} catch (Exception e) { } catch (Exception e) {
strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电流幅值95%概率值数据存在异常(不是数值类型)。"; strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName +(i + 1)+ "谐波电流幅值95%概率值数据存在异常(不是数值类型)。\r\n";
} }
String tmpstrResult = ""; String tmpstrResult = "";
@@ -1322,21 +1332,22 @@ public class ExportModelController extends BaseController {
} }
// 判断单个结论是否存在 // 判断单个结论是否存在
if (!"".equals(tmpstrResult)) { if (!"".equals(tmpstrResult)) {
tmpstrResultCurrent += (i + 1) + "次谐波电流幅值95%概率值" + tmpstrResult + ";"; tmpstrResultCurrent += (i + 1) + "次谐波电流幅值95%概率值" + tmpstrResult + ";\r\n";
} }
} }
strError += strResultCurrentValue;
// 假如为空则所有的都满足 // 假如为空则所有的都满足
if ("".equals(tmpstrResultCurrent)) { if ("".equals(tmpstrResultCurrent) && "".equals(strResultCurrentValue)) {
strResultCurrent += "从上表中可以看出" + strLineBaseName + "2-25次谐波电流幅值95%概率值均满足国标限值要求。"; strResultCurrent += "从上表中可以看出" + strLineBaseName + "\r\n2-25次谐波电流幅值95%概率值均满足国标限值要求。\r\n";
reportmap.put("$ResultCurrentValue$", "");
} else { } else {
strAnalysis += tmpstrResultCurrent + "均不满足国标限值要求。"; strAnalysis += tmpstrResultCurrent + "均不满足国标限值要求。";
strResultCurrent += "从上表中可以看出" + strLineBaseName + tmpstrResultCurrent + "均不满足国标限值要求。"; strResultCurrent += "从上表中可以看出" + strLineBaseName + tmpstrResultCurrent + "均不满足国标限值要求。\r\n";
reportmap.put("$ResultCurrentValue$", strError);
} }
reportmap.put("$ResultCurrent$", strResultCurrent); reportmap.put("$ResultCurrent$", strResultCurrent);
reportmap.put("$ResultCurrentValue$", strResultCurrentValue);
strError += strResultCurrentValue;
// 测试结果填写 // 测试结果填写
reportmap.put("$ResultTitle$", String.format("通过对(%s——%s时间段内%s电能质量统计数据分析后得出以下结论", reportmap.put("$ResultTitle$", String.format("通过对(%s——%s时间段内%s电能质量统计数据分析后得出以下结论",
@@ -1816,4 +1827,64 @@ public class ExportModelController extends BaseController {
list.add(overLimit.getUharm25()); list.add(overLimit.getUharm25());
return list; return list;
} }
/**
* 修复处理图片字节流+获取自适应宽高按原图比例适配Word的EMU单位防止截断
* @param multipartFile 上传的图片文件(可为null)
* @param defaultPicResource 默认图片资源(ClassPathResource)
* @return Map<String,Object> 包含content/width/height/type直接给header用
*/
private Map<String, Object> handleImageData(MultipartFile multipartFile, ClassPathResource defaultPicResource) {
Map<String, Object> imgMap = new HashMap<>(4);
byte[] imgBytes = null;
String contentType = null;
try {
if (ObjectUtil.isNotEmpty(multipartFile) && multipartFile.getSize() > 0) {
// 处理上传的图片
imgBytes = multipartFile.getBytes();
contentType = multipartFile.getContentType();
} else {
// 处理默认图片修复流读取不完整问题
if (defaultPicResource != null && defaultPicResource.exists()) {
try (InputStream in = defaultPicResource.getInputStream()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) != -1) {
baos.write(buffer, 0, len);
}
imgBytes = baos.toByteArray();
contentType = "image/jpeg"; // 默认图片是jpg
}
}
}
// 核心修复获取图片真实宽高 + 按比例自适应缩放关键解决只显示一半
if (imgBytes != null && imgBytes.length > 0) {
ByteArrayInputStream bais = new ByteArrayInputStream(imgBytes);
BufferedImage bufferedImage = ImageIO.read(bais);
int realWidth = bufferedImage.getWidth();
int realHeight = bufferedImage.getHeight();
// 核心配置设置Word中图片的最大显示宽度高度按比例自动计算永不截断
int maxWordImgWidth = 550; // 建议值适配Word页面宽度可微调
double scale = 1.0;
if (realWidth > maxWordImgWidth) {
scale = (double) maxWordImgWidth / realWidth;
}
int adaptWidth = (int) (realWidth * scale);
int adaptHeight = (int) (realHeight * scale);
// 赋值到map直接给原逻辑的header用
imgMap.put("content", imgBytes);
imgMap.put("width", adaptWidth);
imgMap.put("height", adaptHeight);
imgMap.put("type", ObjectUtil.isNotEmpty(contentType) ? contentType : "image/jpeg");
}
} catch (Exception e) {
log.error("处理图片数据异常", e);
}
return imgMap;
}
} }

View File

@@ -1,4 +1,4 @@
package com.njcn.harmonic.controller; package com.njcn.harmonic.controller.report;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;

View File

@@ -401,7 +401,7 @@ public class CustomReportServiceImpl implements CustomReportService {
private void assStatMethod(EleEpdPqd item, List<ReportTreeVO> statTree, String oneKey, String twoKey) { private void assStatMethod(EleEpdPqd item, List<ReportTreeVO> statTree, String oneKey, String twoKey) {
//存在向别为M但是Stat_Method不为空 //存在向别为M但是Stat_Method不为空
if (StrUtil.isNotBlank(item.getStatMethod())) { if (StrUtil.isNotBlank(item.getStatMethod())) {
String[] arr = item.getStatMethod().split(","); String[] arr = item.getStatMethod().split(StrUtil.COMMA);
List<String> stat = Stream.of(arr).collect(Collectors.toList()); List<String> stat = Stream.of(arr).collect(Collectors.toList());
if (CollUtil.isNotEmpty(stat)) { if (CollUtil.isNotEmpty(stat)) {
stat.forEach(statItem -> { stat.forEach(statItem -> {