有功功率趋势
This commit is contained in:
@@ -67,4 +67,6 @@ public interface Param {
|
||||
*/
|
||||
String VALUE_TYPEAVG = "AVG";
|
||||
|
||||
//DecimalFormat格式化
|
||||
String DECIMAL_FORMATSTR = "#0.0000";
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public enum HarmonicResponseEnum {
|
||||
REPORT_TEMPLATE_DOWNLOAD_ERROR("A00560","报表模板下载异常"),
|
||||
NO_DATA("A00561","时间范围内暂无谐波数据"),
|
||||
INSUFFICIENCY_OF_INTEGRITY("A00561","时间范围内谐波数据完整性不足"),
|
||||
NO_LINE_DATA("A00562","监测点无有功功率数据"),
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.harmonic.pojo.param;
|
||||
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 有功功率趋势统计 查询实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class PowerStatisticsParam extends BaseParam {
|
||||
|
||||
@ApiModelProperty(name = "lineId", value = "监测点ID")
|
||||
@NotBlank(message = "监测点ID不能为空")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(name = "statisticalId", value = "指标分类ID(用于查询指标详细数据的指标分类ID)")
|
||||
private String statisticalId;
|
||||
|
||||
@ApiModelProperty(name = "field", value = "区间字段(用于查询指标越限列表)")
|
||||
private String field;
|
||||
|
||||
@ApiModelProperty(name = "ids", value = "ids")
|
||||
private List<String> ids;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.harmonic.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 有功功率趋势指标 实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-20
|
||||
*/
|
||||
@Data
|
||||
public class PowerStatisticsTargetVO {
|
||||
|
||||
@ApiModelProperty("时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private String time;
|
||||
|
||||
@ApiModelProperty("电压偏差")
|
||||
private Integer voltageOffset;
|
||||
|
||||
@ApiModelProperty(value = "谐波电压")
|
||||
private Integer vTimes;
|
||||
|
||||
@ApiModelProperty(value = "谐波电流")
|
||||
private Integer iTimes;
|
||||
|
||||
@ApiModelProperty("三相电压不平衡度")
|
||||
private Integer ubalance;
|
||||
|
||||
@ApiModelProperty(value="电压波动")
|
||||
private Integer voltageFluctuation;
|
||||
|
||||
@ApiModelProperty("闪变")
|
||||
private Integer flicker;
|
||||
|
||||
@ApiModelProperty("间谐波电压含有率")
|
||||
private Integer interHarmonic;
|
||||
|
||||
@ApiModelProperty("电流不平衡度")
|
||||
private Integer sequenceCurrentUnbalance;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.njcn.harmonic.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* 有功功率趋势 实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-20
|
||||
*/
|
||||
@Data
|
||||
public class PowerStatisticsVO {
|
||||
|
||||
@ApiModelProperty("ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("监测点ID")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty("日期(天)")
|
||||
private LocalDate timeId;
|
||||
|
||||
@ApiModelProperty("0%~10%区间时间Json")
|
||||
private String minsTime0;
|
||||
|
||||
@ApiModelProperty("0%~10%区间个数")
|
||||
private Integer minsNum0;
|
||||
|
||||
@ApiModelProperty("0%~10%区间是否越限")
|
||||
private Integer isOrNot0;
|
||||
|
||||
@ApiModelProperty("10%~20%区间时间Json")
|
||||
private String minsTime1;
|
||||
|
||||
@ApiModelProperty("10%~20%区间个数")
|
||||
private Integer minsNum1;
|
||||
|
||||
@ApiModelProperty("10%~20%区间是否越限")
|
||||
private Integer isOrNot1;
|
||||
|
||||
@ApiModelProperty("20%~30%区间时间Json")
|
||||
private String minsTime2;
|
||||
|
||||
@ApiModelProperty("20%~30%区间个数")
|
||||
private Integer minsNum2;
|
||||
|
||||
@ApiModelProperty("20%~30%区间是否越限")
|
||||
private Integer isOrNot2;
|
||||
|
||||
@ApiModelProperty("30%~40%区间时间Json")
|
||||
private String minsTime3;
|
||||
|
||||
@ApiModelProperty("30%~40%区间个数")
|
||||
private Integer minsNum3;
|
||||
|
||||
@ApiModelProperty("30%~40%区间是否越限")
|
||||
private Integer isOrNot3;
|
||||
|
||||
@ApiModelProperty("40%~50%区间时间Json")
|
||||
private String minsTime4;
|
||||
|
||||
@ApiModelProperty("40%~50%区间个数")
|
||||
private Integer minsNum4;
|
||||
|
||||
@ApiModelProperty("40%~50%区间是否越限")
|
||||
private Integer isOrNot4;
|
||||
|
||||
@ApiModelProperty("50%~60%区间时间Json")
|
||||
private String minsTime5;
|
||||
|
||||
@ApiModelProperty("50%~60%区间个数")
|
||||
private Integer minsNum5;
|
||||
|
||||
@ApiModelProperty("50%~60%区间是否越限")
|
||||
private Integer isOrNot5;
|
||||
|
||||
@ApiModelProperty("60%~70%区间时间Json")
|
||||
private String minsTime6;
|
||||
|
||||
@ApiModelProperty("60%~70%区间个数")
|
||||
private Integer minsNum6;
|
||||
|
||||
@ApiModelProperty("60%~70%区间是否越限")
|
||||
private Integer isOrNot6;
|
||||
|
||||
@ApiModelProperty("70%~80%区间时间Json")
|
||||
private String minsTime7;
|
||||
|
||||
@ApiModelProperty("70%~80%区间个数")
|
||||
private Integer minsNum7;
|
||||
|
||||
@ApiModelProperty("70%~80%区间是否越限")
|
||||
private Integer isOrNot7;
|
||||
|
||||
@ApiModelProperty("80%~90%区间时间Json")
|
||||
private String minsTime8;
|
||||
|
||||
@ApiModelProperty("80%~90%区间个数")
|
||||
private Integer minsNum8;
|
||||
|
||||
@ApiModelProperty("80%~90%区间是否越限")
|
||||
private Integer isOrNot8;
|
||||
|
||||
@ApiModelProperty("90%~100%区间时间Json")
|
||||
private String minsTime9;
|
||||
|
||||
@ApiModelProperty("90%~100%区间个数")
|
||||
private Integer minsNum9;
|
||||
|
||||
@ApiModelProperty("90%~100%区间是否越限")
|
||||
private Integer isOrNot9;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.harmonic.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 指标详情数据实体类
|
||||
* @author guofeihu
|
||||
* @since 2024-08-20
|
||||
*/
|
||||
@Data
|
||||
public class ThdDataVO {
|
||||
private String phase;
|
||||
private String statMethod;
|
||||
private String anotherName;
|
||||
private String frequency;
|
||||
private Double statisticalData;
|
||||
}
|
||||
@@ -94,6 +94,18 @@
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.9.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>prepare-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>pq-device-boot</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,11 +1,31 @@
|
||||
package com.njcn.harmonic.controller.powerstatistics;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelExportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
||||
import com.njcn.device.pq.utils.ExcelStyleUtil;
|
||||
import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 有功功率趋势统计 前端控制器
|
||||
@@ -21,5 +41,50 @@ public class PowerStatisticsController extends BaseController {
|
||||
|
||||
private final PowerStatisticsService powerStatisticsService;
|
||||
|
||||
/**
|
||||
* 根据监测点ID及时间获取有功功率趋势
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getDataByLineId")
|
||||
@ApiOperation("根据监测点ID及时间获取有功功率趋势")
|
||||
public HttpResult<PowerStatisticsVO> getDataByLineId(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getDataByLineId");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, powerStatisticsService.getDataByLine(powerStatisticsParam), methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getTargetLimitById")
|
||||
@ApiOperation("根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表")
|
||||
public HttpResult<List<PowerStatisticsTargetVO>> getTargetLimitById(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getTargetLimitById");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, powerStatisticsService.getTargetLimitById(powerStatisticsParam), methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击越限列表时间查询指标的详细数据
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getTargetByTime")
|
||||
@ApiOperation("点击越限列表时间查询指标的详细数据")
|
||||
public HttpResult<List<ThdDataVO>> getTargetByTime(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam) {
|
||||
String methodDescribe = getMethodDescribe("getTargetByTime");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, powerStatisticsService.getTargetByTime(powerStatisticsParam), methodDescribe);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ApiOperation("导出设备基础数据模板")
|
||||
@GetMapping(value = "getExcelTemplate")
|
||||
public HttpResult<String> getExcelTemplate(@RequestBody @Validated PowerStatisticsParam powerStatisticsParam,HttpServletResponse response) {
|
||||
ExportParams exportParams = new ExportParams("数据", "数据");
|
||||
exportParams.setStyle(ExcelStyleUtil.class);
|
||||
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, TerminalBaseExcel.class, new ArrayList<TerminalBaseExcel>());
|
||||
String fileName = "数据.xlsx";
|
||||
PoiUtil.exportFileByWorkbook(workbook, fileName, response);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.njcn.harmonic.service.activepowerrange;
|
||||
|
||||
import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 有功功率趋势统计 服务类
|
||||
* @author guofeihu
|
||||
@@ -7,4 +13,25 @@ package com.njcn.harmonic.service.activepowerrange;
|
||||
*/
|
||||
public interface PowerStatisticsService {
|
||||
|
||||
/**
|
||||
* 根据监测点ID及时间获取有功功率趋势
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
PowerStatisticsVO getDataByLine(PowerStatisticsParam powerStatisticsParam);
|
||||
|
||||
/**
|
||||
* 根据监测点ID、有功功率趋势区间字段、时间获取该有功功率趋势下指标越限列表
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<PowerStatisticsTargetVO> getTargetLimitById(PowerStatisticsParam powerStatisticsParam);
|
||||
|
||||
/**
|
||||
* 点击越限列表时间查询指标的详细数据
|
||||
* @param powerStatisticsParam
|
||||
* @return
|
||||
*/
|
||||
List<ThdDataVO> getTargetByTime(PowerStatisticsParam powerStatisticsParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,27 @@
|
||||
package com.njcn.harmonic.service.activepowerrange.impl;
|
||||
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.harmonic.constant.Param;
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.pojo.param.PowerStatisticsParam;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsTargetVO;
|
||||
import com.njcn.harmonic.pojo.vo.PowerStatisticsVO;
|
||||
import com.njcn.harmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.harmonic.service.activepowerrange.PowerStatisticsService;
|
||||
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import com.njcn.system.api.CsStatisticalSetFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 有功功率趋势统计 服务实现类
|
||||
@@ -9,6 +29,73 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2024-08-20
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PowerStatisticsServiceImpl implements PowerStatisticsService {
|
||||
|
||||
private final RActivePowerRangeFeignClient rActivePowerRangeFeignClient;
|
||||
|
||||
private final CsStatisticalSetFeignClient csStatisticalSetFeignClient;
|
||||
|
||||
private final CommonService commonService;
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat(Param.DECIMAL_FORMATSTR);
|
||||
|
||||
@Override
|
||||
public PowerStatisticsVO getDataByLine(PowerStatisticsParam powerStatisticsParam) {
|
||||
RActivePowerRangePO rActivePowerRangePO = rActivePowerRangeFeignClient.getDataByLineId(powerStatisticsParam.getLineId()).getData();
|
||||
if(rActivePowerRangePO == null){
|
||||
throw new BusinessException(HarmonicResponseEnum.NO_LINE_DATA.getMessage());
|
||||
}
|
||||
PowerStatisticsVO powerStatisticsVO = new PowerStatisticsVO();
|
||||
BeanUtils.copyProperties(rActivePowerRangePO, powerStatisticsVO);
|
||||
return powerStatisticsVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PowerStatisticsTargetVO> getTargetLimitById(PowerStatisticsParam powerStatisticsParam) {
|
||||
List<PowerStatisticsTargetVO> list = new ArrayList();
|
||||
for (int i = 0; i < (int) (Math.random() * 10 + 1); i++) {
|
||||
PowerStatisticsTargetVO powerStatisticsTargetVO = new PowerStatisticsTargetVO();
|
||||
powerStatisticsTargetVO.setTime("2024-06-01 18:00:00");
|
||||
powerStatisticsTargetVO.setVoltageOffset(1);
|
||||
powerStatisticsTargetVO.setVTimes(0);
|
||||
powerStatisticsTargetVO.setITimes(1);
|
||||
powerStatisticsTargetVO.setUbalance(1);
|
||||
powerStatisticsTargetVO.setVoltageFluctuation(0);
|
||||
powerStatisticsTargetVO.setFlicker(0);
|
||||
powerStatisticsTargetVO.setInterHarmonic(1);
|
||||
powerStatisticsTargetVO.setSequenceCurrentUnbalance(1);
|
||||
list.add(powerStatisticsTargetVO);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThdDataVO> getTargetByTime(PowerStatisticsParam powerStatisticsParam) {
|
||||
List<ThdDataVO> result = new ArrayList();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(powerStatisticsParam.getStatisticalId()).getData();
|
||||
eleEpdPqds.forEach(epdPqd->{
|
||||
List<CommonQueryParam> commonQueryParams = new ArrayList<>();
|
||||
commonQueryParams.clear();
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(powerStatisticsParam.getLineId());
|
||||
commonQueryParam.setTableName(epdPqd.getClassId());
|
||||
commonQueryParam.setColumnName(epdPqd.getName());
|
||||
commonQueryParam.setStartTime(powerStatisticsParam.getSearchBeginTime());
|
||||
commonQueryParam.setEndTime(powerStatisticsParam.getSearchEndTime());
|
||||
commonQueryParams.add(commonQueryParam);
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setPhase(temp.getPhaseType());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.njcn.prepare.harmonic.api.event;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.prepare.harmonic.api.event.fallback.RActivePowerRangeFeignClientFallbackFactory;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* 有功功率趋势Feign客户端
|
||||
@@ -20,4 +23,8 @@ public interface RActivePowerRangeFeignClient {
|
||||
|
||||
@PostMapping("/record")
|
||||
HttpResult<Boolean> record();
|
||||
|
||||
@GetMapping("/getDataByLineId")
|
||||
HttpResult<RActivePowerRangePO> getDataByLineId(@RequestParam("lineId") String lineId);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ 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.prepare.harmonic.api.event.RActivePowerRangeFeignClient;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import com.njcn.prepare.harmonic.utils.PrepareEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -33,6 +34,12 @@ public class RActivePowerRangeFeignClientFallbackFactory implements FallbackFact
|
||||
log.error("{}异常,降级处理,异常为:{}", "有功功率趋势记录: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<RActivePowerRangePO> getDataByLineId(String lineId) {
|
||||
log.error("{}异常,降级处理,异常为:{}", "根据监测点ID获取有功功率趋势信息: ", throwable.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 0%~10%区间个数
|
||||
*/
|
||||
private Integer minsNum0;
|
||||
private Integer minsNum0 = 0;
|
||||
|
||||
/**
|
||||
* 0%~10%区间是否越限
|
||||
@@ -54,7 +54,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 10%~20%区间个数
|
||||
*/
|
||||
private Integer minsNum1;
|
||||
private Integer minsNum1 = 0;;
|
||||
|
||||
/**
|
||||
* 10%~20%区间是否越限
|
||||
@@ -69,7 +69,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 20%~30%区间个数
|
||||
*/
|
||||
private Integer minsNum2;
|
||||
private Integer minsNum2 = 0;;
|
||||
|
||||
/**
|
||||
* 20%~30%区间是否越限
|
||||
@@ -84,7 +84,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 30%~40%区间个数
|
||||
*/
|
||||
private Integer minsNum3;
|
||||
private Integer minsNum3 = 0;;
|
||||
|
||||
/**
|
||||
* 30%~40%区间是否越限
|
||||
@@ -99,7 +99,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 40%~50%区间个数
|
||||
*/
|
||||
private Integer minsNum4;
|
||||
private Integer minsNum4 = 0;;
|
||||
|
||||
/**
|
||||
* 40%~50%区间是否越限
|
||||
@@ -114,7 +114,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 50%~60%区间个数
|
||||
*/
|
||||
private Integer minsNum5;
|
||||
private Integer minsNum5 = 0;;
|
||||
|
||||
/**
|
||||
* 50%~60%区间是否越限
|
||||
@@ -129,7 +129,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 60%~70%区间个数
|
||||
*/
|
||||
private Integer minsNum6;
|
||||
private Integer minsNum6 = 0;;
|
||||
|
||||
/**
|
||||
* 60%~70%区间是否越限
|
||||
@@ -144,7 +144,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 70%~80%区间个数
|
||||
*/
|
||||
private Integer minsNum7;
|
||||
private Integer minsNum7 = 0;;
|
||||
|
||||
/**
|
||||
* 70%~80%区间是否越限
|
||||
@@ -159,7 +159,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 80%~90%区间个数
|
||||
*/
|
||||
private Integer minsNum8;
|
||||
private Integer minsNum8 = 0;;
|
||||
|
||||
/**
|
||||
* 80%~90%区间是否越限
|
||||
@@ -174,7 +174,7 @@ public class RActivePowerRangePO extends BaseEntity {
|
||||
/**
|
||||
* 90%~100%区间个数
|
||||
*/
|
||||
private Integer minsNum9;
|
||||
private Integer minsNum9 = 0;;
|
||||
|
||||
/**
|
||||
* 90%~100%区间是否越限
|
||||
|
||||
@@ -14,11 +14,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 有功功率趋势 前端控制器
|
||||
@@ -45,11 +41,11 @@ public class RActivePowerRangeController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
|
||||
@PostMapping("/getDataByLineIds")
|
||||
@ApiOperation("根据监测点ID集合获取有功功率趋势信息")
|
||||
public HttpResult<List<RActivePowerRangePO>> getDataByLineIds(@RequestBody List<String> lineIds) {
|
||||
String methodDescribe = getMethodDescribe("getDataByLineIds");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rActivePowerRangeService.getDataByLineIds(lineIds), methodDescribe);
|
||||
@GetMapping("/getDataByLineId")
|
||||
@ApiOperation("根据监测点ID获取有功功率趋势信息")
|
||||
public HttpResult<RActivePowerRangePO> getDataByLineId(@RequestParam("lineId") String lineId) {
|
||||
String methodDescribe = getMethodDescribe("getDataByLineId");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rActivePowerRangeService.getDataByLineId(lineId), methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,30 @@
|
||||
package com.njcn.prepare.harmonic.service.mysql.Impl.event;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.device.biz.commApi.CommLineClient;
|
||||
import com.njcn.device.biz.pojo.dto.LineDTO;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.pq.api.NewStationClient;
|
||||
import com.njcn.device.pq.api.OverLimitClient;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import com.njcn.event.pojo.constant.Param;
|
||||
import com.njcn.influx.pojo.po.DataHarmPowerP;
|
||||
import com.njcn.influx.pojo.po.DataV;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.influx.service.DataHarmPowerPService;
|
||||
import com.njcn.influx.service.IDataVService;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.event.RActivePowerRangeMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import com.njcn.prepare.harmonic.service.mysql.event.RActivePowerRangeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 有功功率趋势 服务实现类
|
||||
@@ -13,15 +32,98 @@ import java.util.List;
|
||||
* @since 2024-08-22
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RActivePowerRangeServiceImpl extends MppServiceImpl<RActivePowerRangeMapper, RActivePowerRangePO> implements RActivePowerRangeService {
|
||||
|
||||
private final DataHarmPowerPService dataHarmPowerPService;
|
||||
|
||||
private final CommLineClient commLineClient;
|
||||
|
||||
private final NewStationClient newStationClient;
|
||||
|
||||
private final OverLimitClient overLimitClient;
|
||||
|
||||
private final IDataVService iDataVService;
|
||||
|
||||
CommonService commonService;
|
||||
|
||||
@Override
|
||||
public void record() {
|
||||
//根据事件间隔查询 SELECT * FROM "data_harmpower_p" limit 1 得到P
|
||||
// 便利 用p / 风电场额定有功功率 * 100% 看落在那个占比
|
||||
List<RActivePowerRangePO> rActivePowerRangePOS = new ArrayList<>();
|
||||
//定义开始和结束时间
|
||||
String startTime = getTime(1,0);
|
||||
String endTime = getTime(1,1);
|
||||
//获取时间段内的有功功率集合
|
||||
List<DataHarmPowerP> dataHarmPowerPS = dataHarmPowerPService.getHarmonicPowerP("",startTime,endTime);
|
||||
//有功功率趋势表是按照监测点来划分的 所以这边需要根据监测点来分组
|
||||
Map<String,List<DataHarmPowerP>> map = dataHarmPowerPS.stream().collect(Collectors.groupingBy(DataHarmPowerP::getLineId));
|
||||
map.forEach((key,value) ->{
|
||||
RActivePowerRangePO rActivePowerRangePO = new RActivePowerRangePO();
|
||||
rActivePowerRangePO.setId(IdUtil.simpleUUID());
|
||||
rActivePowerRangePO.setLineId(key);
|
||||
rActivePowerRangePO.setTimeId(LocalDate.now());
|
||||
//获取监测点的国标限值
|
||||
List<Overlimit> overlimits = overLimitClient.getOverLimitByLineIds(Arrays.asList(key)).getData();
|
||||
//获取监测点
|
||||
LineDTO lineDTO = commLineClient.getLineDetail(key).getData();
|
||||
if(lineDTO != null && lineDTO.getNewStationId() != null){
|
||||
NewStation newStation = newStationClient.selectById(lineDTO.getNewStationId()).getData();
|
||||
//风电场
|
||||
if(newStation != null && com.njcn.device.pq.constant.Param.WINDFARM.equals(newStation.getStationType())){
|
||||
//计算各个区间个数
|
||||
for(DataHarmPowerP dataHarmPowerP : value){
|
||||
double temp = dataHarmPowerP.getP() / Double.parseDouble(newStation.getRatedPower());
|
||||
if(temp <= 0.1){
|
||||
rActivePowerRangePO.setMinsNum0(rActivePowerRangePO.getMinsNum0() + 1);
|
||||
}else if(0.1 < temp && temp <= 0.2){
|
||||
rActivePowerRangePO.setMinsNum1(rActivePowerRangePO.getMinsNum1() + 1);
|
||||
}else if(0.2 < temp && temp <= 0.3){
|
||||
rActivePowerRangePO.setMinsNum2(rActivePowerRangePO.getMinsNum2() + 1);
|
||||
}else if(0.3 < temp && temp <= 0.4){
|
||||
rActivePowerRangePO.setMinsNum3(rActivePowerRangePO.getMinsNum3() + 1);
|
||||
}else if(0.4 < temp && temp <= 0.5){
|
||||
rActivePowerRangePO.setMinsNum4(rActivePowerRangePO.getMinsNum4() + 1);
|
||||
}else if(0.5 < temp && temp <= 0.6){
|
||||
rActivePowerRangePO.setMinsNum5(rActivePowerRangePO.getMinsNum5() + 1);
|
||||
}else if(0.6 < temp && temp <= 0.7){
|
||||
rActivePowerRangePO.setMinsNum6(rActivePowerRangePO.getMinsNum6() + 1);
|
||||
}else if(0.7 < temp && temp <= 0.8){
|
||||
rActivePowerRangePO.setMinsNum7(rActivePowerRangePO.getMinsNum7() + 1);
|
||||
}else if(0.8 < temp && temp <= 0.9){
|
||||
rActivePowerRangePO.setMinsNum8(rActivePowerRangePO.getMinsNum8() + 1);
|
||||
}else if(temp > 0.9){
|
||||
rActivePowerRangePO.setMinsNum9(rActivePowerRangePO.getMinsNum9() + 1);
|
||||
}
|
||||
}
|
||||
//计算各个区间是否越限
|
||||
//电压偏差
|
||||
List<DataV> dataVS = iDataVService.getHarmonicDataV(key,startTime,endTime);
|
||||
for(DataV dataV : dataVS){
|
||||
if(dataV.getVuDev() > 0 && dataV.getVuDev() > overlimits.get(0).getVoltageDev()){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getTime(long interval,int type){
|
||||
DateTimeFormatter sdf = DateTimeFormatter.ofPattern(DateUtils.DATE_FORMAT_10);
|
||||
LocalDate yesterday = LocalDate.now().minusDays(interval);
|
||||
if(type == 0){
|
||||
return yesterday.format(sdf)+Param.BEGIN;
|
||||
}else{
|
||||
return yesterday.format(sdf)+Param.END;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RActivePowerRangePO> getDataByLineIds(List<String> lineIds) {
|
||||
return null;
|
||||
public RActivePowerRangePO getDataByLineId(String lineId) {
|
||||
LambdaQueryWrapper<RActivePowerRangePO> lambdaQueryWrapper = new LambdaQueryWrapper();
|
||||
lambdaQueryWrapper.eq(RActivePowerRangePO::getLineId,lineId).eq(RActivePowerRangePO::getState,"1");
|
||||
return this.baseMapper.selectOne(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.device.pq.api.NewStationClient;
|
||||
import com.njcn.device.pq.constant.Param;
|
||||
import com.njcn.device.pq.pojo.po.NewStation;
|
||||
import com.njcn.event.api.EventDetailFeignClient;
|
||||
import com.njcn.event.file.component.WaveFileComponent;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.event.SpThroughMapper;
|
||||
import com.njcn.prepare.harmonic.pojo.param.SpThroughParam;
|
||||
@@ -36,6 +37,8 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
|
||||
|
||||
private final NewStationClient newStationClient;
|
||||
|
||||
private final WaveFileComponent waveFileComponent;
|
||||
|
||||
@Override
|
||||
public void record() {
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
@@ -47,6 +50,7 @@ public class SpThroughServiceImpl extends MppServiceImpl<SpThroughMapper, SpThro
|
||||
if(lineDTO != null && lineDTO.getNewStationId() != null){
|
||||
NewStation newStation = newStationClient.selectById(lineDTO.getNewStationId()).getData();
|
||||
if(newStation != null){
|
||||
//waveFileComponent.getComtrade();
|
||||
//暂升事件
|
||||
if(Param.UPPEREVENT.equals(rmpEventDetailPO.getEventType())){
|
||||
//风电场
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.prepare.harmonic.service.mysql.event;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.prepare.harmonic.pojo.po.RActivePowerRangePO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 有功功率趋势 服务类
|
||||
@@ -17,8 +16,8 @@ public interface RActivePowerRangeService extends IMppService<RActivePowerRangeP
|
||||
void record();
|
||||
|
||||
/**
|
||||
* 根据监测点ID集合获取有功功率趋势信息
|
||||
* 根据监测点ID获取有功功率趋势信息
|
||||
*/
|
||||
List<RActivePowerRangePO> getDataByLineIds(List<String> lineIds);
|
||||
RActivePowerRangePO getDataByLineId(String lineId);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user