Browse Source

1.修改数据源更新时不重新保存数据源的BUG

heqinwei 7 years ago
parent
commit
833eb6e4a4

+ 29 - 4
src/main/java/com/dao/ShowChartsMapper.java

@@ -24,16 +24,28 @@ public interface ShowChartsMapper {
                      @Param("tableName") String tableName, @Param("dataType") String dataType,
                      @Param("xdata") String xdata);
 
+    //x轴为空时的数据
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} is null")
+    String getValuesIsNull(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
+                     @Param("tableName") String tableName, @Param("dataType") String dataType);
+
+
 
     //查询分组系列
     @Select("select ${groupsBy} from ${tableName} ${screen} group by ${groupsBy}")
     List<String> getGroups(@Param("groupsBy") String groupsBy, @Param("tableName") String tableName, @Param("screen") String screen);
 
+//    //查询分组的值
+//    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and ${xColumn}=#{xColumnIndex}")
+//    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);
+
     //查询分组的值
-    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and ${xColumn}=#{xColumnIndex}")
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} and ${xColumn}")
     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("groupsColumn") String groupsColumn,
+                          @Param("xColumn") String xColumn);
 
 
     //时间类型的X轴
@@ -58,6 +70,11 @@ public interface ShowChartsMapper {
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex,
                             @Param("afterIndex") String afterIndex);
 
+    //时间为空时间值
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xAxisName} is null")
+    String getTimeIsNull(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
+                         @Param("xAxisName") String xAxisName);
+
 
     //查询时间类型分组的值
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex} ")
@@ -66,6 +83,14 @@ public interface ShowChartsMapper {
                           @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex
                            );
 
