1.技术监督试运行评估-试运行结束后生成试运行报告

2.技术监督计划管理,权限调整为负责地市进行信息修改
3.调整常态化干扰源用户信息更新逻辑
4.调整谐波报告数据请求格式
This commit is contained in:
wr
2024-07-02 16:55:08 +08:00
parent 5ca027513f
commit 50cd5d3895
27 changed files with 510 additions and 283 deletions

View File

@@ -38,6 +38,12 @@
<artifactId>common-poi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-oss</artifactId>
<version>1.0.0</version>
<scope>${project.version}</scope>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>user-api</artifactId>

View File

@@ -0,0 +1,36 @@
package com.njcn.harmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.harmonic.api.fallback.RStatLimitRateDFeignClientFallbackFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@FeignClient(
value = ServerInfo.HARMONIC,
path = "/exportmodel",
fallbackFactory = RStatLimitRateDFeignClientFallbackFactory.class,
contextId = "exportmodel")
public interface ReportFeignClient {
@PostMapping(value ="/exportModel",consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
HttpResult<String> exportWorld(
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") Integer type,
@RequestParam("lineIndex") String lineIndex,
@RequestParam("name") String name,
@RequestParam("reportNumber") String reportNumber,
@RequestParam("crmName") String crmName,
@RequestParam("isUrl") Boolean isUrl,
@RequestPart("file") MultipartFile file) throws IOException;
}

View File

@@ -0,0 +1,51 @@
package com.njcn.harmonic.api.fallback;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.device.biz.utils.DeviceEnumUtil;
import com.njcn.harmonic.api.PqTypicalSourceFeignClient;
import com.njcn.harmonic.api.RStatLimitRateDClient;
import com.njcn.harmonic.api.ReportFeignClient;
import com.njcn.harmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.harmonic.pojo.param.UploadParam;
import com.njcn.harmonic.pojo.po.day.RStatLimitRateDPO;
import com.njcn.harmonic.pojo.po.day.RStatLimitTargetDPO;
import com.njcn.harmonic.pojo.vo.RStatLimitTargetVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author hongawen
* @version 1.0.0
* @date 2023年07月21日 14:31
*/
@Slf4j
@Component
public class ReportClientFallbackFactory implements FallbackFactory<ReportFeignClient> {
@Override
public ReportFeignClient create(Throwable throwable) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (throwable.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) throwable.getCause();
exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new ReportFeignClient() {
@Override
public HttpResult<String> exportWorld( String startTime, String endTime, Integer type, String lineIndex, String name, String reportNumber, String crmName, Boolean isUrl, MultipartFile file) throws IOException {
log.error("{}异常,降级处理,异常为:{}", "获取谐波报告失败", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -1,12 +1,13 @@
package com.njcn.harmonic.utils;
import ch.qos.logback.core.rolling.helper.FileStoreUtil;
import cn.hutool.core.collection.CollUtil;
import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.CollectionUtils;
import org.springframework.stereotype.Component;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@@ -16,10 +17,14 @@ import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
@Component
@RequiredArgsConstructor
public class WordUtil2 {
// 日志记录
private static final Logger logger = LoggerFactory.getLogger(WordUtil2.class);
private final FileStorageUtil fileStorageUtil;
public void getWord(String path, Map<String, Object> params, String fileName, HttpServletResponse response)
throws Exception {
@@ -33,7 +38,7 @@ public class WordUtil2 {
this.replaceInTable(doc, params); // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量
} catch (IOException e) {
logger.error("获取报告模板异常,原因为:" + e);
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
@@ -46,7 +51,7 @@ public class WordUtil2 {
doc.write(outputStream);
outputStream.close();
} catch (Exception e) {
logger.error("输出稳态报告异常,原因为:" + e);
getError("输出稳态报告异常,原因为:" + e);
} finally {
if (doc != null) {
doc.close();
@@ -66,7 +71,7 @@ public class WordUtil2 {
this.replaceInTable(doc,params,tableList);
this.replaceInPara(doc, params);
} catch (IOException e) {
logger.error("获取报告模板异常,原因为:" + e);
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
@@ -80,7 +85,7 @@ public class WordUtil2 {
in = new ByteArrayInputStream(docByteAry);
out.close();
} catch (Exception e) {
logger.error("输出稳态报告异常,原因为:" + e);
getError("输出稳态报告异常,原因为:" + e);
} finally {
if (doc != null) {
doc.close();
@@ -90,6 +95,43 @@ public class WordUtil2 {
}
public String getReportFileUrl(String path,String fileName, Map<String, Object> params)
throws Exception {
path = ClearPathUtil.cleanString(path);
InputStream inStream = null,in = null;
CustomXWPFDocument doc = null;
//读取报告模板
try {
inStream = new ClassPathResource(path).getInputStream();;
doc = new CustomXWPFDocument(inStream);
this.replaceInTable(doc, params); // 替换表格里面的变量
this.replaceInPara(doc, params); // 替换文本里面的变量
//临时缓冲区
ByteArrayOutputStream out = new ByteArrayOutputStream();
doc.write(out);
byte[] docByteAry = out.toByteArray();
in = new ByteArrayInputStream(docByteAry);
out.close();
} catch (IOException e) {
getError("获取报告模板异常,原因为:" + e);
} finally {
if (null != inStream) {
inStream.close();
}
if (doc != null) {
doc.close();
}
}
//上传文件服务器
return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName);
}
private static void getError(String e) {
log.error(e);
}
/**
* 替换段落里面的变量
*
@@ -155,7 +197,7 @@ public class WordUtil2 {
s,paragraph);
bflag = "break";
} catch (Exception e) {
logger.error("文本替换发生异常,异常是" + e.getMessage());
getError("文本替换发生异常,异常是" + e.getMessage());
}
}
}
@@ -234,7 +276,7 @@ public class WordUtil2 {
para.createRun().setText(str, 0);
break;
} catch (Exception e) {
logger.error("文件替换发生异常,异常是" + e.getMessage());
getError("文件替换发生异常,异常是" + e.getMessage());
}
}
}
@@ -336,33 +378,4 @@ public class WordUtil2 {
return res;
}
/**
* 关闭输入流
*
* @param is
*/
private void close(InputStream is) {
if (is != null) {
try {
is.close();
} catch (IOException e) {
logger.error("关闭输入流发生异常,异常是" + e.getMessage());
}
}
}
/**
* 关闭输出流
*
* @param os
*/
private void close(OutputStream os) {
if (os != null) {
try {
os.close();
} catch (IOException e) {
logger.error("关闭输出流发生异常,异常是" + e.getMessage());
}
}
}
}

View File

@@ -75,18 +75,39 @@ public class ExportModelController extends BaseController {
private final ThemeFeignClient themeFeignClient;
private final ReportService reportService;
private final DeviceUnitClient deviceUnitClient;
private final WordUtil2 wordUtil2;
/**
* @param response
* @param startTime 开始时间
* @param endTime 结束时间
* @param type 区分pq:0 pms:1
* @param lineIndex 监测点id
* @param name 监测点名称
* @param reportNumber 客户编号
* @param crmName 客户名称
* @param file 接线图
* @param isUrl 是否地址栏返回
* @return
* @throws IOException
*/
@PostMapping("/exportModel")
@ApiOperation("word报告")
public HttpResult<String> exportWorld(HttpServletResponse response,
String startTime, String endTime, Integer type, String lineIndex,
String name, String reportNumber, String crmName,
MultipartFile file) throws IOException {
@RequestParam("startTime") String startTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") Integer type,
@RequestParam("lineIndex") String lineIndex,
@RequestParam("name") String name,
@RequestParam("reportNumber") String reportNumber,
@RequestParam("crmName") String crmName,
@RequestParam("isUrl") Boolean isUrl,
@RequestPart("file") MultipartFile file) throws IOException {
String methodDescribe = getMethodDescribe("exportWorld");
//获取监测点信息
String bdname = "";
Integer pttype = 0;
String areaName = "";
String bdname;
Integer pttype;
String areaName;
String atype = "";
String btype = "";
String ctype = "";
@@ -163,9 +184,8 @@ public class ExportModelController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "dataFail", methodDescribe);
}
String rtfPath = "";
String rtfPath;
String picPath = "file/default.jpg";
boolean flagPath = false;
Theme theme = themeFeignClient.getTheme().getData();
if (theme.getRemark().equals("国网")) {
@@ -177,31 +197,16 @@ public class ExportModelController extends BaseController {
} else {
rtfPath = "file/reportModel.docx";
}
ClassPathResource rtfPathResource=null;
ClassPathResource picPathResource=null;
//获取图片信息
ClassPathResource picPathResource = null;
try {
rtfPathResource = new ClassPathResource(rtfPath);
picPathResource = new ClassPathResource(picPath);
rtfPath = rtfPath.replaceAll("%20", " ");
picPath = picPath.replaceAll("%20", " ");
} catch (Exception e1) {
log.info("获取报表发生异常,异常是" + e1.getMessage());
}
InputStream ins = null;
try {
ins = rtfPathResource.getInputStream();
if (null != ins) {
flagPath = true;
}
} catch (FileNotFoundException e) {
flagPath = false;
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "readError", methodDescribe);
} finally {
if (ins != null) {
ins.close();
}
}
Map<String, Object> reportmap = new HashMap<>();// 报告Map
//数据单位
@@ -214,11 +219,31 @@ public class ExportModelController extends BaseController {
Map<String, Object> header = new HashMap<String, Object>();
if (ObjectUtil.isNotEmpty(file)) {
byte[] bytes = file.getBytes();
header.put("width", 400);
header.put("height", 250);
header.put("type", file.getContentType());
header.put("content", bytes);
if(bytes.length>0){
header.put("width", 400);
header.put("height", 250);
header.put("type", file.getContentType());
header.put("content", bytes);
}else{
InputStream inStream = null;
byte[] data = null;
try {
inStream = picPathResource.getInputStream();
data = new byte[inStream.available()];
inStream.read(data);
} catch (Exception e) {
log.info("读取报表信息失败:" + e.getMessage());
} finally {
if (inStream != null) {
inStream.close();
}
}
String contentType = "application/x-jpg";
header.put("width", 400);
header.put("height", 250);
header.put("type", contentType);
header.put("content", data);
}
} else {
InputStream inStream = null;
byte[] data = null;
@@ -226,7 +251,7 @@ public class ExportModelController extends BaseController {
inStream = picPathResource.getInputStream();
data = new byte[inStream.available()];
inStream.read(data);
} catch (FileNotFoundException e) {
} catch (Exception e) {
log.info("读取报表信息失败:" + e.getMessage());
} finally {
if (inStream != null) {
@@ -243,12 +268,12 @@ public class ExportModelController extends BaseController {
reportmap.put("$image$", header);
getVirtualData(param);
ReportValue voltage1 = (ReportValue) this.listVirtual.get(0).getList().get(0);// 电压幅值
ReportValue voltage2 = (ReportValue) this.listVirtual.get(0).getList().get(1);// 电压幅值
ReportValue voltage3 = (ReportValue) this.listVirtual.get(0).getList().get(2);// 电压幅值
ReportValue current1 = (ReportValue) this.listVirtual.get(1).getList().get(0);// 电流幅值
ReportValue current2 = (ReportValue) this.listVirtual.get(1).getList().get(1);// 电流幅值
ReportValue current3 = (ReportValue) this.listVirtual.get(1).getList().get(2);// 电流幅值
ReportValue voltage1 = this.listVirtual.get(0).getList().get(0);// 电压幅值
ReportValue voltage2 = this.listVirtual.get(0).getList().get(1);// 电压幅值
ReportValue voltage3 = this.listVirtual.get(0).getList().get(2);// 电压幅值
ReportValue current1 = this.listVirtual.get(1).getList().get(0);// 电流幅值
ReportValue current2 = this.listVirtual.get(1).getList().get(1);// 电流幅值
ReportValue current3 = this.listVirtual.get(1).getList().get(2);// 电流幅值
String strLineBaseName = String.format("%s%s", new String[]{bdname + "_", name});
String strAnalysis = "";// 分析建议
@@ -366,7 +391,7 @@ public class ExportModelController extends BaseController {
iCount++;
}
// 假如所有的数据都为null,则返回(所选的时间段内未找到数据)
if (iCount == reportmap.size()){
if (iCount == reportmap.size()) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "exportWorld", methodDescribe);
}
// 基本数据判断
@@ -480,12 +505,12 @@ public class ExportModelController extends BaseController {
getVoltageRate(param, overLimit);
getCurrentRate(param, overLimit);
ReportValue pst1 = (ReportValue) this.listFlicker.get(0).getList().get(0);// 短闪
ReportValue pst2 = (ReportValue) this.listFlicker.get(0).getList().get(1);// 短闪
ReportValue pst3 = (ReportValue) this.listFlicker.get(0).getList().get(2);// 短闪
ReportValue plt1 = (ReportValue) this.listFlicker.get(1).getList().get(0);// 长闪
ReportValue plt2 = (ReportValue) this.listFlicker.get(1).getList().get(1);// 长闪
ReportValue plt3 = (ReportValue) this.listFlicker.get(1).getList().get(2);// 长闪
ReportValue pst1 = this.listFlicker.get(0).getList().get(0);// 短闪
ReportValue pst2 = this.listFlicker.get(0).getList().get(1);// 短闪
ReportValue pst3 = this.listFlicker.get(0).getList().get(2);// 短闪
ReportValue plt1 = this.listFlicker.get(1).getList().get(0);// 长闪
ReportValue plt2 = this.listFlicker.get(1).getList().get(1);// 长闪
ReportValue plt3 = this.listFlicker.get(1).getList().get(2);// 长闪
reportmap.put("$LineBase$", String.format("%s%sCT变比为%sPT变比为%s。",
new String[]{bdname, name, lineDto.getCt(), lineDto.getPt()}));// 监测点基本信息
@@ -539,9 +564,9 @@ public class ExportModelController extends BaseController {
/**************************************************************
**** 电压偏差(上偏差和下偏差)
***************************************************************/
ReportValue vdeviation1 = (ReportValue) this.listVdeviation.get(0).getList().get(0);
ReportValue vdeviation2 = (ReportValue) this.listVdeviation.get(0).getList().get(1);
ReportValue vdeviation3 = (ReportValue) this.listVdeviation.get(0).getList().get(2);
ReportValue vdeviation1 = this.listVdeviation.get(0).getList().get(0);
ReportValue vdeviation2 = this.listVdeviation.get(0).getList().get(1);
ReportValue vdeviation3 = this.listVdeviation.get(0).getList().get(2);
String vdeviationLimit = judgeNull(this.listVdeviation.get(0).getOverLimit());// 获取电压上下偏差的国标限值
reportmap.put("$VD_L$", vdeviationLimit);
String strResultVdeviationdata = "";
@@ -615,7 +640,7 @@ public class ExportModelController extends BaseController {
/**************************************************************
**** 频率偏差
***************************************************************/
ReportValue valueOfFreValue = (ReportValue) this.listFrequency.get(1).getList().get(0);
ReportValue valueOfFreValue = this.listFrequency.get(1).getList().get(0);
String valueOfFreLimit = judgeNull(this.listFrequency.get(1).getOverLimit());// 获取频率偏差国标限值
reportmap.put("$FRE_L$", valueOfFreLimit);
String strResultFre = "";
@@ -672,12 +697,12 @@ public class ExportModelController extends BaseController {
if ("".equals(tmpstrResultFre)) {
reportmap.put("$FV0R$", "合格");// 三张大表取值
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev()+")的要求。";
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。";
} else {
reportmap.put("$FV0R$", "不合格");// 三张大表取值
strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev()+")的要求。";
strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。";
strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit
+ deviceUnit.getUnitFrequencyDev()+")的要求。";
+ deviceUnit.getUnitFrequencyDev() + ")的要求。";
}
reportmap.put("$ResultFre$", strResultFre);
@@ -687,7 +712,7 @@ public class ExportModelController extends BaseController {
/**************************************************************
**** 三相电压不平衡度
***************************************************************/
ReportValue valueOfThree = (ReportValue) this.listThreephase.get(0).getList().get(0);
ReportValue valueOfThree = this.listThreephase.get(0).getList().get(0);
String valueOfThreeLimit = judgeNull(this.listThreephase.get(0).getOverLimit());// 获取三相电压不平衡度国标限值
reportmap.put("$THE_L$", valueOfThreeLimit);
String strResultThree = "";
@@ -887,9 +912,9 @@ public class ExportModelController extends BaseController {
String strCurrentRate = strMap + (i + 1) + "%";
// 基波电压含有率
strCurrentA = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getCp95Value());
strCurrentB = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getCp95Value());
strCurrentC = judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getCp95Value());
strCurrentA = judgeNull((this.listVoltageRate.get(i).getList().get(0)).getCp95Value());
strCurrentB = judgeNull((this.listVoltageRate.get(i).getList().get(1)).getCp95Value());
strCurrentC = judgeNull((this.listVoltageRate.get(i).getList().get(2)).getCp95Value());
strLimit = judgeNull(this.listVoltageRate.get(i).getOverLimit());
reportmap.put(strCurrentRate + "_A$", strCurrentA);
@@ -905,27 +930,27 @@ public class ExportModelController extends BaseController {
**** 三张大表取值
**************************************/
reportmap.put("$CV" + (i + 1) + "X_A$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getFmaxValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(0)).getFmaxValue()));
reportmap.put("$CV" + (i + 1) + "X_B$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getFmaxValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(1)).getFmaxValue()));
reportmap.put("$CV" + (i + 1) + "N_A$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getMinValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMinValue()));
reportmap.put("$CV" + (i + 1) + "N_B$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getMinValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMinValue()));
reportmap.put("$CV" + (i + 1) + "E_A$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(0)).getMeanValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMeanValue()));
reportmap.put("$CV" + (i + 1) + "E_B$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(1)).getMeanValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMeanValue()));
if (pttype != 2) {
reportmap.put("$CV" + (i + 1) + "X_C$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getFmaxValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(2)).getFmaxValue()));
reportmap.put("$CV" + (i + 1) + "N_C$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getMinValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMinValue()));
reportmap.put("$CV" + (i + 1) + "E_C$",
judgeNull(((ReportValue) this.listVoltageRate.get(i).getList().get(2)).getMeanValue()));
judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMeanValue()));
reportmap.put("$CV" + (i + 1) + "%_C$", strCurrentC);
} else {
reportmap.put("$CV" + (i + 1) + "X_C$", "-");
@@ -986,9 +1011,9 @@ public class ExportModelController extends BaseController {
/**************************************************************
**** 电压总谐波畸变率(THD)
***************************************************************/
ReportValue distortion1 = (ReportValue) this.listDistortion.get(0).getList().get(0);
ReportValue distortion2 = (ReportValue) this.listDistortion.get(0).getList().get(1);
ReportValue distortion3 = (ReportValue) this.listDistortion.get(0).getList().get(2);
ReportValue distortion1 = this.listDistortion.get(0).getList().get(0);
ReportValue distortion2 = this.listDistortion.get(0).getList().get(1);
ReportValue distortion3 = this.listDistortion.get(0).getList().get(2);
String distortionLimit = judgeNull(this.listDistortion.get(0).getOverLimit());
reportmap.put("$DV0%_L$", distortionLimit);
@@ -1077,9 +1102,9 @@ public class ExportModelController extends BaseController {
String strCurrent = strMap + (i + 1) + "%";
// 基波电压含有率
strCurrentA = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getCp95Value());
strCurrentB = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getCp95Value());
strCurrentC = judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getCp95Value());
strCurrentA = judgeNull(this.listICurrent.get(i).getList().get(0).getCp95Value());
strCurrentB = judgeNull(this.listICurrent.get(i).getList().get(1).getCp95Value());
strCurrentC = judgeNull(this.listICurrent.get(i).getList().get(2).getCp95Value());
strLimit = judgeNull(this.listICurrent.get(i).getOverLimit());
reportmap.put(strCurrent + "_A$", strCurrentA);
@@ -1090,17 +1115,17 @@ public class ExportModelController extends BaseController {
/************************************
**** 三张大表取值
**************************************/
reportmap.put("$CI" + (i + 1) + "X_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "X_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "X_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "X_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "X_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "X_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getFmaxValue()));
reportmap.put("$CI" + (i + 1) + "N_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getMinValue()));
reportmap.put("$CI" + (i + 1) + "N_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getMinValue()));
reportmap.put("$CI" + (i + 1) + "N_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getMinValue()));
reportmap.put("$CI" + (i + 1) + "N_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getMinValue()));
reportmap.put("$CI" + (i + 1) + "N_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getMinValue()));
reportmap.put("$CI" + (i + 1) + "N_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getMinValue()));
reportmap.put("$CI" + (i + 1) + "E_A$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(0)).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "E_B$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(1)).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "E_C$", judgeNull(((ReportValue) this.listICurrent.get(i).getList().get(2)).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "E_A$", judgeNull(this.listICurrent.get(i).getList().get(0).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "E_B$", judgeNull(this.listICurrent.get(i).getList().get(1).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "E_C$", judgeNull(this.listICurrent.get(i).getList().get(2).getMeanValue()));
reportmap.put("$CI" + (i + 1) + "%_A$", strCurrentA);
reportmap.put("$CI" + (i + 1) + "%_B$", strCurrentB);
@@ -1159,7 +1184,7 @@ public class ExportModelController extends BaseController {
// 测试结果填写
reportmap.put("$ResultTitle$", String.format("通过对(%s——%s时间段内%s电能质量统计数据分析后得出以下结论",
new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"),
DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒"),strLineBaseName}));// 结论标题
DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒"), strLineBaseName}));// 结论标题
reportmap.put("$Result_VD$", String.format("1电压偏差%s", new String[]{strResultVdeviationdata}));// 电压偏差
reportmap.put("$Result_FRE$", String.format("2频率偏差%s", new String[]{strResultFre}));// 频率偏差
reportmap.put("$Result_THE$", String.format("3三相电压不平衡度%s", new String[]{strResultThree}));// 三相电压不平衡度
@@ -1177,10 +1202,10 @@ public class ExportModelController extends BaseController {
**** 三张大表取值 有功:0-11 无功:12-23 视在:24-31 基波有功汇总:32-35 基波无功汇总:36-39
* 基波视在汇总:40-43 功率因数:44-46
**************************************/
ReportValue powerDto1 = (ReportValue) this.listPower.get(0).getList().get(3);
ReportValue powerDto2 = (ReportValue) this.listPower.get(1).getList().get(3);
ReportValue powerDto3 = (ReportValue) this.listPower.get(2).getList().get(3);
ReportValue powerDto4 = (ReportValue) this.listPower.get(3).getList().get(3);
ReportValue powerDto1 = this.listPower.get(0).getList().get(3);
ReportValue powerDto2 = this.listPower.get(1).getList().get(3);
ReportValue powerDto3 = this.listPower.get(2).getList().get(3);
ReportValue powerDto4 = this.listPower.get(3).getList().get(3);
reportmap.put("$BF0X$", judgeNull(powerDto1.getFmaxValue()));
reportmap.put("$BF0N$", judgeNull(powerDto1.getMinValue()));
reportmap.put("$BF0E$", judgeNull(powerDto1.getMeanValue()));
@@ -1198,64 +1223,70 @@ public class ExportModelController extends BaseController {
reportmap.put("$YF0E$", judgeNull(powerDto4.getMeanValue()));
formatter = new SimpleDateFormat("yyyyMMddHHmmss");// 报告时分秒格式
WordUtil2 oRTF = new WordUtil2();
String reportFileUrl = "";
try {
oRTF.getWord(rtfPath, reportmap, name + formatter.format(currentTime) + ".docx", response);
String fileName = name + formatter.format(currentTime) + ".docx";
if (isUrl) {
reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx", reportmap);
} else {
wordUtil2.getWord(rtfPath, reportmap, fileName, response);
}
} catch (Exception e) {
log.error("获取报告发生异常,异常是" + e.getMessage());
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe);
}
/**
* 数据单位信息 重组
*
* @param deviceUnit 数据单位对象
* @return
*/
private Map<String,String> unitMap(PqsDeviceUnit deviceUnit){
private Map<String, String> unitMap(PqsDeviceUnit deviceUnit) {
List<DictData> dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData();
Map<String,String> unit=new HashMap<>();
Map<String, String> unit = new HashMap<>();
List<String> list = dictData.stream().map(DictData::getCode).collect(Collectors.toList());
for (String s : list) {
//有效值
if(s.equals(DicDataEnum.EFFECTIVE.getCode())){
unit.put("$"+s+"_i$",deviceUnit.getIeffective());
unit.put("$"+s+"_v$",deviceUnit.getLineVoltage());
if (s.equals(DicDataEnum.EFFECTIVE.getCode())) {
unit.put("$" + s + "_i$", deviceUnit.getIeffective());
unit.put("$" + s + "_v$", deviceUnit.getLineVoltage());
}
//功率
if(s.equals(DicDataEnum.POWER.getCode())){
unit.put("$"+s+"_p$",deviceUnit.getTotalActiveP());
unit.put("$"+s+"_q$",deviceUnit.getTotalNoP());
unit.put("$"+s+"_s$",deviceUnit.getTotalViewP());
if (s.equals(DicDataEnum.POWER.getCode())) {
unit.put("$" + s + "_p$", deviceUnit.getTotalActiveP());
unit.put("$" + s + "_q$", deviceUnit.getTotalNoP());
unit.put("$" + s + "_s$", deviceUnit.getTotalViewP());
}
//畸变率
if(s.equals(DicDataEnum.DISTORTION.getCode())){
unit.put("$"+s+"_v$",deviceUnit.getVdistortion());
if (s.equals(DicDataEnum.DISTORTION.getCode())) {
unit.put("$" + s + "_v$", deviceUnit.getVdistortion());
}
//电压偏差
if(s.equals(DicDataEnum.VOLTAGE.getCode())){
unit.put("$"+s+"_v$",deviceUnit.getVoltageDev());
if (s.equals(DicDataEnum.VOLTAGE.getCode())) {
unit.put("$" + s + "_v$", deviceUnit.getVoltageDev());
}
//频率
if(s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())){
unit.put("$"+s+"_freq$",deviceUnit.getUnitFrequency());
unit.put("$"+s+"_freqDev$",deviceUnit.getUnitFrequencyDev());
if (s.equals(DicDataEnum.UNIT_FREQUENCY.getCode())) {
unit.put("$" + s + "_freq$", deviceUnit.getUnitFrequency());
unit.put("$" + s + "_freqDev$", deviceUnit.getUnitFrequencyDev());
}
//三项不平衡度
if(s.equals(DicDataEnum.UNBALANCE.getCode())){
unit.put("$"+s+"_v$","%");
unit.put("$"+s+"_vPos$",deviceUnit.getPositiveV());
unit.put("$"+s+"_vNeg$",deviceUnit.getNoPositiveV());
unit.put("$"+s+"_vZero$",deviceUnit.getNoPositiveV());
unit.put("$"+s+"_i$","%");
unit.put("$"+s+"_iPos$","A");
unit.put("$"+s+"_iNeg$","A");
unit.put("$"+s+"_iZero$","A");
if (s.equals(DicDataEnum.UNBALANCE.getCode())) {
unit.put("$" + s + "_v$", "%");
unit.put("$" + s + "_vPos$", deviceUnit.getPositiveV());
unit.put("$" + s + "_vNeg$", deviceUnit.getNoPositiveV());
unit.put("$" + s + "_vZero$", deviceUnit.getNoPositiveV());
unit.put("$" + s + "_i$", "%");
unit.put("$" + s + "_iPos$", "A");
unit.put("$" + s + "_iNeg$", "A");
unit.put("$" + s + "_iZero$", "A");
}
//基波
if(s.equals(DicDataEnum.FUND.getCode())){
unit.put("$"+s+"_i$",deviceUnit.getIfund());
unit.put("$"+s+"_v$",deviceUnit.getVfundEffective());
if (s.equals(DicDataEnum.FUND.getCode())) {
unit.put("$" + s + "_i$", deviceUnit.getIfund());
unit.put("$" + s + "_v$", deviceUnit.getVfundEffective());
}
}
@@ -1485,7 +1516,7 @@ public class ExportModelController extends BaseController {
List<Float> iHarmList = getIHarmList(overLimit);
for (int i = 0; i < 50; i++) {
Pass pass;
if (i <iHarmList.size() + 1 && i > 0) {
if (i < iHarmList.size() + 1 && i > 0) {
pass = new Pass(iHarmList.get(i - 1),
EnumPass.CP95.getCode());
} else {
@@ -1497,6 +1528,7 @@ public class ExportModelController extends BaseController {
this.listICurrent = new ArrayList<>();
transformData(this.listICurrent, listICurrent, list, true);
}
// 谐波电压
public void getVoltageRate(ReportQueryParam param, Overlimit overLimit) {
List<ReportValue> listVoltageRate = reportService.getVoltageRate(param);
@@ -1523,12 +1555,14 @@ public class ExportModelController extends BaseController {
this.listVoltageRate = new ArrayList<>();
transformData(this.listVoltageRate, listVoltageRate, list, true);
}
public String judgeNull(Float result) {
return (result == null) ? "/" : result.toString();
}
/**
* 谐波电流限值
*
* @param overLimit
* @return
*/
@@ -1563,6 +1597,7 @@ public class ExportModelController extends BaseController {
/**
* 谐波电压限值
*
* @return
*/
public List<Float> getVHarmList(Overlimit overLimit) {