Compare commits
33 Commits
0383bff7fd
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e49dee8263 | ||
|
|
e126a3f800 | ||
|
|
f09409c553 | ||
|
|
63f20da451 | ||
| 1043097a11 | |||
| 713db187c5 | |||
| 6b21e9927a | |||
|
|
c5cb96e8d6 | ||
|
|
76f9c9cb10 | ||
| 386fd1ed1e | |||
| d8d516f63d | |||
|
|
074c020b10 | ||
|
|
af781010f6 | ||
| ca0dd1eea0 | |||
|
|
76deaeee71 | ||
|
|
6a6f7c2f77 | ||
|
|
b0972ba896 | ||
|
|
5afb860467 | ||
|
|
2624d7d495 | ||
|
|
bc1854258d | ||
|
|
438f618d8a | ||
| 89df5f3039 | |||
|
|
8ce1f83531 | ||
|
|
14a13d631c | ||
|
|
11ee847cac | ||
|
|
9261adb79a | ||
|
|
e0154fb3ef | ||
|
|
7bee39f076 | ||
|
|
99f12e74fb | ||
|
|
648a5e1947 | ||
|
|
f519fd3e56 | ||
|
|
536ee24888 | ||
|
|
2159525ed9 |
@@ -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;
|
||||
}
|
||||
|
||||
@@ -42,4 +42,8 @@ public interface LiteFlowAlgorithmFeignClient {
|
||||
@ApiOperation("新能源专项分析算法执行链")
|
||||
@PostMapping("/specialAnalysis")
|
||||
void specialAnalysisExecutor(@RequestBody BaseParam baseParam);
|
||||
|
||||
@ApiOperation("物联监测点算法执行链")
|
||||
@PostMapping("/wlMeasurementPointExecutor")
|
||||
void wlMeasurementPointExecutor(@RequestBody BaseParam baseParam);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
|
||||
/**
|
||||
@@ -16,6 +17,7 @@ import org.springframework.context.annotation.DependsOn;
|
||||
@SpringBootApplication(scanBasePackages = "com.njcn")
|
||||
@MapperScan("com.njcn.**.mapper")
|
||||
@DependsOn("proxyMapperRegister")
|
||||
@EnableAsync
|
||||
public class AlgorithmBootApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -2,19 +2,25 @@ 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.text.StrPool;
|
||||
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.util.StrUtil;
|
||||
import com.njcn.algorithm.pojo.bo.BaseParam;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.pojo.bo.HourParam;
|
||||
import com.njcn.algorithm.pojo.enums.PrepareResponseEnum;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.algorithm.service.line.FlowAsyncService;
|
||||
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;
|
||||
@@ -22,7 +28,6 @@ import com.njcn.user.pojo.po.Dept;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.yomahub.liteflow.core.FlowExecutor;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -39,6 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import static com.njcn.algorithm.utils.MemorySizeUtil.dealResponse;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
@@ -62,6 +68,10 @@ public class ExecutionCenter extends BaseController {
|
||||
private FlowExecutor flowExecutor;
|
||||
@Resource
|
||||
private DeptLineFeignClient deptLineFeignClient;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
@Resource
|
||||
private FlowAsyncService flowService;
|
||||
|
||||
/***
|
||||
* 1、校验非全链执行时,tagNames节点标签集合必须为非空,否则提示---无可执行节点
|
||||
@@ -86,41 +96,6 @@ public class ExecutionCenter extends BaseController {
|
||||
return calculatedParam;
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @author hongawen
|
||||
* @date 2023/11/7 14:44
|
||||
*/
|
||||
private void dealResponse(CalculatedParam calculatedParam, LiteflowResponse liteflowResponse, String methodDescribe) {
|
||||
MemorySizeUtil.getNowMemory();
|
||||
if (liteflowResponse.isSuccess()) {
|
||||
// 获取执行步骤列表
|
||||
long allTime = 0;
|
||||
Map<String, List<CmpStep>> executeSteps = liteflowResponse.getExecuteSteps();
|
||||
for (String key : executeSteps.keySet()) {
|
||||
List<CmpStep> cmpSteps = executeSteps.get(key);
|
||||
long timeSum = cmpSteps.stream().mapToLong(CmpStep::getTimeSpent).sum();
|
||||
allTime+=timeSum;
|
||||
}
|
||||
logger.info("日期{},{}执行{}成功,执行总时长{}分钟", calculatedParam.getDataDate(), methodDescribe, calculatedParam.isFullChain() ? "全链" : "指定节点:".concat(String.join(StrPool.COMMA, calculatedParam.getTagNames())),allTime/1000/60);
|
||||
} else {
|
||||
Map<String, List<CmpStep>> executeSteps = liteflowResponse.getExecuteSteps();
|
||||
CmpStep failStep = null;
|
||||
for (String key : executeSteps.keySet()) {
|
||||
List<CmpStep> cmpSteps = executeSteps.get(key);
|
||||
cmpSteps = cmpSteps.stream().filter(cmpStep -> !cmpStep.isSuccess()).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(cmpSteps)) {
|
||||
failStep = cmpSteps.get(0);
|
||||
}
|
||||
}
|
||||
logger.error("日期{},{}执行{}失败,在执行{}失败,失败原因:{}"
|
||||
, calculatedParam.getDataDate()
|
||||
, methodDescribe
|
||||
, calculatedParam.isFullChain() ? "全链" : "指定节点:".concat(String.join(StrPool.COMMA, calculatedParam.getTagNames()))
|
||||
, failStep.getNodeId().concat(Objects.isNull(failStep.getTag()) ? "" : StrPool.DASHED.concat(failStep.getTag()))
|
||||
, Objects.isNull(failStep.getException()) ? null : failStep.getException().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -142,20 +117,54 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
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("measurement_point", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
CalculatedParam repairParam = BeanUtil.copyProperties(calculatedParam, CalculatedParam.class);
|
||||
flowService.execute2Resp(methodDescribe, repairParam);
|
||||
}
|
||||
} else {
|
||||
//非补招
|
||||
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));
|
||||
calculatedParam.setType(2);
|
||||
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)
|
||||
@@ -177,7 +186,7 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
for (int i = 0; i <= betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
@@ -190,7 +199,7 @@ public class ExecutionCenter extends BaseController {
|
||||
liteflowResponse = flowExecutor.execute2Resp("special_analysis", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -220,7 +229,7 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATETIME_FORMAT);
|
||||
long betweenHour = DateUtil.between(startDate, endDate, DateUnit.HOUR);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenHour; i++) {
|
||||
for (int i = 0; i <= betweenHour; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetHour(startDate, 1);
|
||||
}
|
||||
@@ -234,7 +243,7 @@ public class ExecutionCenter extends BaseController {
|
||||
liteflowResponse = flowExecutor.execute2Resp("measurement_point_hour", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -262,7 +271,7 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
for (int i = 0; i <= betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
@@ -275,7 +284,7 @@ public class ExecutionCenter extends BaseController {
|
||||
liteflowResponse = flowExecutor.execute2Resp("device", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@@ -301,7 +310,7 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
for (int i = 0; i <= betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
@@ -314,7 +323,7 @@ public class ExecutionCenter extends BaseController {
|
||||
liteflowResponse = flowExecutor.execute2Resp("org_point", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
@@ -389,7 +398,7 @@ public class ExecutionCenter extends BaseController {
|
||||
DateTime endDate = DateUtil.parse(baseParam.getEndTime(), DatePattern.NORM_DATE_FORMAT);
|
||||
long betweenDay = DateUtil.betweenDay(startDate, endDate, true);
|
||||
//递增日期执行算法链
|
||||
for (int i = 0; i < betweenDay; i++) {
|
||||
for (int i = 0; i <= betweenDay; i++) {
|
||||
if (i != 0) {
|
||||
startDate = DateUtil.offsetDay(startDate, 1);
|
||||
}
|
||||
@@ -402,7 +411,7 @@ public class ExecutionCenter extends BaseController {
|
||||
liteflowResponse = flowExecutor.execute2Resp("sub_station", calculatedParam);
|
||||
dealResponse(calculatedParam, liteflowResponse, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//
|
||||
// /**
|
||||
|
||||
@@ -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;
|
||||
/**
|
||||
* 数据质量清洗
|
||||
*/
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.dataProcess.pojo.dto.PqReasonableRangeDto;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailVO;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FlowAsyncService {
|
||||
|
||||
/**
|
||||
* 算法多线程执行
|
||||
* @param methodDescribe
|
||||
* @param calculatedParam
|
||||
* @Author: wr
|
||||
* @Date: 2025/12/17 9:25
|
||||
*/
|
||||
void execute2Resp(String methodDescribe,CalculatedParam calculatedParam);
|
||||
|
||||
|
||||
/**
|
||||
* 多线程数据清洗方法
|
||||
* @param line
|
||||
* @param map
|
||||
* @param dataDate
|
||||
* @param dip
|
||||
* @param rise
|
||||
* @param size
|
||||
* @param i
|
||||
* @Author: wr
|
||||
* @Date: 2025/12/17 10:48
|
||||
*/
|
||||
void lineDataClean(LineDetailVO.Detail line,
|
||||
Map<String, List<PqReasonableRangeDto>> map,
|
||||
String dataDate,
|
||||
DictData dip,
|
||||
DictData rise,
|
||||
int size,
|
||||
int i
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@@ -92,4 +94,5 @@ public interface IDataCleanService {
|
||||
* @param calculatedParam 查询条件
|
||||
*/
|
||||
void dataFlickerCleanHandler(CalculatedParam calculatedParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.njcn.algorithm.service.line;
|
||||
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IDataLimitRateAsync {
|
||||
|
||||
/**
|
||||
* limit_rate多线程算法
|
||||
* @param dataDate
|
||||
* @param list
|
||||
* @param phase
|
||||
* @param overLimitMap
|
||||
* @param size
|
||||
* @param i
|
||||
* @Author: wr
|
||||
* @Date: 2025/12/17 12:16
|
||||
*/
|
||||
void lineDataRate(String dataDate,
|
||||
List<String> list,
|
||||
List<String> phase,
|
||||
Map<String, Overlimit> overLimitMap,
|
||||
int size,
|
||||
int i);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//指标处理
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,22 +6,19 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.algorithm.service.line.IDataCrossingService;
|
||||
import com.njcn.algorithm.service.line.IDataLimitRateAsync;
|
||||
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;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.*;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerify;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
@@ -38,7 +35,9 @@ 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.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -54,209 +53,45 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DayDataServiceImpl.class);
|
||||
@Value("${line.num}")
|
||||
private Integer NUM = 100;
|
||||
@Resource
|
||||
private DataVFeignClient dataVFeignClient;
|
||||
private Integer NUM;
|
||||
|
||||
@Resource
|
||||
private CommTerminalGeneralClient commTerminalGeneralClient;
|
||||
@Resource
|
||||
private DataIFeignClient dataIFeignClient;
|
||||
@Resource
|
||||
private DataPltFeignClient dataPltFeignClient;
|
||||
@Resource
|
||||
private DataInharmVFeignClient dataInharmVFeignClient;
|
||||
@Resource
|
||||
private DataHarmRateVFeignClient dataHarmRateVFeignClient;
|
||||
@Resource
|
||||
private DataLimitRateFeignClient dataLimitRateFeignClient;
|
||||
@Resource
|
||||
private DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient;
|
||||
@Resource
|
||||
private PqDataVerifyFeignClient pqDataVerifyFeignClient;
|
||||
@Resource
|
||||
private DataLimitTargetFeignClient dataLimitTargetFeignClient;
|
||||
@Resource
|
||||
private DataLimitQualifiedFeignClient dataLimitQualifiedFeignClient;
|
||||
|
||||
@Resource
|
||||
private IDataLimitRateAsync dataLimitRateAsync;
|
||||
@Resource
|
||||
private CsLineFeignClient csLineFeignClient;
|
||||
|
||||
@Override
|
||||
public void limitRateHandler(CalculatedParam calculatedParam) {
|
||||
MemorySizeUtil.getNowMemory();
|
||||
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
// 获取 JVM 最大可用内存(以字节为单位)
|
||||
long maxMemory = runtime.maxMemory();
|
||||
// 获取 JVM 当前已分配的内存(以字节为单位)
|
||||
long totalMemory = runtime.totalMemory();
|
||||
// 获取 JVM 当前空闲内存(以字节为单位)
|
||||
long freeMemory = runtime.freeMemory();
|
||||
// 计算已使用的内存
|
||||
long usedMemory = totalMemory - freeMemory;
|
||||
|
||||
System.out.println("最大可用内存: " + maxMemory / (1024 * 1024) + " MB");
|
||||
System.out.println("当前已分配的内存: " + totalMemory / (1024 * 1024) + " MB");
|
||||
System.out.println("当前空闲内存: " + freeMemory / (1024 * 1024) + " MB");
|
||||
System.out.println("已使用的内存: " + usedMemory / (1024 * 1024) + " MB");
|
||||
System.out.println("第一次分析结束-----------------------------------------");
|
||||
|
||||
logger.info("{},limitRate表转r_stat_limit_rate_d算法开始=====》", LocalDateTime.now());
|
||||
System.err.println("limitRate表转r_stat_limit_rate_d算法开始,执行日期为{}=====》"+calculatedParam.getDataDate());
|
||||
List<DataLimitDetailDto> result = new ArrayList<>();
|
||||
//远程接口获取分钟数据
|
||||
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();
|
||||
Map<String, Overlimit> overLimitMap = overLimitList.stream().collect(Collectors.toMap(Overlimit::getId, Function.identity()));
|
||||
//添加异常数据时间点
|
||||
getAbnormalData(lineParam);
|
||||
//以100个监测点分片处理
|
||||
List<List<String>> pendingIds = ListUtils.partition(lineIds, NUM);
|
||||
List<List<String>> pendingIds = ListUtils.partition(lineIds, 1);
|
||||
ArrayList<String> phase = ListUtil.toList(PhaseType.PHASE_A, PhaseType.PHASE_B, PhaseType.PHASE_C);
|
||||
MemorySizeUtil.getNowMemory();
|
||||
pendingIds.forEach(list -> {
|
||||
lineParam.setLineId(list);
|
||||
//获取电压数据
|
||||
List<DataVDto> dataVAllTime = dataVFeignClient.getRawData(lineParam).getData();
|
||||
//闪变数据
|
||||
List<DataPltDto> dataFlickerAllTime = dataPltFeignClient.getRawData(lineParam).getData();
|
||||
//谐波数据
|
||||
List<DataHarmDto> dataVHarmList = dataHarmRateVFeignClient.getRawData(lineParam).getData();
|
||||
//间谐波数据
|
||||
List<DataHarmDto> dataVInHarmList = dataInharmVFeignClient.getRawData(lineParam).getData();
|
||||
//电流数据
|
||||
List<DataIDto> dataIList = dataIFeignClient.getRawData(lineParam).getData();
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v ->
|
||||
* 总计算次数(用data_v中phasic_type=A,value_type=avg,quality_flag=0来参与统计)
|
||||
*/
|
||||
Map<String, List<DataVDto>> allTime = dataVAllTime.stream()
|
||||
.filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDbSqlConstant.AVG_WEB.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_plt ->
|
||||
* 闪变总计算次数(用data_plt中phasic_type=A,quality_flag=0来参与统计)
|
||||
*/
|
||||
Map<String, List<DataPltDto>> flickerAllTime = dataFlickerAllTime.stream()
|
||||
.filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType()))
|
||||
.collect(Collectors.groupingBy(DataPltDto::getLineId));
|
||||
|
||||
/**
|
||||
*功能描述:获取influxDB -> data_harmrate_v ->
|
||||
* 2-25次谐波电压含有率 -> A相||B相||C相的日95%概率值
|
||||
*/
|
||||
Map<String, List<DataHarmDto>> harmRateV = dataVHarmList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataHarmDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_i -> 2-25次谐波电流 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataIDto>> dataI = dataIList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataIDto::getLineId));
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_inharm_v -> 0.5-15.5次间谐波电压含有率 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataHarmDto>> inHarmV = dataVInHarmList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataHarmDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 电压总谐波畸变率 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVThd = dataVAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 负序电压不平衡度 -> 最大值 && 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVUnbalance = dataVAllTime.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_i -> 负序电流 -> 最大值 && 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataIDto>> dataINeg = dataIList.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataIDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 频率偏差 -> 最大值 && 最小值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVFreq = dataVAllTime.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.MIN.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 电压偏差 -> 最大值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVDev = dataVAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_plt -> 长时间闪变 -> 注(取最大值原始算法去掉了,现没有根据最大值比较)
|
||||
*/
|
||||
Map<String, List<DataPltDto>> dataPlt = dataFlickerAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.collect(Collectors.groupingBy(DataPltDto::getLineId));
|
||||
|
||||
for (String item : list) {
|
||||
if(ObjectUtil.isNotNull(overLimitMap.get(item))){
|
||||
result.addAll(getData(calculatedParam.getDataDate(),
|
||||
overLimitMap.get(item),
|
||||
allTime.get(item),
|
||||
flickerAllTime.get(item),
|
||||
harmRateV.get(item),
|
||||
dataI.get(item),
|
||||
inHarmV.get(item),
|
||||
dataVThd.get(item),
|
||||
dataVUnbalance.get(item),
|
||||
dataINeg.get(item),
|
||||
dataVFreq.get(item),
|
||||
dataVDev.get(item),
|
||||
dataPlt.get(item)));
|
||||
}
|
||||
}
|
||||
});
|
||||
MemorySizeUtil.getNowMemory();
|
||||
if (CollUtil.isNotEmpty(result)) {
|
||||
//存储数据
|
||||
List<DataLimitRateDto> dataLimitRate = result.stream().map(DataLimitDetailDto::getDataLimitRate).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(dataLimitRate)){
|
||||
dataLimitRateFeignClient.batchInsertion(dataLimitRate);
|
||||
}
|
||||
|
||||
for (int i = 0; i < pendingIds.size(); i++) {
|
||||
logger.info(calculatedParam.getDataDate()+" 总分区数据:" + pendingIds.size() + "=====》当前第"+(i + 1)+"小分区");
|
||||
List<String> list = pendingIds.get(i);
|
||||
dataLimitRateAsync.lineDataRate(calculatedParam.getDataDate(), list, phase, overLimitMap, pendingIds.size(), (i + 1));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(result)) {
|
||||
//存储数据
|
||||
List<DataLimitRateDetailDto> detail = result.stream().map(DataLimitDetailDto::getDataLimitRateDetail).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(detail)){
|
||||
dataLimitRateDetailFeignClient.batchInsertion(detail);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System.gc();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -461,664 +296,6 @@ public class IDataCrossingServiceImpl implements IDataCrossingService {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description: getData
|
||||
* @Param: [overlimit, allTimeList, flickerAllTimeList, dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVPOUnbalanceList, dataIPONegList, dataVPOFreqList, dataVPODevList, dataPltPOList]
|
||||
* @return: java.util.List<com.njcn.harmonic.pojo.po.LimitRate>
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/18
|
||||
*/
|
||||
private List<DataLimitDetailDto> getData(String dataDate,
|
||||
Overlimit overlimit,
|
||||
List<DataVDto> allTimeList,
|
||||
List<DataPltDto> flickerAllTimeList,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPOUnbalanceList,
|
||||
List<DataIDto> dataIPONegList,
|
||||
List<DataVDto> dataVPOFreqList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
List<DataLimitDetailDto> result = new ArrayList<>();
|
||||
|
||||
Map<String, List<DataHarmDto>> harmRateVByPhaseType = new HashMap<>();
|
||||
Map<String, List<DataIDto>> dataIByPhaseType = new HashMap<>();
|
||||
Map<String, List<DataHarmDto>> dataInHarmVPhaseType = new HashMap<>();
|
||||
Map<String, List<DataVDto>> dataVPhaseType = new HashMap<>();
|
||||
Map<String, List<DataVDto>> dataVDevPhaseType = new HashMap<>();
|
||||
Map<String, List<DataPltDto>> dataPltPhaseType = new HashMap<>();
|
||||
|
||||
|
||||
Integer allTime = 0;
|
||||
Integer flickerAllTime = 0;
|
||||
if (!CollectionUtils.isEmpty(allTimeList)) {
|
||||
allTime = allTimeList.size();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(flickerAllTimeList)) {
|
||||
flickerAllTime = flickerAllTimeList.size();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
harmRateVByPhaseType = dataHarmRateVPOList.stream().collect(Collectors.groupingBy(DataHarmDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
dataIByPhaseType = dataIPOList.stream().collect(Collectors.groupingBy(DataIDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
dataInHarmVPhaseType = dataInHarmVPOList.stream().collect(Collectors.groupingBy(DataHarmDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
dataVPhaseType = dataVPOList.stream().collect(Collectors.groupingBy(DataVDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
dataVDevPhaseType = dataVPODevList.stream().collect(Collectors.groupingBy(DataVDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
dataPltPhaseType = dataPltPOList.stream().collect(Collectors.groupingBy(DataPltDto::getPhasicType));
|
||||
}
|
||||
DataLimitDetailDto a = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_A, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_A), dataIByPhaseType.get(PhaseType.PHASE_A), dataInHarmVPhaseType.get(PhaseType.PHASE_A), dataVPhaseType.get(PhaseType.PHASE_A), dataVDevPhaseType.get(PhaseType.PHASE_A), dataPltPhaseType.get(PhaseType.PHASE_A));
|
||||
DataLimitDetailDto b = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_B, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_B), dataIByPhaseType.get(PhaseType.PHASE_B), dataInHarmVPhaseType.get(PhaseType.PHASE_B), dataVPhaseType.get(PhaseType.PHASE_B), dataVDevPhaseType.get(PhaseType.PHASE_B), dataPltPhaseType.get(PhaseType.PHASE_B));
|
||||
DataLimitDetailDto c = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_C, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_C), dataIByPhaseType.get(PhaseType.PHASE_C), dataInHarmVPhaseType.get(PhaseType.PHASE_C), dataVPhaseType.get(PhaseType.PHASE_C), dataVDevPhaseType.get(PhaseType.PHASE_C), dataPltPhaseType.get(PhaseType.PHASE_C));
|
||||
DataLimitDetailDto t = limitRateDataT(dataDate, overlimit, allTime, flickerAllTime, overlimit.getId(), dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVPOUnbalanceList, dataIPONegList, dataVPOFreqList, dataVPODevList, dataPltPOList);
|
||||
result.add(a);
|
||||
result.add(b);
|
||||
result.add(c);
|
||||
result.add(t);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lineParam
|
||||
* @Description:
|
||||
* @Author: wr
|
||||
* @Date: 2025/3/11 9:04
|
||||
*/
|
||||
private void getAbnormalData(LineCountEvaluateParam lineParam) {
|
||||
lineParam.setTableName(DataCleanEnum.DataV.getCode());
|
||||
// 获取异常数据,用于排除异常数据
|
||||
List<PqDataVerify> pqDataVerifies = pqDataVerifyFeignClient.queryData(lineParam).getData();
|
||||
if (CollUtil.isNotEmpty(pqDataVerifies)) {
|
||||
Map<String, List<String>> timeMap = pqDataVerifies.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
PqDataVerify::getLineId,
|
||||
Collectors.mapping(item -> TimeUtils.LocalDateTimeToString(item.getTime()), Collectors.toList())
|
||||
));
|
||||
lineParam.setAbnormalTime(timeMap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: limitRateData
|
||||
* @Param: [overlimit, allTime, flickerAllTime, phasicType, lineId, dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVUnbalanceList, dataINegList]
|
||||
* @return: com.njcn.harmonic.pojo.po.LimitRate
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/18
|
||||
*/
|
||||
public DataLimitDetailDto limitRateData(String dataDate,
|
||||
Overlimit overlimit,
|
||||
Integer allTime,
|
||||
Integer flickerAllTime,
|
||||
String phasicType, String lineId,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
List<AbnormalData> thd = new ArrayList<>(), uDev = new ArrayList<>(), flicker = new ArrayList<>(), freqDev = new ArrayList<>(), uAberrance = new ArrayList<>(), iNeg = new ArrayList<>();
|
||||
DataLimitDetailDto dto = new DataLimitDetailDto();
|
||||
DataLimitRateDto limitRate = new DataLimitRateDto();
|
||||
// 初始化 v 系列列表
|
||||
List<AbnormalData>[] v = new List[24];
|
||||
for (int i = 0; i < 24; i++) {
|
||||
v[i] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
for (DataHarmDto item : dataHarmRateVPOList) {
|
||||
for (int i = 2; i < 26; i++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + i);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getUharm" + i);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)){
|
||||
if (value > limit) {
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}else{
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 i 系列列表
|
||||
List<AbnormalData>[] i = new List[24];
|
||||
for (int j = 0; j < 24; j++) {
|
||||
i[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
for (DataIDto item : dataIPOList) {
|
||||
for (int j = 2; j < 26; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getIx 方法
|
||||
Method getVMethod = DataIDto.class.getMethod("getI" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getIharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (value > limit) {
|
||||
addAbnormalData(i[j - 2], item.getValueType(), item.getPhasicType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 初始化 uHarm 系列列表
|
||||
List<AbnormalData>[] uHarm = new List[16];
|
||||
for (int j = 0; j < 16; j++) {
|
||||
uHarm[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
for (DataHarmDto item : dataInHarmVPOList) {
|
||||
for (int j = 1; j < 17; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getInuharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (value > limit) {
|
||||
addAbnormalData(uHarm[j - 1], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压总谐波畸变率
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
for (DataVDto item : dataVPOList) {
|
||||
if (item.getVThd() > overlimit.getUaberrance()) {
|
||||
addAbnormalData(thd, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
for (DataVDto item : dataVPODevList) {
|
||||
if (item.getVlDev() >= 0) {
|
||||
if (item.getVlDev() > overlimit.getVoltageDev()) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVlDev(), overlimit.getVoltageDev());
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(item.getVuDev()) > Math.abs(overlimit.getUvoltageDev())) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVlDev(), overlimit.getUvoltageDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//长时间闪变
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
for (DataPltDto item : dataPltPOList) {
|
||||
if (item.getPlt() > overlimit.getFlicker()) {
|
||||
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
|
||||
}
|
||||
}
|
||||
}
|
||||
limitRate.setLineId(lineId);
|
||||
limitRate.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
limitRate.setPhasicType(phasicType);
|
||||
limitRate.setAllTime(allTime);
|
||||
limitRate.setFlickerAllTime(flickerAllTime);
|
||||
|
||||
limitRate.setFlickerOvertime(flicker.size());
|
||||
limitRate.setUaberranceOvertime(thd.size());
|
||||
limitRate.setINegOvertime(iNeg.size());
|
||||
limitRate.setFreqDevOvertime(freqDev.size());
|
||||
limitRate.setUbalanceOvertime(uAberrance.size());
|
||||
limitRate.setVoltageDevOvertime(uDev.size());
|
||||
dto.setDataLimitRate(getDataLimitRateDto(limitRate, v, i, uHarm));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
public DataLimitDetailDto limitRateDataT(
|
||||
String dataDate,
|
||||
Overlimit overlimit,
|
||||
Integer allTime,
|
||||
Integer flickerAllTime,
|
||||
String lineId,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPOUnbalanceList,
|
||||
List<DataIDto> dataIPONegList,
|
||||
List<DataVDto> dataVPOFreqList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
DataLimitDetailDto dto = new DataLimitDetailDto();
|
||||
DataLimitRateDto limitRate = new DataLimitRateDto();
|
||||
List<AbnormalData> thd = new ArrayList<>(), uDev = new ArrayList<>(), flicker = new ArrayList<>(), freqDev = new ArrayList<>(), uAberrance = new ArrayList<>(), iNeg = new ArrayList<>();
|
||||
// 初始化 v 系列列表
|
||||
List<AbnormalData>[] v = new List[24];
|
||||
for (int i = 0; i < 24; i++) {
|
||||
v[i] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
for (DataHarmDto item : dataHarmRateVPOList) {
|
||||
for (int i = 2; i < 26; i++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + i);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getUharm" + i);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)){
|
||||
if (value > limit) {
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}else{
|
||||
System.out.println(item);
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 i 系列列表
|
||||
List<AbnormalData>[] i = new List[24];
|
||||
for (int j = 0; j < 24; j++) {
|
||||
i[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
for (DataIDto item : dataIPOList) {
|
||||
for (int j = 2; j < 26; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getIx 方法
|
||||
Method getVMethod = DataIDto.class.getMethod("getI" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getIharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (value > limit) {
|
||||
addAbnormalData(i[j - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 初始化 uHarm 系列列表
|
||||
List<AbnormalData>[] uHarm = new List[16];
|
||||
for (int j = 0; j < 16; j++) {
|
||||
uHarm[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
for (DataHarmDto item : dataInHarmVPOList) {
|
||||
for (int j = 1; j < 17; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getInuharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (value > limit) {
|
||||
addAbnormalData(uHarm[j - 1], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压总谐波畸变率
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
for (DataVDto item : dataVPOList) {
|
||||
if (item.getVThd() > overlimit.getUaberrance()) {
|
||||
addAbnormalData(thd, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
|
||||
}
|
||||
}
|
||||
}
|
||||
//三相电压不平衡度
|
||||
if (!CollectionUtils.isEmpty(dataVPOUnbalanceList)) {
|
||||
for (DataVDto item : dataVPOUnbalanceList) {
|
||||
if (item.getVUnbalance() > overlimit.getUbalance()) {
|
||||
addAbnormalData(uAberrance, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVUnbalance(), overlimit.getUbalance());
|
||||
}
|
||||
}
|
||||
}
|
||||
//负序电流
|
||||
if (!CollectionUtils.isEmpty(dataIPONegList)) {
|
||||
for (DataIDto item : dataIPONegList) {
|
||||
if(ObjectUtil.isNotNull(item.getINeg())){
|
||||
if (item.getINeg() > overlimit.getINeg()) {
|
||||
addAbnormalData(iNeg, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getINeg(), overlimit.getINeg());
|
||||
}
|
||||
}else{
|
||||
System.out.println(item);
|
||||
addAbnormalData(iNeg, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getINeg(), overlimit.getINeg());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//频率偏差
|
||||
if (!CollectionUtils.isEmpty(dataVPOFreqList)) {
|
||||
for (DataVDto item : dataVPOFreqList) {
|
||||
if (item.getFreqDev() > overlimit.getFreqDev()) {
|
||||
addAbnormalData(freqDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getFreqDev(), overlimit.getFreqDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
for (DataVDto item : dataVPODevList) {
|
||||
if (item.getVlDev() >= 0) {
|
||||
if (item.getVlDev() > overlimit.getVoltageDev()) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getMinTime(), item.getValueType(), item.getVlDev(), overlimit.getVoltageDev());
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(item.getVuDev()) > Math.abs(overlimit.getUvoltageDev())) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getMinTime(), item.getValueType(), item.getVlDev(), overlimit.getUvoltageDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//长时间闪变
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
for (DataPltDto item : dataPltPOList) {
|
||||
if (item.getPlt() > overlimit.getFlicker()) {
|
||||
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
|
||||
}
|
||||
}
|
||||
}
|
||||
limitRate.setLineId(lineId);
|
||||
limitRate.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
limitRate.setPhasicType(PhaseType.PHASE_T);
|
||||
limitRate.setAllTime(allTime);
|
||||
limitRate.setFlickerAllTime(flickerAllTime);
|
||||
limitRate.setUaberranceOvertime(thd.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setINegOvertime(iNeg.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setFreqDevOvertime(freqDev.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUbalanceOvertime(uAberrance.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setVoltageDevOvertime(uDev.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setFlickerOvertime(flicker.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm2Overtime(v[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm3Overtime(v[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm4Overtime(v[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm5Overtime(v[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm6Overtime(v[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm7Overtime(v[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm8Overtime(v[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm9Overtime(v[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm10Overtime(v[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm11Overtime(v[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm12Overtime(v[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm13Overtime(v[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm14Overtime(v[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm15Overtime(v[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm16Overtime(v[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm17Overtime(v[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm18Overtime(v[16].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm19Overtime(v[17].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm20Overtime(v[18].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm21Overtime(v[19].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm22Overtime(v[20].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm23Overtime(v[21].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm24Overtime(v[22].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm25Overtime(v[23].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm2Overtime(i[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm3Overtime(i[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm4Overtime(i[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm5Overtime(i[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm6Overtime(i[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm7Overtime(i[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm8Overtime(i[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm9Overtime(i[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm10Overtime(i[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm11Overtime(i[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm12Overtime(i[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm13Overtime(i[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm14Overtime(i[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm15Overtime(i[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm16Overtime(i[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm17Overtime(i[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm18Overtime(i[16].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm19Overtime(i[17].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm20Overtime(i[18].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm21Overtime(i[19].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm22Overtime(i[20].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm23Overtime(i[21].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm24Overtime(i[22].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm25Overtime(i[23].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm1Overtime(uHarm[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm2Overtime(uHarm[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm3Overtime(uHarm[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm4Overtime(uHarm[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm5Overtime(uHarm[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm6Overtime(uHarm[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm7Overtime(uHarm[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm8Overtime(uHarm[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm9Overtime(uHarm[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm10Overtime(uHarm[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm11Overtime(uHarm[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm12Overtime(uHarm[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm13Overtime(uHarm[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm14Overtime(uHarm[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm15Overtime(uHarm[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm16Overtime(uHarm[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
dto.setDataLimitRate(limitRate);
|
||||
|
||||
int detailAllTime = flicker.size() + uAberrance.size() + iNeg.size() + freqDev.size() + thd.size() + uDev.size() +
|
||||
v[0].size() + v[1].size() + v[2].size() + v[3].size() + v[4].size() + v[5].size() + v[6].size() + v[7].size() + v[8].size() + v[9].size() + v[11].size() + v[12].size() + v[13].size() + v[14].size() + v[15].size() + v[16].size() + v[17].size() + v[18].size() + v[19].size() + v[20].size() + v[21].size() + v[22].size() + v[23].size() +
|
||||
i[0].size() + i[1].size() + i[2].size() + i[3].size() + i[4].size() + i[5].size() + i[6].size() + i[7].size() + i[8].size() + i[9].size() + i[10].size() + i[11].size() + i[12].size() + i[13].size() + i[14].size() + i[15].size() + i[16].size() + i[17].size() + i[18].size() + i[19].size() + i[20].size() + i[21].size() + i[22].size() + i[23].size() +
|
||||
uHarm[0].size() + uHarm[1].size() + uHarm[2].size() + uHarm[3].size() + uHarm[4].size() + uHarm[5].size() + uHarm[6].size() + uHarm[7].size() + uHarm[8].size() + uHarm[9].size() + uHarm[10].size() + uHarm[11].size() + uHarm[12].size() + uHarm[13].size() + uHarm[14].size() + uHarm[15].size();
|
||||
if (detailAllTime > 0) {
|
||||
DataLimitRateDetailDto detail = new DataLimitRateDetailDto();
|
||||
detail.setLineId(lineId);
|
||||
detail.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
detail.setFlickerOvertime(toJson(flicker));
|
||||
detail.setUaberranceOvertime(toJson(uAberrance));
|
||||
detail.setINegOvertime(toJson(iNeg));
|
||||
detail.setFreqDevOvertime(toJson(freqDev));
|
||||
detail.setUbalanceOvertime(toJson(thd));
|
||||
detail.setVoltageDevOvertime(toJson(uDev));
|
||||
detail.setUharm2Overtime(toJson(v[0]));
|
||||
detail.setUharm3Overtime(toJson(v[1]));
|
||||
detail.setUharm4Overtime(toJson(v[2]));
|
||||
detail.setUharm5Overtime(toJson(v[3]));
|
||||
detail.setUharm6Overtime(toJson(v[4]));
|
||||
detail.setUharm7Overtime(toJson(v[5]));
|
||||
detail.setUharm8Overtime(toJson(v[6]));
|
||||
detail.setUharm9Overtime(toJson(v[7]));
|
||||
detail.setUharm10Overtime(toJson(v[8]));
|
||||
detail.setUharm11Overtime(toJson(v[9]));
|
||||
detail.setUharm12Overtime(toJson(v[10]));
|
||||
detail.setUharm13Overtime(toJson(v[11]));
|
||||
detail.setUharm14Overtime(toJson(v[12]));
|
||||
detail.setUharm15Overtime(toJson(v[13]));
|
||||
detail.setUharm16Overtime(toJson(v[14]));
|
||||
detail.setUharm17Overtime(toJson(v[15]));
|
||||
detail.setUharm18Overtime(toJson(v[16]));
|
||||
detail.setUharm19Overtime(toJson(v[17]));
|
||||
detail.setUharm20Overtime(toJson(v[18]));
|
||||
detail.setUharm21Overtime(toJson(v[19]));
|
||||
detail.setUharm22Overtime(toJson(v[20]));
|
||||
detail.setUharm23Overtime(toJson(v[21]));
|
||||
detail.setUharm24Overtime(toJson(v[22]));
|
||||
detail.setUharm25Overtime(toJson(v[23]));
|
||||
detail.setIharm2Overtime(toJson(i[0]));
|
||||
detail.setIharm3Overtime(toJson(i[1]));
|
||||
detail.setIharm4Overtime(toJson(i[2]));
|
||||
detail.setIharm5Overtime(toJson(i[3]));
|
||||
detail.setIharm6Overtime(toJson(i[4]));
|
||||
detail.setIharm7Overtime(toJson(i[5]));
|
||||
detail.setIharm8Overtime(toJson(i[6]));
|
||||
detail.setIharm9Overtime(toJson(i[7]));
|
||||
detail.setIharm10Overtime(toJson(i[8]));
|
||||
detail.setIharm11Overtime(toJson(i[9]));
|
||||
detail.setIharm12Overtime(toJson(i[10]));
|
||||
detail.setIharm13Overtime(toJson(i[11]));
|
||||
detail.setIharm14Overtime(toJson(i[12]));
|
||||
detail.setIharm15Overtime(toJson(i[13]));
|
||||
detail.setIharm16Overtime(toJson(i[14]));
|
||||
detail.setIharm17Overtime(toJson(i[15]));
|
||||
detail.setIharm18Overtime(toJson(i[16]));
|
||||
detail.setIharm19Overtime(toJson(i[17]));
|
||||
detail.setIharm20Overtime(toJson(i[18]));
|
||||
detail.setIharm21Overtime(toJson(i[19]));
|
||||
detail.setIharm22Overtime(toJson(i[20]));
|
||||
detail.setIharm23Overtime(toJson(i[21]));
|
||||
detail.setIharm24Overtime(toJson(i[22]));
|
||||
detail.setIharm25Overtime(toJson(i[23]));
|
||||
detail.setInuharm1Overtime(toJson(uHarm[0]));
|
||||
detail.setInuharm2Overtime(toJson(uHarm[1]));
|
||||
detail.setInuharm3Overtime(toJson(uHarm[2]));
|
||||
detail.setInuharm4Overtime(toJson(uHarm[3]));
|
||||
detail.setInuharm5Overtime(toJson(uHarm[4]));
|
||||
detail.setInuharm6Overtime(toJson(uHarm[5]));
|
||||
detail.setInuharm7Overtime(toJson(uHarm[6]));
|
||||
detail.setInuharm8Overtime(toJson(uHarm[7]));
|
||||
detail.setInuharm9Overtime(toJson(uHarm[8]));
|
||||
detail.setInuharm10Overtime(toJson(uHarm[9]));
|
||||
detail.setInuharm11Overtime(toJson(uHarm[10]));
|
||||
detail.setInuharm12Overtime(toJson(uHarm[11]));
|
||||
detail.setInuharm13Overtime(toJson(uHarm[12]));
|
||||
detail.setInuharm14Overtime(toJson(uHarm[13]));
|
||||
detail.setInuharm15Overtime(toJson(uHarm[14]));
|
||||
detail.setInuharm16Overtime(toJson(uHarm[15]));
|
||||
dto.setDataLimitRateDetail(detail);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
private DataLimitRateDto getDataLimitRateDto(DataLimitRateDto limitRate, List<AbnormalData>[] v, List<AbnormalData>[] i, List<AbnormalData>[] uHarm) {
|
||||
limitRate.setUharm2Overtime(v[0].size());
|
||||
limitRate.setUharm3Overtime(v[1].size());
|
||||
limitRate.setUharm4Overtime(v[2].size());
|
||||
limitRate.setUharm5Overtime(v[3].size());
|
||||
limitRate.setUharm6Overtime(v[4].size());
|
||||
limitRate.setUharm7Overtime(v[5].size());
|
||||
limitRate.setUharm8Overtime(v[6].size());
|
||||
limitRate.setUharm9Overtime(v[7].size());
|
||||
limitRate.setUharm10Overtime(v[8].size());
|
||||
limitRate.setUharm11Overtime(v[9].size());
|
||||
limitRate.setUharm12Overtime(v[10].size());
|
||||
limitRate.setUharm13Overtime(v[11].size());
|
||||
limitRate.setUharm14Overtime(v[12].size());
|
||||
limitRate.setUharm15Overtime(v[13].size());
|
||||
limitRate.setUharm16Overtime(v[14].size());
|
||||
limitRate.setUharm17Overtime(v[15].size());
|
||||
limitRate.setUharm18Overtime(v[16].size());
|
||||
limitRate.setUharm19Overtime(v[17].size());
|
||||
limitRate.setUharm20Overtime(v[18].size());
|
||||
limitRate.setUharm21Overtime(v[19].size());
|
||||
limitRate.setUharm22Overtime(v[20].size());
|
||||
limitRate.setUharm23Overtime(v[21].size());
|
||||
limitRate.setUharm24Overtime(v[22].size());
|
||||
limitRate.setUharm25Overtime(v[23].size());
|
||||
limitRate.setIharm2Overtime(i[0].size());
|
||||
limitRate.setIharm3Overtime(i[1].size());
|
||||
limitRate.setIharm4Overtime(i[2].size());
|
||||
limitRate.setIharm5Overtime(i[3].size());
|
||||
limitRate.setIharm6Overtime(i[4].size());
|
||||
limitRate.setIharm7Overtime(i[5].size());
|
||||
limitRate.setIharm8Overtime(i[6].size());
|
||||
limitRate.setIharm9Overtime(i[7].size());
|
||||
limitRate.setIharm10Overtime(i[8].size());
|
||||
limitRate.setIharm11Overtime(i[9].size());
|
||||
limitRate.setIharm12Overtime(i[10].size());
|
||||
limitRate.setIharm13Overtime(i[11].size());
|
||||
limitRate.setIharm14Overtime(i[12].size());
|
||||
limitRate.setIharm15Overtime(i[13].size());
|
||||
limitRate.setIharm16Overtime(i[14].size());
|
||||
limitRate.setIharm17Overtime(i[15].size());
|
||||
limitRate.setIharm18Overtime(i[16].size());
|
||||
limitRate.setIharm19Overtime(i[17].size());
|
||||
limitRate.setIharm20Overtime(i[18].size());
|
||||
limitRate.setIharm21Overtime(i[19].size());
|
||||
limitRate.setIharm22Overtime(i[20].size());
|
||||
limitRate.setIharm23Overtime(i[21].size());
|
||||
limitRate.setIharm24Overtime(i[22].size());
|
||||
limitRate.setIharm25Overtime(i[23].size());
|
||||
limitRate.setInuharm1Overtime(uHarm[0].size());
|
||||
limitRate.setInuharm2Overtime(uHarm[1].size());
|
||||
limitRate.setInuharm3Overtime(uHarm[2].size());
|
||||
limitRate.setInuharm4Overtime(uHarm[3].size());
|
||||
limitRate.setInuharm5Overtime(uHarm[4].size());
|
||||
limitRate.setInuharm6Overtime(uHarm[5].size());
|
||||
limitRate.setInuharm7Overtime(uHarm[6].size());
|
||||
limitRate.setInuharm8Overtime(uHarm[7].size());
|
||||
limitRate.setInuharm9Overtime(uHarm[8].size());
|
||||
limitRate.setInuharm10Overtime(uHarm[9].size());
|
||||
limitRate.setInuharm11Overtime(uHarm[10].size());
|
||||
limitRate.setInuharm12Overtime(uHarm[11].size());
|
||||
limitRate.setInuharm13Overtime(uHarm[12].size());
|
||||
limitRate.setInuharm14Overtime(uHarm[13].size());
|
||||
limitRate.setInuharm15Overtime(uHarm[14].size());
|
||||
limitRate.setInuharm16Overtime(uHarm[15].size());
|
||||
return limitRate;
|
||||
}
|
||||
|
||||
private String toJson(List<AbnormalData> list) {
|
||||
Map<String, List<AbnormalData>> abnormalMap = list.stream().collect(Collectors.groupingBy(x -> x.getPhasic() + "_" + x.getValueType()));
|
||||
List<AbnormalData.Json> info = new ArrayList<>();
|
||||
abnormalMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
AbnormalData.Json json = new AbnormalData.Json();
|
||||
json.setPhasic(split[0]);
|
||||
json.setValueType(split[1]);
|
||||
json.setTime(String.join(",", value.stream()
|
||||
.map(abnormal -> abnormal.getTime())
|
||||
.collect(Collectors.toList())));
|
||||
json.setValue(String.join(",", value.stream()
|
||||
.map(abnormal -> abnormal.getValue() + "")
|
||||
.collect(Collectors.toList())));
|
||||
info.add(json);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(info)) {
|
||||
return JSON.toJSONString(info);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addAbnormalData(List<AbnormalData> list, String phasicType, String valueType, String time, Double value, float overLimitValue) {
|
||||
AbnormalData data = new AbnormalData();
|
||||
data.setTime(time.substring(11, time.length()));
|
||||
data.setPhasic(phasicType);
|
||||
data.setValueType(valueType);
|
||||
data.setValue(value);
|
||||
data.setOverLimitValue(overLimitValue);
|
||||
list.add(data);
|
||||
}
|
||||
|
||||
|
||||
private void chanelData(DataLimitRateDto limitRate, DataLimitTargetDto limitTarget) {
|
||||
//有一个指标超标,allTime则为1
|
||||
int allTime = limitRate.getFreqDevOvertime() + limitRate.getVoltageDevOvertime() + limitRate.getUbalanceOvertime() + limitRate.getUaberranceOvertime() + limitRate.getINegOvertime();
|
||||
|
||||
@@ -0,0 +1,871 @@
|
||||
package com.njcn.algorithm.serviceimpl.line;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.njcn.algorithm.service.line.IDataLimitRateAsync;
|
||||
import com.njcn.algorithm.utils.MemorySizeUtil;
|
||||
import com.njcn.dataProcess.api.*;
|
||||
import com.njcn.dataProcess.constant.PhaseType;
|
||||
import com.njcn.dataProcess.param.LineCountEvaluateParam;
|
||||
import com.njcn.dataProcess.pojo.dto.*;
|
||||
import com.njcn.dataProcess.util.TimeUtils;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.influx.constant.InfluxDbSqlConstant;
|
||||
import com.njcn.influx.pojo.constant.InfluxDBTableConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2025/12/17 10:56
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class IDataLimitRateAsyncImpl implements IDataLimitRateAsync {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(IDataLimitRateAsyncImpl.class);
|
||||
|
||||
@Resource
|
||||
private DataVFeignClient dataVFeignClient;
|
||||
@Resource
|
||||
private DataIFeignClient dataIFeignClient;
|
||||
@Resource
|
||||
private DataPltFeignClient dataPltFeignClient;
|
||||
@Resource
|
||||
private DataInharmVFeignClient dataInharmVFeignClient;
|
||||
@Resource
|
||||
private DataHarmRateVFeignClient dataHarmRateVFeignClient;
|
||||
@Resource
|
||||
private DataLimitRateFeignClient dataLimitRateFeignClient;
|
||||
@Resource
|
||||
private DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
@Async("asyncExecutor")
|
||||
public void lineDataRate(String dataDate,
|
||||
List<String> list,
|
||||
List<String> phase,
|
||||
Map<String, Overlimit> overLimitMap,
|
||||
int size,
|
||||
int i) {
|
||||
List<DataLimitDetailDto> result = new ArrayList<>();
|
||||
LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
|
||||
lineParam.setStartTime(TimeUtils.getBeginOfDay(dataDate));
|
||||
lineParam.setEndTime(TimeUtils.getEndOfDay(dataDate));
|
||||
lineParam.setLineId(list);
|
||||
//获取电压数据
|
||||
List<DataVDto> dataVAllTime = dataVFeignClient.getRawData(lineParam).getData();
|
||||
//闪变数据
|
||||
List<DataPltDto> dataPltAllTime = dataPltFeignClient.getRawData(lineParam).getData();
|
||||
//谐波数据
|
||||
List<DataHarmDto> dataVHarmList = dataHarmRateVFeignClient.getRawData(lineParam).getData();
|
||||
//间谐波数据
|
||||
List<DataHarmDto> dataVInHarmList = dataInharmVFeignClient.getRawData(lineParam).getData();
|
||||
//电流数据
|
||||
List<DataIDto> dataIList = dataIFeignClient.getRawData(lineParam).getData();
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v ->
|
||||
* 总计算次数(用data_v中phasic_type=A,value_type=avg,quality_flag=0来参与统计)
|
||||
*/
|
||||
Map<String, List<DataVDto>> allTime = dataVAllTime.stream()
|
||||
.filter(x -> PhaseType.PHASE_A.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDbSqlConstant.AVG_WEB.equalsIgnoreCase(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_plt ->
|
||||
* 闪变总计算次数(用data_plt中phasic_type=A,value_type=avg,quality_flag=0来参与统计)
|
||||
*/
|
||||
//fixme 冀北现场 闪变原始表没有 value_type 这个参数
|
||||
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));
|
||||
|
||||
/**
|
||||
*功能描述:获取influxDB -> data_harmrate_v ->
|
||||
* 2-25次谐波电压含有率 -> A相||B相||C相的日95%概率值
|
||||
*/
|
||||
Map<String, List<DataHarmDto>> harmRateV = dataVHarmList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataHarmDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_i -> 2-25次谐波电流 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataIDto>> dataI = dataIList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataIDto::getLineId));
|
||||
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_inharm_v -> 0.5-15.5次间谐波电压含有率 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataHarmDto>> inHarmV = dataVInHarmList.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataHarmDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 电压总谐波畸变率 -> 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVThd = dataVAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 负序电压不平衡度 -> 最大值 && 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVUnbalance = dataVAllTime.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_i -> 负序电流 -> 最大值 && 日95%概率值
|
||||
*/
|
||||
Map<String, List<DataIDto>> dataINeg = dataIList.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.CP95.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataIDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 频率偏差 -> 最大值 && 最小值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVFreq = dataVAllTime.stream()
|
||||
.filter(x -> InfluxDBTableConstant.PHASE_TYPE_T.equals(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.MIN.equals(x.getValueType()) ||
|
||||
InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_v -> 电压偏差 -> 最大值
|
||||
*/
|
||||
Map<String, List<DataVDto>> dataVDev = dataVAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.filter(x -> InfluxDBTableConstant.MAX.equals(x.getValueType()))
|
||||
.collect(Collectors.groupingBy(DataVDto::getLineId));
|
||||
|
||||
/**
|
||||
* 功能描述:获取influxDB -> data_plt -> 长时间闪变 -> 注(取最大值原始算法去掉了,现没有根据最大值比较)
|
||||
*/
|
||||
Map<String, List<DataPltDto>> dataPlt = dataPltAllTime.stream()
|
||||
.filter(x -> phase.contains(x.getPhasicType()))
|
||||
.collect(Collectors.groupingBy(DataPltDto::getLineId));
|
||||
|
||||
for (String item : list) {
|
||||
if (ObjectUtil.isNotNull(overLimitMap.get(item))) {
|
||||
result.addAll(getData(dataDate,
|
||||
overLimitMap.get(item),
|
||||
allTime.get(item),
|
||||
pltAllTime.get(item),
|
||||
harmRateV.get(item),
|
||||
dataI.get(item),
|
||||
inHarmV.get(item),
|
||||
dataVThd.get(item),
|
||||
dataVUnbalance.get(item),
|
||||
dataINeg.get(item),
|
||||
dataVFreq.get(item),
|
||||
dataVDev.get(item),
|
||||
dataPlt.get(item)));
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(result)) {
|
||||
//存储数据
|
||||
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)) {
|
||||
//存储数据
|
||||
List<DataLimitRateDetailDto> detail = result.stream().map(DataLimitDetailDto::getDataLimitRateDetail).filter(x -> ObjectUtil.isNotNull(x)).collect(Collectors.toList());
|
||||
if (CollUtil.isNotEmpty(detail)) {
|
||||
dataLimitRateDetailFeignClient.batchInsertion(detail);
|
||||
}
|
||||
}
|
||||
logger.info(dataDate + " 总分区数据:" + size + "=====》当前第" + i + "小分区已完成!");
|
||||
result = null;
|
||||
if(i==size){
|
||||
MemorySizeUtil.getNowMemory();
|
||||
}
|
||||
System.gc();
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: getData
|
||||
* @Param: [overlimit, allTimeList, flickerAllTimeList, dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVPOUnbalanceList, dataIPONegList, dataVPOFreqList, dataVPODevList, dataPltPOList]
|
||||
* @return: java.util.List<com.njcn.harmonic.pojo.po.LimitRate>
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/18
|
||||
*/
|
||||
private List<DataLimitDetailDto> getData(String dataDate,
|
||||
Overlimit overlimit,
|
||||
List<DataVDto> allTimeList,
|
||||
List<DataPltDto> flickerAllTimeList,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPOUnbalanceList,
|
||||
List<DataIDto> dataIPONegList,
|
||||
List<DataVDto> dataVPOFreqList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
List<DataLimitDetailDto> result = new ArrayList<>();
|
||||
|
||||
Map<String, List<DataHarmDto>> harmRateVByPhaseType = new HashMap<>();
|
||||
Map<String, List<DataIDto>> dataIByPhaseType = new HashMap<>();
|
||||
Map<String, List<DataHarmDto>> dataInHarmVPhaseType = new HashMap<>();
|
||||
Map<String, List<DataVDto>> dataVPhaseType = new HashMap<>();
|
||||
Map<String, List<DataVDto>> dataVDevPhaseType = new HashMap<>();
|
||||
Map<String, List<DataPltDto>> dataPltPhaseType = new HashMap<>();
|
||||
|
||||
|
||||
Integer allTime = 0;
|
||||
Integer flickerAllTime = 0;
|
||||
if (!CollectionUtils.isEmpty(allTimeList)) {
|
||||
allTime = allTimeList.size();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(flickerAllTimeList)) {
|
||||
flickerAllTime = flickerAllTimeList.size();
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
harmRateVByPhaseType = dataHarmRateVPOList.stream().collect(Collectors.groupingBy(DataHarmDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
dataIByPhaseType = dataIPOList.stream().collect(Collectors.groupingBy(DataIDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
dataInHarmVPhaseType = dataInHarmVPOList.stream().collect(Collectors.groupingBy(DataHarmDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
dataVPhaseType = dataVPOList.stream().collect(Collectors.groupingBy(DataVDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
dataVDevPhaseType = dataVPODevList.stream().collect(Collectors.groupingBy(DataVDto::getPhasicType));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
dataPltPhaseType = dataPltPOList.stream().collect(Collectors.groupingBy(DataPltDto::getPhasicType));
|
||||
}
|
||||
DataLimitDetailDto a = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_A, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_A), dataIByPhaseType.get(PhaseType.PHASE_A), dataInHarmVPhaseType.get(PhaseType.PHASE_A), dataVPhaseType.get(PhaseType.PHASE_A), dataVDevPhaseType.get(PhaseType.PHASE_A), dataPltPhaseType.get(PhaseType.PHASE_A));
|
||||
DataLimitDetailDto b = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_B, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_B), dataIByPhaseType.get(PhaseType.PHASE_B), dataInHarmVPhaseType.get(PhaseType.PHASE_B), dataVPhaseType.get(PhaseType.PHASE_B), dataVDevPhaseType.get(PhaseType.PHASE_B), dataPltPhaseType.get(PhaseType.PHASE_B));
|
||||
DataLimitDetailDto c = limitRateData(dataDate, overlimit, allTime, flickerAllTime, PhaseType.PHASE_C, overlimit.getId(), harmRateVByPhaseType.get(PhaseType.PHASE_C), dataIByPhaseType.get(PhaseType.PHASE_C), dataInHarmVPhaseType.get(PhaseType.PHASE_C), dataVPhaseType.get(PhaseType.PHASE_C), dataVDevPhaseType.get(PhaseType.PHASE_C), dataPltPhaseType.get(PhaseType.PHASE_C));
|
||||
DataLimitDetailDto t = limitRateDataT(dataDate, overlimit, allTime, flickerAllTime, overlimit.getId(), dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVPOUnbalanceList, dataIPONegList, dataVPOFreqList, dataVPODevList, dataPltPOList);
|
||||
result.add(a);
|
||||
result.add(b);
|
||||
result.add(c);
|
||||
result.add(t);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: limitRateData
|
||||
* @Param: [overlimit, allTime, flickerAllTime, phasicType, lineId, dataHarmRateVPOList, dataIPOList, dataInHarmVPOList, dataVPOList, dataVUnbalanceList, dataINegList]
|
||||
* @return: com.njcn.harmonic.pojo.po.LimitRate
|
||||
* @Author: clam
|
||||
* @Date: 2022/10/18
|
||||
*/
|
||||
public DataLimitDetailDto limitRateData(String dataDate,
|
||||
Overlimit overlimit,
|
||||
Integer allTime,
|
||||
Integer flickerAllTime,
|
||||
String phasicType, String lineId,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
List<AbnormalData> thd = new ArrayList<>(), uDev = new ArrayList<>(), flicker = new ArrayList<>(), freqDev = new ArrayList<>(), uAberrance = new ArrayList<>(), iNeg = new ArrayList<>();
|
||||
DataLimitDetailDto dto = new DataLimitDetailDto();
|
||||
DataLimitRateDto limitRate = new DataLimitRateDto();
|
||||
// 初始化 v 系列列表
|
||||
List<AbnormalData>[] v = new List[24];
|
||||
for (int i = 0; i < 24; i++) {
|
||||
v[i] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
for (DataHarmDto item : dataHarmRateVPOList) {
|
||||
for (int i = 2; i < 26; i++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + i);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getUharm" + i);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 i 系列列表
|
||||
List<AbnormalData>[] i = new List[24];
|
||||
for (int j = 0; j < 24; j++) {
|
||||
i[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
for (DataIDto item : dataIPOList) {
|
||||
for (int j = 2; j < 26; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getIx 方法
|
||||
Method getVMethod = DataIDto.class.getMethod("getI" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getIharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(i[j - 2], item.getValueType(), item.getPhasicType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 初始化 uHarm 系列列表
|
||||
List<AbnormalData>[] uHarm = new List[16];
|
||||
for (int j = 0; j < 16; j++) {
|
||||
uHarm[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
for (DataHarmDto item : dataInHarmVPOList) {
|
||||
for (int j = 1; j < 17; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getInuharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(uHarm[j - 1], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压总谐波畸变率
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
for (DataVDto item : dataVPOList) {
|
||||
if (ObjectUtil.isNotNull(item.getVThd())) {
|
||||
if (item.getVThd() > overlimit.getUaberrance()) {
|
||||
addAbnormalData(thd, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
for (DataVDto item : dataVPODevList) {
|
||||
if (ObjectUtil.isNotNull(item.getVlDev())) {
|
||||
if (item.getVlDev() >= 0) {
|
||||
if (item.getVlDev() > overlimit.getVoltageDev()) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVlDev(), overlimit.getVoltageDev());
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(item.getVuDev()) > Math.abs(overlimit.getUvoltageDev())) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVuDev(), overlimit.getUvoltageDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//长时间闪变
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
for (DataPltDto item : dataPltPOList) {
|
||||
if (ObjectUtil.isNotNull(item.getPlt())) {
|
||||
if (item.getPlt() > overlimit.getFlicker()) {
|
||||
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
limitRate.setLineId(lineId);
|
||||
limitRate.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
limitRate.setPhasicType(phasicType);
|
||||
limitRate.setAllTime(allTime);
|
||||
limitRate.setFlickerAllTime(flickerAllTime);
|
||||
|
||||
limitRate.setFlickerOvertime(flicker.size());
|
||||
limitRate.setUaberranceOvertime(thd.size());
|
||||
limitRate.setINegOvertime(iNeg.size());
|
||||
limitRate.setFreqDevOvertime(freqDev.size());
|
||||
limitRate.setUbalanceOvertime(uAberrance.size());
|
||||
limitRate.setVoltageDevOvertime(uDev.size());
|
||||
dto.setDataLimitRate(getDataLimitRateDto(limitRate, v, i, uHarm));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
public DataLimitDetailDto limitRateDataT(
|
||||
String dataDate,
|
||||
Overlimit overlimit,
|
||||
Integer allTime,
|
||||
Integer flickerAllTime,
|
||||
String lineId,
|
||||
List<DataHarmDto> dataHarmRateVPOList,
|
||||
List<DataIDto> dataIPOList,
|
||||
List<DataHarmDto> dataInHarmVPOList,
|
||||
List<DataVDto> dataVPOList,
|
||||
List<DataVDto> dataVPOUnbalanceList,
|
||||
List<DataIDto> dataIPONegList,
|
||||
List<DataVDto> dataVPOFreqList,
|
||||
List<DataVDto> dataVPODevList,
|
||||
List<DataPltDto> dataPltPOList) {
|
||||
DataLimitDetailDto dto = new DataLimitDetailDto();
|
||||
DataLimitRateDto limitRate = new DataLimitRateDto();
|
||||
//thd 总谐波畸变率
|
||||
List<AbnormalData> sx = new ArrayList<>(), uDev = new ArrayList<>(), flicker = new ArrayList<>(), freqDev = new ArrayList<>(), zxb = new ArrayList<>(), iNeg = new ArrayList<>();
|
||||
// 初始化 v 系列列表
|
||||
List<AbnormalData>[] v = new List[24];
|
||||
for (int i = 0; i < 24; i++) {
|
||||
v[i] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataHarmRateVPOList)) {
|
||||
for (DataHarmDto item : dataHarmRateVPOList) {
|
||||
for (int i = 2; i < 26; i++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + i);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getUharm" + i);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(v[i - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化 i 系列列表
|
||||
List<AbnormalData>[] i = new List[24];
|
||||
for (int j = 0; j < 24; j++) {
|
||||
i[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataIPOList)) {
|
||||
for (DataIDto item : dataIPOList) {
|
||||
for (int j = 2; j < 26; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getIx 方法
|
||||
Method getVMethod = DataIDto.class.getMethod("getI" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getIharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(i[j - 2], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 初始化 uHarm 系列列表
|
||||
List<AbnormalData>[] uHarm = new List[16];
|
||||
for (int j = 0; j < 16; j++) {
|
||||
uHarm[j] = new ArrayList<>();
|
||||
}
|
||||
// 处理数据
|
||||
if (!CollectionUtils.isEmpty(dataInHarmVPOList)) {
|
||||
for (DataHarmDto item : dataInHarmVPOList) {
|
||||
for (int j = 1; j < 17; j++) {
|
||||
try {
|
||||
// 获取 DataHarmDto 类的 getVx 方法
|
||||
Method getVMethod = DataHarmDto.class.getMethod("getV" + j);
|
||||
Double value = (Double) getVMethod.invoke(item);
|
||||
// 获取 Overlimit 类的 getUharmx 方法
|
||||
Method getUharmMethod = Overlimit.class.getMethod("getInuharm" + j);
|
||||
float limit = (float) getUharmMethod.invoke(overlimit);
|
||||
if (ObjectUtil.isNotNull(value)) {
|
||||
if (value > limit) {
|
||||
addAbnormalData(uHarm[j - 1], item.getPhasicType(), item.getValueType(), item.getMinTime(), value, limit);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//电压总谐波畸变率
|
||||
if (!CollectionUtils.isEmpty(dataVPOList)) {
|
||||
for (DataVDto item : dataVPOList) {
|
||||
if (ObjectUtil.isNotNull(item.getVThd())) {
|
||||
if (item.getVThd() > overlimit.getUaberrance()) {
|
||||
addAbnormalData(zxb, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVThd(), overlimit.getUaberrance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//三相电压不平衡度
|
||||
if (!CollectionUtils.isEmpty(dataVPOUnbalanceList)) {
|
||||
for (DataVDto item : dataVPOUnbalanceList) {
|
||||
if (ObjectUtil.isNotNull(item.getVUnbalance())) {
|
||||
if (item.getVUnbalance() > overlimit.getUbalance()) {
|
||||
addAbnormalData(sx, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getVUnbalance(), overlimit.getUbalance());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//负序电流
|
||||
if (!CollectionUtils.isEmpty(dataIPONegList)) {
|
||||
for (DataIDto item : dataIPONegList) {
|
||||
if (ObjectUtil.isNotNull(item.getINeg())) {
|
||||
if (item.getINeg() > overlimit.getINeg()) {
|
||||
addAbnormalData(iNeg, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getINeg(), overlimit.getINeg());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//频率偏差
|
||||
if (!CollectionUtils.isEmpty(dataVPOFreqList)) {
|
||||
for (DataVDto item : dataVPOFreqList) {
|
||||
if (ObjectUtil.isNotNull(item.getFreqDev())) {
|
||||
if (item.getFreqDev() > overlimit.getFreqDev()) {
|
||||
addAbnormalData(freqDev, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getFreqDev(), overlimit.getFreqDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//电压上偏差、电压下偏差(根据vl_dev的正负判断是用哪个值判断越限)
|
||||
if (!CollectionUtils.isEmpty(dataVPODevList)) {
|
||||
for (DataVDto item : dataVPODevList) {
|
||||
if (ObjectUtil.isNotNull(item.getVlDev())) {
|
||||
if (item.getVlDev() >= 0) {
|
||||
if (item.getVlDev() > overlimit.getVoltageDev()) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getMinTime(), item.getValueType(), item.getVlDev(), overlimit.getVoltageDev());
|
||||
}
|
||||
} else {
|
||||
if (Math.abs(item.getVuDev()) > Math.abs(overlimit.getUvoltageDev())) {
|
||||
addAbnormalData(uDev, item.getPhasicType(), item.getMinTime(), item.getValueType(), item.getVuDev(), overlimit.getUvoltageDev());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//长时间闪变
|
||||
if (!CollectionUtils.isEmpty(dataPltPOList)) {
|
||||
for (DataPltDto item : dataPltPOList) {
|
||||
if (ObjectUtil.isNotNull(item.getPlt())) {
|
||||
if (item.getPlt() > overlimit.getFlicker()) {
|
||||
addAbnormalData(flicker, item.getPhasicType(), item.getValueType(), item.getMinTime(), item.getPlt(), overlimit.getFlicker());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
limitRate.setLineId(lineId);
|
||||
limitRate.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
limitRate.setPhasicType(PhaseType.PHASE_T);
|
||||
limitRate.setAllTime(allTime);
|
||||
limitRate.setFlickerAllTime(flickerAllTime);
|
||||
limitRate.setUaberranceOvertime(zxb.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setINegOvertime(iNeg.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setFreqDevOvertime(freqDev.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUbalanceOvertime(sx.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setVoltageDevOvertime(uDev.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setFlickerOvertime(flicker.stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm2Overtime(v[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm3Overtime(v[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm4Overtime(v[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm5Overtime(v[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm6Overtime(v[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm7Overtime(v[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm8Overtime(v[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm9Overtime(v[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm10Overtime(v[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm11Overtime(v[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm12Overtime(v[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm13Overtime(v[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm14Overtime(v[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm15Overtime(v[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm16Overtime(v[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm17Overtime(v[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm18Overtime(v[16].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm19Overtime(v[17].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm20Overtime(v[18].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm21Overtime(v[19].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm22Overtime(v[20].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm23Overtime(v[21].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm24Overtime(v[22].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setUharm25Overtime(v[23].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm2Overtime(i[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm3Overtime(i[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm4Overtime(i[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm5Overtime(i[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm6Overtime(i[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm7Overtime(i[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm8Overtime(i[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm9Overtime(i[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm10Overtime(i[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm11Overtime(i[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm12Overtime(i[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm13Overtime(i[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm14Overtime(i[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm15Overtime(i[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm16Overtime(i[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm17Overtime(i[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm18Overtime(i[16].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm19Overtime(i[17].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm20Overtime(i[18].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm21Overtime(i[19].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm22Overtime(i[20].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm23Overtime(i[21].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm24Overtime(i[22].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setIharm25Overtime(i[23].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm1Overtime(uHarm[0].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm2Overtime(uHarm[1].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm3Overtime(uHarm[2].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm4Overtime(uHarm[3].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm5Overtime(uHarm[4].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm6Overtime(uHarm[5].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm7Overtime(uHarm[6].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm8Overtime(uHarm[7].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm9Overtime(uHarm[8].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm10Overtime(uHarm[9].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm11Overtime(uHarm[10].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm12Overtime(uHarm[11].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm13Overtime(uHarm[12].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm14Overtime(uHarm[13].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm15Overtime(uHarm[14].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
limitRate.setInuharm16Overtime(uHarm[15].stream().map(AbnormalData::getTime).distinct().collect(Collectors.toList()).size());
|
||||
dto.setDataLimitRate(limitRate);
|
||||
|
||||
int detailAllTime = flicker.size() + sx.size() + iNeg.size() + freqDev.size() + zxb.size() + uDev.size() +
|
||||
v[0].size() + v[1].size() + v[2].size() + v[3].size() + v[4].size() + v[5].size() + v[6].size() + v[7].size() + v[8].size() + v[9].size() + v[11].size() + v[12].size() + v[13].size() + v[14].size() + v[15].size() + v[16].size() + v[17].size() + v[18].size() + v[19].size() + v[20].size() + v[21].size() + v[22].size() + v[23].size() +
|
||||
i[0].size() + i[1].size() + i[2].size() + i[3].size() + i[4].size() + i[5].size() + i[6].size() + i[7].size() + i[8].size() + i[9].size() + i[10].size() + i[11].size() + i[12].size() + i[13].size() + i[14].size() + i[15].size() + i[16].size() + i[17].size() + i[18].size() + i[19].size() + i[20].size() + i[21].size() + i[22].size() + i[23].size() +
|
||||
uHarm[0].size() + uHarm[1].size() + uHarm[2].size() + uHarm[3].size() + uHarm[4].size() + uHarm[5].size() + uHarm[6].size() + uHarm[7].size() + uHarm[8].size() + uHarm[9].size() + uHarm[10].size() + uHarm[11].size() + uHarm[12].size() + uHarm[13].size() + uHarm[14].size() + uHarm[15].size();
|
||||
if (detailAllTime > 0) {
|
||||
DataLimitRateDetailDto detail = new DataLimitRateDetailDto();
|
||||
detail.setLineId(lineId);
|
||||
detail.setTime(LocalDateTimeUtil.parseDate(dataDate, DatePattern.NORM_DATE_PATTERN));
|
||||
detail.setFlickerOvertime(toJson(flicker));
|
||||
detail.setUaberranceOvertime(toJson(zxb));
|
||||
detail.setINegOvertime(toJson(iNeg));
|
||||
detail.setFreqDevOvertime(toJson(freqDev));
|
||||
detail.setUbalanceOvertime(toJson(sx));
|
||||
detail.setVoltageDevOvertime(toJson(uDev));
|
||||
detail.setUharm2Overtime(toJson(v[0]));
|
||||
detail.setUharm3Overtime(toJson(v[1]));
|
||||
detail.setUharm4Overtime(toJson(v[2]));
|
||||
detail.setUharm5Overtime(toJson(v[3]));
|
||||
detail.setUharm6Overtime(toJson(v[4]));
|
||||
detail.setUharm7Overtime(toJson(v[5]));
|
||||
detail.setUharm8Overtime(toJson(v[6]));
|
||||
detail.setUharm9Overtime(toJson(v[7]));
|
||||
detail.setUharm10Overtime(toJson(v[8]));
|
||||
detail.setUharm11Overtime(toJson(v[9]));
|
||||
detail.setUharm12Overtime(toJson(v[10]));
|
||||
detail.setUharm13Overtime(toJson(v[11]));
|
||||
detail.setUharm14Overtime(toJson(v[12]));
|
||||
detail.setUharm15Overtime(toJson(v[13]));
|
||||
detail.setUharm16Overtime(toJson(v[14]));
|
||||
detail.setUharm17Overtime(toJson(v[15]));
|
||||
detail.setUharm18Overtime(toJson(v[16]));
|
||||
detail.setUharm19Overtime(toJson(v[17]));
|
||||
detail.setUharm20Overtime(toJson(v[18]));
|
||||
detail.setUharm21Overtime(toJson(v[19]));
|
||||
detail.setUharm22Overtime(toJson(v[20]));
|
||||
detail.setUharm23Overtime(toJson(v[21]));
|
||||
detail.setUharm24Overtime(toJson(v[22]));
|
||||
detail.setUharm25Overtime(toJson(v[23]));
|
||||
detail.setIharm2Overtime(toJson(i[0]));
|
||||
detail.setIharm3Overtime(toJson(i[1]));
|
||||
detail.setIharm4Overtime(toJson(i[2]));
|
||||
detail.setIharm5Overtime(toJson(i[3]));
|
||||
detail.setIharm6Overtime(toJson(i[4]));
|
||||
detail.setIharm7Overtime(toJson(i[5]));
|
||||
detail.setIharm8Overtime(toJson(i[6]));
|
||||
detail.setIharm9Overtime(toJson(i[7]));
|
||||
detail.setIharm10Overtime(toJson(i[8]));
|
||||
detail.setIharm11Overtime(toJson(i[9]));
|
||||
detail.setIharm12Overtime(toJson(i[10]));
|
||||
detail.setIharm13Overtime(toJson(i[11]));
|
||||
detail.setIharm14Overtime(toJson(i[12]));
|
||||
detail.setIharm15Overtime(toJson(i[13]));
|
||||
detail.setIharm16Overtime(toJson(i[14]));
|
||||
detail.setIharm17Overtime(toJson(i[15]));
|
||||
detail.setIharm18Overtime(toJson(i[16]));
|
||||
detail.setIharm19Overtime(toJson(i[17]));
|
||||
detail.setIharm20Overtime(toJson(i[18]));
|
||||
detail.setIharm21Overtime(toJson(i[19]));
|
||||
detail.setIharm22Overtime(toJson(i[20]));
|
||||
detail.setIharm23Overtime(toJson(i[21]));
|
||||
detail.setIharm24Overtime(toJson(i[22]));
|
||||
detail.setIharm25Overtime(toJson(i[23]));
|
||||
detail.setInuharm1Overtime(toJson(uHarm[0]));
|
||||
detail.setInuharm2Overtime(toJson(uHarm[1]));
|
||||
detail.setInuharm3Overtime(toJson(uHarm[2]));
|
||||
detail.setInuharm4Overtime(toJson(uHarm[3]));
|
||||
detail.setInuharm5Overtime(toJson(uHarm[4]));
|
||||
detail.setInuharm6Overtime(toJson(uHarm[5]));
|
||||
detail.setInuharm7Overtime(toJson(uHarm[6]));
|
||||
detail.setInuharm8Overtime(toJson(uHarm[7]));
|
||||
detail.setInuharm9Overtime(toJson(uHarm[8]));
|
||||
detail.setInuharm10Overtime(toJson(uHarm[9]));
|
||||
detail.setInuharm11Overtime(toJson(uHarm[10]));
|
||||
detail.setInuharm12Overtime(toJson(uHarm[11]));
|
||||
detail.setInuharm13Overtime(toJson(uHarm[12]));
|
||||
detail.setInuharm14Overtime(toJson(uHarm[13]));
|
||||
detail.setInuharm15Overtime(toJson(uHarm[14]));
|
||||
detail.setInuharm16Overtime(toJson(uHarm[15]));
|
||||
dto.setDataLimitRateDetail(detail);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
private DataLimitRateDto getDataLimitRateDto(DataLimitRateDto limitRate, List<AbnormalData>[] v, List<AbnormalData>[] i, List<AbnormalData>[] uHarm) {
|
||||
limitRate.setUharm2Overtime(v[0].size());
|
||||
limitRate.setUharm3Overtime(v[1].size());
|
||||
limitRate.setUharm4Overtime(v[2].size());
|
||||
limitRate.setUharm5Overtime(v[3].size());
|
||||
limitRate.setUharm6Overtime(v[4].size());
|
||||
limitRate.setUharm7Overtime(v[5].size());
|
||||
limitRate.setUharm8Overtime(v[6].size());
|
||||
limitRate.setUharm9Overtime(v[7].size());
|
||||
limitRate.setUharm10Overtime(v[8].size());
|
||||
limitRate.setUharm11Overtime(v[9].size());
|
||||
limitRate.setUharm12Overtime(v[10].size());
|
||||
limitRate.setUharm13Overtime(v[11].size());
|
||||
limitRate.setUharm14Overtime(v[12].size());
|
||||
limitRate.setUharm15Overtime(v[13].size());
|
||||
limitRate.setUharm16Overtime(v[14].size());
|
||||
limitRate.setUharm17Overtime(v[15].size());
|
||||
limitRate.setUharm18Overtime(v[16].size());
|
||||
limitRate.setUharm19Overtime(v[17].size());
|
||||
limitRate.setUharm20Overtime(v[18].size());
|
||||
limitRate.setUharm21Overtime(v[19].size());
|
||||
limitRate.setUharm22Overtime(v[20].size());
|
||||
limitRate.setUharm23Overtime(v[21].size());
|
||||
limitRate.setUharm24Overtime(v[22].size());
|
||||
limitRate.setUharm25Overtime(v[23].size());
|
||||
limitRate.setIharm2Overtime(i[0].size());
|
||||
limitRate.setIharm3Overtime(i[1].size());
|
||||
limitRate.setIharm4Overtime(i[2].size());
|
||||
limitRate.setIharm5Overtime(i[3].size());
|
||||
limitRate.setIharm6Overtime(i[4].size());
|
||||
limitRate.setIharm7Overtime(i[5].size());
|
||||
limitRate.setIharm8Overtime(i[6].size());
|
||||
limitRate.setIharm9Overtime(i[7].size());
|
||||
limitRate.setIharm10Overtime(i[8].size());
|
||||
limitRate.setIharm11Overtime(i[9].size());
|
||||
limitRate.setIharm12Overtime(i[10].size());
|
||||
limitRate.setIharm13Overtime(i[11].size());
|
||||
limitRate.setIharm14Overtime(i[12].size());
|
||||
limitRate.setIharm15Overtime(i[13].size());
|
||||
limitRate.setIharm16Overtime(i[14].size());
|
||||
limitRate.setIharm17Overtime(i[15].size());
|
||||
limitRate.setIharm18Overtime(i[16].size());
|
||||
limitRate.setIharm19Overtime(i[17].size());
|
||||
limitRate.setIharm20Overtime(i[18].size());
|
||||
limitRate.setIharm21Overtime(i[19].size());
|
||||
limitRate.setIharm22Overtime(i[20].size());
|
||||
limitRate.setIharm23Overtime(i[21].size());
|
||||
limitRate.setIharm24Overtime(i[22].size());
|
||||
limitRate.setIharm25Overtime(i[23].size());
|
||||
limitRate.setInuharm1Overtime(uHarm[0].size());
|
||||
limitRate.setInuharm2Overtime(uHarm[1].size());
|
||||
limitRate.setInuharm3Overtime(uHarm[2].size());
|
||||
limitRate.setInuharm4Overtime(uHarm[3].size());
|
||||
limitRate.setInuharm5Overtime(uHarm[4].size());
|
||||
limitRate.setInuharm6Overtime(uHarm[5].size());
|
||||
limitRate.setInuharm7Overtime(uHarm[6].size());
|
||||
limitRate.setInuharm8Overtime(uHarm[7].size());
|
||||
limitRate.setInuharm9Overtime(uHarm[8].size());
|
||||
limitRate.setInuharm10Overtime(uHarm[9].size());
|
||||
limitRate.setInuharm11Overtime(uHarm[10].size());
|
||||
limitRate.setInuharm12Overtime(uHarm[11].size());
|
||||
limitRate.setInuharm13Overtime(uHarm[12].size());
|
||||
limitRate.setInuharm14Overtime(uHarm[13].size());
|
||||
limitRate.setInuharm15Overtime(uHarm[14].size());
|
||||
limitRate.setInuharm16Overtime(uHarm[15].size());
|
||||
return limitRate;
|
||||
}
|
||||
|
||||
private String toJson(List<AbnormalData> list) {
|
||||
Map<String, List<AbnormalData>> abnormalMap = list.stream().collect(Collectors.groupingBy(x -> x.getPhasic() + "_" + x.getValueType()));
|
||||
List<AbnormalData.Json> info = new ArrayList<>();
|
||||
abnormalMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
AbnormalData.Json json = new AbnormalData.Json();
|
||||
json.setPhasic(split[0]);
|
||||
json.setValueType(split[1]);
|
||||
json.setTime(String.join(",", value.stream()
|
||||
.map(abnormal -> abnormal.getTime())
|
||||
.collect(Collectors.toList())));
|
||||
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)) {
|
||||
return JSON.toJSONString(info);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addAbnormalData(List<AbnormalData> list, String phasicType, String valueType, String time, Double value, float overLimitValue) {
|
||||
AbnormalData data = new AbnormalData();
|
||||
data.setTime(time.substring(11, time.length()));
|
||||
data.setPhasic(phasicType);
|
||||
data.setValueType(valueType);
|
||||
data.setValue(value);
|
||||
data.setOverLimitValue(overLimitValue);
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package com.njcn.algorithm.utils;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.yomahub.liteflow.flow.LiteflowResponse;
|
||||
import com.yomahub.liteflow.flow.entity.CmpStep;
|
||||
import org.apache.commons.lang.SerializationUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @Author: cdf
|
||||
@@ -13,6 +24,8 @@ import java.util.List;
|
||||
|
||||
public class MemorySizeUtil {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MemorySizeUtil.class);
|
||||
|
||||
public static double getObjectSize(List<?> list) {
|
||||
byte[] serialized = SerializationUtils.serialize((java.io.Serializable) list);
|
||||
return (double)serialized.length/1024/1024;
|
||||
@@ -36,5 +49,41 @@ public class MemorySizeUtil {
|
||||
System.out.println("已使用的内存: " + usedMemory / (1024 * 1024) + " MB");
|
||||
}
|
||||
|
||||
/***
|
||||
*
|
||||
* @author hongawen
|
||||
* @date 2023/11/7 14:44
|
||||
*/
|
||||
public static void dealResponse(CalculatedParam calculatedParam, LiteflowResponse liteflowResponse, String methodDescribe) {
|
||||
MemorySizeUtil.getNowMemory();
|
||||
if (liteflowResponse.isSuccess()) {
|
||||
// 获取执行步骤列表
|
||||
long allTime = 0;
|
||||
Map<String, List<CmpStep>> executeSteps = liteflowResponse.getExecuteSteps();
|
||||
for (String key : executeSteps.keySet()) {
|
||||
List<CmpStep> cmpSteps = executeSteps.get(key);
|
||||
long timeSum = cmpSteps.stream().mapToLong(CmpStep::getTimeSpent).sum();
|
||||
allTime+=timeSum;
|
||||
}
|
||||
logger.info("日期{},{}执行{}成功,执行总时长{}分钟", calculatedParam.getDataDate(), methodDescribe, calculatedParam.isFullChain() ? "全链" : "指定节点:".concat(String.join(StrPool.COMMA, calculatedParam.getTagNames())),allTime/1000/60);
|
||||
} else {
|
||||
Map<String, List<CmpStep>> executeSteps = liteflowResponse.getExecuteSteps();
|
||||
CmpStep failStep = null;
|
||||
for (String key : executeSteps.keySet()) {
|
||||
List<CmpStep> cmpSteps = executeSteps.get(key);
|
||||
cmpSteps = cmpSteps.stream().filter(cmpStep -> !cmpStep.isSuccess()).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(cmpSteps)) {
|
||||
failStep = cmpSteps.get(0);
|
||||
}
|
||||
}
|
||||
logger.error("日期{},{}执行{}失败,在执行{}失败,失败原因:{}"
|
||||
, calculatedParam.getDataDate()
|
||||
, methodDescribe
|
||||
, calculatedParam.isFullChain() ? "全链" : "指定节点:".concat(String.join(StrPool.COMMA, calculatedParam.getTagNames()))
|
||||
, failStep.getNodeId().concat(Objects.isNull(failStep.getTag()) ? "" : StrPool.DASHED.concat(failStep.getTag()))
|
||||
, Objects.isNull(failStep.getException()) ? null : failStep.getException().getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ liteflow:
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root:
|
||||
root: error
|
||||
|
||||
|
||||
#mybatis配置信息
|
||||
@@ -66,7 +66,7 @@ mybatis-plus:
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.harmonic.pojo
|
||||
line:
|
||||
num: 20
|
||||
num: 10
|
||||
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.dataProcess.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.dataProcess.api.fallback.PqDataVerifyNewFeignClientFallbackFactory;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
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 xy
|
||||
* @version 1.0.0
|
||||
* @date 2025年02月13日 20:11
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.PLATFORM_DATA_PROCESSING_BOOT, path = "/pqDataVerifyCount", fallbackFactory = PqDataVerifyNewFeignClientFallbackFactory.class, contextId = "pqDataVerifyNew")
|
||||
public interface PqDataVerifyCountFeignClient {
|
||||
|
||||
@PostMapping("/insertDataBatch")
|
||||
HttpResult<List<String>> insertDataBatch(@RequestBody List<PqDataVerifyCount> list);
|
||||
|
||||
@PostMapping("/insertData")
|
||||
HttpResult<List<String>> insertData(@RequestBody PqDataVerifyCount pqDataVerifyCount);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.dataProcess.api.fallback;
|
||||
|
||||
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.PqDataVerifyCountFeignClient;
|
||||
import com.njcn.dataProcess.api.PqDataVerifyNewFeignClient;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
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 xy
|
||||
* @version 1.0.0
|
||||
* @date 2025年02月13日 20:13
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PqDataVerifyCountFeignClientFallbackFactory implements FallbackFactory<PqDataVerifyCountFeignClient> {
|
||||
|
||||
/**
|
||||
* 输出远程请求接口异常日志
|
||||
* @param cause RPC请求异常
|
||||
*/
|
||||
@Override
|
||||
public PqDataVerifyCountFeignClient 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 PqDataVerifyCountFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> insertDataBatch(List<PqDataVerifyCount> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量存储清洗的异常数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<String>> insertData(PqDataVerifyCount pqDataVerifyCount) {
|
||||
log.error("{}异常,降级处理,异常为:{}","单监测点存储清洗的异常数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,11 @@ public class DataCleanJsonDTO {
|
||||
@ApiModelProperty("异常数据量")
|
||||
private Integer errorCounts;
|
||||
|
||||
@ApiModelProperty("指标上限")
|
||||
private Double minValue;
|
||||
|
||||
@ApiModelProperty("指标下限")
|
||||
private Double maxValue;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -62,5 +62,7 @@ public class LineCountEvaluateParam extends BaseParam implements Serializable {
|
||||
*/
|
||||
private Boolean dataType = true;
|
||||
|
||||
//0:通用 1:省级平台 2:物联
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -65,6 +65,8 @@ public class AbnormalData {
|
||||
@JSONField(ordinal = 4)
|
||||
private String value;
|
||||
|
||||
@JSONField(ordinal = 5)
|
||||
private float overLimitValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.njcn.dataProcess.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("pq_data_verify_count")
|
||||
public class PqDataVerifyCount implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
@MppMultiId
|
||||
@TableField(value = "line_id")
|
||||
private String lineId;
|
||||
|
||||
/**
|
||||
* 数据时间
|
||||
*/
|
||||
@MppMultiId
|
||||
@TableField(value = "time_id")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
private LocalDate time;
|
||||
|
||||
/**
|
||||
* 异常指标数量
|
||||
*/
|
||||
@TableField(value = "total")
|
||||
private Integer total = 0;
|
||||
|
||||
/**
|
||||
* 总指标数量
|
||||
*/
|
||||
@TableField(value = "total_all")
|
||||
private Integer totalAll = 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.dataProcess.controller;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
import com.njcn.dataProcess.service.IPqDataVerifyCountService;
|
||||
import com.njcn.dataProcess.service.IPqDataVerifyNewService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pqDataVerifyCount")
|
||||
public class PqDataVerifyCountController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IPqDataVerifyCountService pqDataVerifyNewService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/insertDataBatch")
|
||||
@ApiOperation("存储清洗的异常数据数量")
|
||||
public HttpResult<List<String>> insertDataBatch(@RequestBody List<PqDataVerifyCount> list) {
|
||||
String methodDescribe = getMethodDescribe("insertDataBatch");
|
||||
pqDataVerifyNewService.insertDataBatch(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/insertData")
|
||||
@ApiOperation("存储清洗的异常数据数量")
|
||||
public HttpResult<List<String>> insertData(@RequestBody PqDataVerifyCount pqDataVerifyCount) {
|
||||
String methodDescribe = getMethodDescribe("insertData");
|
||||
pqDataVerifyNewService.insertData(pqDataVerifyCount);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.dataProcess.controller;
|
||||
|
||||
import com.njcn.algorithm.pojo.bo.CalculatedParam;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.dataProcess.annotation.InsertBean;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import com.njcn.dataProcess.service.IRMpVThdService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0
|
||||
* @data 2024/11/6 19:48
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RestController
|
||||
@RequestMapping("/rmpvthd")
|
||||
@Api(tags = "畸变率")
|
||||
public class RMpVThdController extends BaseController {
|
||||
|
||||
@InsertBean
|
||||
private IRMpVThdService irMpVThdService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/batchInsertionThd")
|
||||
@ApiOperation("畸变率批量插入")
|
||||
public HttpResult<String> batchInsertionThd(@RequestBody List<RMpVThd> result) {
|
||||
String methodDescribe = getMethodDescribe("batchInsertionPower");
|
||||
irMpVThdService.batchInsertionThd(result);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/batchInsertionPower")
|
||||
@ApiOperation("畸变率查询")
|
||||
public HttpResult<List<RMpVThd>> queryThd(@RequestBody CalculatedParam calculatedParam) {
|
||||
String methodDescribe = getMethodDescribe("batchInsertionPower");
|
||||
List<RMpVThd> rMpVThdList = irMpVThdService.queryHarmonicVThd(calculatedParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, rMpVThdList, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.dataProcess.dao.relation.mapper;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface PqDataVerifyCountMapper extends MppBaseMapper<PqDataVerifyCount> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.dataProcess.dao.relation.mapper;
|
||||
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||
import com.njcn.dataProcess.pojo.dto.RMpVThd;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 谐波畸变率排名 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @since 2022-11-07
|
||||
*/
|
||||
public interface RMpVThdMapper extends MppBaseMapper<RMpVThd> {
|
||||
|
||||
int insertRate(@Param("item") Map<String, Object> item);
|
||||
|
||||
/**
|
||||
* 从r_stat_data_v_d中获取畸变率的最大值
|
||||
* phasic_type = A、B、C && value_type = CP95
|
||||
*/
|
||||
List<RMpVThd> getVThdData(@Param("time") String time, @Param("lineList")List<String> lineList);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.dataProcess.dao.relation.mapper.RMpVThdMapper">
|
||||
|
||||
<insert id="insertRate">
|
||||
INSERT INTO r_mp_v_thd ( measurement_point_id, data_type, data_date, v_thd) VALUES
|
||||
( #{item.lineId}, #{item.dataType}, #{item.dataDate}, #{item.vThd} )
|
||||
ON DUPLICATE KEY UPDATE v_thd = #{item.vThd}
|
||||
</insert>
|
||||
|
||||
<select id="getVThdData" resultType="com.njcn.dataProcess.pojo.dto.RMpVThd">
|
||||
select
|
||||
line_id measurementPointId,
|
||||
max(v_thd) vThd,
|
||||
time dataDate,
|
||||
'0' dataType
|
||||
from
|
||||
r_stat_data_v_d
|
||||
where
|
||||
time = #{time}
|
||||
and phasic_type in ('A', 'B', 'C')
|
||||
and value_type = 'CP95'
|
||||
<if test="lineList != null and lineList.size() > 0">
|
||||
and line_id in
|
||||
<foreach collection="lineList" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
</if>
|
||||
group by line_id, time
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.dataProcess.service;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
public interface IPqDataVerifyCountService extends IMppService<PqDataVerifyCount> {
|
||||
|
||||
/**
|
||||
* 异常数据插入
|
||||
* @param list
|
||||
*/
|
||||
void insertDataBatch(List<PqDataVerifyCount> list);
|
||||
|
||||
/**
|
||||
* 异常数据插入
|
||||
*/
|
||||
void insertData(PqDataVerifyCount pqDataVerifyCount);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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) {
|
||||
@@ -50,9 +67,8 @@ public class InfluxdbDataFlickerImpl extends MppServiceImpl<RStatDataFlickerRela
|
||||
}
|
||||
|
||||
List<DataFlicker> collect = dataFlickerDTOList.stream().map(temp -> DataFlicker.relationToInfluxDB(temp)).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataFlicker>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataFlicker>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataFlicker> dataFlickerList : partition) {
|
||||
List<DataFlicker> sublistAsOriginalListType = new ArrayList<>(dataFlickerList);
|
||||
|
||||
@@ -64,7 +80,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 +98,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 +263,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -48,9 +65,8 @@ public class InfluxdbDataFlucImpl extends MppServiceImpl<RStatDataFlucRelationMa
|
||||
}
|
||||
|
||||
List<DataFluc> collect = dataFlucDTOList.stream().map(temp -> DataFluc.relationToInfluxDB(temp)).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataFluc>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataFluc>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataFluc> dataFlucList : partition) {
|
||||
List<DataFluc> sublistAsOriginalListType = new ArrayList<>(dataFlucList);
|
||||
|
||||
@@ -62,7 +78,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 +96,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 +217,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
//以监测点分组
|
||||
@@ -176,7 +200,7 @@ public class InfluxdbDataHarmRateIImpl extends MppServiceImpl<RStatDataHarmRateI
|
||||
List<DataHarmrateI> dataList;
|
||||
List<DataHarmrateI> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmrateI::getLineId, lineList)
|
||||
.select(DataHarmrateI::getLineId)
|
||||
.select(DataHarmrateI::getPhasicType)
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -63,9 +84,8 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
}
|
||||
|
||||
List<DataHarmrateV> collect = dataHarmrateVDTOList.stream().flatMap(temp -> DataHarmrateV.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmrateV>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmrateV>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmrateV> dataHarmrateVList : partition) {
|
||||
List<DataHarmrateV> sublistAsOriginalListType = new ArrayList<>(dataHarmrateVList);
|
||||
|
||||
@@ -77,7 +97,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());
|
||||
//以监测点分组
|
||||
@@ -212,7 +237,7 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
@Override
|
||||
public List<DataHarmDto> getGroupByTimeHarmRateV(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper harmRateVQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
harmRateVQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
harmRateVQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
harmRateVQueryWrapper.regular(DataV::getLineId, lineParam.getLineId())
|
||||
.eq(DataHarmrateV::getValueType, InfluxDbSqlConstant.CP95)
|
||||
.ne(DataHarmrateV::getPhasicType, InfluxDBTableConstant.PHASE_TYPE_T)
|
||||
@@ -240,7 +265,7 @@ public class InfluxdbDataHarmRateVImpl extends MppServiceImpl<RStatDataHarmRateV
|
||||
List<DataHarmrateV> dataList;
|
||||
List<DataHarmrateV> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmrateV::getLineId, lineParam.getLineId())
|
||||
.select(DataHarmrateV::getLineId)
|
||||
.select(DataHarmrateV::getPhasicType)
|
||||
@@ -292,4 +317,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -49,9 +66,8 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
}
|
||||
|
||||
List<DataHarmphasicI> collect = dataHarmphasicIDTOList.stream().flatMap(temp -> DataHarmphasicI.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmphasicI>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmphasicI>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmphasicI> dataHarmphasicIList : partition) {
|
||||
List<DataHarmphasicI> sublistAsOriginalListType = new ArrayList<>(dataHarmphasicIList);
|
||||
dataHarmphasicIMapper.insertBatch(sublistAsOriginalListType);
|
||||
@@ -62,7 +78,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 +96,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());
|
||||
//以监测点分组
|
||||
@@ -197,7 +223,7 @@ public class InfluxdbDataHarmphasicIImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
List<DataHarmphasicI> dataList;
|
||||
List<DataHarmphasicI> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmphasicI::getLineId, lineList)
|
||||
.select(DataHarmphasicI::getLineId)
|
||||
.select(DataHarmphasicI::getPhasicType)
|
||||
@@ -245,4 +271,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -52,9 +70,8 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
}
|
||||
|
||||
List<DataHarmphasicV> collect = dataHarmphasicVDTOList.stream().flatMap(temp -> DataHarmphasicV.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmphasicV>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmphasicV>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmphasicV> dataHarmphasicVList : partition) {
|
||||
List<DataHarmphasicV> sublistAsOriginalListType = new ArrayList<>(dataHarmphasicVList);
|
||||
|
||||
@@ -66,7 +83,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 +101,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());
|
||||
//以监测点分组
|
||||
@@ -201,7 +228,7 @@ public class InfluxdbDataHarmphasicVImpl extends MppServiceImpl<RStatDataHarmPha
|
||||
List<DataHarmphasicV> dataList;
|
||||
List<DataHarmphasicV> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmphasicV::getLineId, lineList)
|
||||
.select(DataHarmphasicV::getLineId)
|
||||
.select(DataHarmphasicV::getPhasicType)
|
||||
@@ -249,4 +276,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -51,9 +70,8 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
return;
|
||||
}
|
||||
List<DataHarmpowerP> collect = dataHarmpowerPDTOList.stream().flatMap(temp -> DataHarmpowerP.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmpowerP>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmpowerP>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmpowerP> dataHarmpowerPList : partition) {
|
||||
List<DataHarmpowerP> sublistAsOriginalListType = new ArrayList<>(dataHarmpowerPList);
|
||||
|
||||
@@ -65,7 +83,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 +101,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());
|
||||
//以监测点分组
|
||||
@@ -204,7 +232,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
List<DataHarmpowerP> dataList;
|
||||
List<DataHarmpowerP> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, InfluxDbSqlConstant.P, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmpowerP::getLineId, lineList)
|
||||
.select(DataHarmpowerP::getLineId)
|
||||
.select(DataHarmpowerP::getPhasicType)
|
||||
@@ -255,4 +283,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -49,9 +66,8 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
return;
|
||||
}
|
||||
List<DataHarmpowerQ> collect = dataHarmpowerQDTOList.stream().flatMap(temp -> DataHarmpowerQ.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmpowerQ>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmpowerQ>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmpowerQ> dataHarmpowerQList : partition) {
|
||||
List<DataHarmpowerQ> sublistAsOriginalListType = new ArrayList<>(dataHarmpowerQList);
|
||||
|
||||
@@ -63,7 +79,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 +97,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());
|
||||
//以监测点分组
|
||||
@@ -200,7 +226,7 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
List<DataHarmpowerQ> dataList;
|
||||
List<DataHarmpowerQ> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, InfluxDbSqlConstant.Q, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmpowerQ::getLineId, lineList)
|
||||
.select(DataHarmpowerQ::getLineId)
|
||||
.select(DataHarmpowerQ::getPhasicType)
|
||||
@@ -250,4 +276,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -49,9 +66,8 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
return;
|
||||
}
|
||||
List<DataHarmpowerS> collect = dataHarmpowerSDTOList.stream().flatMap(temp -> DataHarmpowerS.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataHarmpowerS>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataHarmpowerS>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataHarmpowerS> dataHarmpowerSList : partition) {
|
||||
List<DataHarmpowerS> sublistAsOriginalListType = new ArrayList<>(dataHarmpowerSList);
|
||||
|
||||
@@ -63,7 +79,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 +97,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());
|
||||
//以监测点分组
|
||||
@@ -200,7 +226,7 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
|
||||
List<DataHarmpowerS> dataList;
|
||||
List<DataHarmpowerS> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, InfluxDbSqlConstant.S, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataHarmpowerS::getLineId, lineList)
|
||||
.select(DataHarmpowerS::getLineId)
|
||||
.select(DataHarmpowerS::getPhasicType)
|
||||
@@ -250,4 +276,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -54,9 +69,8 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
return;
|
||||
}
|
||||
List<DataI> collect = dataIDTOList.stream().flatMap(temp -> DataI.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataI>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataI>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataI> dataIList : partition) {
|
||||
List<DataI> sublistAsOriginalListType = new ArrayList<>(dataIList);
|
||||
|
||||
@@ -68,7 +82,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 +100,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());
|
||||
//以监测点分组
|
||||
@@ -207,7 +231,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
@Override
|
||||
public List<DataIDto> getGroupByTimeDataI(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
influxQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.maxSamePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(2, 50, 1));
|
||||
influxQueryWrapper.regular(DataI::getLineId, lineParam.getLineId())
|
||||
.eq(DataI::getValueType, InfluxDbSqlConstant.CP95)
|
||||
.ne(DataI::getPhasicType, InfluxDBTableConstant.PHASE_TYPE_T)
|
||||
@@ -235,7 +259,7 @@ public class InfluxdbDataIImpl extends MppServiceImpl<RStatDataIRelationMapper,
|
||||
List<DataI> dataList;
|
||||
List<DataI> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataI::getLineId, lineParam.getLineId())
|
||||
.select(DataI::getLineId)
|
||||
.select(DataI::getPhasicType)
|
||||
@@ -293,4 +317,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -51,7 +67,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
List<DataInharmI> collect = dataInharmIDTOList.stream().flatMap(temp -> DataInharmI.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataInharmI>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataInharmI>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataInharmI> dataInharmIList : partition) {
|
||||
List<DataInharmI> sublistAsOriginalListType = new ArrayList<>(dataInharmIList);
|
||||
|
||||
@@ -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());
|
||||
//以监测点分组
|
||||
@@ -198,7 +224,7 @@ public class InfluxdbDataInharmIImpl extends MppServiceImpl<RStatDataInHarmIRela
|
||||
List<DataInharmI> dataList;
|
||||
List<DataInharmI> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataInharmI::getLineId, lineList)
|
||||
.select(DataInharmI::getLineId)
|
||||
.select(DataInharmI::getPhasicType)
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -52,9 +68,8 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
|
||||
return;
|
||||
}
|
||||
List<DataInharmV> collect = dataInharmVDTOList.stream().flatMap(temp -> DataInharmV.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataInharmV>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataInharmV>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataInharmV> dataInharmVList : partition) {
|
||||
List<DataInharmV> sublistAsOriginalListType = new ArrayList<>(dataInharmVList);
|
||||
|
||||
@@ -66,7 +81,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 +99,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());
|
||||
//以监测点分组
|
||||
@@ -201,7 +226,7 @@ public class InfluxdbDataInharmVImpl extends MppServiceImpl<RStatDataInHarmVRela
|
||||
List<DataInharmV> dataList;
|
||||
List<DataInharmV> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.regular(DataInharmV::getLineId, lineParam.getLineId())
|
||||
.select(DataInharmV::getLineId)
|
||||
.select(DataInharmV::getPhasicType)
|
||||
@@ -252,4 +277,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
@@ -49,9 +66,8 @@ public class InfluxdbDataPltImpl extends MppServiceImpl<RStatDataPltRelationMapp
|
||||
}
|
||||
|
||||
List<DataPlt> collect = dataPltDTOList.stream().map(temp -> DataPlt.relationToInfluxDB(temp)).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataPlt>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataPlt>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataPlt> dataPltList : partition) {
|
||||
List<DataPlt> sublistAsOriginalListType = new ArrayList<>(dataPltList);
|
||||
|
||||
@@ -63,7 +79,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 +97,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 +225,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -95,9 +111,8 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
return;
|
||||
}
|
||||
List<DataV> collect = dataVDTOList.stream().flatMap(temp -> DataV.relationToInfluxDB(temp).stream()).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataV>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataV>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataV> dataVList : partition) {
|
||||
List<DataV> sublistAsOriginalListType = new ArrayList<>(dataVList);
|
||||
|
||||
@@ -122,21 +137,27 @@ 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCountRawData(LineCountEvaluateParam lineParam) {
|
||||
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)
|
||||
@@ -205,7 +226,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());
|
||||
//以监测点分组
|
||||
@@ -343,12 +369,10 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
return dataV;
|
||||
|
||||
}).collect(Collectors.toList());
|
||||
int minSize = Math.min(1200000, collect.size());
|
||||
|
||||
List<List<DataV>> partition = ListUtils.partition(collect, minSize);
|
||||
List<List<DataV>> partition = ListUtils.partition(collect, 20000);
|
||||
for (List<DataV> dataVList : partition) {
|
||||
List<DataV> sublistAsOriginalListType = new ArrayList<>(dataVList);
|
||||
|
||||
dataVMapper.insertBatch(sublistAsOriginalListType);
|
||||
|
||||
}
|
||||
@@ -403,7 +427,7 @@ public class InfluxdbDataVImpl extends MppServiceImpl<RStatDataVRelationMapper,
|
||||
|
||||
/**
|
||||
* 按监测点集合、时间条件获取dataV分钟数据
|
||||
* timeMap参数来判断是否进行数据出来 timeMap为空则不进行数据处理
|
||||
* timeMap参数来判断是否进行数据处理 timeMap为空则不进行数据处理
|
||||
* 剔除异常数据,这里会有三种情况判断
|
||||
* 1.无异常数据,则直接返回集合;
|
||||
* 2.异常数据和无异常数据参杂,剔除异常数据,只计算正常数据;
|
||||
@@ -412,7 +436,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 +463,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);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.dataProcess.service.impl.relation;
|
||||
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.PqDataVerifyCountMapper;
|
||||
import com.njcn.dataProcess.dao.relation.mapper.PqDataVerifyNewMapper;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyBak;
|
||||
import com.njcn.dataProcess.pojo.po.PqDataVerifyCount;
|
||||
import com.njcn.dataProcess.service.IPqDataVerifyCountService;
|
||||
import com.njcn.dataProcess.service.IPqDataVerifyNewService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-02-17
|
||||
*/
|
||||
@Service
|
||||
public class PqDataVerifyCountServiceImpl extends MppServiceImpl<PqDataVerifyCountMapper, PqDataVerifyCount> implements IPqDataVerifyCountService {
|
||||
|
||||
@Override
|
||||
public void insertDataBatch(List<PqDataVerifyCount> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertData(PqDataVerifyCount pqDataVerifyCount) {
|
||||
this.saveOrUpdateByMultiId(pqDataVerifyCount);
|
||||
}
|
||||
}
|
||||
@@ -111,7 +111,15 @@ public class RelationDataLimitRateDetailImpl extends MppServiceImpl<RStatLimitRa
|
||||
BeanUtils.copyProperties(item, limitRate);
|
||||
result.add(limitRate);
|
||||
});
|
||||
this.saveOrUpdateBatchByMultiId(result,1000);
|
||||
if(CollUtil.isNotEmpty(result)){
|
||||
List<String> ids = result.stream().map(RStatLimitRateDetailD::getLineId).collect(Collectors.toList());
|
||||
this.remove(new LambdaQueryWrapper<RStatLimitRateDetailD>()
|
||||
.eq(RStatLimitRateDetailD::getTime,result.get(0).getTime())
|
||||
.in(RStatLimitRateDetailD::getLineId,ids)
|
||||
);
|
||||
this.saveBatch(result,500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public class DeviceRebootMessage {
|
||||
private String series;
|
||||
//终端识别码
|
||||
private String devKey;
|
||||
private Integer processNo;
|
||||
//
|
||||
private List<MonitorInfo> monitorData;
|
||||
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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小时,避免重复消费
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ public class TopicLogsConsumer extends EnhanceConsumerMessageHandler<FrontLogslM
|
||||
*/
|
||||
@Override
|
||||
protected boolean isRetry() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class InsertDataHarmRateIImpl implements InsertIDataHarmRateI {
|
||||
@Override
|
||||
public List<DataHarmrateI> listDataHarmrateI(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmrateI::getLineId)
|
||||
.select(DataHarmrateI::getPhasicType)
|
||||
|
||||
@@ -31,7 +31,7 @@ public class InsertDataHarmRateVImpl implements InsertIDataHarmRateV {
|
||||
@Override
|
||||
public List<DataHarmrateV> listDataHarmrateV(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmrateV::getLineId)
|
||||
.select(DataHarmrateV::getPhasicType)
|
||||
|
||||
@@ -37,7 +37,7 @@ public class InsertDataHarmphasicIImpl implements InsertIDataHarmphasicI {
|
||||
public List<DataHarmphasicI> listDataHarmphasicI(LineCountEvaluateParam lineParam) {
|
||||
List<DataHarmphasicI> result = new ArrayList<>();
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmphasicI::getLineId)
|
||||
.select(DataHarmphasicI::getPhasicType)
|
||||
|
||||
@@ -36,7 +36,7 @@ public class InsertDataHarmphasicVImpl implements InsertIDataHarmphasicV {
|
||||
@Override
|
||||
public List<DataHarmphasicV> listDataHarmphasicV(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmphasicV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmphasicV::getLineId)
|
||||
.select(DataHarmphasicV::getPhasicType)
|
||||
|
||||
@@ -36,7 +36,7 @@ public class InsertDataHarmpowerPImpl implements InsertIDataHarmpowerP {
|
||||
@Override
|
||||
public List<DataHarmpowerP> listDataHarmpowerP(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, InfluxDbSqlConstant.P, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmpowerP::getLineId)
|
||||
.select(DataHarmpowerP::getPhasicType)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class InsertDataHarmpowerQImpl implements InsertIDataHarmpowerQ {
|
||||
@Override
|
||||
public List<DataHarmpowerQ> listDataHarmpowerQ(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, InfluxDbSqlConstant.Q, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmpowerQ::getLineId)
|
||||
.select(DataHarmpowerQ::getPhasicType)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class InsertDataHarmpowerSImpl implements InsertIDataHarmpowerS {
|
||||
@Override
|
||||
public List<DataHarmpowerS> listDataHarmpowerS(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, InfluxDbSqlConstant.S, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmpowerS::getLineId)
|
||||
.select(DataHarmpowerS::getPhasicType)
|
||||
|
||||
@@ -36,7 +36,7 @@ public class InsertDataIImpl implements InsertIDataI {
|
||||
@Override
|
||||
public List<DataI> listDataI(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataI::getLineId)
|
||||
.select(DataI::getPhasicType)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class InsertDataInharmIImpl implements InsertIDataInharmI {
|
||||
@Override
|
||||
public List<DataInharmI> listDataInharmI(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataInharmI::getLineId)
|
||||
.select(DataInharmI::getPhasicType)
|
||||
|
||||
@@ -35,7 +35,7 @@ public class InsertDataInharmVImpl implements InsertIDataInharmV {
|
||||
@Override
|
||||
public List<DataInharmV> listDataInharmV(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataInharmV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataInharmV::getLineId)
|
||||
.select(DataInharmV::getPhasicType)
|
||||
|
||||
@@ -34,7 +34,7 @@ public class InsertDataVImpl implements InsertIDataV {
|
||||
@Override
|
||||
public List<DataV> listDataV(LineCountEvaluateParam lineParam) {
|
||||
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
|
||||
.select(DataV::getLineId)
|
||||
.select(DataV::getPhasicType)
|
||||
@@ -66,7 +66,7 @@ public class InsertDataVImpl implements InsertIDataV {
|
||||
@Override
|
||||
public List<DataV> listDataVDesc(LineCountEvaluateParam lineParam) {
|
||||
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
|
||||
.select(DataV::getLineId)
|
||||
.select(DataV::getPhasicType)
|
||||
|
||||
@@ -82,14 +82,14 @@ public class MigrationInfluxDBController {
|
||||
long betweenDay = LocalDateTimeUtil.between(startDate, endDate, ChronoUnit.HOURS);
|
||||
param.setStartTime(startDate.format(dateTimeFormatter));
|
||||
param.setEndTime(startDate.with(LocalTime.of(startDate.getHour(), 59, 59)).format(dateTimeFormatter));
|
||||
migrationService.hourseLineEventBacthSysc(param);
|
||||
migrationService.hourseDevDataBacthSysc(param);
|
||||
for (int i = 0; i <betweenDay; i++) {
|
||||
LineCountEvaluateParam countEvaluateParam=new LineCountEvaluateParam();
|
||||
countEvaluateParam.setIsManual(true);
|
||||
startDate = LocalDateTimeUtil.offset(startDate, 1, ChronoUnit.HOURS);
|
||||
countEvaluateParam.setStartTime(startDate.format(dateTimeFormatter));
|
||||
countEvaluateParam.setEndTime(startDate.with(LocalTime.of(startDate.getHour(), 59, 59)).format(dateTimeFormatter));
|
||||
migrationService.hourseLineEventBacthSysc(countEvaluateParam);
|
||||
migrationService.hourseDevDataBacthSysc(countEvaluateParam);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
|
||||
@@ -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 * * ?")
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DataHarmRateIImpl implements IDataHarmRateI {
|
||||
@Override
|
||||
public List<DataHarmrateI> listDataHarmrateI(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateI.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.I, InfluxDbSqlConstant.I, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmrateI::getLineId)
|
||||
.select(DataHarmrateI::getPhasicType)
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DataHarmRateVImpl implements IDataHarmRateV {
|
||||
@Override
|
||||
public List<DataHarmrateV> listDataHarmrateV(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmrateV.class);
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, "", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.V, InfluxDbSqlConstant.V, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
|
||||
influxQueryWrapper
|
||||
.select(DataHarmrateV::getLineId)
|
||||
.select(DataHarmrateV::getPhasicType)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user