diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java index 45ba0cb27..460cd1981 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/EventDetailFeignClient.java @@ -59,8 +59,14 @@ public interface EventDetailFeignClient { HttpResult> getEventDetailByIdsList(@RequestBody List ids); /** - * 根据监测点id集合获取暂降列表 + * 根据监测点id集合,统计时间范围内暂态超标次数 */ @PostMapping("/getEventDetailByLineCount") HttpResult getEventDetailByLineCount(@RequestBody EventCountParam param); + + /** + * 根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息 + */ + @PostMapping("/getAppEventDetailLtAmplitude") + HttpResult> getAppEventDetailLtAmplitude(@RequestBody EventCountParam param); } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/ReportFeignClient.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/ReportFeignClient.java new file mode 100644 index 000000000..44005ec6a --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/ReportFeignClient.java @@ -0,0 +1,30 @@ +package com.njcn.event.api; + +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.pq.pojo.param.DeviceInfoParam; +import com.njcn.event.api.fallback.ReportFeignClientFallbackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + + + +/** + * @author wr + * @description + * @date 2024/1/3 10:02 + */ +@FeignClient(value = ServerInfo.EVENT, path = "/report", fallbackFactory = ReportFeignClientFallbackFactory.class) +public interface ReportFeignClient { + + + /** + * 灿能云获取暂态报告 + * @param businessParam + * @return + */ + @PostMapping("/appEventExport") + HttpResult appEventExport(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam); +} diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java index 193595089..e3d36b9c5 100644 --- a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/EventDetailFeignClientFallbackFactory.java @@ -66,7 +66,13 @@ public class EventDetailFeignClientFallbackFactory implements FallbackFactory getEventDetailByLineCount(EventCountParam param) { - log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合获取暂降列表", throwable.toString()); + log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合,统计时间范围内暂态超标次数", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + + @Override + public HttpResult> getAppEventDetailLtAmplitude(EventCountParam param) { + log.error("{}异常,降级处理,异常为:{}", "根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息", throwable.toString()); throw new BusinessException(finalExceptionEnum); } diff --git a/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/ReportFeignClientFallbackFactory.java b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/ReportFeignClientFallbackFactory.java new file mode 100644 index 000000000..682f755e2 --- /dev/null +++ b/pqs-event/event-api/src/main/java/com/njcn/event/api/fallback/ReportFeignClientFallbackFactory.java @@ -0,0 +1,40 @@ +package com.njcn.event.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.pq.pojo.param.DeviceInfoParam; +import com.njcn.event.api.ReportFeignClient; +import com.njcn.event.utils.EventlEnumUtil; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + + +/** + * @author wr + * @description + * @date 2024/1/3 10:02 + */ +@Slf4j +@Component +public class ReportFeignClientFallbackFactory implements FallbackFactory { + @Override + public ReportFeignClient create(Throwable throwable) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (throwable.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) throwable.getCause(); + exceptionEnum = EventlEnumUtil.getExceptionEnum(businessException.getResult()); + } + Enum finalExceptionEnum = exceptionEnum; + return new ReportFeignClient() { + + @Override + public HttpResult appEventExport(DeviceInfoParam.BusinessParam businessParam) { + log.error("{}异常,降级处理,异常为:{}", "暂态报告导出", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + } +} diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java index 463639e32..324fbc548 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/EventDetailController.java @@ -148,7 +148,7 @@ public class EventDetailController extends BaseController { } /** - * 根据监测点集合获取短时终端,电压暂升,电压暂降 + * 根据暂态id集合获取暂降列表 * @return */ @OperateInfo(info = LogEnum.BUSINESS_COMMON) @@ -161,12 +161,12 @@ public class EventDetailController extends BaseController { } /** - * 根据监测点集合获取短时终端,电压暂升,电压暂降 + * 根据监测点id集合,统计时间范围内暂态超标次数(灿能云) * @return */ @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getEventDetailByLineCount") - @ApiOperation("根据暂态id集合获取暂降列表") + @ApiOperation("根据监测点id集合,统计时间范围内暂态超标次数") public HttpResult getEventDetailByLineCount(@RequestBody EventCountParam param) { String methodDescribe = getMethodDescribe("getEventDetailByLineCount"); int count = eventDetailService.count(new LambdaQueryWrapper() @@ -176,4 +176,22 @@ public class EventDetailController extends BaseController { ); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe); } + + /** + * 根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息(灿能云) + * @return + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getAppEventDetailLtAmplitude") + @ApiOperation("根据监测点id集合,统计时间范围内特征增幅小于0.9的暂态信息") + public HttpResult> getAppEventDetailLtAmplitude(@RequestBody EventCountParam param) { + String methodDescribe = getMethodDescribe("getAppEventDetailLtAmplitude"); + List list = eventDetailService.list(new LambdaQueryWrapper() + .in(CollUtil.isNotEmpty(param.getIds()), RmpEventDetailPO::getLineId, param.getIds()) + .ge(StrUtil.isNotBlank(param.getStartTime()), RmpEventDetailPO::getStartTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + .lt(RmpEventDetailPO::getFeatureAmplitude,0.9) + ); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); + } } diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java index c8e29d2b1..170fc15a8 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/controller/majornetwork/ReportController.java @@ -132,6 +132,18 @@ public class ReportController extends BaseController { reportService.getExport(businessParam, response); } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/appEventExport") + @ApiOperation("灿能云暂态报告导出") + @ApiImplicitParam(name = "businessParam", value = "灿能云暂态导出参数", required = true) + public HttpResult appEventExport(@RequestBody @Validated DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException { + String methodDescribe = getMethodDescribe("appEventExport"); + String path = reportService.appEventExport(businessParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, path, methodDescribe); + + } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/getLineExport") @ApiOperation("监测点报告导出") diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java index 70bb93cb7..b8c4fee01 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/EventDetailServiceImpl.java @@ -68,9 +68,10 @@ public class EventDetailServiceImpl extends ServiceImpl getEventDetail(List lineIndexes, String startTime, String endTime, List waveType) { List info = this.list(new LambdaQueryWrapper() - .ne(RmpEventDetailPO::getMeasurementPointId, lineIndexes) + .in(RmpEventDetailPO::getMeasurementPointId, lineIndexes) .ge(StrUtil.isNotBlank(startTime), RmpEventDetailPO::getStartTime,DateUtil.beginOfDay(DateUtil.parse(startTime))) .le(StrUtil.isNotBlank(endTime), RmpEventDetailPO::getStartTime, DateUtil.endOfDay(DateUtil.parse(endTime))) + .orderByDesc(RmpEventDetailPO::getStartTime) ); return BeanUtil.copyToList(info, EventDetail.class); diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java index e7e96375c..3494a6314 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/Impl/ReportServiceImpl.java @@ -14,6 +14,7 @@ import com.njcn.common.pojo.dto.SimpleDTO; 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.common.utils.FileUtil; import com.njcn.device.biz.enums.DeviceResponseEnum; import com.njcn.device.pms.api.MonitorClient; import com.njcn.device.pms.api.PmsGeneralDeviceInfoClient; @@ -48,6 +49,8 @@ import com.njcn.event.service.majornetwork.EventDetailService; import com.njcn.event.service.majornetwork.EventReportService; import com.njcn.event.service.majornetwork.ReportService; import com.njcn.event.utils.WordUtils; +import com.njcn.oss.constant.OssPath; +import com.njcn.oss.utils.FileStorageUtil; import com.njcn.poi.util.PoiUtil; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.enums.DicDataEnum; @@ -86,8 +89,10 @@ import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.util.Units; import org.apache.poi.xwpf.usermodel.*; +import org.jetbrains.annotations.NotNull; import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.springframework.beans.BeanUtils; +import org.springframework.core.io.InputStreamResource; import org.springframework.stereotype.Service; import sun.misc.BASE64Decoder; @@ -118,6 +123,7 @@ public class ReportServiceImpl implements ReportService { private final EventDetailMapper eventDetailMapper; private final ReportMapper reportMapper; private final DrawPicUtil drawPicUtil; + private final FileStorageUtil fileStorageUtil; public List getED(DeviceInfoParam.BusinessParam businessParam, String id) { List info = new ArrayList<>(); @@ -637,6 +643,18 @@ public class ReportServiceImpl implements ReportService { @Override public void getExport(DeviceInfoParam.BusinessParam businessParam, HttpServletResponse response) throws IOException, TemplateException { + HSSFWorkbook sheets = getSheets(businessParam); + PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response); + } + + /** + * 生成暂态报告xlsx + * @param businessParam + * @return + * @throws TemplateException + * @throws IOException + */ + private HSSFWorkbook getSheets(DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException { //区域暂态统计数据 List GereralList = getGeneralSituation(businessParam); //电压暂态统计数据 @@ -859,7 +877,7 @@ public class ReportServiceImpl implements ReportService { drawingPatriarch.createPicture(anchor1, addPicture(str2, sheets)); drawingPatriarch.createPicture(anchor2, addPicture(str3, sheets)); drawingPatriarch.createPicture(anchor3, addPicture(str4, sheets)); - PoiUtil.exportFileByWorkbook(sheets, "电压暂降周报.xlsx", response); + return sheets; } public Integer addPicture(String str, HSSFWorkbook sheets) throws IOException { @@ -7977,6 +7995,21 @@ public class ReportServiceImpl implements ReportService { } + @Override + public String appEventExport(DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException { + //临时缓冲区 + ByteArrayOutputStream out = new ByteArrayOutputStream(); + HSSFWorkbook workbook = this.getSheets(businessParam); + //创建临时文件 + workbook.write(out); + byte[] bookByteAry = out.toByteArray(); + InputStream in = new ByteArrayInputStream(bookByteAry); + String xlsx = fileStorageUtil.uploadStream(in, OssPath.RESPONSIBILITY_APP_REPORT, FileUtil.generateFileName("xlsx")); + workbook.close(); + in.close(); + return xlsx; + } + /** * zbj * diff --git a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java index b79f55649..c93c71be8 100644 --- a/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java +++ b/pqs-event/event-boot/src/main/java/com/njcn/event/service/majornetwork/ReportService.java @@ -64,4 +64,13 @@ public interface ReportService { * @param response */ void getPmsAreaReport(AreaReportParam areaReportParam, HttpServletResponse response) throws Exception; + + /** + * @Description: 灿能云暂态报告 + * @param businessParam + * @return: java.lang.String + * @Author: wr + * @Date: 2024/1/3 11:46 + */ + String appEventExport(DeviceInfoParam.BusinessParam businessParam) throws TemplateException, IOException; } diff --git a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/HistoryResultController.java b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/HistoryResultController.java index d4fec6599..3f0822e3a 100644 --- a/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/HistoryResultController.java +++ b/pqs-harmonic/harmonic-boot/src/main/java/com/njcn/harmonic/controller/HistoryResultController.java @@ -1,5 +1,6 @@ package com.njcn.harmonic.controller; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; @@ -109,8 +110,8 @@ public class HistoryResultController extends BaseController { List list = limitRateDService.list(new LambdaQueryWrapper() .in(RStatLimitRateDPO::getLineId, param.getIds()) .eq(RStatLimitRateDPO::getPhasicType, "T") - .ge(RStatLimitRateDPO::getTime, param.getStartTime()) - .le(RStatLimitRateDPO::getTime, param.getEndTime()) + .ge(StrUtil.isNotBlank(param.getStartTime()),RStatLimitRateDPO::getTime, param.getStartTime()) + .le(StrUtil.isNotBlank(param.getEndTime()),RStatLimitRateDPO::getTime, param.getEndTime()) ); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);