Compare commits

...

14 Commits

70 changed files with 2843 additions and 129 deletions

View File

@@ -58,6 +58,6 @@ public class BaseParam implements Serializable {
@ApiModelProperty(name = "idList",value = "索引集合")
private List<String> idList;
@ApiModelProperty(name = "type",value = "0:通用 1:省级平台 ")
@ApiModelProperty(name = "type",value = "0:通用 1:省级平台 2:物联平台")
private Integer type;
}

View File

@@ -42,4 +42,8 @@ public interface LiteFlowAlgorithmFeignClient {
@ApiOperation("新能源专项分析算法执行链")
@PostMapping("/specialAnalysis")
void specialAnalysisExecutor(@RequestBody BaseParam baseParam);
@ApiOperation("物联监测点算法执行链")
@PostMapping("/wlMeasurementPointExecutor")
void wlMeasurementPointExecutor(@RequestBody BaseParam baseParam);
}

View File

@@ -52,6 +52,12 @@ public class LiteFlowAlgorithmFeignClientFallbackFactory implements FallbackFact
throw new BusinessException(finalExceptionEnum);
}
@Override
public void wlMeasurementPointExecutor(BaseParam baseParam) {
log.error("{}异常,降级处理,异常为:{}", "物联监测点算法执行链: ", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public void deviceExecutor(BaseParam baseParam) {
log.error("{}异常,降级处理,异常为:{}", "装置算法执行链: ", throwable.toString());

View File

@@ -104,6 +104,11 @@
<artifactId>pq-device-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>cs-device-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>common-event</artifactId>

View File

@@ -2,7 +2,10 @@ package com.njcn.algorithm;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.*;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.StrUtil;
import com.njcn.algorithm.pojo.bo.BaseParam;
@@ -13,8 +16,12 @@ import com.njcn.algorithm.utils.MemorySizeUtil;
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.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.*;
import com.njcn.device.biz.pojo.dto.DeptGetChildrenMoreDTO;
import com.njcn.device.biz.pojo.dto.DeptGetDeviceDTO;
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.user.api.DeptFeignClient;
@@ -62,6 +69,8 @@ public class ExecutionCenter extends BaseController {
private FlowExecutor flowExecutor;
@Resource
private DeptLineFeignClient deptLineFeignClient;
@Resource
private CsLineFeignClient csLineFeignClient;
/***
* 1、校验非全链执行时tagNames节点标签集合必须为非空否则提示---无可执行节点
@@ -155,7 +164,40 @@ public class ExecutionCenter extends BaseController {
liteflowResponse = flowExecutor.execute2Resp("measurement_point", calculatedParam);
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("物联监测点算法执行链")
@PostMapping("/wlMeasurementPointExecutor")
@Async("asyncExecutor")
public void wlMeasurementPointExecutor(@RequestBody BaseParam baseParam) {
String methodDescribe = getMethodDescribe("wlMeasurementPointExecutor");
//手动判断参数是否合法,
CalculatedParam calculatedParam = judgeExecuteParam(baseParam);
// 测点索引
if (CollectionUtils.isEmpty(calculatedParam.getIdList())) {
calculatedParam.setIdList(csLineFeignClient.getAllLine().getData());
}
LiteflowResponse liteflowResponse;
if (baseParam.isRepair()) {
//补招时,起始日期、截止日期必填
DateTime startDate = DateUtil.parse(baseParam.getBeginTime(), DatePattern.NORM_DATE_FORMAT);
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
//递增日期执行算法链
for (int i = 0; i < betweenDay; i++) {
if (i != 0) {
startDate = DateUtil.offsetDay(startDate, 1);
}
calculatedParam.setDataDate(DateUtil.format(startDate, DatePattern.NORM_DATE_PATTERN));
liteflowResponse = flowExecutor.execute2Resp("wl_measurement_point", calculatedParam);
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
}
} else {
//非补招
liteflowResponse = flowExecutor.execute2Resp("wl_measurement_point", calculatedParam);
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
}
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)

View File

@@ -2,6 +2,8 @@ package com.njcn.algorithm.executor;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.algorithm.service.line.*;
import com.njcn.dataProcess.api.RmpVThdFeignClient;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
@@ -11,6 +13,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import java.util.List;
/**
@@ -39,6 +42,8 @@ public class MeasurementExecutor extends BaseExecutor {
private IPollutionService pollutionService;
@Resource
private IPollutionCalc pollutionCalc;
@Resource
private RmpVThdFeignClient rmpVThdFeignClient;
/**
* 数据质量清洗
*/
@@ -226,7 +231,7 @@ public class MeasurementExecutor extends BaseExecutor {
dayDataService.dataVHandler(bindCmp.getRequestData());
}
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "dataI", nodeType = NodeTypeEnum.COMMON)
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "dataI", nodeType = NodeTypeEnum.COMMON)
public boolean dataIToDayAccess(NodeComponent bindCmp) {
return isAccess(bindCmp);
}
@@ -481,6 +486,24 @@ public class MeasurementExecutor extends BaseExecutor {
dataIntegrityService.dataIntegrity(bindCmp.getRequestData());
}
/**
* 算法名: 3.4.1.6.1-----监测点谐波畸变率_日表(r_mp_v_thd)
*
* @author xuyang
* @date 2023年11月13日 19:34
*/
@LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "rMpVThd", nodeType = NodeTypeEnum.COMMON)
public boolean rMpVThdAccess(NodeComponent bindCmp) {
return isAccess(bindCmp);
}
@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "rMpVThd", nodeType = NodeTypeEnum.COMMON)
public void rMpVThdProcess(NodeComponent bindCmp) {
List<RMpVThd> data = rmpVThdFeignClient.queryThd(bindCmp.getRequestData()).getData();
rmpVThdFeignClient.batchInsertionThd(data);
}
}

View File

@@ -333,6 +333,8 @@ public class DataCleanServiceImpl implements IDataCleanService {
List<DataFlucDto> data8 = dataFlucFeignClient.getRawData(lineParam).getData();
//dataFlicker
List<DataFlickerDto> data9 = dataFlickerFeignClient.getRawData(lineParam).getData();
//获取监测点的暂态事件
List<RmpEventDetailDTO> eventList = rmpEventDetailFeignClient.getRawData(lineParam).getData();
if (CollUtil.isNotEmpty(data1)) {
logger.info("{}数据清洗dataV集合大小为>>>>>>>>>>>>{}",lineParam.getStartTime(), MemorySizeUtil.getObjectSize(data1));
@@ -514,6 +516,27 @@ public class DataCleanServiceImpl implements IDataCleanService {
}
}
if (CollUtil.isNotEmpty(eventList)) {
logger.info("{}数据清洗eventDetail集合大小为>>>>>>>>>>>>{}",lineParam.getStartTime(), MemorySizeUtil.getObjectSize(eventList));
List<PqDataVerify> result = new ArrayList<>();
List<PqReasonableRangeDto> list = map.get(DataCleanEnum.RMpEventDetail.getCode());
Map<String, PqReasonableRangeDto> pqReasonableRangeDtoMap = list.stream().collect(Collectors.toMap(PqReasonableRangeDto::getIndexCode, Function.identity()));
eventList.forEach(data->{
data.setFeatureAmplitude(data.getFeatureAmplitude()*100.0);
List<PqDataVerify> pqDataVerifies = judgeDataEvent(pqReasonableRangeDtoMap,data);
result.addAll(pqDataVerifies);
});
if (CollUtil.isNotEmpty(result)) {
Map<String,Object> dtoMap = handleDataEvent(result,bak,item.getTimeInterval());
Set<String> timeSet = new HashSet<>(result.stream().map(dt -> dt.getTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_TIME_PATTERN))).collect(Collectors.toSet()));
dtoMap.put("errorTimes",timeSet.size() * item.getTimeInterval());
allTimeSet.addAll(timeSet);
if (CollUtil.isNotEmpty(dtoMap)) {
resultData.add(dtoMap);
}
}
}
if (CollUtil.isNotEmpty(allTimeSet)) {
Map<String,Object> dtoMap = new HashMap<>();
dtoMap.put("lineErrorTimes",allTimeSet.size() * item.getTimeInterval());
@@ -716,6 +739,24 @@ public class DataCleanServiceImpl implements IDataCleanService {
return map;
}
public Map<String,Object> handleDataEvent(List<PqDataVerify> result, PqDataVerifyBak bak,Integer timeInterval) {
Map<String,Object> map = new HashMap<>();
Map<String,List<PqDataVerify>> codeMap = result.stream().collect(Collectors.groupingBy(PqDataVerify::getIndexCode));
//暂降事件
List<DataCleanJsonDTO.DataHarmCleanJsonDTO> list = handleData(codeMap.get(DataCleanEnum.VoltageDip.getCode()),timeInterval);
if (CollUtil.isNotEmpty(list)) {
bak.setDip(1);
map.put(DataCleanEnum.RMpEventDetail.getCode() + "-" + DataCleanEnum.VoltageDip.getCode(),list);
}
//暂升事件
List<DataCleanJsonDTO.DataHarmCleanJsonDTO> list2 = handleData(codeMap.get(DataCleanEnum.VoltageRise.getCode()),timeInterval);
if (CollUtil.isNotEmpty(list2)) {
bak.setRise(1);
map.put(DataCleanEnum.RMpEventDetail.getCode() + "-" + DataCleanEnum.VoltageRise.getCode(),list2);
}
return map;
}
public List<DataCleanJsonDTO.DataHarmCleanJsonDTO> handleData(List<PqDataVerify> list, Integer timeInterval) {
List<DataCleanJsonDTO.DataHarmCleanJsonDTO> dataList = new ArrayList<>();
if (CollUtil.isNotEmpty(list)) {
@@ -754,6 +795,8 @@ public class DataCleanServiceImpl implements IDataCleanService {
});
dto.setErrorCounts(allCounts.get());
dto.setErrorTimes(timeSet.size()*timeInterval);
dto.setMinValue(list.get(0).getMinValue());
dto.setMaxValue(list.get(0).getMaxValue());
dto.setList(list1);
});
dataList.add(dto);
@@ -1144,7 +1187,7 @@ public class DataCleanServiceImpl implements IDataCleanService {
Map<String, List<PqReasonableRangeDto>> pqReasonableRangeDtoMap = new HashMap<>();
DataCleanParam param = new DataCleanParam();
param.setSystemType(DataCleanEnum.Pqs.getCode());
param.setDataSource(DataCleanEnum.InfluxDB.getCode());
// param.setDataSource(DataCleanEnum.InfluxDB.getCode());
List<PqReasonableRangeDto> list = pqReasonableRangeFeignClient.getData(param).getData();
if (CollUtil.isNotEmpty(list)) {
pqReasonableRangeDtoMap = list.stream().collect(Collectors.groupingBy(PqReasonableRangeDto::getInfluxdbTableName));
@@ -1769,12 +1812,52 @@ public class DataCleanServiceImpl implements IDataCleanService {
return list;
}
/**
* 获取数据的标准范围,进行数据比对
*/
public List<PqDataVerify> judgeDataEvent(Map<String, PqReasonableRangeDto> map, RmpEventDetailDTO dto) {
List<PqDataVerify> list = new ArrayList<>();
PqReasonableRangeDto pqReasonableRangeDto = map.get(DataCleanEnum.VoltageDip.getCode());
if(ObjectUtil.isNotNull(dto.getFeatureAmplitude())){
if (dto.getFeatureAmplitude() < pqReasonableRangeDto.getMinValue() || dto.getFeatureAmplitude() > pqReasonableRangeDto.getMaxValue()) {
PqDataVerify pqDataVerify = getPqDataVerify(dto.getMeasurementPointId()
,dto.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN))
,"Feature_Amplitude"
,"/"
,pqReasonableRangeDto.getIndexCode()
,pqReasonableRangeDto.getIndexName()
,pqReasonableRangeDto.getInfluxdbTableName()
,dto.getFeatureAmplitude()
,pqReasonableRangeDto.getMinValue()
,pqReasonableRangeDto.getMaxValue());
list.add(pqDataVerify);
}
}
PqReasonableRangeDto pqReasonableRangeDto2 = map.get(DataCleanEnum.VoltageRise.getCode());
if(ObjectUtil.isNotNull(dto.getFeatureAmplitude())){
if (dto.getFeatureAmplitude() < pqReasonableRangeDto2.getMinValue() || dto.getFeatureAmplitude() > pqReasonableRangeDto2.getMaxValue()) {
PqDataVerify pqDataVerify = getPqDataVerify(dto.getMeasurementPointId()
,dto.getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN))
,"Feature_Amplitude"
,"/"
,pqReasonableRangeDto2.getIndexCode()
,pqReasonableRangeDto2.getIndexName()
,pqReasonableRangeDto2.getInfluxdbTableName()
,dto.getFeatureAmplitude()
,pqReasonableRangeDto2.getMinValue()
,pqReasonableRangeDto2.getMaxValue());
list.add(pqDataVerify);
}
}
return list;
}
public PqDataVerify getPqDataVerify(String lineId,String time,String valueType, String phasicType, String indexCode, String indexName, String indexTable, Double data, Double minValue, Double maxValue) {
PqDataVerify pqDataVerify = new PqDataVerify();
pqDataVerify.setLineId(lineId);
pqDataVerify.setTime(TimeUtils.StringToLocalDateTime(time));
pqDataVerify.setValueType(Objects.isNull(valueType)?"avg":valueType);
pqDataVerify.setTime(time.contains(".")?TimeUtils.StringToLocalDateTimeSSS(time):TimeUtils.StringToLocalDateTime(time));
pqDataVerify.setValueType(Objects.isNull(valueType)?"AVG":valueType);
pqDataVerify.setPhasicType(phasicType);
pqDataVerify.setIndexCode(indexCode);
pqDataVerify.setIndexName(indexName);

View File

@@ -76,6 +76,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -107,7 +108,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -125,6 +125,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -155,7 +156,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -174,6 +174,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -204,7 +205,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -223,6 +223,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -253,7 +254,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -271,6 +271,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -301,7 +302,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -319,6 +319,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -349,7 +350,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -367,6 +367,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -397,7 +398,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -415,6 +415,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -445,7 +446,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -463,6 +463,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -493,7 +494,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -511,6 +511,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -541,7 +542,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -559,6 +559,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -589,7 +590,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -607,6 +607,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -637,7 +638,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -655,6 +655,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -685,7 +686,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -704,6 +704,7 @@ public class DayDataServiceImpl implements IDayDataService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
//以100个监测点分片处理
List<List<String>> pendingIds = ListUtils.partition(calculatedParam.getIdList(),NUM);
pendingIds.forEach(list->{
@@ -734,7 +735,6 @@ public class DayDataServiceImpl implements IDayDataService {
});
});
}
partList = null;
});
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -756,10 +756,8 @@ public class DayDataServiceImpl implements IDayDataService {
Collectors.mapping(item->TimeUtils.LocalDateTimeToString(item.getTime()), Collectors.toList())
));
lineParam.setAbnormalTime(timeMap);
pqDataVerifies.clear();
}
}
//指标处理

