commit
d298d8069b
@ -62,10 +62,7 @@ import io.dataease.service.datasource.DatasourceService;
|
||||
import io.dataease.service.engine.EngineService;
|
||||
import io.dataease.service.sys.SysAuthService;
|
||||
import lombok.Data;
|
||||
import net.sf.jsqlparser.expression.Alias;
|
||||
import net.sf.jsqlparser.expression.BinaryExpression;
|
||||
import net.sf.jsqlparser.expression.Expression;
|
||||
import net.sf.jsqlparser.expression.Parenthesis;
|
||||
import net.sf.jsqlparser.expression.*;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.AndExpression;
|
||||
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
|
||||
import net.sf.jsqlparser.expression.operators.relational.*;
|
||||
@ -1185,11 +1182,9 @@ public class DataSetTableService {
|
||||
binaryExpression = (BinaryExpression) expr;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (binaryExpression != null) {
|
||||
boolean hasSubBinaryExpression = binaryExpression instanceof AndExpression || binaryExpression instanceof OrExpression;
|
||||
|
||||
if (!hasSubBinaryExpression && !(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && hasVariable(binaryExpression.getRightExpression().toString())) {
|
||||
if (!hasSubBinaryExpression && !(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getLeftExpression() instanceof InExpression) && (hasVariable(binaryExpression.getLeftExpression().toString()) || hasVariable(binaryExpression.getRightExpression().toString()))) {
|
||||
stringBuilder.append(SubstitutedSql);
|
||||
} else {
|
||||
expr.accept(getExpressionDeParser(stringBuilder));
|
||||
@ -2380,8 +2375,6 @@ public class DataSetTableService {
|
||||
public List<ExcelSheetData> parseExcel(String filename, InputStream inputStream, boolean isPreview) throws Exception {
|
||||
List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
|
||||
String suffix = filename.substring(filename.lastIndexOf(".") + 1);
|
||||
excelSheetDataList = excelSheetDataList(inputStream, isPreview);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(suffix, "csv")) {
|
||||
List<TableField> fields = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||
@ -2423,6 +2416,8 @@ public class DataSetTableService {
|
||||
excelSheetData.setExcelLabel(filename);
|
||||
excelSheetData.setFieldsMd5(Md5Utils.md5(StringUtils.join(fieldArray, ",")));
|
||||
excelSheetDataList.add(excelSheetData);
|
||||
}else {
|
||||
excelSheetDataList = excelSheetDataList(inputStream, isPreview);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
@ -2833,28 +2828,43 @@ public class DataSetTableService {
|
||||
|
||||
private void visitBinaryExpr(BinaryExpression expr, String operator) {
|
||||
boolean hasSubBinaryExpression = false;
|
||||
if(expr.getLeftExpression() instanceof Parenthesis){
|
||||
Parenthesis parenthesis = (Parenthesis)expr.getLeftExpression();
|
||||
BinaryExpression leftBinaryExpression = (BinaryExpression)parenthesis.getExpression();
|
||||
hasSubBinaryExpression = leftBinaryExpression instanceof AndExpression || leftBinaryExpression instanceof OrExpression;
|
||||
}
|
||||
if(expr.getLeftExpression() instanceof BinaryExpression){
|
||||
try {
|
||||
BinaryExpression leftBinaryExpression = (BinaryExpression) expr.getLeftExpression();
|
||||
hasSubBinaryExpression = leftBinaryExpression instanceof AndExpression || leftBinaryExpression instanceof OrExpression;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (expr.getLeftExpression() instanceof BinaryExpression && !hasSubBinaryExpression && hasVariable(expr.getLeftExpression().toString())) {
|
||||
if ((expr.getLeftExpression() instanceof BinaryExpression || expr.getLeftExpression() instanceof Parenthesis) && !hasSubBinaryExpression && hasVariable(expr.getLeftExpression().toString())) {
|
||||
getBuffer().append(SubstitutedSql);
|
||||
} else {
|
||||
expr.getLeftExpression().accept(this);
|
||||
}
|
||||
|
||||
getBuffer().append(" " + operator + " ");
|
||||
|
||||
hasSubBinaryExpression = false;
|
||||
if(expr.getRightExpression() instanceof Parenthesis){
|
||||
Parenthesis parenthesis = (Parenthesis)expr.getRightExpression();
|
||||
BinaryExpression rightBinaryExpression = (BinaryExpression)parenthesis.getExpression();
|
||||
hasSubBinaryExpression = rightBinaryExpression instanceof AndExpression || rightBinaryExpression instanceof OrExpression;
|
||||
}
|
||||
if(expr.getRightExpression() instanceof BinaryExpression){
|
||||
try {
|
||||
BinaryExpression rightBinaryExpression = (BinaryExpression) expr.getRightExpression();
|
||||
hasSubBinaryExpression = rightBinaryExpression instanceof AndExpression || rightBinaryExpression instanceof OrExpression;
|
||||
;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (expr.getRightExpression() instanceof BinaryExpression && !hasSubBinaryExpression && hasVariable(expr.getRightExpression().toString())) {
|
||||
}
|
||||
|
||||
if ((expr.getRightExpression() instanceof Parenthesis || expr.getRightExpression() instanceof BinaryExpression || expr.getRightExpression() instanceof Function) && !hasSubBinaryExpression && hasVariable(expr.getRightExpression().toString())) {
|
||||
getBuffer().append(SubstitutedSql);
|
||||
} else {
|
||||
expr.getRightExpression().accept(this);
|
||||
|
||||
@ -757,8 +757,6 @@ public class ExtractDataService {
|
||||
for (ExcelSheetData excelSheetData : excelSheetDataList) {
|
||||
String suffix = excelSheetData.getPath().substring(excelSheetData.getPath().lastIndexOf(".") + 1);
|
||||
List<ExcelSheetData> totalSheets = new ArrayList<>();
|
||||
totalSheets = dataSetTableService.excelSheetDataList(new FileInputStream(excelSheetData.getPath()), false);
|
||||
|
||||
if (StringUtils.equalsIgnoreCase(suffix, "csv")) {
|
||||
List<TableField> fields = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(excelSheetData.getPath()), StandardCharsets.UTF_8));
|
||||
@ -796,6 +794,8 @@ public class ExtractDataService {
|
||||
csvSheetData.setExcelLabel(excelSheetData.getExcelLabel());
|
||||
csvSheetData.setFieldsMd5(Md5Utils.md5(StringUtils.join(fieldArray, ",")));
|
||||
totalSheets = Arrays.asList(csvSheetData);
|
||||
}else {
|
||||
totalSheets = dataSetTableService.excelSheetDataList(new FileInputStream(excelSheetData.getPath()), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user