From 50cd5d3895e81f7b4b42d159c77890ea16a97fb1 Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Tue, 2 Jul 2024 16:55:08 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=8A=80=E6=9C=AF=E7=9B=91=E7=9D=A3=E8=AF=95?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E8=AF=84=E4=BC=B0-=E8=AF=95=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=BB=93=E6=9D=9F=E5=90=8E=E7=94=9F=E6=88=90=E8=AF=95?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=8A=A5=E5=91=8A=202.=E6=8A=80=E6=9C=AF?= =?UTF-8?q?=E7=9B=91=E7=9D=A3=E8=AE=A1=E5=88=92=E7=AE=A1=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4=E4=B8=BA=E8=B4=9F=E8=B4=A3?= =?UTF-8?q?=E5=9C=B0=E5=B8=82=E8=BF=9B=E8=A1=8C=E4=BF=A1=E6=81=AF=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=203.=E8=B0=83=E6=95=B4=E5=B8=B8=E6=80=81=E5=8C=96?= =?UTF-8?q?=E5=B9=B2=E6=89=B0=E6=BA=90=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91=204.=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E8=B0=90=E6=B3=A2=E6=8A=A5=E5=91=8A=E6=95=B0=E6=8D=AE=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pq/pojo/dto/LineDataQualityDTO.java | 7 + .../pq/controller/TerminalBaseController.java | 1 - .../impl/RStatIntegrityDServiceImpl.java | 1 + pqs-harmonic/harmonic-api/pom.xml | 6 + .../njcn/harmonic/api/ReportFeignClient.java | 36 +++ .../fallback/ReportClientFallbackFactory.java | 51 ++++ .../com/njcn/harmonic/utils/WordUtil2.java | 97 ++++--- .../controller/ExportModelController.java | 269 ++++++++++-------- .../enums/SupervisionResponseEnum.java | 1 + .../pojo/param/user/UserReportParam.java | 6 + .../device/SupervisionTempLineRunTestPO.java | 5 +- .../vo/device/SupervisionTempLineDebugVO.java | 77 +++-- pqs-supervision/supervision-boot/pom.xml | 6 - .../SupervisionTempLineRunTestController.java | 6 +- .../user/UserReportManageController.java | 2 - .../user/UserReportRenewalController.java | 4 +- .../SupervisionTempLineDebugPOMapper.java | 5 +- .../SupervisionTempLineDebugPOMapper.xml | 1 + .../ISupervisionTempLineRunTestService.java | 4 +- .../device/impl/LineWarningServiceImpl.java | 3 +- ...SupervisionTempLineRunTestServiceImpl.java | 135 +++++---- .../service/survey/ISurveyTestService.java | 1 + .../survey/impl/SurveyTestServiceImpl.java | 4 +- .../user/IUserReportRenewalService.java | 5 + .../user/impl/UserReportPOServiceImpl.java | 14 +- .../impl/UserReportRenewalServiceImpl.java | 25 +- .../njcn/supervision/utils/InstanceUtil.java | 21 +- 27 files changed, 510 insertions(+), 283 deletions(-) create mode 100644 pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/ReportFeignClient.java create mode 100644 pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/fallback/ReportClientFallbackFactory.java diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/dto/LineDataQualityDTO.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/dto/LineDataQualityDTO.java index e38caedba..c7a036548 100644 --- a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/dto/LineDataQualityDTO.java +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/pojo/dto/LineDataQualityDTO.java @@ -11,8 +11,15 @@ import lombok.Data; @Data public class LineDataQualityDTO { + /** + * 监测点id + */ private String lineId; + /** + * 监测点名称 + */ + private String lineName; /** * 在线率 diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/TerminalBaseController.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/TerminalBaseController.java index 8577ad482..3b7435e8e 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/TerminalBaseController.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/controller/TerminalBaseController.java @@ -148,7 +148,6 @@ public class TerminalBaseController extends BaseController { @PostMapping("terminalSync") public HttpResult terminalSync(@Valid @RequestBody SyncTerminalParam syncTerminalParam) { String methodDescribe = getMethodDescribe("terminalSync"); - String subtation = terminalBaseService.terminalSync(syncTerminalParam); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, subtation, methodDescribe); } diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RStatIntegrityDServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RStatIntegrityDServiceImpl.java index 8d6ce8212..6faeedb10 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RStatIntegrityDServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/RStatIntegrityDServiceImpl.java @@ -85,6 +85,7 @@ public class RStatIntegrityDServiceImpl extends ServiceImplcommon-poi ${project.version} + + com.njcn + common-oss + 1.0.0 + ${project.version} + com.njcn user-api diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/ReportFeignClient.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/ReportFeignClient.java new file mode 100644 index 000000000..89f305631 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/ReportFeignClient.java @@ -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 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; + +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/fallback/ReportClientFallbackFactory.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/fallback/ReportClientFallbackFactory.java new file mode 100644 index 000000000..259892691 --- /dev/null +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/api/fallback/ReportClientFallbackFactory.java @@ -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 { + @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 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); + } + + }; + } +} diff --git a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/utils/WordUtil2.java b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/utils/WordUtil2.java index 3df4584a9..da0740666 100644 --- a/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/utils/WordUtil2.java +++ b/pqs-harmonic/harmonic-api/src/main/java/com/njcn/harmonic/utils/WordUtil2.java @@ -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 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 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()); - } - } - } } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/ExportModelController.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/ExportModelController.java index 7f0003a07..5f2d98305 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/ExportModelController.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/ExportModelController.java @@ -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 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 reportmap = new HashMap<>();// 报告Map //数据单位 @@ -214,11 +219,31 @@ public class ExportModelController extends BaseController { Map header = new HashMap(); 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%s,CT变比为:%s,PT变比为:%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 unitMap(PqsDeviceUnit deviceUnit){ + private Map unitMap(PqsDeviceUnit deviceUnit) { List dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData(); - Map unit=new HashMap<>(); + Map unit = new HashMap<>(); List 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 iHarmList = getIHarmList(overLimit); for (int i = 0; i < 50; i++) { Pass pass; - if (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 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 getVHarmList(Overlimit overLimit) { diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java index d5bbbd14a..c00afa80d 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java @@ -22,6 +22,7 @@ public enum SupervisionResponseEnum { DATA_NOT_EXISTS("A00550","数据不存在"), NO_POWER("A00550","不能操作非自己创建的任务!"), NO_USER_REPORT_UPDATE("A00550","常态化干扰源用户管理信息更新失败,不存在该条信息"), + NO_DEPT_POWER("A00550","不能操作非自己部门创建的任务"), ; private final String code; diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/user/UserReportParam.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/user/UserReportParam.java index fd07c9f93..bb0af53d3 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/user/UserReportParam.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/param/user/UserReportParam.java @@ -48,6 +48,12 @@ public class UserReportParam { @ApiModelProperty(value = "填报部门") private String orgId; + /** + * 填报部门 + */ + @ApiModelProperty(value = "填报部门名称") + private String orgName; + /** * 工程预期投产日期 */ diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionTempLineRunTestPO.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionTempLineRunTestPO.java index d42395fc5..2601df997 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionTempLineRunTestPO.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionTempLineRunTestPO.java @@ -74,5 +74,8 @@ public class SupervisionTempLineRunTestPO extends BaseEntity { */ private String testRunTime; - + /** + * 试运行成功报告地址 + */ + private String testRunReport; } diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/device/SupervisionTempLineDebugVO.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/device/SupervisionTempLineDebugVO.java index 5b9a298c3..2a4fbaae1 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/device/SupervisionTempLineDebugVO.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/vo/device/SupervisionTempLineDebugVO.java @@ -1,5 +1,6 @@ package com.njcn.supervision.pojo.vo.device; +import cn.hutool.core.util.StrUtil; import com.njcn.db.bo.BaseEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -14,39 +15,61 @@ import lombok.Data; @Data public class SupervisionTempLineDebugVO extends BaseEntity { - private String id; - @ApiModelProperty(value="监测点编号") - private String lineId; - @ApiModelProperty(value="监测点名称") - private String lineName; - @ApiModelProperty(value="关联干扰源用户id名称") - private String userName; - @ApiModelProperty(value="接入母线") - private String connectedBus; - @ApiModelProperty(value="监测终端编码") - private String monitoringTerminalCode; - @ApiModelProperty(value="监测终端名称") - private String monitoringTerminalName; - @ApiModelProperty(value="电网侧变电站") - private String powerSubstationName; - private String reason; - private String processInstanceId; + private String id; - @ApiModelProperty(value = "流程实例的编号") - private String historyInstanceId; + @ApiModelProperty(value = "监测点编号") + private String lineId; - private Integer status; - /** - * 0:未试运行 1:试运行中 2.试运行成功 3.试运行异常 - */ - private Integer testRunState; + @ApiModelProperty(value = "监测点名称") + private String lineName; + + @ApiModelProperty(value = "关联干扰源用户id名称") + private String userName; + + @ApiModelProperty(value = "接入母线") + private String connectedBus; + + @ApiModelProperty(value = "监测终端编码") + private String monitoringTerminalCode; + + @ApiModelProperty(value = "监测终端名称") + private String monitoringTerminalName; + + @ApiModelProperty(value = "电网侧变电站") + private String powerSubstationName; + + private String reason; + + private String processInstanceId; + + + @ApiModelProperty(value = "流程实例的编号") + private String historyInstanceId; + + private Integer status; + /** + * 0:未试运行 1:试运行中 2.试运行成功 3.试运行异常 + */ + private Integer testRunState; + + /** + * 试运行时间范围 + */ + private String testRunTime; /** - * 试运行时间范围 + * 试运行成功报告地址 */ - private String testRunTime; + @ApiModelProperty(value = "试运行成功报告地址") + private String testRunReport; + public void setTestRunReport(String testRunReport) { + if(StrUtil.isNotBlank(testRunReport)){ + this.testRunReport = "/"+testRunReport; + }else { + this.testRunReport = testRunReport; - private String createBy; + } + } } diff --git a/pqs-supervision/supervision-boot/pom.xml b/pqs-supervision/supervision-boot/pom.xml index c93776d33..d8c06b59b 100644 --- a/pqs-supervision/supervision-boot/pom.xml +++ b/pqs-supervision/supervision-boot/pom.xml @@ -58,12 +58,6 @@ 1.0.0 compile - - com.njcn - common-oss - ${project.version} - - supervision-boot diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/SupervisionTempLineRunTestController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/SupervisionTempLineRunTestController.java index 9b742e38a..eb3d5f20d 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/SupervisionTempLineRunTestController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/SupervisionTempLineRunTestController.java @@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.*; import com.njcn.web.controller.BaseController; +import javax.servlet.http.HttpServletResponse; + /** *

* 监测点试运行前端控制器 @@ -67,8 +69,8 @@ public class SupervisionTempLineRunTestController extends BaseController { @OperateInfo(info = LogEnum.BUSINESS_COMMON) @GetMapping("/isTestRunStartOrEnd") @ApiOperation("每日判断试运行是否结束") - public void isTestRunStartOrEnd(){ - iSupervisionTempLineRunTestService.isTestRunStartOrEnd(); + public void isTestRunStartOrEnd(HttpServletResponse response){ + iSupervisionTempLineRunTestService.isTestRunStartOrEnd(response); } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportManageController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportManageController.java index 68038526f..1cf463542 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportManageController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportManageController.java @@ -71,9 +71,7 @@ public class UserReportManageController extends BaseController { public HttpResult auditUserReport(@RequestBody @Validated UserReportParam.UserReportUpdate userReportUpdate) { String methodDescribe = getMethodDescribe("auditUserReport"); boolean res = userReportPOService.auditUserReport(userReportUpdate); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, res, methodDescribe); - } @OperateInfo(info = LogEnum.BUSINESS_COMMON) diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportRenewalController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportRenewalController.java index c8512e605..004bdee61 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportRenewalController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/user/UserReportRenewalController.java @@ -46,7 +46,7 @@ public class UserReportRenewalController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, userReportUpdateById, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) @PostMapping("/addEditor") @ApiOperation("干扰源用户管理更新信息新增功能") public HttpResult addEditor(@RequestBody @Validated UserReportParam userReportParam) { @@ -55,7 +55,7 @@ public class UserReportRenewalController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, s, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE) @PostMapping("/cancel") @ApiOperation("取消") @ApiImplicitParam(name = "cancelReqVO", value = "取消原因", required = true) diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/SupervisionTempLineDebugPOMapper.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/SupervisionTempLineDebugPOMapper.java index d084a9371..425ed5df6 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/SupervisionTempLineDebugPOMapper.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/SupervisionTempLineDebugPOMapper.java @@ -9,7 +9,6 @@ import com.njcn.supervision.pojo.vo.device.SupervisionTempLineDebugVO; import org.apache.ibatis.annotations.Param; /** - * * Description: * Date: 2024/5/17 15:26【需求编号】 * @@ -17,8 +16,8 @@ import org.apache.ibatis.annotations.Param; * @version V1.0.0 */ public interface SupervisionTempLineDebugPOMapper extends BaseMapper { - Page page(@Param("page")Page objectPage, @Param("ew") QueryWrapper queryWrapper); + Page page(@Param("page") Page objectPage, @Param("ew") QueryWrapper queryWrapper); - Page pageHasDebug(@Param("page")Page objectPage, @Param("ew") QueryWrapper queryWrapper); + Page pageHasDebug(@Param("page") Page objectPage, @Param("ew") QueryWrapper queryWrapper); } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/mapping/SupervisionTempLineDebugPOMapper.xml b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/mapping/SupervisionTempLineDebugPOMapper.xml index 6e00811c3..09048082a 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/mapping/SupervisionTempLineDebugPOMapper.xml +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/mapper/device/mapping/SupervisionTempLineDebugPOMapper.xml @@ -57,6 +57,7 @@ supervision_temp_line_report.Power_Substation_Name, supervision_temp_line_report.line_id lineId, supervision_temp_line_report.line_name lineName, + supervision_temp_line_run_test.test_run_report, supervision_temp_line_debug.reason reason, supervision_temp_line_run_test.process_instance_id process_instanceId, supervision_temp_line_run_test.history_instance_id, diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/ISupervisionTempLineRunTestService.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/ISupervisionTempLineRunTestService.java index bdac58c47..0e50a780d 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/ISupervisionTempLineRunTestService.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/ISupervisionTempLineRunTestService.java @@ -7,6 +7,8 @@ import com.njcn.supervision.pojo.param.device.SupervisionTempLineRunTestParam; import com.njcn.supervision.pojo.po.device.SupervisionTempLineRunTestPO; import com.njcn.supervision.pojo.vo.device.SupervisionTempLineRunTestVO; +import javax.servlet.http.HttpServletResponse; + /** *

* 服务类 @@ -21,7 +23,7 @@ public interface ISupervisionTempLineRunTestService extends IBpmService - * 服务实现类 + * 服务实现类 *

* * @author hongawen @@ -77,6 +83,9 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl lineIds = supervisionTempLineReportList.stream().map(SupervisionTempLineReport::getId).collect(Collectors.toList()); List lineDTOList = commLineClient.getLineDetailBatch(lineIds).getData(); - if(lineIds.size()!=lineDTOList.size()){ - throw new BusinessException(CommonResponseEnum.FAIL,"请联系管理员检查监测点唯一编号是否匹配"); + if (lineIds.size() != lineDTOList.size()) { + throw new BusinessException(CommonResponseEnum.FAIL, "请联系管理员检查监测点唯一编号是否匹配"); } //校验 @@ -101,37 +110,36 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl= 0; i--) { List list1 = iUserReportNormalService.lambdaQuery().eq(UserReportNormalPO::getUserReportId, tempUserIds.get(i)).list(); - if (CollectionUtil.isNotEmpty(list1)){ + if (CollectionUtil.isNotEmpty(list1)) { //为空则没有治理工程不需要移除,存在审核未通过的也不要移除,只有全是2的移除 - list1 = list1.stream().filter(temp->!Objects.equals(temp.getStatus(),2)).collect(Collectors.toList()); - if(CollectionUtil.isEmpty(list1)){ + list1 = list1.stream().filter(temp -> !Objects.equals(temp.getStatus(), 2)).collect(Collectors.toList()); + if (CollectionUtil.isEmpty(list1)) { tempUserIds.remove(i); } } } } - if(CollectionUtil.isNotEmpty(tempUserIds)){ - String userNames = supervisionTempLineReportList.stream() - .filter(temp->tempUserIds.contains(temp.getUserId())) + if (CollectionUtil.isNotEmpty(tempUserIds)) { + String userNames = supervisionTempLineReportList.stream() + .filter(temp -> tempUserIds.contains(temp.getUserId())) .map(SupervisionTempLineReport::getUserName) .collect(Collectors.joining(", ")); - throw new BusinessException(CommonResponseEnum.FAIL,"存在关联干扰源用户:"+userNames+"需要治理通过才可以进行试运行"); + throw new BusinessException(CommonResponseEnum.FAIL, "存在关联干扰源用户:" + userNames + "需要治理通过才可以进行试运行"); } - List supervisionTempLineRunTestPOList = this.list(new LambdaQueryWrapper().in(SupervisionTempLineRunTestPO::getId,ids).ne(SupervisionTempLineRunTestPO::getStatus,BpmTaskStatusEnum.REJECT.getStatus())); - if(CollUtil.isNotEmpty(supervisionTempLineRunTestPOList)){ - String msg = assMsg(supervisionTempLineReportList,supervisionTempLineRunTestPOList); - throw new BusinessException(CommonResponseEnum.FAIL,msg); + List supervisionTempLineRunTestPOList = this.list(new LambdaQueryWrapper().in(SupervisionTempLineRunTestPO::getId, ids).ne(SupervisionTempLineRunTestPO::getStatus, BpmTaskStatusEnum.REJECT.getStatus())); + if (CollUtil.isNotEmpty(supervisionTempLineRunTestPOList)) { + String msg = assMsg(supervisionTempLineReportList, supervisionTempLineRunTestPOList); + throw new BusinessException(CommonResponseEnum.FAIL, msg); } List poList = new ArrayList<>(); - for(SupervisionTempLineReport item:supervisionTempLineReportList){ + for (SupervisionTempLineReport item : supervisionTempLineReportList) { SupervisionTempLineRunTestPO supervisionTempLineRunTestPO = new SupervisionTempLineRunTestPO(); supervisionTempLineRunTestPO.setId(item.getId()); supervisionTempLineRunTestPO.setLineId(item.getLineId()); @@ -141,9 +149,9 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.eq(SupervisionTempLineRunTestPO::getTestRunState,1).eq(SupervisionTempLineRunTestPO::getState,DataStateEnum.ENABLE.getCode()); + lambdaQueryWrapper.eq(SupervisionTempLineRunTestPO::getTestRunState, 1).eq(SupervisionTempLineRunTestPO::getState, DataStateEnum.ENABLE.getCode()); List supervisionTempLineRunTestPOList = this.list(lambdaQueryWrapper); - List usePoList = new ArrayList<>(); - for(SupervisionTempLineRunTestPO item : supervisionTempLineRunTestPOList){ - String endTime = item.getTestRunTime().split("--")[1]; - LocalDateTime end = LocalDate.parse(endTime, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)).atTime(23,59,59); - if(end.isBefore(time)){ - //结束时间在当前时间之前,则已经执行完试运行,开始组装审核条件 - usePoList.add(item); - } + for (SupervisionTempLineRunTestPO item : supervisionTempLineRunTestPOList) { + String endTime = item.getTestRunTime().split("--")[1]; + LocalDateTime end = LocalDate.parse(endTime, DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN)).atTime(23, 59, 59); + if (end.isBefore(time)) { + //结束时间在当前时间之前,则已经执行完试运行,开始组装审核条件 + usePoList.add(item); + } } - if(CollUtil.isNotEmpty(usePoList)){ - Map> map = usePoList.stream().collect(Collectors.groupingBy(SupervisionTempLineRunTestPO::getTestRunTime)); - map.forEach((key,val)->{ + if (CollUtil.isNotEmpty(usePoList)) { + Map> map = usePoList.stream().collect(Collectors.groupingBy(SupervisionTempLineRunTestPO::getTestRunTime)); + map.forEach((key, val) -> { String startTime = key.split("--")[0]; String endTime = key.split("--")[1]; List ids = val.stream().map(SupervisionTempLineRunTestPO::getId).collect(Collectors.toList()); LineDataQualityParam lineDataQualityParam = LineDataQualityParam.builder().lineIds(ids).beginTime(startTime).endTime(endTime).build(); List lineDataQualityDTOList = lineIntegrityClient.getLineDataQuality(lineDataQualityParam).getData(); - Map qualityDTOMap = lineDataQualityDTOList.stream().collect(Collectors.toMap(LineDataQualityDTO::getLineId,Function.identity())); - - for(SupervisionTempLineRunTestPO supervisionTempLineRunTestPO : val){ - - - + Map qualityDTOMap = lineDataQualityDTOList.stream().collect(Collectors.toMap(LineDataQualityDTO::getLineId, Function.identity())); + for (SupervisionTempLineRunTestPO supervisionTempLineRunTestPO : val) { // 发起 BPM 流程 Map processInstanceVariables = new HashMap<>(); BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO(); bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.LINE_RUN_TEST.getKey()); bpmProcessInstanceCreateReqDTO.setBusinessKey(supervisionTempLineRunTestPO.getId()); - bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap>()); + bpmProcessInstanceCreateReqDTO.setStartUserSelectAssignees(new HashMap<>()); bpmProcessInstanceCreateReqDTO.setVariables(processInstanceVariables); - String processInstanceId = bpmProcessFeignClient.createProcessInstance(supervisionTempLineRunTestPO.getCreateBy(),bpmProcessInstanceCreateReqDTO).getData(); + String processInstanceId = bpmProcessFeignClient.createProcessInstance(supervisionTempLineRunTestPO.getCreateBy(), bpmProcessInstanceCreateReqDTO).getData(); // 将工作流的编号,更新到流程单中 SupervisionTempLineRunTestPO po = new SupervisionTempLineRunTestPO(); po.setId(supervisionTempLineRunTestPO.getId()); po.setProcessInstanceId(processInstanceId); po.setStatus(1); po.setTestRunState(2); - - if(CollUtil.isEmpty(lineDataQualityDTOList)){ + if (qualityDTOMap.containsKey(supervisionTempLineRunTestPO.getId())) { + LineDataQualityDTO dto = qualityDTOMap.get(supervisionTempLineRunTestPO.getId()); + po.setOnlineRate(dto.getOnlineRate()); + po.setIntegrityRate(dto.getIntegrityRate()); + po.setSuitRate(dto.getSuitRate()); + try { + startTime = DateUtil.beginOfDay(DateUtil.parse(startTime)).toString(); + endTime = DateUtil.endOfDay(DateUtil.parse(endTime)).toString(); + String fileUrl = reportFeignClient.exportWorld( + startTime, + endTime, + 0, + dto.getLineId(), + dto.getLineName(), + "", + "", + true, new MockMultipartFile("file", new byte[0])).getData(); + po.setTestRunReport(fileUrl); + } catch (IOException e) { + throw new RuntimeException(e); + } + } else { po.setOnlineRate(0.00); po.setIntegrityRate(0.00); po.setSuitRate(0.00); - }else { - po.setOnlineRate(qualityDTOMap.containsKey(supervisionTempLineRunTestPO.getLineId())?qualityDTOMap.get(supervisionTempLineRunTestPO.getLineId()).getOnlineRate():0.00); - po.setIntegrityRate(qualityDTOMap.containsKey(supervisionTempLineRunTestPO.getLineId())?qualityDTOMap.get(supervisionTempLineRunTestPO.getLineId()).getIntegrityRate():0.00); - po.setSuitRate(qualityDTOMap.containsKey(supervisionTempLineRunTestPO.getLineId())?qualityDTOMap.get(supervisionTempLineRunTestPO.getLineId()).getIntegrityRate():0.00); } - this.baseMapper.updateById(po); } - - - }); } } @@ -279,7 +294,7 @@ public class SupervisionTempLineRunTestServiceImpl extends ServiceImpl supervisionTempLineReportList,List supervisionTempLineRunTestPOList){ + private String assMsg(List supervisionTempLineReportList, List supervisionTempLineRunTestPOList) { StringBuilder builder = new StringBuilder(); - Map map = supervisionTempLineReportList.stream().collect(Collectors.toMap(SupervisionTempLineReport::getId, Function.identity())); + Map map = supervisionTempLineReportList.stream().collect(Collectors.toMap(SupervisionTempLineReport::getId, Function.identity())); List ids = supervisionTempLineRunTestPOList.stream().map(SupervisionTempLineRunTestPO::getId).collect(Collectors.toList()); - for(String id:ids){ - if(map.containsKey(id)){ + for (String id : ids) { + if (map.containsKey(id)) { builder.append(map.get(id).getPowerSubstationName()).append("_").append(map.get(id).getLineName()).append(";"); } } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/ISurveyTestService.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/ISurveyTestService.java index 5523e662d..7c7ead778 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/ISurveyTestService.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/ISurveyTestService.java @@ -19,6 +19,7 @@ import com.njcn.supervision.pojo.vo.survey.SurveyTestVO; public interface ISurveyTestService extends IBpmService { Page surveyTestPage(SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam); + Page pageProblemSurvey(SurveyTestParam.SurveyTestQueryParam surveyTestQueryParam); String addSurveyTest(SurveyTestParam surveyTestParam); diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyTestServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyTestServiceImpl.java index bee85c74e..403105862 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyTestServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/survey/impl/SurveyTestServiceImpl.java @@ -238,7 +238,7 @@ public class SurveyTestServiceImpl extends ServiceImpl