|
@@ -122,14 +122,14 @@ public class GenSqlStringServiceImpl implements GenSqlStringService {
|
|
|
SqlColumnModel cm = aliasMap.get(dim.getTempFeildId());
|
|
|
|
|
|
colString += MessageFormat.format("{0} {1} AS {2}\n\t",
|
|
|
- getCommaString(fieldIndex), cm.getDisplayColumn(), getFieldName(fieldIndex));
|
|
|
+ getCommaString(fieldIndex), cm.getDisplayColumn(), getFieldName(dim.getDisOrder()));
|
|
|
groupString += MessageFormat.format("{0} {1}\n\t",getCommaString(fieldIndex), cm.getDisplayColumn());
|
|
|
cm.setMeasureColumn(cm.getDisplayColumn());
|
|
|
|
|
|
//生成字段-名称对照表
|
|
|
result.excelNameList.add(ExceNameModel.GenModel(
|
|
|
getFieldName(dim.getFieldName(), dim.getDisplayName()),
|
|
|
- getFieldName(fieldIndex)));
|
|
|
+ getFieldName(dim.getDisOrder())));
|
|
|
fieldIndex++;
|
|
|
}
|
|
|
|
|
@@ -141,13 +141,13 @@ public class GenSqlStringServiceImpl implements GenSqlStringService {
|
|
|
colString += MessageFormat.format("{0} {1} AS {2}\n\t",
|
|
|
getCommaString(fieldIndex),
|
|
|
getMeasurString(msr.getOperation(), cm.getDisplayColumn()),
|
|
|
- getFieldName(fieldIndex));
|
|
|
+ getFieldName(msr.getDisOrder()));
|
|
|
cm.setMeasureColumn(getMeasurString(msr.getOperation(), cm.getDisplayColumn()));
|
|
|
|
|
|
//生成字段-名称对照表
|
|
|
result.excelNameList.add(ExceNameModel.GenModel(
|
|
|
getFieldName(msr.getFieldName(), msr.getDisplayName()),
|
|
|
- getFieldName(fieldIndex)));
|
|
|
+ getFieldName(msr.getDisOrder())));
|
|
|
fieldIndex++;
|
|
|
}
|
|
|
|
|
@@ -177,11 +177,17 @@ public class GenSqlStringServiceImpl implements GenSqlStringService {
|
|
|
data.pagination.rows, (data.pagination.page-1) * data.pagination.rows);
|
|
|
|
|
|
|
|
|
- String mainSqlString = MessageFormat.format("SELECT {0} \nFROM {1} AS T {2} \nWHERE 1=1 {3} \nGROUP BY {4} \n{5} \n{6}",
|
|
|
+ //如有聚合则进行分组
|
|
|
+ if(data.measures.size()>0){
|
|
|
+ groupString = MessageFormat.format("\nGROUP BY {0}",groupString);
|
|
|
+ }else{
|
|
|
+ groupString="";
|
|
|
+ }
|
|
|
+ String mainSqlString = MessageFormat.format("SELECT {0} \nFROM {1} AS T {2} \nWHERE 1=1 {3} {4} \n{5} \n{6}",
|
|
|
colString, data.sub.getTabCode(), leftTableString, whereString, groupString, orderByString, limitString);
|
|
|
result.setMainSqlString(mainSqlString);
|
|
|
|
|
|
- String countSqlString = MessageFormat.format("SELECT COUNT(*) CNT FROM (SELECT {0} \nFROM {1} AS T {2} \nWHERE 1=1 {3} \nGROUP BY {4})",
|
|
|
+ String countSqlString = MessageFormat.format("SELECT COUNT(*) CNT FROM (SELECT {0} \nFROM {1} AS T {2} \nWHERE 1=1 {3} {4})",
|
|
|
colString, data.sub.getTabCode(), leftTableString, whereString, groupString);
|
|
|
result.setCountSqlStrimg(countSqlString);
|
|
|
|