oralce数据转入mysql
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
<docker.repostory>${docker.server.url}:8090</docker.repostory>
|
||||
<!--docker远程项目仓库名-->
|
||||
<docker.registry.name>njcn</docker.registry.name>
|
||||
<docker.operate>install</docker.operate>
|
||||
<docker.operate>site</docker.operate>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.mysql.bo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum TargetEnum {
|
||||
|
||||
DAY_V(0,"day_v"),
|
||||
DAY_I(1,"day_i"),
|
||||
DAY_FLICKER(2,"day_flicker"),
|
||||
DAY_PLT(3,"day_plt"),
|
||||
DAY_HARM_RATE_V(4,"day_harmrate_v"),
|
||||
DAY_IN_HARM_V(5,"day_inharm_v");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
private final String message;
|
||||
|
||||
TargetEnum(Integer code, String message) {
|
||||
this.code=code;
|
||||
this.message=message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.mysql.bo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ import java.time.LocalDate;
|
||||
*/
|
||||
@Data
|
||||
@TableName("r_stat_integrity_d")
|
||||
public class RStatIntegrityD {
|
||||
public class RStatIntegrityD implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -31,8 +31,4 @@ public class RStatIntegrityD {
|
||||
|
||||
private Integer realTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Float integrityData;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.mysql.service;
|
||||
|
||||
import com.njcn.oracle.bo.po.DayHarmrateV;
|
||||
import com.njcn.oracle.bo.po.DayV;
|
||||
import com.njcn.oracle.bo.po.PqsIntegrity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,4 +14,20 @@ public interface OracleDataService {
|
||||
* @return
|
||||
*/
|
||||
List<DayHarmrateV> getDayHarmRate(String time);
|
||||
|
||||
/**
|
||||
* 查询oracle中PQS_INTEGRITY数据
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
List<PqsIntegrity> getPqsIntegrity(String time);
|
||||
|
||||
/**
|
||||
* 查询oracle中DAY_V数据
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
List<DayV> getDayV(String time);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,49 @@
|
||||
package com.njcn.mysql.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.mysql.service.OracleDataService;
|
||||
import com.njcn.oracle.bo.po.DataFlicker;
|
||||
import com.njcn.oracle.bo.po.DayHarmrateV;
|
||||
import com.njcn.oracle.bo.po.DayV;
|
||||
import com.njcn.oracle.bo.po.PqsIntegrity;
|
||||
import com.njcn.oracle.mapper.DayHarmrateVMapper;
|
||||
import com.njcn.oracle.mapper.DayVMapper;
|
||||
import com.njcn.oracle.mapper.PqsIntegrityMapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class OracleDataServiceImpl implements OracleDataService {
|
||||
|
||||
private final DayHarmrateVMapper dayHarmrateVMapper;
|
||||
|
||||
private final PqsIntegrityMapper pqsIntegrityMapper;
|
||||
|
||||
private final DayVMapper dayVMapper;
|
||||
|
||||
@Override
|
||||
public List<DayHarmrateV> getDayHarmRate(String time) {
|
||||
// time = LocalDateTimeUtil.format(LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.parse(time, DatePattern.NORM_DATE_PATTERN)),DatePattern.NORM_DATETIME_PATTERN);
|
||||
LambdaQueryWrapper<DayHarmrateV> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.apply("TIMEID = to_date({0},'yyyy-mm-dd')",time);
|
||||
return dayHarmrateVMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqsIntegrity> getPqsIntegrity(String time) {
|
||||
LambdaQueryWrapper<PqsIntegrity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.apply("TIMEID = to_date({0},'yyyy-mm-dd')",time);
|
||||
return pqsIntegrityMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DayV> getDayV(String time) {
|
||||
LambdaQueryWrapper<DayV> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.apply("TIMEID = to_date({0},'yyyy-mm-dd')",time);
|
||||
return dayVMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,5 +34,25 @@ public class OracleToMysqlController {
|
||||
return true;// HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "数据同步");
|
||||
}
|
||||
|
||||
@GetMapping("/pqsIntegrity")
|
||||
@ApiOperation("pqs_integrity转成r_stat_integrity_d")
|
||||
public Boolean pqsIntegritySync(@RequestParam("startDateTime")String startDateTime, @RequestParam("endDateTime")String endDateTime) {
|
||||
DataAsynParam dataAsynParam = new DataAsynParam();
|
||||
dataAsynParam.setStartDateTime(LocalDateTimeUtil.parse(startDateTime, DatePattern.NORM_DATE_PATTERN));
|
||||
dataAsynParam.setEndDateTime(LocalDateTimeUtil.parse(endDateTime, DatePattern.NORM_DATE_PATTERN));
|
||||
oracleToMysqlService.insertPqsIntegrity(startDateTime,endDateTime);
|
||||
return true;// HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "数据同步");
|
||||
}
|
||||
|
||||
@GetMapping("/dayVSync")
|
||||
@ApiOperation("day_v转成r_stat_data_v_d")
|
||||
public Boolean dayVSync(@RequestParam("startDateTime")String startDateTime, @RequestParam("endDateTime")String endDateTime) {
|
||||
DataAsynParam dataAsynParam = new DataAsynParam();
|
||||
dataAsynParam.setStartDateTime(LocalDateTimeUtil.parse(startDateTime, DatePattern.NORM_DATE_PATTERN));
|
||||
dataAsynParam.setEndDateTime(LocalDateTimeUtil.parse(endDateTime, DatePattern.NORM_DATE_PATTERN));
|
||||
oracleToMysqlService.insertDayV(startDateTime,endDateTime);
|
||||
return true;// HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, "数据同步");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.njcn.mysql.service;
|
||||
|
||||
import com.njcn.mysql.bo.po.RStatIntegrityD;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IntegrityService {
|
||||
|
||||
void insert(List<RStatIntegrityD> list);
|
||||
}
|
||||
@@ -8,4 +8,18 @@ public interface OracleToMysqlService {
|
||||
* @param endTime
|
||||
*/
|
||||
void insertDayHarmRateV(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* r_stat_integrity_d数据插入
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
*/
|
||||
void insertPqsIntegrity(String startTime, String endTime);
|
||||
|
||||
/**
|
||||
* r_stat_data_v_d数据插入
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
*/
|
||||
void insertDayV(String startTime, String endTime);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.mysql.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.mysql.bo.po.RStatIntegrityD;
|
||||
import com.njcn.mysql.mapper.RStatIntegrityDMapper;
|
||||
import com.njcn.mysql.service.IntegrityService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 数据完整性统计
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/10/24 20:07
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@DS("target")
|
||||
public class IntegrityServiceImpl extends MppServiceImpl<RStatIntegrityDMapper, RStatIntegrityD> implements IntegrityService {
|
||||
|
||||
@Override
|
||||
public void insert(List<RStatIntegrityD> list) {
|
||||
this.saveOrUpdateBatchByMultiId(list,50);
|
||||
}
|
||||
}
|
||||
@@ -2,24 +2,22 @@ package com.njcn.mysql.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.njcn.mysql.bo.enums.TargetEnum;
|
||||
import com.njcn.mysql.bo.po.PqLineBak;
|
||||
import com.njcn.mysql.bo.po.RStatDataHarmrateVD;
|
||||
import com.njcn.mysql.service.IPqLineBakService;
|
||||
import com.njcn.mysql.service.IRStatDataHarmRateVDService;
|
||||
import com.njcn.mysql.service.OracleDataService;
|
||||
import com.njcn.mysql.service.OracleToMysqlService;
|
||||
import com.njcn.mysql.bo.po.RStatDataVD;
|
||||
import com.njcn.mysql.bo.po.RStatIntegrityD;
|
||||
import com.njcn.mysql.service.*;
|
||||
import com.njcn.mysql.util.PubUtils;
|
||||
import com.njcn.oracle.bo.po.DayHarmrateV;
|
||||
import com.njcn.oracle.bo.po.DayV;
|
||||
import com.njcn.oracle.bo.po.PqsIntegrity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -35,118 +33,220 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
||||
|
||||
private final IRStatDataHarmRateVDService rStatDataHarmRateVDService;
|
||||
|
||||
private final IntegrityService integrityService;
|
||||
|
||||
private final IRStatDataVDService rStatDataVDService;
|
||||
|
||||
@Override
|
||||
public void insertDayHarmRateV(String startTime, String endTime) {
|
||||
List<RStatDataHarmrateVD> result = new ArrayList<>();
|
||||
List<String> timeList = PubUtils.getTimeList(startTime,endTime);
|
||||
List<PqLineBak> bakList = pqLineBakService.list();
|
||||
//lineId:Oracle监测点ID id:Mysql监测点ID
|
||||
Map<String, String> oracleRelationMysql = bakList.stream().collect(Collectors.toMap(PqLineBak::getLineId, PqLineBak::getId));
|
||||
timeList.forEach(item->{
|
||||
System.out.println("当前执行日期:"+ item);
|
||||
List<RStatDataHarmrateVD> result = new ArrayList<>();
|
||||
long system1 = System.currentTimeMillis();
|
||||
List<DayHarmrateV> list = oracleDataService.getDayHarmRate(item);
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
list.forEach(data->{
|
||||
if (ObjUtil.isNotNull(oracleRelationMysql.get(data.getLineid()))) {
|
||||
RStatDataHarmrateVD po1 = getData1(data,oracleRelationMysql,"AVG");
|
||||
PubUtils.setValuesUsingReflection(po1,data,false,"getV","setV",null);
|
||||
|
||||
RStatDataHarmrateVD po2 = getData1(data,oracleRelationMysql,"MAX");
|
||||
PubUtils.setValuesUsingReflection(po2,data,true,"getV","setV","Max");
|
||||
|
||||
RStatDataHarmrateVD po3 = getData1(data,oracleRelationMysql,"MIN");
|
||||
PubUtils.setValuesUsingReflection(po3,data,true,"getV","setV","Min");
|
||||
|
||||
RStatDataHarmrateVD po4 = getData1(data,oracleRelationMysql,"CP95");
|
||||
PubUtils.setValuesUsingReflection(po4,data,true,"getV","setV","Cp95");
|
||||
result.addAll(Arrays.asList(po1,po2,po3,po4));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:0,执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
if(CollUtil.isNotEmpty(result)){
|
||||
rStatDataHarmRateVDService.insert(result);
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:"+(CollUtil.isNotEmpty(list)?list.size():0)+",插入mysql数据:"+ result.size() + ",执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertPqsIntegrity(String startTime, String endTime) {
|
||||
List<String> timeList = PubUtils.getTimeList(startTime,endTime);
|
||||
List<PqLineBak> bakList = pqLineBakService.list();
|
||||
//lineId:Oracle监测点ID id:Mysql监测点ID
|
||||
Map<String, String> oracleRelationMysql = bakList.stream().collect(Collectors.toMap(PqLineBak::getLineId, PqLineBak::getId));
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
timeList.forEach(item->{
|
||||
System.out.println("数据查询时间:" + item);
|
||||
List<DayHarmrateV> list = oracleDataService.getDayHarmRate(item);
|
||||
System.out.println("当前执行日期:"+ item);
|
||||
List<RStatIntegrityD> result = new ArrayList<>();
|
||||
long system1 = System.currentTimeMillis();
|
||||
List<PqsIntegrity> list = oracleDataService.getPqsIntegrity(item);
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
System.out.println("oracle数据量:" + list.size());
|
||||
list.forEach(data->{
|
||||
RStatDataHarmrateVD po1 = new RStatDataHarmrateVD();
|
||||
po1.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
if (ObjUtil.isNotNull(oracleRelationMysql.get(data.getLineid()))) {
|
||||
po1.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po1.setPhaseType(data.getPhasicType());
|
||||
po1.setValueType("AVG");
|
||||
//异常数据判断
|
||||
List<Float> avgData1 = this.getData(data);
|
||||
boolean quality1 = avgData1.stream().anyMatch(o->o>30.0 || o<0.0);
|
||||
if (quality1) {
|
||||
po1.setQualityFlag(1);
|
||||
}
|
||||
setValuesUsingReflection(po1,data,false,"getV","setV",null);
|
||||
|
||||
RStatDataHarmrateVD po2 = new RStatDataHarmrateVD();
|
||||
po2.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po2.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po2.setPhaseType(data.getPhasicType());
|
||||
po2.setValueType("MAX");
|
||||
List<Float> avgData2 = this.getData(data);
|
||||
boolean quality2 = avgData2.stream().anyMatch(o->o>30 || o<0.0);
|
||||
if (quality2) {
|
||||
po2.setQualityFlag(1);
|
||||
}
|
||||
setValuesUsingReflection(po2,data,true,"getV","setV","Max");
|
||||
|
||||
RStatDataHarmrateVD po3 = new RStatDataHarmrateVD();
|
||||
po3.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po3.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po3.setPhaseType(data.getPhasicType());
|
||||
po3.setValueType("MIN");
|
||||
List<Float> avgData3 = this.getData(data);
|
||||
boolean quality3 = avgData3.stream().anyMatch(o->o>30.0 || o<0.0);
|
||||
if (quality3) {
|
||||
po3.setQualityFlag(1);
|
||||
}
|
||||
setValuesUsingReflection(po3,data,true,"getV","setV","Min");
|
||||
|
||||
RStatDataHarmrateVD po4 = new RStatDataHarmrateVD();
|
||||
po4.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po4.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po4.setPhaseType(data.getPhasicType());
|
||||
po4.setValueType("CP95");
|
||||
List<Float> avgData4 = this.getData(data);
|
||||
boolean quality4 = avgData4.stream().anyMatch(o->o>30.0 || o<0.0);
|
||||
if (quality4) {
|
||||
po4.setQualityFlag(1);
|
||||
}
|
||||
setValuesUsingReflection(po4,data,true,"getV","setV","Cp95");
|
||||
|
||||
result.addAll(Arrays.asList(po1,po2,po3,po4));
|
||||
if (ObjUtil.isNotNull(oracleRelationMysql.get(data.getLineIndex()))) {
|
||||
RStatIntegrityD po = new RStatIntegrityD();
|
||||
po.setTimeId(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po.setLineIndex(data.getLineIndex());
|
||||
po.setDueTime(data.getDue());
|
||||
po.setRealTime(data.getReal());
|
||||
result.add(po);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:0,执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
if(CollUtil.isNotEmpty(result)){
|
||||
rStatDataHarmRateVDService.insert(result);
|
||||
integrityService.insert(result);
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:"+(CollUtil.isNotEmpty(list)?list.size():0)+",插入mysql数据:"+ result.size() + ",执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<Float> getData(Object data) {
|
||||
List<Float> avgData = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
String methodName = "getV" + i;
|
||||
Method method = data.getClass().getMethod(methodName);
|
||||
Float value = (Float) method.invoke(data);
|
||||
avgData.add(value);
|
||||
@Override
|
||||
public void insertDayV(String startTime, String endTime) {
|
||||
List<String> timeList = PubUtils.getTimeList(startTime,endTime);
|
||||
List<PqLineBak> bakList = pqLineBakService.list();
|
||||
//lineId:Oracle监测点ID id:Mysql监测点ID
|
||||
Map<String, String> oracleRelationMysql = bakList.stream().collect(Collectors.toMap(PqLineBak::getLineId, PqLineBak::getId));
|
||||
timeList.forEach(item->{
|
||||
System.out.println("当前执行日期:"+ item);
|
||||
List<RStatDataVD> result = new ArrayList<>();
|
||||
long system1 = System.currentTimeMillis();
|
||||
List<DayV> list = oracleDataService.getDayV(item);
|
||||
//处理线电压有效值
|
||||
|
||||
if(CollUtil.isNotEmpty(list)){
|
||||
list.forEach(data->{
|
||||
if (ObjUtil.isNotNull(oracleRelationMysql.get(data.getLineid()))) {
|
||||
RStatDataVD po1 = getData2(data,oracleRelationMysql,"AVG");
|
||||
PubUtils.setValuesUsingReflection(po1,data,false,"getV","setV",null);
|
||||
|
||||
RStatDataVD po2 = getData2(data,oracleRelationMysql,"MAX");
|
||||
PubUtils.setValuesUsingReflection(po2,data,true,"getV","setV","Max");
|
||||
|
||||
RStatDataVD po3 = getData2(data,oracleRelationMysql,"MIN");
|
||||
PubUtils.setValuesUsingReflection(po3,data,true,"getV","setV","Min");
|
||||
|
||||
RStatDataVD po4 = getData2(data,oracleRelationMysql,"CP95");
|
||||
PubUtils.setValuesUsingReflection(po4,data,true,"getV","setV","Cp95");
|
||||
result.addAll(Arrays.asList(po1,po2,po3,po4));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:0,执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return avgData;
|
||||
if(CollUtil.isNotEmpty(result)){
|
||||
rStatDataVDService.insert(result);
|
||||
long system2 = System.currentTimeMillis();
|
||||
System.out.println("查询oracle数据:"+(CollUtil.isNotEmpty(list)?list.size():0)+",插入mysql数据:"+ result.size() + ",执行时间:" + (system2-system1)/1000.0 + "s");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public RStatDataHarmrateVD getData1(DayHarmrateV data, Map<String, String> oracleRelationMysql, String valueType) {
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
RStatDataHarmrateVD po1 = new RStatDataHarmrateVD();
|
||||
po1.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po1.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po1.setPhaseType(data.getPhasicType());
|
||||
po1.setValueType(valueType);
|
||||
//异常数据判断
|
||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_HARM_RATE_V.getCode(),data));
|
||||
return po1;
|
||||
}
|
||||
|
||||
public void setValuesUsingReflection(Object po1, Object data, boolean judge, String getString, String setString, String getEndString) {
|
||||
try {
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
String methodNameGet;
|
||||
if (judge) {
|
||||
methodNameGet = getString + i + getEndString;
|
||||
} else {
|
||||
methodNameGet = getString + i;
|
||||
}
|
||||
String methodNameSet = setString + i;
|
||||
Method getMethod = data.getClass().getMethod(methodNameGet);
|
||||
Object value = getMethod.invoke(data);
|
||||
if (value != null) {
|
||||
BigDecimal bigDecimalValue = new BigDecimal(value.toString());
|
||||
double doubleValue = bigDecimalValue.doubleValue();
|
||||
Method setMethod = po1.getClass().getMethod(methodNameSet, Double.class);
|
||||
setMethod.invoke(po1, doubleValue);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public RStatDataVD getData2(DayV data, Map<String, String> oracleRelationMysql, String valueType) {
|
||||
ZoneId zoneId = ZoneId.systemDefault();
|
||||
RStatDataVD po1 = new RStatDataVD();
|
||||
po1.setTime(data.getTimeid().toInstant().atZone(zoneId).toLocalDate());
|
||||
po1.setLineId(oracleRelationMysql.get(data.getLineid()));
|
||||
po1.setPhasicType(data.getPhasicType());
|
||||
po1.setValueType(valueType);
|
||||
if (Objects.equals(valueType,"AVG")) {
|
||||
po1.setRms(BigDecimal.valueOf(data.getRms()).doubleValue());
|
||||
po1.setVuDev(BigDecimal.valueOf(data.getVuDev()).doubleValue());
|
||||
po1.setVlDev(BigDecimal.valueOf(data.getVlDev()).doubleValue());
|
||||
po1.setFreq(BigDecimal.valueOf(data.getFreq()).doubleValue());
|
||||
po1.setFreqDev(BigDecimal.valueOf(data.getFreqDev()).doubleValue());
|
||||
po1.setVUnbalance(BigDecimal.valueOf(data.getVUnbalance()).doubleValue());
|
||||
po1.setVPos(BigDecimal.valueOf(data.getVPos()).doubleValue());
|
||||
po1.setVNeg(BigDecimal.valueOf(data.getVNeg()).doubleValue());
|
||||
po1.setVZero(BigDecimal.valueOf(data.getVZero()).doubleValue());
|
||||
po1.setVThd(BigDecimal.valueOf(data.getVThd()).doubleValue());
|
||||
//异常数据判断
|
||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
||||
} else if (Objects.equals(valueType,"MAX")) {
|
||||
po1.setRms(BigDecimal.valueOf(data.getRmsMax()).doubleValue());
|
||||
po1.setVuDev(BigDecimal.valueOf(data.getVuDevMax()).doubleValue());
|
||||
po1.setVlDev(BigDecimal.valueOf(data.getVlDevMax()).doubleValue());
|
||||
po1.setFreq(BigDecimal.valueOf(data.getFreqMax()).doubleValue());
|
||||
po1.setFreqDev(BigDecimal.valueOf(data.getFreqDevMax()).doubleValue());
|
||||
po1.setVUnbalance(BigDecimal.valueOf(data.getVUnbalanceMax()).doubleValue());
|
||||
po1.setVPos(BigDecimal.valueOf(data.getVPosMax()).doubleValue());
|
||||
po1.setVNeg(BigDecimal.valueOf(data.getVNegMax()).doubleValue());
|
||||
po1.setVZero(BigDecimal.valueOf(data.getVZeroMax()).doubleValue());
|
||||
po1.setVThd(BigDecimal.valueOf(data.getVThdMax()).doubleValue());
|
||||
//异常数据判断
|
||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
||||
} else if (Objects.equals(valueType,"MIN")) {
|
||||
po1.setRms(BigDecimal.valueOf(data.getRmsMin()).doubleValue());
|
||||
po1.setVuDev(BigDecimal.valueOf(data.getVuDevMin()).doubleValue());
|
||||
po1.setVlDev(BigDecimal.valueOf(data.getVlDevMin()).doubleValue());
|
||||
po1.setFreq(BigDecimal.valueOf(data.getFreqMin()).doubleValue());
|
||||
po1.setFreqDev(BigDecimal.valueOf(data.getFreqDevMin()).doubleValue());
|
||||
po1.setVUnbalance(BigDecimal.valueOf(data.getVUnbalanceMin()).doubleValue());
|
||||
po1.setVPos(BigDecimal.valueOf(data.getVPosMin()).doubleValue());
|
||||
po1.setVNeg(BigDecimal.valueOf(data.getVNegMin()).doubleValue());
|
||||
po1.setVZero(BigDecimal.valueOf(data.getVZeroMin()).doubleValue());
|
||||
po1.setVThd(BigDecimal.valueOf(data.getVThdMin()).doubleValue());
|
||||
//异常数据判断
|
||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
||||
} else if (Objects.equals(valueType,"CP95")) {
|
||||
po1.setRms(BigDecimal.valueOf(data.getRmsCp95()).doubleValue());
|
||||
po1.setVuDev(BigDecimal.valueOf(data.getVuDevCp95()).doubleValue());
|
||||
po1.setVlDev(BigDecimal.valueOf(data.getVlDevCp95()).doubleValue());
|
||||
po1.setFreq(BigDecimal.valueOf(data.getFreqCp95()).doubleValue());
|
||||
po1.setFreqDev(BigDecimal.valueOf(data.getFreqDevCp95()).doubleValue());
|
||||
po1.setVUnbalance(BigDecimal.valueOf(data.getVUnbalanceCp95()).doubleValue());
|
||||
po1.setVPos(BigDecimal.valueOf(data.getVPosCp95()).doubleValue());
|
||||
po1.setVNeg(BigDecimal.valueOf(data.getVNegCp95()).doubleValue());
|
||||
po1.setVZero(BigDecimal.valueOf(data.getVZeroCp95()).doubleValue());
|
||||
po1.setVThd(BigDecimal.valueOf(data.getVThdCp95()).doubleValue());
|
||||
//异常数据判断
|
||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
||||
}
|
||||
return po1;
|
||||
}
|
||||
|
||||
public void getRmsLvrData(List<DayV> list) {
|
||||
Map<String,List<Float>> map = new HashMap<>();
|
||||
Map<String, List<DayV>> dayMap = list.stream().collect(Collectors.groupingBy(DayV::getLineid));
|
||||
List<DayV> tList = list.stream().filter(type ->Objects.equals(type.getPhasicType(),"T")).collect(Collectors.toList());
|
||||
tList.forEach(item->{
|
||||
if (CollUtil.isNotEmpty(dayMap.get(item.getLineid()))){
|
||||
DayV dayV = dayMap.get(item.getLineid()).stream().filter(type ->Objects.equals(type.getPhasicType(),"T")).collect(Collectors.toList()).get(0);
|
||||
dayMap.get(item.getLineid()).forEach(day->{
|
||||
if (Objects.equals(day.getPhasicType(),"A")) {
|
||||
|
||||
} else if (Objects.equals(day.getPhasicType(),"B")) {
|
||||
|
||||
} else if (Objects.equals(day.getPhasicType(),"C")) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.mysql.service.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.mysql.bo.po.RStatDataVD;
|
||||
import com.njcn.mysql.mapper.RStatDataVDMapper;
|
||||
@@ -15,6 +16,7 @@ import java.util.List;
|
||||
* @version 1.0.0
|
||||
* @createTime 2023/3/24 9:53
|
||||
*/
|
||||
@DS("target")
|
||||
@Service
|
||||
public class RStatDataVDServiceImpl extends MppServiceImpl<RStatDataVDMapper, RStatDataVD> implements IRStatDataVDService {
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.njcn.mysql.util;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.njcn.oracle.bo.po.DayHarmrateV;
|
||||
import com.njcn.oracle.bo.po.DayV;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -49,5 +54,89 @@ public class PubUtils {
|
||||
return timeStringList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据是否异常 0:正常 1:异常
|
||||
* code: 指标名称
|
||||
* object: 数据实体
|
||||
*/
|
||||
public static int judgeData(Integer code, Object object) {
|
||||
int result = 0;
|
||||
switch (code) {
|
||||
case 0:
|
||||
DayV data = new ObjectMapper().convertValue(object, DayV.class);
|
||||
if (data.getFreq() > 57.5|| data.getFreq() < 42.5
|
||||
|| Math.abs(data.getVuDev()) >20.0|| Math.abs(data.getVlDev()) >20.0
|
||||
|| Math.abs(data.getFreqDev()) >7.5
|
||||
|| data.getVUnbalance() <0.0|| data.getVUnbalance() > 40.0
|
||||
|| data.getVThd() < 0.0 || data.getVThd() > 30.0) {
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
case 4:
|
||||
DayHarmrateV data4 = new ObjectMapper().convertValue(object, DayHarmrateV.class);
|
||||
List<Float> avgData4 = getData(data4);
|
||||
boolean quality4 = avgData4.stream().anyMatch(o->o>30.0 || o<0.0);
|
||||
if (quality4) {
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 2-50次谐波数据赋值
|
||||
* @param po1
|
||||
* @param data
|
||||
* @param judge
|
||||
* @param getString
|
||||
* @param setString
|
||||
* @param getEndString
|
||||
*/
|
||||
public static void setValuesUsingReflection(Object po1, Object data, boolean judge, String getString, String setString, String getEndString) {
|
||||
try {
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
String methodNameGet;
|
||||
if (judge) {
|
||||
methodNameGet = getString + i + getEndString;
|
||||
} else {
|
||||
methodNameGet = getString + i;
|
||||
}
|
||||
String methodNameSet = setString + i;
|
||||
Method getMethod = data.getClass().getMethod(methodNameGet);
|
||||
Object value = getMethod.invoke(data);
|
||||
if (value != null) {
|
||||
BigDecimal bigDecimalValue = new BigDecimal(value.toString());
|
||||
double doubleValue = bigDecimalValue.doubleValue();
|
||||
Method setMethod = po1.getClass().getMethod(methodNameSet, Double.class);
|
||||
setMethod.invoke(po1, doubleValue);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取谐波2-50次数据
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static List<Float> getData(Object data) {
|
||||
List<Float> avgData = new ArrayList<>();
|
||||
try {
|
||||
for (int i = 1; i <= 50; i++) {
|
||||
String methodName = "getV" + i;
|
||||
Method method = data.getClass().getMethod(methodName);
|
||||
Float value = (Float) method.invoke(data);
|
||||
avgData.add(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return avgData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -57,26 +57,26 @@ spring:
|
||||
primary: master
|
||||
strict: false
|
||||
datasource:
|
||||
# master:
|
||||
# url: jdbc:oracle:thin:@127.0.0.1:1521:orcl
|
||||
# username: pqsadmin_jb
|
||||
# password: pqsadmin
|
||||
# driver-class-name: oracle.jdbc.driver.OracleDriver
|
||||
# target:
|
||||
# url: jdbc:mysql://127.0.0.1:3306/pqsinfo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
# username: root
|
||||
# password: 123456
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
master:
|
||||
url: jdbc:oracle:thin:@10.118.135.139:1521:pqsbase
|
||||
username: pqsadmin
|
||||
password: Pqsadmin123
|
||||
url: jdbc:oracle:thin:@127.0.0.1:1521:orcl
|
||||
username: pqsadmin_jb
|
||||
password: pqsadmin
|
||||
driver-class-name: oracle.jdbc.driver.OracleDriver
|
||||
target:
|
||||
url: jdbc:mysql://10.118.135.128:13306/pqsinfo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
url: jdbc:mysql://127.0.0.1:3306/pqsinfo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
username: root
|
||||
password: njcnpqs
|
||||
password: 123456
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# master:
|
||||
# url: jdbc:oracle:thin:@10.118.135.139:1521:pqsbase
|
||||
# username: pqsadmin
|
||||
# password: Pqsadmin123
|
||||
# driver-class-name: oracle.jdbc.driver.OracleDriver
|
||||
# target:
|
||||
# url: jdbc:mysql://10.118.135.128:13306/pqsinfo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT
|
||||
# username: root
|
||||
# password: njcnpqs
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#mybatis配置信息
|
||||
mybatis-plus:
|
||||
#别名扫描
|
||||
|
||||
@@ -8,6 +8,7 @@ import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -24,7 +25,7 @@ public class DayV implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableField("TIMEID")
|
||||
private LocalDateTime timeid;
|
||||
private Date timeid;
|
||||
@TableField("LINEID")
|
||||
private String lineid;
|
||||
@TableField("PHASIC_TYPE")
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.oracle.bo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("PQS_INTEGRITY")
|
||||
public class PqsIntegrity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField("TIMEID")
|
||||
private Date timeid;
|
||||
|
||||
@TableField("LINE_INDEX")
|
||||
private String lineIndex;
|
||||
|
||||
@TableField("DUE")
|
||||
private Integer due;
|
||||
|
||||
@TableField("REAL")
|
||||
private Integer real;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.njcn.oracle.mapper;
|
||||
|
||||
import com.njcn.oracle.bo.po.PqsIntegrity;
|
||||
import com.njcn.oracle.mybatis.mapper.BatchBaseMapper;
|
||||
|
||||
public interface PqsIntegrityMapper extends BatchBaseMapper<PqsIntegrity> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user