异常数据判断调整
This commit is contained in:
@@ -1,12 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
<parent>
|
||||||
|
<artifactId>mysql-data</artifactId>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>data-migration</artifactId>
|
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>mysql-source</name>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<artifactId>mysql-source</artifactId>
|
<artifactId>mysql-source</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
@@ -86,11 +88,13 @@
|
|||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>oracle-source</artifactId>
|
<artifactId>oracle-source</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-collections4</artifactId>
|
<artifactId>commons-collections4</artifactId>
|
||||||
@@ -101,5 +105,6 @@
|
|||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.njcn</groupId>
|
|
||||||
<artifactId>mysql-data</artifactId>
|
<artifactId>mysql-data</artifactId>
|
||||||
|
<groupId>com.njcn</groupId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>mysql-target</name>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>mysql-target</artifactId>
|
<artifactId>mysql-target</artifactId>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
<maven.compiler.source>8</maven.compiler.source>
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
<maven.compiler.target>8</maven.compiler.target>
|
||||||
@@ -24,6 +26,7 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!--oracle数据源-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.njcn</groupId>
|
<groupId>com.njcn</groupId>
|
||||||
<artifactId>mysql-source</artifactId>
|
<artifactId>mysql-source</artifactId>
|
||||||
@@ -36,18 +39,9 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>mysqlTarget</finalName>
|
<finalName>mysql-target</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.0</version>
|
|
||||||
<configuration>
|
|
||||||
<compilerArgument>-Xlint:unchecked</compilerArgument>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
@@ -61,12 +55,35 @@
|
|||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
|
<version>2.2.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>attach-sources</id>
|
||||||
|
<goals>
|
||||||
|
<goal>jar-no-fork</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.spotify</groupId>
|
<groupId>com.spotify</groupId>
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
<version>1.2.2</version>
|
<version>1.0.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
|
||||||
<execution>
|
<execution>
|
||||||
<id>build-image</id>
|
<id>build-image</id>
|
||||||
<phase>${docker.operate}</phase>
|
<phase>${docker.operate}</phase>
|
||||||
@@ -80,20 +97,15 @@
|
|||||||
<registryUrl>http://${docker.repostory}</registryUrl>
|
<registryUrl>http://${docker.repostory}</registryUrl>
|
||||||
<!-- 镜像名称 -->
|
<!-- 镜像名称 -->
|
||||||
<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}</imageName>
|
<imageName>${docker.repostory}/${docker.registry.name}/${project.artifactId}</imageName>
|
||||||
<!-- 指定标签 -->
|
|
||||||
<imageTags>
|
<imageTags>
|
||||||
<imageTag>latest</imageTag>
|
<imageTag>latest</imageTag>
|
||||||
</imageTags>
|
</imageTags>
|
||||||
<!-- 指定远程 Docker API地址 -->
|
|
||||||
<dockerHost>${docker.url}</dockerHost>
|
<dockerHost>${docker.url}</dockerHost>
|
||||||
<dockerDirectory>${basedir}/</dockerDirectory>
|
<dockerDirectory>${basedir}/</dockerDirectory>
|
||||||
<!-- 复制 jar包到docker容器指定目录-->
|
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<targetPath>/ROOT</targetPath>
|
<targetPath>/ROOT</targetPath>
|
||||||
<!-- 用于指定需要复制的根目录,${project.build.directory}表示target目录 -->
|
|
||||||
<directory>${project.build.directory}</directory>
|
<directory>${project.build.directory}</directory>
|
||||||
<!-- 用于指定需要复制的文件,${project.build.finalName}.jar就是打包后的target目录下的jar包名称 -->
|
|
||||||
<include>${project.build.finalName}.jar</include>
|
<include>${project.build.finalName}.jar</include>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ import com.njcn.mysql.bo.po.*;
|
|||||||
import com.njcn.mysql.service.*;
|
import com.njcn.mysql.service.*;
|
||||||
import com.njcn.mysql.util.PubUtils;
|
import com.njcn.mysql.util.PubUtils;
|
||||||
import com.njcn.oracle.bo.po.*;
|
import com.njcn.oracle.bo.po.*;
|
||||||
import com.njcn.oracle.bo.po.DayHarmrateV;
|
|
||||||
import com.njcn.oracle.bo.po.DayV;
|
|
||||||
import com.njcn.oracle.bo.po.LimitRate;
|
|
||||||
import com.njcn.oracle.bo.po.PqsIntegrity;
|
|
||||||
import com.njcn.oracle.bo.po.*;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -447,7 +442,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
po1.setPhaseType(data.getPhasicType());
|
po1.setPhaseType(data.getPhasicType());
|
||||||
po1.setValueType(valueType);
|
po1.setValueType(valueType);
|
||||||
//异常数据判断
|
//异常数据判断
|
||||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_HARM_RATE_V.getCode(),data));
|
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_HARM_RATE_V.getCode(),data,null));
|
||||||
return po1;
|
return po1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +465,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
po1.setVZero(data.getVZero());
|
po1.setVZero(data.getVZero());
|
||||||
po1.setVThd(data.getVThd());
|
po1.setVThd(data.getVThd());
|
||||||
//异常数据判断
|
//异常数据判断
|
||||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data,null));
|
||||||
} else if (Objects.equals(valueType,"MAX")) {
|
} else if (Objects.equals(valueType,"MAX")) {
|
||||||
po1.setRms(data.getRmsMax());
|
po1.setRms(data.getRmsMax());
|
||||||
po1.setVuDev(data.getVuDevMax());
|
po1.setVuDev(data.getVuDevMax());
|
||||||
@@ -483,7 +478,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
po1.setVZero(data.getVZeroMax());
|
po1.setVZero(data.getVZeroMax());
|
||||||
po1.setVThd(data.getVThdMax());
|
po1.setVThd(data.getVThdMax());
|
||||||
//异常数据判断
|
//异常数据判断
|
||||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data,"Max"));
|
||||||
} else if (Objects.equals(valueType,"MIN")) {
|
} else if (Objects.equals(valueType,"MIN")) {
|
||||||
po1.setRms(data.getRmsMin());
|
po1.setRms(data.getRmsMin());
|
||||||
po1.setVuDev(data.getVuDevMin());
|
po1.setVuDev(data.getVuDevMin());
|
||||||
@@ -496,7 +491,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
po1.setVZero(data.getVZeroMin());
|
po1.setVZero(data.getVZeroMin());
|
||||||
po1.setVThd(data.getVThdMin());
|
po1.setVThd(data.getVThdMin());
|
||||||
//异常数据判断
|
//异常数据判断
|
||||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data,"Min"));
|
||||||
} else if (Objects.equals(valueType,"CP95")) {
|
} else if (Objects.equals(valueType,"CP95")) {
|
||||||
po1.setRms(data.getRmsCp95());
|
po1.setRms(data.getRmsCp95());
|
||||||
po1.setVuDev(data.getVuDevCp95());
|
po1.setVuDev(data.getVuDevCp95());
|
||||||
@@ -509,7 +504,7 @@ public class OracleToMysqlServiceImpl implements OracleToMysqlService {
|
|||||||
po1.setVZero(data.getVZeroCp95());
|
po1.setVZero(data.getVZeroCp95());
|
||||||
po1.setVThd(data.getVThdCp95());
|
po1.setVThd(data.getVThdCp95());
|
||||||
//异常数据判断
|
//异常数据判断
|
||||||
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data));
|
po1.setQualityFlag(PubUtils.judgeData(TargetEnum.DAY_V.getCode(),data,"Cp95"));
|
||||||
}
|
}
|
||||||
return po1;
|
return po1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import com.njcn.oracle.bo.po.DayV;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PubUtils {
|
public class PubUtils {
|
||||||
|
|
||||||
@@ -59,18 +56,61 @@ public class PubUtils {
|
|||||||
* code: 指标名称
|
* code: 指标名称
|
||||||
* object: 数据实体
|
* object: 数据实体
|
||||||
*/
|
*/
|
||||||
public static int judgeData(Integer code, Object object) {
|
public static int judgeData(Integer code, Object object, String type) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 0:
|
case 0:
|
||||||
DayV data = new ObjectMapper().convertValue(object, DayV.class);
|
DayV data = new ObjectMapper().convertValue(object, DayV.class);
|
||||||
if (data.getFreq() > 57.5|| data.getFreq() < 42.5
|
try {
|
||||||
|| Math.abs(data.getVuDev()) >20.0|| Math.abs(data.getVlDev()) >20.0
|
String methodName1 = "getFreq" + (Objects.isNull(type)?"":type);
|
||||||
|| Math.abs(data.getFreqDev()) >7.5
|
Method method1 = data.getClass().getMethod(methodName1);
|
||||||
|| data.getVUnbalance() <0.0|| data.getVUnbalance() > 40.0
|
//防止数据异常大,超过数据库字段设置的大小
|
||||||
|| data.getVThd() < 0.0 || data.getVThd() > 30.0) {
|
float value1 = Math.min((Float) method1.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
String methodName2 = "getVuDev" + (Objects.isNull(type)?"":type);
|
||||||
|
Method method2 = data.getClass().getMethod(methodName2);
|
||||||
|
float value2 = Math.min((Float) method2.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
String methodName3 = "getVlDev" + (Objects.isNull(type)?"":type);
|
||||||
|
Method method3 = data.getClass().getMethod(methodName3);
|
||||||
|
float value3 = Math.min((Float) method3.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
String methodName4 = "getFreqDev" + (Objects.isNull(type)?"":type);
|
||||||
|
Method method4 = data.getClass().getMethod(methodName4);
|
||||||
|
float value4 = Math.min((Float) method4.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
String methodName5 = "getVUnbalance" + (Objects.isNull(type)?"":type);
|
||||||
|
Method method5 = data.getClass().getMethod(methodName5);
|
||||||
|
float value5 = Math.min((Float) method5.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
String methodName6 = "getVThd" + (Objects.isNull(type)?"":type);
|
||||||
|
Method method6 = data.getClass().getMethod(methodName6);
|
||||||
|
float value6 = Math.min((Float) method6.invoke(data), 999999.0f);
|
||||||
|
|
||||||
|
List<String> phase = Arrays.asList("A","B","C");
|
||||||
|
//频率异常判断
|
||||||
|
if (Objects.equals(data.getPhasicType(),"T") && (value1 > 57.5|| value1 < 42.5)){
|
||||||
result = 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
//电压偏差异常判断
|
||||||
|
if (phase.contains(data.getPhasicType()) && (Math.abs(value2) >20.0|| Math.abs(value3) >20.0)){
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
//频率偏差异常判断
|
||||||
|
if (Objects.equals(data.getPhasicType(),"T") && Math.abs(value4) >7.5){
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
//三相电压不平衡度异常判断
|
||||||
|
if (Objects.equals(data.getPhasicType(),"T") && (value5 <0.0|| value5 > 40.0)){
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
//电压总谐波畸变率异常判断
|
||||||
|
if (phase.contains(data.getPhasicType()) && (value6 < 0.0 || value6 > 30.0)){
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.getMessage();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
case 4:
|
case 4:
|
||||||
DayHarmrateV data4 = new ObjectMapper().convertValue(object, DayHarmrateV.class);
|
DayHarmrateV data4 = new ObjectMapper().convertValue(object, DayHarmrateV.class);
|
||||||
@@ -108,7 +148,8 @@ public class PubUtils {
|
|||||||
Object value = getMethod.invoke(data);
|
Object value = getMethod.invoke(data);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
BigDecimal bigDecimalValue = new BigDecimal(value.toString());
|
BigDecimal bigDecimalValue = new BigDecimal(value.toString());
|
||||||
float floatValue = bigDecimalValue.floatValue();
|
//防止数据异常大,超过数据库字段设置的大小
|
||||||
|
float floatValue = Math.min(bigDecimalValue.floatValue(), 999999.0f);
|
||||||
Method setMethod = po1.getClass().getMethod(methodNameSet, Float.class);
|
Method setMethod = po1.getClass().getMethod(methodNameSet, Float.class);
|
||||||
setMethod.invoke(po1, floatValue);
|
setMethod.invoke(po1, floatValue);
|
||||||
}
|
}
|
||||||
@@ -131,6 +172,21 @@ public class PubUtils {
|
|||||||
Method method = data.getClass().getMethod(methodName);
|
Method method = data.getClass().getMethod(methodName);
|
||||||
Float value = (Float) method.invoke(data);
|
Float value = (Float) method.invoke(data);
|
||||||
avgData.add(value);
|
avgData.add(value);
|
||||||
|
|
||||||
|
String methodName2 = "getV" + i + "Max";
|
||||||
|
Method method2 = data.getClass().getMethod(methodName2);
|
||||||
|
Float value2 = (Float) method2.invoke(data);
|
||||||
|
avgData.add(value2);
|
||||||
|
|
||||||
|
String methodName3 = "getV" + i + "Min";
|
||||||
|
Method method3 = data.getClass().getMethod(methodName3);
|
||||||
|
Float value3 = (Float) method3.invoke(data);
|
||||||
|
avgData.add(value3);
|
||||||
|
|
||||||
|
String methodName4 = "getV" + i + "Cp95";
|
||||||
|
Method method4 = data.getClass().getMethod(methodName4);
|
||||||
|
Float value4 = (Float) method4.invoke(data);
|
||||||
|
avgData.add(value4);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user