+    //有分组时时间类型为空值
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} is null and TO_CHAR(${xColumn},${timeType})=#{xColumnIndex} ")
+    String getGroupsValueTimeIsNull(@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
+    );
+
+
     //查询分组的值(时间类型半年)
     //分组半年时间值
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex} ")
@@ -75,7 +100,7 @@ public interface ShowChartsMapper {
 
 
     /*
-   个体表查询标准差
+   总体未分组
     */
     @Select("select ${operation}(${columnName}) from ${tableName} ${screen}")
     Double getColumnDev(@Param("tableName") String tableName, @Param("columnName") String columnName,

+ 10 - 10
src/main/java/com/server/DataConnectorService.java

@@ -3,7 +3,6 @@ package com.server;
 import com.dao.DataConnectorMapper;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.model.bo.DatabaseConfig;
 import com.model.bo.GroupUpdateId;
 import com.model.po.BaseConfig;
 import com.model.po.DataConnector;
@@ -165,7 +164,7 @@ public class DataConnectorService {
         dataConnector.setTableName(tableName);
 
         List<ColumnRenameInfo> columnConfig = dataConnectorInfo.getColumnConfig();
-        DatabaseConfig dbConfig = dataConnectorInfo.getDbConfig();
+//        DatabaseConfig dbConfig = dataConnectorInfo.getDbConfig();
         List<String> dataTag = dataConnectorInfo.getDataTag();
 
 
@@ -181,14 +180,15 @@ public class DataConnectorService {
             }
             dataConnector.setColumnConfig(columnConfigJson);
         }
-        if (!("".equals(dbConfig)) && dbConfig != null){
-            try {
-                dbConfigJson = objectmapper.writeValueAsString(dbConfig);
-            } catch (JsonProcessingException e) {
-                e.printStackTrace();
-            }
-            dataConnector.setDbConfig(null);
-        }
+//        if (!("".equals(dbConfig)) && dbConfig != null){
+//            try {
+//                dbConfigJson = objectmapper.writeValueAsString(dbConfig);
+//            } catch (JsonProcessingException e) {
+//                e.printStackTrace();
+//            }
+//            dataConnector.setDbConfig(null);
+//        }
+        dataConnector.setDbConfig(dbConfigJson);
         if (dataTag != null){
             try {
                 dataTagJson = objectmapper.writeValueAsString(dataTag);

+ 1 - 6
src/main/java/com/server/ImplementSqlService.java

@@ -66,16 +66,11 @@ public class ImplementSqlService {
             DriverManager.setLoginTimeout(8);
             con = DriverManager.getConnection(url, username, password);
             System.out.println("数据库连接成功");
+            con.close();
         } catch (SQLException se) {
             System.out.println("数据库连接失败!");
             se.printStackTrace();
             return new RepEntity(RepCode.Null);
-        }finally{
-            try {
-                con.close();
-                } catch (SQLException e) {
-                   e.printStackTrace();
-            }
         }
         return new RepEntity(RepCode.success);
     }

+ 23 - 11
src/main/java/com/server/ShowHistogramService.java

@@ -135,15 +135,16 @@ public class ShowHistogramService {
             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);
                 }else {
-                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata);
+                    if (xdata == null || "".equals(xdata)){
+                        valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType);
+                    }else {
+                        valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata);
+                    }
                 }
                 if (valueOnes == null || "".equals(valueOnes)){
                     valueOne = 0;
@@ -175,9 +176,9 @@ public class ShowHistogramService {
                     while(itGroupsData.hasNext()){
                         Series ne = new Series();
                         String groupsName = (String)itGroupsData.next();
-                        if (groupsName == null || "".equals(groupsName)){
-                            continue;
-                        }
+//                        if (groupsName == null || "".equals(groupsName)){
+//                            continue;
+//                        }
                         ne.setName(groupsName);
                         ne.setStack(groupByName);
 
@@ -187,16 +188,27 @@ public class ShowHistogramService {
                         //每个系列对应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);
                             }else {
-                                groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne);
+                                String xColumnKey = "";
+                                if (xAxisDataOne == null || "".equals(xAxisDataOne)){
+                                    xColumnKey  = xColumn + " is null";
+                                }else
+                                {
+                                    xColumnKey = xColumn + " = '" +xAxisDataOne +"'";
+                                }
+
+                                String groupByKey = "";
+                                if (groupsName == null || "".equals(groupsName)){
+                                    groupByKey = groupByName +" is null";
+                                }else {
+                                    groupByKey = groupByName + " = '" +groupsName +"'";
+                                }
+                                groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey);
                             }
                             if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                                 groupsValueOne = 0;

+ 7 - 1
src/main/java/com/server/ShowPopulationService.java

@@ -104,8 +104,9 @@ public class ShowPopulationService {
             //获取运算列
             List<String> operatorColumn = new ArrayList<>();
 
+            String next = null;
             while (operatorsList.hasNext()){
-                String next = String.valueOf(operatorsList.next()).toLowerCase();
+                next = String.valueOf(operatorsList.next()).toLowerCase();
                 String op = next + "(" + columnName + ") as " +next.toLowerCase() ;
                 operatorColumn.add(op);
             }
@@ -116,6 +117,11 @@ public class ShowPopulationService {
             String oprs = operatorColumn.toString();
             String opr = getString(oprs);
 
+            //计算25th,75th,和百分比
+            if (next == "25TH" || "25Th".equals(next)){
+
+            }
+
             List<LinkedHashMap<String, Object>> valueList = new ArrayList<>();
             valueList = showChartsMapper.getGroupByValue(groupBy, opr, tableName, listOne, screenStr);
             System.out.println("valueList:"+ valueList);

+ 1 - 1
src/main/java/com/server/ShowScatterService.java

@@ -175,7 +175,7 @@ public class ShowScatterService {
                             groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
                                     groupsName, xColumn, xAxisDataOne);
                         }else {
-                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne);
+//                            groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByName, groupsName, xColumn, xAxisDataOne);
                         }
                         if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             groupsValueOne = 0;

+ 66 - 57
src/main/java/com/server/TimeConverterUtil.java

@@ -74,33 +74,37 @@ public class TimeConverterUtil {
         String timeGroup = "'YYYY-MM-DD'";
         String value = null;
         //判断时间类型
-        if ("halfYear".equals(timeType)){
-            String[] str = xdata.split("-");
-            if ("H1".equals(str[1])){
-                String firstIndex = str[0] + "-01";
-                String afterIndex = str[0] + "-06";
-                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
-            }else {
-                String firstIndex = str[0] + "-07";
-                String afterIndex = str[0] + "-12";
-                value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
-            }
-        }else if ("year".equals(timeType)){
-            timeGroup = "'YYYY'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
-        }else if ("month".equals(timeType)){
-            timeGroup = "'YYYY-MM'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
-        }else if ("day".equals(timeType) || "".equals(timeType)){
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
-        }else if ("quarter".equals(timeType)){
-            timeGroup = "'YYYY-Q'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
-        }else if ("week".equals(timeType)){
-            timeGroup = "'YYYY-WW'";
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+        if (xdata == null || "".equals(xdata)){
+            value = showChartsMapper.getTimeIsNull(dataType, yColumn, tableName, xColumn);
         }else {
-            value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup,xdata);
+            if ("halfYear".equals(timeType)) {
+                String[] str = xdata.split("-");
+                if ("H1".equals(str[1])) {
+                    String firstIndex = str[0] + "-01";
+                    String afterIndex = str[0] + "-06";
+                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                } else {
+                    String firstIndex = str[0] + "-07";
+                    String afterIndex = str[0] + "-12";
+                    value = showChartsMapper.getTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex);
+                }
+            } else if ("year".equals(timeType)) {
+                timeGroup = "'YYYY'";
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            } else if ("month".equals(timeType)) {
+                timeGroup = "'YYYY-MM'";
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            } else if ("day".equals(timeType) || "".equals(timeType)) {
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            } else if ("quarter".equals(timeType)) {
+                timeGroup = "'YYYY-Q'";
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            } else if ("week".equals(timeType)) {
+                timeGroup = "'YYYY-WW'";
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            } else {
+                value = showChartsMapper.getTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, xdata);
+            }
         }
         return value;
     }