View File

@@ -11,6 +11,7 @@ import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.algorithm.service.line.IDataCrossingService;
import com.njcn.algorithm.utils.MemorySizeUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.dataProcess.api.*;
import com.njcn.dataProcess.constant.PhaseType;
import com.njcn.dataProcess.enums.DataCleanEnum;
@@ -38,7 +39,10 @@ import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -77,6 +81,8 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
private DataLimitTargetFeignClient dataLimitTargetFeignClient;
@Resource
private DataLimitQualifiedFeignClient dataLimitQualifiedFeignClient;
@Resource
private CsLineFeignClient csLineFeignClient;
@Override
@@ -105,9 +111,10 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
lineParam.setType(calculatedParam.getType());
List<String> lineIds = calculatedParam.getIdList();
//获取所有监测点的限值
List<Overlimit> overLimitList = commTerminalGeneralClient.getOverLimitDataByIds(lineIds).getData();
List<Overlimit> overLimitList = csLineFeignClient.getOverLimitData(lineIds).getData();
Map<String, Overlimit> overLimitMap = overLimitList.stream().collect(Collectors.toMap(Overlimit::getId, Function.identity()));
//添加异常数据时间点
getAbnormalData(lineParam);
@@ -120,7 +127,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//获取电压数据
List<DataVDto> dataVAllTime = dataVFeignClient.getRawData(lineParam).getData();
//闪变数据
List<DataPltDto> dataFlickerAllTime = dataPltFeignClient.getRawData(lineParam).getData();
List<DataPltDto> dataPltAllTime = dataPltFeignClient.getRawData(lineParam).getData();
//谐波数据
List<DataHarmDto> dataVHarmList = dataHarmRateVFeignClient.getRawData(lineParam).getData();
//间谐波数据
@@ -133,15 +140,16 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
*/
Map<String, List<DataVDto>> allTime = dataVAllTime.stream()
.filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType()))
.filter(x -> InfluxDbSqlConstant.AVG_WEB.equals(x.getValueType()))
.filter(x -> InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(x.getValueType()))
.collect(Collectors.groupingBy(DataVDto::getLineId));
/**
* 功能描述:获取influxDB -> data_plt ->
* 闪变总计算次数(用data_plt中phasic_type=A,quality_flag=0来参与统计)
* 闪变总计算次数(用data_plt中phasic_type=A,value_type=avg,quality_flag=0来参与统计)
*/
Map<String, List<DataPltDto>> flickerAllTime = dataFlickerAllTime.stream()
Map<String, List<DataPltDto>> pltAllTime = dataPltAllTime.stream()
.filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType()))
.filter(x -> InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(x.getValueType()))
.collect(Collectors.groupingBy(DataPltDto::getLineId));
/**
@@ -215,7 +223,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
/**
* 功能描述:获取influxDB -> data_plt -> 长时间闪变 -> 注(取最大值原始算法去掉了,现没有根据最大值比较)
*/
Map<String, List<DataPltDto>> dataPlt = dataFlickerAllTime.stream()
Map<String, List<DataPltDto>> dataPlt = dataPltAllTime.stream()
.filter(x -> phase.contains(x.getPhasicType()))
.collect(Collectors.groupingBy(DataPltDto::getLineId));
@@ -224,7 +232,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
result.addAll(getData(calculatedParam.getDataDate(),
overLimitMap.get(item),
allTime.get(item),
flickerAllTime.get(item),
pltAllTime.get(item),
harmRateV.get(item),
dataI.get(item),
inHarmV.get(item),
@@ -240,11 +248,10 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
MemorySizeUtil.getNowMemory();
if (CollUtil.isNotEmpty(result)) {
//存储数据
List<DataLimitRateDto> dataLimitRate = result.stream().map(DataLimitDetailDto::getDataLimitRate).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList());
List<DataLimitRateDto> dataLimitRate = result.stream().map(DataLimitDetailDto::getDataLimitRate).filter(ObjectUtil::isNotNull).collect(Collectors.toList());
if(CollUtil.isNotEmpty(dataLimitRate)){
dataLimitRateFeignClient.batchInsertion(dataLimitRate);
}
}
if (CollUtil.isNotEmpty(result)) {
//存储数据
@@ -252,11 +259,8 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
if(CollUtil.isNotEmpty(detail)){
dataLimitRateDetailFeignClient.batchInsertion(detail);
}
}
System.gc();
}
@Override
@@ -652,7 +656,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//电压总谐波畸变率
if (!CollectionUtils.isEmpty(dataVPOList)) {
for (DataVDto item : dataVPOList) {
if (item.getVThd() > overlimit.getUaberrance()) {
if (ObjectUtil.isNull(item.getVThd())||item.getVThd() > overlimit.getUaberrance()) {
addAbnormalData(thd, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
}
}
@@ -660,7 +664,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
if (!CollectionUtils.isEmpty(dataVPODevList)) {
for (DataVDto item : dataVPODevList) {
if (item.getVlDev() >= 0) {
if (ObjectUtil.isNull(item.getVlDev())||item.getVlDev() >= 0) {
if (item.getVlDev() > overlimit.getVoltageDev()) {
addAbnormalData(uDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVlDev(), overlimit.getVoltageDev());
}
@@ -674,7 +678,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//长时间闪变
if (!CollectionUtils.isEmpty(dataPltPOList)) {
for (DataPltDto item : dataPltPOList) {
if (item.getPlt() > overlimit.getFlicker()) {
if (ObjectUtil.isNull(item.getPlt())||item.getPlt() > overlimit.getFlicker()) {
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
}
}
@@ -799,7 +803,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//电压总谐波畸变率
if (!CollectionUtils.isEmpty(dataVPOList)) {
for (DataVDto item : dataVPOList) {
if (item.getVThd() > overlimit.getUaberrance()) {
if (ObjectUtil.isNull(item.getVThd())||item.getVThd() > overlimit.getUaberrance()) {
addAbnormalData(thd, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
}
}
@@ -807,7 +811,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//三相电压不平衡度
if (!CollectionUtils.isEmpty(dataVPOUnbalanceList)) {
for (DataVDto item : dataVPOUnbalanceList) {
if (item.getVUnbalance() > overlimit.getUbalance()) {
if (ObjectUtil.isNull(item.getVUnbalance())||item.getVUnbalance() > overlimit.getUbalance()) {
addAbnormalData(uAberrance, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVUnbalance(), overlimit.getUbalance());
}
}
@@ -829,7 +833,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//频率偏差
if (!CollectionUtils.isEmpty(dataVPOFreqList)) {
for (DataVDto item : dataVPOFreqList) {
if (item.getFreqDev() > overlimit.getFreqDev()) {
if (ObjectUtil.isNull(item.getFreqDev())||item.getFreqDev() > overlimit.getFreqDev()) {
addAbnormalData(freqDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getFreqDev(), overlimit.getFreqDev());
}
}
@@ -838,7 +842,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
if (!CollectionUtils.isEmpty(dataVPODevList)) {
for (DataVDto item : dataVPODevList) {
if (item.getVlDev() >= 0) {
if (ObjectUtil.isNull(item.getVlDev())||item.getVlDev() >= 0) {
if (item.getVlDev() > overlimit.getVoltageDev()) {
addAbnormalData(uDev, item.getPhasicType(), item.getMinTime(), item.getValueType(), item.getVlDev(), overlimit.getVoltageDev());
}
@@ -852,7 +856,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
//长时间闪变
if (!CollectionUtils.isEmpty(dataPltPOList)) {
for (DataPltDto item : dataPltPOList) {
if (item.getPlt() > overlimit.getFlicker()) {
if (ObjectUtil.isNull(item.getPlt())||item.getPlt() > overlimit.getFlicker()) {
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
}
}
@@ -1100,6 +1104,7 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
json.setValue(String.join(",", value.stream()
.map(abnormal -> abnormal.getValue() + "")
.collect(Collectors.toList())));
json.setOverLimitValue(list.get(0).getOverLimitValue());
info.add(json);
});
if (CollUtil.isNotEmpty(info)) {

View File

@@ -93,9 +93,10 @@ public class PollutionCalcImpl implements IPollutionCalc {
if (CollUtil.isNotEmpty(dataVDtoList) && CollUtil.isNotEmpty(dataHarmDtoList)) {
//计算谐波电压污染值
dataPollutionD.setValue(PubUtils.doubleRound(2, calcVAllPollutionValue(dataVDtoList, dataHarmDtoList, overlimit) * line.getTimeInterval()));
list.add(dataPollutionD);
}else{
dataPollutionD.setValue(0.0);
}
list.add(dataPollutionD);
dataPollutionD = new DataPollutionD();
dataPollutionD.setLineId(id);
dataPollutionD.setDataDate(LocalDateTimeUtil.parseDate(calculatedParam.getDataDate()));
@@ -104,9 +105,10 @@ public class PollutionCalcImpl implements IPollutionCalc {
if (CollUtil.isNotEmpty(data)) {
//计算谐波电流污染值
dataPollutionD.setValue(PubUtils.doubleRound(2, calcIAllPollutionValue(data, overlimit) * line.getTimeInterval()));
list.add(dataPollutionD);
}else{
dataPollutionD.setValue(0.0);
}
list.add(dataPollutionD);
}
}
}

View File

@@ -59,6 +59,12 @@
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.njcn.platform</groupId>
<artifactId>algorithm-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.dataProcess.api.fallback.DataIFeignClientFallbackFactory;
import com.njcn.dataProcess.api.fallback.DataRecallFeignClientFallbackFactory;
import com.njcn.dataProcess.dto.DataIDTO;
import com.njcn.dataProcess.param.FullRecallMessage;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
import com.njcn.dataProcess.pojo.dto.DataIDto;
@@ -32,4 +33,10 @@ public interface DataRecallFeignClient {
@ApiOperation("数据补招")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<String>> recall(@RequestBody RecallMessage param);
@PostMapping("/fullHourRecall")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("数据全量补招")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<String>> fullHourRecall(@RequestBody FullRecallMessage param);
}

View File

@@ -0,0 +1,31 @@
package com.njcn.dataProcess.api;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.dataProcess.api.fallback.RMpVThdFeignClientFallbackFactory;
import com.njcn.dataProcess.api.fallback.SpThroughFeignClientFallbackFactory;
import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import com.njcn.dataProcess.pojo.dto.SpThroughDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022年01月05日 15:11
*/
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/rmpvthd", fallbackFactory = RMpVThdFeignClientFallbackFactory.class, contextId = "rmpvthd")
public interface RmpVThdFeignClient {
@PostMapping("/batchInsertionThd")
HttpResult<String> batchInsertionThd(@RequestBody List<RMpVThd> result);
@PostMapping("/batchInsertionPower")
HttpResult<List<RMpVThd>> queryThd(@RequestBody CalculatedParam calculatedParam);
}

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.dataProcess.api.DataRecallFeignClient;
import com.njcn.dataProcess.param.FullRecallMessage;
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
import com.njcn.message.message.RecallMessage;
import feign.hystrix.FallbackFactory;
@@ -44,6 +45,12 @@ public class DataRecallFeignClientFallbackFactory implements FallbackFactory<Dat
log.error("{}异常,降级处理,异常为:{}","补招接口调用异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<String>> fullHourRecall(FullRecallMessage param) {
log.error("{}异常,降级处理,异常为:{}","按小时补招接口调用异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,58 @@
package com.njcn.dataProcess.api.fallback;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.dataProcess.api.RmpVThdFeignClient;
import com.njcn.dataProcess.api.SpThroughFeignClient;
import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import com.njcn.dataProcess.pojo.dto.SpThroughDto;
import com.njcn.dataProcess.util.DataProcessingEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author denghuajun
* @version 1.0.0
* @date 2022年01月05日 15:08
*/
@Slf4j
@Component
public class RMpVThdFeignClientFallbackFactory implements FallbackFactory<RmpVThdFeignClient> {
/**
* 输出远程请求接口异常日志
* @param cause RPC请求异常
*/
@Override
public RmpVThdFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if(cause.getCause() instanceof BusinessException){
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = DataProcessingEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new RmpVThdFeignClient() {
@Override
public HttpResult<String> batchInsertionThd(List<RMpVThd> result) {
log.error("{}异常,降级处理,异常为:{}","畸变率插入",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RMpVThd>> queryThd(CalculatedParam calculatedParam) {
log.error("{}异常,降级处理,异常为:{}","畸变率查询",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -25,6 +25,11 @@ public class DataCleanJsonDTO {
@ApiModelProperty("异常数据量")
private Integer errorCounts;
@ApiModelProperty("指标上限")
private Double minValue;
@ApiModelProperty("指标下限")
private Double maxValue;
}
@Data

View File

@@ -0,0 +1,23 @@
package com.njcn.dataProcess.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
/**
* Description:
* Date: 2025/08/25 下午 2:42【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Data
@RequiredArgsConstructor
@AllArgsConstructor
public class RecallReplyDTO {
//code 200 完成500错误300补招进行中
private Integer code;
private String message;
}

View File

@@ -81,8 +81,8 @@ public enum DataCleanEnum {
V_Data("v_1","相(线)电压基波有效值"),
//r_mp_event_detail
VoltageDip("Voltage_Dip","相(线)电压基波有效"),
VoltageRise("Voltage_Rise","相(线)电压基波有效");
VoltageDip("Voltage_Dip","电压暂降特征幅"),
VoltageRise("Voltage_Rise","电压暂升特征幅");
private String code;

View File

@@ -62,5 +62,7 @@ public class LineCountEvaluateParam extends BaseParam implements Serializable {
*/
private Boolean dataType = true;
//0:通用 1:省级平台 2:物联
private Integer type;
}

View File

@@ -33,6 +33,12 @@ public class DataFlicker {
@Column(name = "phasic_type",tag = true)
private String phasicType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
@Column(name = "fluc")
private Double fluc=0.00;

View File

@@ -33,6 +33,12 @@ public class DataFluc {
@Column(name = "phasic_type",tag = true)
private String phasicType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
@Column(name = "fluc")
private Double fluc=0.00;

View File

@@ -43,6 +43,12 @@ public class DataHarmphasicI {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataHarmphasicV {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataHarmpowerP {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataHarmpowerQ {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataHarmpowerS {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -43,6 +43,12 @@ public class DataHarmrateI {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -43,6 +43,12 @@ public class DataHarmrateV {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataI {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataInharmI {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -44,6 +44,12 @@ public class DataInharmV {
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -34,9 +34,18 @@ public class DataPlt {
@Column(name = "phasic_type",tag = true)
private String phasicType;
@Column(name = "value_type",tag = true)
private String valueType;
@Column(name = "quality_flag",tag = true)
private String qualityFlag="0";
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -45,6 +45,13 @@ public class DataV {
@Column(name = "quality_flag", tag = true)
private String qualityFlag="0";
@Column(name = "cl_did", tag = true)
private String cldid;
@Column(name = "process", tag = true)
private String process;
//是否是异常指标数据0否1是
@Column(name = "abnormal_flag")
private Integer abnormalFlag;

View File

@@ -65,6 +65,8 @@ public class AbnormalData {
@JSONField(ordinal = 4)
private String value;
@JSONField(ordinal = 5)
private float overLimitValue;
}
}

View File

@@ -0,0 +1,62 @@
package com.njcn.dataProcess.pojo.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.time.LocalDate;
/**
*
* Description:
* 接口文档访问地址http://serverIP:port/swagger-ui.html
* Date: 2022/10/10 19:59【需求编号】
*
* @author clam
* @version V1.0.0
*/
/**
* 谐波畸变率排名
*/
@ApiModel(value="com-njcn-harmonic-pojo-po-RMpVThd")
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "r_mp_v_thd")
public class RMpVThd implements Serializable {
/**
* 监测点ID
*/
@TableField(value = "measurement_point_id")
@MppMultiId
private String measurementPointId;
/**
* 排名类型,字典表1年 2季度 3月份 4周 5日
*/
@TableField(value = "data_type")
@MppMultiId
private String dataType;
/**
* 时间
*/
@TableField(value = "data_date")
@MppMultiId
private LocalDate dataDate;
/**
* 谐波畸变率
*/
@TableField(value = "v_thd")
private Double vThd;
private static final long serialVersionUID = 1L;
}

View File

@@ -173,6 +173,20 @@ public class PqDataVerifyBak implements Serializable {
@TableField(value = "pst")
private Integer pst = 0;
/**
* 电压暂降(0:正常 1:异常)
*/
@TableField(value = "dip")
private Integer dip;
/**
* 电压暂升(0:正常 1:异常)
*/
@TableField(value = "rise")
private Integer rise;
/**
* 文件路径
*/

View File

@@ -16,6 +16,7 @@ import java.time.format.DateTimeFormatter;
public class TimeUtils {
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private static final DateTimeFormatter DATE_TIME_FORMATTER_SSS = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN);
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
/**
@@ -37,6 +38,10 @@ public class TimeUtils {
return LocalDateTime.parse(time, DATE_TIME_FORMATTER);
}
public static LocalDateTime StringToLocalDateTimeSSS(String time) {
return LocalDateTime.parse(time, DATE_TIME_FORMATTER_SSS);
}
/**
* LocalDataTime类型的yyyy-MM-dd HH:mm:ss转成String yyyy-MM-dd HH:mm:ss
* @param time

View File

@@ -73,12 +73,28 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>cs-device-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.njcn.platform</groupId>
<artifactId>stat-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>com.njcn.platform</groupId>
<artifactId>algorithm-api</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@@ -1,5 +1,6 @@
package com.njcn.dataProcess.controller;//package com.njcn.message.websocket;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
@@ -10,8 +11,12 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.dataProcess.annotation.InsertBean;
import com.njcn.dataProcess.annotation.QueryBean;
import com.njcn.dataProcess.param.FullRecallMessage;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.DataIntegrityDto;
import com.njcn.dataProcess.service.IDataIntegrity;
import com.njcn.dataProcess.service.IDataV;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
@@ -57,13 +62,14 @@ public class DataRecallController extends BaseController {
private final ProduceFeignClient produceFeignClient;
private final DeviceFeignClient deviceFeignClient;
@InsertBean
private IDataIntegrity iDataIntegrityInsert;
//页面补招按时间段带小时的全部补招不查datav数据去筛选
@PostMapping("/FullRecall")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("数据全量补招")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<String>> recall(@RequestBody FullRecallMessage param) {
public HttpResult<List<String>> FullRecall(@RequestBody FullRecallMessage param) {
String methodDescribe = getMethodDescribe("recall");
List<String> guidList = new ArrayList<>();
List<String> runMonitorIds = new ArrayList<>();
@@ -80,16 +86,185 @@ public class DataRecallController extends BaseController {
}else {
runMonitorIds = param.getMonitorId();
}
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setLineId(runMonitorIds);
//查看监测点的数据完整性
lineParam.setStartTime( LocalDateTimeUtil.format( param.getReCallStartTime(), DatePattern.NORM_DATETIME_FORMATTER));
lineParam.setEndTime(LocalDateTimeUtil.format( param.getReCallEndTime(), DatePattern.NORM_DATETIME_FORMATTER));
List<DataIntegrityDto> rawData = iDataIntegrityInsert.getRawData(lineParam);
Map<String, Map<String, List<DataIntegrityDto>>> collect1 = rawData.stream().collect(Collectors.groupingBy(DataIntegrityDto::getLineIndex, Collectors.groupingBy(DataIntegrityDto::getTimeId)));
runMonitorIds.forEach(temp->{
LineDevGetDTO data = commTerminalGeneralClient.getMonitorDetail(temp).getData();
//后续根据不同前置下的测点发送补招密令
DeviceDTO data2 = deviceFeignClient.getDeviceInfo(data.getDevId()).getData();
LocalDateTime currentDate = param.getReCallStartTime();
//循环每一天
while (!currentDate.isAfter(param.getReCallEndTime())) {
LocalDateTime tempTime = currentDate.toLocalDate().plusDays(1).atTime(0,0,0);
//查看数据完整性,根据数据完整性进行补招;
//校验数据完整性完整率>=98%不补招完整率80%~98%,差量补招,完整率<=80%,全量补招
Integer recallType = 1; //1全量补 2:差量补 3不需要补招
String curDateString = LocalDateTimeUtil.format(currentDate.toLocalDate().atTime(0, 0, 0), DatePattern.NORM_DATETIME_FORMATTER);
if(collect1.containsKey(temp)&&collect1.get(temp).containsKey(curDateString)){
DataIntegrityDto dto = collect1.get(temp).get(curDateString).get(0);
if( dto.getDueTime()!=0){
double i =(double)dto.getRealTime() / dto.getDueTime();
if( i>=0.98){
recallType=3;
} else if(i<0.98&&i>0.8){
recallType=2;
}
}
}
if(recallType ==3){
currentDate = tempTime;
continue;
}else if(recallType ==2){
Integer timeInterval = data.getTimeInterval();
List<LocalDateTime> localDateTimeList = generateTimeIntervals( currentDate.toLocalDate(), timeInterval);
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format( currentDate.toLocalDate(), DatePattern.NORM_DATE_PATTERN));
localDateTimeList.removeAll(data1);
if(!CollectionUtils.isEmpty(localDateTimeList)){
List<String> timePeriod = mergeTimeIntervals(localDateTimeList, timeInterval);
//最大时间段为300
if(timePeriod.size()<300){
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(timePeriod);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}else {
List<List<String>> timePeriods = CollUtil.split(timePeriod, 300);
timePeriods.forEach(period->{
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(period);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
});
}
}
}else {
//暂态补招
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
//不设置dataType暂态稳态全部补招
recallDTO.setDataType("");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
if(tempTime.isAfter(param.getReCallEndTime())){
String eventTime = formatInterval(currentDate,param.getReCallEndTime());
recallDTO.setTimeInterval(Stream.of(eventTime).collect(Collectors.toList()));
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}else {
String eventTime = formatInterval(currentDate,tempTime);
recallDTO.setTimeInterval(Stream.of(eventTime).collect(Collectors.toList()));
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}
}
currentDate = tempTime;
}
});
if(!CollectionUtils.isEmpty(recallDTOList)){
Map<String, List<RecallMessage.RecallDTO>> collect = recallDTOList.stream().collect(Collectors.groupingBy(RecallMessage.RecallDTO::getNodeId));
collect.forEach((k,v)->{
RecallMessage message = new RecallMessage();
message.setNodeId(k);
message.setData(v);
String guid = IdUtil.simpleUUID();
message.setGuid(guid);
produceFeignClient.recall(message);
guidList.add(guid);
});
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, guidList, methodDescribe);
}
@PostMapping("/fullHourRecall")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("按小时数据补招")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<String>> fullHourRecall(@RequestBody FullRecallMessage param){
String methodDescribe = getMethodDescribe("recall");
List<String> guidList = new ArrayList<>();
List<String> runMonitorIds = new ArrayList<>();
List<RecallMessage.RecallDTO> recallDTOList = new ArrayList<>();
// Duration duration = Duration.between(param.getReCallStartTime(), param.getReCallEndTime());
// // 获取剩余的分钟数,如果要精确到分钟可以这样做
// long minutes = duration.toMinutes() ;
// if(minutes>60){
// throw new BusinessException("全量补招时间区间不能超过一个小时");
//
// }
if(CollectionUtils.isEmpty(param.getMonitorId())){
runMonitorIds = commTerminalGeneralClient.getRunMonitorIds().getData();
}else {
runMonitorIds = param.getMonitorId();
}
runMonitorIds.forEach(temp->{
LineDevGetDTO data = commTerminalGeneralClient.getMonitorDetail(temp).getData();
//后续根据不同前置下的测点发送补招密令
DeviceDTO data2 = deviceFeignClient.getDeviceInfo(data.getDevId()).getData();
Integer timeInterval = data.getTimeInterval();
List<LocalDateTime> localDateTimeList = generateTimeIntervals(param.getReCallStartTime(),param.getReCallEndTime(), timeInterval);
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format(param.getReCallStartTime().toLocalDate(), DatePattern.NORM_DATE_PATTERN));
List<LocalDateTime> tempTime = data1.stream().filter(dateTime -> (!dateTime.isAfter(param.getReCallEndTime())) &&
(!dateTime.isBefore(param.getReCallStartTime()))).collect(Collectors.toList());
localDateTimeList.removeAll(tempTime);
if(!CollectionUtils.isEmpty(localDateTimeList)){
List<String> timePeriod = mergeTimeIntervals(localDateTimeList, timeInterval);
//最大时间段为300
if(timePeriod.size()<300){
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(timePeriod);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}else {
List<List<String>> timePeriods = CollUtil.split(timePeriod, 300);
timePeriods.forEach(period->{
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(period);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
});
}
}
//暂态补招
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
//不设置dataType暂态稳态全部补招
recallDTO.setDataType("");
recallDTO.setDataType("1");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
String eventTime = formatInterval(param.getReCallStartTime(),param.getReCallEndTime());
recallDTO.setTimeInterval(Stream.of(eventTime).collect(Collectors.toList()));
@@ -117,7 +292,6 @@ public class DataRecallController extends BaseController {
}
@PostMapping("/recall")
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@ApiOperation("数据补招")
@@ -134,6 +308,14 @@ public class DataRecallController extends BaseController {
}else {
runMonitorIds = param.getMonitorId();
}
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setLineId(runMonitorIds);
//查看监测点的数据完整性
lineParam.setStartTime( LocalDateTimeUtil.format( param.getReCallStartTime(), DatePattern.NORM_DATETIME_FORMATTER));
lineParam.setEndTime(LocalDateTimeUtil.format( param.getReCallEndTime(), DatePattern.NORM_DATETIME_FORMATTER));
List<DataIntegrityDto> rawData = iDataIntegrityInsert.getRawData(lineParam);
Map<String, Map<String, List<DataIntegrityDto>>> collect1 = rawData.stream().collect(Collectors.groupingBy(DataIntegrityDto::getLineIndex, Collectors.groupingBy(DataIntegrityDto::getTimeId)));
LocalDate currentDate = param.getReCallStartTime();
//循环每一天
while (!currentDate.isAfter(param.getReCallEndTime())) {
@@ -143,19 +325,72 @@ public class DataRecallController extends BaseController {
//后续根据不同前置下的测点发送补招密令
DeviceDTO data2 = deviceFeignClient.getDeviceInfo(data.getDevId()).getData();
Integer timeInterval = data.getTimeInterval();
List<LocalDateTime> localDateTimeList = generateTimeIntervals(finalCurrentDate, timeInterval);
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format(finalCurrentDate, DatePattern.NORM_DATE_PATTERN));
localDateTimeList.removeAll(data1);
if(!CollectionUtils.isEmpty(localDateTimeList)){
List<String> timePeriod = mergeTimeIntervals(localDateTimeList, timeInterval);
//查看数据完整性,根据数据完整性进行补招;
//校验数据完整性完整率>=98%不补招完整率80%~98%,差量补招,完整率<=80%,全量补招
Integer recallType = 1; //1全量补 2:差量补 3不需要补招
String curDateString = LocalDateTimeUtil.format(finalCurrentDate.atTime(0, 0, 0), DatePattern.NORM_DATETIME_FORMATTER);
if(collect1.containsKey(temp)&&collect1.get(temp).containsKey(curDateString)){
DataIntegrityDto dto = collect1.get(temp).get(curDateString).get(0);
if( dto.getDueTime()!=0){
double i = (double)dto.getRealTime() / dto.getDueTime();
if( i>=0.98){
recallType=3;
} else if(i<0.98&&i>0.8){
recallType=2;
}
}
}
if(recallType ==3){
return;
}else if(recallType ==2){
Integer timeInterval = data.getTimeInterval();
List<LocalDateTime> localDateTimeList = generateTimeIntervals(finalCurrentDate, timeInterval);
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format(finalCurrentDate, DatePattern.NORM_DATE_PATTERN));
localDateTimeList.removeAll(data1);
if(!CollectionUtils.isEmpty(localDateTimeList)){
List<String> timePeriod = mergeTimeIntervals(localDateTimeList, timeInterval);
//最大时间段为300
if(timePeriod.size()<300){
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(timePeriod);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}else {
List<List<String>> timePeriods = CollUtil.split(timePeriod, 300);
timePeriods.forEach(period->{
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(period);
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
});
}
}
}else {
//暂态补招
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
//不设置dataType暂态稳态全部补招
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(timePeriod);
String eventTime = formatInterval(finalCurrentDate.atTime(0,0,0),finalCurrentDate.atTime(23,59,0));
recallDTO.setTimeInterval(Stream.of(eventTime).collect(Collectors.toList()));
recallDTO.setNodeId(data2.getNodeId());
recallDTOList.add(recallDTO);
}
//暂态补招
RecallMessage.RecallDTO recallDTO2 = new RecallMessage.RecallDTO();
recallDTO2.setDataType("1");
@@ -177,10 +412,10 @@ public class DataRecallController extends BaseController {
RecallMessage message = new RecallMessage();
message.setNodeId(k);
message.setData(v);
String guid = IdUtil.simpleUUID();
message.setGuid(guid);
String guid = IdUtil.simpleUUID();
message.setGuid(guid);
produceFeignClient.recall(message);
guidList.add(guid);
guidList.add(guid);
});
@@ -225,6 +460,22 @@ public class DataRecallController extends BaseController {
return dateTimeList;
}
public List<LocalDateTime> generateTimeIntervals(LocalDateTime startDateTime,LocalDateTime endDateTime , int intervalMinutes) {
List<LocalDateTime> dateTimeList = new ArrayList<>();
// Generate LocalDateTime list with the given interval
LocalDateTime currentDateTime = startDateTime;
while (!currentDateTime.isAfter(endDateTime)) {
dateTimeList.add(currentDateTime);
currentDateTime = currentDateTime.plusMinutes(intervalMinutes);
}
return dateTimeList;
}
public static List<String> mergeTimeIntervals(List<LocalDateTime> times, int intervalMinutes) {
List<String> mergedIntervals = new ArrayList<>();
if (times == null || times.isEmpty()) {
@@ -259,10 +510,18 @@ public class DataRecallController extends BaseController {
}
public static void main(String[] args) {
// 创建两个LocalDateTime对象
LocalDateTime dateTime1 = LocalDateTime.of(2023, 1, 1, 10, 0); // 例如2023年1月1日 10:00
LocalDateTime dateTime2 = LocalDateTime.of(2023, 1, 2, 15, 30); // 例如2023年1月1日 15:30
LocalDate localDate1 = LocalDate.now();
LocalDate localDate2 = LocalDate.now();
while (!localDate1.isAfter(localDate2)) {
LocalDate finalCurrentDate = localDate1;
System.out.println(finalCurrentDate);
localDate1 = localDate1.plusDays(1);
}
// 创建两个LocalDateTime对象
LocalDateTime dateTime1 = LocalDateTime.of(2023, 1, 1, 10, 0,11); // 例如2023年1月1日 10:00
LocalDateTime dateTime2 = LocalDateTime.of(2023, 1, 1, 10, 30,22); // 例如2023年1月1日 15:30
// 使用Duration计算两个时间之间的差异
Duration duration = Duration.between(dateTime1, dateTime2);

View File

@@ -0,0 +1,60 @@
package com.njcn.dataProcess.controller;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.dataProcess.annotation.InsertBean;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import com.njcn.dataProcess.service.IRMpVThdService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author hongawen
* @version 1.0
* @data 2024/11/6 19:48
*/
@Validated
@Slf4j
@Controller
@RestController
@RequestMapping("/rmpvthd")
@Api(tags = "畸变率")
public class RMpVThdController extends BaseController {
@InsertBean
private IRMpVThdService irMpVThdService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@PostMapping("/batchInsertionThd")
@ApiOperation("畸变率批量插入")
public HttpResult<String> batchInsertionThd(@RequestBody List<RMpVThd> result) {
String methodDescribe = getMethodDescribe("batchInsertionPower");
irMpVThdService.batchInsertionThd(result);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
@PostMapping("/batchInsertionPower")
@ApiOperation("畸变率查询")
public HttpResult<List<RMpVThd>> queryThd(@RequestBody CalculatedParam calculatedParam) {
String methodDescribe = getMethodDescribe("batchInsertionPower");
List<RMpVThd> rMpVThdList = irMpVThdService.queryHarmonicVThd(calculatedParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpVThdList, methodDescribe);
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.dataProcess.dao.relation.mapper;
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 谐波畸变率排名 Mapper 接口
* </p>
*
* @author xiaoyao
* @since 2022-11-07
*/
public interface RMpVThdMapper extends MppBaseMapper<RMpVThd> {
int insertRate(@Param("item") Map<String, Object> item);
/**
* 从r_stat_data_v_d中获取畸变率的最大值
* phasic_type = A、B、C && value_type = CP95
*/
List<RMpVThd> getVThdData(@Param("time") String time, @Param("lineList")List<String> lineList);
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.dataProcess.dao.relation.mapper.RMpVThdMapper">
<insert id="insertRate">
INSERT INTO r_mp_v_thd ( measurement_point_id, data_type, data_date, v_thd) VALUES
( #{item.lineId}, #{item.dataType}, #{item.dataDate}, #{item.vThd} )
ON DUPLICATE KEY UPDATE v_thd = #{item.vThd}
</insert>
<select id="getVThdData" resultType="com.njcn.dataProcess.pojo.dto.RMpVThd">
select
line_id measurementPointId,
max(v_thd) vThd,
time dataDate,
'0' dataType
from
r_stat_data_v_d
where
time = #{time}
and phasic_type in ('A', 'B', 'C')
and value_type = 'CP95'
<if test="lineList != null and lineList.size() > 0">
and line_id in
<foreach collection="lineList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
group by line_id, time
</select>
</mapper>

View File

@@ -0,0 +1,18 @@
package com.njcn.dataProcess.service;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import java.util.List;
public interface IRMpVThdService {
/**
* 计算谐波畸变率表
* @param calculatedParam
*/
List<RMpVThd> queryHarmonicVThd(CalculatedParam calculatedParam);
void batchInsertionThd(List<RMpVThd> result);
}

View File

@@ -4,6 +4,10 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
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;
@@ -20,10 +24,12 @@ 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;
/**
@@ -41,6 +47,17 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
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");
}};
@Override
public void batchInsertion(List<DataFlickerDTO> dataFlickerDTOList) {
@@ -64,7 +81,12 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
@Override
public List<DataFlickerDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataFlickerDto> result = new ArrayList<>();
List<DataFlicker> list = getMinuteData(lineParam);
List<DataFlicker> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteData(lineParam);
} else {
list = getMinuteData(lineParam);
}
list.forEach(item -> {
DataFlickerDto dto = new DataFlickerDto();
BeanUtils.copyProperties(item, dto);
@@ -77,7 +99,12 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataFlicker> dataIList = getMinuteData(lineParam);
List<DataFlicker> dataIList;
if (Objects.equals(lineParam.getType(), 2)) {
dataIList = getWlMinuteData(lineParam);
} else {
dataIList = getMinuteData(lineParam);
}
if (CollectionUtil.isNotEmpty(dataIList)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -237,4 +264,63 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
}

View File

@@ -2,6 +2,10 @@ package com.njcn.dataProcess.service.impl.influxdb;
import cn.hutool.core.collection.CollectionUtil;
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;
@@ -18,10 +22,12 @@ 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;
/**
@@ -39,6 +45,17 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
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");
}};
@Override
public void batchInsertion(List<DataFlucDTO> dataFlucDTOList) {
@@ -62,7 +79,12 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
@Override
public List<DataFlucDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataFlucDto> result = new ArrayList<>();
List<DataFluc> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataFlucDto dto = new DataFlucDto();
BeanUtils.copyProperties(item,dto);
@@ -75,7 +97,12 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataFluc> dataIList = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(dataIList)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -191,4 +218,53 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
}
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
}

View File

@@ -4,15 +4,17 @@ 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;
import com.njcn.dataProcess.po.influx.DataHarmrateI;
import com.njcn.dataProcess.po.influx.DataHarmrateV;
import com.njcn.dataProcess.po.influx.DataI;
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
import com.njcn.dataProcess.pojo.dto.DataHarmRateIDto;
import com.njcn.dataProcess.pojo.dto.DataIDto;
import com.njcn.dataProcess.pojo.po.RStatDataHarmRateID;
import com.njcn.dataProcess.service.IDataHarmRateI;
import com.njcn.dataProcess.util.TimeUtils;
@@ -26,6 +28,7 @@ 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;
/**
@@ -37,11 +40,27 @@ 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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
public List<DataHarmRateIDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmRateIDto> result = new ArrayList<>();
List<DataHarmrateI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataHarmRateIDto dto = new DataHarmRateIDto();
BeanUtils.copyProperties(item,dto);
@@ -54,7 +73,12 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmrateI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -225,4 +249,47 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
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()));
}
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;
}
}

View File

@@ -4,6 +4,10 @@ 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.DataHarmRateVMapper;
import com.njcn.dataProcess.dao.relation.mapper.RStatDataHarmRateVRelationMapper;
@@ -14,7 +18,6 @@ import com.njcn.dataProcess.po.influx.DataV;
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
import com.njcn.dataProcess.pojo.dto.DataHarmDto;
import com.njcn.dataProcess.pojo.dto.DataHarmRateVDto;
import com.njcn.dataProcess.pojo.dto.DataVDto;
import com.njcn.dataProcess.pojo.po.RStatDataHarmRateVD;
import com.njcn.dataProcess.service.IDataHarmRateV;
import com.njcn.dataProcess.util.TimeUtils;
@@ -25,10 +28,12 @@ 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;
/**
@@ -41,11 +46,27 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
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");
}};
@Override
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmDto> result = new ArrayList<>();
List<DataHarmrateV> list = getMinuteData(lineParam);
List<DataHarmrateV> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteData(lineParam);
} else {
list = getMinuteData(lineParam);;
}
list.forEach(item->{
DataHarmDto dto = new DataHarmDto();
BeanUtils.copyProperties(item,dto);
@@ -77,7 +98,12 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmrateV> data = getMinuteData(lineParam);
List<DataHarmrateV> data;
if (Objects.equals(lineParam.getType(), 2)) {
data = getWlMinuteData(lineParam);
} else {
data = getMinuteData(lineParam);;
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -292,4 +318,56 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
}

View File

@@ -4,6 +4,10 @@ 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;
@@ -21,10 +25,12 @@ 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;
/**
@@ -40,6 +46,17 @@ 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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
public void batchInsertion(List<DataHarmphasicIDTO> dataHarmphasicIDTOList) {
@@ -62,7 +79,12 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
@Override
public List<DataHarmPhasicIDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmPhasicIDto> result = new ArrayList<>();
List<DataHarmphasicI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataHarmPhasicIDto dto = new DataHarmPhasicIDto();
BeanUtils.copyProperties(item,dto);
@@ -75,7 +97,12 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmphasicI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -245,4 +272,48 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
}
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()));
}
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;
}
}

View File

@@ -4,10 +4,15 @@ 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.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,10 +27,12 @@ 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;
/**
@@ -42,6 +49,17 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
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");
}};
@Override
@@ -66,7 +84,12 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
@Override
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmDto> result = new ArrayList<>();
List<DataHarmphasicV> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataHarmDto dto = new DataHarmDto();
BeanUtils.copyProperties(item,dto);
@@ -79,7 +102,12 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmphasicV> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -249,4 +277,57 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
}
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
}

View File

@@ -4,10 +4,16 @@ 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;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.po.influx.DataHarmphasicI;
import com.njcn.dataProcess.po.influx.DataHarmphasicV;
import com.njcn.dataProcess.po.influx.DataHarmpowerP;
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
import com.njcn.dataProcess.pojo.dto.DataHarmPowerPDto;
@@ -22,10 +28,12 @@ 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;
/**
@@ -42,6 +50,17 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
@@ -65,7 +84,12 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<DataPowerPDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataPowerPDto> result = new ArrayList<>();
List<DataHarmpowerP> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(), lineParam.getDataType());
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.forEach(item->{
DataPowerPDto dto = new DataPowerPDto();
BeanUtils.copyProperties(item,dto);
@@ -78,7 +102,12 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmpowerP> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(), lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -255,4 +284,54 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
}
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);
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmP_", "p_", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
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")
//总功功率
.select("Pq_P","p")
//基波有功功率
.select("Pq_FundP","p_1")
.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()));
}
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;
}
}

View File

@@ -4,6 +4,10 @@ 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;
@@ -21,10 +25,12 @@ 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;
/**
@@ -40,6 +46,17 @@ 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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
@@ -63,7 +80,12 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<DataHarmPowerQDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmPowerQDto> result = new ArrayList<>();
List<DataHarmpowerQ> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataHarmPowerQDto dto = new DataHarmPowerQDto();
BeanUtils.copyProperties(item,dto);
@@ -76,7 +98,12 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmpowerQ> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -250,4 +277,49 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
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);
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmQ_", "q_", 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)
//总功功率
.select("Pq_Q","q")
//基波有功功率
.select("Pq_FundQ","q_1")
.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()));
}
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;
}
}

View File

@@ -4,6 +4,10 @@ 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;
@@ -21,10 +25,12 @@ 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;
/**
@@ -40,6 +46,17 @@ 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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
@@ -63,7 +80,12 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<DataHarmPowerSDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmPowerSDto> result = new ArrayList<>();
List<DataHarmpowerS> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(), lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataHarmPowerSDto dto = new DataHarmPowerSDto();
BeanUtils.copyProperties(item,dto);
@@ -76,7 +98,12 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataHarmpowerS> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -250,4 +277,49 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
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);
influxQueryWrapper.samePrefixAndSuffix("Pq_HarmS_", "s_", 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)
//总功功率
.select("Pq_S","s")
//基波有功功率
.select("Pq_FundS","s_1")
.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()));
}
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;
}
}

View File

@@ -4,16 +4,17 @@ 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;
import com.njcn.dataProcess.dto.DataIDTO;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.po.influx.DataHarmrateV;
import com.njcn.dataProcess.po.influx.DataI;
import com.njcn.dataProcess.po.influx.DataV;
import com.njcn.dataProcess.pojo.dto.CommonMinuteDto;
import com.njcn.dataProcess.pojo.dto.DataHarmDto;
import com.njcn.dataProcess.pojo.dto.DataIDto;
import com.njcn.dataProcess.pojo.po.RStatDataID;
import com.njcn.dataProcess.service.IDataI;
@@ -25,10 +26,12 @@ 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,6 +49,18 @@ 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");
put("CA", "C");
put("M", "T");
}};
@Override
public void batchInsertion(List<DataIDTO> dataIDTOList) {
@@ -68,7 +83,12 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
@Override
public List<DataIDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataIDto> result = new ArrayList<>();
List<DataI> list = getMinuteDataI(lineParam);
List<DataI> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteDataI(lineParam);
} else {
list = getMinuteDataI(lineParam);
}
list.forEach(item->{
DataIDto dto = new DataIDto();
BeanUtils.copyProperties(item,dto);
@@ -81,7 +101,12 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataI> dataIList = getMinuteDataI(lineParam);
List<DataI> dataIList;
if (Objects.equals(lineParam.getType(), 2)) {
dataIList = getWlMinuteDataI(lineParam);
} else {
dataIList = getMinuteDataI(lineParam);
}
if (CollectionUtil.isNotEmpty(dataIList)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -293,4 +318,64 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
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 (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;
}
}

View File

@@ -4,6 +4,10 @@ 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;
@@ -21,10 +25,12 @@ 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;
/**
@@ -40,7 +46,17 @@ 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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
public void batchInsertion(List<DataInharmIDTO> dataInharmIDTOList) {
@@ -63,7 +79,12 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
@Override
public List<DataInHarmIDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataInHarmIDto> result = new ArrayList<>();
List<DataInharmI> list = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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.forEach(item->{
DataInHarmIDto dto = new DataInHarmIDto();
BeanUtils.copyProperties(item,dto);
@@ -76,7 +97,12 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataInharmI> data = getMinuteData(lineParam.getLineId(), lineParam.getStartTime(), lineParam.getEndTime(),lineParam.getAbnormalTime(),lineParam.getDataType());
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());
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -247,4 +273,46 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
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()));
}
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;
}
}

View File

@@ -4,6 +4,10 @@ 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;
@@ -22,10 +26,12 @@ 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;
@@ -43,7 +49,17 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
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");
put("BC", "B");
put("CA", "C");
put("M", "T");
}};
@Override
public void batchInsertion(List<DataInharmVDTO> dataInharmVDTOList) {
@@ -66,7 +82,12 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
@Override
public List<DataHarmDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataHarmDto> result = new ArrayList<>();
List<DataInharmV> list = getMinuteData(lineParam);
List<DataInharmV> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteData(lineParam);
} else {
list = getMinuteData(lineParam);
}
list.forEach(item->{
DataHarmDto dto = new DataHarmDto();
BeanUtils.copyProperties(item,dto);
@@ -79,7 +100,12 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataInharmV> data = getMinuteData(lineParam);
List<DataInharmV> data;
if (Objects.equals(lineParam.getType(), 2)) {
data = getWlMinuteData(lineParam);
} else {
data = getMinuteData(lineParam);
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -252,4 +278,54 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
}
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()));
}
//判断接线方式 (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;
}
}

View File

@@ -3,6 +3,10 @@ package com.njcn.dataProcess.service.impl.influxdb;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
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;
@@ -20,10 +24,12 @@ 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;
/**
@@ -40,6 +46,17 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
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");
}};
@Override
public void batchInsertion(List<DataPltDTO> dataPltDTOList) {
@@ -63,7 +80,12 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
@Override
public List<DataPltDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataPltDto> result = new ArrayList<>();
List<DataPlt> list = getMinuteDataPlt(lineParam);
List<DataPlt> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteDataPlt(lineParam);
} else {
list = getMinuteDataPlt(lineParam);
}
list.forEach(item->{
DataPltDto dto = new DataPltDto();
BeanUtils.copyProperties(item,dto);
@@ -76,7 +98,12 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataPlt> data = getMinuteDataPlt(lineParam);
List<DataPlt> data;
if (Objects.equals(lineParam.getType(), 2)) {
data = getWlMinuteDataPlt(lineParam);
} else {
data = getMinuteDataPlt(lineParam);
}
if (CollectionUtil.isNotEmpty(data)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -199,4 +226,56 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
}

View File

@@ -6,6 +6,10 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
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;
@@ -34,6 +38,7 @@ 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,6 +51,17 @@ 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;
@@ -122,14 +138,20 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
@Override
public List<DataVDto> getRawData(LineCountEvaluateParam lineParam) {
List<DataVDto> result = new ArrayList<>();
List<DataV> list = getMinuteDataV(lineParam);
list.forEach(item -> {
DataVDto dto = new DataVDto();
BeanUtils.copyProperties(item, dto);
dto.setMinTime(DATE_TIME_FORMATTER.format(item.getTime()));
result.add(dto);
});
List<DataV> list;
if (Objects.equals(lineParam.getType(), 2)) {
list = getWlMinuteDataV(lineParam);
} else {
list = getMinuteDataV(lineParam);
}
if (CollectionUtil.isNotEmpty(list)) {
list.forEach(item -> {
DataVDto dto = new DataVDto();
BeanUtils.copyProperties(item, dto);
dto.setMinTime(DATE_TIME_FORMATTER.format(item.getTime()));
result.add(dto);
});
}
return result;
}
@@ -205,7 +227,12 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
@Override
public List<CommonMinuteDto> getBaseData(LineCountEvaluateParam lineParam) {
List<CommonMinuteDto> result = new ArrayList<>();
List<DataV> dataVList = getMinuteDataV(lineParam);
List<DataV> dataVList;
if (Objects.equals(lineParam.getType(), 2)) {
dataVList = getWlMinuteDataV(lineParam);
} else {
dataVList = getMinuteDataV(lineParam);
}
if (CollectionUtil.isNotEmpty(dataVList)) {
String time = TimeUtils.StringTimeToString(lineParam.getStartTime());
//以监测点分组
@@ -403,7 +430,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
/**
* 按监测点集合、时间条件获取dataV分钟数据
* timeMap参数来判断是否进行数据出来 timeMap为空则不进行数据处理
* timeMap参数来判断是否进行数据处理 timeMap为空则不进行数据处理
* 剔除异常数据,这里会有三种情况判断
* 1.无异常数据,则直接返回集合;
* 2.异常数据和无异常数据参杂,剔除异常数据,只计算正常数据;
@@ -412,7 +439,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
public List<DataV> getMinuteDataV(LineCountEvaluateParam lineParam) {
List<DataV> result = new ArrayList<>();
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataV.class);
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.regular(DataV::getLineId, lineParam.getLineId())
.select(DataV::getLineId)
.select(DataV::getPhasicType)
@@ -439,6 +466,90 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
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 -> {
String newType = PHASE_MAPPING.get(item.getPhasicType());
if (newType != null) {
item.setPhasicType(newType);
}
});
}
}
return result;
}
private void quality(List<DataV> result, InfluxQueryWrapper influxQueryWrapper, LineCountEvaluateParam lineParam) {
List<DataV> dataList;
List<DataV> list = dataVMapper.selectByQueryWrapper(influxQueryWrapper);

View File

@@ -0,0 +1,53 @@
package com.njcn.dataProcess.service.impl.relation;
import cn.hutool.core.collection.CollectionUtil;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.dataProcess.dao.relation.mapper.RMpVThdMapper;
import com.njcn.dataProcess.pojo.dto.RMpVThd;
import com.njcn.dataProcess.service.IRMpVThdService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/24 17:58
*/
@Service("RelationRMpVThdServiceImpl")
@Slf4j
public class RelationRMpVThdServiceImpl extends MppServiceImpl<RMpVThdMapper, RMpVThd> implements IRMpVThdService {
@Override
@Transactional(rollbackFor = {Exception.class})
public List<RMpVThd> queryHarmonicVThd(CalculatedParam calculatedParam) {
log.info(LocalDateTime.now()+"===>监测点谐波畸变率开始执行");
List<String> lineIds = calculatedParam.getIdList();
List<RMpVThd> rMpVThdList = new ArrayList<>();
//以尺寸100分片,查询数据
List<List<String>> pendingIds = ListUtils.partition(lineIds,5);
for (List<String> pendingId : pendingIds) {
List<RMpVThd> result = this.baseMapper.getVThdData(calculatedParam.getDataDate(),pendingId);
if (CollectionUtil.isNotEmpty(result)){
rMpVThdList.addAll(result);
}
}
return rMpVThdList;
}
@Override
public void batchInsertionThd(List<RMpVThd> result) {
this.saveOrUpdateBatchByMultiId(result);
}
}

View File

@@ -0,0 +1,592 @@
package com.njcn.dataProcess.websocket;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.njcn.algorithm.pojo.bo.BaseParam;
import com.njcn.algorithm.pojo.liteflow.LiteFlowAlgorithmFeignClient;
import com.njcn.dataProcess.annotation.InsertBean;
import com.njcn.dataProcess.annotation.QueryBean;
import com.njcn.dataProcess.dto.RecallReplyDTO;
import com.njcn.dataProcess.param.FullRecallMessage;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.DataIntegrityDto;
import com.njcn.dataProcess.service.IDataIntegrity;
import com.njcn.dataProcess.service.IDataV;
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
import com.njcn.device.pq.api.DeviceFeignClient;
import com.njcn.device.pq.pojo.dto.DeviceDTO;
import com.njcn.message.api.ProduceFeignClient;
import com.njcn.message.constant.RedisKeyPrefix;
import com.njcn.message.message.RecallMessage;
import com.njcn.message.messagedto.TopicReplyDTO;
import com.njcn.redis.utils.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Description:
* Date: 2024/12/13 15:11【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@Component
@ServerEndpoint(value ="/api/recell/{userId}")
public class RecallWebSocketServer {
@QueryBean
private static IDataV dataVQuery;
@Autowired
@Qualifier("InfluxdbDataVImpl")
public void setDataVQuery( IDataV dataVQuery) {
RecallWebSocketServer.dataVQuery = dataVQuery;
}
private static CommTerminalGeneralClient commTerminalGeneralClient;
@Autowired
public void setCommTerminalGeneralClient(CommTerminalGeneralClient commTerminalGeneralClient) {
RecallWebSocketServer.commTerminalGeneralClient = commTerminalGeneralClient;
}
private static ProduceFeignClient produceFeignClient;
@Autowired
public void setProduceFeignClient(ProduceFeignClient produceFeignClient) {
RecallWebSocketServer.produceFeignClient = produceFeignClient;
}
@InsertBean
private static IDataIntegrity iDataIntegrityInsert;
@Autowired
@Qualifier("RelationDataIntegrityImpl")
public void setiDataIntegrityInsert(IDataIntegrity iDataIntegrityInsert) {
RecallWebSocketServer.iDataIntegrityInsert = iDataIntegrityInsert;
}
private static LiteFlowAlgorithmFeignClient liteFlowAlgorithmFeignClient;
@Autowired
public void setLiteFlowAlgorithmFeignClient(LiteFlowAlgorithmFeignClient liteFlowAlgorithmFeignClient) {
RecallWebSocketServer.liteFlowAlgorithmFeignClient = liteFlowAlgorithmFeignClient;
}
private static RedisUtil redisUtil;
@Autowired
public void setRedisUtil( RedisUtil redisUtil) {
RecallWebSocketServer.redisUtil = redisUtil;
}
private static DeviceFeignClient deviceFeignClient;
// 注入的时候,给类的 service 注入
@Autowired
public void setLineFeignClient(DeviceFeignClient deviceFeignClient) {
RecallWebSocketServer.deviceFeignClient = deviceFeignClient;
}
/**
* 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
*/
private static int onlineCount = 0;
/**
* concurrent包的线程安全Set用来存放每个客户端对应的WebSocket对象。
*/
private static ConcurrentHashMap<String, RecallWebSocketServer> webSocketMap = new ConcurrentHashMap<>();
/**
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
*/
private Session session;
/**
* 接收userId
*/
private String userId = "";
/**
* 连接建立成
* 功调用的方法
*/
@OnOpen
public void onOpen(Session session, @PathParam("userId") String userId) {
//lineId 是 userid+","+lineId+","+Devid
this.session = session;
this.userId = userId;
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
//加入set中
webSocketMap.put(userId, this);
} else {
//加入set中
webSocketMap.put(userId, this);
//在线数加1
addOnlineCount();
}
sendMessage("连接成功");
}
/**
* 连接关闭
* 调用的方法
*/
@OnClose
public void onClose() {
if (webSocketMap.containsKey(userId)) {
webSocketMap.remove(userId);
//从set中删除
subOnlineCount();
}
log.info("用户退出:" + userId + ",当前在线监测点数为:" + getOnlineCount());
}
/**
* 收到客户端消
* 息后调用的方法
*
* @param message 客户端发送过来的消息
**/
@OnMessage
public void onMessage(String message, Session session) {
//会每30s发送请求1次
log.info("监测点消息:" + userId + ",报文:" + message);
if(Objects.equals(message,"alive")){
sendInfo("connect");
return;
}
FullRecallMessage param = JSONUtil.toBean(message,FullRecallMessage.class,true);
if(Objects.isNull(message)){
RecallReplyDTO recallReplyDTO = new RecallReplyDTO(500,"参数有误");
sendInfo(JSONObject.toJSONString(recallReplyDTO));
}else {
List<String> runMonitorIds = param.getMonitorId();
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setLineId(runMonitorIds);
//查看监测点的数据完整性
lineParam.setStartTime( LocalDateTimeUtil.format( param.getReCallStartTime(), DatePattern.NORM_DATETIME_FORMATTER));
lineParam.setEndTime(LocalDateTimeUtil.format( param.getReCallEndTime(), DatePattern.NORM_DATETIME_FORMATTER));
List<DataIntegrityDto> rawData = iDataIntegrityInsert.getRawData(lineParam);
Map<String, Map<String, List<DataIntegrityDto>>> collect1 = rawData.stream().collect(Collectors.groupingBy(DataIntegrityDto::getLineIndex, Collectors.groupingBy(DataIntegrityDto::getTimeId)));
List<BaseParam> bsParmList = new ArrayList<>();
runMonitorIds.forEach(temp->{
LineDevGetDTO data = commTerminalGeneralClient.getMonitorDetail(temp).getData();
//后续根据不同前置下的测点发送补招密令
DeviceDTO data2 = deviceFeignClient.getDeviceInfo(data.getDevId()).getData();
LocalDateTime currentDate = param.getReCallStartTime();
//循环每一天
while (!currentDate.isAfter(param.getReCallEndTime())) {
String key ="";
LocalDateTime tempTime = currentDate.toLocalDate().plusDays(1).atTime(0,0,0);
//查看数据完整性,根据数据完整性进行补招;
//校验数据完整性完整率>=98%不补招完整率80%~98%,差量补招,完整率<=80%,全量补招
Integer recallType = 1; //1全量补 2:差量补 3不需要补招
String curDateString = LocalDateTimeUtil.format(currentDate.toLocalDate().atTime(0, 0, 0), DatePattern.NORM_DATETIME_FORMATTER);
if(collect1.containsKey(temp)&&collect1.get(temp).containsKey(curDateString)){
DataIntegrityDto dto = collect1.get(temp).get(curDateString).get(0);
if( dto.getDueTime()!=0){
double i = (double)dto.getRealTime() / dto.getDueTime();
if( i>=0.98){
recallType=3;
} else if(i<0.98&&i>0.8){
recallType=2;
}
}
}
// 确定补招时间段
LocalDateTime toDayBeginTime,toDayEndTime;
if(tempTime.isAfter(param.getReCallEndTime())){
toDayBeginTime =currentDate;
toDayEndTime = param.getReCallEndTime();
}else {
toDayBeginTime =currentDate;
toDayEndTime = tempTime;
}
RecallReplyDTO recallReplyDTO = new RecallReplyDTO(300,"监测点:"+data.getPointName()+";日期:"+currentDate.toLocalDate()+"开始补招");
sendInfo(JSONObject.toJSONString(recallReplyDTO));
//暂态补招
RecallMessage.RecallDTO recallDTO2 = new RecallMessage.RecallDTO();
recallDTO2.setDataType("1");
recallDTO2.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
String tempTimeInterval = formatInterval(toDayBeginTime, toDayEndTime);
recallDTO2.setTimeInterval(Stream.of(tempTimeInterval).collect(Collectors.toList()));
recallDTO2.setNodeId(data2.getNodeId());
RecallMessage eventMessage = new RecallMessage();
eventMessage.setNodeId(data2.getNodeId());
eventMessage.setData(Stream.of(recallDTO2).collect(Collectors.toList()));
String guid1 = IdUtil.simpleUUID();
eventMessage.setGuid(guid1);
produceFeignClient.recall(eventMessage);
if(recallType ==3){
}else if(recallType ==2){
Integer timeInterval = data.getTimeInterval();
List<LocalDateTime> localDateTimeList = generateTimeIntervals( toDayBeginTime,toDayBeginTime, timeInterval);
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format( currentDate.toLocalDate(), DatePattern.NORM_DATE_PATTERN));
localDateTimeList.removeAll(data1);
if(!CollectionUtils.isEmpty(localDateTimeList)){
List<String> timePeriod = mergeTimeIntervals(localDateTimeList, timeInterval);
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
//
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
recallDTO.setTimeInterval(timePeriod);
recallDTO.setNodeId(data2.getNodeId());
RecallMessage recallMessage = new RecallMessage();
recallMessage.setNodeId(data2.getNodeId());
recallMessage.setData(Stream.of(recallDTO).collect(Collectors.toList()));
String guid = IdUtil.simpleUUID();
recallMessage.setGuid(guid);
produceFeignClient.recall(recallMessage);
// boolean flag =true;
// LocalDateTime beginTaskTime = LocalDateTime.now();
// while (flag){
// if(Duration.between(beginTaskTime, LocalDateTime.now()).toMinutes()<=5){
// key =RedisKeyPrefix.TOPIC_REPLY.concat(temp).concat(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
//
// String jsonString =redisUtil.getStringByKey(key);
// if(Objects.nonNull(jsonString)){
// TopicReplyDTO bean = JSONUtil.toBean(jsonString, TopicReplyDTO.class, true);
// redisUtil.delete(key);
// flag =false;
// RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,bean.getResult());
//
// sendInfo(JSONObject.toJSONString(recallReplyDTO2));
//
// BaseParam baseParam = new BaseParam();
// baseParam.setFullChain(false);
// baseParam.setRepair(false);
// baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
// baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
// baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
// bsParmList.add(baseParam);
// }
// }else {
// flag =false;
// RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,"监测点:"+data.getPointName()+";日期:"+currentDate.toLocalDate()+"执行补招程序超时");
//
// sendInfo(JSONObject.toJSONString(recallReplyDTO2));
//
// BaseParam baseParam = new BaseParam();
// baseParam.setFullChain(false);
// baseParam.setRepair(false);
// baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
// baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
// baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
// bsParmList.add(baseParam);
// }
//
// }
}
}else {
//暂态补招
RecallMessage.RecallDTO recallDTO = new RecallMessage.RecallDTO();
//不设置dataType暂态稳态全部补招
recallDTO.setDataType("0");
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
String eventTime = formatInterval(toDayBeginTime,toDayEndTime);
recallDTO.setTimeInterval(Stream.of(eventTime).collect(Collectors.toList()));
recallDTO.setNodeId(data2.getNodeId());
RecallMessage recallMessage = new RecallMessage();
recallMessage.setNodeId(data2.getNodeId());
recallMessage.setData(Stream.of(recallDTO).collect(Collectors.toList()));
String guid = IdUtil.simpleUUID();
recallMessage.setGuid(guid);
produceFeignClient.recall(recallMessage);
//
//
// boolean flag =true;
// LocalDateTime beginTaskTime = LocalDateTime.now();
// while (flag){
// if(Duration.between(beginTaskTime, LocalDateTime.now()).toMinutes()<=5){
// key =RedisKeyPrefix.TOPIC_REPLY.concat(temp).concat(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
//
// String jsonString =redisUtil.getStringByKey(key);
// if(Objects.nonNull(jsonString)){
// TopicReplyDTO bean = JSONUtil.toBean(jsonString, TopicReplyDTO.class, true);
// redisUtil.delete(key);
//
// flag =false;
// RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,bean.getResult());
//
// sendInfo(JSONObject.toJSONString(recallReplyDTO2));
//
// BaseParam baseParam = new BaseParam();
// baseParam.setFullChain(false);
// baseParam.setRepair(false);
// baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
// baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
// baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
// bsParmList.add(baseParam);
// }
// }else {
// flag =false;
// RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,"监测点:"+data.getPointName()+";日期:"+currentDate.toLocalDate()+"超时");
//
// sendInfo(JSONObject.toJSONString(recallReplyDTO2));
// BaseParam baseParam = new BaseParam();
// baseParam.setFullChain(false);
// baseParam.setRepair(false);
// baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
// baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
// baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
// bsParmList.add(baseParam);
// }
//
// }
}
boolean flag =true;
LocalDateTime beginTaskTime = LocalDateTime.now();
while (flag){
if(Duration.between(beginTaskTime, LocalDateTime.now()).toMinutes()<=10){
key =RedisKeyPrefix.TOPIC_REPLY.concat(temp).concat(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
String jsonString =redisUtil.getStringByKey(key);
if(Objects.nonNull(jsonString)){
TopicReplyDTO bean = JSONUtil.toBean(jsonString, TopicReplyDTO.class, true);
redisUtil.delete(key);
flag =false;
RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,bean.getResult());
sendInfo(JSONObject.toJSONString(recallReplyDTO2));
BaseParam baseParam = new BaseParam();
baseParam.setFullChain(false);
baseParam.setRepair(false);
baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
bsParmList.add(baseParam);
}
}else {
flag =false;
RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,"监测点:"+data.getPointName()+";日期:"+currentDate.toLocalDate()+"执行补招程序超时");
sendInfo(JSONObject.toJSONString(recallReplyDTO2));
BaseParam baseParam = new BaseParam();
baseParam.setFullChain(false);
baseParam.setRepair(false);
baseParam.setDataDate(currentDate.toLocalDate().format(DatePattern.NORM_DATE_FORMATTER));
baseParam.setTagNames(Stream.of("dataIntegrity").collect(Collectors.toSet()));
baseParam.setIdList(Stream.of(temp).collect(Collectors.toList()));
bsParmList.add(baseParam);
}
}
currentDate = tempTime;
}
});
if(!CollectionUtils.isEmpty(bsParmList)){
RecallReplyDTO recallReplyDTO = new RecallReplyDTO(300,"开始执行数据完整性算法");
sendInfo(JSONObject.toJSONString(recallReplyDTO));
bsParmList.forEach(temp->{
liteFlowAlgorithmFeignClient.measurementPointExecutor(temp);
});
RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(300,"执行完成");
sendInfo(JSONObject.toJSONString(recallReplyDTO2));
}
}
RecallReplyDTO recallReplyDTO2 = new RecallReplyDTO(200,"补招任务结束");
sendInfo(JSONObject.toJSONString(recallReplyDTO2));
}
public List<LocalDateTime> generateTimeIntervals(LocalDate date, int intervalMinutes) {
List<LocalDateTime> dateTimeList = new ArrayList<>();
// Create the starting LocalDateTime
LocalDateTime startDateTime = LocalDateTime.of(date, LocalTime.MIDNIGHT);
// Create the ending LocalDateTime
LocalDateTime endDateTime = LocalDateTime.of(date, LocalTime.MAX);
// Generate LocalDateTime list with the given interval
LocalDateTime currentDateTime = startDateTime;
while (!currentDateTime.isAfter(endDateTime)) {
dateTimeList.add(currentDateTime);
currentDateTime = currentDateTime.plusMinutes(intervalMinutes);
}
return dateTimeList;
}
public List<LocalDateTime> generateTimeIntervals(LocalDateTime startDateTime,LocalDateTime endDateTime , int intervalMinutes) {
List<LocalDateTime> dateTimeList = new ArrayList<>();
// Generate LocalDateTime list with the given interval
LocalDateTime currentDateTime = startDateTime;
while (!currentDateTime.isAfter(endDateTime)) {
dateTimeList.add(currentDateTime);
currentDateTime = currentDateTime.plusMinutes(intervalMinutes);
}
return dateTimeList;
}
public static List<String> mergeTimeIntervals(List<LocalDateTime> times, int intervalMinutes) {
List<String> mergedIntervals = new ArrayList<>();
if (times == null || times.isEmpty()) {
return mergedIntervals;
}
// Sort the list to ensure the times are in order
times.sort(LocalDateTime::compareTo);
LocalDateTime start = times.get(0);
LocalDateTime end = start;
for (int i = 1; i < times.size(); i++) {
LocalDateTime current = times.get(i);
if (current.isAfter(end.plusMinutes(intervalMinutes))) {
// If the current time is more than interval minutes after the end, close the current interval
mergedIntervals.add(formatInterval(start, end));
start = current; // Start a new interval
}
end = current; // Update the end of the current interval
}
// Add the last interval
mergedIntervals.add(formatInterval(start, end));
return mergedIntervals;
}
private static String formatInterval(LocalDateTime start, LocalDateTime end) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return start.format(formatter) + "~" + end.format(formatter);
}
/**
* @param session
* @param error
*/
@OnError
public void onError(Session session, Throwable error) {
log.error("用户错误:" + this.userId + ",原因:" + error.getMessage());
error.printStackTrace();
}
/**
* 实现服务
* 器主动推送
*/
public void sendMessage(String message) {
try {
this.session.getBasicRemote().sendText(message);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 发送自定
* 义消息
**/
public static void sendInfo(String message) {
webSocketMap.forEach((k,v)->{
webSocketMap.get(k).sendMessage(message);
});
}
/**
* 获得此时的
* 在线监测点
*
* @return
*/
public static synchronized int getOnlineCount() {
return onlineCount;
}
/**
* 在线监测点
* 数加1
*/
public static synchronized void addOnlineCount() {
RecallWebSocketServer.onlineCount++;
}
/**
* 在线监测点
* 数减1
*/
public static synchronized void subOnlineCount() {
RecallWebSocketServer.onlineCount--;
}
// /**
// * 过滤所有键包含指定字符串的条目
// * @param map 原始的Map
// * @param substring 要检查的子字符串
// * @return 过滤的Map
// */
// public static Map<String, String> filterMapByKey(ConcurrentHashMap<String, RecallWebSocketServer> map, String substring) {
// Map<String, String> result = new HashMap<>();
// for (Map.Entry<String, RecallWebSocketServer> entry : map.entrySet()) {
// if (entry.getKey().contains(substring)) {
// result.put(entry.getKey(), entry.getValue().toString());
// }
// }
// return result;
// }
}

View File

@@ -0,0 +1,41 @@
package com.njcn.dataProcess.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean;
/**
* Description:
* Date: 2024/12/13 15:09【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
/**
* 通信文本消息和二进制缓存区大小
* 避免对接 第三方 报文过大时Websocket 1009 错误
*
* @return
*/
@Bean
public ServletServerContainerFactoryBean createWebSocketContainer() {
ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean();
// 在此处设置bufferSize
container.setMaxTextMessageBufferSize(10240000);
container.setMaxBinaryMessageBufferSize(10240000);
container.setMaxSessionIdleTimeout(15 * 60000L);
return container;
}
}

View File

@@ -49,6 +49,7 @@ public class DeviceRebootMessage {
private String series;
//终端识别码
private String devKey;
private Integer processNo;
//
private List<MonitorInfo> monitorData;

View File

@@ -15,7 +15,7 @@ import java.time.LocalDateTime;
* @version V1.0.0
*/
@Data
public class DevComFlagDTO extends BaseMessage implements Serializable {
public class DevComFlagDTO extends BaseMessage implements Serializable {
private String id;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

View File

@@ -16,6 +16,7 @@ import java.io.Serializable;
public class FrontLogslMessage extends BaseMessage implements Serializable {
private String nodeId;
private String processNo;
private String code;
private String businessId;
private String level;
private String logType;

View File

@@ -1,9 +1,14 @@
package com.njcn.message.messagedto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.njcn.middle.rocket.domain.BaseMessage;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* Description:
@@ -14,11 +19,22 @@ import java.io.Serializable;
*/
@Data
public class TopicReplyDTO extends BaseMessage implements Serializable {
//消息id
//消息id guid="12345"是补招回复结果
private String guid;
private String step;
//guid="12345"是补招回复结果
private String result;
private String lineIndex;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime recallStartDate;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime recallEndDate;
}

View File

@@ -64,19 +64,19 @@ public class DeviceRunFlagDataConsumer extends EnhanceConsumerMessageHandler<Dev
*/
@Override
public boolean filter(DevComFlagDTO message) {
String keyStatus = redisUtil.getStringByKey(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()));
if (Objects.isNull(keyStatus) || keyStatus.equalsIgnoreCase(MessageStatus.FAIL)) {
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(message.getKey()), MessageStatus.BEING_PROCESSED, 30L);
return false;
}
return true;
// String keyStatus = redisUtil.getStringByKey(AppRedisKey.RMQ_CONSUME_KEY.concat(message.getKey()));
// if (Objects.isNull(keyStatus) || keyStatus.equalsIgnoreCase(MessageStatus.FAIL)) {
// redisUtil.saveByKeyWithExpire(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(message.getKey()), MessageStatus.BEING_PROCESSED, 30L);
// return false;
// }
return false;
}
/**
* 消费成功缓存到redis72小时避免重复消费
*/
@Override
protected void consumeSuccess(DevComFlagDTO message) {
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(message.getKey()), MessageStatus.SUCCESS, 5*60L);
// redisUtil.saveByKeyWithExpire(RedisKeyPrefix.DEVICE_RUN_FLAG.concat(message.getKey()), MessageStatus.SUCCESS, 5*60L);
}

View File

@@ -70,7 +70,7 @@ public class FrontHeartBeatConsumer extends EnhanceConsumerMessageHandler<FrontH
// redisUtil.saveByKeyWithExpire(RedisKeyPrefix.HEART_BEAT.concat(message.getKey()), MessageStatus.BEING_PROCESSED, 30L);
// return false;
// }
return true;
return false;
}
/**
* 消费成功缓存到redis72小时避免重复消费

View File

@@ -74,7 +74,7 @@ public class RealTimeDataConsumer extends EnhanceConsumerMessageHandler<MessageD
*/
@Override
protected void consumeSuccess(MessageDataDTO message) {
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.REAL_TIME_DATA.concat(message.getKey()), MessageStatus.SUCCESS, 5*60L);
// redisUtil.saveByKeyWithExpire(RedisKeyPrefix.REAL_TIME_DATA.concat(message.getKey()), MessageStatus.SUCCESS, 5*60L);
}

View File

@@ -129,7 +129,7 @@ public class TopicLogsConsumer extends EnhanceConsumerMessageHandler<FrontLogslM
*/
@Override
protected boolean isRetry() {
return true;
return false;
}

View File

@@ -1,12 +1,12 @@
package com.njcn.message.consumer;
import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.JSONObject;
import com.njcn.message.constant.MessageStatus;
import com.njcn.message.messagedto.TopicReplyDTO;
import com.njcn.message.constant.RedisKeyPrefix;
import com.njcn.middle.rocket.constant.EnhanceMessageConstant;
import com.njcn.middle.rocket.handler.EnhanceConsumerMessageHandler;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.pojo.enums.RedisKeyEnum;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.stat.api.MessAnalysisFeignClient;
@@ -76,14 +76,20 @@ public class TopicReplyConsumer extends EnhanceConsumerMessageHandler<TopicReply
*/
@Override
protected void consumeSuccess(TopicReplyDTO message) {
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
// redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getKey()), MessageStatus.SUCCESS, RedisKeyEnum.ROCKET_MQ_KEY.getTime());
}
@Override
protected void handleMessage(TopicReplyDTO message) {
//业务处理
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getGuid()),JSONObject.toJSONString(message),60*60L);
//“12345”补招回复
if(Objects.equals(message.getGuid(),"12345")){
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getLineIndex().concat(message.getRecallStartDate().toLocalDate().format(DatePattern.NORM_DATE_FORMATTER))),JSONObject.toJSONString(message),1*60L);
}else {
//业务处理
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getGuid()),JSONObject.toJSONString(message),60*60L);
}
}

View File

@@ -67,11 +67,24 @@ public class MigrationInfluxDBJob {
// 加上59分钟59秒
LocalDateTime modifiedResultOld = resultOld.plusMinutes(59).plusSeconds(59);
LineCountEvaluateParam paramOld = new LineCountEvaluateParam();
paramOld.setIsManual(false);
paramOld.setIsManual(true);
paramOld.setStartTime(resultOld.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
paramOld.setEndTime(modifiedResultOld.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
migrationService.hourseLineDataBacthSysc(paramOld);
migrationService.hourseDevDataBacthSysc(paramOld);
// //定时任务在往前补俩小时的
// LocalDateTime oneHourAgoOld2 = now.minusHours(4);
// // 将分钟和秒设置为0
// LocalDateTime resultOld2 = oneHourAgoOld2.truncatedTo(ChronoUnit.HOURS);
// // 加上59分钟59秒
// LocalDateTime modifiedResultOld2 = resultOld2.plusMinutes(59).plusSeconds(59);
// LineCountEvaluateParam paramOld2 = new LineCountEvaluateParam();
// paramOld2.setIsManual(true);
// paramOld2.setStartTime(resultOld2.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
// paramOld2.setEndTime(modifiedResultOld2.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)));
// migrationService.hourseLineDataBacthSysc(paramOld2);
// migrationService.hourseDevDataBacthSysc(paramOld2);
}
@Scheduled(cron = "0 0 22 * * ?")