Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-04-11 16:41:21 +08:00
14 changed files with 106 additions and 81 deletions

View File

@@ -396,7 +396,7 @@ public class COverlimit {
}else if(DicDataEnum.KV1100.getCode().equalsIgnoreCase(voltageLevel)){
return 7000;
}else {
throw new BusinessException("没有对应电压等级,请先完善字典");
throw new BusinessException("没有对应电压等级,请先完善字典"+voltageLevel);
}
}

View File

@@ -17,6 +17,7 @@ public interface THDistortionService {
/**
* 功能描述: 获取谐波总畸变率
*
* @param thDistortionParam
* @return
*/
@@ -25,10 +26,12 @@ public interface THDistortionService {
/**
* 功能描述: 获取总畸变率图表
*
* @param thDistortionCensusParam
* @return
*/
THDistortionCensusVO getTHDistortionCensus(DeviceInfoParam.BusinessParam thDistortionCensusParam);
/**
* @Description: 谐波总畸变率前topNum列表
* @Param: [statisticsBizBaseParam]
@@ -36,5 +39,5 @@ public interface THDistortionService {
* @Author: clam
* @Date: 2022/11/7
*/
List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam,Integer topNum);
List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam, Integer topNum);
}

View File

@@ -57,6 +57,7 @@ public class THDistortionServiceImpl implements THDistortionService {
private final RMpVThdMapper rMpVThdMapper;
private final LineFeignClient lineFeignClient;
private final IRStatDataVDService statDataVDService;
@Override
public List<THDistortionVO> getTHDistortionData(DeviceInfoParam.BusinessParam thDistortionParam) {
List<THDistortionVO> thDistortionVOS = new ArrayList<>();
@@ -72,7 +73,7 @@ public class THDistortionServiceImpl implements THDistortionService {
THDistortionVO thDistortionVO = new THDistortionVO();
thDistortionVO.setId(generalDeviceDTO.getIndex());
thDistortionVO.setName(generalDeviceDTO.getName());
if (!CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())){
if (!CollectionUtils.isEmpty(generalDeviceDTO.getLineIndexes())) {
List<String> lineIndexes = generalDeviceDTO.getLineIndexes();
//查找畸变率
@@ -121,33 +122,33 @@ public class THDistortionServiceImpl implements THDistortionService {
* @Date: 2022/10/10
*/
@Override
public List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam,Integer topNum) {
public List<RMpVThdVO> getTHDTopTenData(StatisticsBizBaseParam statisticsBizBaseParam, Integer topNum) {
List<RMpVThdVO> rMpVThdVOList = new ArrayList<> ();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam ();
deviceInfoParam.setDeptIndex (statisticsBizBaseParam.getId ());
deviceInfoParam.setStatisticalType (new SimpleDTO ());
deviceInfoParam.setServerName (generalInfo.getMicroServiceName());
deviceInfoParam.setPowerFlag (0);
deviceInfoParam.setMonitorFlag (0);
List<RMpVThdVO> rMpVThdVOList = new ArrayList<>();
DeviceInfoParam deviceInfoParam = new DeviceInfoParam();
deviceInfoParam.setDeptIndex(statisticsBizBaseParam.getId());
deviceInfoParam.setStatisticalType(new SimpleDTO());
deviceInfoParam.setServerName(generalInfo.getMicroServiceName());
deviceInfoParam.setPowerFlag(0);
deviceInfoParam.setMonitorFlag(0);
/*获取按部门分类的实际所有终端综合信息*/
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalAllDeviceInfoAsDept (deviceInfoParam).getData ();
List<GeneralDeviceDTO> deviceList = generalDeviceInfoClient.getPracticalAllDeviceInfoAsDept(deviceInfoParam).getData();
/*监测点ID扁平化*/
List<String> collect = deviceList.stream ( ).map (GeneralDeviceDTO::getLineIndexes).flatMap (Collection::stream).distinct ( ).collect (Collectors.toList ( ));
List<String> collect = deviceList.stream().map(GeneralDeviceDTO::getLineIndexes).flatMap(Collection::stream).distinct().collect(Collectors.toList());
QueryWrapper<RMpVThd> wrapper = new QueryWrapper<>();
wrapper.in ("measurement_point_id",collect)
.between ("data_date", statisticsBizBaseParam.getStartTime (), statisticsBizBaseParam.getEndTime ())
.eq("data_type",1)
.orderByDesc ("v_thd");
List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList (wrapper);
rMpVThdVOList = rMpVThdList.stream ( ).limit (topNum).map (rMpVThd -> {
RMpVThdVO rMpVThdVO = new RMpVThdVO ( );
BeanUtils.copyProperties (rMpVThd, rMpVThdVO);
wrapper.in("measurement_point_id", collect)
.between("data_date", statisticsBizBaseParam.getStartTime(), statisticsBizBaseParam.getEndTime())
.eq("data_type", 1)
.orderByDesc("v_thd");
List<RMpVThd> rMpVThdList = rMpVThdMapper.selectList(wrapper);
rMpVThdVOList = rMpVThdList.stream().limit(topNum).map(rMpVThd -> {
RMpVThdVO rMpVThdVO = new RMpVThdVO();
BeanUtils.copyProperties(rMpVThd, rMpVThdVO);
/*查询监测点详情获取名称*/
LineDetailDataVO data = lineFeignClient.getLineDetailData (rMpVThd.getMeasurementPointId ( )).getData ( );
rMpVThdVO.setName (data.getLineName ());
LineDetailDataVO data = lineFeignClient.getLineDetailData(rMpVThd.getMeasurementPointId()).getData();
rMpVThdVO.setName(data.getLineName());
return rMpVThdVO;
}).collect (Collectors.toList ( ));
}).collect(Collectors.toList());
return rMpVThdVOList;
}
@@ -174,6 +175,7 @@ public class THDistortionServiceImpl implements THDistortionService {
private List<THDistortionVO> getChildCategoryList(THDistortionVO item, List<THDistortionVO> child) {
return child.stream().filter(allItem -> allItem.getPid().equals(item.getId())).collect(Collectors.toList());
}
private void setChildesList(List<THDistortionVO> item, List<THDistortionVO> childes) {
//groupLine变电站索引和监测点集合
Map<String, List<THDistortionVO>> groupLine;
@@ -215,7 +217,7 @@ public class THDistortionServiceImpl implements THDistortionService {
// busBarList.stream().peek(item -> item.setChildren(getChildCategoryList(item, monitorList))).collect(Collectors.toList());
// deviceList.stream().peek(item -> item.setChildren(getChildCategoryList(item, busBarList))).collect(Collectors.toList());
// substationList.stream().peek(item -> item.setChildren(getChildesList(item, monitorList))).collect(Collectors.toList());
setChildesList(substationList,monitorList);
setChildesList(substationList, monitorList);
setFatherDistortion(substationList);
powerCompanyList.stream().peek(item -> item.setChildren(getChildCategoryList(item, substationList))).collect(Collectors.toList());
setFatherDistortion(powerCompanyList);
@@ -227,13 +229,14 @@ public class THDistortionServiceImpl implements THDistortionService {
/**
* influxDB查询畸变率
*
* @param lineIndexes
* @param startTime
* @param endTime
*/
private List<PublicDTO> getCondition(List<String> lineIndexes, String startTime, String endTime) {
List<PublicDTO> publicDTOList = new ArrayList<>();
List<String> phasicType=new ArrayList<>();
List<String> phasicType = new ArrayList<>();
phasicType.add(Param.PHASIC_TYPEA);
phasicType.add(Param.PHASIC_TYPEB);
phasicType.add(Param.PHASIC_TYPEC);
@@ -247,11 +250,11 @@ public class THDistortionServiceImpl implements THDistortionService {
.in(RStatDataVD::getPhasicType, phasicType)
.eq(RStatDataVD::getValueType, Param.VALUE_TYPEAVG)
);
if (CollUtil.isNotEmpty(info)){
if (CollUtil.isNotEmpty(info)) {
//根据id分组先乘以100.在取平均值,在四舍五入
Map<String, Double> vthdMap = info.stream().filter(x-> x.getVThd()!=null).collect(Collectors.groupingBy(RStatDataVD::getLineId,
Collectors.averagingDouble(x->x.getVThd().multiply(new BigDecimal(100)).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue())));
PublicDTO publicDTO ;
Map<String, Double> vthdMap = info.stream().filter(x -> x.getVThd() != null).collect(Collectors.groupingBy(RStatDataVD::getLineId,
Collectors.averagingDouble(x -> x.getVThd().multiply(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())));
PublicDTO publicDTO;
for (Map.Entry<String, Double> entry : vthdMap.entrySet()) {
publicDTO = new PublicDTO();
publicDTO.setId(entry.getKey());
@@ -260,43 +263,6 @@ public class THDistortionServiceImpl implements THDistortionService {
}
}
return publicDTOList;
//组装sql语句
// StringBuilder string = new StringBuilder();
// string.append(Param.QualityFlag + "='1' and (" + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEA + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEB + "' or " + Param.PHASIC_TYPE + "='" + Param.PHASIC_TYPEC + "') and "+ Param.VALUETYPE + "='AVG' and ");
// StringBuilder timeId = new StringBuilder();
// timeId.append(Param.TIME + " >= '" + startTime + Param.START_TIME + "' and " + Param.TIME + " <= '" + endTime + Param.END_TIME + "' and (");
// for (int i = 0; i < lineIndexes.size(); i++) {
// if (lineIndexes.size() - i != 1) {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("' or ");
// } else {
// timeId.append(Param.LINE_ID + "='").append(lineIndexes.get(i)).append("')");
// }
// }
// // String a = "SELECT MEAN(V_THD) AS distortion FROM Data_V WHERE QualityFlag='1' and (phasic_type='A' or phasic_type='B' or phasic_type='C')and value_type='AVG' and time >= '2022-03-20 00:00:00' and time <= '2022-03-21 23:59:59' and (lineid ='1e3b8531483b2a8cbee6747f1f641cf9') group by lineid;";
// //sql语句
// String sql = "SELECT MEAN(" + Param.V_THD + ")*100 AS distortion FROM Data_V WHERE " + string + timeId + " group by " + Param.LINE_ID;
// //结果集
// QueryResult result = influxDbUtils.query(sql);
// //处理结果集
// List<QueryResult.Series> list = result.getResults().get(0).getSeries();
// if (!CollectionUtils.isEmpty(list)){
// list.forEach(po->{
// PublicDTO publicDTO = new PublicDTO();
// List<List<Object>> valueList = po.getValues();
// String index = po.getTags().get(Param.LINE_ID);
// if (!CollectionUtils.isEmpty(valueList)){
// for (List<Object> value : valueList) {
// //谐波畸变率 保留两位小数
// Double distortion = value.get(1) == null ? null : BigDecimal.valueOf(Double.parseDouble(value.get(1).toString())).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
// publicDTO.setId(index);
// publicDTO.setData(distortion);
// }
// }
// publicDTOList.add(publicDTO);
// });
// }
// return publicDTOList;
}

View File

@@ -24,6 +24,6 @@ public class ThsSuperviseJob {
public void thsSuperviseJob() {
SuperviseParam superviseParam = new SuperviseParam();
superviseParam.setInitType(0);
thsSuperviseClient.initSupervise(superviseParam);
thsSuperviseClient.creatSupervise(superviseParam);
}
}

View File

@@ -16,11 +16,21 @@ import org.springframework.web.bind.annotation.RequestBody;
)
public interface ThsSuperviseClient {
/**
* 预警/告警事务的生成
* 预警/告警事务的初始化
*
* @param superviseParam
* @return
*/
@PostMapping("/initSupervise")
HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam);
/**
* 预警/告警事务的生成
*
* @param superviseParam
* @return
*/
@PostMapping("/creatSupervise")
HttpResult<String> creatSupervise(@RequestBody @Validated SuperviseParam superviseParam);
}

View File

@@ -26,6 +26,12 @@ public class ThsSuperviseClientFallbackFactory implements FallbackFactory<ThsSup
return new ThsSuperviseClient() {
@Override
public HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
log.error("{}异常,降级处理,异常为:{}", "预警/告警事务的初始化: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> creatSupervise(SuperviseParam superviseParam) {
log.error("{}异常,降级处理,异常为:{}", "预警/告警事务的生成: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}

View File

@@ -42,7 +42,7 @@ public class DistortionRateController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/distortionRate")
@ApiOperation("谐波畸变率排名")
@ApiOperation("谐波畸变率排名_mysql")
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
public HttpResult<String> distortionRate(@RequestBody @Validated LineParam lineParam){
String methodDescribe = getMethodDescribe("distortionRate");
@@ -54,6 +54,7 @@ public class DistortionRateController extends BaseController {
@PostMapping("/distortionRateBySource")
@ApiOperation("谐波畸变率排名")
@ApiImplicitParam(name = "lineParam", value = "参数", required = true)
@Deprecated
public HttpResult<String> distortionRateBySource(@RequestBody @Validated LineParam lineParam){
log.info(LocalDateTime.now()+"distortionRateBySource开始执行");
String methodDescribe = getMethodDescribe("distortionRateBySource");

View File

@@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequestMapping("/normalLimit")
@Api(tags = "告警数据预处理")
@Api(tags = "告警数据预处理_mysql")
@AllArgsConstructor
public class NormalLimitController extends BaseController {

View File

@@ -1,7 +1,9 @@
package com.njcn.prepare.harmonic.controller.line;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.prepare.harmonic.pojo.param.SuperviseParam;
import com.njcn.prepare.harmonic.service.mysql.line.ThsSuperviseService;
import com.njcn.web.controller.BaseController;
@@ -27,13 +29,23 @@ public class ThsSuperviseController extends BaseController {
@Autowired
private ThsSuperviseService thsSuperviseService;
@ApiOperation("预警/告警事务生成")
@ApiImplicitParam(name = "superviseParam", value = "建技术监督参数", required = true)
@ApiOperation("预警/告警事务手动初始化")
@ApiImplicitParam(name = "superviseParam", value = "建技术监督参数", required = true)
@PostMapping("/initSupervise")
@ResponseBody
public HttpResult<String> initSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
HttpResult<String> superviceRunLogVoHttpResult = thsSuperviseService.initSupervise(superviseParam);
return superviceRunLogVoHttpResult;
return thsSuperviseService.initSupervise(superviseParam);
}
@ApiOperation("预警/告警事务自动生成")
@ApiImplicitParam(name = "superviseParam", value = "创建技术监督参数", required = true)
@PostMapping("/creatSupervise")
@ResponseBody
public HttpResult<String> creatSupervise(@RequestBody @Validated SuperviseParam superviseParam) {
String methodDescribe = getMethodDescribe("creatSupervise");
thsSuperviseService.creatSupervise(superviseParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}

View File

@@ -540,6 +540,7 @@ public class DayDataServiceImpl implements DayDataService {
@Transactional(rollbackFor = {Exception.class})
@Async("asyncExecutor")
public void dataToDayHandler(List<String> indexLists, String startTime, String endTime) {
log.info(LocalDateTime.now()+"data表转day开始=====》");
Date time = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
@@ -761,6 +762,9 @@ public class DayDataServiceImpl implements DayDataService {
if (!CollectionUtils.isEmpty(dataPltPOList)){
statDataPltDService.insert(dataPltPOList);
}
log.info(LocalDateTime.now()+"data表转day结束=====》");
}

View File

@@ -29,6 +29,7 @@ import org.springframework.util.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -111,6 +112,7 @@ public class LimitRateService extends MppServiceImpl<LimitRatePOMapper, LimitRa
@SneakyThrows
@Async("asyncExecutor")
public void limitRate(List<String> lineList, String startTime, String endTime) {
log.info(LocalDateTime.now()+"r_stat_limit_rate_d开始执行=======》");
List<RStatLimitRateDPO> list = new ArrayList<>();
List<LimitRate> limitRateList = new ArrayList<> ();
Date date = null;
@@ -153,6 +155,8 @@ public class LimitRateService extends MppServiceImpl<LimitRatePOMapper, LimitRa
/*插入mysql*/
statLimitRateDService.insert(list);
}
log.info(LocalDateTime.now()+"r_stat_limit_rate_d执行结束《=======");
}

View File

@@ -23,6 +23,7 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
@@ -64,6 +65,7 @@ public class LimitTargetServiceImpl extends MppServiceImpl<RStatLimitTargetDMapp
@Override
@Async("asyncExecutor")
public void limitTargetData(LineParam lineParam,String time) {
log.info(LocalDateTime.now()+"r_stat_limit_target_d开始执行=======》");
List<RStatLimitTargetDPO> list = new ArrayList<>();
Date dateOut = DateUtil.parse(time);
List<RStatLimitRateDPO> limitRateData = new ArrayList<>();
@@ -83,6 +85,7 @@ public class LimitTargetServiceImpl extends MppServiceImpl<RStatLimitTargetDMapp
}
}
this.saveOrUpdateBatchByMultiId(list,50);
log.info(LocalDateTime.now()+"r_stat_limit_target_d开始执行=======》");
}
private List<LimitRate> getLimitRateData(String lineId,String date){

View File

@@ -36,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -78,6 +79,13 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
private FileStorageUtil fileStorageUtil;
private static final String DESCRIPTION = "description";
@Override
@Async("asyncExecutor")
public void creatSupervise(SuperviseParam superviseParam) {
this.initSupervise(superviseParam);
}
@Override
public HttpResult<String> initSupervise(SuperviseParam superviseParam) {
SuperviceRunLogVo superviceRunLogVo = new SuperviceRunLogVo();
@@ -215,6 +223,7 @@ public class ThsSuperviseServiceImpl extends ServiceImpl<ThsSuperviseMapper, Ths
}
}
/**
* 查询策略列表
*

View File

@@ -88,5 +88,12 @@ public interface ThsSuperviseService extends IService<ThsSupervise> {
*/
void creatData(Dept dept, ThsSupervise thsSupervise, List<ThsOverRunLog> overRunLogList);
/**
* 创建技术监督
*
* @param superviseParam
* @return
*/
void creatSupervise(SuperviseParam superviseParam);
}