Compare commits
16 Commits
master-jb
...
587e936554
| Author | SHA1 | Date | |
|---|---|---|---|
| 587e936554 | |||
| 69df89f2e8 | |||
|
|
aa9dc1b00a | ||
|
|
e56dc8c4be | ||
| 7bf8b9d393 | |||
|
|
5090e023b1 | ||
|
|
5cb4ab0e8f | ||
|
|
fce3f74da1 | ||
|
|
cf0c0085e9 | ||
|
|
ff0cbc7151 | ||
| 761fbc73f2 | |||
|
|
f1eb4515da | ||
| c02acfca4f | |||
|
|
221007b367 | ||
| 7f6172d0ad | |||
| 5d4e461ef0 |
@@ -1,10 +1,18 @@
|
||||
package com.njcn.dataProcess.api;
|
||||
package com.njcn.algorithm.pojo.api;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2026/05/21 下午 2:41【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
|
||||
import com.njcn.algorithm.pojo.api.fallback.PqReasonableRangeFeignClientFallbackFactory;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.dataProcess.api.fallback.PqReasonableRangeFeignClientFallbackFactory;
|
||||
import com.njcn.dataProcess.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -17,7 +25,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @date 2025年02月13日 20:11
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/pqReasonableRange", fallbackFactory = PqReasonableRangeFeignClientFallbackFactory.class, contextId = "pqReasonableRange")
|
||||
@FeignClient(value = ServerInfo.ALGORITHM_BOOT, path = "/pqReasonableRange", fallbackFactory = PqReasonableRangeFeignClientFallbackFactory.class, contextId = "pqReasonableRange")
|
||||
public interface PqReasonableRangeFeignClient {
|
||||
|
||||
@PostMapping("/getData")
|
||||
@@ -25,3 +33,4 @@ public interface PqReasonableRangeFeignClient {
|
||||
HttpResult<List<PqReasonableRangeDto>> getData(@RequestBody DataCleanParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.njcn.dataProcess.api.fallback;
|
||||
package com.njcn.algorithm.pojo.api.fallback;
|
||||
|
||||
import com.njcn.algorithm.pojo.api.PqReasonableRangeFeignClient;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.algorithm.pojo.util.PrepareEnumUtil;
|
||||
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.PqReasonableRangeFeignClient;
|
||||
import com.njcn.dataProcess.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -14,9 +14,11 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
* @version 1.0.0
|
||||
* @date 2025年02月13日 20:13
|
||||
* Description:
|
||||
* Date: 2026/05/21 下午 2:42【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -32,7 +34,7 @@ public class PqReasonableRangeFeignClientFallbackFactory implements FallbackFact
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if(cause.getCause() instanceof BusinessException){
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
exceptionEnum = DataProcessingEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
exceptionEnum = PrepareEnumUtil.getExceptionEnum(businessException.getResult());
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new PqReasonableRangeFeignClient() {
|
||||
@@ -45,3 +47,4 @@ public class PqReasonableRangeFeignClientFallbackFactory implements FallbackFact
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.dataProcess.pojo.dto;
|
||||
package com.njcn.algorithm.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.dataProcess.param;
|
||||
package com.njcn.algorithm.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.dataProcess.pojo.po;
|
||||
package com.njcn.algorithm.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
@@ -16,6 +16,7 @@ import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsLineDTO;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
|
||||
import com.njcn.device.biz.pojo.dto.DeptGetDeviceDTO;
|
||||
@@ -23,6 +24,7 @@ import com.njcn.device.biz.pojo.dto.DeptGetSubStationDTO;
|
||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||
import com.njcn.device.biz.pojo.param.DeptGetLineParam;
|
||||
import com.njcn.device.pq.api.DeptLineFeignClient;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -73,6 +75,8 @@ public class ExecutionCenter extends BaseController {
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private FlowAsyncService flowService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/***
|
||||
* 1、校验非全链执行时,tagNames节点标签集合必须为非空,否则提示---无可执行节点
|
||||
@@ -143,9 +147,27 @@ public class ExecutionCenter extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("wlMeasurementPointExecutor");
|
||||
//手动判断参数是否合法,
|
||||
CalculatedParam calculatedParam = judgeExecuteParam(baseParam);
|
||||
//缓存监测点、接线方式数据
|
||||
List<CsLineDTO> csLineDTOList = csLineFeignClient.getAllLineDetail().getData();
|
||||
List<String> lineIdList = new ArrayList<>();
|
||||
Map<String, Integer> lineConTypeMap = new HashMap<>();
|
||||
if (CollectionUtils.isNotEmpty(csLineDTOList)) {
|
||||
lineIdList = csLineDTOList.stream().map(CsLineDTO::getLineId).collect(Collectors.toList());
|
||||
//接线方式(0-星型 1-角型 2-V型)
|
||||
lineConTypeMap = csLineDTOList.stream()
|
||||
.filter(dto -> dto.getLineId() != null)
|
||||
.collect(Collectors.toMap(
|
||||
CsLineDTO::getLineId,
|
||||
dto -> dto.getConType() != null ? dto.getConType() : 0,
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
redisUtil.saveByKeyWithExpire("wlLineDetail", lineConTypeMap, 3600L*3);
|
||||
}
|
||||
// 测点索引
|
||||
if (CollectionUtils.isEmpty(calculatedParam.getIdList())) {
|
||||
calculatedParam.setIdList(csLineFeignClient.getAllLine().getData());
|
||||
calculatedParam.setIdList(lineIdList);
|
||||
} else {
|
||||
calculatedParam.setIdList(calculatedParam.getIdList());
|
||||
}
|
||||
LiteflowResponse liteflowResponse;
|
||||
if (baseParam.isRepair()) {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.njcn.algorithm.controller;
|
||||
|
||||
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.algorithm.service.line.IPqReasonableRangeService;
|
||||
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.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
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.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/pqReasonableRange")
|
||||
@Api(tags = "数据清洗标准库")
|
||||
public class PqReasonableRangeController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IPqReasonableRangeService pqReasonableRangeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
|
||||
@PostMapping("/getData")
|
||||
@ApiOperation("按条件获取数据合理范围")
|
||||
public HttpResult<List<PqReasonableRangeDto>> getData(@RequestBody DataCleanParam param) {
|
||||
String methodDescribe = getMethodDescribe("getData");
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeService.getReasonableRangeList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/save")
|
||||
@ApiOperation("新增数据合理范围")
|
||||
public HttpResult<String> save(@RequestBody @Validated PqReasonableRangeDto dto) {
|
||||
String methodDescribe = getMethodDescribe("save");
|
||||
boolean result = pqReasonableRangeService.savePqReasonableRange(dto);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "新增成功", methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "新增失败", methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新数据合理范围")
|
||||
public HttpResult<String> update(@RequestBody @Validated PqReasonableRangeDto dto) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
boolean result = pqReasonableRangeService.updatePqReasonableRange(dto);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "更新成功", methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "更新失败", methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除数据合理范围")
|
||||
@DeviceLog(operateType = DeviceOperate.DELETE)
|
||||
public HttpResult<String> delete(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
boolean result = pqReasonableRangeService.deletePqReasonableRange(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "删除成功", methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, "删除失败", methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.njcn.dataProcess.dao.relation.mapper;
|
||||
package com.njcn.algorithm.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
|
||||
|
||||
import java.util.List;
|
||||
import com.njcn.algorithm.pojo.po.PqReasonableRange;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.njcn.dataProcess.service;
|
||||
package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.dataProcess.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.algorithm.pojo.po.PqReasonableRange;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,4 +24,10 @@ public interface IPqReasonableRangeService extends IService<PqReasonableRange> {
|
||||
*/
|
||||
List<PqReasonableRangeDto> getReasonableRangeList(DataCleanParam param);
|
||||
|
||||
boolean savePqReasonableRange(PqReasonableRangeDto dto);
|
||||
|
||||
boolean updatePqReasonableRange(PqReasonableRangeDto dto);
|
||||
|
||||
boolean deletePqReasonableRange(String id);
|
||||
|
||||
}
|
||||
@@ -3,13 +3,15 @@ package com.njcn.algorithm.serviceimpl.line;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.algorithm.service.line.FlowAsyncService;
|
||||
import com.njcn.algorithm.service.line.IDataCleanService;
|
||||
import com.njcn.algorithm.service.line.IPqReasonableRangeService;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.*;
|
||||
import com.njcn.dataProcess.dto.RmpEventDetailDTO;
|
||||
import com.njcn.dataProcess.enums.DataCleanEnum;
|
||||
import com.njcn.dataProcess.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.*;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerify;
|
||||
@@ -33,7 +35,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.*;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -48,8 +52,8 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DataCleanServiceImpl.class);
|
||||
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
|
||||
@Resource
|
||||
private DataVFeignClient dataVFeignClient;
|
||||
@@ -80,7 +84,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
@Resource
|
||||
private PqDataVerifyFeignClient pqDataVerifyFeignClient;
|
||||
@Resource
|
||||
private PqReasonableRangeFeignClient pqReasonableRangeFeignClient;
|
||||
private IPqReasonableRangeService pqReasonableRangeService;
|
||||
@Resource
|
||||
private LineFeignClient lineFeignClient;
|
||||
@Resource
|
||||
@@ -97,7 +101,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
public void dataQualityCleanHandler(CalculatedParam calculatedParam) {
|
||||
MemorySizeUtil.getNowMemory();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
logger.info("{},数据质量清洗算法执行=====》", LocalDateTime.now());
|
||||
logger.info("{},{}数据质量清洗算法执行=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
//获取监测点的统计间隔
|
||||
List<String> listOfString = (List<String>) (List<?>) calculatedParam.getIdList();
|
||||
List<LineDetailDataVO> lineDetailDataVOS = lineFeignClient.getLineDetailList(listOfString).getData();
|
||||
@@ -286,7 +290,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
DictData dip = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.VOLTAGE_DIP.getCode(), DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
DictData rise = dicDataFeignClient.getDicDataByCodeAndType(DicDataEnum.VOLTAGE_RISE.getCode(), DicDataTypeEnum.EVENT_STATIS.getCode()).getData();
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},原始表数据清洗=====》", LocalDateTime.now());
|
||||
logger.info("{},{}原始表数据清洗=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
//获取标准
|
||||
Map<String, List<PqReasonableRangeDto>> map = getStandardData();
|
||||
//获取监测点台账信息
|
||||
@@ -300,7 +304,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
|
||||
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
|
||||
for (int i = 0; i < lineDetail.size(); i++) {
|
||||
logger.info( calculatedParam.getDataDate()+"总数据:" + lineDetail.size() + "=====》当前第" + (i + 1));
|
||||
// logger.info( calculatedParam.getDataDate()+"总数据:" + lineDetail.size() + "=====》当前第" + (i + 1));
|
||||
LineDetailVO.Detail item = lineDetail.get(i);
|
||||
flowService.lineDataClean(item, map, calculatedParam.getDataDate(), dip, rise,lineDetail.size(),(i + 1));
|
||||
}
|
||||
@@ -644,7 +648,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
DataCleanParam param = new DataCleanParam();
|
||||
param.setSystemType(DataCleanEnum.Pqs.getCode());
|
||||
// param.setDataSource(DataCleanEnum.InfluxDB.getCode());
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeFeignClient.getData(param).getData();
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeService.getReasonableRangeList(param);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
pqReasonableRangeDtoMap = list.stream().collect(Collectors.groupingBy(PqReasonableRangeDto::getInfluxdbTableName));
|
||||
}
|
||||
@@ -662,7 +666,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
|
||||
if (ObjectUtil.isNotNull(tableName)) {
|
||||
param.setTableName(tableName);
|
||||
}
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeFeignClient.getData(param).getData();
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeService.getReasonableRangeList(param);
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
pqReasonableRangeDtoMap = list.stream().collect(Collectors.toMap(PqReasonableRangeDto::getIndexCode, Function.identity()));
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.algorithm.serviceimpl.line;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IDataComAssService;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.DataComAssFeignClient;
|
||||
import com.njcn.dataProcess.api.DataFlickerFeignClient;
|
||||
import com.njcn.dataProcess.api.DataVFeignClient;
|
||||
@@ -38,8 +39,8 @@ import java.util.stream.Collectors;
|
||||
public class DataComAssServiceImpl implements IDataComAssService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class);
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
|
||||
|
||||
@Resource
|
||||
private DataVFeignClient dataVFeignClient;
|
||||
|
||||
@@ -53,7 +54,8 @@ public class DataComAssServiceImpl implements IDataComAssService {
|
||||
@Override
|
||||
public void dataComAssHandler(CalculatedParam calculatedParam) {
|
||||
List<DataComassesDPO> list = new ArrayList<>();
|
||||
logger.info("{},r_stat_comasses_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_stat_comasses_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
|
||||
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
|
||||
|
||||
@@ -35,8 +35,9 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class);
|
||||
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
|
||||
@Resource
|
||||
private DataVFeignClient dataVFeignClient;
|
||||
@Resource
|
||||
@@ -75,7 +76,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataVHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataV表转r_stat_data_v_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataV表转r_stat_data_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataVDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -91,7 +93,6 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
//获取原始数据
|
||||
List<CommonMinuteDto> partList = dataVFeignClient.getBaseData(lineParam).getData();
|
||||
if (CollUtil.isNotEmpty(partList)) {
|
||||
logger.info("{}dataV集合大小为>>>>>>>>>>>>{}",lineParam.getStartTime(),MemorySizeUtil.getObjectSize(partList));
|
||||
partList.forEach(item->{
|
||||
//相别
|
||||
List<CommonMinuteDto.PhasicType> phasicTypeList = item.getPhasicTypeList();
|
||||
@@ -125,7 +126,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataIHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataI表转r_stat_data_i_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataI表转r_stat_data_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataIDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -173,7 +175,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataFlickerHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataFlicker表转r_stat_data_flicker_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataFlicker表转r_stat_data_flicker_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<String> valueList = Arrays.asList("AVG","MAX","MIN","CP95");
|
||||
List<DataFlickerDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
@@ -222,7 +225,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataFlucHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataFluc表转r_stat_data_fluc_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataFluc表转r_stat_data_fluc_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<String> valueList = Arrays.asList("AVG","MAX","MIN","CP95");
|
||||
List<DataFlucDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
@@ -271,7 +275,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmPhasicIHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmPhasicI表转r_stat_data_harmphasic_i_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmPhasicI表转r_stat_data_harmphasic_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmPhasicIDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -319,7 +324,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmPhasicVHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmPhasicV表转r_stat_data_harmphasic_v_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmPhasicV表转r_stat_data_harmphasic_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmPhasicVDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -367,7 +373,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmPowerPHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmPowerP表转r_stat_data_harmpower_p_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmPowerP表转r_stat_data_harmpower_p_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmPowerPDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -415,7 +422,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmPowerQHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmPowerQ表转r_stat_data_harmpower_q_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmPowerQ表转r_stat_data_harmpower_q_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmPowerQDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -463,7 +471,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmPowerSHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmPowerS表转r_stat_data_harmpower_s_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmPowerS表转r_stat_data_harmpower_s_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmPowerSDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -511,7 +520,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmRateIHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmRateI表转r_stat_data_harmRate_i_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmRateI表转r_stat_data_harmRate_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmRateIDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -559,7 +569,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataHarmRateVHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataHarmRateV表转r_stat_data_harmRate_v_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataHarmRateV表转r_stat_data_harmRate_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataHarmRateVDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -607,7 +618,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataInHarmIHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataInHarmI表转r_stat_data_inharm_i_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataInHarmI表转r_stat_data_inharm_i_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataInHarmIDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -655,7 +667,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataInHarmVHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataInHarmV表转r_stat_data_inharm_v_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataInHarmV表转r_stat_data_inharm_v_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataInHarmVDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -703,7 +716,8 @@ public class DayDataServiceImpl implements IDayDataService {
|
||||
|
||||
@Override
|
||||
public void dataPltHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},dataPlt表转r_stat_data_plt_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}dataPlt表转r_stat_data_plt_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataPltDto> result = new ArrayList<>();
|
||||
List<String> valueList = Arrays.asList("AVG","MAX","MIN","CP95");
|
||||
//远程接口获取分钟数据
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.service.line.FlowAsyncService;
|
||||
import com.njcn.dataProcess.api.*;
|
||||
import com.njcn.dataProcess.dto.DataCleanJsonDTO;
|
||||
@@ -92,7 +93,7 @@ public class FlowAsyncServiceImpl implements FlowAsyncService {
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void lineDataClean(LineDetailVO.Detail line, Map<String, List<PqReasonableRangeDto>> map, String dataDate,DictData dip,DictData rise,int size,int i) {
|
||||
public void lineDataClean(LineDetailVO.Detail line, Map<String, List<PqReasonableRangeDto>> map, String dataDate, DictData dip, DictData rise, int size, int i) {
|
||||
LineDetailVO.Detail item = line;
|
||||
List<Map<String, Object>> resultData = new ArrayList<>();
|
||||
Set<String> allTimeSet = new HashSet<>();
|
||||
@@ -389,16 +390,16 @@ public class FlowAsyncServiceImpl implements FlowAsyncService {
|
||||
bak.setState(1);
|
||||
//存储文件
|
||||
InputStream reportStream = IoUtil.toStream(new Gson().toJson(resultData), CharsetUtil.UTF_8);
|
||||
String[] date = dataDate.split("-");
|
||||
String fileName = fileStorageUtil.uploadStreamSpecifyName(
|
||||
reportStream
|
||||
, OssPath.DATA_CLEAN + dataDate + "/"
|
||||
, OssPath.DATA_CLEAN + date[0] + "/"+ date[1] + "/"+ date[2] + "/"
|
||||
, item.getLineId() + ".txt");
|
||||
//存储数据
|
||||
bak.setFilePath(fileName);
|
||||
}
|
||||
pqDataVerifyNewFeignClient.insertData(bak);
|
||||
resultData=null;
|
||||
logger.info( dataDate+"总数据:" + size + "=====》当前第" + i+"已完成!");
|
||||
System.gc();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IDataCrossingService;
|
||||
@@ -42,10 +43,7 @@ import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -61,7 +59,7 @@ import java.util.stream.Collectors;
|
||||
public class IDataCrossingServiceImpl implements IDataCrossingService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class);
|
||||
@Value("${line.num}")
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
|
||||
@Resource
|
||||
@@ -106,29 +104,28 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
|
||||
}
|
||||
Map<String, Overlimit> overLimitMap = overLimitList.stream().collect(Collectors.toMap(Overlimit::getId, Function.identity()));
|
||||
//以100个监测点分片处理
|
||||
List<List<String>> pendingIds = ListUtils.partition(lineIds, 1);
|
||||
ArrayList<String> phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C);
|
||||
MemorySizeUtil.getNowMemory();
|
||||
List<List<String>> pendingIds = ListUtils.partition(lineIds, 20);
|
||||
ArrayList<String> phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C);
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (int i = 0; i < pendingIds.size(); i++) {
|
||||
logger.info(calculatedParam.getDataDate()+" 总分区数据:" + pendingIds.size() + "=====》当前第"+(i + 1)+"小分区");
|
||||
List<String> list = pendingIds.get(i);
|
||||
// 获取Future
|
||||
CompletableFuture<Void> future = dataLimitRateAsync.lineDataRate(
|
||||
calculatedParam.getDataDate(),
|
||||
list,
|
||||
phase,
|
||||
overLimitMap,
|
||||
pendingIds.size(),
|
||||
(i + 1),
|
||||
lineParam.getType()
|
||||
);
|
||||
|
||||
futures.add(future);
|
||||
for (List<String> pendingId : pendingIds) {
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
for (String s : pendingId) {
|
||||
CompletableFuture<Void> future = dataLimitRateAsync.lineDataRate(
|
||||
calculatedParam.getDataDate(),
|
||||
Arrays.asList(s),
|
||||
phase,
|
||||
overLimitMap,
|
||||
pendingId.size(),
|
||||
pendingId.size(),
|
||||
lineParam.getType()
|
||||
);
|
||||
futures.add(future);
|
||||
}
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
}
|
||||
// 等待所有任务完成
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
System.err.println("limitRate表转r_stat_limit_rate_d算法开始,执行日期为{},执行完成=====》"+calculatedParam.getDataDate());
|
||||
System.gc();
|
||||
}
|
||||
|
||||
@@ -169,7 +166,8 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
|
||||
|
||||
@Override
|
||||
public void limitQualifiedDayHandler(CalculatedParam calculatedParam) {
|
||||
logger.info("{},r_stat_limit_qualified_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_stat_limit_qualified_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
|
||||
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IDataIntegrityService;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.DataIntegrityFeignClient;
|
||||
import com.njcn.dataProcess.api.DataVFeignClient;
|
||||
import com.njcn.dataProcess.dto.MeasurementCountDTO;
|
||||
@@ -42,8 +43,8 @@ public class IDataIntegrityServiceImpl implements IDataIntegrityService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IDataIntegrityServiceImpl.class);
|
||||
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
@Resource
|
||||
private CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
@Resource
|
||||
@@ -54,7 +55,8 @@ public class IDataIntegrityServiceImpl implements IDataIntegrityService {
|
||||
|
||||
@Override
|
||||
public void dataIntegrity(CalculatedParam<String> calculatedParam) {
|
||||
logger.info("{},integrity表转r_stat_integrity_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}integrity表转r_stat_integrity_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataIntegrityDto> poList = new ArrayList<>();
|
||||
List<String> lineIds = calculatedParam.getIdList();
|
||||
String beginDay = LocalDateTimeUtil.format(
|
||||
|
||||
@@ -294,11 +294,11 @@ public class IDataLimitRateAsyncImpl implements IDataLimitRateAsync {
|
||||
dataLimitRateDetailFeignClient.batchInsertion(detail);
|
||||
}
|
||||
}
|
||||
logger.info(dataDate + " 总分区数据:" + size + "=====》当前第" + i + "小分区已完成!");
|
||||
// logger.info(dataDate + " 总分区数据:" + size + "=====》当前第" + i + "小分区已完成!");
|
||||
result = null;
|
||||
if(i==size){
|
||||
MemorySizeUtil.getNowMemory();
|
||||
}
|
||||
// if(i==size){
|
||||
// MemorySizeUtil.getNowMemory();
|
||||
// }
|
||||
System.gc();
|
||||
|
||||
return CompletableFuture.completedFuture(null);
|
||||
|
||||
@@ -9,6 +9,7 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IDataOnlineRateService;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.DataIntegrityFeignClient;
|
||||
import com.njcn.dataProcess.api.DataOnlineRateFeignClient;
|
||||
import com.njcn.dataProcess.api.DataVFeignClient;
|
||||
@@ -48,8 +49,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class);
|
||||
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
|
||||
private final Integer online = 1;
|
||||
private final Integer offline = 0;
|
||||
@@ -69,7 +70,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
|
||||
|
||||
@Override
|
||||
public void dataOnlineRate(CalculatedParam calculatedParam) {
|
||||
logger.info("{},onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
|
||||
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
|
||||
@@ -247,6 +249,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
|
||||
long differ = DateUtil.between(date, newDate, DateUnit.MINUTE);
|
||||
if (online.equals(type)) {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ;
|
||||
}else{
|
||||
minute = (int) differ;
|
||||
}
|
||||
} else {
|
||||
List<PqsCommunicateDto> communicateDataOld = communicateFeignClient.getRawDataEnd(lineParam).getData();
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IEventDetailService;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.EventDetailFeignClient;
|
||||
import com.njcn.dataProcess.api.RmpEventDetailFeignClient;
|
||||
import com.njcn.dataProcess.dto.RmpEventDetailDTO;
|
||||
@@ -44,8 +45,8 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class IEventDetailServiceImpl implements IEventDetailService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class);
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 10;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
@Resource
|
||||
private RmpEventDetailFeignClient eventDetailFeignClient;
|
||||
@Resource
|
||||
@@ -55,7 +56,8 @@ public class IEventDetailServiceImpl implements IEventDetailService {
|
||||
|
||||
@Override
|
||||
public void dataDayHandle(CalculatedParam<String> calculatedParam) {
|
||||
logger.info("{},r_mp_event_detail_d算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_mp_event_detail_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataEventDetailDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -106,7 +108,8 @@ public class IEventDetailServiceImpl implements IEventDetailService {
|
||||
|
||||
@Override
|
||||
public void dataMonthHandle(CalculatedParam<String> calculatedParam) {
|
||||
logger.info("{},r_mp_event_detail_m算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_mp_event_detail_m算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataEventDetailDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -139,7 +142,8 @@ public class IEventDetailServiceImpl implements IEventDetailService {
|
||||
|
||||
@Override
|
||||
public void dataQuarterHandle(CalculatedParam<String> calculatedParam) {
|
||||
logger.info("{},r_mp_event_detail_q算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_mp_event_detail_q算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataEventDetailDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
@@ -172,7 +176,8 @@ public class IEventDetailServiceImpl implements IEventDetailService {
|
||||
|
||||
@Override
|
||||
public void dataYearHandle(CalculatedParam<String> calculatedParam) {
|
||||
logger.info("{},r_mp_event_detail_y算法开始=====》", LocalDateTime.now());
|
||||
MemorySizeUtil.getNowMemory();
|
||||
logger.info("{},{}r_mp_event_detail_y算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
|
||||
List<DataEventDetailDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
|
||||
@@ -49,8 +49,8 @@ import java.util.stream.Stream;
|
||||
@RequiredArgsConstructor
|
||||
public class PollutionServiceImpl implements IPollutionService {
|
||||
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
|
||||
@Resource
|
||||
private PqDataVerifyFeignClient pqDataVerifyFeignClient;
|
||||
@@ -101,7 +101,7 @@ public class PollutionServiceImpl implements IPollutionService {
|
||||
Map<String, DataPollutionD> interHarmonicVoltageList = getInterharmonicVoltage(lineCountEvaluateParam, limitMap);
|
||||
Map<String, DataPollutionD> voltageFlickerList = getVoltageFlicker(lineCountEvaluateParam, limitMap);
|
||||
|
||||
List<DataPollutionD> pollutionList = processPollutionList(local, idList, dictData, harmonicVoltageList, harmonicCurrentList, frequencyDeviationList, voltageDeviationList,
|
||||
List<DataPollutionD> pollutionList = processPollutionList(local, list, dictData, harmonicVoltageList, harmonicCurrentList, frequencyDeviationList, voltageDeviationList,
|
||||
threePhaseVoltageList, negativeSequenceList, interHarmonicVoltageList, voltageFlickerList);
|
||||
|
||||
if (CollUtil.isNotEmpty(pollutionList)) {
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package com.njcn.dataProcess.service.impl.relation;
|
||||
package com.njcn.algorithm.serviceimpl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.PqReasonableRangeMapper;
|
||||
import com.njcn.dataProcess.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.dataProcess.pojo.po.PqReasonableRange;
|
||||
import com.njcn.dataProcess.service.IPqReasonableRangeService;
|
||||
import com.njcn.algorithm.mapper.PqReasonableRangeMapper;
|
||||
import com.njcn.algorithm.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.algorithm.pojo.param.DataCleanParam;
|
||||
import com.njcn.algorithm.pojo.po.PqReasonableRange;
|
||||
import com.njcn.algorithm.service.line.IPqReasonableRangeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -23,14 +25,18 @@ import java.util.List;
|
||||
* @author xy
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqReasonableRangeServiceImpl extends ServiceImpl<PqReasonableRangeMapper, PqReasonableRange> implements IPqReasonableRangeService {
|
||||
|
||||
@Override
|
||||
public List<PqReasonableRangeDto> getReasonableRangeList(DataCleanParam param) {
|
||||
List<PqReasonableRangeDto> result = new ArrayList<>();
|
||||
LambdaQueryWrapper<PqReasonableRange> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PqReasonableRange::getBelongingSystem,param.getSystemType());
|
||||
if (StrUtil.isNotBlank(param.getSystemType())) {
|
||||
queryWrapper.eq(PqReasonableRange::getBelongingSystem,param.getSystemType());
|
||||
}
|
||||
if(StrUtil.isNotBlank(param.getDataSource())){
|
||||
queryWrapper.eq(PqReasonableRange::getDataSource,param.getDataSource());
|
||||
}
|
||||
@@ -48,4 +54,29 @@ public class PqReasonableRangeServiceImpl extends ServiceImpl<PqReasonableRangeM
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean savePqReasonableRange(PqReasonableRangeDto dto) {
|
||||
PqReasonableRange entity = new PqReasonableRange();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
entity.setState(1);
|
||||
return this.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqReasonableRange(PqReasonableRangeDto dto) {
|
||||
PqReasonableRange entity = new PqReasonableRange();
|
||||
BeanUtils.copyProperties(dto, entity);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqReasonableRange(String id) {
|
||||
PqReasonableRange entity = this.getById(id);
|
||||
if (entity != null) {
|
||||
entity.setState(0);
|
||||
return this.updateById(entity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -65,8 +65,8 @@ import java.util.stream.Collectors;
|
||||
@RequiredArgsConstructor
|
||||
public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService {
|
||||
|
||||
|
||||
private Integer NUM=10;
|
||||
@Value("${line.num:10}")
|
||||
private Integer NUM;
|
||||
@Resource
|
||||
private EventDetailFeignClient eventDetailFeignClient;
|
||||
@Resource
|
||||
|
||||
@@ -196,5 +196,8 @@ public interface InfluxDBTableConstant {
|
||||
String NORMAL = "0";
|
||||
String UN_NORMAL = "1";
|
||||
|
||||
|
||||
/**
|
||||
* 数据清洗标志 0:正常 1:异常
|
||||
*/
|
||||
String ABNORMAL_FLAG = "abnormal_flag";
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ public class PqsCommunicateDto {
|
||||
private Integer type;
|
||||
//是否更新updateTime标志;数据上送更新1,状态翻转不更新0
|
||||
private Integer flag=0;
|
||||
//是否更新、pqs_communicate标志,0更新,1不更新
|
||||
|
||||
private Integer updateCommunicateFlag=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.njcn.dataProcess.controller;
|
||||
|
||||
|
||||
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.param.DataCleanParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.dataProcess.service.IPqReasonableRangeService;
|
||||
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 javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/pqReasonableRange")
|
||||
@Api(tags = "数据清洗标准库")
|
||||
public class PqReasonableRangeController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IPqReasonableRangeService pqReasonableRangeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.QUERY)
|
||||
@PostMapping("/getData")
|
||||
@ApiOperation("按条件获取数据合理范围")
|
||||
public HttpResult<List<PqReasonableRangeDto>> getData(@RequestBody DataCleanParam param) {
|
||||
String methodDescribe = getMethodDescribe("getData");
|
||||
List<PqReasonableRangeDto> list = pqReasonableRangeService.getReasonableRangeList(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,14 +12,16 @@ import com.njcn.device.pq.api.DeviceFeignClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.DevComFlagDTO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDeviceStateVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -30,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Service("RelationLnDataDealServiceImpl")
|
||||
@Slf4j
|
||||
public class LnDataDealServiceImpl implements LnDataDealService {
|
||||
@QueryBean
|
||||
private IDataFlicker dataFlickerQuery;
|
||||
@@ -66,33 +69,61 @@ public class LnDataDealServiceImpl implements LnDataDealService {
|
||||
private LineFeignClient lineFeignClient;
|
||||
@QueryBean
|
||||
private IPqsCommunicate iPqsCommunicate;
|
||||
|
||||
@Resource(name="asyncExecutor")
|
||||
private Executor executor;
|
||||
@Override
|
||||
public void batchInsertion(LnDataDTO lnDataDTO) {
|
||||
dataVService.batchInsertion(lnDataDTO.getDataVList());
|
||||
dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList());
|
||||
dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList());
|
||||
dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList());
|
||||
dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList());
|
||||
dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList());
|
||||
dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList());
|
||||
dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList());
|
||||
dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList());
|
||||
dataIService.batchInsertion(lnDataDTO.getDataIDTOList());
|
||||
dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList());
|
||||
dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList());
|
||||
dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList());
|
||||
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
// 提交每个批量插入任务
|
||||
futures.add(CompletableFuture.runAsync(() -> dataVService.batchInsertion(lnDataDTO.getDataVList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataIService.batchInsertion(lnDataDTO.getDataIDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList()), executor));
|
||||
futures.add(CompletableFuture.runAsync(() -> dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList()), executor));
|
||||
|
||||
// 等待所有任务完成,如果任一任务抛出异常,这里会重新抛出
|
||||
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])).join();
|
||||
|
||||
|
||||
|
||||
// dataVService.batchInsertion(lnDataDTO.getDataVList());
|
||||
// dataHarmrateVQuery.batchInsertion(lnDataDTO.getDataHarmrateVDTOList());
|
||||
// dataFlickerQuery.batchInsertion(lnDataDTO.getDataFlickerDTOList());
|
||||
// dataFlucQuery.batchInsertion(lnDataDTO.getDataFlucDTOList());
|
||||
// dataHarmphasicIQuery.batchInsertion(lnDataDTO.getDataHarmphasicIDTOList());
|
||||
// dataHarmphasicVQuery.batchInsertion(lnDataDTO.getDataHarmphasicVDTOList());
|
||||
// dataHarmpowerPService.batchInsertion(lnDataDTO.getDataHarmpowerPDTOList());
|
||||
// dataHarmpowerQService.batchInsertion(lnDataDTO.getDataHarmpowerQDTOList());
|
||||
// dataHarmpowerSService.batchInsertion(lnDataDTO.getDataHarmpowerSDTOList());
|
||||
// dataIService.batchInsertion(lnDataDTO.getDataIDTOList());
|
||||
// dataInharmIService.batchInsertion(lnDataDTO.getDataInharmIDTOList());
|
||||
// dataInharmVService.batchInsertion(lnDataDTO.getDataInharmVDTOList());
|
||||
// dataPltService.batchInsertion(lnDataDTO.getDataPltDTOList());
|
||||
//更新mysqldevice表最新数据时间
|
||||
|
||||
if(!CollectionUtils.isEmpty(lnDataDTO.getDataVList())){
|
||||
|
||||
List<String> lineIdList = lnDataDTO.getDataVList().stream().map(DataVDTO::getLineid).distinct().collect(Collectors.toList());
|
||||
List<LineDeviceStateVO> data = lineFeignClient.getAllLine(lineIdList).getData();
|
||||
|
||||
|
||||
Map<String, String> map = data.stream().collect(Collectors.toMap(LineDeviceStateVO::getId, temp -> temp.getPids().split(",")[4]));
|
||||
lnDataDTO.getDataVList().forEach(temp->{
|
||||
temp.setDevId(map.get(temp.getLineid()));
|
||||
});
|
||||
Map<String, List<DataVDTO>> collect = lnDataDTO.getDataVList().stream().collect(Collectors.groupingBy(DataVDTO::getDevId));
|
||||
List<CompletableFuture<Void>> updatefutures = new ArrayList<>();
|
||||
|
||||
collect.forEach((temp,dataVDTOList)->{
|
||||
PqsCommunicateDto pqsCommunicateDto = new PqsCommunicateDto();
|
||||
DataVDTO dataVDTO =dataVDTOList.stream().max(Comparator.comparing(DataVDTO::getTimeid)).get();
|
||||
@@ -101,10 +132,12 @@ public class LnDataDealServiceImpl implements LnDataDealService {
|
||||
pqsCommunicateDto.setDevId(temp);
|
||||
pqsCommunicateDto.setType(1);
|
||||
pqsCommunicateDto.setFlag(1);
|
||||
pqsCommunicateDto.setUpdateCommunicateFlag(1);
|
||||
updatefutures.add(CompletableFuture.runAsync(() -> iPqsCommunicate.insertion(pqsCommunicateDto), executor));
|
||||
|
||||
|
||||
iPqsCommunicate.insertion(pqsCommunicateDto);
|
||||
});
|
||||
|
||||
CompletableFuture.allOf(updatefutures.toArray(new CompletableFuture[0])).join();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package com.njcn.dataProcess.service.impl.influxdb;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataFlickerMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlickerRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataFlickerDTO;
|
||||
@@ -19,17 +17,18 @@ import com.njcn.dataProcess.pojo.po.RStatDataFlickerD;
|
||||
import com.njcn.dataProcess.service.IDataFlicker;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -44,19 +43,19 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRelationMapper, RStatDataFlickerD> implements IDataFlicker {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataFlickerMapper dataFlickerMapper;
|
||||
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
|
||||
@Override
|
||||
@@ -80,12 +79,7 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
@Override
|
||||
public List<DataFlickerDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataFlickerDto> result = new ArrayList<>();
|
||||
List<DataFlicker> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
list = getMinuteData(lineParam);
|
||||
}
|
||||
List<DataFlicker> list = getMinuteData(lineParam);
|
||||
list.forEach(item -> {
|
||||
DataFlickerDto dto = new DataFlickerDto();
|
||||
BeanUtils.copyProperties(item, dto);
|
||||
@@ -98,12 +92,7 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataFlicker> dataIList;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
dataIList = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
dataIList = getMinuteData(lineParam);
|
||||
}
|
||||
List<DataFlicker> dataIList = getMinuteData(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(dataIList)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -249,6 +238,13 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
*/
|
||||
public List<DataFlicker> getMinuteData(LineCountEvaluateParam lineParam) {
|
||||
List<DataFlicker> result = new ArrayList<>();
|
||||
List<DataFlicker> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFlicker.class);
|
||||
influxQueryWrapper.regular(DataFlicker::getLineId, lineParam.getLineId())
|
||||
.select(DataFlicker::getLineId)
|
||||
@@ -261,58 +257,24 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
.between(DataFlicker::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataFlicker::getQualityFlag, "0");
|
||||
quality(result, influxQueryWrapper, lineParam);
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataFlicker> getWlMinuteData(LineCountEvaluateParam lineParam) {
|
||||
List<DataFlicker> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFlicker.class);
|
||||
influxQueryWrapper.eq(DataFlicker::getLineId, lineId)
|
||||
.eq(DataFlicker::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataFlicker::getLineId)
|
||||
.select(DataFlicker::getPhasicType)
|
||||
.between(DataFlicker::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataFlicker::getQualityFlag, "0");
|
||||
if (CollUtil.isNotEmpty(lineParam.getPhasicType())) {
|
||||
influxQueryWrapper.regular(DataFlicker::getPhasicType, lineParam.getPhasicType());
|
||||
}
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataFlicker::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataFlicker::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//相电压电压变动幅度
|
||||
influxQueryWrapper.select("Pq_Fluct","fluc");
|
||||
//相电压长时闪变
|
||||
influxQueryWrapper.select("Pq_Plt","plt");
|
||||
//相电压短时闪变
|
||||
influxQueryWrapper.select("Pq_Pst","pst");
|
||||
} else {
|
||||
//线电压电压变动幅度
|
||||
influxQueryWrapper.select("Pq_LFluct","fluc");
|
||||
//相电压长时闪变
|
||||
influxQueryWrapper.select("Pq_LPlt","plt");
|
||||
//相电压短时闪变
|
||||
influxQueryWrapper.select("Pq_LPst","pst");
|
||||
}
|
||||
result.addAll(dataFlickerMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataFlicker>> lineMap = result.stream().collect(Collectors.groupingBy(DataFlicker::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataFlicker> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -320,6 +282,6 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.njcn.dataProcess.service.impl.influxdb;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataFlucMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataFlucRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataFlucDTO;
|
||||
@@ -17,17 +15,18 @@ import com.njcn.dataProcess.pojo.po.RStatDataFlucD;
|
||||
import com.njcn.dataProcess.service.IDataFluc;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -42,20 +41,19 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMapper, RStatDataFlucD> implements IDataFluc {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataFlucMapper dataFlucMapper;
|
||||
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
@Override
|
||||
public void batchInsertion(List<DataFlucDTO> dataFlucDTOList) {
|
||||
@@ -78,12 +76,7 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
@Override
|
||||
public List<DataFlucDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataFlucDto> result = new ArrayList<>();
|
||||
List<DataFluc> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataFluc> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataFlucDto dto = new DataFlucDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -96,12 +89,7 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataFluc> dataIList;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
dataIList = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
dataIList = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataFluc> dataIList = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(dataIList)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -168,6 +156,13 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
public List<DataFluc> getMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataFluc> dataList;
|
||||
List<DataFluc> result = new ArrayList<>();
|
||||
List<DataFluc> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFluc.class);
|
||||
influxQueryWrapper.regular(DataFluc::getLineId, lineList)
|
||||
.select(DataFluc::getLineId)
|
||||
@@ -215,47 +210,24 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataFluc> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
//todo FLUCCF电压波动频度原先oracle表存储的是0,写死的,这边暂不取值
|
||||
List<DataFluc> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataFluc.class);
|
||||
influxQueryWrapper.eq(DataFluc::getLineId, lineId)
|
||||
.eq(DataFluc::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataFluc::getLineId)
|
||||
.select(DataFluc::getPhasicType)
|
||||
.between(DataFluc::getTime, startTime, endTime)
|
||||
.eq(DataFluc::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataFluc::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataFluc::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//相电压电压变动幅度
|
||||
influxQueryWrapper.select("Pq_Fluct","fluc");
|
||||
} else {
|
||||
//线电压电压变动幅度
|
||||
influxQueryWrapper.select("Pq_LFluct","fluc");
|
||||
}
|
||||
result.addAll(dataFlucMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataFluc>> lineMap = result.stream().collect(Collectors.groupingBy(DataFluc::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataFluc> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -263,7 +235,7 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmRateIMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateIRelationMapper;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
@@ -28,7 +24,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -40,10 +35,6 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
@Resource
|
||||
private DataHarmRateIMapper dataHarmRateIMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -55,12 +46,7 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
|
||||
@Override
|
||||
public List<DataHarmRateIDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmRateIDto> result = new ArrayList<>();
|
||||
List<DataHarmrateI> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmrateI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataHarmRateIDto dto = new DataHarmRateIDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -73,12 +59,7 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmrateI> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmrateI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -246,48 +227,13 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmrateI> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataHarmrateI> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmRI_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.eq(DataHarmrateI::getLineId, lineId)
|
||||
.eq(DataHarmrateI::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmrateI::getLineId)
|
||||
.select(DataHarmrateI::getPhasicType)
|
||||
.select(DataHarmrateI::getValueType)
|
||||
//电流基波有效值
|
||||
.select("Pq_RmsFundI_","i_1")
|
||||
.between(DataHarmrateI::getTime, startTime, endTime)
|
||||
.eq(DataHarmrateI::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmrateI::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmrateI::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataHarmRateIMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2,17 +2,16 @@ package com.njcn.dataProcess.service.impl.influxdb;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.constant.InfluxDBTableConstant;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmRateVMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateVRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmrateVDTO;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.po.influx.DataFlicker;
|
||||
import com.njcn.dataProcess.po.influx.DataHarmrateV;
|
||||
import com.njcn.dataProcess.po.influx.DataV;
|
||||
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
|
||||
@@ -23,17 +22,18 @@ import com.njcn.dataProcess.service.IDataHarmRateV;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -42,31 +42,25 @@ import java.util.stream.Collectors;
|
||||
@Service("InfluxdbDataHarmRateVImpl")
|
||||
@RequiredArgsConstructor
|
||||
public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateVRelationMapper, RStatDataHarmRateVD> implements IDataHarmRateV {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataHarmRateVMapper dataHarmRateVMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
@Override
|
||||
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmDto> result = new ArrayList<>();
|
||||
List<DataHarmrateV> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
list = getMinuteData(lineParam);;
|
||||
}
|
||||
List<DataHarmrateV> list = getMinuteData(lineParam);
|
||||
list.forEach(item->{
|
||||
DataHarmDto dto = new DataHarmDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -97,12 +91,7 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmrateV> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
data = getMinuteData(lineParam);;
|
||||
}
|
||||
List<DataHarmrateV> data = getMinuteData(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -264,6 +253,13 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
public List<DataHarmrateV> getMinuteData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmrateV> dataList;
|
||||
List<DataHarmrateV> result = new ArrayList<>();
|
||||
List<DataHarmrateV> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmrateV::getLineId, lineParam.getLineId())
|
||||
@@ -314,51 +310,24 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmrateV> getWlMinuteData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmrateV> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
influxQueryWrapper.eq(DataHarmrateV::getLineId, lineId)
|
||||
.eq(DataHarmrateV::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmrateV::getLineId)
|
||||
.select(DataHarmrateV::getPhasicType)
|
||||
.select(DataHarmrateV::getValueType)
|
||||
.between(DataHarmrateV::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataHarmrateV::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmrateV::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmrateV::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//相电压基波有效值
|
||||
influxQueryWrapper.select("Pq_RmsFundU_","v_1");
|
||||
//2-50次 相电压谐波含有率
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmU_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
} else {
|
||||
//线电压基波有效值
|
||||
influxQueryWrapper.select("Pq_RmsFundLU_","v_1");
|
||||
//2-50次 线电压谐波含有率
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLU_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
}
|
||||
result.addAll(dataHarmRateVMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataHarmrateV>> lineMap = result.stream().collect(Collectors.groupingBy(DataHarmrateV::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataHarmrateV> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -366,7 +335,6 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmphasicIMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPhasicIRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmphasicIDTO;
|
||||
@@ -25,12 +21,10 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -46,10 +40,6 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
private final DataHarmphasicIMapper dataHarmphasicIMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -78,12 +68,7 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
@Override
|
||||
public List<DataHarmPhasicIDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmPhasicIDto> result = new ArrayList<>();
|
||||
List<DataHarmphasicI> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmphasicI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataHarmPhasicIDto dto = new DataHarmPhasicIDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -96,12 +81,7 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmphasicI> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmphasicI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -269,50 +249,15 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmphasicI> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap,Boolean dataType) {
|
||||
List<DataHarmphasicI> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicI.class);
|
||||
//谐波电流幅值相角
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmIAng_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.eq(DataHarmphasicI::getLineId, lineId)
|
||||
.eq(DataHarmphasicI::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmphasicI::getLineId)
|
||||
.select(DataHarmphasicI::getPhasicType)
|
||||
.select(DataHarmphasicI::getValueType)
|
||||
//基波电流相角
|
||||
.select("Pq_FundIAng","i_1")
|
||||
.between(DataHarmphasicI::getTime, startTime, endTime)
|
||||
.eq(DataHarmphasicI::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmphasicI::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmphasicI::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataHarmphasicIMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,17 +2,14 @@ package com.njcn.dataProcess.service.impl.influxdb;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmphasicVMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPhasicVRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmphasicVDTO;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.po.influx.DataHarmphasicI;
|
||||
import com.njcn.dataProcess.po.influx.DataHarmphasicV;
|
||||
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
|
||||
import com.njcn.dataProcess.pojo.dto.DataHarmDto;
|
||||
@@ -22,17 +19,18 @@ import com.njcn.dataProcess.service.IDataHarmphasicV;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,19 +45,19 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPhasicVRelationMapper, RStatDataHarmPhasicVD> implements IDataHarmphasicV {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataHarmphasicVMapper dataHarmphasicVMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
|
||||
@Override
|
||||
@@ -83,12 +81,7 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
@Override
|
||||
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmDto> result = new ArrayList<>();
|
||||
List<DataHarmphasicV> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmphasicV> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataHarmDto dto = new DataHarmDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -101,12 +94,7 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmphasicV> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmphasicV> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -227,6 +215,13 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
public List<DataHarmphasicV> getMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataHarmphasicV> dataList;
|
||||
List<DataHarmphasicV> result = new ArrayList<>();
|
||||
List<DataHarmphasicV> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmphasicV::getLineId, lineList)
|
||||
@@ -274,52 +269,24 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public List<DataHarmphasicV> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataHarmphasicV> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class);
|
||||
influxQueryWrapper.eq(DataHarmphasicV::getLineId, lineId)
|
||||
.eq(DataHarmphasicV::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmphasicV::getLineId)
|
||||
.select(DataHarmphasicV::getPhasicType)
|
||||
.select(DataHarmphasicV::getValueType)
|
||||
.between(DataHarmphasicV::getTime, startTime, endTime)
|
||||
.eq(DataHarmphasicV::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmphasicV::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmphasicV::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//相电压基波有效值相角
|
||||
influxQueryWrapper.select("Pq_FundUAng","v_1");
|
||||
//2-50次 相电压谐波相角
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmUAng_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
} else {
|
||||
//线电压基波有效值相角
|
||||
influxQueryWrapper.select("Pq_FundLUAng","v_1");
|
||||
//2-50次 线电压谐波相角
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLUAng_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
}
|
||||
result.addAll(dataHarmphasicVMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataHarmphasicV>> lineMap = result.stream().collect(Collectors.groupingBy(DataHarmphasicV::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataHarmphasicV> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -327,6 +294,6 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmpowerPMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerPRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmpowerPDTO;
|
||||
@@ -26,13 +22,11 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,12 +41,7 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowerPRelationMapper, RStatDataHarmPowerPD> implements IDataHarmpowerP {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataHarmpowerPMapper dataHarmpowerPMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -82,12 +71,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<DataPowerPDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataPowerPDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerP> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerP> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataPowerPDto dto = new DataPowerPDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -100,12 +84,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerP> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerP> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -261,65 +240,13 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmpowerP> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataHarmpowerP> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class);
|
||||
//A、B、C谐波有功功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmP_", "p_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
//三相总 谐波有功功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTP_", "totP_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
InfluxQueryWrapper eq = influxQueryWrapper.eq(DataHarmpowerP::getLineId, lineId)
|
||||
.eq(DataHarmpowerP::getProcess, Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmpowerP::getLineId)
|
||||
.select(DataHarmpowerP::getPhasicType)
|
||||
.select(DataHarmpowerP::getValueType)
|
||||
//位移功率因数
|
||||
.select("Pq_DF", "df")
|
||||
//视在功率因素
|
||||
.select("Pq_PF", "pf")
|
||||
//A、B、C三相有功功率
|
||||
.select("Pq_P", "p")
|
||||
//基波有功功率
|
||||
.select("Pq_FundP", "p_1")
|
||||
//三相总视在功率因数
|
||||
.select("Pq_TotPF", "totPf")
|
||||
//三相总位移功率因数
|
||||
.select("Pq_TotDF", "totDf")
|
||||
//三相总功率因数
|
||||
.select("Pq_TotP", "totP")
|
||||
//三相总基波有功功率
|
||||
.select("Pq_TotHarmP", "totP1")
|
||||
.between(DataHarmpowerP::getTime, startTime, endTime)
|
||||
.eq(DataHarmpowerP::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmpowerP::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmpowerP::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataHarmpowerPMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmpowerQMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerQRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmpowerQDTO;
|
||||
@@ -25,13 +21,11 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,10 +41,6 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
private final DataHarmpowerQMapper dataHarmpowerQMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -80,12 +70,7 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<DataHarmPowerQDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmPowerQDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerQ> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerQ> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataHarmPowerQDto dto = new DataHarmPowerQDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -98,12 +83,7 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerQ> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerQ> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -125,7 +105,6 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
valueTypeMap.forEach((valueType,valueTypeList)->{
|
||||
CommonMinuteDto.ValueType value = new CommonMinuteDto.ValueType();
|
||||
value.setValueType(valueType);
|
||||
|
||||
List<List<Double>> lists;
|
||||
if (Objects.equals(phasicType, "T") && Objects.equals(lineParam.getType(), 2)) {
|
||||
lists = extractDataLists(valueTypeList, "Tot");
|
||||
@@ -254,57 +233,13 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmpowerQ> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataHarmpowerQ> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class);
|
||||
//A、B、C谐波无功功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmQ_", "q_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
//三相总 谐波有功功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTQ_", "totQ_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.eq(DataHarmpowerQ::getLineId, lineId)
|
||||
.eq(DataHarmpowerQ::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmpowerQ::getLineId)
|
||||
.select(DataHarmpowerQ::getPhasicType)
|
||||
.select(DataHarmpowerQ::getValueType)
|
||||
//A、B、C三相无功功率
|
||||
.select("Pq_Q", "q")
|
||||
//基波无功功率
|
||||
.select("Pq_FundQ","q_1")
|
||||
//总无功功率
|
||||
.select("Pq_TotQ","totQ")
|
||||
//基波无功功率(T)
|
||||
.select("Pq_TotHarmQ","totQ1")
|
||||
.between(DataHarmpowerQ::getTime, startTime, endTime)
|
||||
.eq(DataHarmpowerQ::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmpowerQ::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmpowerQ::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataHarmpowerQMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataHarmpowerSMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmPowerSRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataHarmpowerSDTO;
|
||||
@@ -25,13 +21,11 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -47,10 +41,6 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
private final DataHarmpowerSMapper dataHarmpowerSMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -80,12 +70,7 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<DataHarmPowerSDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmPowerSDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerS> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerS> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataHarmPowerSDto dto = new DataHarmPowerSDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -98,12 +83,7 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataHarmpowerS> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataHarmpowerS> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -253,59 +233,14 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataHarmpowerS> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap,Boolean dataType) {
|
||||
List<DataHarmpowerS> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class);
|
||||
//A、B、C谐波视在功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmS_", "s_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
//三相总 谐波视在功率有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmTS_", "totS_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.eq(DataHarmpowerS::getLineId, lineId)
|
||||
.eq(DataHarmpowerS::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataHarmpowerS::getLineId)
|
||||
.select(DataHarmpowerS::getPhasicType)
|
||||
.select(DataHarmpowerS::getValueType)
|
||||
//A、B、C视在功率
|
||||
.select("Pq_S","s")
|
||||
//基波视在功率
|
||||
.select("Pq_FundS","s_1")
|
||||
//总视在功率
|
||||
.select("Pq_TotS","totS")
|
||||
//基波视在功率(T)
|
||||
.select("Pq_TotHarmS","totS1")
|
||||
.between(DataHarmpowerS::getTime, startTime, endTime)
|
||||
.eq(DataHarmpowerS::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataHarmpowerS::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataHarmpowerS::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataHarmpowerSMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.constant.InfluxDBTableConstant;
|
||||
import com.njcn.dataProcess.dao.imapper.DataIMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataIRelationMapper;
|
||||
@@ -26,12 +22,10 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -49,11 +43,6 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
|
||||
private final DataIMapper dataIMapper;
|
||||
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
@@ -82,12 +71,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
@Override
|
||||
public List<DataIDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataIDto> result = new ArrayList<>();
|
||||
List<DataI> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteDataI(lineParam);
|
||||
} else {
|
||||
list = getMinuteDataI(lineParam);
|
||||
}
|
||||
List<DataI> list = getMinuteDataI(lineParam);;
|
||||
list.forEach(item->{
|
||||
DataIDto dto = new DataIDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -100,12 +84,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataI> dataIList;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
dataIList = getWlMinuteDataI(lineParam);
|
||||
} else {
|
||||
dataIList = getMinuteDataI(lineParam);
|
||||
}
|
||||
List<DataI> dataIList = getMinuteDataI(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(dataIList)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -314,65 +293,13 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataI> getWlMinuteDataI(LineCountEvaluateParam lineParam) {
|
||||
List<DataI> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
//2-50次 谐波电流有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmI_", "i_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.eq(DataI::getLineId, lineId)
|
||||
.eq(DataI::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataI::getLineId)
|
||||
.select(DataI::getPhasicType)
|
||||
.select(DataI::getValueType)
|
||||
//电流负序
|
||||
.select("Pq_SeqNegI","i_neg")
|
||||
//电流正序
|
||||
.select("Pq_SeqPosI","i_pos")
|
||||
//电流总谐波畸变率
|
||||
.select("Pq_ThdI","i_thd")
|
||||
//电流负序不平衡度
|
||||
.select("Pq_UnbalNegI","i_unbalance")
|
||||
//电流零序
|
||||
.select("Pq_SeqZeroI","i_zero")
|
||||
//电流总有效值
|
||||
.select("Pq_RmsI","rms")
|
||||
//电流基波有效值
|
||||
.select("Pq_RmsFundI","i_1")
|
||||
.between(DataI::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataI::getQualityFlag, "0");
|
||||
if (CollUtil.isNotEmpty(lineParam.getPhasicType())) {
|
||||
influxQueryWrapper.regular(DataI::getPhasicType, lineParam.getPhasicType());
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataI::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataI::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
result.addAll(dataIMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataInharmIMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataInHarmIRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataInharmIDTO;
|
||||
@@ -25,12 +21,10 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -46,10 +40,6 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
|
||||
private final DataInharmIMapper dataInharmIMapper;
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -79,12 +69,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
@Override
|
||||
public List<DataInHarmIDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataInHarmIDto> result = new ArrayList<>();
|
||||
List<DataInharmI> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataInharmI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
list.forEach(item->{
|
||||
DataInHarmIDto dto = new DataInHarmIDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -97,12 +82,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataInharmI> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
} else {
|
||||
data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
}
|
||||
List<DataInharmI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -270,49 +250,14 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataInharmI> getWlMinuteData(List<String> lineList, String startTime, String endTime, Map<String,List<String>> timeMap, Boolean dataType) {
|
||||
List<DataInharmI> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineList).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineList.forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmI.class);
|
||||
//2-50次 间谐波电流有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmIAmp_", "i_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.eq(DataInharmI::getLineId, lineId)
|
||||
.eq(DataInharmI::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataInharmI::getLineId)
|
||||
.select(DataInharmI::getPhasicType)
|
||||
.select(DataInharmI::getValueType)
|
||||
.between(DataInharmI::getTime, startTime, endTime)
|
||||
.eq(DataInharmI::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataInharmI::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataInharmI::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
result.addAll(dataInharmIMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataInharmVMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataInHarmVRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataInharmVDTO;
|
||||
@@ -26,12 +22,10 @@ import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -47,12 +41,7 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRelationMapper, RStatDataInHarmVD> implements IDataInharmV {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataInharmVMapper dataInharmVMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
@@ -81,12 +70,7 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
|
||||
@Override
|
||||
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmDto> result = new ArrayList<>();
|
||||
List<DataInharmV> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
list = getMinuteData(lineParam);
|
||||
}
|
||||
List<DataInharmV> list = getMinuteData(lineParam);
|
||||
list.forEach(item->{
|
||||
DataHarmDto dto = new DataHarmDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -99,12 +83,7 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataInharmV> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteData(lineParam);
|
||||
} else {
|
||||
data = getMinuteData(lineParam);
|
||||
}
|
||||
List<DataInharmV> data = getMinuteData(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -275,56 +254,14 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataInharmV> getWlMinuteData(LineCountEvaluateParam lineParam) {
|
||||
List<DataInharmV> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmV.class);
|
||||
//2-50次 间谐波电流有效值
|
||||
influxQueryWrapper.eq(DataInharmV::getLineId, lineId)
|
||||
.eq(DataInharmV::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataInharmV::getLineId)
|
||||
.select(DataInharmV::getPhasicType)
|
||||
.select(DataInharmV::getValueType)
|
||||
.between(DataInharmV::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataInharmV::getQualityFlag, "0");
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataInharmV::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataInharmV::getCldid,Integer.toString(po.getLineNo()));
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//0.5-49.5次 间谐波相电压有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmURV_", "v_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
} else {
|
||||
//0.5-49.5次 间谐波线电压有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_InHarmLURV_", "v_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
}
|
||||
result.addAll(dataInharmVMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.njcn.dataProcess.service.impl.influxdb;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.dao.imapper.DataPltMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.RStatDataPltRelationMapper;
|
||||
import com.njcn.dataProcess.dto.DataPltDTO;
|
||||
@@ -19,17 +17,18 @@ import com.njcn.dataProcess.pojo.po.RStatDataPltD;
|
||||
import com.njcn.dataProcess.service.IDataPlt;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -44,19 +43,19 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapper, RStatDataPltD> implements IDataPlt {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
|
||||
private final DataPltMapper dataPltMapper;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
@Override
|
||||
public void batchInsertion(List<DataPltDTO> dataPltDTOList) {
|
||||
@@ -79,12 +78,7 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
@Override
|
||||
public List<DataPltDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataPltDto> result = new ArrayList<>();
|
||||
List<DataPlt> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteDataPlt(lineParam);
|
||||
} else {
|
||||
list = getMinuteDataPlt(lineParam);
|
||||
}
|
||||
List<DataPlt> list = getMinuteDataPlt(lineParam);
|
||||
list.forEach(item->{
|
||||
DataPltDto dto = new DataPltDto();
|
||||
BeanUtils.copyProperties(item,dto);
|
||||
@@ -97,12 +91,7 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataPlt> data;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
data = getWlMinuteDataPlt(lineParam);
|
||||
} else {
|
||||
data = getMinuteDataPlt(lineParam);
|
||||
}
|
||||
List<DataPlt> data = getMinuteDataPlt(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -173,6 +162,13 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
public List<DataPlt> getMinuteDataPlt(LineCountEvaluateParam lineParam) {
|
||||
List<DataPlt> dataList;
|
||||
List<DataPlt> result = new ArrayList<>();
|
||||
List<DataPlt> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataPlt.class);
|
||||
influxQueryWrapper.regular(DataPlt::getLineId, lineParam.getLineId())
|
||||
.select(DataPlt::getLineId)
|
||||
@@ -222,51 +218,24 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
result.addAll(dataList);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<DataPlt> getWlMinuteDataPlt(LineCountEvaluateParam lineParam) {
|
||||
List<DataPlt> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataPlt.class);
|
||||
influxQueryWrapper.eq(DataPlt::getLineId, lineId)
|
||||
.eq(DataPlt::getProcess,Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataPlt::getLineId)
|
||||
.select(DataPlt::getPhasicType)
|
||||
.select(DataPlt::getValueType)
|
||||
.between(DataPlt::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataPlt::getQualityFlag, "0");
|
||||
if (CollUtil.isNotEmpty(lineParam.getPhasicType())) {
|
||||
influxQueryWrapper.regular(DataPlt::getPhasicType, lineParam.getPhasicType());
|
||||
}
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataPlt::getCldid,Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataPlt::getCldid,Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(),0)) {
|
||||
//相电压长时闪变
|
||||
influxQueryWrapper.select("Pq_Plt","plt");
|
||||
} else {
|
||||
//线电压长时闪变
|
||||
influxQueryWrapper.select("Pq_LPlt","plt");
|
||||
}
|
||||
result.addAll(dataPltMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataPlt>> lineMap = result.stream().collect(Collectors.groupingBy(DataPlt::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataPlt> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -274,7 +243,6 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,12 +4,10 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.utils.HarmonicTimesUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.dataProcess.constant.InfluxDBTableConstant;
|
||||
import com.njcn.dataProcess.constant.PhaseType;
|
||||
import com.njcn.dataProcess.dao.imapper.DataVMapper;
|
||||
@@ -28,12 +26,14 @@ import com.njcn.dataProcess.service.IDataV;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
@@ -51,20 +51,20 @@ import java.util.stream.Collectors;
|
||||
public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper, RStatDataVD> implements IDataV {
|
||||
|
||||
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault());
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private static final Map<String, String> PHASE_MAPPING = new HashMap<String, String>() {{
|
||||
put("AB", "A");
|
||||
put("BC", "B");
|
||||
put("CA", "C");
|
||||
put("M", "T");
|
||||
}};
|
||||
|
||||
@Resource
|
||||
private DataVMapper dataVMapper;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
private static final Set<String> LINE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("AB", "BC", "CA", "T")));
|
||||
private static final Set<String> PHASE_VOLTAGE_TYPES =
|
||||
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("A", "B", "C", "T")));
|
||||
|
||||
/**
|
||||
* 注意:influxdb不推荐采用in函数的方式批量查询监测点的数据,效率很低,容易造成崩溃,故每次单测点查询
|
||||
@@ -137,12 +137,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
@Override
|
||||
public List<DataVDto> getRawData(LineCountEvaluateParam lineParam) {
|
||||
List<DataVDto> result = new ArrayList<>();
|
||||
List<DataV> list;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
list = getWlMinuteDataV(lineParam);
|
||||
} else {
|
||||
list = getMinuteDataV(lineParam);
|
||||
}
|
||||
List<DataV> list = getMinuteDataV(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
list.forEach(item -> {
|
||||
DataVDto dto = new DataVDto();
|
||||
@@ -226,12 +221,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
@Override
|
||||
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
|
||||
List<CommonMinuteDto> result = new ArrayList<>();
|
||||
List<DataV> dataVList;
|
||||
if (Objects.equals(lineParam.getType(), 2)) {
|
||||
dataVList = getWlMinuteDataV(lineParam);
|
||||
} else {
|
||||
dataVList = getMinuteDataV(lineParam);
|
||||
}
|
||||
List<DataV> dataVList = getMinuteDataV(lineParam);
|
||||
if (CollectionUtil.isNotEmpty(dataVList)) {
|
||||
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
|
||||
//以监测点分组
|
||||
@@ -456,6 +446,13 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
*/
|
||||
public List<DataV> getMinuteDataV(LineCountEvaluateParam lineParam) {
|
||||
List<DataV> result = new ArrayList<>();
|
||||
List<DataV> data = new ArrayList<>();
|
||||
//获取监测点、接线方式数据
|
||||
Type type = new TypeToken<Map<String, Integer>>(){}.getType();
|
||||
Map<String, Integer> map = new Gson().fromJson(
|
||||
String.valueOf(redisUtil.getObjectByKey("wlLineDetail")),
|
||||
type
|
||||
);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataV::getLineId, lineParam.getLineId())
|
||||
@@ -481,83 +478,47 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
influxQueryWrapper.regular(DataV::getPhasicType, lineParam.getPhasicType());
|
||||
}
|
||||
quality(result, influxQueryWrapper, lineParam);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按监测点集合、时间条件获取dataV分钟数据
|
||||
* timeMap参数来判断是否进行数据处理 timeMap为空则不进行数据处理
|
||||
*/
|
||||
public List<DataV> getWlMinuteDataV(LineCountEvaluateParam lineParam) {
|
||||
List<DataV> result = new ArrayList<>();
|
||||
if (CollectionUtil.isNotEmpty(lineParam.getLineId())) {
|
||||
//fixme 这边查询的数据可以缓存起来,因为日表计算时可以使用
|
||||
//获取监测点信息
|
||||
List<CsLinePO> line = csLineFeignClient.queryLineById(lineParam.getLineId()).getData();
|
||||
Map<String, CsLinePO> lineMap = line.stream().collect(Collectors.toMap(CsLinePO::getLineId, Function.identity()));
|
||||
//获取设备信息
|
||||
List<String> devList = line.stream().map(CsLinePO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryDTO> dev = equipmentFeignClient.queryDeviceById(devList).getData();
|
||||
Map<String, CsEquipmentDeliveryDTO> devsMap = dev.stream().collect(Collectors.toMap(CsEquipmentDeliveryDTO::getId, Function.identity()));
|
||||
lineParam.getLineId().forEach(lineId -> {
|
||||
String devId = lineMap.get(lineId).getDeviceId();
|
||||
CsLinePO po = lineMap.get(lineId);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
|
||||
influxQueryWrapper.eq(DataV::getLineId, lineId)
|
||||
.eq(DataV::getProcess, Integer.toString(devsMap.get(devId).getProcess()))
|
||||
.select(DataV::getLineId)
|
||||
.select(DataV::getPhasicType)
|
||||
.select(DataV::getValueType)
|
||||
//频率
|
||||
.select("Pq_Freq", "freq")
|
||||
//频率偏差
|
||||
.select("Pq_FreqDev", "freq_dev")
|
||||
//相电压有效值
|
||||
.select("Pq_RmsU", "rms")
|
||||
//线电压有效值
|
||||
.select("Pq_RmsLU", "rms_lvr")
|
||||
//电压负序
|
||||
.select("Pq_SeqNegU", "v_neg")
|
||||
//电压正序
|
||||
.select("Pq_SeqPosU", "v_pos")
|
||||
//电压零序
|
||||
.select("Pq_SeqZeroU", "v_zero")
|
||||
//电压负序不平衡度
|
||||
.select("Pq_UnbalNegU", "v_unbalance")
|
||||
.between(DataV::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.eq(DataV::getQualityFlag, "0");
|
||||
if (CollUtil.isNotEmpty(lineParam.getPhasicType())) {
|
||||
influxQueryWrapper.regular(DataV::getPhasicType, lineParam.getPhasicType());
|
||||
}
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getClDid()));
|
||||
} else {
|
||||
influxQueryWrapper.eq(DataV::getCldid, Integer.toString(po.getLineNo()));
|
||||
}
|
||||
//判断接线方式 (0-星型 1-角型 2-V型) 星型是相电压 角型或者v型是线电压
|
||||
if (Objects.equals(po.getConType(), 0)) {
|
||||
//相电压偏差
|
||||
influxQueryWrapper.select("Pq_UDev", "vu_dev");
|
||||
//相电压谐波总畸变率
|
||||
influxQueryWrapper.select("Pq_ThdU", "v_thd");
|
||||
//相电压基波有效值
|
||||
influxQueryWrapper.select("Pq_RmsFundU", "v_1");
|
||||
//2-50次 相电压谐波有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
} else {
|
||||
//线电压偏差
|
||||
influxQueryWrapper.select("Pq_LUDev", "vu_dev");
|
||||
//线电压谐波总畸变率
|
||||
influxQueryWrapper.select("Pq_ThdLU", "v_thd");
|
||||
//线电压基波有效值
|
||||
influxQueryWrapper.select("Pq_RmsFundLU", "v_1");
|
||||
//2-50次 线电压谐波有效值
|
||||
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmLUV_", "v_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
}
|
||||
result.addAll(dataVMapper.selectByQueryWrapper(influxQueryWrapper));
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result.forEach(item -> {
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
if (!Objects.isNull(map)) {
|
||||
//现根据监测点分组,然后根据接线方式排除多于数据,在修改相别
|
||||
Map<String, List<DataV>> lineMap = result.stream().collect(Collectors.groupingBy(DataV::getLineId));
|
||||
lineMap.forEach((k,v)->{
|
||||
if (Objects.isNull(map.get(k))) {
|
||||
return;
|
||||
}
|
||||
//这边需要特殊处理下,将线电压数据赋值
|
||||
Map<String, DataV> lineVoltageIndex = v.stream()
|
||||
.filter(d -> PHASE_MAPPING.containsKey(d.getPhasicType()))
|
||||
.filter(d -> d.getRmsLvr() != null)
|
||||
.collect(Collectors.toMap(
|
||||
d -> buildKey(d.getTime(), d.getValueType(), d.getPhasicType()),
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
v.stream()
|
||||
.filter(d -> PHASE_VOLTAGE_TYPES.contains(d.getPhasicType()))
|
||||
.forEach(phaseData -> {
|
||||
// 根据当前相电压反查对应的线电压相别
|
||||
String targetLinePhasic = getReverseLinePhasic(phaseData.getPhasicType());
|
||||
if (targetLinePhasic == null) {
|
||||
return;
|
||||
}
|
||||
String key = buildKey(phaseData.getTime(), phaseData.getValueType(), targetLinePhasic);
|
||||
DataV matchedLineData = lineVoltageIndex.get(key);
|
||||
if (matchedLineData != null && matchedLineData.getRmsLvr() != null) {
|
||||
phaseData.setRmsLvr(matchedLineData.getRmsLvr());
|
||||
}
|
||||
});
|
||||
Integer conType = map.get(k);
|
||||
Set<String> validPhasicTypes = (conType != 0) ? LINE_VOLTAGE_TYPES : PHASE_VOLTAGE_TYPES;
|
||||
List<DataV> result2 = v.stream().filter(item -> validPhasicTypes.contains(item.getPhasicType())).collect(Collectors.toList());
|
||||
data.addAll(result2);
|
||||
});
|
||||
} else {
|
||||
data.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(data)) {
|
||||
data.forEach(item -> {
|
||||
String newType = PHASE_MAPPING.get(item.getPhasicType());
|
||||
if (newType != null) {
|
||||
item.setPhasicType(newType);
|
||||
@@ -565,7 +526,27 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return data;
|
||||
}
|
||||
|
||||
private static String buildKey(Object time, Object valueType, Object phasicType) {
|
||||
return time + "|" + valueType + "|" + phasicType;
|
||||
}
|
||||
|
||||
private static String getReverseLinePhasic(String phaseType) {
|
||||
if (phaseType == null) {
|
||||
return null;
|
||||
}
|
||||
switch (phaseType) {
|
||||
case "A":
|
||||
return "AB";
|
||||
case "B":
|
||||
return "BC";
|
||||
case "C":
|
||||
return "CA";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void quality(List<DataV> result, InfluxQueryWrapper influxQueryWrapper, LineCountEvaluateParam lineParam) {
|
||||
|
||||
@@ -110,23 +110,32 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate {
|
||||
|
||||
@Override
|
||||
public void insertion(PqsCommunicateDto pqsCommunicateDto) {
|
||||
// log.info("进出Influxdb实现类");
|
||||
|
||||
//获取最新一条数据
|
||||
PqsCommunicate dto = new PqsCommunicate();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1);
|
||||
List<PqsCommunicate> pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
if(Objects.equals(pqsCommunicateDto.getUpdateCommunicateFlag(),0)){
|
||||
|
||||
|
||||
PqsCommunicate dto = new PqsCommunicate();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
influxQueryWrapper.eq(PqsCommunicate::getDevId,pqsCommunicateDto.getDevId()).timeDesc().limit(1);
|
||||
List<PqsCommunicate> pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
|
||||
PqsCommunicate pqsCommunicate = new PqsCommunicate();
|
||||
pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant());
|
||||
pqsCommunicate.setDevId(pqsCommunicateDto.getDevId());
|
||||
pqsCommunicate.setType(pqsCommunicateDto.getType());
|
||||
//如果不存数据或者状态不一样则插入数据
|
||||
//可能存在掉线后最后一组数据还未入库,添加时间判断
|
||||
if(CollectionUtils.isEmpty(pqsCommunicates)|| (!Objects.equals( pqsCommunicates.get(0).getType(),pqsCommunicateDto.getType())&&pqsCommunicates.get(0).getTime().isBefore(pqsCommunicate.getTime()))){
|
||||
pqsCommunicateMapper.insertOne(pqsCommunicate);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
PqsCommunicate pqsCommunicate = new PqsCommunicate();
|
||||
pqsCommunicate.setTime(LocalDateTime.parse(pqsCommunicateDto.getTime(), DATE_TIME_FORMATTER).atZone(ZoneId.systemDefault()).toInstant());
|
||||
pqsCommunicate.setDevId(pqsCommunicateDto.getDevId());
|
||||
pqsCommunicate.setType(pqsCommunicateDto.getType());
|
||||
//如果不存数据或者状态不一样则插入数据
|
||||
//可能存在掉线后最后一组数据还未入库,添加时间判断
|
||||
if(CollectionUtils.isEmpty(pqsCommunicates)|| (!Objects.equals( pqsCommunicates.get(0).getType(),pqsCommunicateDto.getType())&&pqsCommunicates.get(0).getTime().isBefore(pqsCommunicate.getTime()))){
|
||||
pqsCommunicateMapper.insertOne(pqsCommunicate);
|
||||
|
||||
}
|
||||
//更新mysql数据
|
||||
DevComFlagDTO devComFlagDTO = new DevComFlagDTO();
|
||||
devComFlagDTO.setId(pqsCommunicateDto.getDevId());
|
||||
@@ -136,6 +145,8 @@ public class InfluxdbPqsCommunicateImpl implements IPqsCommunicate {
|
||||
devComFlagDTO.setStatus(pqsCommunicateDto.getType());
|
||||
|
||||
deviceFeignClient.updateDevComFlag(devComFlagDTO);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user