Преглед изворни кода

Merge branch 'feature-refactor' of ssh://10.10.100.21/source/platform-bi-server into feature-refactor

zhuth пре 7 година
родитељ
комит
6e65445b48

+ 6 - 0
bi-server/src/main/java/com/usoftchina/bi/server/controller/chart/ChartsConfigController.java

@@ -1,5 +1,6 @@
 package com.usoftchina.bi.server.controller.chart;
 package com.usoftchina.bi.server.controller.chart;
 
 
+import com.usoftchina.bi.auth.annotation.Auth;
 import com.usoftchina.bi.core.base.RepEntity;
 import com.usoftchina.bi.core.base.RepEntity;
 import com.usoftchina.bi.core.base.TestPage;
 import com.usoftchina.bi.core.base.TestPage;
 import com.usoftchina.bi.server.model.bo.GroupUpdateId;
 import com.usoftchina.bi.server.model.bo.GroupUpdateId;
@@ -62,6 +63,7 @@ public class ChartsConfigController {
      */
      */
     @ApiOperation(value = "更新图表分组", notes = "更新图表分组", response = RepEntity.class)
     @ApiOperation(value = "更新图表分组", notes = "更新图表分组", response = RepEntity.class)
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @PostMapping("/updateChartConfigGroup")
     @PostMapping("/updateChartConfigGroup")
     public RepEntity updateConfigGroup(@RequestHeader String token, @RequestBody GroupUpdateId body){
     public RepEntity updateConfigGroup(@RequestHeader String token, @RequestBody GroupUpdateId body){
         return chartsConfigService.updateConfigGroup(body);
         return chartsConfigService.updateConfigGroup(body);
@@ -102,6 +104,7 @@ public class ChartsConfigController {
      */
      */
     @ApiOperation(value = "添加图表分组", notes = "添加图表分组", response = RepEntity.class)
     @ApiOperation(value = "添加图表分组", notes = "添加图表分组", response = RepEntity.class)
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @PostMapping("/setChartsGroup")
     @PostMapping("/setChartsGroup")
     public RepEntity setChartsGroup(@RequestHeader String token, @RequestBody GroupInfo body){
     public RepEntity setChartsGroup(@RequestHeader String token, @RequestBody GroupInfo body){
         return chartsConfigService.setDataConnectorGroup(body);
         return chartsConfigService.setDataConnectorGroup(body);
@@ -112,6 +115,7 @@ public class ChartsConfigController {
      */
      */
     @ApiOperation(value = "更新图表分组", notes = "更新图表分组", response = RepEntity.class)
     @ApiOperation(value = "更新图表分组", notes = "更新图表分组", response = RepEntity.class)
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @PostMapping("/updataChartsGroup")
     @PostMapping("/updataChartsGroup")
     public RepEntity updataChartsGroup(@RequestHeader String token,@RequestBody GroupInfo body){
     public RepEntity updataChartsGroup(@RequestHeader String token,@RequestBody GroupInfo body){
         return chartsConfigService.updataDataConnectorGroup(body);
         return chartsConfigService.updataDataConnectorGroup(body);
@@ -119,6 +123,7 @@ public class ChartsConfigController {
 
 
     @ApiOperation(value = "批量更新数据源分组", notes = "批量更新数据源分组", response = RepEntity.class)
     @ApiOperation(value = "批量更新数据源分组", notes = "批量更新数据源分组", response = RepEntity.class)
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @PostMapping("/batchUpdateChartsGroup")
     @PostMapping("/batchUpdateChartsGroup")
     public RepEntity saveChartsGroup(@RequestHeader String token, @RequestBody List<GroupInfo> groupInfoList){
     public RepEntity saveChartsGroup(@RequestHeader String token, @RequestBody List<GroupInfo> groupInfoList){
         return chartsConfigService.saveChartsGroup(groupInfoList);
         return chartsConfigService.saveChartsGroup(groupInfoList);
@@ -139,6 +144,7 @@ public class ChartsConfigController {
      */
      */
     @ApiOperation(value = "删除图表分组", notes = "删除图表分组", response = RepEntity.class)
     @ApiOperation(value = "删除图表分组", notes = "删除图表分组", response = RepEntity.class)
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @PostMapping("/delChartsGroup")
     @PostMapping("/delChartsGroup")
     public RepEntity delChartsGroup(@RequestHeader String token,@RequestBody List<Integer> body){
     public RepEntity delChartsGroup(@RequestHeader String token,@RequestBody List<Integer> body){
         return chartsConfigService.delDataConnectorGroup(body);
         return chartsConfigService.delDataConnectorGroup(body);

+ 5 - 0
bi-server/src/main/java/com/usoftchina/bi/server/controller/dashboard/DashboardMenuController.java

@@ -1,5 +1,6 @@
 package com.usoftchina.bi.server.controller.dashboard;
 package com.usoftchina.bi.server.controller.dashboard;
 
 
+import com.usoftchina.bi.auth.annotation.Auth;
 import com.usoftchina.bi.core.base.RepCode;
 import com.usoftchina.bi.core.base.RepCode;
 import com.usoftchina.bi.core.base.RepEntity;
 import com.usoftchina.bi.core.base.RepEntity;
 import com.usoftchina.bi.server.model.pojo.annotation.CheckToken;
 import com.usoftchina.bi.server.model.pojo.annotation.CheckToken;
@@ -32,6 +33,7 @@ public class DashboardMenuController {
 
 
     @PostMapping("/save")
     @PostMapping("/save")
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @ApiOperation(value = "保存目录", notes = "保存看板目录", response = RepEntity.class)
     @ApiOperation(value = "保存目录", notes = "保存看板目录", response = RepEntity.class)
     public RepEntity save(@RequestHeader String token, @RequestBody DashBoardMenuInfo dashBoardMenuInfo){
     public RepEntity save(@RequestHeader String token, @RequestBody DashBoardMenuInfo dashBoardMenuInfo){
         dashBoardMenuService.save(dashBoardMenuInfo);
         dashBoardMenuService.save(dashBoardMenuInfo);
@@ -40,6 +42,7 @@ public class DashboardMenuController {
 
 
     @PostMapping("/update")
     @PostMapping("/update")
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @ApiOperation(value = "更新目录", notes = "更新看板目录", response = RepEntity.class)
     @ApiOperation(value = "更新目录", notes = "更新看板目录", response = RepEntity.class)
     public RepEntity update(@RequestHeader String token, @RequestBody DashBoardMenuInfo dashBoardMenuInfo){
     public RepEntity update(@RequestHeader String token, @RequestBody DashBoardMenuInfo dashBoardMenuInfo){
         dashBoardMenuService.update(dashBoardMenuInfo);
         dashBoardMenuService.update(dashBoardMenuInfo);
@@ -48,6 +51,7 @@ public class DashboardMenuController {
 
 
     @PostMapping("/delete/{id}")
     @PostMapping("/delete/{id}")
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @ApiOperation(value = "删除目录", notes = "删除看板目录", response = RepEntity.class)
     @ApiOperation(value = "删除目录", notes = "删除看板目录", response = RepEntity.class)
     public RepEntity delete(@RequestHeader String token, @PathVariable("id") Long id){
     public RepEntity delete(@RequestHeader String token, @PathVariable("id") Long id){
         dashBoardMenuService.deleteById(id);
         dashBoardMenuService.deleteById(id);
@@ -56,6 +60,7 @@ public class DashboardMenuController {
 
 
     @PostMapping("/update/dashboard")
     @PostMapping("/update/dashboard")
     @CheckToken
     @CheckToken
+    @Auth(user = "admin")
     @ApiOperation(value = "更新看板目录", notes = "更新看板目录", response = RepEntity.class)
     @ApiOperation(value = "更新看板目录", notes = "更新看板目录", response = RepEntity.class)
     public RepEntity updateDashBoard(@RequestHeader String token, @RequestBody DashBoardUpdateMenuInfo dashBoardUpdateMenuInfo){
     public RepEntity updateDashBoard(@RequestHeader String token, @RequestBody DashBoardUpdateMenuInfo dashBoardUpdateMenuInfo){
         dashBoardMenuService.updateDashBoardMenu(dashBoardUpdateMenuInfo);
         dashBoardMenuService.updateDashBoardMenu(dashBoardUpdateMenuInfo);

+ 47 - 4
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ShowChartsMapper.java

@@ -29,10 +29,16 @@ public interface ShowChartsMapper {
 
 
     //x轴数据
     //x轴数据
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} = #{xdata} ${screen}")
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} = #{xdata} ${screen}")
-    String getValues(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
+    String getXValue(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
                      @Param("tableName") String tableName, @Param("dataType") String dataType,
                      @Param("tableName") String tableName, @Param("dataType") String dataType,
                      @Param("xdata") String xdata, @Param("screen") String screen);
                      @Param("xdata") String xdata, @Param("screen") String screen);
 
 
+    //x轴数据 -> 优化后
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where 1=1 ${screen} GROUP BY ${xColumn}")
+    List<Double> getValues(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
+                    @Param("tableName") String tableName, @Param("dataType") String dataType,
+                    @Param("screen") String screen);
+
     //x轴为空时的数据
     //x轴为空时的数据
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} is null ${screen}")
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xColumn} is null ${screen}")
     String getValuesIsNull(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
     String getValuesIsNull(@Param("yAxisName") String yAxisName, @Param("xColumn") String xColumn,
@@ -42,7 +48,7 @@ public interface ShowChartsMapper {
 
 
 
 
     //查询分组系列
     //查询分组系列
-    @Select("select ${groupsBy} from ${tableName} where 1=1 ${screen} and rownum<=#{count} group by ${groupsBy}")
+    @Select("SELECT * FROM (select ${groupsBy} from ${tableName} where ${groupsBy} is not null ${screen} group by ${groupsBy}) WHERE rownum<=#{count}")
     List<String> getGroups(@Param("groupsBy") String groupsBy, @Param("tableName") String tableName, @Param("screen") String screen, @Param("count") int count);
     List<String> getGroups(@Param("groupsBy") String groupsBy, @Param("tableName") String tableName, @Param("screen") String screen, @Param("count") int count);
 
 
     //查询分组系列个数
     //查询分组系列个数
@@ -57,6 +63,10 @@ public interface ShowChartsMapper {
                           @Param("xColumn") String xColumn,
                           @Param("xColumn") String xColumn,
                           @Param("screen") String screen);
                           @Param("screen") String screen);
 
 
+    //查询分组的值(柱状图)->优化后
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn} and ${xColumn} ${screen}")
+    List<Double> getGroupsValues(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
+                                 @Param("groupsColumn") String groupsColumn, @Param("xColumn") String xColumn, @Param("screen") String screen);
 
 
     //时间类型的X轴
     //时间类型的X轴
     @Select("select distinct to_char(${xAxisName},${timeType})time from ${tableName} ${screen} ORDER by to_char(${xAxisName},${timeType}) ASC")
     @Select("select distinct to_char(${xAxisName},${timeType})time from ${tableName} ${screen} ORDER by to_char(${xAxisName},${timeType}) ASC")
@@ -70,7 +80,7 @@ public interface ShowChartsMapper {
 
 
     //半年
     //半年
     @Select("select distinct case when to_char(${xAxisName},'MM')<=6 then to_char(${xAxisName},'YYYY')|| '-H1'" +
     @Select("select distinct case when to_char(${xAxisName},'MM')<=6 then to_char(${xAxisName},'YYYY')|| '-H1'" +
-            "else to_char(${xAxisName},'YYYY')||'-H2' end time from ${tableName} ${screen} order by time")
+            "else to_char(${xAxisName},'YYYY')||'-H2' end time from ${tableName} ${screen} and ${xAxisName} is not null order by time")
     List<String> getTimeYear(@Param("xAxisName") String xAxisName, @Param("tableName") String tableName, @Param("screen") String screen);
     List<String> getTimeYear(@Param("xAxisName") String xAxisName, @Param("tableName") String tableName, @Param("screen") String screen);
     
     
     //无分组时间类型值
     //无分组时间类型值
@@ -86,12 +96,33 @@ public interface ShowChartsMapper {
                                  @Param("tableName") String tableName, @Param("xAxisName") String xAxisName,
                                  @Param("tableName") String tableName, @Param("xAxisName") String xAxisName,
                                  @Param("screen") String screen);
                                  @Param("screen") String screen);
 
 
+    //无分组时间类型值(柱状图)->优化后
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} WHERE 1=1 ${screen} GROUP BY (to_char(${xAxisName},${timeType})) ORDER BY (to_char(${xAxisName},${timeType}))")
+    List<Double> getHistogramTimeValue(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName,
+                                       @Param("tableName") String tableName, @Param("xAxisName") String xAxisName,
+                                       @Param("timeType") String timeType, @Param("screen") String screen);
+
     //无分组半年时间值
     //无分组半年时间值
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} ${screen}")
     @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,
     String getTimeValueYear(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex,
                             @Param("xAxisName") String xAxisName, @Param("firstIndex") String firstIndex,
                             @Param("afterIndex") String afterIndex, @Param("screen") String screen);
                             @Param("afterIndex") String afterIndex, @Param("screen") String screen);
 
 
+    /**
+     * 无分组半年时间值(柱状图)
+     * @param dataType
+     * @param yAxisName
+     * @param tableName
+     * @param xAxisName
+     * @param firstIndex
+     * @param afterIndex
+     * @param screen
+     * @return
+     */
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} ${screen}")
+    Double getHistogramTimeValueYear(@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("screen") String screen);
     //时间为空时间值
     //时间为空时间值
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xAxisName} is null ${screen}")
     @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${xAxisName} is null ${screen}")
     String getTimeIsNull(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
     String getTimeIsNull(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
@@ -105,13 +136,19 @@ public interface ShowChartsMapper {
                           @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex
                           @Param("xColumn") String xColumn, @Param("timeType") String timeType, @Param("xColumnIndex") String xColumnIndex
                            );
                            );
 
 
-    //查询时间类型分组的值->优化后
+    //查询时间类型分组的值->优化后(折线图)
     @Select("select ${dataType}(${yAxisName}) as \"value\",TO_CHAR(${xColumn},${timeType}) as \"date\" from ${tableName} where ${groupsColumn}=#{groupsIndex} GROUP BY TO_CHAR(${xColumn},${timeType}) ")
     @Select("select ${dataType}(${yAxisName}) as \"value\",TO_CHAR(${xColumn},${timeType}) as \"date\" from ${tableName} where ${groupsColumn}=#{groupsIndex} GROUP BY TO_CHAR(${xColumn},${timeType}) ")
     List<LineSeriesMap> getGroupValuesTime(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
     List<LineSeriesMap> getGroupValuesTime(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
                               @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex,
                               @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex,
                               @Param("xColumn") String xColumn, @Param("timeType") String timeType
                               @Param("xColumn") String xColumn, @Param("timeType") String timeType
     );
     );
 
 
+    //查询时间类型分组的值->优化后(柱状图)
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where ${groupsColumn}=#{groupsIndex} GROUP BY TO_CHAR(${xColumn},${timeType}) GROUP BY TO_CHAR(${xColumn},${timeType})")
+    List<Double> getHistogramTimeValueGroupValuesTime(@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);
+
     //查询时间类型分组的值->优化后
     //查询时间类型分组的值->优化后
     @Select("select ${dataType}(${yAxisName}) as \"value\",TO_CHAR(${xColumn},${timeType}) as \"date\",${groupsColumn} as \"group\" from ${tableName} where ${groupsColumn} IN (SELECT ${groupsColumn} FROM ${tableName} GROUP BY ${groupsColumn}) GROUP BY TO_CHAR(${xColumn},${timeType}),${groupsColumn} ")
     @Select("select ${dataType}(${yAxisName}) as \"value\",TO_CHAR(${xColumn},${timeType}) as \"date\",${groupsColumn} as \"group\" from ${tableName} where ${groupsColumn} IN (SELECT ${groupsColumn} FROM ${tableName} GROUP BY ${groupsColumn}) GROUP BY TO_CHAR(${xColumn},${timeType}),${groupsColumn} ")
     List<LineSeriesGroupMap> getGroupsValuesTime(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
     List<LineSeriesGroupMap> getGroupsValuesTime(@Param("dataType") String dataType, @Param("yAxisName") String yAxisName, @Param("tableName") String tableName,
@@ -135,6 +172,12 @@ public interface ShowChartsMapper {
                             @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("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex, @Param("screen") String screen);
                                 @Param("groupsColumn") String groupsColumn, @Param("groupsIndex") String groupsIndex, @Param("screen") String screen);
 
 
+    //查询分组的值(时间类型半年)  柱状图
+    //分组半年时间值
+    @Select("select ${dataType}(${yAxisName}) from ${tableName} where TO_CHAR(${xAxisName},'YYYY-MM') between #{firstIndex} and #{afterIndex} and ${groupsColumn}=#{groupsIndex} ${screen}")
+    Double getHistogramTimeValueHalfYear (@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("screen") String screen);
 
 
     /*
     /*
    总体未分组
    总体未分组

+ 7 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/dataSource/DataConnectorMapper.java

@@ -250,6 +250,13 @@ public interface DataConnectorMapper {
             "</script>")
             "</script>")
     void updataConnectorGroup(GroupInfo groupInfo);
     void updataConnectorGroup(GroupInfo groupInfo);
 
 
+    /**
+     * 删除分组时,将数据源分组更新成默认值 -1
+     * @param id  数据源分组ID
+     */
+    @Update("UPDATE BI_DATA_CONNECTORS SET BD_GROUP = -1 WHERE BD_GROUP = #{id,jdbcType=INTEGER}")
+    void updateGroupIdToDefault(Long id);
+
     /*
     /*
     删除分组
     删除分组
      */
      */

+ 26 - 33
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java

@@ -138,26 +138,10 @@ public class ShowHistogramService {
             }
             }
 
 
             //无分组时Y值
             //无分组时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, screenToColumnS);
-                }else {
-                    if (xdata == null || "".equals(xdata)){
-                        valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
-                    }else {
-                        valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
-                    }
-                }
-                if (valueOnes == null || "".equals(valueOnes)){
-                    valueOne = 0;
-                }else {
-                    valueOne = Double.parseDouble(valueOnes);
-                }
-                value.add(valueOne);
+            if ("time".equals(xColumnType)){        //如果是时间类型
+                value = timeConverterUtil.getHistogramTimeValue(yColumn, xColumn, tableName, yAxisType, xAxisType, xAxisData, screenToColumnS);
+            }else {
+                value = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
             }
             }
 
 
             series.setName(xColumn);
             series.setName(xColumn);
@@ -167,16 +151,16 @@ public class ShowHistogramService {
             //有分组
             //有分组
             if (groupBy.size() != 0){
             if (groupBy.size() != 0){
                 serieses.remove(0);
                 serieses.remove(0);
-                Iterator itGroup = groupBy.iterator();  //分组数
+                Iterator<String> itGroup = groupBy.iterator();  //分组数
 
 
                 //便利分组
                 //便利分组
                 while (itGroup.hasNext()){
                 while (itGroup.hasNext()){
-                    String groupByName = (String) itGroup.next(); //每个分组的组名
+                    String groupByName = itGroup.next(); //每个分组的组名
                     int counts = showChartsMapper.getGroupsCount(groupByName,tableName, screenToColumnS);
                     int counts = showChartsMapper.getGroupsCount(groupByName,tableName, screenToColumnS);
-                    if (counts > 20){
+                    if (counts > histogramConfigInfo.getMaxCount()){
                         chartsDataInfo.setTooMany(true);
                         chartsDataInfo.setTooMany(true);
                     }
                     }
-                    List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenToColumnS, 20); //查询每个分组系列
+                    List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenToColumnS, histogramConfigInfo.getMaxCount()); //查询每个分组系列
                     Iterator itGroupsData = groupsData.iterator();
                     Iterator itGroupsData = groupsData.iterator();
 
 
                     //每个分组得到得每个系列
                     //每个分组得到得每个系列
@@ -195,14 +179,13 @@ public class ShowHistogramService {
                             double groupsValueOne = 0;
                             double groupsValueOne = 0;
                             String groupsValueOnes = null;
                             String groupsValueOnes = null;
                             if ("time".equals(xColumnType)){
                             if ("time".equals(xColumnType)){
-                                groupsValueOnes = timeConverterUtil.getGroupTimeConverter(yAxisType, yColumn, tableName, groupByName, xAxisType,
-                                        groupsName, xColumn, xAxisDataOne, screenToColumnS);
+                                groupsValue = timeConverterUtil.getHistogramGroupTime(yAxisType, yColumn, tableName, groupByName, xAxisType,
+                                        groupsName, xColumn, xAxisData, screenToColumnS);
                             }else {
                             }else {
                                 String xColumnKey = "";
                                 String xColumnKey = "";
                                 if (xAxisDataOne == null || "".equals(xAxisDataOne)){
                                 if (xAxisDataOne == null || "".equals(xAxisDataOne)){
                                     xColumnKey  = xColumn + " is null";
                                     xColumnKey  = xColumn + " is null";
-                                }else
-                                {
+                                }else {
                                     xColumnKey = xColumn + " = '" +xAxisDataOne +"'";
                                     xColumnKey = xColumn + " = '" +xAxisDataOne +"'";
                                 }
                                 }
 
 
@@ -212,6 +195,7 @@ public class ShowHistogramService {
                                 }else {
                                 }else {
                                     groupByKey = groupByName + " = '" +groupsName +"'";
                                     groupByKey = groupByName + " = '" +groupsName +"'";
                                 }
                                 }
+                                //groupsValue = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey, screenToColumnS);
                                 groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey, screenToColumnS);
                                 groupsValueOnes = showChartsMapper.getGroupsValue(yAxisType, yColumn, tableName, groupByKey, xColumnKey, screenToColumnS);
                             }
                             }
                             if ("".equals(groupsValueOnes) || groupsValueOnes == null){
                             if ("".equals(groupsValueOnes) || groupsValueOnes == null){
@@ -222,6 +206,15 @@ public class ShowHistogramService {
                             groupsValue.add(groupsValueOne);
                             groupsValue.add(groupsValueOne);
                         }
                         }
 
 
+                        /*if ("time".equals(xColumnType)){
+                            groupsValue = timeConverterUtil.getHistogramGroupTime(yAxisType, yColumn, tableName, groupByName, xAxisType,
+                                    groupsName, xColumn, xAxisData, screenToColumnS);
+                        }else {
+                            String xColumnKey = xColumn;
+                            String groupByKey =groupByName + " = '" +groupsName +"'";
+                            groupsValue = showChartsMapper.getGroupsValues(yAxisType, yColumn, tableName, groupByKey, xColumnKey, screenToColumnS);
+                        }*/
+
                         ne.setValue(groupsValue);
                         ne.setValue(groupsValue);
                         serieses.add(ne);
                         serieses.add(ne);
                     }
                     }
@@ -230,11 +223,11 @@ public class ShowHistogramService {
 
 
             chartsDataInfo.setSerieses(serieses);
             chartsDataInfo.setSerieses(serieses);
         }catch (Exception e){
         }catch (Exception e){
-        e.printStackTrace();
-        return new RepEntity(RepCode.erro);
-    }finally {
-        DynamicDataSourceContextHolder.clearDataSourceType();
-    }
+            e.printStackTrace();
+            return new RepEntity(RepCode.erro.getCode(), e.getCause().getMessage(), null);
+        }finally {
+            DynamicDataSourceContextHolder.clearDataSourceType();
+        }
 
 
         return new RepEntity(RepCode.success, chartsDataInfo);
         return new RepEntity(RepCode.success, chartsDataInfo);
     }
     }

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPieService.java

@@ -145,7 +145,7 @@ public class ShowPieService {
                 if (xdata == null || "".equals(xdata)){
                 if (xdata == null || "".equals(xdata)){
                     valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
                     valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
                 }else {
                 }else {
-                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
+                    valueOnes = showChartsMapper.getXValue(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
                 }
                 }
             }
             }
             if (valueOnes == null || "".equals(valueOnes)){
             if (valueOnes == null || "".equals(valueOnes)){
@@ -165,7 +165,7 @@ public class ShowPieService {
         chartsDataInfo.setSerieses(serieses);
         chartsDataInfo.setSerieses(serieses);
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
-            return new RepEntity(RepCode.erro);
+            return new RepEntity(RepCode.erro.getCode(), e.getCause().getMessage(), null);
         }finally {
         }finally {
             DynamicDataSourceContextHolder.clearDataSourceType();
             DynamicDataSourceContextHolder.clearDataSourceType();
         }
         }

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java

@@ -142,7 +142,7 @@ public class ShowScatterService {
                 if (xdata == null || "".equals(xdata)){
                 if (xdata == null || "".equals(xdata)){
                     valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
                     valueOnes = showChartsMapper.getValuesIsNull(yColumn, xColumn, tableName, yAxisType, screenToColumnS);
                 }else {
                 }else {
-                    valueOnes = showChartsMapper.getValues(yColumn, xColumn, tableName, yAxisType, xdata ,screenToColumnS);
+                    valueOnes = showChartsMapper.getXValue(yColumn, xColumn, tableName, yAxisType, xdata ,screenToColumnS);
                 }
                 }
             }
             }
             if (valueOnes == null || "".equals(valueOnes)){
             if (valueOnes == null || "".equals(valueOnes)){
@@ -233,7 +233,7 @@ public class ShowScatterService {
         chartsDataInfo.setSerieses(serieses);
         chartsDataInfo.setSerieses(serieses);
         }catch (Exception e){
         }catch (Exception e){
             e.printStackTrace();
             e.printStackTrace();
-            return new RepEntity(RepCode.erro);
+            return new RepEntity(RepCode.erro.getCode(), e.getCause().getMessage(), null);
         }finally {
         }finally {
             DynamicDataSourceContextHolder.clearDataSourceType();
             DynamicDataSourceContextHolder.clearDataSourceType();
         }
         }

+ 91 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/TimeConverterUtil.java

@@ -154,6 +154,51 @@ public class TimeConverterUtil {
         return value;
         return value;
     }
     }
 
 
+    /**
+     * 无分组时间值(柱状图)
+     * @param yColumn
+     * @param xColumn
+     * @param tableName
+     * @param dataType
+     * @param timeType
+     * @param xAxisData
+     * @param screen
+     * @return
+     */
+    public List<Double> getHistogramTimeValue(String yColumn, String xColumn, String tableName, String dataType, String timeType, List<String> xAxisData, String screen){
+        String timeGroup = "'YYYY-MM-DD'";
+        List<Double> result = new ArrayList<>();
+        Double value = null;
+        //判断时间类型
+        if ("halfYear".equals(timeType)) {
+            for(String xData : xAxisData) {
+                String firstIndex = null;
+                String afterIndex = null;
+                String[] str = xData.split("-");
+                if ("H1".equals(str[1])) {
+                    firstIndex = str[0] + "-01";
+                    afterIndex = str[0] + "-06";
+                } else {
+                    firstIndex = str[0] + "-07";
+                    afterIndex = str[0] + "-12";
+                }
+                value = showChartsMapper.getHistogramTimeValueYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, screen);
+                result.add(value);
+            }
+            return result;
+        } else if ("year".equals(timeType)) {
+            timeGroup = "'YYYY'";
+        } else if ("month".equals(timeType)) {
+            timeGroup = "'YYYY-MM'";
+        } else if ("day".equals(timeType) || "".equals(timeType)) {
+        } else if ("quarter".equals(timeType)) {
+            timeGroup = "'YYYY-Q'";
+        } else if ("week".equals(timeType)) {
+            timeGroup = "'YYYY-WW'";
+        }
+        return showChartsMapper.getHistogramTimeValue(dataType, yColumn, tableName, xColumn, timeGroup, screen);
+    }
+
     //有分组时间类型值处理
     //有分组时间类型值处理
     public String getGroupTimeConverter(String dataType, String yColumn, String tableName, String groupByName, String timeType,
     public String getGroupTimeConverter(String dataType, String yColumn, String tableName, String groupByName, String timeType,
                                         String groupsName, String xColumn, String xAxisDataOne, String screen){
                                         String groupsName, String xColumn, String xAxisDataOne, String screen){
@@ -200,4 +245,50 @@ public class TimeConverterUtil {
         }
         }
         return value;
         return value;
     }
     }
+
+    /**
+     * 有分组时间类型值处理(柱状图)
+     * @param dataType
+     * @param yColumn
+     * @param tableName
+     * @param groupByName
+     * @param timeType
+     * @param groupsName
+     * @param xColumn
+     * @param xAxisData
+     * @param screen
+     * @return
+     */
+    public List<Double> getHistogramGroupTime(String dataType, String yColumn, String tableName, String groupByName, String timeType,
+                                        String groupsName, String xColumn, List<String> xAxisData, String screen){
+        String timeGroup = "'YYYY-MM-DD'";
+        Double value = null;
+        List<Double> result = new ArrayList<>();
+        if ("halfYear".equals(timeType)) {
+            for (String xAxisDataOne : xAxisData) {
+                String firstIndex = null;
+                String afterIndex = null;
+                String[] str = xAxisDataOne.split("-");
+                if ("上半年".equals(str[1])) {
+                    firstIndex = str[0] + "-01";
+                    afterIndex = str[0] + "-06";
+                } else {
+                    firstIndex = str[0] + "-07";
+                    afterIndex = str[0] + "-12";
+                }
+                value = showChartsMapper.getHistogramTimeValueHalfYear(dataType, yColumn, tableName, xColumn, firstIndex, afterIndex, groupByName, groupsName, screen);
+                result.add(value);
+            }
+            return result;
+        } else if ("year".equals(timeType)) {
+            timeGroup = "'YYYY'";
+        } else if ("month".equals(timeType)) {
+            timeGroup = "'YYYY-MM'";
+        } else if ("quarter".equals(timeType)) {
+            timeGroup = "'YYYY-Q'";
+        } else if ("week".equals(timeType)) {
+            timeGroup = "'YYYY-WW'";
+        }
+        return showChartsMapper.getHistogramTimeValueGroupValuesTime(dataType, yColumn, tableName, groupByName, groupsName, xColumn, timeGroup);
+    }
 }
 }

+ 2 - 2
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataBasesService.java

@@ -76,9 +76,9 @@ public class DataBasesService {
      * @param databases
      * @param databases
      */
      */
     private void validExists(Databases databases){
     private void validExists(Databases databases){
-        int count = dataConnectorMapper.countDataBasesName(databases.getDataName());
+        int count = dataConnectorMapper.countDataBasesName(databases.getName());
         if (count > 0) {
         if (count > 0) {
-            throw new MyException("已存在连接名为 " + databases.getDataName() + " 的数据连接");
+            throw new MyException("已存在连接名为 " + databases.getName() + " 的数据连接");
         }
         }
         count = dataConnectorMapper.countDataBases(databases);
         count = dataConnectorMapper.countDataBases(databases);
         if (count > 0) {
         if (count > 0) {

+ 3 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/dataSource/DataConnectorService.java

@@ -314,6 +314,8 @@ public class DataConnectorService {
             return new RepEntity(RepCode.hasConUsing);
             return new RepEntity(RepCode.hasConUsing);
         }
         }
         dataConnectorMapper.delConnectorGroup(id);
         dataConnectorMapper.delConnectorGroup(id);
+        // 更新分组字段值
+        dataConnectorMapper.updateGroupIdToDefault(id);
         return new RepEntity(RepCode.success);
         return new RepEntity(RepCode.success);
     }
     }
 
 
@@ -395,6 +397,7 @@ public class DataConnectorService {
         dataConnector.setCreateBy(userName);
         dataConnector.setCreateBy(userName);
         dataConnector.setCreateId(userId);
         dataConnector.setCreateId(userId);
         dataConnector.setDbConId(String.valueOf(dataConnectionId));
         dataConnector.setDbConId(String.valueOf(dataConnectionId));
+        dataConnector.setTableName(dataConnector.getLoadObject());
         dataConnectorMapper.insertDataConnector(dataConnector);
         dataConnectorMapper.insertDataConnector(dataConnector);
         int dataId = dataConnector.getDataId();
         int dataId = dataConnector.getDataId();
         return new RepEntity(RepCode.success, dataId);
         return new RepEntity(RepCode.success, dataId);

+ 1 - 10
bi-server/src/main/java/com/usoftchina/bi/server/service/user/UserService.java

@@ -155,16 +155,7 @@ public class UserService {
     查询匹配用户
     查询匹配用户
      */
      */
     public RepEntity getNameList(String condition, Long count){
     public RepEntity getNameList(String condition, Long count){
-        String value = null;
-        String v = null;
-        try {
-            v = objectMapper.readValue(condition, String.class);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        value = "like '%" + v + "%'";
-
+        String value = "like '%" + condition + "%'";
         List<User> userName = userMapper.getNameList(value, count);
         List<User> userName = userMapper.getNameList(value, count);
         return new RepEntity(RepCode.success, userName);
         return new RepEntity(RepCode.success, userName);
     }
     }