Browse Source

1.个体
2.总体
3.筛选
4.修改部分bug

heqinwei 6 years ago
parent
commit
69bb3da0bb

+ 25 - 19
src/main/java/com/dao/ShowChartsMapper.java

@@ -30,10 +30,11 @@ public interface ShowChartsMapper {
     List<String> getGroups(@Param("groupsBy") String groupsBy, @Param("tableName") String tableName);
 
     //查询分组的值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and ${xColumn}=#{xColumnIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and ${xColumn}=#{xColumnIndex} ${screen}")
     String getGroupsValue(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                                @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex,
-                                @Param("xColumn") String xColumn, @Param("xColumnIndex") String xColumnIndex);
+                                @Param("xColumn") String xColumn, @Param("xColumnIndex") String xColumnIndex,
+                          @Param("screen") String screen);
 
 
     //时间类型的X轴
@@ -46,41 +47,45 @@ public interface ShowChartsMapper {
     List<String> getTimeYear(@Param("xAxisName") String xAxisName, @Param("tableName") String tableName);
     
     //无分组时间类型值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where (to_char(${xAxisName},${timeType})) = #{xColumnIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where (to_char(${xAxisName},${timeType})) = #{xColumnIndex} ${screen}")
     String getTimeValue (@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
-                         @Param("xAxisName") String xAxisName, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex);
+                         @Param("xAxisName") String xAxisName, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex,
+                         @Param("screen") String screen);
 
     //无分组半年时间值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} ${screen}")
     String getTimeValueYear(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
-                            @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex, @Param("afterIndex") String afterIndex);
+                            @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex,
+                            @Param("afterIndex") String afterIndex, @Param("screen") String screen);
 
 
     //查询时间类型分组的值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex} ${screen}")
     String getGroupsValueTime(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                           @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex,
-                          @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex);
+                          @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex,
+                              @Param("screen") String screen);
 
     //查询分组的值(时间类型半年)
     //分组半年时间值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex} ${screen}")
     String getTimeValueHalfYear(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex, @Param("afterIndex") String afterIndex,
-                                @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex);
+                                @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex, @Param("screen") String screen);
 
 
     /*
    个体表查询标准差
     */
-    @Select("select ${operation}(${columnName}) from ${tableName}")
-    Double getColumnDev(@Param("tableName") String tableName, @Param("columnName") String columnName, @Param("operation") String operation);
+    @Select("select ${operation}(${columnName}) from ${tableName} ${screen}")
+    Double getColumnDev(@Param("tableName") String tableName, @Param("columnName") String columnName,
+                        @Param("operation") String operation, @Param("screen") String screen);
 
     /*
     取主键名称
      */
     @Select("select column_name from user_cons_columns where table_name = #{tableName} and constraint_name = #{tableKey}")
-    String getTableKey(@Param("tableName") String tableName, @Param("tableKey") String tableKey);
+    String getTableKey(@Param("tableName") String tableName, @Param("tableKey") String tableKey, @Param("screen") String screen);
 
     /*
     取目标列的值
@@ -91,21 +96,22 @@ public interface ShowChartsMapper {
     /*
     获取其他类数据
      */
-    @Select("select ${columnList} from ${tableName} where ${keyName} = #{id} ")
-    Object getOtherData(@Param("columnList") String columnList, @Param("id") int id, @Param("tableName") String tableName, @Param("keyName") String keyName);
+    @Select("select ${columnList} from (select ${columnList} from ${tableName} order by ${columnName} ${sort}) where rownum<${line} ${screen}")
+    List<LinkedHashMap<String, Object>> getOtherData(@Param("columnList") String columnList, @Param("tableName") String tableName, @Param("columnName") String columnName,
+                                                     @Param("sort") String sort, @Param("line") String line, @Param("screen") String screen);
 
     /*
     总体统计求值
      */
-    @Select("select ${operation}(${columnName}) from ${tableName} where ${columnName} between #{first} and #{last}")
+    @Select("select ${operation}(${columnName}) from ${tableName} where ${columnName} between #{first} and #{last} ${screen}")
     Double getValue(@Param("tableName") String tableName, @Param("columnName") String columnName, @Param("operation") String operation, @Param("first") Double first,
-                    @Param("last") Double last);
+                    @Param("last") Double last, @Param("screen") String screen);
 
     /*
     总体分组的值
      */
-    @Select("select ${groupBy},${operation} from ${tableName} group by ${groupBy} order by ${groupByOne}")
+    @Select("select ${groupBy},${operation} from ${tableName} ${screen} group by ${groupBy} order by ${groupByOne}")
     List<LinkedHashMap<String, Object>> getGroupByValue(@Param("groupBy") String groupBy, @Param("operation") String operation, @Param("tableName") String tableName,
-                                                        @Param("groupByOne") String groupByOne);
+                                                        @Param("groupByOne") String groupByOne, @Param("screen") String screen);
 
 }

+ 12 - 22
src/main/java/com/model/vo/configVo/IndividualConfigInfo.java

@@ -1,5 +1,7 @@
 package com.model.vo.configVo;
 
