544245
parent
4d86154f8c
commit
c26b0a3284
Binary file not shown.
|
@ -1,24 +0,0 @@
|
|||
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();
|
||||
}
|
Binary file not shown.
|
@ -1,11 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,30 +0,0 @@
|
|||
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;
|
||||
}
|
Binary file not shown.
|
@ -1,73 +0,0 @@
|
|||
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;
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,18 +0,0 @@
|
|||
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();
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -1,36 +0,0 @@
|
|||
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