@@ -110,39 +114,44 @@ public class TimeConverterUtil {
                                         String groupsName, String xColumn, String xAxisDataOne){
         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);
-        }else if ("month".equals(timeType)){
-            timeGroup = "'YYYY-MM'";
-            value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+        if(groupsName == null || "".equals(groupsName)){
+            value = showChartsMapper.getGroupsValueTimeIsNull(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
                     timeGroup, xAxisDataOne);
-        }else if ("quarter".equals(timeType)){
-            timeGroup = "'YYYY-Q'";
-            value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
-        }else if ("week".equals(timeType)){
-            timeGroup = "'YYYY-WW'";
-            value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
-        }else if ("day".equals(timeType) || "".equals(timeType)){
-            value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
-        }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);
-            }else {
-                String firstIndex = str[0] + "-07";
-                String afterIndex = str[0] + "-12";
-                value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+        }else {
+            if ("year".equals(timeType)) {
+                timeGroup = "'YYYY'";
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
+            } else if ("month".equals(timeType)) {
+                timeGroup = "'YYYY-MM'";
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
+            } else if ("quarter".equals(timeType)) {
+                timeGroup = "'YYYY-Q'";
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
+            } else if ("week".equals(timeType)) {
+                timeGroup = "'YYYY-WW'";
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
+            } else if ("day".equals(timeType) || "".equals(timeType)) {
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
+            } 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);
+                } else {
+                    String firstIndex = str[0] + "-07";
+                    String afterIndex = str[0] + "-12";
+                    value = showChartsMapper.getTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName);
+                }
+            } else {
+                value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
+                        timeGroup, xAxisDataOne);
             }
-        }else{
-            value = showChartsMapper.getGroupsValueTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn,
-                    timeGroup, xAxisDataOne);
         }
         return value;
     }