+import com.model.bo.Screen;
+
 import java.util.List;
 
 /*
@@ -7,11 +9,11 @@ import java.util.List;
  */
 public class IndividualConfigInfo {
     private int id;
-    private String columnName;
+    private String sortColumn;
     private List<String> columnListName;
     private String sort;
     private int showLine;
-    private String operation;
+    private List<Screen> filters;
 
 
     public int getId() {
@@ -22,12 +24,12 @@ public class IndividualConfigInfo {
         this.id = id;
     }
 
-    public String getColumnName() {
-        return columnName;
+    public String getSortColumn() {
+        return sortColumn;
     }
 
-    public void setColumnName(String columnName) {
-        this.columnName = columnName;
+    public void setSortColumn(String sortColumn) {
+        this.sortColumn = sortColumn;
     }
 
     public List<String> getColumnListName() {
@@ -54,23 +56,11 @@ public class IndividualConfigInfo {
         this.showLine = showLine;
     }
 
-    public String getOperation() {
-        return operation;
-    }
-
-    public void setOperation(String operation) {
-        this.operation = operation;
+    public List<Screen> getFilters() {
+        return filters;
     }
 
-    @Override
-    public String toString() {
-        return "IndividualConfigInfo{" +
-                "id=" + id +
-                ", columnName='" + columnName + '\'' +
-                ", columnListName=" + columnListName +
-                ", sort='" + sort + '\'' +
-                ", showLine=" + showLine +
-                ", operation='" + operation + '\'' +
-                '}';
+    public void setFilters(List<Screen> filters) {
+        this.filters = filters;
     }
 }

+ 10 - 0
src/main/java/com/model/vo/configVo/LineConfigInfo.java

@@ -2,6 +2,7 @@ package com.model.vo.configVo;
 
 
 import com.model.bo.Column;
+import com.model.bo.Screen;
 
 import java.util.List;
 
@@ -10,6 +11,7 @@ public class LineConfigInfo {
     private Column xAxis;
     private Column yAxis;
     private List<String> groups;
+    private List<Screen> filters;
 
     public int getId() {
         return id;
@@ -43,6 +45,14 @@ public class LineConfigInfo {
         this.groups = groups;
     }
 
+    public List<Screen> getFilters() {
+        return filters;
+    }
+
+    public void setFilters(List<Screen> filters) {
+        this.filters = filters;
+    }
+
     @Override
     public String toString() {
         return "LineConfigInfo{" +

+ 12 - 0
src/main/java/com/model/vo/configVo/PieConfigInfo.java

@@ -2,11 +2,15 @@ package com.model.vo.configVo;
 
 
 import com.model.bo.Column;
+import com.model.bo.Screen;
+
+import java.util.List;
 
 public class PieConfigInfo {
     private int id;
     private Column legendData;
     private Column series;
+    private List<Screen> filters;
 
     public int getId() {
         return id;
@@ -32,6 +36,14 @@ public class PieConfigInfo {
         this.series = series;
     }
 
+    public List<Screen> getFilters() {
+        return filters;
+    }
+
+    public void setFilters(List<Screen> filters) {
+        this.filters = filters;
+    }
+
     @Override
     public String toString() {
         return "PieConfigInfo{" +

+ 11 - 0
src/main/java/com/model/vo/configVo/PopulationInfo.java

@@ -1,5 +1,7 @@
 package com.model.vo.configVo;
 
+import com.model.bo.Screen;
+
 import java.util.List;
 
 public class PopulationInfo {
@@ -7,6 +9,7 @@ public class PopulationInfo {
     private String columnName;
     private List<String> operatorList;
     private List<String> groupByList;
+    private List<Screen> filters;
 
     public int getId() {
         return id;
@@ -39,4 +42,12 @@ public class PopulationInfo {
     public void setGroupByList(List<String> groupByList) {
         this.groupByList = groupByList;
     }
+
+    public List<Screen> getFilters() {
+        return filters;
+    }
+
+    public void setFilters(List<Screen> filters) {
+        this.filters = filters;
+    }
 }

+ 10 - 0
src/main/java/com/model/vo/configVo/ScatterConfigInfo.java

@@ -2,6 +2,7 @@ package com.model.vo.configVo;
 
 
 import com.model.bo.Column;
+import com.model.bo.Screen;
 
 import java.util.List;
 
@@ -10,6 +11,7 @@ public class ScatterConfigInfo {
     private Column xAxis;
     private Column yAxis;
     private List<String> groups;
+    private List<Screen> filters;
 
     public int getId() {
         return id;
@@ -43,6 +45,14 @@ public class ScatterConfigInfo {
         this.groups = groups;
     }
 
+    public List<Screen> getFilters() {
+        return filters;
+    }
+
+    public void setFilters(List<Screen> filters) {
+        this.filters = filters;
+    }
+
     @Override
     public String toString() {
         return "LineConfigInfo{" +

+ 132 - 115
src/main/java/com/server/ShowHistogramService.java

@@ -14,6 +14,7 @@ import com.util.CalculationJudgeUtil;
 import com.util.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -39,6 +40,7 @@ public class ShowHistogramService {
     /*
     柱状图数据展示
      */
+    @Transactional
     public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         if (histogramConfigInfo == null || "".equals(histogramConfigInfo)){
@@ -55,141 +57,156 @@ public class ShowHistogramService {
         String baseName = getChartsDataUtilService.getBaseName(id);
         System.out.println("切换数据库"+baseName);
 
-        if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
-            //joinPoint.getSignature() :获取连接点的方法签名对象
-            System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
-        } else {
-            System.out.println("使用数据源:" + baseName);
-            DynamicDataSourceContextHolder.setDataSourceType(baseName);
-        }
-
-        String xColumn = histogramConfigInfo.getxAxis().getColumnRename();
-        String yColumn = histogramConfigInfo.getyAxis().getColumnRename();
-        String xColumnType = histogramConfigInfo.getxAxis().getColumnType();
+        try{
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
+                //joinPoint.getSignature() :获取连接点的方法签名对象
+                System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
+            } else {
+                System.out.println("使用数据源:" + baseName);
+                DynamicDataSourceContextHolder.setDataSourceType(baseName);
+            }
 
-        String xAxisType = histogramConfigInfo.getxAxis().getShowDataType();
-        List<String> groupBy = histogramConfigInfo.getGroups();
+            String xColumn = histogramConfigInfo.getxAxis().getColumnRename();
+            String yColumn = histogramConfigInfo.getyAxis().getColumnRename();
+            String xColumnType = histogramConfigInfo.getxAxis().getColumnType();
 
-        if (xColumn == null || "".equals(xColumn) || yColumn == null || "".equals(yColumn)){
-            return new RepEntity(RepCode.nullAxis);
-        }
+            String xAxisType = histogramConfigInfo.getxAxis().getShowDataType();
+            List<String> groupBy = histogramConfigInfo.getGroups();
 
-        String yType = histogramConfigInfo.getyAxis().getShowDataType();
-        String yAxisType = calculationJudgeUtil.Judge(yType);
+            if (xColumn == null || "".equals(xColumn) || yColumn == null || "".equals(yColumn)){
+                return new RepEntity(RepCode.nullAxis);
+            }
 
+            String yType = histogramConfigInfo.getyAxis().getShowDataType();
+            String yAxisType = calculationJudgeUtil.Judge(yType);
 
-        Series series = new Series();
-        List<Double> value = new ArrayList<Double>();
-        List<Series> serieses = new ArrayList<Series>();    //生成柱状图的系列
-        List<String> xAxisData = new ArrayList<String>();  //X轴自己用
-        List<String> xData = new ArrayList<String>();      //X轴前端用
 
-        //X轴
-        //判断是否为日期类型
-        if ("time".equals(xColumnType)){
-            xAxisData = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType);
-            xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
-            System.out.println("data:"+xAxisData);
-        }else {
-            xAxisData = showChartsMapper.getXAxis(xColumn, tableName);
+            Series series = new Series();
+            List<Double> value = new ArrayList<Double>();
+            List<Series> serieses = new ArrayList<Series>();    //生成柱状图的系列
+            List<String> xAxisData = new ArrayList<String>();  //X轴自己用
+            List<String> xData = new ArrayList<String>();      //X轴前端用
 
-        }
-        if ("".equals(xAxisData) || xAxisData == null || xAxisData.size() == 0){
-            return new RepEntity(RepCode.Null);
-        }
-        if ("week".equals(xAxisType) || "month".equals(xAxisType) || "quarter".equals(xAxisType)){
-            chartsDataInfo.setxAxis(xData);
-        }else {
-            chartsDataInfo.setxAxis(xAxisData);
-        }
+            //X轴
+            //判断是否为日期类型
+            if ("time".equals(xColumnType)){
+                xAxisData = timeConverterUtil.timeConverter(xColumn, tableName, xAxisType);
+                xData = timeConverterUtil.toRespons(xAxisData,xAxisType );
+                System.out.println("data:"+xAxisData);
+            }else {
+                xAxisData = showChartsMapper.getXAxis(xColumn, tableName);
 
+            }
+            if ("".equals(xAxisData) || xAxisData == null || xAxisData.size() == 0){
+                return new RepEntity(RepCode.Null);
+            }
+            if ("week".equals(xAxisType) || "month".equals(xAxisType) || "quarter".equals(xAxisType)){
+                chartsDataInfo.setxAxis(xData);
+            }else {
+                chartsDataInfo.setxAxis(xAxisData);
+            }
 
-        //取筛选列表
-        List<Screen> screens = histogramConfigInfo.getFilters();
-        String screen = "";
-        if ("".equals(screens) || screens == null){
-            screen = "";
-        }else {
-            screen = screenUtil.screensUtil(screens);
-        }
 
-        //无分组时Y值
-        Iterator itX = xAxisData.iterator();
-        while (itX.hasNext()){
-            String xdata = (String)itX.next();
-            double valueOne = 0;
-            String valueOnes = null;
-            if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+            //取筛选列表
+            List<Screen> screens = histogramConfigInfo.getFilters();
+            String screen = "";
+            if ("".equals(screens) || screens == null){
+                screen = "";
             }else {
-                valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screen);
+                screen = screenUtil.screensUtil(screens);
             }
-            if (valueOnes == null || "".equals(valueOnes)){
-                valueOne = 0;
-            }else {
-                valueOne = Double.parseDouble(valueOnes);
+
+            //无分组时Y值
+            Iterator itX = xAxisData.iterator();
+            while (itX.hasNext()){
+                String xdata = (String)itX.next();
+                if (xdata == null || "".equals(xdata)){
+                    continue;
+                }
+                double valueOne = 0;
+                String valueOnes = null;
+                if ("time".equals(xColumnType)){
+                    valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
+                }else {
+                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screen);
+                }
+                if (valueOnes == null || "".equals(valueOnes)){
+                    valueOne = 0;
+                }else {
+                    valueOne = Double.parseDouble(valueOnes);
+                }
+                value.add(valueOne);
             }
-            value.add(valueOne);
-        }
 
-        System.out.println(value);
-        series.setName(xColumn);
-        series.setValue(value);
-        serieses.add(series);
-        System.out.println(serieses);
-
-        //有分组
-        if (groupBy.size() != 0){
-            serieses.remove(0);
-            Iterator itGroup = groupBy.iterator();  //分组数
-
-            //便利分组
-            while (itGroup.hasNext()){
-               String groupByName = (String) itGroup.next(); //每个分组的组名
-                List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName); //查询每个分组系列
-                System.out.println("groupdata:"+ groupsData.toString());
-                Iterator itGroupsData = groupsData.iterator();
-
-                //每个分组得到得每个系列
-                while(itGroupsData.hasNext()){
-                    Series ne = new Series();
-                    String groupsName = (String)itGroupsData.next();
-                    ne.setName(groupsName);
-                    ne.setStack(groupByName);
-
-                    List<Double> groupsValue = new ArrayList<Double>();
-                    Iterator itXAxisData = xAxisData.iterator();
-
-                    //每个系列对应X轴上的值
-                    while (itXAxisData.hasNext()){
-                        String xAxisDataOne = (String) itXAxisData.next();
-                        double groupsValueOne = 0;
-                        String groupsValueOnes = null;
-                        if ("time".equals(xColumnType)){
-                            groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                    groupsName, xColumn, xAxisDataOne);
-                        }else {
-                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne);
+            System.out.println(value);
+            series.setName(xColumn);
+            series.setValue(value);
+            serieses.add(series);
+            System.out.println(serieses);
+
+            //有分组
+            if (groupBy.size() != 0){
+                serieses.remove(0);
+                Iterator itGroup = groupBy.iterator();  //分组数
+
+                //便利分组
+                while (itGroup.hasNext()){
+                    String groupByName = (String) itGroup.next(); //每个分组的组名
+                    List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName); //查询每个分组系列
+                    System.out.println("groupdata:"+ groupsData.toString());
+                    Iterator itGroupsData = groupsData.iterator();
+
+                    //每个分组得到得每个系列
+                    while(itGroupsData.hasNext()){
+                        Series ne = new Series();
+                        String groupsName = (String)itGroupsData.next();
+                        if (groupsName == null || "".equals(groupsName)){
+                            continue;
                         }
-                        if ("".equals(groupsValueOnes) || groupsValueOnes == null){
-                            groupsValueOne = 0;
-                        }else{
-                            groupsValueOne = Double.parseDouble(groupsValueOnes);
+                        ne.setName(groupsName);
+                        ne.setStack(groupByName);
+
+                        List<Double> groupsValue = new ArrayList<Double>();
+                        Iterator itXAxisData = xAxisData.iterator();
+
+                        //每个系列对应X轴上的值
+                        while (itXAxisData.hasNext()){
+                            String xAxisDataOne = (String) itXAxisData.next();
+                            if (xAxisDataOne == null || "".equals(xAxisDataOne)){
+                                continue;
+                            }
+                            double groupsValueOne = 0;
+                            String groupsValueOnes = null;
+                            if ("time".equals(xColumnType)){
+                                groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
+                                        groupsName, xColumn, xAxisDataOne, screen);
+                            }else {
+                                groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne, screen);
+                            }
+                            if ("".equals(groupsValueOnes) || groupsValueOnes == null){
+                                groupsValueOne = 0;
+                            }else{
+                                groupsValueOne = Double.parseDouble(groupsValueOnes);
+                            }
+                            groupsValue.add(groupsValueOne);
                         }
-                        groupsValue.add(groupsValueOne);
-                    }
 
-                    ne.setValue(groupsValue);
-                    System.out.println("值:"+ series);
-                    serieses.add(ne);
+                        ne.setValue(groupsValue);
+                        System.out.println("值:"+ series);
+                        serieses.add(ne);
+                    }
+                    System.out.println(serieses);
                 }
-                System.out.println(serieses);
             }
-        }
-
-        chartsDataInfo.setSerieses(serieses);
 
-        DynamicDataSourceContextHolder.clearDataSourceType();
+            chartsDataInfo.setSerieses(serieses);
+        }catch (Exception e){
+            e.printStackTrace();
+            System.out.println("异常");
+            return new RepEntity(RepCode.erro);
+        }finally {
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
 
         return new RepEntity(RepCode.success, chartsDataInfo);
     }

+ 112 - 65
src/main/java/com/server/ShowIndividualService.java

@@ -2,16 +2,17 @@ package com.server;
 
 import com.dao.ChartsConfigMapper;
 import com.dao.ShowChartsMapper;
-import com.model.po.TargetData;
+import com.model.bo.Screen;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.IndividualConfigInfo;
-import com.model.vo.dataVo.TableDataInfo;
+import com.util.BasesSource.DynamicDataSourceContextHolder;
+import com.util.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 
 /*
@@ -22,88 +23,134 @@ public class ShowIndividualService {
     @Autowired
     ChartsConfigMapper chartsConfigMapper;
     @Autowired
+    GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
     ShowChartsMapper showChartsMapper;
+    @Autowired
+    ScreenUtil screenUtil;
+
     public RepEntity showIndividual(IndividualConfigInfo individualConfigInfo){
         if (individualConfigInfo == null || "".equals(individualConfigInfo)){
             return new RepEntity(RepCode.Null);
         }
+
+        List<LinkedHashMap<String, Object>> targetValue = new ArrayList<>();
         //取表名
         int id = individualConfigInfo.getId();
-        String tableName = chartsConfigMapper.getTableName(id).toUpperCase();
+        String tableName = chartsConfigMapper.getTableName(id);
 //        String tableName = "bench_flowchart".toUpperCase();
         if (tableName == null || "".equals(tableName)){
             return new RepEntity(RepCode.nullTableName);
         }
 
-        //取主建名
-        String tableKey = tableName + "_PK";
-        String keyName = showChartsMapper.getTableKey(tableName, tableKey);
-
+        String baseName = getChartsDataUtilService.getBaseName(id);
+        System.out.println("切换数据库"+baseName);
 
-        Double columnDev = null;                    //标准差
-        Double columnAvg = null;                    //平均值
-        String columnName = individualConfigInfo.getColumnName();
-        System.out.println("columnName:"+columnName);
-        String operation = individualConfigInfo.getOperation();
-        String line = String.valueOf(individualConfigInfo.getShowLine() + 1);
-        String sort = individualConfigInfo.getSort();
-
-        if ("STDDEV".equals(operation) || "stddev".equals(operation)){
-            operation = "STDDEV";
-            columnDev = showChartsMapper.getColumnDev(tableName, columnName, operation);  //标准差
-            operation = "AVG";
-            columnAvg = showChartsMapper.getColumnDev(tableName, columnName, operation);  //平均值
+        try{
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
+                //joinPoint.getSignature() :获取连接点的方法签名对象
+                System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
+            } else {
+                System.out.println("使用数据源:" + baseName);
+                DynamicDataSourceContextHolder.setDataSourceType(baseName);
+            }
 
-        }else {
-            columnDev = null;
-            columnAvg = null;
-        }
-        List<TargetData> targetDataList = showChartsMapper.getTargetData(keyName, columnName, tableName, sort, line);
-        List<Integer> idList = new ArrayList<>();
-        List<Double> dataList = new ArrayList<>();
-        Iterator isDataList = targetDataList.iterator();
-        while (isDataList.hasNext()){
-            TargetData targetData = (TargetData) isDataList.next();
-            idList.add(targetData.getId());
-            //算出目标列的值
-            if (columnDev == null || "".equals(columnDev)){
-                dataList.add(targetData.getData());
+        //取主建名
+//        String tableKey = tableName + "_PK";
+//        String keyName = showChartsMapper.getTableKey(tableName, tableKey);
+//
+//
+            //取筛选列表
+            List<Screen> screens = individualConfigInfo.getFilters();
+            String screen = "";
+            if ("".equals(screens) || screens == null){
+                screen = "";
             }else {
-                dataList.add((targetData.getData()-columnAvg)/columnDev);
+                screen = screenUtil.screensUtil(screens);
             }
-        }
-
+        String columnName = individualConfigInfo.getSortColumn();
+        System.out.println("columnName:"+columnName);
         //查询其他列
-        List<String>  columnListName = individualConfigInfo.getColumnListName(); //列名
-
-
-        List<List<Object>> columnAllData = new ArrayList<>();//全部结果
-
-        Iterator isIdList = idList.iterator();
-
-        while (isIdList.hasNext()){
-            int ids = (int) isIdList.next();
-            List<Object> columnDataList = new ArrayList<>();//其他类一行结果集
-            Iterator isColumnName = columnListName.iterator();
-            while (isColumnName.hasNext()){
-                String columnOtherName = (String) isColumnName.next();
-                Object data = new Object();
-                data = showChartsMapper.getOtherData(columnOtherName, ids, tableName, keyName);
-                columnDataList.add(data);
-                System.out.println("单个:"+columnDataList);
-            }
-            columnAllData.add(columnDataList);
-            System.out.println("全部:"+columnAllData);
-            System.out.println();
-        }
+        String columnListName = individualConfigInfo.getColumnListName().toString();
+        String line = String.valueOf(individualConfigInfo.getShowLine() + 1);
+        String sort = individualConfigInfo.getSort();
 
-        System.out.println("------------------------------------------------------------------------------------------------------"+columnAllData);
+        String tableListName = this.getString(columnListName);
 
-        TableDataInfo tableDataInfo = new TableDataInfo();
-        tableDataInfo.setTargetData(dataList);
-        tableDataInfo.setColumnData(columnAllData);
+        targetValue = showChartsMapper.getOtherData(tableListName, tableName, columnName, sort, line, screen);
+    }catch (Exception e){
+        e.printStackTrace();
+        System.out.println("异常");
+        return new RepEntity(RepCode.erro);
+    }finally {
+        DynamicDataSourceContextHolder.clearDataSourceType();
+    }
+//
+//        if ("STDDEV".equals(operation) || "stddev".equals(operation)){
+//            operation = "STDDEV";
+//            columnDev = showChartsMapper.getColumnDev(tableName, columnName, operation);  //标准差
+//            operation = "AVG";
+//            columnAvg = showChartsMapper.getColumnDev(tableName, columnName, operation);  //平均值
+//
+//        }else {
+//            columnDev = null;
+//            columnAvg = null;
+//        }
+//        List<TargetData> targetDataList = showChartsMapper.getTargetData(keyName, columnName, tableName, sort, line);
+//        List<Integer> idList = new ArrayList<>();
+//        List<Double> dataList = new ArrayList<>();
+//        Iterator isDataList = targetDataList.iterator();
+//        while (isDataList.hasNext()){
+//            TargetData targetData = (TargetData) isDataList.next();
+//            idList.add(targetData.getId());
+//            //算出目标列的值
+//            if (columnDev == null || "".equals(columnDev)){
+//                dataList.add(targetData.getData());
+//            }else {
+//                dataList.add((targetData.getData()-columnAvg)/columnDev);
+//            }
+//        }
+//
+//
+//
+//
+//        List<List<Object>> columnAllData = new ArrayList<>();//全部结果
+//
+//        Iterator isIdList = idList.iterator();
+//
+//        while (isIdList.hasNext()){
+//            int ids = (int) isIdList.next();
+//            List<Object> columnDataList = new ArrayList<>();//其他类一行结果集
+//            Iterator isColumnName = columnListName.iterator();
+//            while (isColumnName.hasNext()){
+//                String columnOtherName = (String) isColumnName.next();
+//                Object data = new Object();
+//                data = showChartsMapper.getOtherData(columnOtherName, ids, tableName, keyName);
+//                columnDataList.add(data);
+//                System.out.println("单个:"+columnDataList);
+//            }
+//            columnAllData.add(columnDataList);
+//            System.out.println("全部:"+columnAllData);
+//            System.out.println();
+//        }
+//
+//        System.out.println("------------------------------------------------------------------------------------------------------"+columnAllData);
+//
+//        TableDataInfo tableDataInfo = new TableDataInfo();
+//        tableDataInfo.setTargetData(dataList);
+//        tableDataInfo.setColumnData(columnAllData);
+
+
+        return new RepEntity(RepCode.success, targetValue);
+    }
 
 
-        return new RepEntity(RepCode.success, tableDataInfo);
+    private String getString(String str){
+        String st1 = "[";
+        String st2 = "]";
+        String strA = str.replace(st1, "");
+        String StrB = strA.replace(st2, "");
+        System.out.println("str:"+ StrB);
+        return StrB;
     }
 }

+ 35 - 2
src/main/java/com/server/ShowLineService.java

@@ -4,11 +4,14 @@ import com.dao.ChartsConfigMapper;
 import com.dao.ShowChartsMapper;
 import com.model.bo.LineSeries;
 import com.model.bo.LineSeriesMap;
+import com.model.bo.Screen;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.LineConfigInfo;
 import com.model.vo.dataVo.ChartsDataInfo;
+import com.util.BasesSource.DynamicDataSourceContextHolder;
 import com.util.CalculationJudgeUtil;
+import com.util.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,6 +29,10 @@ public class ShowLineService {
     CalculationJudgeUtil calculationJudgeUtil;
     @Autowired
     ChartsConfigMapper chartsConfigMapper;
+    @Autowired
+    GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
+    ScreenUtil screenUtil;
 
     /*
     Line数据展示
@@ -38,6 +45,18 @@ public class ShowLineService {
         int id = lineConfigInfo.getId();
         String tableName = chartsConfigMapper.getTableName(id);
 
+        String baseName = getChartsDataUtilService.getBaseName(id);
+        System.out.println("切换数据库"+baseName);
+
+        try{
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
+                //joinPoint.getSignature() :获取连接点的方法签名对象
+                System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
+            } else {
+                System.out.println("使用数据源:" + baseName);
+                DynamicDataSourceContextHolder.setDataSourceType(baseName);
+            }
+
         String xColumn = lineConfigInfo.getxAxis().getColumnRename();
         String yColumn = lineConfigInfo.getyAxis().getColumnRename();
 
@@ -68,6 +87,13 @@ public class ShowLineService {
             return new RepEntity(RepCode.Null);
         }
 
+            List<Screen> screens = lineConfigInfo.getFilters();
+            String screen = "";
+            if ("".equals(screens) || screens == null){
+                screen = "";
+            }else {
+                screen = screenUtil.screensUtil(screens);
+            }
         //无分组时Y值
         Iterator itX = xAxisData.iterator();
         while (itX.hasNext()){
@@ -75,7 +101,7 @@ public class ShowLineService {
             double valueOne = 0;
             String valueOnes = null;
 //                System.out.println("Y:"+ yColumn + "........x:" + xColumn + "........yAxistype:" + yAxisType + "...xtpye:+"+yAxisType+ "   xdata:"+xdata);
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
 //                System.out.println("value:"+valueOnes);
             if (valueOnes == null || "".equals(valueOnes)){
                 valueOne = 0;
@@ -119,7 +145,7 @@ public class ShowLineService {
                         double groupsValueOne = 0;
                         String groupsValueOnes = null;
                         groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                    groupsName, xColumn, xAxisDataOne);
+                                    groupsName, xColumn, xAxisDataOne, screen);
                         if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             groupsValueOne = 0;
                         }else{
@@ -141,6 +167,13 @@ public class ShowLineService {
         }
 
         chartsDataInfo.setSerieses(serieses);
+        }catch (Exception e){
+            e.printStackTrace();
+            System.out.println("异常");
+            return new RepEntity(RepCode.erro);
+        }finally {
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
 
         return new RepEntity(RepCode.success, chartsDataInfo);
     }

+ 12 - 3
src/main/java/com/server/ShowPieService.java

@@ -4,6 +4,7 @@ import com.dao.ChartsConfigMapper;
 import com.dao.ShowChartsMapper;
 import com.model.bo.PieSeries;
 import com.model.bo.PieSeriesMap;
+import com.model.bo.Screen;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.PieConfigInfo;
@@ -79,6 +80,15 @@ public class ShowPieService {
             chartsDataInfo.setxAxis(xAxisData);
         }
 
+        //取筛选列表
+        List<Screen> screens = pieConfigInfo.getFilters();
+        String screen = "";
+        if ("".equals(screens) || screens == null){
+            screen = "";
+        }else {
+            screen = screenUtil.screensUtil(screens);
+        }
+
         //无分组时Y值
         Iterator itX = xAxisData.iterator();
         while (itX.hasNext()){
@@ -87,10 +97,9 @@ public class ShowPieService {
             String valueOnes = null;
             PieSeriesMap pieSeriesMap = new PieSeriesMap();
             if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
             }else {
-                String p = "";
-                valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, p);
+                valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screen);
             }
             if (valueOnes == null || "".equals(valueOnes)){
                 valueOne = 0;

+ 49 - 13
src/main/java/com/server/ShowPopulationService.java

@@ -2,9 +2,12 @@ package com.server;
 
 import com.dao.ChartsConfigMapper;
 import com.dao.ShowChartsMapper;
+import com.model.bo.Screen;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.PopulationInfo;
+import com.util.BasesSource.DynamicDataSourceContextHolder;
+import com.util.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,6 +20,10 @@ public class ShowPopulationService {
     ChartsConfigMapper chartsConfigMapper;
     @Autowired
     ShowChartsMapper showChartsMapper;
+    @Autowired
+    GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
+    ScreenUtil screenUtil;
 
     public RepEntity showPopulation(PopulationInfo populationInfo) throws SQLException {
         if (populationInfo == null || "".equals(populationInfo)){
@@ -30,13 +37,35 @@ public class ShowPopulationService {
             return new RepEntity(RepCode.nullTableName);
         }
 
-        List<String> groupByList = populationInfo.getGroupByList();  //分组
+        String baseName = getChartsDataUtilService.getBaseName(id);
+        System.out.println("切换数据库"+baseName);
+
+        try{
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
+                //joinPoint.getSignature() :获取连接点的方法签名对象
+                System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
+            } else {
+                System.out.println("使用数据源:" + baseName);
+                DynamicDataSourceContextHolder.setDataSourceType(baseName);
+            }
+            List<String> groupByList = populationInfo.getGroupByList();  //分组
 
         //取目标列和分析运算符
-        String columnName = populationInfo.getColumnName();
-        List<String> operators = populationInfo.getOperatorList();
-        Map<String, Double> targetData = new HashMap<>();  //存放结果集
-        Double value = null;                 //MAP的值
+            String columnName = populationInfo.getColumnName();
+            List<String> operators = populationInfo.getOperatorList();
+            Map<String, Double> targetData = new HashMap<>();  //存放结果集
+            Double value = null;                 //MAP的值
+
+            //取筛选列表
+            List<Screen> screens = populationInfo.getFilters();
+            String screen = "";
+            String screenStr = "";
+            if ("".equals(screens) || screens == null){
+                screen = "";
+            }else {
+                screen = screenUtil.screensUtil(screens);
+                screenStr = screen.replace("and", "where");
+            }
 
         //无分组
         if (groupByList.size() == 0) {
@@ -45,20 +74,20 @@ public class ShowPopulationService {
                 String operator = String.valueOf(operatorsList.next()).toUpperCase();
                 if ("75th".equals(operator)) {
                     String calculation = "MEDIAN";
-                    Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation);
+                    Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
                     calculation = "MAX";
-                    Double max = showChartsMapper.getColumnDev(tableName, columnName, calculation);
-                    value = showChartsMapper.getValue(tableName, columnName, calculation, median, max);
+                    Double max = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
+                    value = showChartsMapper.getValue(tableName, columnName, calculation, median, max, screenStr);
                 } else if ("25th".equals(operator)) {
                     String calculation = "MEDIAN";
-                    Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation);
+                    Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation, screen);
                     calculation = "MIN";
-                    Double min = showChartsMapper.getColumnDev(tableName, columnName, calculation);
-                    value = showChartsMapper.getValue(tableName, columnName, calculation, min, median);
+                    Double min = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
+                    value = showChartsMapper.getValue(tableName, columnName, calculation, min, median, screen);
                 } else if ("percentage".equals(operator)) {
                     value = 1.00;
                 } else {
-                    value = showChartsMapper.getColumnDev(tableName, columnName, operator);
+                    value = showChartsMapper.getColumnDev(tableName, columnName, operator, screenStr);
                 }
                 targetData.put(operator, value);
             }
@@ -91,13 +120,20 @@ public class ShowPopulationService {
 
 
             List<LinkedHashMap<String, Object>> valueList = new ArrayList<>();
-            valueList = showChartsMapper.getGroupByValue(groupBy, opr, tableName, listOne);
+            valueList = showChartsMapper.getGroupByValue(groupBy, opr, tableName, listOne, screenStr);
             System.out.println("valueList:"+ valueList);
 //            PopulationDataInfo populationDataInfo = new PopulationDataInfo();
 //            populationDataInfo.setColumnHead(groupByList);
 //            populationDataInfo.setValueList(valueList);
             return new RepEntity(RepCode.success, valueList);
         }
+        }catch (Exception e){
+            e.printStackTrace();
+            System.out.println("异常");
+            return new RepEntity(RepCode.erro);
+        }finally {
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
     }
 
     public String getString(String str){

+ 42 - 3
src/main/java/com/server/ShowScatterService.java

@@ -4,11 +4,14 @@ import com.dao.ChartsConfigMapper;
 import com.dao.ShowChartsMapper;
 import com.model.bo.LineSeries;
 import com.model.bo.LineSeriesMap;
+import com.model.bo.Screen;
 import com.model.pojo.RepCode;
 import com.model.pojo.RepEntity;
 import com.model.vo.configVo.ScatterConfigInfo;
 import com.model.vo.dataVo.ChartsDataInfo;
+import com.util.BasesSource.DynamicDataSourceContextHolder;
 import com.util.CalculationJudgeUtil;
+import com.util.ScreenUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -26,6 +29,10 @@ public class ShowScatterService {
     CalculationJudgeUtil calculationJudgeUtil;
     @Autowired
     ChartsConfigMapper chartsConfigMapper;
+    @Autowired
+    GetChartsDataUtilService getChartsDataUtilService;
+    @Autowired
+    ScreenUtil screenUtil;
 
     /*
     Line数据展示
@@ -38,6 +45,18 @@ public class ShowScatterService {
         int id = scatterConfigInfo.getId();
         String tableName = chartsConfigMapper.getTableName(id);
 
+        String baseName = getChartsDataUtilService.getBaseName(id);
+        System.out.println("切换数据库"+baseName);
+
+        try{
+            if (!DynamicDataSourceContextHolder.isContainsDataSource(baseName)) {
+                //joinPoint.getSignature() :获取连接点的方法签名对象
+                System.out.println("数据源 " + baseName + " 不存在使用默认的数据源 -> ");
+            } else {
+                System.out.println("使用数据源:" + baseName);
+                DynamicDataSourceContextHolder.setDataSourceType(baseName);
+            }
+
         String xColumn = scatterConfigInfo.getxAxis().getColumnRename();
         String yColumn = scatterConfigInfo.getyAxis().getColumnRename();
         String xColumnType = scatterConfigInfo.getxAxis().getColumnType();
@@ -74,6 +93,16 @@ public class ShowScatterService {
             return new RepEntity(RepCode.Null);
         }
 
+
+            //取筛选列表
+            List<Screen> screens = scatterConfigInfo.getFilters();
+            String screen = "";
+            if ("".equals(screens) || screens == null){
+                screen = "";
+            }else {
+                screen = screenUtil.screensUtil(screens);
+            }
+
         //无分组时Y值
         Iterator itX = xAxisData.iterator();
         while (itX.hasNext()){
@@ -81,7 +110,7 @@ public class ShowScatterService {
             double valueOne = 0;
             String valueOnes = null;
             if ("time".equals(xColumnType)){
-                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata);
+                valueOnes = timeConverterUtil.getTimeValueConverter(yColumn, xColumn, tableName, yAxisType, xAxisType, xdata, screen);
             }else {
                 valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata,"");
             }
@@ -117,6 +146,9 @@ public class ShowScatterService {
                 //每个分组得到得每个系列
                 while(itGroupsData.hasNext()){
                     String groupsName = (String)itGroupsData.next();
+                    if (groupsName == null || "".equals(groupsName)){
+                        continue;
+                    }
 
                     List<LineSeriesMap> groupsValue = new ArrayList<LineSeriesMap>();
                     Iterator itXAxisData = xAxisData.iterator();
@@ -128,9 +160,9 @@ public class ShowScatterService {
                         String groupsValueOnes = null;
                         if ("time".equals(xColumnType)){
                             groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                    groupsName, xColumn, xAxisDataOne);
+                                    groupsName, xColumn, xAxisDataOne, screen);
                         }else {
-                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne);
+                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne, screen);
                         }
                         if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             groupsValueOne = 0;
@@ -153,6 +185,13 @@ public class ShowScatterService {
         }
 
         chartsDataInfo.setSerieses(serieses);
+        }catch (Exception e){
+            e.printStackTrace();
+            System.out.println("异常");
+            return new RepEntity(RepCode.erro);
+        }finally {
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
 
         return new RepEntity(RepCode.success, chartsDataInfo);
     }

+ 18 - 18
src/main/java/com/server/TimeConverterUtil.java

@@ -66,7 +66,7 @@ public class TimeConverterUtil {
     }
 
     //无分组时间值
-    public String getTimeValueConverter(String yColumn, String xColumn, String tableName, String dataType, String timeType, String xdata){
+    public String getTimeValueConverter(String yColumn, String xColumn, String tableName, String dataType, String timeType, String xdata, String screen){
 
         String timeGroup = "'YYYY-MM-DD'";
         String value = null;
@@ -76,70 +76,70 @@ public class TimeConverterUtil {
             if ("H1".equals(str[1])){
                 String firstIndex = str[0] + "-01";
                 String afterIndex = str[0] + "-06";
-                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, screen);
             }else {
                 String firstIndex = str[0] + "-07";
                 String afterIndex = str[0] + "-12";
-                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, screen);
             }
         }else if ("year".equals(timeType)){
             timeGroup = "'YYYY'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }else if ("month".equals(timeType)){
             timeGroup = "'YYYY-MM'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }else if ("day".equals(timeType) || "".equals(timeType)){
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }else if ("quarter".equals(timeType)){
             timeGroup = "'YYYY-Q'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }else if ("week".equals(timeType)){
             timeGroup = "'YYYY-WW'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }else {
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata,screen);
         }
         return value;
     }
 
     //有分组时间类型值处理
     public String getGroupTimeConverter(String dataType, String yColumn, String tableName, String groupByName, String timeType,
-                                        String groupsName, String xColumn, String xAxisDataOne){
+                                        String groupsName, String xColumn, String xAxisDataOne, String screen){
         String timeGroup = "'YYYY-MM-DD'";
         String value = null;
         if ("year".equals(timeType)){
             timeGroup = "'YYYY'";
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }else if ("month".equals(timeType)){
             timeGroup = "'YYYY-MM'";
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne ,screen);
         }else if ("quarter".equals(timeType)){
             timeGroup = "'YYYY-Q'";
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }else if ("week".equals(timeType)){
             timeGroup = "'YYYY-WW'";
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }else if ("day".equals(timeType) || "".equals(timeType)){
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }else if ("halfYear".equals(timeType)){
             String[] str = xAxisDataOne.split("-");
             if ("上半年".equals(str[1])){
                 String firstIndex = str[0] + "-01";
                 String afterIndex = str[0] + "-06";
-                value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+                value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName, screen);
             }else {
                 String firstIndex = str[0] + "-07";
                 String afterIndex = str[0] + "-12";
-                value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+                value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName, screen);
             }
         }else{
             value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
+                    timeGroup, xAxisDataOne, screen);
         }
         return value;
     }

+ 18 - 3
src/main/java/com/util/ScreenUtil.java

@@ -30,7 +30,9 @@ public class ScreenUtil {
                 ret = ret + " and " + columnName + " " + symbVal;
                 System.out.println("ret:" + ret);
             }if(columnType == "time" || "time".equals(columnType)){
-                String symbVal ;
+                String symbVal = getTimeSymbAndVal(symbol, value);
+                String column = getTimeColumn(columnName);
+                ret = ret + " and " + column + " " + symbVal;
             }
         }
         return ret;
@@ -56,7 +58,20 @@ public class ScreenUtil {
         return tar;
     }
 
-    public String getTimeSybVal(String symbol, String value){
-        return "";
+    public String getTimeColumn(String columnName){
+        return "to_char(" + columnName +", 'yyyy-mm-dd')";
+    }
+
+    private String getTimeSymbAndVal(String symbol, String value){
+        String values = "'" + value;
+        String tar = "";
+        if("null".equals(symbol)){
+            tar = "is null";
+        }else if ("notNull".equals(symbol)){
+            tar = "is not null";
+        }else {
+            tar = symbol + " " + values + "'";
+        }
+        return tar;
     }
 }