初始化
commit
6bb7bc4cf7
|
@ -0,0 +1,35 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?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"
|
||||||
|
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>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>cloud-common-etl</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<description>
|
||||||
|
cloud-common-etl
|
||||||
|
</description>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.muyu.etl.basic;
|
||||||
|
|
||||||
|
import com.muyu.etl.domain.DataValue;
|
||||||
|
|
||||||
|
public interface DataValueBasic extends TaskBasic{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据值
|
||||||
|
* @return 返回查询的数据值
|
||||||
|
*/
|
||||||
|
public DataValue getDataStructure();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据记录
|
||||||
|
* @return 数据记录
|
||||||
|
*/
|
||||||
|
public DataValue[] getRow();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据集
|
||||||
|
* @return 数据集
|
||||||
|
*/
|
||||||
|
public DataValue[][] getRows();
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.etl.basic;
|
||||||
|
|
||||||
|
import com.muyu.etl.scope.TaskScopeBasic;
|
||||||
|
import com.muyu.etl.scope.TaskScopeConfig;
|
||||||
|
|
||||||
|
public interface TaskBasic {
|
||||||
|
|
||||||
|
public default TaskScopeConfig getScopeConfig(){
|
||||||
|
return TaskScopeBasic.get();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.muyu.etl.domain;
|
||||||
|
|
||||||
|
import com.muyu.etl.enums.DataType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DataValue {
|
||||||
|
/**
|
||||||
|
* 字段名
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
/**
|
||||||
|
* 字段类型
|
||||||
|
*/
|
||||||
|
private DataType type;
|
||||||
|
/**
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
/**
|
||||||
|
* 值
|
||||||
|
*/
|
||||||
|
private Object value;
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package com.muyu.etl.enums;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:zhangzhihao
|
||||||
|
* @name:DataType
|
||||||
|
* @Date:2024/8/28 18:38
|
||||||
|
* 不准抄代码,添加注释,清楚每一行代码意思
|
||||||
|
*/
|
||||||
|
public enum DataType {
|
||||||
|
VARCHAR("varchar",String.class,"String"),
|
||||||
|
BIGINT("bigint", Long.class,"Long"),
|
||||||
|
INT("int", Integer.class,"Integer"),
|
||||||
|
DECIMAL("decimal", BigDecimal.class,"BigDecimal"),
|
||||||
|
DATETIME("datetime", Date.class,"Date"),
|
||||||
|
TEXT("text", String.class,"String"),
|
||||||
|
DOUBLE("double", Double.class,"Double");
|
||||||
|
|
||||||
|
private final String sourceType;
|
||||||
|
|
||||||
|
private final Class<?> targetType;
|
||||||
|
|
||||||
|
private final String javaType;
|
||||||
|
|
||||||
|
public String getSourceType() {
|
||||||
|
return sourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<?> getTargetType() {
|
||||||
|
return targetType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJavaType() {
|
||||||
|
return javaType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Class convertType(String type){
|
||||||
|
for (DataType dataType : DataType.values()) {
|
||||||
|
if (dataType.sourceType.equalsIgnoreCase(type)){
|
||||||
|
return dataType.targetType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataType findBySqlType(String sqlType){
|
||||||
|
for (DataType dataType : DataType.values()) {
|
||||||
|
if (dataType.getSourceType().equalsIgnoreCase(sqlType)){
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return VARCHAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertTypeString(String type){
|
||||||
|
|
||||||
|
for (DataType dataType : DataType.values()) {
|
||||||
|
if (dataType.sourceType.equalsIgnoreCase(type)){
|
||||||
|
return dataType.javaType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "String";
|
||||||
|
}
|
||||||
|
|
||||||
|
DataType(String sourceType, Class<?> targetType, String javaType) {
|
||||||
|
this.sourceType = sourceType;
|
||||||
|
this.targetType = targetType;
|
||||||
|
this.javaType = javaType;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.muyu.etl.scope;
|
||||||
|
|
||||||
|
public class TaskScopeBasic {
|
||||||
|
|
||||||
|
private static final ThreadLocal<TaskScopeConfig> localScope = new ThreadLocal<>();
|
||||||
|
|
||||||
|
public static void set(final TaskScopeConfig handler) {
|
||||||
|
localScope.set(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TaskScopeConfig get() {
|
||||||
|
return localScope.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(){
|
||||||
|
localScope.remove();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.muyu.etl.scope;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class TaskScopeConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任務ID
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
|
||||||
|
private LinkedBlockingDeque taskNodeQueue = new LinkedBlockingDeque();
|
||||||
|
|
||||||
|
public void addTaskNode(Object obj){
|
||||||
|
this.taskNodeQueue.add(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hashTaskNodeNext(){
|
||||||
|
return !taskNodeQueue.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> T nextTaskNode(){
|
||||||
|
return (T) taskNodeQueue.poll();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue