修改容器内部路径
parent
e6d59dde91
commit
c744c72127
|
@ -15,13 +15,13 @@ import java.util.HashMap;
|
||||||
*/
|
*/
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main (String[] args) {
|
public static void main(String[] args) {
|
||||||
BaseDataSource mySqlDataSource = new MySqlDataSource();
|
BaseDataSource mySqlDataSource = new MySqlDataSource();
|
||||||
MySqlQuery mySqlQuery = new MySqlQuery();
|
MySqlQuery mySqlQuery = new MySqlQuery();
|
||||||
mySqlQuery.setDataSourceId("1");
|
mySqlQuery.setDataSourceId("1");
|
||||||
mySqlQuery.setSql("select age as 库.表.字段 from abc where name = :name");
|
mySqlQuery.setSql("select age as 库.表.字段 from abc where name = :name");
|
||||||
mySqlQuery.setParams(
|
mySqlQuery.setParams(
|
||||||
new HashMap<>(){{
|
new HashMap<>() {{
|
||||||
put("name", "张三");
|
put("name", "张三");
|
||||||
}}
|
}}
|
||||||
);
|
);
|
||||||
|
|
|
@ -3,11 +3,11 @@ package com.muyu.access.data.base;
|
||||||
public abstract class BaseDataAbsSource implements BaseDataSource {
|
public abstract class BaseDataAbsSource implements BaseDataSource {
|
||||||
|
|
||||||
|
|
||||||
public void setQuery(BaseQuery baseQuery){
|
public void setQuery(BaseQuery baseQuery) {
|
||||||
BaseQueryHandler.set(baseQuery);
|
BaseQueryHandler.set(baseQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T getQuery(){
|
public <T> T getQuery() {
|
||||||
return BaseQueryHandler.get();
|
return BaseQueryHandler.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.muyu.access.data.base;
|
package com.muyu.access.data.base;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: DongZeLiang
|
* @Author: DongZeLiang
|
||||||
* @date: 2024/8/28
|
* @date: 2024/8/28
|
||||||
|
@ -9,11 +10,11 @@ public class BaseQueryHandler {
|
||||||
|
|
||||||
private static final ThreadLocal<BaseQuery> BASE_QUERY_THREAD_LOCAL = new ThreadLocal<>();
|
private static final ThreadLocal<BaseQuery> BASE_QUERY_THREAD_LOCAL = new ThreadLocal<>();
|
||||||
|
|
||||||
public static void set(BaseQuery baseQuery){
|
public static void set(BaseQuery baseQuery) {
|
||||||
BASE_QUERY_THREAD_LOCAL.set(baseQuery);
|
BASE_QUERY_THREAD_LOCAL.set(baseQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T get(){
|
public static <T> T get() {
|
||||||
return (T) BASE_QUERY_THREAD_LOCAL.get();
|
return (T) BASE_QUERY_THREAD_LOCAL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Map;
|
||||||
public class MySqlDataSource extends BaseDataAbsSource {
|
public class MySqlDataSource extends BaseDataAbsSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataValue getDataValue () {
|
public DataValue getDataValue() {
|
||||||
MySqlQuery query = getQuery();
|
MySqlQuery query = getQuery();
|
||||||
String dataSourceId = query.getDataSourceId();
|
String dataSourceId = query.getDataSourceId();
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
@ -32,7 +32,7 @@ public class MySqlDataSource extends BaseDataAbsSource {
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
||||||
ResultSet resultSet = preparedStatement.getResultSet();
|
ResultSet resultSet = preparedStatement.getResultSet();
|
||||||
if(resultSet.next()){
|
if (resultSet.next()) {
|
||||||
DataValue.builder()
|
DataValue.builder()
|
||||||
.key(resultSet.getCursorName())
|
.key(resultSet.getCursorName())
|
||||||
.label("")
|
.label("")
|
||||||
|
@ -47,12 +47,12 @@ public class MySqlDataSource extends BaseDataAbsSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataValue[] getRow () {
|
public DataValue[] getRow() {
|
||||||
return new DataValue[0];
|
return new DataValue[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataValue[][] getRows () {
|
public DataValue[][] getRows() {
|
||||||
return new DataValue[0][];
|
return new DataValue[0][];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,17 +12,17 @@ import com.muyu.access.data.base.DataValue;
|
||||||
*/
|
*/
|
||||||
public class RedisDataSource extends BaseDataAbsSource {
|
public class RedisDataSource extends BaseDataAbsSource {
|
||||||
@Override
|
@Override
|
||||||
public DataValue getDataValue () {
|
public DataValue getDataValue() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataValue[] getRow () {
|
public DataValue[] getRow() {
|
||||||
return new DataValue[0];
|
return new DataValue[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataValue[][] getRows () {
|
public DataValue[][] getRows() {
|
||||||
return new DataValue[0][];
|
return new DataValue[0][];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public interface BasicEngine<V> {
|
||||||
|
|
||||||
public V get();
|
public V get();
|
||||||
|
|
||||||
public default void remove(){
|
public default void remove() {
|
||||||
DataEngineHandler.remove();
|
DataEngineHandler.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@ import com.muyu.core.domain.DataValue;
|
||||||
|
|
||||||
public abstract class DataEngineRowActuator implements BasicEngine<DataValue[]> {
|
public abstract class DataEngineRowActuator implements BasicEngine<DataValue[]> {
|
||||||
|
|
||||||
public void set(DataValue[] dataValue){
|
public void set(DataValue[] dataValue) {
|
||||||
DataEngineRowHandler.set(dataValue);
|
DataEngineRowHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValue[] get(){
|
public DataValue[] get() {
|
||||||
return DataEngineRowHandler.get();
|
return DataEngineRowHandler.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,16 +12,16 @@ import com.muyu.core.domain.DataValue;
|
||||||
*/
|
*/
|
||||||
public abstract class DataEngineValueActuator implements BasicEngine<DataValue> {
|
public abstract class DataEngineValueActuator implements BasicEngine<DataValue> {
|
||||||
|
|
||||||
public void set(DataValue dataValue){
|
public void set(DataValue dataValue) {
|
||||||
DataEngineValueHandler.set(dataValue);
|
DataEngineValueHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataValue get(){
|
public DataValue get() {
|
||||||
return DataEngineValueHandler.get();
|
return DataEngineValueHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execution () {
|
public void execution() {
|
||||||
this.run();
|
this.run();
|
||||||
this.remove();
|
this.remove();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class DataEngineHandler {
|
||||||
return (T) dataEngineHandler.get();
|
return (T) dataEngineHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(){
|
public static void remove() {
|
||||||
dataEngineHandler.remove();
|
dataEngineHandler.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ import com.muyu.core.domain.DataValue;
|
||||||
*/
|
*/
|
||||||
public class DataEngineRowHandler {
|
public class DataEngineRowHandler {
|
||||||
|
|
||||||
public static void set(DataValue[] dataValue){
|
public static void set(DataValue[] dataValue) {
|
||||||
DataEngineHandler.set(dataValue);
|
DataEngineHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataValue[] get(){
|
public static DataValue[] get() {
|
||||||
return DataEngineHandler.get();
|
return DataEngineHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,23 +11,23 @@ import com.muyu.core.utils.Convert;
|
||||||
*/
|
*/
|
||||||
public class DataEngineValueHandler {
|
public class DataEngineValueHandler {
|
||||||
|
|
||||||
public static void set(DataValue dataValue){
|
public static void set(DataValue dataValue) {
|
||||||
DataEngineHandler.set(dataValue);
|
DataEngineHandler.set(dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataValue get(){
|
public static DataValue get() {
|
||||||
return DataEngineHandler.get();
|
return DataEngineHandler.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(){
|
public static void remove() {
|
||||||
DataEngineHandler.remove();
|
DataEngineHandler.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getValue(){
|
public static Object getValue() {
|
||||||
return get().getValue();
|
return get().getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getIntegerValue(){
|
public static Integer getIntegerValue() {
|
||||||
return Convert.toInt(getValue(), null);
|
return Convert.toInt(getValue(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public enum DataType {
|
||||||
private final Class<?> targetType;
|
private final Class<?> targetType;
|
||||||
|
|
||||||
|
|
||||||
DataType (String sourceType, Class<?> targetType) {
|
DataType(String sourceType, Class<?> targetType) {
|
||||||
this.sourceType = sourceType;
|
this.sourceType = sourceType;
|
||||||
this.targetType = targetType;
|
this.targetType = targetType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String toStr (Object value, String defaultValue) {
|
public static String toStr(Object value, String defaultValue) {
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -43,10 +42,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String toStr (Object value) {
|
public static String toStr(Object value) {
|
||||||
return toStr(value, null);
|
return toStr(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +55,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Character toChar (Object value, Character defaultValue) {
|
public static Character toChar(Object value, Character defaultValue) {
|
||||||
if (null == value) {
|
if (null == value) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -78,10 +75,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Character toChar (Object value) {
|
public static Character toChar(Object value) {
|
||||||
return toChar(value, null);
|
return toChar(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,10 +88,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Byte toByte (Object value, Byte defaultValue) {
|
public static Byte toByte(Object value, Byte defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -122,10 +117,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Byte toByte (Object value) {
|
public static Byte toByte(Object value) {
|
||||||
return toByte(value, null);
|
return toByte(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,10 +130,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Short toShort (Object value, Short defaultValue) {
|
public static Short toShort(Object value, Short defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -166,10 +159,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Short toShort (Object value) {
|
public static Short toShort(Object value) {
|
||||||
return toShort(value, null);
|
return toShort(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,10 +172,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Number toNumber (Object value, Number defaultValue) {
|
public static Number toNumber(Object value, Number defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -207,10 +198,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Number toNumber (Object value) {
|
public static Number toNumber(Object value) {
|
||||||
return toNumber(value, null);
|
return toNumber(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,10 +211,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Integer toInt (Object value, Integer defaultValue) {
|
public static Integer toInt(Object value, Integer defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -251,10 +240,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Integer toInt (Object value) {
|
public static Integer toInt(Object value) {
|
||||||
return toInt(value, null);
|
return toInt(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,10 +250,9 @@ public class Convert {
|
||||||
* 转换为Integer数组<br>
|
* 转换为Integer数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Integer[] toIntArray (String str) {
|
public static Integer[] toIntArray(String str) {
|
||||||
return toIntArray(",", str);
|
return toIntArray(",", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,10 +260,9 @@ public class Convert {
|
||||||
* 转换为Long数组<br>
|
* 转换为Long数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Long[] toLongArray (String str) {
|
public static Long[] toLongArray(String str) {
|
||||||
return toLongArray(",", str);
|
return toLongArray(",", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,16 +271,15 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Integer[] toIntArray (String split, String str) {
|
public static Integer[] toIntArray(String split, String str) {
|
||||||
if (StringUtils.isEmpty(str)) {
|
if (StringUtils.isEmpty(str)) {
|
||||||
return new Integer[]{};
|
return new Integer[]{};
|
||||||
}
|
}
|
||||||
String[] arr = str.split(split);
|
String[] arr = str.split(split);
|
||||||
final Integer[] ints = new Integer[arr.length];
|
final Integer[] ints = new Integer[arr.length];
|
||||||
for (int i = 0 ; i < arr.length ; i++) {
|
for (int i = 0; i < arr.length; i++) {
|
||||||
final Integer v = toInt(arr[i], 0);
|
final Integer v = toInt(arr[i], 0);
|
||||||
ints[i] = v;
|
ints[i] = v;
|
||||||
}
|
}
|
||||||
|
@ -306,16 +291,15 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Long[] toLongArray (String split, String str) {
|
public static Long[] toLongArray(String split, String str) {
|
||||||
if (StringUtils.isEmpty(str)) {
|
if (StringUtils.isEmpty(str)) {
|
||||||
return new Long[]{};
|
return new Long[]{};
|
||||||
}
|
}
|
||||||
String[] arr = str.split(split);
|
String[] arr = str.split(split);
|
||||||
final Long[] longs = new Long[arr.length];
|
final Long[] longs = new Long[arr.length];
|
||||||
for (int i = 0 ; i < arr.length ; i++) {
|
for (int i = 0; i < arr.length; i++) {
|
||||||
final Long v = toLong(arr[i], null);
|
final Long v = toLong(arr[i], null);
|
||||||
longs[i] = v;
|
longs[i] = v;
|
||||||
}
|
}
|
||||||
|
@ -326,10 +310,9 @@ public class Convert {
|
||||||
* 转换为String数组<br>
|
* 转换为String数组<br>
|
||||||
*
|
*
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String[] toStrArray (String str) {
|
public static String[] toStrArray(String str) {
|
||||||
return toStrArray(",", str);
|
return toStrArray(",", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,10 +321,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param split 分隔符
|
* @param split 分隔符
|
||||||
* @param str 被转换的值
|
* @param str 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static String[] toStrArray (String split, String str) {
|
public static String[] toStrArray(String split, String str) {
|
||||||
return str.split(split);
|
return str.split(split);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,10 +334,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Long toLong (Object value, Long defaultValue) {
|
public static Long toLong(Object value, Long defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -383,10 +364,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Long toLong (Object value) {
|
public static Long toLong(Object value) {
|
||||||
return toLong(value, null);
|
return toLong(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,10 +377,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Double toDouble (Object value, Double defaultValue) {
|
public static Double toDouble(Object value, Double defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -428,10 +407,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Double toDouble (Object value) {
|
public static Double toDouble(Object value) {
|
||||||
return toDouble(value, null);
|
return toDouble(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,10 +420,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Float toFloat (Object value, Float defaultValue) {
|
public static Float toFloat(Object value, Float defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -472,10 +449,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Float toFloat (Object value) {
|
public static Float toFloat(Object value) {
|
||||||
return toFloat(value, null);
|
return toFloat(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,10 +462,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Boolean toBool (Object value, Boolean defaultValue) {
|
public static Boolean toBool(Object value, Boolean defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -522,10 +497,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static Boolean toBool (Object value) {
|
public static Boolean toBool(Object value) {
|
||||||
return toBool(value, null);
|
return toBool(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -536,10 +510,9 @@ public class Convert {
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
* @param defaultValue 默认值
|
* @param defaultValue 默认值
|
||||||
*
|
|
||||||
* @return Enum
|
* @return Enum
|
||||||
*/
|
*/
|
||||||
public static <E extends Enum<E>> E toEnum (Class<E> clazz, Object value, E defaultValue) {
|
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -565,10 +538,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param clazz Enum的Class
|
* @param clazz Enum的Class
|
||||||
* @param value 值
|
* @param value 值
|
||||||
*
|
|
||||||
* @return Enum
|
* @return Enum
|
||||||
*/
|
*/
|
||||||
public static <E extends Enum<E>> E toEnum (Class<E> clazz, Object value) {
|
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||||
return toEnum(clazz, value, null);
|
return toEnum(clazz, value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,10 +551,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static BigInteger toBigInteger (Object value, BigInteger defaultValue) {
|
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -609,10 +580,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static BigInteger toBigInteger (Object value) {
|
public static BigInteger toBigInteger(Object value) {
|
||||||
return toBigInteger(value, null);
|
return toBigInteger(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -623,10 +593,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
* @param defaultValue 转换错误时的默认值
|
* @param defaultValue 转换错误时的默认值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static BigDecimal toBigDecimal (Object value, BigDecimal defaultValue) {
|
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -659,10 +628,9 @@ public class Convert {
|
||||||
* 转换失败不会报错
|
* 转换失败不会报错
|
||||||
*
|
*
|
||||||
* @param value 被转换的值
|
* @param value 被转换的值
|
||||||
*
|
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public static BigDecimal toBigDecimal (Object value) {
|
public static BigDecimal toBigDecimal(Object value) {
|
||||||
return toBigDecimal(value, null);
|
return toBigDecimal(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,10 +639,9 @@ public class Convert {
|
||||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String utf8Str (Object obj) {
|
public static String utf8Str(Object obj) {
|
||||||
return str(obj, "UTF-8");
|
return str(obj, "UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,10 +651,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charsetName 字符集
|
* @param charsetName 字符集
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (Object obj, String charsetName) {
|
public static String str(Object obj, String charsetName) {
|
||||||
return str(obj, Charset.forName(charsetName));
|
return str(obj, Charset.forName(charsetName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -697,10 +663,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param obj 对象
|
* @param obj 对象
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (Object obj, Charset charset) {
|
public static String str(Object obj, Charset charset) {
|
||||||
if (null == obj) {
|
if (null == obj) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -714,7 +679,7 @@ public class Convert {
|
||||||
Byte[] bytes = (Byte[]) obj;
|
Byte[] bytes = (Byte[]) obj;
|
||||||
int length = bytes.length;
|
int length = bytes.length;
|
||||||
byte[] dest = new byte[length];
|
byte[] dest = new byte[length];
|
||||||
for (int i = 0 ; i < length ; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
dest[i] = bytes[i];
|
dest[i] = bytes[i];
|
||||||
}
|
}
|
||||||
return str(dest, charset);
|
return str(dest, charset);
|
||||||
|
@ -730,10 +695,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param bytes byte数组
|
* @param bytes byte数组
|
||||||
* @param charset 字符集
|
* @param charset 字符集
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (byte[] bytes, String charset) {
|
public static String str(byte[] bytes, String charset) {
|
||||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,10 +706,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param data 字符串
|
* @param data 字符串
|
||||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||||
*
|
|
||||||
* @return 解码后的字符串
|
* @return 解码后的字符串
|
||||||
*/
|
*/
|
||||||
public static String str (byte[] data, Charset charset) {
|
public static String str(byte[] data, Charset charset) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -761,10 +724,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (ByteBuffer data, String charset) {
|
public static String str(ByteBuffer data, String charset) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -777,10 +739,9 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param data 数据
|
* @param data 数据
|
||||||
* @param charset 字符集,如果为空使用当前系统字符集
|
* @param charset 字符集,如果为空使用当前系统字符集
|
||||||
*
|
|
||||||
* @return 字符串
|
* @return 字符串
|
||||||
*/
|
*/
|
||||||
public static String str (ByteBuffer data, Charset charset) {
|
public static String str(ByteBuffer data, Charset charset) {
|
||||||
if (null == charset) {
|
if (null == charset) {
|
||||||
charset = Charset.defaultCharset();
|
charset = Charset.defaultCharset();
|
||||||
}
|
}
|
||||||
|
@ -793,10 +754,9 @@ public class Convert {
|
||||||
* 半角转全角
|
* 半角转全角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
*
|
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
*/
|
*/
|
||||||
public static String toSBC (String input) {
|
public static String toSBC(String input) {
|
||||||
return toSBC(input, null);
|
return toSBC(input, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,12 +765,11 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param input String
|
* @param input String
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
*
|
|
||||||
* @return 全角字符串.
|
* @return 全角字符串.
|
||||||
*/
|
*/
|
||||||
public static String toSBC (String input, Set<Character> notConvertSet) {
|
public static String toSBC(String input, Set<Character> notConvertSet) {
|
||||||
char[] c = input.toCharArray();
|
char[] c = input.toCharArray();
|
||||||
for (int i = 0 ; i < c.length ; i++) {
|
for (int i = 0; i < c.length; i++) {
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||||
// 跳过不替换的字符
|
// 跳过不替换的字符
|
||||||
continue;
|
continue;
|
||||||
|
@ -830,10 +789,9 @@ public class Convert {
|
||||||
* 全角转半角
|
* 全角转半角
|
||||||
*
|
*
|
||||||
* @param input String.
|
* @param input String.
|
||||||
*
|
|
||||||
* @return 半角字符串
|
* @return 半角字符串
|
||||||
*/
|
*/
|
||||||
public static String toDBC (String input) {
|
public static String toDBC(String input) {
|
||||||
return toDBC(input, null);
|
return toDBC(input, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,12 +800,11 @@ public class Convert {
|
||||||
*
|
*
|
||||||
* @param text 文本
|
* @param text 文本
|
||||||
* @param notConvertSet 不替换的字符集合
|
* @param notConvertSet 不替换的字符集合
|
||||||
*
|
|
||||||
* @return 替换后的字符
|
* @return 替换后的字符
|
||||||
*/
|
*/
|
||||||
public static String toDBC (String text, Set<Character> notConvertSet) {
|
public static String toDBC(String text, Set<Character> notConvertSet) {
|
||||||
char[] c = text.toCharArray();
|
char[] c = text.toCharArray();
|
||||||
for (int i = 0 ; i < c.length ; i++) {
|
for (int i = 0; i < c.length; i++) {
|
||||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||||
// 跳过不替换的字符
|
// 跳过不替换的字符
|
||||||
continue;
|
continue;
|
||||||
|
@ -866,10 +823,9 @@ public class Convert {
|
||||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||||
*
|
*
|
||||||
* @param n 数字
|
* @param n 数字
|
||||||
*
|
|
||||||
* @return 中文大写数字
|
* @return 中文大写数字
|
||||||
*/
|
*/
|
||||||
public static String digitUppercase (double n) {
|
public static String digitUppercase(double n) {
|
||||||
String[] fraction = {"角", "分"};
|
String[] fraction = {"角", "分"};
|
||||||
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
String[] digit = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"};
|
||||||
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
String[][] unit = {{"元", "万", "亿"}, {"", "拾", "佰", "仟"}};
|
||||||
|
@ -878,7 +834,7 @@ public class Convert {
|
||||||
n = Math.abs(n);
|
n = Math.abs(n);
|
||||||
|
|
||||||
String s = "";
|
String s = "";
|
||||||
for (int i = 0 ; i < fraction.length ; i++) {
|
for (int i = 0; i < fraction.length; i++) {
|
||||||
// 优化double计算精度丢失问题
|
// 优化double计算精度丢失问题
|
||||||
BigDecimal nNum = new BigDecimal(n);
|
BigDecimal nNum = new BigDecimal(n);
|
||||||
BigDecimal decimal = new BigDecimal(10);
|
BigDecimal decimal = new BigDecimal(10);
|
||||||
|
@ -891,9 +847,9 @@ public class Convert {
|
||||||
}
|
}
|
||||||
int integerPart = (int) Math.floor(n);
|
int integerPart = (int) Math.floor(n);
|
||||||
|
|
||||||
for (int i = 0 ; i < unit[0].length && integerPart > 0 ; i++) {
|
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
|
||||||
String p = "";
|
String p = "";
|
||||||
for (int j = 0 ; j < unit[1].length && n > 0 ; j++) {
|
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||||
integerPart = integerPart / 10;
|
integerPart = integerPart / 10;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* :qdm
|
* :qdm
|
||||||
|
*
|
||||||
* @Package:com.muyu.req
|
* @Package:com.muyu.req
|
||||||
* @Project:cloud-etl-engine
|
* @Project:cloud-etl-engine
|
||||||
* @name:EngineVersionListResp
|
* @name:EngineVersionListResp
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class EngineVersionController extends BaseController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/insertVersion")
|
@PostMapping("/insertVersion")
|
||||||
public boolean insertVersion(@RequestBody EngineVersion engineVersion) {
|
public boolean insertVersion(@RequestBody EngineVersion engineVersion) {
|
||||||
log.info("数据是:{}"+engineVersion.getRuleContent());
|
log.info("数据是:{}" + engineVersion.getRuleContent());
|
||||||
OssUpload.uploadFiles(engineVersion.getRuleContent(), engineVersion.getVersionCode());
|
OssUpload.uploadFiles(engineVersion.getRuleContent(), engineVersion.getVersionCode());
|
||||||
OSSFileDownload.streamingDownload(engineVersion.getName());
|
OSSFileDownload.streamingDownload(engineVersion.getName());
|
||||||
JavaClass.compile(engineVersion.getName());
|
JavaClass.compile(engineVersion.getName());
|
||||||
|
|
|
@ -64,13 +64,13 @@ public class SourceDataController extends BaseController {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@PostMapping("/selectDataBase")
|
@PostMapping("/selectDataBase")
|
||||||
public List<Datas> selectDataBase(){
|
public List<Datas> selectDataBase() {
|
||||||
List<Datas> dataSources = tableInfoService.selectDataBase();
|
List<Datas> dataSources = tableInfoService.selectDataBase();
|
||||||
return dataSources;
|
return dataSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/selectData")
|
@PostMapping("/selectData")
|
||||||
public List<SourceData> selectData(){
|
public List<SourceData> selectData() {
|
||||||
List<SourceData> dataSources = tableInfoService.selectData();
|
List<SourceData> dataSources = tableInfoService.selectData();
|
||||||
return dataSources;
|
return dataSources;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,42 +16,53 @@ import lombok.experimental.SuperBuilder;
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName(value ="table_info") //数据库表相关
|
@TableName(value = "table_info") //数据库表相关
|
||||||
public class TableInfo extends BaseEntity {
|
public class TableInfo extends BaseEntity {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
//数据源主键
|
//数据源主键
|
||||||
private Long basicId;
|
private Long basicId;
|
||||||
|
|
||||||
/** 表名称/数据库 */
|
/**
|
||||||
|
* 表名称/数据库
|
||||||
|
*/
|
||||||
@Excel(name = "表名称/数据库")
|
@Excel(name = "表名称/数据库")
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/** 表备注 */
|
/**
|
||||||
|
* 表备注
|
||||||
|
*/
|
||||||
@Excel(name = "表备注")
|
@Excel(name = "表备注")
|
||||||
private String tableRemark;
|
private String tableRemark;
|
||||||
|
|
||||||
/** 表的数据来源 */
|
/**
|
||||||
|
* 表的数据来源
|
||||||
|
*/
|
||||||
@Excel(name = "数据来源类型")
|
@Excel(name = "数据来源类型")
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/** 数据量 */
|
/**
|
||||||
|
* 数据量
|
||||||
|
*/
|
||||||
@Excel(name = "数据量")
|
@Excel(name = "数据量")
|
||||||
private Long dataNum;
|
private Long dataNum;
|
||||||
|
|
||||||
/** 是否核心 'Y'是 'N'不是 */
|
/**
|
||||||
|
* 是否核心 'Y'是 'N'不是
|
||||||
|
*/
|
||||||
@Excel(name = "是否核心 'Y'是 'N'不是")
|
@Excel(name = "是否核心 'Y'是 'N'不是")
|
||||||
private String center;
|
private String center;
|
||||||
|
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static TableInfoResp toTableInfoResp(TableInfo tableInfo) {
|
public static TableInfoResp toTableInfoResp(TableInfo tableInfo) {
|
||||||
return TableInfoResp.builder()
|
return TableInfoResp.builder()
|
||||||
.id(tableInfo.id)
|
.id(tableInfo.id)
|
||||||
|
|
|
@ -32,10 +32,14 @@ public class TableInfoResp {
|
||||||
*/
|
*/
|
||||||
private String tableRemark;
|
private String tableRemark;
|
||||||
|
|
||||||
/** 数据量 */
|
/**
|
||||||
|
* 数据量
|
||||||
|
*/
|
||||||
private Long dataNum;
|
private Long dataNum;
|
||||||
|
|
||||||
/** 是否核心 'Y'是 'N'不是 */
|
/**
|
||||||
|
* 是否核心 'Y'是 'N'不是
|
||||||
|
*/
|
||||||
private String isCenter;
|
private String isCenter;
|
||||||
|
|
||||||
//父级ID
|
//父级ID
|
||||||
|
|
|
@ -6,6 +6,7 @@ import javax.tools.*;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class JavaCompilerDemo {
|
public class JavaCompilerDemo {
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ public class JavaCompilerDemo {
|
||||||
|
|
||||||
// 执行编译
|
// 执行编译
|
||||||
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits);
|
JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits);
|
||||||
log.info("数据是:{}"+task);
|
log.info("数据是:{}" + task);
|
||||||
boolean success = task.call();
|
boolean success = task.call();
|
||||||
|
|
||||||
// 处理编译结果
|
// 处理编译结果
|
||||||
|
|
|
@ -30,14 +30,11 @@ public class JavaStringCompiler {
|
||||||
/**
|
/**
|
||||||
* Compile a Java source file in memory.
|
* Compile a Java source file in memory.
|
||||||
*
|
*
|
||||||
* @param fileName
|
* @param fileName Java file name, e.g. "Test.java"
|
||||||
* Java file name, e.g. "Test.java"
|
* @param source The source code as String.
|
||||||
* @param source
|
|
||||||
* The source code as String.
|
|
||||||
* @return The compiled results as Map that contains class name as key,
|
* @return The compiled results as Map that contains class name as key,
|
||||||
* class binary as value.
|
* class binary as value.
|
||||||
* @throws IOException
|
* @throws IOException If compile error.
|
||||||
* If compile error.
|
|
||||||
*/
|
*/
|
||||||
public Map<String, byte[]> compile(String fileName, String source) throws IOException {
|
public Map<String, byte[]> compile(String fileName, String source) throws IOException {
|
||||||
try (MemoryJavaFileManager manager = new MemoryJavaFileManager(stdManager)) {
|
try (MemoryJavaFileManager manager = new MemoryJavaFileManager(stdManager)) {
|
||||||
|
@ -54,15 +51,11 @@ public class JavaStringCompiler {
|
||||||
/**
|
/**
|
||||||
* Load class from compiled classes.
|
* Load class from compiled classes.
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name Full class name.
|
||||||
* Full class name.
|
* @param classBytes Compiled results as a Map.
|
||||||
* @param classBytes
|
|
||||||
* Compiled results as a Map.
|
|
||||||
* @return The Class instance.
|
* @return The Class instance.
|
||||||
* @throws ClassNotFoundException
|
* @throws ClassNotFoundException If class not found.
|
||||||
* If class not found.
|
* @throws IOException If load error.
|
||||||
* @throws IOException
|
|
||||||
* If load error.
|
|
||||||
*/
|
*/
|
||||||
public Class<?> loadClass(String name, Map<String, byte[]> classBytes) throws ClassNotFoundException, IOException {
|
public Class<?> loadClass(String name, Map<String, byte[]> classBytes) throws ClassNotFoundException, IOException {
|
||||||
try (DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(classBytes)) {
|
try (DynamicLoader.MemoryClassLoader classLoader = new DynamicLoader.MemoryClassLoader(classBytes)) {
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class OssDownload {
|
||||||
return Result.error("bucket不存在");
|
return Result.error("bucket不存在");
|
||||||
}
|
}
|
||||||
String objectName = fileName + ".java";
|
String objectName = fileName + ".java";
|
||||||
Boolean flag_file = ossClient.doesObjectExist(bucketName, filePath+objectName);
|
Boolean flag_file = ossClient.doesObjectExist(bucketName, filePath + objectName);
|
||||||
if (!flag_file) {
|
if (!flag_file) {
|
||||||
System.out.println("预下载文件不存在");
|
System.out.println("预下载文件不存在");
|
||||||
return Result.error("预下载文件不存在");
|
return Result.error("预下载文件不存在");
|
||||||
}
|
}
|
||||||
// 本地文件下载路径
|
// 本地文件下载路径
|
||||||
String localPath = "home/"+objectName;
|
String localPath = "home/" + objectName;
|
||||||
ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + objectName), new File(localPath));
|
ObjectMetadata object = ossClient.getObject(new GetObjectRequest(bucketName, filePath + objectName), new File(localPath));
|
||||||
System.out.println(object);
|
System.out.println(object);
|
||||||
ossClient.shutdown();
|
ossClient.shutdown();
|
||||||
|
|
|
@ -149,8 +149,7 @@ public class EngIneServiceImpl extends ServiceImpl<EngineMapper, EngineMaintenan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object measurementList(EngineVersion ruleEdition)
|
public Object measurementList(EngineVersion ruleEdition) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package com.muyu.service.serviceImpl;
|
package com.muyu.service.serviceImpl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.domain.Datas;
|
import com.muyu.domain.Datas;
|
||||||
import com.muyu.domain.SourceData;
|
import com.muyu.domain.SourceData;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import javax.tools.ToolProvider;
|
||||||
public class JavaClass {
|
public class JavaClass {
|
||||||
public static Result<Object> compile(String fileName) {
|
public static Result<Object> compile(String fileName) {
|
||||||
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
|
||||||
String[] strings = {"-classpath", "/home/lib", "-verbose", "-d", "/home", "/home/"+fileName+".java"};
|
String[] strings = {"-classpath", "/home/lib", "-verbose", "-d", "/home", "/home/" + fileName + ".java"};
|
||||||
int result = compiler.run(null, null, null, strings);
|
int result = compiler.run(null, null, null, strings);
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
System.out.println("编译成功,生成的.class文件位于源代码同目录");
|
System.out.println("编译成功,生成的.class文件位于源代码同目录");
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TestService {
|
||||||
OutputStream second = null; // 程序的输出 null 用 system.out
|
OutputStream second = null; // 程序的输出 null 用 system.out
|
||||||
OutputStream third = null; // 程序的错误输出 .,null 用 system.err
|
OutputStream third = null; // 程序的错误输出 .,null 用 system.err
|
||||||
// 程序编译参数 注意 我们编译目录是我们的项目目录
|
// 程序编译参数 注意 我们编译目录是我们的项目目录
|
||||||
String[] strings = {"-classpath", engineWorkSourcePath, "-verbose", "-d", engineWorkSourcePath, engineWorkSourcePath + engineVersion.getName()+".java"};
|
String[] strings = {"-classpath", engineWorkSourcePath, "-verbose", "-d", engineWorkSourcePath, engineWorkSourcePath + engineVersion.getName() + ".java"};
|
||||||
// 0 表示成功, 其他表示出现了错误
|
// 0 表示成功, 其他表示出现了错误
|
||||||
System.out.println(Arrays.toString(strings));
|
System.out.println(Arrays.toString(strings));
|
||||||
int i = javaCompiler.run(first, second, third, strings);
|
int i = javaCompiler.run(first, second, third, strings);
|
||||||
|
@ -87,7 +87,7 @@ public class TestService {
|
||||||
|
|
||||||
// 假设这是你的外部类文件路径
|
// 假设这是你的外部类文件路径
|
||||||
String externalClassFilePath =
|
String externalClassFilePath =
|
||||||
engineWorkSourcePath + "\\com\\muyu\\abstracts\\"+engineVersion.getName()+".class";
|
engineWorkSourcePath + "\\com\\muyu\\abstracts\\" + engineVersion.getName() + ".class";
|
||||||
Path classFilePath = Paths.get(externalClassFilePath);
|
Path classFilePath = Paths.get(externalClassFilePath);
|
||||||
// 获取外部类所在的目录
|
// 获取外部类所在的目录
|
||||||
String externalClassDir = externalClassFilePath.substring(0, externalClassFilePath.lastIndexOf('\\'));
|
String externalClassDir = externalClassFilePath.substring(0, externalClassFilePath.lastIndexOf('\\'));
|
||||||
|
|
Loading…
Reference in New Issue