diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java index faeac02..0889171 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/CsLineFeignClient.java @@ -9,6 +9,7 @@ import com.njcn.common.utils.HttpResultUtil; import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory; import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.device.biz.pojo.po.Overlimit; import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; @@ -71,4 +72,7 @@ public interface CsLineFeignClient { @PostMapping("/list") HttpResult> list(@RequestBody CsLinePO param); + @PostMapping("/getLineDetailData") + HttpResult getLineDetailData(@RequestParam("id") String id); + } diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java index 2335aef..3589831 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/fallback/CsLineClientFallbackFactory.java @@ -6,10 +6,12 @@ import com.njcn.common.pojo.response.HttpResult; import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.device.biz.pojo.po.Overlimit; import feign.hystrix.FallbackFactory; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -116,6 +118,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory getLineDetailData(@RequestParam("id") String id) { + log.error("{}异常,降级处理,异常为:{}","查询监测点详情异常",cause.toString()); + throw new BusinessException(finalExceptionEnum); + } }; } } diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/LineDetailDataVO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/LineDetailDataVO.java new file mode 100644 index 0000000..c791abf --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/LineDetailDataVO.java @@ -0,0 +1,135 @@ +package com.njcn.csdevice.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * @author denghuajun + * @date 2022/2/23 + * 监测点信息 + */ +@Data +@ApiModel +public class LineDetailDataVO { + + private String lineId; + + @ApiModelProperty(name = "id",value = "监测点序号") + private Integer id; + + @ApiModelProperty(name = "lineName",value = "监测点名称") + private String lineName; + + @ApiModelProperty(name = "areaName",value = "工程名称") + private String areaName; + + @ApiModelProperty(name = "gdName",value = "单位") + private String gdName; + + @ApiModelProperty(name = "bdName",value = "部门") + private String bdName; + + @ApiModelProperty(name = "scale",value = "电压等级") + private String scale; + + @ApiModelProperty(name = "manufacturer",value = "厂家") + private String manufacturer; + + @ApiModelProperty(name = "devId",value = "终端Id") + private String devId; + + @ApiModelProperty(name = "devName",value = "终端名称") + private String devName; + + @ApiModelProperty(name = "ip",value = "网络参数") + private String ip; + + @ApiModelProperty(name = "runFlag",value = "终端运行状态") + private String runFlag; + + @ApiModelProperty(name = "comFlag",value = "通讯状态") + private String comFlag; + + @ApiModelProperty(name = "loadType",value = "干扰源类型") + private String loadType; + + @ApiModelProperty(name = "businessType",value = "行业类型") + private String businessType; + + @ApiModelProperty(name = "objName",value = "监测点对象名称") + private String objName; + + @ApiModelProperty(name = "ptType",value = "接线方式") + private String ptType; + + @ApiModelProperty(name = "pt",value = "PT变比") + private String pt; + + @ApiModelProperty(name = "ct",value = "CT变比") + private String ct; + + @ApiModelProperty(name = "standardCapacity",value = "基准容量(MVA)") + private Float standardCapacity; + + @ApiModelProperty(name = "shortCapacity",value = "最小短路容量(MVA)") + private Float shortCapacity; + + @ApiModelProperty(name = "devCapacity",value = "供电设备容量(MVA)") + private Float devCapacity; + + @ApiModelProperty(name = "dealCapacity",value = "用户协议容量(MVA)") + private Float dealCapacity; + + @ApiModelProperty(name = "powerFlag",value = "电网标志(0-电网侧;1-非电网侧)") + private Integer powerFlag; + + /** + * 测量间隔(1-10分钟) + */ + @ApiModelProperty(name = "timeInterval",value = "测量间隔(1-10分钟)") + private Integer timeInterval; + + /** + * 监测点拥有者 + */ + @ApiModelProperty(name = "owner",value = "监测点拥有者") + private String owner; + + /** + * 拥有者职务 + */ + @ApiModelProperty(name = "ownerDuty",value = "拥有者职务") + private String ownerDuty; + + /** + * 拥有者联系方式 + */ + @ApiModelProperty(name = "ownerTel",value = "拥有者联系方式") + private String ownerTel; + + /** + * 接线图 + */ + @ApiModelProperty(name = "wiringDiagram",value = "接线图") + private String wiringDiagram; + @ApiModelProperty(name = "ptPhaseType",value = "监测点接线相别(0,单相,1,三相,默认三相)") + private Integer ptPhaseType; + + @ApiModelProperty(name = "投运日期") + private LocalDate loginTime; + + @ApiModelProperty(name = "最新数据时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + @ApiModelProperty(name = "监测对象信息ID") + private String objId; + + @ApiModelProperty(name = "对象类型大类") + private String bigObjType; +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java index 97426a0..1666c02 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java @@ -11,6 +11,7 @@ import com.njcn.common.utils.HttpResultUtil; import com.njcn.csdevice.mapper.OverlimitMapper; import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO; import com.njcn.csdevice.service.CsLinePOService; import com.njcn.device.biz.pojo.po.Overlimit; @@ -302,4 +303,14 @@ public class CslineController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, url, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getLineDetailData") + @ApiOperation("根据监测点id获取监测点详情") + @ApiImplicitParam(name = "id", value = "监测点id", required = true) + public HttpResult getLineDetailData(@RequestParam("id") String id) { + String methodDescribe = getMethodDescribe("getLineDetailData"); + LineDetailDataVO result = csLinePOService.getLineDetailData(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java index 220ed19..448fc03 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO; import com.njcn.web.pojo.param.BaseParam; import org.springframework.web.multipart.MultipartFile; @@ -11,7 +12,7 @@ import org.springframework.web.multipart.MultipartFile; import java.util.List; /** - * + * * Description: * Date: 2023/5/18 14:01【需求编号】 * @@ -83,4 +84,11 @@ public interface CsLinePOService extends IService{ Page getSensitiveUserLineList(BaseParam param); boolean uploadReport(MultipartFile file, String lineId); String getReportUrl(String lineId); + + /** + * 获取监测点详情 + * @param id 监测点id + * @return 结果 + */ + LineDetailDataVO getLineDetailData(String id); } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java index b711c1d..fca68c5 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsLinePOServiceImpl.java @@ -14,9 +14,11 @@ import com.njcn.access.api.CsLineLatestDataFeignClient; import com.njcn.access.pojo.po.CsLineLatestData; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.common.utils.PubUtils; import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.po.*; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO; import com.njcn.csdevice.service.CsDevModelService; import com.njcn.csdevice.service.CsLinePOService; @@ -32,22 +34,21 @@ import com.njcn.user.api.UserFeignClient; import com.njcn.user.pojo.constant.UserType; import com.njcn.user.pojo.vo.UserVO; import com.njcn.web.pojo.param.BaseParam; +import com.njcn.web.pojo.vo.LineDataVO; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; +import org.apache.commons.lang.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** - * + * * Description: * Date: 2023/5/18 14:01【需求编号】 * @@ -386,6 +387,40 @@ public class CsLinePOServiceImpl extends ServiceImpl i } + @Override + public LineDetailDataVO getLineDetailData(String id) { + if (StringUtils.isEmpty(id)) { + return new LineDetailDataVO(); + } else { + CsLinePO csLinePO = this.baseMapper.selectOne(new LambdaQueryWrapper().eq(CsLinePO::getLineId,id)); + LineDetailDataVO lineDetailDataVO = new LineDetailDataVO(); + + //lineDetailDataVO.setScale(dicDataFeignClient.getDicDataById(voltageMapper.selectById(voId).getScale()).getData().getName()); + //Device device = deviceMapper.selectById(devId); + //lineDetailDataVO.setComFlag(PubUtils.comFlag(device.getComFlag())); + //lineDetailDataVO.setRunFlag(PubUtils.lineRunFlag(lineDetail.getRunFlag())); + //lineDetailDataVO.setIp(device.getIp()); + //lineDetailDataVO.setLoginTime(device.getLoginTime()); + //lineDetailDataVO.setDevId(device.getId()); + //lineDetailDataVO.setBusinessType(dicDataFeignClient.getDicDataById(lineDetail.getBusinessType()).getData().getName()); + //lineDetailDataVO.setLoadType(dicDataFeignClient.getDicDataById(lineDetail.getLoadType()).getData().getName()); + lineDetailDataVO.setObjName(csLinePO.getMonitorUser()); + lineDetailDataVO.setLineId(csLinePO.getLineId()); + lineDetailDataVO.setPtType(PubUtils.ptType(csLinePO.getConType())); + //lineDetailDataVO.setPt(lineDetail.getPt1() + "/" + lineDetail.getPt2()); + //lineDetailDataVO.setCt(lineDetail.getCt1() + "/" + lineDetail.getCt2()); + lineDetailDataVO.setDealCapacity(csLinePO.getProtocolCapacity().floatValue()); + lineDetailDataVO.setDevCapacity(csLinePO.getDevCapacity().floatValue()); + lineDetailDataVO.setShortCapacity(csLinePO.getShortCircuitCapacity().floatValue()); + lineDetailDataVO.setStandardCapacity(csLinePO.getBasicCapacity().floatValue()); + lineDetailDataVO.setTimeInterval(csLinePO.getLineInterval()); + + return lineDetailDataVO; + } + + } + + private String getRunStatusDescription(Integer runStatus) { // 0:运行;1:检修;2:停运;3:调试;4:退运 switch (runStatus) { diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java new file mode 100644 index 0000000..648a9e7 --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/WordExportModelController.java @@ -0,0 +1,1756 @@ +package com.njcn.csharmonic.controller; + + +import cn.hutool.core.date.DatePattern; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.ObjectUtil; +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.HttpResultUtil; +import com.njcn.common.utils.PubUtils; +import com.njcn.csdevice.api.CsLineFeignClient; +import com.njcn.csdevice.pojo.vo.LineDetailDataVO; +import com.njcn.csharmonic.service.ReportService; +import com.njcn.device.biz.pojo.po.Overlimit; +import com.njcn.device.biz.pojo.po.PqsDeviceUnit; +import com.njcn.device.pms.api.MonitorClient; +import com.njcn.device.pms.pojo.po.Monitor; +import com.njcn.device.pq.api.DeviceUnitClient; +import com.njcn.harmonic.pojo.param.ReportQueryParam; +import com.njcn.harmonic.pojo.po.report.EnumPass; +import com.njcn.harmonic.pojo.po.report.OverLimitInfo; +import com.njcn.harmonic.pojo.po.report.Pass; +import com.njcn.harmonic.pojo.po.report.ReportTarget; +import com.njcn.harmonic.pojo.vo.ReportValue; +import com.njcn.harmonic.utils.WordUtil2; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.api.ThemeFeignClient; +import com.njcn.system.enums.DicDataEnum; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; +import com.njcn.system.pojo.po.Theme; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.io.ClassPathResource; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import sun.misc.BASE64Encoder; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + + +/** + * @author wr + */ +@Slf4j +@RestController +@RequestMapping("/exportmodel") +@Api(tags = "word报告") +@AllArgsConstructor +public class WordExportModelController extends BaseController { + + /** + * 非谐波数据 + */ + List listVirtual; + List listPower; + List listFlicker; + List listDistortion; + List listVdeviation; + List listFrequency; + List listThreephase; + /** + * 谐波电压数据 + */ + List listVoltageRate; + /** + * 谐波电流数据 + */ + List listICurrent; + + + private final CsLineFeignClient csLineFeignClient; + private final MonitorClient monitorClient; + private final DicDataFeignClient dicDataFeignClient; + 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, + @RequestParam(value ="startTime",required = false) String startTime, + @RequestParam(value ="endTime",required = false) String endTime, + @RequestParam(value ="type",required = false) Integer type, + @RequestParam(value ="lineIndex",required = false) String lineIndex, + @RequestParam(value ="name",required = false) String name, + @RequestParam(value ="reportNumber",required = false) String reportNumber, + @RequestParam(value ="crmName",required = false) String crmName, + @RequestParam(value = "isUrl",required = false) Boolean isUrl, + @RequestPart(value ="file",required = false) MultipartFile file) throws IOException { + String methodDescribe = getMethodDescribe("exportWorld"); + //获取监测点信息 + String bdname; + Integer pttype; + String areaName; + String atype = ""; + String btype = ""; + String ctype = ""; + LineDetailDataVO lineDto = new LineDetailDataVO(); + if (type == 0) { + lineDto = csLineFeignClient.getLineDetailData(lineIndex).getData(); + if (ObjectUtil.isNull(lineDto)) { + throw new BusinessException(CommonResponseEnum.NO_DATA); + } + bdname = lineDto.getBdName(); + areaName = lineDto.getAreaName(); + if("冀北".equals(areaName)){ + areaName="国网"+areaName; + } + pttype = PubUtils.ptTypeName(lineDto.getPtType()); + } else { + List monitorList = monitorClient.getMonitorList(Collections.singletonList(lineIndex)).getData(); + if (ObjectUtil.isNull(monitorList)) { + throw new BusinessException(CommonResponseEnum.NO_DATA); + } + Monitor monitor = monitorList.get(0); + bdname = monitor.getPowerrName(); + areaName = monitor.getOrgName(); + String terminalWiringMethod = dicDataFeignClient.getDicDataById(monitor.getTerminalWiringMethod()).getData().getName(); + pttype = PubUtils.ptTypeName(terminalWiringMethod); + lineDto.setPt(monitor.getPt1() + "/" + monitor.getPt2()); + lineDto.setCt(monitor.getCt1() + "/" + monitor.getCt2()); + //基准容量 + lineDto.setStandardCapacity(monitor.getStandShortCapacity()); + //短路容量 + lineDto.setShortCapacity(monitor.getMinShortCircuitCapacity()); + //协议容量 + lineDto.setDealCapacity(monitor.getUserAgreementCapacity()); + //设备容量 + lineDto.setDevCapacity(monitor.getPowerSupplyEqCapacity()); + //电压等级 + lineDto.setScale(dicDataFeignClient.getDicDataById(monitor.getVoltageLevel()).getData().getName()); + + } + if (pttype == 0) { + atype = "A相"; + btype = "B相"; + ctype = "C相"; + } else if (pttype == 1) { + atype = "AB相"; + btype = "BC相"; + ctype = "CA相"; + } else if (pttype == 2) { + atype = "AB相"; + btype = "BC相"; + ctype = "-"; + + } + DateTime startDate = DateUtil.beginOfDay(DateUtil.parse(startTime)); + DateTime endDate = DateUtil.endOfDay(DateUtil.parse(endTime)); + long day = DateUtil.betweenDay(startDate, endDate, false); + //通用查询条件 + ReportQueryParam param = new ReportQueryParam(); + param.setLineId(lineIndex); + param.setStartTime(DateUtil.format(startDate, "yyyy-MM-dd HH:mm:ss")); + LocalDateTime parse = LocalDateTimeUtil.parse(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss"), DatePattern.NORM_DATETIME_PATTERN); + if(LocalDateTime.now().isBefore(parse)){ + + param.setEndTime(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); + endDate = DateUtil.parse(LocalDateTimeUtil.format(LocalDateTime.now(),DatePattern.NORM_DATETIME_PATTERN)); + + }else { + param.setEndTime(DateUtil.format(endDate, "yyyy-MM-dd HH:mm:ss")); + } + param.setB(day == 0); + + //限值 + OverLimitInfo overLimitData = reportService.getOverLimitData(param); + Overlimit overLimit; + if (type == 0) { + overLimit = csLineFeignClient.getOverLimitData(Stream.of(param.getLineId()).collect(Collectors.toList())).getData().get(0); + } else { + overLimit = monitorClient.getOverLimitData(param.getLineId()).getData(); + } + param.setCount(overLimitData.getCount()); + overLimitData.setOverLimitRate(Arrays.asList(overLimit)); + + + if (0 == overLimitData.getOverLimitRate().size()) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "dataFail", methodDescribe); + } + + String rtfPath; + String picPath = "file/default.jpg"; + + Theme theme = themeFeignClient.getTheme().getData(); + if (theme.getRemark().equals("国网")) { + rtfPath = "file/reportModelGW.docx"; + } else if (theme.getRemark().equals("南网")) { + rtfPath = "file/reportModelNW.docx"; + } else if (theme.getRemark().equals("灿能")) { + rtfPath = "file/reportModelCN.docx"; + } else { + rtfPath = "file/reportModel.docx"; + } + + //获取图片信息 + ClassPathResource picPathResource = null; + try { + picPathResource = new ClassPathResource(picPath); + rtfPath = rtfPath.replaceAll("%20", " "); + } catch (Exception e1) { + log.info("获取报表发生异常,异常是" + e1.getMessage()); + } + + // 报告Map + Map reportmap = new HashMap<>(16); + //数据单位 + PqsDeviceUnit deviceUnit = new PqsDeviceUnit(); + reportmap.putAll(unitMap(deviceUnit)); + reportmap.put("$atype$", atype); + reportmap.put("$btype$", btype); + reportmap.put("$ctype$", ctype); + + Map header = new HashMap<>(16); + if (ObjectUtil.isNotEmpty(file)) { + byte[] bytes = file.getBytes(); + 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; + 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); + } + + reportmap.put("$image$", header); + + getVirtualData(param); + // 电压幅值 + 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 = ""; + // 报表错误 + String strError = ""; + + /************************************************************** + **** 基波电压/电流有效值表格 + * 一、用基波电压和基波电流做是否有值的判断, 判断策略为所有的基波电压和基波电流都为空 + * ************************************* + * ************************************* 二、基本数据判断 + * ①、(最大值>=最小值、平均值、95%概率值) ②、(平均值>=最小值) ③、(95%概率值>=最小值) + ***************************************************************/ + String strBaseVIResult = ""; + // 基波电压最大值 + + reportmap.put("$B" + "V0" + "X" + "_A$", judgeNull(voltage1.getFmaxValue())); + + reportmap.put("$B" + "V0" + "X" + "_B$", judgeNull(voltage2.getFmaxValue())); + reportmap.put("$B" + "V0" + "X" + "_C$", judgeNull(voltage3.getFmaxValue())); + + // 基波电流最大值 + reportmap.put("$B" + "I0" + "X" + "_A$", judgeNull(current1.getFmaxValue())); + reportmap.put("$B" + "I0" + "X" + "_B$", judgeNull(current2.getFmaxValue())); + reportmap.put("$B" + "I0" + "X" + "_C$", judgeNull(current3.getFmaxValue())); + + /************************************************************** + **** 三张大表基础数据幅值 + ***************************************************************/ + // 基波电压最大值 + reportmap.put("$C" + "V0" + "X" + "_A$", judgeNull(voltage1.getFmaxValue())); + reportmap.put("$C" + "V0" + "X" + "_B$", judgeNull(voltage2.getFmaxValue())); + reportmap.put("$C" + "V0" + "X" + "_C$", judgeNull(voltage3.getFmaxValue())); + + // 基波电流最大值 + reportmap.put("$C" + "I0" + "X" + "_A$", judgeNull(current1.getFmaxValue())); + reportmap.put("$C" + "I0" + "X" + "_B$", judgeNull(current2.getFmaxValue())); + reportmap.put("$C" + "I0" + "X" + "_C$", judgeNull(current3.getFmaxValue())); + + // 基波电压最小值 + reportmap.put("$B" + "V0" + "N" + "_A$", judgeNull(voltage1.getMinValue())); + reportmap.put("$B" + "V0" + "N" + "_B$", judgeNull(voltage2.getMinValue())); + reportmap.put("$B" + "V0" + "N" + "_C$", judgeNull(voltage3.getMinValue())); + + // 基波电流最小值 + reportmap.put("$B" + "I0" + "N" + "_A$", judgeNull(current1.getMinValue())); + reportmap.put("$B" + "I0" + "N" + "_B$", judgeNull(current2.getMinValue())); + reportmap.put("$B" + "I0" + "N" + "_C$", judgeNull(current3.getMinValue())); + + /************************************************************** + **** 三张大表基础数据幅值 + ***************************************************************/ + // 基波电压最小值 + reportmap.put("$C" + "V0" + "N" + "_A$", judgeNull(voltage1.getMinValue())); + reportmap.put("$C" + "V0" + "N" + "_B$", judgeNull(voltage2.getMinValue())); + reportmap.put("$C" + "V0" + "N" + "_C$", judgeNull(voltage3.getMinValue())); + + // 基波电流最小值 + reportmap.put("$C" + "I0" + "N" + "_A$", judgeNull(current1.getMinValue())); + reportmap.put("$C" + "I0" + "N" + "_B$", judgeNull(current2.getMinValue())); + reportmap.put("$C" + "I0" + "N" + "_C$", judgeNull(current3.getMinValue())); + + // 基波电压平均值 + reportmap.put("$B" + "V0" + "E" + "_A$", judgeNull(voltage1.getMeanValue())); + reportmap.put("$B" + "V0" + "E" + "_B$", judgeNull(voltage2.getMeanValue())); + reportmap.put("$B" + "V0" + "E" + "_C$", judgeNull(voltage3.getMeanValue())); + + // 基波电流平均值 + reportmap.put("$B" + "I0" + "E" + "_A$", judgeNull(current1.getMeanValue())); + reportmap.put("$B" + "I0" + "E" + "_B$", judgeNull(current2.getMeanValue())); + reportmap.put("$B" + "I0" + "E" + "_C$", judgeNull(current3.getMeanValue())); + + /************************************************************** + **** 三张大表基础数据幅值 + ***************************************************************/ + // 基波电压平均值 + reportmap.put("$C" + "V0" + "E" + "_A$", judgeNull(voltage1.getMeanValue())); + reportmap.put("$C" + "V0" + "E" + "_B$", judgeNull(voltage2.getMeanValue())); + reportmap.put("$C" + "V0" + "E" + "_C$", judgeNull(voltage3.getMeanValue())); + + // 基波电流平均值 + reportmap.put("$C" + "I0" + "E" + "_A$", judgeNull(current1.getMeanValue())); + reportmap.put("$C" + "I0" + "E" + "_B$", judgeNull(current2.getMeanValue())); + reportmap.put("$C" + "I0" + "E" + "_C$", judgeNull(current3.getMeanValue())); + + // 基波电压cp95值 + reportmap.put("$B" + "V0" + "%" + "_A$", judgeNull(voltage1.getCp95Value())); + reportmap.put("$B" + "V0" + "%" + "_B$", judgeNull(voltage2.getCp95Value())); + reportmap.put("$B" + "V0" + "%" + "_C$", judgeNull(voltage3.getCp95Value())); + + // 基波电流cp95值 + reportmap.put("$B" + "I0" + "%" + "_A$", judgeNull(current1.getCp95Value())); + reportmap.put("$B" + "I0" + "%" + "_B$", judgeNull(current2.getCp95Value())); + reportmap.put("$B" + "I0" + "%" + "_C$", judgeNull(current3.getCp95Value())); + + /************************************************************** + **** 三张大表基础数据幅值 + ***************************************************************/ + // 基波电压cp95值 + reportmap.put("$C" + "V0" + "%" + "_A$", judgeNull(voltage1.getCp95Value())); + reportmap.put("$C" + "V0" + "%" + "_B$", judgeNull(voltage2.getCp95Value())); + reportmap.put("$C" + "V0" + "%" + "_C$", judgeNull(voltage3.getCp95Value())); + + // 基波电流cp95值 + reportmap.put("$C" + "I0" + "%" + "_A$", judgeNull(current1.getCp95Value())); + reportmap.put("$C" + "I0" + "%" + "_B$", judgeNull(current2.getCp95Value())); + reportmap.put("$C" + "I0" + "%" + "_C$", judgeNull(current3.getCp95Value())); + + // 遍历map中的值 + int iCount = 0; + // 判断所取的基波电压、基波电流值是否为null + for (Object value : reportmap.values()) { + if (value == null) + iCount++; + } + // 假如所有的数据都为null,则返回(所选的时间段内未找到数据) + if (iCount == reportmap.size()) { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "exportWorld", methodDescribe); + } + // 基本数据判断 + for (int i = 0; i < 3; i++) { + String tmpstrMap = "A"; + switch (i) { + case 0: + tmpstrMap = "A"; + break; + case 1: + tmpstrMap = "B"; + break; + default: + tmpstrMap = "C"; + break; + } + try { + // 基波电压 + Double vmaxValue = Double.parseDouble(reportmap.get("$BV0X_" + tmpstrMap + "$").toString()); + Double vminValue = Double.parseDouble(reportmap.get("$BV0N_" + tmpstrMap + "$").toString()); + Double vaveValue = Double.parseDouble(reportmap.get("$BV0E_" + tmpstrMap + "$").toString()); + Double vcp95Value = Double.parseDouble(reportmap.get("$BV0%_" + tmpstrMap + "$").toString()); + // 基波电流 + Double imaxValue = Double.parseDouble(reportmap.get("$BI0X_" + tmpstrMap + "$").toString()); + Double iminValue = Double.parseDouble(reportmap.get("$BI0N_" + tmpstrMap + "$").toString()); + Double iaveValue = Double.parseDouble(reportmap.get("$BI0E_" + tmpstrMap + "$").toString()); + Double icp95Value = Double.parseDouble(reportmap.get("$BI0%_" + tmpstrMap + "$").toString()); + + if (!(vmaxValue >= vminValue && vmaxValue >= vaveValue && vmaxValue >= vcp95Value)) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } else if (vaveValue < vminValue) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } else if (vcp95Value < vminValue) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } else if (!(imaxValue >= iminValue && imaxValue >= iaveValue && imaxValue >= icp95Value)) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } else if (iaveValue < iminValue) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } else if (icp95Value < iminValue) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + + "基波电压/电流数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + break; + } + } catch (Exception e) { + strBaseVIResult += "注意:从上表中可以看出" + strLineBaseName + "基波电压/电流数据存在异常(不是数值类型)。"; + break; + } + } + reportmap.put("$BaseVIResult$", strBaseVIResult); + if (!"".equals(strBaseVIResult)) + strError += strBaseVIResult; + + /************************************************************** + **** 所选的时间段内有数据存在则进行其他加载 + ***************************************************************/ + +// Depts dep = R.getCurrentDept(); +// String detpName = dep.getArea(); + // 区域名称 + reportmap.put("$detpName$", areaName); + // 获取报告生成时间 + Date currentTime = new Date(); + // 报告时分秒格式 + SimpleDateFormat formatter = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒"); + String strTime = String.format("%s——%s。", + new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"), + DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒")}); + // 报告编号 + reportmap.put("$number$", reportNumber); + // 客户名称 + reportmap.put("$titlePoint$", crmName); + // 报告生成时间 + reportmap.put("$TitleTime$", formatter.format(currentTime)); + // 报告标题 + reportmap.put("$ReportTitle$", + String.format("对该地区%s电能质量在线监测数据进行分析, 以判断电能质量指标是否满足国标。", new String[]{strLineBaseName})); + // 报告分析时间段 + reportmap.put("$ReportTime$", strTime); + // 运行数据分析 + reportmap.put("$RunBaseName$", String.format("以下将对%s电能质量统计数据进行分析,数据包括基波电压/电流、谐波电压/电流、电压偏差、三相电压不平衡度、电压闪变、频率偏差。", + new String[]{strLineBaseName})); + // 基波电压和电流 + reportmap.put("$BaseVITable$", String.format("报告分析时间段内%s的基波电压/电流分钟统计数据见下表。", new String[]{strLineBaseName})); + // 供电电压偏差 + reportmap.put("$VDTable$", String.format("报告分析时间段内%s的电压偏差统计数据见下表。", new String[]{strLineBaseName})); + // 频率偏差 + reportmap.put("$FRETable$", String.format("报告分析时间段内%s的频率偏差统计数据见下表。", new String[]{strLineBaseName})); + // 三相电压不平衡度 + reportmap.put("$THETable$", String.format("报告分析时间段内%s的三相电压不平衡度统计数据见下表。", new String[]{strLineBaseName})); + // 闪变 + reportmap.put("$PLTTable$", String.format("报告分析时间段内%s的闪变统计数据见下表。", new String[]{strLineBaseName})); + // 谐波电压 + reportmap.put("$RVTable$", + String.format("报告分析时间段内%s的2-25次谐波电压含有率CP95概率值统计数据见下表。", new String[]{strLineBaseName})); + // 谐波电流 + reportmap.put("$RITable$", + String.format("报告分析时间段内%s的2-25次谐波电流幅值CP95概率值统计数据见下表。", new String[]{strLineBaseName})); + // 监测点名称1 + reportmap.put("$LineName1$", name); + // 监测点名称2 + reportmap.put("$LineName2$", name); + // 监测点名称3 + reportmap.put("$LineName3$", name); + // 监测点名称4 + reportmap.put("$LineName4$", name); + // 监测点名称5 + reportmap.put("$LineName5$", name); + + /********************** + **** 数据获取 + ***********************/ + + getPowerData(param); + getFlicker(param, overLimit); + getVdeviation(param, overLimit); + getDistortion(param, overLimit); + getFre(param, overLimit); + getThreePhase(param, overLimit); + getVoltageRate(param, overLimit); + getCurrentRate(param, overLimit); + // 短闪 + 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()})); + + /************************************************************** + **** 三张大表基础数据幅值 + ***************************************************************/ + reportmap.put("$CI_JCD$", bdname); + reportmap.put("$bdTitle$", bdname); + + reportmap.put("$CI_Time$", strTime); + reportmap.put("$CI_JCXL$", name); + reportmap.put("$CI_PT$", lineDto.getPt()); + reportmap.put("$CI_DYDJ$", lineDto.getScale()); + reportmap.put("$CI_CT$", lineDto.getCt()); + reportmap.put("$CI_JZRL$", String.valueOf(lineDto.getStandardCapacity())); + reportmap.put("$CI_DLRL$", String.valueOf(lineDto.getShortCapacity())); + reportmap.put("$CI_XYRL$", String.valueOf(lineDto.getDealCapacity())); + reportmap.put("$CI_SBRL$", String.valueOf(lineDto.getDevCapacity())); + + reportmap.put("$CV_JCD$", bdname); + reportmap.put("$CV_Time$", strTime); + reportmap.put("$CV_JCXL$", name); + reportmap.put("$CV_PT$", lineDto.getPt()); + reportmap.put("$CV_DYDJ$", lineDto.getScale()); + reportmap.put("$CV_CT$", lineDto.getCt()); + reportmap.put("$CV_JZRL$", String.valueOf(lineDto.getStandardCapacity())); + reportmap.put("$CV_DLRL$", String.valueOf(lineDto.getShortCapacity())); + reportmap.put("$CV_XYRL$", String.valueOf(lineDto.getDealCapacity())); + reportmap.put("$CV_SBRL$", String.valueOf(lineDto.getDevCapacity())); + + reportmap.put("$FV_JCD$", bdname); + reportmap.put("$FV_Time$", strTime); + reportmap.put("$FV_JCXL$", name); + reportmap.put("$FV_PT$", lineDto.getPt()); + reportmap.put("$FV_DYDJ$", lineDto.getScale()); + reportmap.put("$FV_CT$", lineDto.getCt()); + reportmap.put("$FV_JZRL$", String.valueOf(lineDto.getStandardCapacity())); + reportmap.put("$FV_DLRL$", String.valueOf(lineDto.getShortCapacity())); + reportmap.put("$FV_XYRL$", String.valueOf(lineDto.getDealCapacity())); + reportmap.put("$FV_SBRL$", String.valueOf(lineDto.getDevCapacity())); + + Double maxValue = 0.00; + Double minValue = 0.00; + Double aveValue = 0.00; + Double cp95Value = 0.00; + Double cp95ValueA = 0.00; + Double cp95ValueB = 0.00; + Double cp95ValueC = 0.00; + Double limit = 0.00; + /************************************************************** + **** 电压偏差(上偏差和下偏差) + ***************************************************************/ + 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 = ""; + String tmpstrResultVdeviationdata = ""; + String strResultVdeviationdataValue = ""; + // 获取电压偏差 + String tmpstrMap = ""; + reportmap.put("$VDTX_A$", judgeNull(vdeviation1.getFmaxValue())); + reportmap.put("$VDTN_A$", judgeNull(vdeviation1.getMinValue())); + reportmap.put("$VDTE_A$", judgeNull(vdeviation1.getMeanValue())); + reportmap.put("$VDT%_A$", judgeNull(vdeviation1.getCp95Value())); + reportmap.put("$VDTX_B$", judgeNull(vdeviation2.getFmaxValue())); + reportmap.put("$VDTN_B$", judgeNull(vdeviation2.getMinValue())); + reportmap.put("$VDTE_B$", judgeNull(vdeviation2.getMeanValue())); + reportmap.put("$VDT%_B$", judgeNull(vdeviation2.getCp95Value())); + if (pttype != 2) { + reportmap.put("$VDTX_C$", judgeNull(vdeviation3.getFmaxValue())); + reportmap.put("$VDTN_C$", judgeNull(vdeviation3.getMinValue())); + reportmap.put("$VDTE_C$", judgeNull(vdeviation3.getMeanValue())); + reportmap.put("$VDT%_C$", judgeNull(vdeviation3.getCp95Value())); + } else { + reportmap.put("$VDTX_C$", "-"); + reportmap.put("$VDTN_C$", "-"); + reportmap.put("$VDTE_C$", "-"); + reportmap.put("$VDT%_C$", "-"); + } + + // 值错误判断 + try { + maxValue = Math.abs(Double.parseDouble(vdeviation1.getFmaxValue().toString())); + minValue = Math.abs(Double.parseDouble(vdeviation1.getMinValue().toString())); + aveValue = Math.abs(Double.parseDouble(vdeviation1.getMeanValue().toString())); + cp95Value = Math.abs(Double.parseDouble(vdeviation1.getCp95Value().toString())); + limit = Math.abs(Double.parseDouble(vdeviationLimit)); + } catch (Exception e) { + strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + "电压偏差数据存在异常(不是数值类型)。"; + } + + if ("".equals(strResultVdeviationdataValue)) { + if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { + strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (aveValue < minValue) { + strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (cp95Value < minValue) { + strResultVdeviationdataValue += "注意:从上表中可以看出" + strLineBaseName + + "电压偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } + } + // 限值判断 + if (maxValue > limit) { + if (!"".equals(tmpstrResultVdeviationdata)) + tmpstrResultVdeviationdata += "、"; + tmpstrResultVdeviationdata += tmpstrMap + "相"; + } + + // 假如为空则所有的都满足 + if ("".equals(tmpstrResultVdeviationdata)) { + strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + "A、B、C三相电压偏差满足国标限值(10%)的要求。"; + } else { + strAnalysis += tmpstrResultVdeviationdata + "电压偏差不满足国标限值(10%)的要求。"; + strResultVdeviationdata += "从上表中可以看出" + strLineBaseName + tmpstrResultVdeviationdata + + "电压偏差不满足国标限值(10%)的要求。"; + } + + reportmap.put("$ResultVdeviationdata$", strResultVdeviationdata); + reportmap.put("$ResultVdeviationdataValue$", strResultVdeviationdataValue); + strError += strResultVdeviationdataValue; + + /************************************************************** + **** 频率偏差 + ***************************************************************/ + ReportValue valueOfFreValue = this.listFrequency.get(1).getList().get(0); + // 获取频率偏差国标限值 + String valueOfFreLimit = judgeNull(this.listFrequency.get(1).getOverLimit()); + reportmap.put("$FRE_L$", valueOfFreLimit); + String strResultFre = ""; + String tmpstrResultFre = ""; + String strResultFreValue = ""; + + reportmap.put("$FREX$", judgeNull(valueOfFreValue.getFmaxValue())); + reportmap.put("$FREN$", judgeNull(valueOfFreValue.getMinValue())); + reportmap.put("$FREE$", judgeNull(valueOfFreValue.getMeanValue())); + reportmap.put("$FRE%$", judgeNull(valueOfFreValue.getCp95Value())); + + /************************************ + **** 三张大表取值 + **************************************/ + reportmap.put("$FV0L$", valueOfFreLimit); + reportmap.put("$FV0X$", judgeNull(valueOfFreValue.getFmaxValue())); + reportmap.put("$FV0N$", judgeNull(valueOfFreValue.getMinValue())); + reportmap.put("$FV0E$", judgeNull(valueOfFreValue.getMeanValue())); + reportmap.put("$FV0%$", judgeNull(valueOfFreValue.getCp95Value())); + + try { + maxValue = Double.parseDouble(valueOfFreValue.getFmaxValue().toString()); + minValue = Double.parseDouble(valueOfFreValue.getMinValue().toString()); + aveValue = Double.parseDouble(valueOfFreValue.getMeanValue().toString()); + cp95Value = Double.parseDouble(valueOfFreValue.getCp95Value().toString()); + limit = Math.abs(Double.parseDouble(valueOfFreLimit)); + } catch (Exception e) { + strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + "频率偏差数据存在异常(不是数值类型)。"; + } + + if (Math.abs(maxValue) > limit) { + tmpstrResultFre += "最大值为:" + valueOfFreValue.getFmaxValue().toString() + deviceUnit.getUnitFrequencyDev(); + } + if (Math.abs(minValue) > limit) { + tmpstrResultFre += "最小值为:" + valueOfFreValue.getMinValue().toString() + deviceUnit.getUnitFrequencyDev(); + } + if (Math.abs(aveValue) > limit) { + tmpstrResultFre += "平均值为:" + valueOfFreValue.getMeanValue().toString() + deviceUnit.getUnitFrequencyDev(); + } + if (Math.abs(cp95Value) > limit) { + tmpstrResultFre += "95%概率值为:" + valueOfFreValue.getCp95Value().toString() + deviceUnit.getUnitFrequencyDev(); + } + + if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { + strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (aveValue < minValue) { + strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (cp95Value < minValue) { + strResultFreValue += "注意:从上表中可以看出" + strLineBaseName + + "频率偏差数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } + + if ("".equals(tmpstrResultFre)) { + // 三张大表取值 + reportmap.put("$FV0R$", "合格"); + strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差均满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。"; + } else { + // 三张大表取值 + reportmap.put("$FV0R$", "不合格"); + strAnalysis += tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + deviceUnit.getUnitFrequencyDev() + ")的要求。"; + strResultFre += "从上表中可以看出" + strLineBaseName + "频率偏差" + tmpstrResultFre + ",均不满足国标限值(±" + valueOfFreLimit + + deviceUnit.getUnitFrequencyDev() + ")的要求。"; + } + + reportmap.put("$ResultFre$", strResultFre); + reportmap.put("$ResultFreValue$", strResultFreValue); + strError += strResultFreValue; + + /************************************************************** + **** 三相电压不平衡度 + ***************************************************************/ + ReportValue valueOfThree = this.listThreephase.get(0).getList().get(0); + // 获取三相电压不平衡度国标限值 + String valueOfThreeLimit = judgeNull(this.listThreephase.get(0).getOverLimit()); + reportmap.put("$THE_L$", valueOfThreeLimit); + String strResultThree = ""; + String tmpstrResultThree = ""; + String strResultThreeValue = ""; + reportmap.put("$THEX$", judgeNull(valueOfThree.getFmaxValue())); + reportmap.put("$THEN$", judgeNull(valueOfThree.getMinValue())); + reportmap.put("$THEE$", judgeNull(valueOfThree.getMeanValue())); + reportmap.put("$THE%$", judgeNull(valueOfThree.getCp95Value())); + + /************************************ + **** 三张大表取值 + **************************************/ + reportmap.put("$TV0L$", valueOfThreeLimit); + reportmap.put("$TV0X$", judgeNull(valueOfThree.getFmaxValue())); + reportmap.put("$TV0N$", judgeNull(valueOfThree.getMinValue())); + reportmap.put("$TV0E$", judgeNull(valueOfThree.getMeanValue())); + reportmap.put("$TV0%$", judgeNull(valueOfThree.getCp95Value())); + + try { + maxValue = Double.parseDouble(valueOfThree.getFmaxValue().toString()); + minValue = Double.parseDouble(valueOfThree.getMinValue().toString()); + aveValue = Double.parseDouble(valueOfThree.getMeanValue().toString()); + cp95Value = Double.parseDouble(valueOfThree.getCp95Value().toString()); + limit = Double.parseDouble(valueOfThreeLimit); + } catch (Exception e) { + strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + "三相电压不平衡度数据存在异常(不是数值类型)。"; + } + if (cp95Value > limit) { + // 三张大表取值 + reportmap.put("$TV0R$", "不合格"); + tmpstrResultThree += "三相电压不平衡度95%概率值为:" + valueOfThree.getCp95Value().toString(); + } else { + // 三张大表取值 + reportmap.put("$TV0R$", "合格"); + } + + if (!(maxValue >= minValue && maxValue >= aveValue && maxValue >= cp95Value)) { + strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (aveValue < minValue) { + strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } else if (cp95Value < minValue) { + strResultThreeValue += "注意:从上表中可以看出" + strLineBaseName + + "三相电压不平衡度数据存在异常( 1、最大值>=最小值、平均值、95%概率值;2、平均值>=最小值;3、95%概率值>=最小值)。"; + } + + if ("".equals(tmpstrResultThree)) { + strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + tmpstrResultThree + + ",满足国标限值(" + valueOfThreeLimit + "%)的要求。"; + } else { + strAnalysis += tmpstrResultThree + ",不满足国标限值(" + valueOfThreeLimit + "%)的要求。"; + strResultThree += "三相电压不平衡度根据国标标准测量结果以95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + tmpstrResultThree + + ",不满足国标限值(" + valueOfThreeLimit + "%)的要求。"; + } + + reportmap.put("$ResultThree$", strResultThree); + reportmap.put("$ResultThreeValue$", strResultThreeValue); + strError += strResultThreeValue; + + /************************************************************** + **** 电压闪变 + ***************************************************************/ + // 获取电压长时闪变的限值 + String valueOfFlickerLimit = judgeNull(this.listFlicker.get(1).getOverLimit()); + reportmap.put("$PLT_L$", valueOfFlickerLimit); + String strResultFlicker = ""; + String tmpstrResultFlicker = ""; + String strResultFlickerValue = ""; + Double fmaxValue1 = 0.0; + Double fmaxValue2 = 0.0; + Double fmaxValue3 = 0.0; + Double flickerLimit = 0.0; + try { + fmaxValue1 = Double.parseDouble(plt1.getFmaxValue().toString()); + fmaxValue2 = Double.parseDouble(plt2.getFmaxValue().toString()); + fmaxValue3 = Double.parseDouble(plt3.getFmaxValue().toString()); + flickerLimit = Double.parseDouble(valueOfFlickerLimit); + } catch (Exception e) { + strResultFlickerValue += "注意:从上表中可以看出" + strLineBaseName + "长时闪变数据存在异常(不是数值类型)。"; + } + if (fmaxValue1 > flickerLimit) { + if (!"".equals(tmpstrResultFlicker)) + tmpstrResultFlicker += ","; + tmpstrResultFlicker += atype + "最大值为:" + plt1.getFmaxValue().toString(); + reportmap.put("$" + "L" + "V0R_" + "A" + "$", "不合格"); + } else { + reportmap.put("$" + "L" + "V0R_" + "A" + "$", "合格"); + } + + if (fmaxValue2 > flickerLimit) { + if (!"".equals(tmpstrResultFlicker)) + tmpstrResultFlicker += ","; + tmpstrResultFlicker += btype + "最大值为:" + plt2.getFmaxValue().toString(); + reportmap.put("$" + "L" + "V0R_" + "B" + "$", "不合格"); + } else { + reportmap.put("$" + "L" + "V0R_" + "B" + "$", "合格"); + } + + if (fmaxValue3 > flickerLimit && pttype != 2) { + if (!"".equals(tmpstrResultFlicker)) + tmpstrResultFlicker += ","; + tmpstrResultFlicker += ctype + "最大值为:" + plt3.getFmaxValue().toString(); + reportmap.put("$" + "L" + "V0R_" + "C" + "$", "不合格"); + } else { + reportmap.put("$" + "L" + "V0R_" + "C" + "$", "合格"); + } + + reportmap.put("$PSTX_A$", judgeNull(pst1.getFmaxValue())); + reportmap.put("$PSTN_A$", judgeNull(pst1.getMinValue())); + reportmap.put("$PSTE_A$", judgeNull(pst1.getMeanValue())); + reportmap.put("$PST%_A$", judgeNull(pst1.getCp95Value())); + reportmap.put("$PSTX_B$", judgeNull(pst2.getFmaxValue())); + reportmap.put("$PSTN_B$", judgeNull(pst2.getMinValue())); + reportmap.put("$PSTE_B$", judgeNull(pst2.getMeanValue())); + reportmap.put("$PST%_B$", judgeNull(pst2.getCp95Value())); + if (pttype != 2) { + reportmap.put("$PSTX_C$", judgeNull(pst3.getFmaxValue())); + reportmap.put("$PSTN_C$", judgeNull(pst3.getMinValue())); + reportmap.put("$PSTE_C$", judgeNull(pst3.getMeanValue())); + reportmap.put("$PST%_C$", judgeNull(pst3.getCp95Value())); + } else { + reportmap.put("$PSTX_C$", "-"); + reportmap.put("$PSTN_C$", "-"); + reportmap.put("$PSTE_C$", "-"); + reportmap.put("$PST%_C$", "-"); + } + + reportmap.put("$PLTX_A$", judgeNull(plt1.getFmaxValue())); + reportmap.put("$PLTN_A$", judgeNull(plt1.getMinValue())); + reportmap.put("$PLTE_A$", judgeNull(plt1.getMeanValue())); + reportmap.put("$PLT%_A$", judgeNull(plt1.getCp95Value())); + reportmap.put("$PLTX_B$", judgeNull(plt2.getFmaxValue())); + reportmap.put("$PLTN_B$", judgeNull(plt2.getMinValue())); + reportmap.put("$PLTE_B$", judgeNull(plt2.getMeanValue())); + reportmap.put("$PLT%_B$", judgeNull(plt2.getCp95Value())); + if (pttype != 2) { + reportmap.put("$PLTX_C$", judgeNull(plt3.getFmaxValue())); + reportmap.put("$PLTN_C$", judgeNull(plt3.getMinValue())); + reportmap.put("$PLTE_C$", judgeNull(plt3.getMeanValue())); + reportmap.put("$PLT%_C$", judgeNull(plt3.getCp95Value())); + } else { + reportmap.put("$PLTX_C$", "-"); + reportmap.put("$PLTN_C$", "-"); + reportmap.put("$PLTE_C$", "-"); + reportmap.put("$PLT%_C$", "-"); + } + reportmap.put("$PLT_L$", valueOfFlickerLimit); + + /************************************ + **** 三张大表取值 + **************************************/ + reportmap.put("$" + "L" + "V0" + "X" + "_" + "A" + "$", judgeNull(plt1.getFmaxValue())); + reportmap.put("$" + "L" + "V0" + "E" + "_" + "A" + "$", judgeNull(plt1.getMeanValue())); + reportmap.put("$" + "L" + "V0" + "N" + "_" + "A" + "$", judgeNull(plt1.getMinValue())); + reportmap.put("$" + "L" + "V0" + "%" + "_" + "A" + "$", judgeNull(plt1.getCp95Value())); + reportmap.put("$" + "L" + "V0" + "X" + "_" + "B" + "$", judgeNull(plt2.getFmaxValue())); + reportmap.put("$" + "L" + "V0" + "E" + "_" + "B" + "$", judgeNull(plt2.getMeanValue())); + reportmap.put("$" + "L" + "V0" + "N" + "_" + "B" + "$", judgeNull(plt2.getMinValue())); + reportmap.put("$" + "L" + "V0" + "%" + "_" + "B" + "$", judgeNull(plt2.getCp95Value())); + reportmap.put("$" + "L" + "V0" + "X" + "_" + "C" + "$", judgeNull(plt3.getFmaxValue())); + reportmap.put("$" + "L" + "V0" + "E" + "_" + "C" + "$", judgeNull(plt3.getMeanValue())); + reportmap.put("$" + "L" + "V0" + "N" + "_" + "C" + "$", judgeNull(plt3.getMinValue())); + reportmap.put("$" + "L" + "V0" + "%" + "_" + "C" + "$", judgeNull(plt3.getCp95Value())); + reportmap.put("$LV0%_L$", valueOfFlickerLimit); + + reportmap.put("$" + "S" + "V0" + "X" + "_" + "A" + "$", judgeNull(pst1.getFmaxValue())); + reportmap.put("$" + "S" + "V0" + "E" + "_" + "A" + "$", judgeNull(pst1.getMeanValue())); + reportmap.put("$" + "S" + "V0" + "N" + "_" + "A" + "$", judgeNull(pst1.getMinValue())); + reportmap.put("$" + "S" + "V0" + "%" + "_" + "A" + "$", judgeNull(pst1.getCp95Value())); + reportmap.put("$" + "S" + "V0" + "X" + "_" + "B" + "$", judgeNull(pst2.getFmaxValue())); + reportmap.put("$" + "S" + "V0" + "E" + "_" + "B" + "$", judgeNull(pst2.getMeanValue())); + reportmap.put("$" + "S" + "V0" + "N" + "_" + "B" + "$", judgeNull(pst2.getMinValue())); + reportmap.put("$" + "S" + "V0" + "%" + "_" + "B" + "$", judgeNull(pst2.getCp95Value())); + reportmap.put("$" + "S" + "V0" + "X" + "_" + "C" + "$", judgeNull(pst3.getFmaxValue())); + reportmap.put("$" + "S" + "V0" + "E" + "_" + "C" + "$", judgeNull(pst3.getMeanValue())); + reportmap.put("$" + "S" + "V0" + "N" + "_" + "C" + "$", judgeNull(pst3.getMinValue())); + reportmap.put("$" + "S" + "V0" + "%" + "_" + "C" + "$", judgeNull(pst3.getCp95Value())); + + if ("".equals(tmpstrResultFlicker)) { + strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + "长时闪变" + + tmpstrResultFlicker + ",其满足国标限值(" + valueOfFlickerLimit + ")的要求。"; + } else { + strAnalysis += "长时闪变" + tmpstrResultFlicker + ",其不满足国标限值(" + valueOfFlickerLimit + ")的要求。"; + strResultFlicker += "电压长时闪变根据国标标准测量结果以最大值、最小值、95%概率值作为判断是否合格的依据,从上表中可以看出" + strLineBaseName + "长时闪变" + + tmpstrResultFlicker + ",其不满足国标限值(" + valueOfFlickerLimit + ")的要求。"; + } + + reportmap.put("$ResultFlicker$", strResultFlicker); + reportmap.put("$ResultFlickerValue$", strResultFlickerValue); + strError += strResultFlickerValue; + + /************************************************************** + **** 电压含有率 + ***************************************************************/ + String strResultVoltageRate = ""; + String tmpstrResultVoltageRate = ""; + String strResultVoltageRateValue = ""; + String strCurrentA, strCurrentB, strCurrentC, strLimit; + // 获取25次谐波 + for (int i = 1; i < 25; i++) { + String strMap = "$RV"; + String strCurrentRate = strMap + (i + 1) + "%"; + + // 基波电压含有率 + 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); + reportmap.put(strCurrentRate + "_B$", strCurrentB); + if (pttype != 2) { + reportmap.put(strCurrentRate + "_C$", strCurrentC); + } else { + reportmap.put(strCurrentRate + "_C$", "-"); + } + reportmap.put(strCurrentRate + "_L$", strLimit); + + /************************************ + **** 三张大表取值 + **************************************/ + reportmap.put("$CV" + (i + 1) + "X_A$", + judgeNull((this.listVoltageRate.get(i).getList().get(0)).getFmaxValue())); + reportmap.put("$CV" + (i + 1) + "X_B$", + judgeNull((this.listVoltageRate.get(i).getList().get(1)).getFmaxValue())); + + reportmap.put("$CV" + (i + 1) + "N_A$", + judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMinValue())); + reportmap.put("$CV" + (i + 1) + "N_B$", + judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMinValue())); + + reportmap.put("$CV" + (i + 1) + "E_A$", + judgeNull((this.listVoltageRate.get(i).getList().get(0)).getMeanValue())); + reportmap.put("$CV" + (i + 1) + "E_B$", + judgeNull((this.listVoltageRate.get(i).getList().get(1)).getMeanValue())); + + if (pttype != 2) { + reportmap.put("$CV" + (i + 1) + "X_C$", + judgeNull((this.listVoltageRate.get(i).getList().get(2)).getFmaxValue())); + reportmap.put("$CV" + (i + 1) + "N_C$", + judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMinValue())); + reportmap.put("$CV" + (i + 1) + "E_C$", + judgeNull((this.listVoltageRate.get(i).getList().get(2)).getMeanValue())); + reportmap.put("$CV" + (i + 1) + "%_C$", strCurrentC); + } else { + reportmap.put("$CV" + (i + 1) + "X_C$", "-"); + reportmap.put("$CV" + (i + 1) + "N_C$", "-"); + reportmap.put("$CV" + (i + 1) + "E_C$", "-"); + reportmap.put("$CV" + (i + 1) + "%_C$", "-"); + } + + reportmap.put("$CV" + (i + 1) + "%_A$", strCurrentA); + reportmap.put("$CV" + (i + 1) + "%_B$", strCurrentB); + reportmap.put("$CV" + (i + 1) + "L$", strLimit); + + try { + maxValue = Double.parseDouble(strCurrentA); + minValue = Double.parseDouble(strCurrentB); + aveValue = Double.parseDouble(strCurrentC); + limit = Double.parseDouble(strLimit); + } catch (Exception e) { + strResultVoltageRateValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电压含有率95%概率值数据存在异常(不是数值类型)。"; + } + + String tmpstrResult = ""; + if (maxValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "A"; + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_A$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_A$", "合格"); + } + if (minValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "B"; + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_B$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_B$", "合格"); + } + if (aveValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "C"; + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_C$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CV" + (i + 1) + "R_C$", "合格"); + } + // 判断单个结论是否存在 + if (!"".equals(tmpstrResult)) { + tmpstrResultVoltageRate += (i + 1) + "次谐波电压含有率95%概率值" + tmpstrResult + ";"; + } + } + + // 假如为空则所有的都满足 + if ("".equals(tmpstrResultVoltageRate)) { + strResultVoltageRate += "从上表中可以看出" + strLineBaseName + "2-25次谐波电压含有率95%概率值均满足国标限值要求。"; + } else { + strAnalysis += tmpstrResultVoltageRate + "2-25次谐波电压含有率95%概率值均不满足国标限值要求。"; + strResultVoltageRate += "从上表中可以看出" + strLineBaseName + tmpstrResultVoltageRate + "均不满足国标限值要求。"; + } + + /************************************************************** + **** 电压总谐波畸变率(THD) + ***************************************************************/ + 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); + + String strResultDistortion = ""; + String tmpstrResultDistortion = ""; + String strResultDistortionValue = ""; + + reportmap.put("$DV0%_A$", judgeNull(distortion1.getCp95Value())); + reportmap.put("$DV0%_B$", judgeNull(distortion2.getCp95Value())); + reportmap.put("$DV0%_C$", judgeNull(distortion3.getCp95Value())); + + /************************************ + **** 三张大表取值 + **************************************/ + reportmap.put("$TV0X_L$", distortionLimit); + reportmap.put("$TV0X_A$", judgeNull(distortion1.getFmaxValue())); + reportmap.put("$TV0E_A$", judgeNull(distortion1.getMeanValue())); + reportmap.put("$TV0N_A$", judgeNull(distortion1.getMinValue())); + reportmap.put("$TV0%_A$", judgeNull(distortion1.getCp95Value())); + + reportmap.put("$TV0X_B$", judgeNull(distortion2.getFmaxValue())); + reportmap.put("$TV0E_B$", judgeNull(distortion2.getMeanValue())); + reportmap.put("$TV0N_B$", judgeNull(distortion2.getMinValue())); + reportmap.put("$TV0%_B$", judgeNull(distortion2.getCp95Value())); + + reportmap.put("$TV0X_C$", judgeNull(distortion3.getFmaxValue())); + reportmap.put("$TV0E_C$", judgeNull(distortion3.getMeanValue())); + reportmap.put("$TV0N_C$", judgeNull(distortion3.getMinValue())); + reportmap.put("$TV0%_C$", judgeNull(distortion3.getCp95Value())); + + // 值错误判断 + try { + cp95ValueA = Math.abs(Double.parseDouble(distortion1.getCp95Value().toString())); + cp95ValueB = Math.abs(Double.parseDouble(distortion2.getCp95Value().toString())); + cp95ValueC = Math.abs(Double.parseDouble(distortion3.getCp95Value().toString())); + limit = Math.abs(Double.parseDouble(distortionLimit)); + } catch (Exception e) { + strResultDistortionValue += "注意:从上表中可以看出" + strLineBaseName + "电压总谐波畸变率(THD)数据存在异常(不是数值类型)。"; + } + // 限值判断 + if (cp95ValueA > limit) { + if (!"".equals(tmpstrResultDistortion)) { + tmpstrResultDistortion += "、"; + } + tmpstrResultDistortion += atype; + // 三张大表取值 + reportmap.put("$TV0R_A$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$TV0R_A$", "合格"); + } + if (cp95ValueB > limit) { + if (!"".equals(tmpstrResultDistortion)) { + tmpstrResultDistortion += "、"; + } + tmpstrResultDistortion += btype; + // 三张大表取值 + reportmap.put("$TV0R_B$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$TV0R_B$", "合格"); + } + if (cp95ValueC > limit && pttype != 2) { + if (!"".equals(tmpstrResultDistortion)) { + tmpstrResultDistortion += "、"; + } + tmpstrResultDistortion += ctype; + // 三张大表取值 + reportmap.put("$TV0R_C$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$TV0R_C$", "合格"); + } + + // 假如为空则所有的都满足 + if ("".equals(tmpstrResultDistortion)) { + strResultDistortion += "电压总谐波畸变率(THD)95%概率值均满足国标限值要求。"; + } else { + strAnalysis += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; + strResultDistortion += "电压总谐波畸变率(THD)95%概率值" + tmpstrResultDistortion + "均不满足国标限值要求。"; + } + reportmap.put("$ResultVoltageRate$", strResultVoltageRate + strResultDistortion); + reportmap.put("$ResultVoltageRateValue$", strResultVoltageRateValue + strResultDistortionValue); + strError += strResultVoltageRateValue + strResultDistortionValue; + + /************************************************************** + **** 谐波电流幅值 + ***************************************************************/ + String strResultCurrent = ""; + String tmpstrResultCurrent = ""; + String strResultCurrentValue = ""; + // 获取25次谐波 + for (int i = 1; i < 25; i++) { + String strMap = "$RI"; + String strCurrent = strMap + (i + 1) + "%"; + + // 基波电压含有率 + 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); + reportmap.put(strCurrent + "_B$", strCurrentB); + reportmap.put(strCurrent + "_C$", strCurrentC); + reportmap.put(strCurrent + "_L$", strLimit); + + /************************************ + **** 三张大表取值 + **************************************/ + 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(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(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); + reportmap.put("$CI" + (i + 1) + "%_C$", strCurrentC); + reportmap.put("$CI" + (i + 1) + "L$", strLimit); + + try { + maxValue = Double.parseDouble(strCurrentA); + minValue = Double.parseDouble(strCurrentB); + aveValue = Double.parseDouble(strCurrentC); + limit = Double.parseDouble(strLimit); + } catch (Exception e) { + strResultCurrentValue += "注意:从上表中可以看出" + strLineBaseName + "谐波电流幅值95%概率值数据存在异常(不是数值类型)。"; + } + + String tmpstrResult = ""; + if (maxValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "A"; + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_A$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_A$", "合格"); + } + if (minValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "B"; + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_B$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_B$", "合格"); + } + if (aveValue > limit) { + if (!"".equals(tmpstrResult)) { + tmpstrResult += "、"; + } + tmpstrResult += "C"; + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_C$", "不合格"); + } else { + // 三张大表取值 + reportmap.put("$CI" + (i + 1) + "R_C$", "合格"); + } + // 判断单个结论是否存在 + if (!"".equals(tmpstrResult)) { + tmpstrResultCurrent += (i + 1) + "次谐波电流幅值95%概率值" + tmpstrResult + ";"; + } + } + + // 假如为空则所有的都满足 + if ("".equals(tmpstrResultCurrent)) { + strResultCurrent += "从上表中可以看出" + strLineBaseName + "2-25次谐波电流幅值95%概率值均满足国标限值要求。"; + } else { + strAnalysis += tmpstrResultCurrent + "均不满足国标限值要求。"; + strResultCurrent += "从上表中可以看出" + strLineBaseName + tmpstrResultCurrent + "均不满足国标限值要求。"; + } + + reportmap.put("$ResultCurrent$", strResultCurrent); + reportmap.put("$ResultCurrentValue$", strResultCurrentValue); + strError += strResultCurrentValue; + + // 测试结果填写 + 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})); + + // 电压偏差 + 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})); + // 电压长时闪变 + reportmap.put("$Result_FIC$", String.format("(4)电压长时闪变:%s", new String[]{strResultFlicker})); + // 谐波电压 + reportmap.put("$Result_VOL$", String.format("(5)谐波电压:%s", new String[]{strResultVoltageRate})); + // 谐波电流 + reportmap.put("$Result_CUR$", String.format("(6)谐波电流:%s", new String[]{strResultCurrent})); + // 分析建议填写 + if (!"".equals(strAnalysis) || !"".equals(strError)) { + // 分析建议 + reportmap.put("$Analysis$", "根据统计数据结果分析,监测点为:" + name + "," + strAnalysis + strError); + } else { + // 分析建议 + reportmap.put("$Analysis$", "根据统计数据结果分析,监测点为:" + name + ",电能质量数据满足国标限值要求。"); + } + + /************************************ + **** 三张大表取值 有功:0-11 无功:12-23 视在:24-31 基波有功汇总:32-35 基波无功汇总:36-39 + * 基波视在汇总:40-43 功率因数:44-46 + **************************************/ + 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())); + + reportmap.put("$NF0X$", judgeNull(powerDto2.getFmaxValue())); + reportmap.put("$NF0N$", judgeNull(powerDto2.getMinValue())); + reportmap.put("$NF0E$", judgeNull(powerDto2.getMeanValue())); + + reportmap.put("$SF0X$", judgeNull(powerDto3.getFmaxValue())); + reportmap.put("$SF0N$", judgeNull(powerDto3.getMinValue())); + reportmap.put("$SF0E$", judgeNull(powerDto3.getMeanValue())); + + reportmap.put("$YF0X$", judgeNull(powerDto4.getFmaxValue())); + reportmap.put("$YF0N$", judgeNull(powerDto4.getMinValue())); + reportmap.put("$YF0E$", judgeNull(powerDto4.getMeanValue())); + // 报告时分秒格式 + formatter = new SimpleDateFormat("yyyyMMddHHmmss"); + + String reportFileUrl = ""; + try { + String fileName = name + formatter.format(currentTime) + ".docx"; + if(ObjectUtil.isNotNull(isUrl)){ + if (isUrl) { + reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",null ,reportmap); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe); + } + } + wordUtil2.getWord(rtfPath, reportmap, fileName,null, response); + } catch (Exception e) { + log.error("获取报告发生异常,异常是" + e.getMessage()); + } + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe); + } + + /** + * 数据单位信息 重组 + * + * @param deviceUnit 数据单位对象 + * @return + */ + private Map unitMap(PqsDeviceUnit deviceUnit) { + List dictData = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEVICE_UNIT.getCode()).getData(); + Map unit = new HashMap<>(16); + 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.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.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.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()); + + } + } + return unit; + } + + + /** + * 解析base64,返回图片所在路径 + */ + @SuppressWarnings("restriction") + private String decodeBase64(byte[] base64Info) { + if (base64Info.length == 0) { + return null; + } + BASE64Encoder decoder = new BASE64Encoder(); + + return decoder.encode(base64Info); + } + + private void transformData(List list, List listValue, List listOverlimit, boolean... b) { + int offset = b[0] ? 3 : 1; + offset = (b.length == 2 && !b[1]) ? 4 : offset; + int i = 0; + + for (int index = 0; index < listValue.size(); index += offset) { + if (i == listOverlimit.size()) { + break; + } + ReportTarget reportTarget = new ReportTarget(); + reportTarget.setList(listValue.subList(index, index + offset)); + Float overLimit = listOverlimit.get(i).getOverLimit(); + reportTarget.setOverLimit(overLimit); + + switch (listOverlimit.get(i).getCode()) { + case 1: + for (int k = 0; k < reportTarget.getList().size(); k++) { + if (null == reportTarget.getList().get(k).getFmaxValue()) { + break; + } else if (reportTarget.getList().get(k).getFmaxValue().floatValue() > overLimit.floatValue()) { + reportTarget.setPass(EnumPass.NOPASS.getCode()); + break; + } else { + reportTarget.setPass(EnumPass.PASS.getCode()); + } + } + break; + case 2: + for (int k = 0; k < reportTarget.getList().size(); k++) { + if (null == reportTarget.getList().get(k).getMinValue()) { + break; + } else if (reportTarget.getList().get(k).getMinValue().floatValue() > overLimit.floatValue()) { + reportTarget.setPass(EnumPass.NOPASS.getCode()); + break; + } else { + reportTarget.setPass(EnumPass.PASS.getCode()); + } + } + break; + case 3: + for (int k = 0; k < reportTarget.getList().size(); k++) { + if (null == reportTarget.getList().get(k).getMeanValue()) { + break; + } else if (reportTarget.getList().get(k).getMeanValue().floatValue() > overLimit.floatValue()) { + reportTarget.setPass(EnumPass.NOPASS.getCode()); + break; + } else { + reportTarget.setPass(EnumPass.PASS.getCode()); + } + } + break; + case 4: + for (int k = 0; k < reportTarget.getList().size(); k++) { + if (null == reportTarget.getList().get(k).getCp95Value()) { + break; + } else if (reportTarget.getList().get(k).getCp95Value().floatValue() > overLimit.floatValue()) { + reportTarget.setPass(EnumPass.NOPASS.getCode()); + break; + } else { + reportTarget.setPass(EnumPass.PASS.getCode()); + } + } + break; + default: + break; + } + + i++; + list.add(reportTarget); + } + } + + /** + * 基波幅值 + */ + public void getVirtualData(ReportQueryParam param) { + + List listVirtual = reportService.getVirtualData(param); + + List list = new ArrayList<>(); + + for (int i = 0; i < 3; i++) { + Pass pass = new Pass(null); + list.add(pass); + } + + this.listVirtual = new ArrayList<>(); + + transformData(this.listVirtual, listVirtual, list, true); + + + } + + /** + * 功率 + */ + public void getPowerData(ReportQueryParam param) { + List listPower = reportService.getPowerData(param); + + List list = new ArrayList<>(); + + for (int i = 0; i < 4; i++) { + Pass pass = new Pass(null); + list.add(pass); + } + this.listPower = new ArrayList<>(); + transformData(this.listPower, listPower, list, true, false); + } + + /** + * 闪变 + */ + public void getFlicker(ReportQueryParam param, Overlimit overLimit) { + List listFlicker = reportService.getFlickerData(param); + List list = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + Pass pass; + if (i == 1) { + pass = new Pass(overLimit.getFlicker(), EnumPass.MAX.getCode()); + } else { + pass = new Pass(null); + } + list.add(pass); + } + this.listFlicker = new ArrayList<>(); + transformData(this.listFlicker, listFlicker, list, true); + } + + /** + * 电压偏差 + */ + public void getVdeviation(ReportQueryParam param, Overlimit overLimit) { + List listVdeviation = reportService.getVdeviation(param); + List list = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + Pass pass; + pass = new Pass(overLimit.getVoltageDev(), EnumPass.MAX.getCode()); + list.add(pass); + } + this.listVdeviation = new ArrayList<>(); + transformData(this.listVdeviation, listVdeviation, list, true); + } + + /** + * 畸变率 + */ + public void getDistortion(ReportQueryParam param, Overlimit overLimit) { + List listDistortion = reportService.getDistortionData(param); + List list = new ArrayList<>(); + for (int i = 0; i < 2; i++) { + Pass pass; + + if (i == 0) { + pass = new Pass(overLimit.getUaberrance(), EnumPass.MAX.getCode()); + } else { + pass = new Pass(null); + } + + list.add(pass); + } + this.listDistortion = new ArrayList<>(); + transformData(this.listDistortion, listDistortion, list, true); + } + + /** + * 频率 + */ + public void getFre(ReportQueryParam param, Overlimit overLimit) { + List listFrequency = reportService.getFrequencyData(param); + + List list = new ArrayList<>(); + + for (int i = 0; i < 2; i++) { + Pass pass; + if (i == 1) { + pass = new Pass(overLimit.getFreqDev(), EnumPass.MAX.getCode()); + } else { + pass = new Pass(null); + } + list.add(pass); + } + + this.listFrequency = new ArrayList<>(); + transformData(this.listFrequency, listFrequency, list, false); + } + + + /** + * 三相不平衡 + */ + public void getThreePhase(ReportQueryParam param, Overlimit overLimit) { + List listThreephase = reportService.getThreephase(param); + + List list = new ArrayList<>(); + + for (int i = 0; i < 8; i++) { + Pass pass; + + if (i == 0) { + pass = new Pass(overLimit.getUbalance(), EnumPass.CP95.getCode()); + } else { + pass = new Pass(null); + } + + list.add(pass); + } + + this.listThreephase = new ArrayList<>(); + transformData(this.listThreephase, listThreephase, list, false); + } + + + /** + * 谐波电流 + */ + public void getCurrentRate(ReportQueryParam param, Overlimit overLimit) { + List listICurrent = reportService.getICurrent(param); + + List list = new ArrayList<>(); + List iHarmList = getIHarmList(overLimit); + for (int i = 0; i < 50; i++) { + Pass pass; + if (i < iHarmList.size() + 1 && i > 0) { + pass = new Pass(iHarmList.get(i - 1), + EnumPass.CP95.getCode()); + } else { + pass = new Pass(null); + } + list.add(pass); + } + + this.listICurrent = new ArrayList<>(); + transformData(this.listICurrent, listICurrent, list, true); + } + + /** + * 谐波电压 + */ + public void getVoltageRate(ReportQueryParam param, Overlimit overLimit) { + List listVoltageRate = reportService.getVoltageRate(param); + + List list = new ArrayList<>(); + List vHarmList = getVHarmList(overLimit); + for (int i = 0; i < 51; i++) { + Pass pass; + + if (i == 0) { + pass = new Pass(null); + } else if (i == 50) { + pass = new Pass(overLimit.getUaberrance(), EnumPass.MAX.getCode()); + } else if (i < vHarmList.size() + 1) { + pass = new Pass(vHarmList.get(i - 1), + EnumPass.CP95.getCode()); + } else { + pass = new Pass(null); + } + + list.add(pass); + } + + this.listVoltageRate = new ArrayList<>(); + transformData(this.listVoltageRate, listVoltageRate, list, true); + } + + public String judgeNull(Float result) { + return (result == null) ? "/" : result.toString(); + } + + /** + * 谐波电流限值 + * + * @param overLimit + * @return + */ + public List getIHarmList(Overlimit overLimit) { + List list = new ArrayList<>(); + list.add(overLimit.getIharm2()); + list.add(overLimit.getIharm3()); + list.add(overLimit.getIharm4()); + list.add(overLimit.getIharm5()); + list.add(overLimit.getIharm6()); + list.add(overLimit.getIharm7()); + list.add(overLimit.getIharm8()); + list.add(overLimit.getIharm9()); + list.add(overLimit.getIharm10()); + list.add(overLimit.getIharm11()); + list.add(overLimit.getIharm12()); + list.add(overLimit.getIharm13()); + list.add(overLimit.getIharm14()); + list.add(overLimit.getIharm15()); + list.add(overLimit.getIharm16()); + list.add(overLimit.getIharm17()); + list.add(overLimit.getIharm18()); + list.add(overLimit.getIharm19()); + list.add(overLimit.getIharm20()); + list.add(overLimit.getIharm21()); + list.add(overLimit.getIharm22()); + list.add(overLimit.getIharm23()); + list.add(overLimit.getIharm24()); + list.add(overLimit.getIharm25()); + return list; + } + + /** + * 谐波电压限值 + * + * @return + */ + public List getVHarmList(Overlimit overLimit) { + List list = new ArrayList<>(); + list.add(overLimit.getUharm2()); + list.add(overLimit.getUharm3()); + list.add(overLimit.getUharm4()); + list.add(overLimit.getUharm5()); + list.add(overLimit.getUharm6()); + list.add(overLimit.getUharm7()); + list.add(overLimit.getUharm8()); + list.add(overLimit.getUharm9()); + list.add(overLimit.getUharm10()); + list.add(overLimit.getUharm11()); + list.add(overLimit.getUharm12()); + list.add(overLimit.getUharm13()); + list.add(overLimit.getUharm14()); + list.add(overLimit.getUharm15()); + list.add(overLimit.getUharm16()); + list.add(overLimit.getUharm17()); + list.add(overLimit.getUharm18()); + list.add(overLimit.getUharm19()); + list.add(overLimit.getUharm20()); + list.add(overLimit.getUharm21()); + list.add(overLimit.getUharm22()); + list.add(overLimit.getUharm23()); + list.add(overLimit.getUharm24()); + list.add(overLimit.getUharm25()); + return list; + } +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ReportMapper.xml b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ReportMapper.xml new file mode 100644 index 0000000..02a8d9c --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/mapping/ReportMapper.xml @@ -0,0 +1,959 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java new file mode 100644 index 0000000..9535258 --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataIDMapper.java @@ -0,0 +1,29 @@ +package com.njcn.csharmonic.mapper.report; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.harmonic.pojo.po.day.RStatDataIDPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author wr + * @since 2023-04-17 + */ +public interface RStatDataIDMapper extends BaseMapper { + + /** + * 获取监测点负序电流 + * @return + */ + List getINeg(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 谐波电流 + */ + List getI(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java new file mode 100644 index 0000000..514effb --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataInharmVDMapper.java @@ -0,0 +1,17 @@ +package com.njcn.csharmonic.mapper.report; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Description: + * @Author: wr + * @Date: 2024/7/31 9:24 + */ +public interface RStatDataInharmVDMapper extends BaseMapper { + + List getV(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDMapper.java new file mode 100644 index 0000000..674ae7b --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/RStatDataVDMapper.java @@ -0,0 +1,43 @@ +package com.njcn.csharmonic.mapper.report; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.harmonic.pojo.po.RStatDataVD; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + *

+ * Mapper 接口 + *

+ * + * @author wr + * @since 2023-03-31 + */ +public interface RStatDataVDMapper extends BaseMapper { + + /** + * 获取频率偏差、三相电压不平衡度 + */ + List getFreqDev(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 获取电压偏差 + */ + List getVuDev(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 获取电压总谐波畸变率 + */ + List getVthd(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 获取三相电压不平衡度 + */ + List getUnbalance(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); + + /** + * 获取谐波电压 + */ + List getV(@Param("list") List lineList, @Param("startTime") String startTime, @Param("endTime") String endTime); +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java new file mode 100644 index 0000000..0cc9bdf --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/mapper/report/ReportMapper.java @@ -0,0 +1,137 @@ +package com.njcn.csharmonic.mapper.report; + +import com.njcn.harmonic.pojo.param.ReportQueryParam; +import com.njcn.harmonic.pojo.vo.ReportValue; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 谐波报告查询 + */ +public interface ReportMapper { + /** + * 获取电流有效值 + * @return + */ + List getVirtualDataI(@Param("param") ReportQueryParam param); + + /** + * 获取电压有效值 + * @return + */ + List getVirtualDataV(@Param("param") ReportQueryParam param); + + /** + * CP95条数 + * @param param + * @return + */ + Integer getTotalCP95Day(@Param("param")ReportQueryParam param); + /** + * CP95条数 + * @param param + * @return + */ + Integer getTotalPltCP95Day(@Param("param")ReportQueryParam param); + /** + * CP95条数 + * @param param + * @return + */ + Integer getTotalPstCP95Day(@Param("param")ReportQueryParam param); + + + List getVVirtualData(@Param("param")ReportQueryParam param); + + /** + * 获取有功功率 + * @param param + * @return + */ + List getPowerP(@Param("param")ReportQueryParam param); + + /** + * 无功功率 + * @param param + * @return + */ + List getPowerQ(@Param("param")ReportQueryParam param); + + /** + * 视在功率 + * @param param + * @return + */ + List getPowerS(@Param("param")ReportQueryParam param); + + /** + * 功率因数 + * @param param + * @return + */ + List getPF(@Param("param")ReportQueryParam param); + + /** + * 短时闪变 + * @param param + * @return + */ + List getFlickerData(@Param("param")ReportQueryParam param); + + /** + * 长时闪变 + * @param param + * @return + */ + List getLFlickerData(@Param("param")ReportQueryParam param); + + /** + * 电压负偏差 + * @param param + * @return + */ + List getUVdeviationData(@Param("param")ReportQueryParam param); + + /** + * 电压正偏差 + * @param param + * @return + */ + List getLVdeviationData(@Param("param")ReportQueryParam param); + + /** + * 获取电压畸变率 + * @param param + * @return + */ + List getDistortionDataV(@Param("param")ReportQueryParam param); + + /** + * 获取电流畸变率 + * @param param + * @return + */ + List getDistortionDataI(@Param("param")ReportQueryParam param); + + /** + *频率 + * @param param + * @return + */ + List getFrequencyData(@Param("param")ReportQueryParam param); + + /** + *频率 + * @param param + * @return + */ + List getDEVFrequencyData(@Param("param")ReportQueryParam param); + + /** + * 负序电流 + * @param param + * @return + */ + List getINegData(@Param("param")ReportQueryParam param); +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/ReportService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/ReportService.java new file mode 100644 index 0000000..0336ead --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/ReportService.java @@ -0,0 +1,97 @@ +package com.njcn.csharmonic.service; + +import com.njcn.harmonic.pojo.param.ReportQueryParam; +import com.njcn.harmonic.pojo.po.report.OverLimitInfo; +import com.njcn.harmonic.pojo.vo.ReportValue; + +import java.util.List; + +/** + * 谐波报告 + */ +public interface ReportService { + + /** + * 限值 + * @param param + * @return + */ + OverLimitInfo getOverLimitData(ReportQueryParam param); + + /** + * 基波增幅 + * @param param + * @return + */ + List getVirtualData(ReportQueryParam param); + + /** + * 功率 + * @param param + * @return + */ + List getPowerData(ReportQueryParam param); + + /** + * 闪变 + * @param param + * @return + */ + List getFlickerData(ReportQueryParam param); + + /** + * 电压偏差 + * @param param + * @return + */ + List getVdeviation(ReportQueryParam param); + + /** + * 畸变率 + * @param param + * @return + */ + List getDistortionData(ReportQueryParam param); + + /** + * 频率 + * @param param + * @return + */ + List getFrequencyData(ReportQueryParam param); + + /** + * 三相不平衡 + * @param param + * @return + */ + List getThreephase(ReportQueryParam param); + + /** + * 谐波电流 + * @param param + * @return + */ + List getICurrent(ReportQueryParam param); + + /** + * 谐波电压 + * @param param + * @return + */ + List getVoltageRate(ReportQueryParam param); + + /** + * 间谐波 + * @param param + * @return + */ + List getInharmVeRate(ReportQueryParam param); + + /** + * 负序电流 + * @param param + * @return + */ + List getINegDataRate(ReportQueryParam param); +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java new file mode 100644 index 0000000..965cc95 --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/ReportServiceImpl.java @@ -0,0 +1,595 @@ +package com.njcn.csharmonic.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.njcn.csharmonic.mapper.report.RStatDataIDMapper; +import com.njcn.csharmonic.mapper.report.RStatDataInharmVDMapper; +import com.njcn.csharmonic.mapper.report.RStatDataVDMapper; +import com.njcn.csharmonic.mapper.report.ReportMapper; +import com.njcn.csharmonic.service.ReportService; +import com.njcn.csharmonic.util.RegroupData; +import com.njcn.harmonic.pojo.param.ReportQueryParam; +import com.njcn.harmonic.pojo.po.RStatDataVD; +import com.njcn.harmonic.pojo.po.day.RStatDataIDPO; +import com.njcn.harmonic.pojo.po.day.RStatDataInharmVDPO; +import com.njcn.harmonic.pojo.po.report.OverLimitInfo; +import com.njcn.harmonic.pojo.vo.ReportValue; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author wr + */ +@Service +@RequiredArgsConstructor +@DS("sjzx") +public class ReportServiceImpl implements ReportService { + + private final ReportMapper reportMapper; + private final RStatDataVDMapper rStatDataVDMapper; + private final RStatDataIDMapper rStatDataIDMapper; + private final RStatDataInharmVDMapper rStatDataInharmVDMapper; + + @Override + public OverLimitInfo getOverLimitData(ReportQueryParam param) { + + + OverLimitInfo overLimitInfo = new OverLimitInfo(); + + //查询时间段内共有多少条记录,并*0.95取整处理,用来计算CP95值 降序*0.05进一位计算 + double count = 0; + double pstCount = 0; + double pltCount = 0; + if (param.getB()) { + count = Math.ceil(1); + pltCount = Math.ceil(1); + pstCount = Math.ceil(1); + } else { + count = Math.ceil(reportMapper.getTotalCP95Day(param).intValue() * 0.05); + pltCount = Math.ceil(reportMapper.getTotalPltCP95Day(param).intValue() * 0.05); + pstCount = Math.ceil(reportMapper.getTotalPstCP95Day(param).intValue() * 0.05); + } + overLimitInfo.setCount(count); + overLimitInfo.setPltCount(pltCount); + overLimitInfo.setPstCount(pstCount); + return overLimitInfo; + } + + @Override + public List getVirtualData(ReportQueryParam param) { + List list = new ArrayList<>(); + + // 获取电流有效值 + List listI = reportMapper.getVirtualDataI(param); + //获取电压有效值 + List listV = reportMapper.getVirtualDataV(param); + //获取线电压有效值 + List listVV = reportMapper.getVVirtualData(param); + + RegroupData.regroupData(listV, true); + RegroupData.regroupData(listI, true); + RegroupData.regroupData(listVV, true); + list.addAll(listV); + list.addAll(listI); + list.addAll(listVV); + + return list; + } + + @Override + public List getPowerData(ReportQueryParam param) { + List list = new ArrayList<>(); + //获取有功功率 + List listP = reportMapper.getPowerP(param); + //获取无功功率 + List listQ = reportMapper.getPowerQ(param); + //获取视在功率 + List listS = reportMapper.getPowerS(param); + //获取功率因数 + List listF = reportMapper.getPF(param); + + RegroupData.regroupData(listP, true, false); + RegroupData.regroupData(listQ, true, false); + RegroupData.regroupData(listS, true, false); + RegroupData.regroupData(listF, true, false); + list.addAll(listP); + list.addAll(listQ); + list.addAll(listS); + list.addAll(listF); + return list; + } + + @Override + public List getFlickerData(ReportQueryParam param) { + List list = new ArrayList<>(); + + //短时闪变 + List listFlicker = reportMapper.getFlickerData(param); + //长时闪变 + List listLFlicker = reportMapper.getLFlickerData(param); + + RegroupData.regroupData(listFlicker, true); + RegroupData.regroupData(listLFlicker, true); + list.addAll(listFlicker); + list.addAll(listLFlicker); + + return list; + } + + @Override + public List getVdeviation(ReportQueryParam param) { + List list = new ArrayList<>(); + + //获取电压偏差 + List listU = reportMapper.getUVdeviationData(param); + List listL = reportMapper.getLVdeviationData(param); + + RegroupData.regroupData(listU, true); + RegroupData.regroupData(listL, true); + list.addAll(listU); + list.addAll(listL); + return list; + } + + @Override + public List getDistortionData(ReportQueryParam param) { + List list = new ArrayList<>(); + //获取电压畸变率 + List listU = reportMapper.getDistortionDataV(param); + //获取电流畸变率 + List listI = reportMapper.getDistortionDataI(param); + + //添加之前判断数据库是否有数据,如果没有数据模拟数据添加到集合中 + RegroupData.regroupData(listU, true); + RegroupData.regroupData(listI, true); + list.addAll(listU); + list.addAll(listI); + + return list; + } + + @Override + public List getFrequencyData(ReportQueryParam param) { + List list = new ArrayList<>(); + + List listFre = reportMapper.getFrequencyData(param); + List listFreDEV = reportMapper.getDEVFrequencyData(param); + + + RegroupData.regroupData(listFre, true); + RegroupData.regroupData(listFreDEV, true); + list.addAll(listFre); + list.addAll(listFreDEV); + return list; + } + + @Override + public List getThreephase(ReportQueryParam param) { + List list = new ArrayList<>(); + //电压三相不平衡度 + List listV = dataV(param, Arrays.asList("T"), 1, 5, true, 0); + //电流三相不平衡度 + List listI = dataI(param, Arrays.asList("T"), 1, 5, true, 0); + + if (CollUtil.isNotEmpty(listV)) { + list.addAll(listV); + } else { + regroupData(list); + } + + if (CollUtil.isNotEmpty(listI)) { + list.addAll(listI); + } else { + regroupData(list); + } + return list; + } + + @Override + public List getICurrent(ReportQueryParam param) { + List list = new ArrayList<>(); + + //获取电流幅值,包含基波 + List listI = dataI(param, Arrays.asList("A", "B", "C"), 1, 51, false, 0); + if (CollUtil.isEmpty(listI)) { + for (int i = 0; i < 50; i++) { + RegroupData.regroupData(list, true, true); + } + } else { + list.addAll(listI); + } + return list; + } + + @Override + public List getVoltageRate(ReportQueryParam param) { + List list = new ArrayList<>(); + + //获取基波电压幅值,单位kV + List listV = dataV(param, Arrays.asList("A", "B", "C"), 0, 1, true, 5); + + if (CollUtil.isEmpty(listV)) { + RegroupData.regroupData(list, true, true); + } else { + list.addAll(listV); + } + + //获取电压含有率,不包含基波 + List listRate = dataV(param, Arrays.asList("A", "B", "C"), 2, 51, false, 1); + + if (CollUtil.isEmpty(listRate)) { + for (int i = 0; i < 49; i++) { + RegroupData.regroupData(list, true, true); + } + } else { + list.addAll(listRate); + } + + //获取电压畸变率 + List listU = reportMapper.getDistortionDataV(param); + RegroupData.regroupData(listU, true); + list.addAll(listU); + return list; + } + + @Override + public List getInharmVeRate(ReportQueryParam param) { + List inharm = rStatDataInharmVDMapper.selectList(new LambdaQueryWrapper() + .eq(RStatDataInharmVDPO::getLineId, param.getLineId()) + .in(RStatDataInharmVDPO::getPhaseType, Arrays.asList("A", "B", "C")) + .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataInharmVDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataInharmVDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + ); + String max = "MAX"; + String avg = "AVG"; + String min = "MIN"; + String cp95 = "CP95"; + List a = new ArrayList<>(); + Map> collect = inharm.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getPhaseType)); + collect.forEach((key, value) -> { + Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataInharmVDPO::getValueType)); + + for (int i = 1; i < 17; i++) { + ReportValue reportValue = new ReportValue(); + String attribute = "v" + i; + + if (valueTypeMap.containsKey(max)) { + List aa = reflectDataInV(valueTypeMap.get(max), max, attribute); + reportValue.setPhaseType(key); + Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); + reportValue.setFmaxValue(maxNum); + } + if (valueTypeMap.containsKey(avg)) { + List aa = reflectDataInV(valueTypeMap.get(avg), avg, attribute); + reportValue.setPhaseType(key); + Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); + reportValue.setMeanValue(avgNum.floatValue()); + } + if (valueTypeMap.containsKey(min)) { + List aa = reflectDataInV(valueTypeMap.get(min), min, attribute); + reportValue.setPhaseType(key); + double minNum = aa.stream().distinct().min(Float::compareTo).get(); + reportValue.setMinValue((float) minNum); + } + if (valueTypeMap.containsKey(cp95)) { + List aa = reflectDataInV(valueTypeMap.get(cp95), cp95, attribute); + reportValue.setPhaseType(key); + List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); + reportValue.setCp95Value(cp95Num.get(0).floatValue()); + } + a.add(reportValue); + } + }); + if (CollUtil.isEmpty(a)) { + for (int i = 1; i < 17; i++) { + RegroupData.regroupData(a, true, true); + } + } + return a; + } + + @Override + public List getINegDataRate(ReportQueryParam param) { + List list = new ArrayList<>(); + //负序电流 + List iNegData = reportMapper.getINegData(param); + RegroupData.regroupData(iNegData, true); + list.addAll(iNegData); + return list; + } + + //赋值默认值 + private void regroupData(List list) { + for (int i = 0; i < 4; i++) { + List list1 = new ArrayList<>(); + RegroupData.regroupData(list1, false); + list.addAll(list1); + } + } + + /** + * 电压信息 + * + * @param param 查询条件 + * @param valueTypes 区分类别 例如"A","B","C" + * @param num 循环开始 + * @param size 循环结束 + * @param fly 否是启用获取属性电压 + * @param index 获取属性位置名称 + * @return + */ + private List dataV(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { + List rStatDataVDS = rStatDataVDMapper.selectList(new LambdaQueryWrapper() + .eq(RStatDataVD::getLineId, param.getLineId()) + .in(CollUtil.isNotEmpty(valueTypes), RStatDataVD::getPhasicType, valueTypes) + .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataVD::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataVD::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + ); + String max = "MAX"; + String avg = "AVG"; + String min = "MIN"; + String cp95 = "CP95"; + List a = new ArrayList<>(); + Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataVD::getPhasicType)); + collect.forEach((key, value) -> { + Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataVD::getValueType)); + + for (int i = num; i < size; i++) { + ReportValue reportValue = new ReportValue(); + String attribute = ""; + if (fly) { + if (index == 0) { + attribute = attributeV(i); + } else { + attribute = attributeV(index); + } + } else { + attribute = "v" + i; + } + + if (valueTypeMap.containsKey(max)) { + List aa = reflectDataV(valueTypeMap.get(max), max, attribute); + reportValue.setPhaseType(key); + Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); + reportValue.setFmaxValue(maxNum); + } + if (valueTypeMap.containsKey(avg)) { + List aa = reflectDataV(valueTypeMap.get(avg), avg, attribute); + reportValue.setPhaseType(key); + Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); + reportValue.setMeanValue(avgNum.floatValue()); + } + if (valueTypeMap.containsKey(min)) { + List aa = reflectDataV(valueTypeMap.get(min), min, attribute); + reportValue.setPhaseType(key); + double minNum = aa.stream().distinct().min(Float::compareTo).get(); + reportValue.setMinValue((float) minNum); + } + if (valueTypeMap.containsKey(cp95)) { + List aa = reflectDataV(valueTypeMap.get(cp95), cp95, attribute); + reportValue.setPhaseType(key); + List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); + reportValue.setCp95Value(cp95Num.get(0).floatValue()); + } + a.add(reportValue); + } + }); + return a; + } + + /** + * 电压反射取属性值 + * + * @param value + * @param name + * @return + */ + private List reflectDataV(List value, String name, String attribute) { + Field field = null; + try { + field = RStatDataVD.class.getDeclaredField(attribute); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + field.setAccessible(true); + + Field finalField = field; + return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { + BigDecimal o = null; + try { + o = (BigDecimal) finalField.get(temp); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + + return o.floatValue(); + }).collect(Collectors.toList()); + } + + /** + * 电压反射取属性值 + * + * @param value + * @param name + * @return + */ + private List reflectDataInV(List value, String name, String attribute) { + Field field; + try { + field = RStatDataInharmVDPO.class.getDeclaredField(attribute); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + field.setAccessible(true); + + Field finalField = field; + return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { + Double o; + try { + o = (Double) finalField.get(temp); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + + return o.floatValue(); + }).collect(Collectors.toList()); + } + + /** + * 电流信息 + * + * @param param + * @return + */ + private List dataI(ReportQueryParam param, List valueTypes, Integer num, Integer size, Boolean fly, Integer index) { + List rStatDataVDS = rStatDataIDMapper.selectList(new LambdaQueryWrapper() + .eq(RStatDataIDPO::getLineId, param.getLineId()) + .in(CollUtil.isNotEmpty(valueTypes), RStatDataIDPO::getPhaseType, valueTypes) + .ge(StrUtil.isNotBlank(param.getStartTime()), RStatDataIDPO::getTime, DateUtil.beginOfDay(DateUtil.parse(param.getStartTime()))) + .le(StrUtil.isNotBlank(param.getEndTime()), RStatDataIDPO::getTime, DateUtil.endOfDay(DateUtil.parse(param.getEndTime()))) + ); + String max = "MAX"; + String avg = "AVG"; + String min = "MIN"; + String cp95 = "CP95"; + List a = new ArrayList<>(); + Map> collect = rStatDataVDS.stream().collect(Collectors.groupingBy(RStatDataIDPO::getPhaseType)); + collect.forEach((key, value) -> { + Map> valueTypeMap = value.stream().collect(Collectors.groupingBy(RStatDataIDPO::getValueType)); + + for (int i = num; i < size; i++) { + ReportValue reportValue = new ReportValue(); + String attribute = ""; + if (fly) { + if (index == 0) { + attribute = attributeI(i); + } else { + attribute = attributeI(index); + } + } else { + attribute = "i" + i; + } + if (valueTypeMap.containsKey(max)) { + List aa = reflectDataI(valueTypeMap.get(max), max, attribute); + reportValue.setPhaseType(key); + Float maxNum = aa.stream().distinct().max(Float::compareTo).get(); + reportValue.setFmaxValue(maxNum); + } + if (valueTypeMap.containsKey(avg)) { + List aa = reflectDataI(valueTypeMap.get(avg), avg, attribute); + reportValue.setPhaseType(key); + Double avgNum = aa.stream().distinct().collect(Collectors.averagingDouble(Float::doubleValue)); + reportValue.setMeanValue(avgNum.floatValue()); + } + if (valueTypeMap.containsKey(min)) { + List aa = reflectDataI(valueTypeMap.get(min), min, attribute); + reportValue.setPhaseType(key); + double minNum = aa.stream().distinct().min(Float::compareTo).get(); + reportValue.setMinValue((float) minNum); + } + if (valueTypeMap.containsKey(cp95)) { + List aa = reflectDataI(valueTypeMap.get(cp95), cp95, attribute); + reportValue.setPhaseType(key); + List cp95Num = aa.stream().distinct().sorted(Comparator.comparing(Float::doubleValue).reversed()).collect(Collectors.toList()); + reportValue.setCp95Value(cp95Num.get(0).floatValue()); + } + a.add(reportValue); + } + }); + return a; + } + + /** + * 电流反射取属性值 + * + * @param value + * @param name + * @return + */ + private List reflectDataI(List value, String name, String attribute) { + Field field = null; + try { + field = RStatDataIDPO.class.getDeclaredField(attribute); + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + field.setAccessible(true); + Field finalField = field; + return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { + Double o = null; + try { + o = (Double) finalField.get(temp); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + + return o.floatValue(); + }).collect(Collectors.toList()); + } + + /** + * 获取属性电压 + * + * @param i + * @return + */ + private String attributeV(Integer i) { + String str = null; + switch (i) { + case 1: + str = "vUnbalance"; + break; + case 2: + str = "vPos"; + break; + case 3: + str = "vNeg"; + break; + case 4: + str = "vZero"; + break; + case 5: + str = "v1"; + break; + default: + break; + } + return str; + } + + /** + * 获取属性电流 + * + * @param i + * @return + */ + private String attributeI(Integer i) { + String str = null; + switch (i) { + case 1: + str = "iUnbalance"; + break; + case 2: + str = "iPos"; + break; + case 3: + str = "iNeg"; + break; + case 4: + str = "iZero"; + break; + default: + break; + } + return str; + } +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java new file mode 100644 index 0000000..07d2dfd --- /dev/null +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/util/RegroupData.java @@ -0,0 +1,44 @@ +package com.njcn.csharmonic.util; + +import com.njcn.harmonic.pojo.vo.ReportValue; + +import java.util.List; + +public class RegroupData { + public static void regroupData(List list, boolean... b) { + if (1 == b.length || (2 == b.length && b[1] == false)) { + if (0 < list.size()) { + return; + } + } + + Float value = null; + int length = b[0] ? 3 : 1; + + length = (b.length == 2 && !b[1]) ? 4 : length; + + for (int i = 0; i < length; i++) { + String str = null; + + if (b[0]) { + switch (i) { + case 0: + str = "A"; + break; + case 1: + str = "B"; + break; + case 2: + str = "C"; + break; + case 3: + str = "T"; + break; + } + } + + ReportValue reportValue = new ReportValue(str, value, value, value, value); + list.add(reportValue); + } + } +} diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/default.jpg b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/default.jpg new file mode 100644 index 0000000..0cb20c9 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/default.jpg differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/jxt.jpg b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/jxt.jpg new file mode 100644 index 0000000..d15f954 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/jxt.jpg differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModel.docx b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModel.docx new file mode 100644 index 0000000..f9aed02 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModel.docx differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelCN.docx b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelCN.docx new file mode 100644 index 0000000..a20ffee Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelCN.docx differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelGW.docx b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelGW.docx new file mode 100644 index 0000000..f31cc43 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelGW.docx differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelJB.docx b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelJB.docx new file mode 100644 index 0000000..b0de482 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelJB.docx differ diff --git a/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelNW.docx b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelNW.docx new file mode 100644 index 0000000..be0d0e2 Binary files /dev/null and b/cs-harmonic/cs-harmonic-boot/src/main/resources/file/reportModelNW.docx differ