添加畸变率算法
This commit is contained in:
@@ -59,6 +59,12 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.platform</groupId>
|
||||
<artifactId>algorithm-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.dataProcess.api;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.dataProcess.api.fallback.RMpVThdFeignClientFallbackFactory;
|
||||
import com.njcn.dataProcess.api.fallback.SpThroughFeignClientFallbackFactory;
|
||||
import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import com.njcn.dataProcess.pojo.dto.SpThroughDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年01月05日 15:11
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/rmpvthd", fallbackFactory = RMpVThdFeignClientFallbackFactory.class, contextId = "rmpvthd")
|
||||
public interface RmpVThdFeignClient {
|
||||
|
||||
@PostMapping("/batchInsertionThd")
|
||||
HttpResult<String> batchInsertionThd(@RequestBody List<RMpVThd> result);
|
||||
|
||||
@PostMapping("/batchInsertionPower")
|
||||
HttpResult<List<RMpVThd>> queryThd(@RequestBody CalculatedParam calculatedParam);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.dataProcess.api.fallback;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
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.dataProcess.api.RmpVThdFeignClient;
|
||||
import com.njcn.dataProcess.api.SpThroughFeignClient;
|
||||
import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import com.njcn.dataProcess.pojo.dto.SpThroughDto;
|
||||
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author denghuajun
|
||||
* @version 1.0.0
|
||||
* @date 2022年01月05日 15:08
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RMpVThdFeignClientFallbackFactory implements FallbackFactory<RmpVThdFeignClient> {
|
||||
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public RmpVThdFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = DataProcessingEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new RmpVThdFeignClient() {
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResult<String> batchInsertionThd(List<RMpVThd> result) {
|
||||
log.error("{}异常,降级处理,异常为:{}","畸变率插入",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<RMpVThd>> queryThd(CalculatedParam calculatedParam) {
|
||||
log.error("{}异常,降级处理,异常为:{}","畸变率查询",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.njcn.dataProcess.pojo.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/10/10 19:59【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* 谐波畸变率排名
|
||||
*/
|
||||
@ApiModel(value="com-njcn-harmonic-pojo-po-RMpVThd")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "r_mp_v_thd")
|
||||
public class RMpVThd implements Serializable {
|
||||
/**
|
||||
* 监测点ID
|
||||
*/
|
||||
@TableField(value = "measurement_point_id")
|
||||
@MppMultiId
|
||||
private String measurementPointId;
|
||||
|
||||
/**
|
||||
* 排名类型,字典表(1年 2季度 3月份 4周 5日)
|
||||
*/
|
||||
@TableField(value = "data_type")
|
||||
@MppMultiId
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 时间
|
||||
*/
|
||||
@TableField(value = "data_date")
|
||||
@MppMultiId
|
||||
private LocalDate dataDate;
|
||||
|
||||
/**
|
||||
* 谐波畸变率
|
||||
*/
|
||||
@TableField(value = "v_thd")
|
||||
private Double vThd;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.dataProcess.controller;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
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.dataProcess.annotation.InsertBean;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import com.njcn.dataProcess.service.IRMpVThdService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2024/11/6 19:48
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/rmpvthd")
|
||||
@Api(tags = "畸变率")
|
||||
public class RMpVThdController extends BaseController {
|
||||
|
||||
@InsertBean
|
||||
private IRMpVThdService irMpVThdService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/batchInsertionThd")
|
||||
@ApiOperation("畸变率批量插入")
|
||||
public HttpResult<String> batchInsertionThd(@RequestBody List<RMpVThd> result) {
|
||||
String methodDescribe = getMethodDescribe("batchInsertionPower");
|
||||
irMpVThdService.batchInsertionThd(result);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/batchInsertionPower")
|
||||
@ApiOperation("畸变率查询")
|
||||
public HttpResult<List<RMpVThd>> queryThd(@RequestBody CalculatedParam calculatedParam) {
|
||||
String methodDescribe = getMethodDescribe("batchInsertionPower");
|
||||
List<RMpVThd> rMpVThdList = irMpVThdService.queryHarmonicVThd(calculatedParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpVThdList, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.dataProcess.dao.relation.mapper;
|
||||
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 谐波畸变率排名 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @since 2022-11-07
|
||||
*/
|
||||
public interface RMpVThdMapper extends MppBaseMapper<RMpVThd> {
|
||||
|
||||
int insertRate(@Param("item") Map<String, Object> item);
|
||||
|
||||
/**
|
||||
* 从r_stat_data_v_d中获取畸变率的最大值
|
||||
* phasic_type = A、B、C && value_type = CP95
|
||||
*/
|
||||
List<RMpVThd> getVThdData(@Param("time") String time, @Param("lineList")List<String> lineList);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.dataProcess.dao.relation.mapper.RMpVThdMapper">
|
||||
|
||||
<insert id="insertRate">
|
||||
INSERT INTO r_mp_v_thd ( measurement_point_id, data_type, data_date, v_thd) VALUES
|
||||
( #{item.lineId}, #{item.dataType}, #{item.dataDate}, #{item.vThd} )
|
||||
ON DUPLICATE KEY UPDATE v_thd = #{item.vThd}
|
||||
</insert>
|
||||
|
||||
<select id="getVThdData" resultType="com.njcn.dataProcess.pojo.dto.RMpVThd">
|
||||
select
|
||||
line_id measurementPointId,
|
||||
max(v_thd) vThd,
|
||||
time dataDate,
|
||||
'0' dataType
|
||||
from
|
||||
r_stat_data_v_d
|
||||
where
|
||||
time = #{time}
|
||||
and phasic_type in ('A', 'B', 'C')
|
||||
and value_type = 'CP95'
|
||||
<if test="lineList != null and lineList.size() > 0">
|
||||
and line_id in
|
||||
<foreach collection="lineList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
group by line_id, time
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.njcn.dataProcess.service;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRMpVThdService {
|
||||
|
||||
/**
|
||||
* 计算谐波畸变率表
|
||||
* @param calculatedParam
|
||||
*/
|
||||
List<RMpVThd> queryHarmonicVThd(CalculatedParam calculatedParam);
|
||||
|
||||
void batchInsertionThd(List<RMpVThd> result);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.dataProcess.service.impl.relation;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RMpVThdMapper;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import com.njcn.dataProcess.service.IRMpVThdService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
* @author xuyang
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/4/24 17:58
|
||||
*/
|
||||
|
||||
@Service("RelationRMpVThdServiceImpl")
|
||||
@Slf4j
|
||||
public class RelationRMpVThdServiceImpl extends MppServiceImpl<RMpVThdMapper, RMpVThd> implements IRMpVThdService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public List<RMpVThd> queryHarmonicVThd(CalculatedParam calculatedParam) {
|
||||
log.info(LocalDateTime.now()+"===>监测点谐波畸变率开始执行");
|
||||
List<String> lineIds = calculatedParam.getIdList();
|
||||
List<RMpVThd> rMpVThdList = new ArrayList<>();
|
||||
//以尺寸100分片,查询数据
|
||||
List<List<String>> pendingIds = ListUtils.partition(lineIds,5);
|
||||
for (List<String> pendingId : pendingIds) {
|
||||
List<RMpVThd> result = this.baseMapper.getVThdData(calculatedParam.getDataDate(),pendingId);
|
||||
if (CollectionUtil.isNotEmpty(result)){
|
||||
rMpVThdList.addAll(result);
|
||||
}
|
||||
}
|
||||
return rMpVThdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsertionThd(List<RMpVThd> result) {
|
||||
this.saveOrUpdateBatchByMultiId(result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user