Browse Source

Merge remote-tracking branch 'origin/feature-refactor' into feature-refactor

hy 6 years ago
parent
commit
935a8b37c9
28 changed files with 259 additions and 95 deletions
  1. 1 1
      bi-auth/src/main/java/com/usoftchina/bi/auth/config/ConfigAdapter.java
  2. 3 3
      bi-core/src/main/java/com/usoftchina/bi/core/base/BaseContextHolder.java
  3. 13 3
      bi-server/src/main/java/com/usoftchina/bi/server/aspect/JwtTokenAspect.java
  4. 4 4
      bi-server/src/main/java/com/usoftchina/bi/server/controller/chart/ShowChartsController.java
  5. 48 0
      bi-server/src/main/java/com/usoftchina/bi/server/controller/dashboard/DefaultDashboardController.java
  6. 6 3
      bi-server/src/main/java/com/usoftchina/bi/server/controller/user/UserController.java
  7. 1 1
      bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ChartsConfigMapper.java
  8. 8 0
      bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ShowChartsMapper.java
  9. 1 1
      bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardFavoriteMapper.java
  10. 27 0
      bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DefaultDashboardMapper.java
  11. 9 9
      bi-server/src/main/java/com/usoftchina/bi/server/dao/user/UserMapper.java
  12. 9 0
      bi-server/src/main/java/com/usoftchina/bi/server/model/po/ChartsConfigToDash.java
  13. 9 0
      bi-server/src/main/java/com/usoftchina/bi/server/model/vo/dataVo/ChartsDataInfo.java
  14. 9 0
      bi-server/src/main/java/com/usoftchina/bi/server/model/vo/dataVo/PopAndIndDataInfo.java
  15. 26 26
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowHistogramService.java
  16. 4 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowLineService.java
  17. 2 1
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPieService.java
  18. 8 6
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPopulationService.java
  19. 2 1
      bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowScatterService.java
  20. 4 0
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java
  21. 27 29
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsToChartsUtilService.java
  22. 34 0
      bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DefaultDashboardService.java
  23. 1 1
      bi-server/src/main/java/com/usoftchina/bi/server/service/user/SynchronizeEmpInfo.java
  24. 1 2
      bi-server/src/main/java/com/usoftchina/bi/server/service/user/UserService.java
  25. 0 0
      bi-server/src/main/resources/static/index.5ff87b47.js
  26. 0 0
      bi-server/src/main/resources/static/index.c10dd238.js
  27. 0 0
      bi-server/src/main/resources/static/index.e49f5545.css
  28. 2 2
      bi-server/src/main/resources/static/index.html

+ 1 - 1
bi-auth/src/main/java/com/usoftchina/bi/auth/config/ConfigAdapter.java

@@ -25,11 +25,11 @@ public class ConfigAdapter implements WebMvcConfigurer {
         .addPathPatterns("/getUserList")
         .addPathPatterns("/*User*")
         .addPathPatterns("/*User*/*")
+        .addPathPatterns("/home/defaultDashboard/*")
         .addPathPatterns("/Connector/*").excludePathPatterns("/Connector/getListDataConnector")
         .excludePathPatterns("/Connector/getConnectorGroup")
         .excludePathPatterns("/getDashboardByCode")
         .excludePathPatterns("/getSharedDashboard")
         .excludePathPatterns("/Connector/getConnectorData");
-        logger.info("进入全局拦截器");
     }
 }

+ 3 - 3
bi-core/src/main/java/com/usoftchina/bi/core/base/BaseContextHolder.java

@@ -35,7 +35,7 @@ public class BaseContextHolder {
         return Integer.valueOf(String.valueOf(value));
     }
 
-    public static synchronized void setUserId(int userId) {
+    public static void setUserId(int userId) {
         set("userId", userId);
     }
 
@@ -44,7 +44,7 @@ public class BaseContextHolder {
         return String.valueOf(value);
     }
 
-    public static synchronized void setUserName(String userName) {
+    public static void setUserName(String userName) {
         set("userName", userName);
     }
 
@@ -53,7 +53,7 @@ public class BaseContextHolder {
         return String.valueOf(value);
     }
 
-    public static synchronized void setRole(String role){
+    public static void setRole(String role){
         set("role", role);
     }
 }

+ 13 - 3
bi-server/src/main/java/com/usoftchina/bi/server/aspect/JwtTokenAspect.java

@@ -21,6 +21,8 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
 
 @Aspect
 @Component
@@ -92,9 +94,17 @@ public class JwtTokenAspect {
         } catch (MyException e) {
             throw new MyException(-505, "token过期");
         }
-        BaseContextHolder.setUserId(Integer.valueOf(jwt.getClaim("id").asString()));
-        BaseContextHolder.setUserName(jwt.getClaim("name").asString());
-        BaseContextHolder.setRole(jwt.getClaim("role").asString());
+
+        Lock lock = new ReentrantLock();
+        lock.lock();
+        try {
+            BaseContextHolder.setUserId(Integer.valueOf(jwt.getClaim("id").asString()));
+            BaseContextHolder.setUserName(jwt.getClaim("name").asString());
+            BaseContextHolder.setRole(jwt.getClaim("role").asString());
+        } finally {
+            lock.unlock();
+        }
+
         return jwt.getClaims();
     }
 }

+ 4 - 4
bi-server/src/main/java/com/usoftchina/bi/server/controller/chart/ShowChartsController.java

@@ -43,7 +43,7 @@ public class ShowChartsController {
     @CheckToken
     @PostMapping("/showHistogram")
     public RepEntity showHistogram(@RequestHeader String token,@RequestBody HistogramConfigInfo body){
-        return showHistogramService.showHistogram(body, token, 0);
+        return showHistogramService.showHistogram(body, token, 0, null);
     }
 
     /*
@@ -53,7 +53,7 @@ public class ShowChartsController {
     @CheckToken
     @PostMapping("/showPie")
     public RepEntity showPie(@RequestHeader String token,@RequestBody PieConfigInfo body){
-        return showPieService.showPie(body, token, 0);
+        return showPieService.showPie(body, token, 0, null);
     }
 
     /*
@@ -63,7 +63,7 @@ public class ShowChartsController {
     @CheckToken
     @PostMapping("/showLine")
     public RepEntity showLine(@RequestHeader String token,@RequestBody LineConfigInfo body){
-        return showLineService.showLine(body, token, 0);
+        return showLineService.showLine(body, token, 0, null);
     }
 
     /*
@@ -73,7 +73,7 @@ public class ShowChartsController {
     @CheckToken
     @PostMapping("/showScatter")
     public RepEntity showScatter(@RequestHeader String token,@RequestBody ScatterConfigInfo body){
-        return showScatterService.showScatter(body, token, 0);
+        return showScatterService.showScatter(body, token, 0, null);
     }
 
     /*

+ 48 - 0
bi-server/src/main/java/com/usoftchina/bi/server/controller/dashboard/DefaultDashboardController.java

@@ -0,0 +1,48 @@
+package com.usoftchina.bi.server.controller.dashboard;
+
+import com.usoftchina.bi.core.base.RepCode;
+import com.usoftchina.bi.core.base.RepEntity;
+import com.usoftchina.bi.server.model.pojo.annotation.CheckToken;
+import com.usoftchina.bi.server.service.dashboard.DefaultDashboardService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 设置首页默认报表
+ * @Author chenwei
+ * @Date 2019-05-31
+ */
+@RestController
+@Api(description = "设置首页默认报表相关接口")
+@RequestMapping("/home/defaultDashboard")
+public class DefaultDashboardController {
+
+    @Autowired
+    private DefaultDashboardService defaultDashboardService;
+
+    @GetMapping("/read/{userId}")
+    @CheckToken
+    @ApiOperation(value = "查看用户设置的首页默认报表", notes = "查看用户设置的首页默认报表", response = RepEntity.class)
+    public RepEntity read(@RequestHeader String token, @PathVariable("userId") int userId){
+        return new RepEntity(RepCode.success, defaultDashboardService.read(userId));
+    }
+
+    @PostMapping("/save/{userId}/{dashboardId}")
+    @CheckToken
+    @ApiOperation(value = "设置首页默认报表", notes = "设置首页默认报表", response = RepEntity.class)
+    public RepEntity save(@RequestHeader String token, @PathVariable("userId") int userId, @PathVariable("dashboardId") int dashboardId){
+        defaultDashboardService.save(userId, dashboardId);
+        return new RepEntity(RepCode.success, null);
+    }
+
+    @PostMapping("/delete/{userId}/{dashboardId}")
+    @CheckToken
+    @ApiOperation(value = "取消首页默认报表", notes = "取消首页默认报表", response = RepEntity.class)
+    public RepEntity delete(@RequestHeader String token, @PathVariable("userId") int userId, @PathVariable("dashboardId") int dashboardId){
+        defaultDashboardService.delete(userId, dashboardId);
+        return new RepEntity(RepCode.success, null);
+    }
+
+}

+ 6 - 3
bi-server/src/main/java/com/usoftchina/bi/server/controller/user/UserController.java

@@ -100,8 +100,9 @@ public class UserController {
      */
     @ApiOperation(value = "删除用户组", notes = "删除用户组", response = RepEntity.class)
     @Auth(user = "admin")
+    @CheckToken
     @PostMapping("/delUserGroup/{id}")
-    public RepEntity delUserGroup(@PathVariable("id") Long id){
+    public RepEntity delUserGroup(@RequestHeader String token, @PathVariable("id") Long id){
         return userService.delUserGroup(id);
     }
 
@@ -111,7 +112,8 @@ public class UserController {
     @ApiOperation(value = "用户组添加用户", notes = "用户组添加用户", response = RepEntity.class)
     @Auth(user = "admin")
     @PostMapping("/setUserInto")
-    public RepEntity setUserInto(@RequestBody UserGroupSetInfo body){
+    @CheckToken
+    public RepEntity setUserInto(@RequestHeader String token, @RequestBody UserGroupSetInfo body){
         return userService.setUserInto(body);
     }
 
@@ -131,7 +133,8 @@ public class UserController {
     @ApiOperation(value = "删除用户组下的用户", notes = "删除用户组下的用户", response = RepEntity.class)
     @Auth(user = "admin")
     @PostMapping("/delUserInGroup")
-    public RepEntity delUserInGroup(@RequestBody UserGroupSetInfo body){
+    @CheckToken
+    public RepEntity delUserInGroup(@RequestHeader String token, @RequestBody UserGroupSetInfo body){
         return userService.delUserInGroup(body);
     }
 }

+ 1 - 1
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ChartsConfigMapper.java

@@ -329,7 +329,7 @@ public interface ChartsConfigMapper {
     /*
     通过图表ID获取图表配置
      */
-    @Select("select id, chart_type as chartType, BC_FETCHCONFIG as fetchConfig from bi_charts where id = #{id}")
+    @Select("select id, chart_type as chartType, BC_FETCHCONFIG as fetchConfig,BC_CHART_STYLE as styleConfig from bi_charts where id = #{id}")
     ChartsConfigToDash getChartConfigToDash(int id);
 
     /*

+ 8 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ShowChartsMapper.java

@@ -194,6 +194,14 @@ public interface ShowChartsMapper {
     Double getColumnData(@Param("tableName") String tableName, @Param("columnName") String columnName,
                         @Param("operation") String operation, @Param("screen") String screen);
 
+    /**
+     * 不重复计数
+     * @return
+     */
+    @Select("SELECT COUNT(${columnName}) FROM (SELECT DISTINCT ${columnName} FROM ${tableName} ${screen})")
+    Double getDistinctCountColumnData(@Param("tableName") String tableName, @Param("columnName") String columnName,
+                                      @Param("operation") String operation, @Param("screen") String screen);
+
     /*
     取主键名称
      */

+ 1 - 1
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardFavoriteMapper.java

@@ -13,7 +13,7 @@ import java.util.Map;
 @Repository
 public interface DashboardFavoriteMapper {
 
-    @Select("SELECT ID AS id, BD_NAME AS name FROM BI_DASHBOARDS WHERE ID IN (SELECT DASHBOARD_ID FROM BI_DASHBOARDS_FAVORITE WHERE USER_ID = #{userId})")
+    @Select("SELECT ID AS \"id\", BD_NAME AS \"name\" FROM BI_DASHBOARDS WHERE ID IN (SELECT DASHBOARD_ID FROM BI_DASHBOARDS_FAVORITE WHERE USER_ID = #{userId})")
     List<Map<String, String>> list(@Param("userId") int userId);
 
     @Insert("INSERT INTO BI_DASHBOARDS_FAVORITE(USER_ID, DASHBOARD_ID) VALUES(#{userId,jdbcType=INTEGER},#{dashboardId,jdbcType=INTEGER})")

+ 27 - 0
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DefaultDashboardMapper.java

@@ -0,0 +1,27 @@
+package com.usoftchina.bi.server.dao.dashboard;
+
+import org.apache.ibatis.annotations.*;
+import org.springframework.stereotype.Repository;
+
+import java.util.Map;
+
+/**
+ * @Author chenwei
+ * @Date 2019-05-31
+ */
+@Mapper
+@Repository
+public interface DefaultDashboardMapper {
+
+    @Select("SELECT DASHBOARD_ID AS \"id\", BD_NAME AS \"name\" FROM BI_DASHBOARDS_USER LEFT JOIN BI_DASHBOARDS ON ID = DASHBOARD_ID WHERE USER_ID = #{userId}")
+    Map<String, String> selectDashboardIdByUserId(@Param("userId") int userId);
+
+    @Insert("INSERT INTO BI_DASHBOARDS_USER(USER_ID,DASHBOARD_ID) VALUES(#{userId,jdbcType=INTEGER},#{dashboardId,jdbcType=INTEGER})")
+    void save(@Param("userId") int userId, @Param("dashboardId") int dashboardId);
+
+    @Delete("DELETE FROM BI_DASHBOARDS_USER WHERE USER_ID = #{userId,jdbcType=INTEGER} AND DASHBOARD_ID = #{dashboardId,jdbcType=INTEGER}")
+    void delete(@Param("userId") int userId, @Param("dashboardId") int dashboardId);
+
+    @Delete("DELETE FROM BI_DASHBOARDS_USER WHERE USER_ID = #{userId,jdbcType=INTEGER}")
+    void deleteByUserId(@Param("userId") int userId);
+}

+ 9 - 9
bi-server/src/main/java/com/usoftchina/bi/server/dao/user/UserMapper.java

@@ -36,7 +36,7 @@ public interface UserMapper {
      * 查询UAS的人员资料表数据
      * @return
      */
-    @Select("SELECT EM_ID as id,EM_DEFAULTHSNAME as department, EM_TYPE role, EM_DEPART as post, EM_NAME as name, EM_PASSWORD as passWord, "
+    @Select("SELECT EM_ID as id,EM_DEFAULTHSNAME as post, EM_TYPE role, EM_DEPART as department, EM_NAME as name, EM_PASSWORD as passWord, "
             + "EM_MOBILE as phone, EM_CODE as userName,EM_CLASS AS state FROM EMPLOYEE")
     List<User> getUASEmployee();
 
@@ -104,14 +104,14 @@ public interface UserMapper {
     /*
     查询uas用户信息
      */
-    @Select("SELECT EM_DEFAULTHSNAME as department, EM_DEPART as post,EM_TYPE as role, EM_NAME as name, EM_PASSWORD as passWord," +
+    @Select("SELECT EM_DEFAULTHSNAME as post, EM_DEPART as department,EM_TYPE as role, EM_NAME as name, EM_PASSWORD as passWord," +
             " EM_MOBILE as phone, EM_CODE as userName,EM_CLASS AS state FROM EMPLOYEE where EM_CODE = #{userName}")
     User getUserMessByName(@Param("userName") String userName);
 
     /*
     查询uas用户信息
      */
-    @Select("SELECT EM_DEFAULTHSNAME as department, EM_DEPART as post,EM_TYPE as role, EM_NAME as name, EM_PASSWORD as passWord," +
+    @Select("SELECT EM_DEFAULTHSNAME as post, EM_DEPART as department,EM_TYPE as role, EM_NAME as name, EM_PASSWORD as passWord," +
             " EM_MOBILE as phone, EM_CODE as userName,EM_CLASS AS state FROM EMPLOYEE where EM_MOBILE = #{mobile}")
     User getUserMessByMobile(@Param("mobile") String mobile);
 
@@ -130,7 +130,7 @@ public interface UserMapper {
      */
     @Select("SELECT BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
             " USER_NAME as userName, PASS_WORD as passWord, BU_PHONE as phone, BU_CLASS as state " +
-            "FROM BI_USERS WHERE USER_NAME = #{userName} AND BU_CLASS <> '离职'")
+            "FROM BI_USERS WHERE USER_NAME = #{userName} AND NVL(BU_CLASS,' ') <> '离职'")
     User getBIUserByName(@Param("userName") String userName);
 
     /**
@@ -140,7 +140,7 @@ public interface UserMapper {
      */
     @Select("SELECT BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
             " USER_NAME as userName, PASS_WORD as passWord, BU_PHONE as phone, BU_CLASS as state " +
-            "FROM BI_USERS WHERE BU_PHONE = #{mobile} AND BU_CLASS <> '离职'")
+            "FROM BI_USERS WHERE BU_PHONE = #{mobile} AND NVL(BU_CLASS,' ') <> '离职'")
     User getBIUserByMobile(@Param("mobile") String mobile);
 
     /*
@@ -160,7 +160,7 @@ public interface UserMapper {
      */
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
             "user_name as userName, pass_word as passWord, create_date as createDate " +
-            "from bi_users WHERE BU_CLASS <> '离职' AND BU_ROLE <> 'superAdmin'")
+            "from bi_users WHERE NVL(BU_CLASS,' ') <> '离职' AND BU_ROLE <> 'superAdmin'")
     List<User> getUserList();
 
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role," +
@@ -172,7 +172,7 @@ public interface UserMapper {
     匹配用户20个
      */
     @Select("select BU_ID as id, BU_NAME as name, BU_DEPARTMENT as department, BU_POST as post, BU_ROLE as role " +
-            "from bi_users where bu_name ${condition} AND BU_CLASS <> '离职' AND BU_ROLE <> 'superAdmin' and rownum < #{count, jdbcType=INTEGER}")
+            "from bi_users where bu_name ${condition} AND NVL(BU_CLASS,' ') <> '离职' AND BU_ROLE <> 'superAdmin' and rownum < #{count, jdbcType=INTEGER}")
     List<User> getNameList(@Param("condition") String condition, @Param("count") Long count);
 
     /*
@@ -256,14 +256,14 @@ public interface UserMapper {
      * @return
      */
     @Select("SELECT WM_CONCAT(BU_NAME) FROM BI_USERS WHERE BU_ID IN (${ids})")
-    String getUserByIds(String ids);
+    String getUserByIds(@Param("ids") String ids);
 
     /*
     查询用户组下的用户信息
      */
     @Select("select bu_id as id, bu_name as name, bu_department as department, bu_post as post, bu_role as role " +
             " from bi_users,bi_user_groups,bi_user_rel_groups where bi_users.bu_id=bi_user_rel_groups.br_user_id and " +
-            " bi_user_rel_groups.br_user_group=bi_user_groups.bg_id and bi_user_groups.bg_id = #{id} AND BU_CLASS <> '离职'")
+            " bi_user_rel_groups.br_user_group=bi_user_groups.bg_id and bi_user_groups.bg_id = #{id} AND NVL(BU_CLASS,' ') <> '离职'")
     List<User> getGroupUserList(int id);
 
     /*

+ 9 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/po/ChartsConfigToDash.java

@@ -4,6 +4,15 @@ public class ChartsConfigToDash {
     private int chartId;
     private String fetchConfig;
     private String chartType;
+    private String styleConfig;
+
+    public String getStyleConfig() {
+        return styleConfig;
+    }
+
+    public void setStyleConfig(String styleConfig) {
+        this.styleConfig = styleConfig;
+    }
 
     public String getChartType() {
         return chartType;

+ 9 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/dataVo/ChartsDataInfo.java

@@ -9,6 +9,15 @@ public class ChartsDataInfo<T> {
     private List<T> serieses;
     private ChartsColumnConfig chartsColumnConfig;
     private boolean tooMany;
+    private String styleConfig;
+
+    public String getStyleConfig() {
+        return styleConfig;
+    }
+
+    public void setStyleConfig(String styleConfig) {
+        this.styleConfig = styleConfig;
+    }
 
     public boolean isTooMany() {
         return tooMany;

+ 9 - 0
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/dataVo/PopAndIndDataInfo.java

@@ -5,6 +5,15 @@ import com.usoftchina.bi.server.model.bo.ChartsColumnConfig;
 public class PopAndIndDataInfo<T> {
     private ChartsColumnConfig chartsColumnConfig;
     private T valueList;
+    private String styleConfig;
+
+    public String getStyleConfig() {
+        return styleConfig;
+    }
+
+    public void setStyleConfig(String styleConfig) {
+        this.styleConfig = styleConfig;
+    }
 
     public ChartsColumnConfig getChartsColumnConfig() {
         return chartsColumnConfig;

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

@@ -38,8 +38,9 @@ public class ShowHistogramService {
     /*
     柱状图数据展示
      */
-    public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo, String token, int dashId){
+    public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo, String token, int dashId, String styleConfig){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
+        chartsDataInfo.setStyleConfig(styleConfig);
         TimeReture timeReture = new TimeReture();
         if (histogramConfigInfo == null || "".equals(histogramConfigInfo)){
             return new RepEntity(RepCode.Null);
@@ -136,37 +137,36 @@ public class ShowHistogramService {
             }else {
                 chartsDataInfo.setxAxis(xAxisData);
             }
-
             //无分组时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.getXValue(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
+            if (groupBy.size() == 0) {
+                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.getXValue(yColumn, xColumn, tableName, yAxisType, xdata, screenToColumnS);
+                        }
                     }
+                    if (valueOnes == null || "".equals(valueOnes)) {
+                        valueOne = 0;
+                    } else {
+                        valueOne = Double.parseDouble(valueOnes);
+                    }
+                    value.add(valueOne);
                 }
-                if (valueOnes == null || "".equals(valueOnes)){
-                    valueOne = 0;
-                }else {
-                    valueOne = Double.parseDouble(valueOnes);
-                }
-                value.add(valueOne);
-            }
-
-            series.setName(xColumn);
-            series.setValue(value);
-            serieses.add(series);
 
+                series.setName(xColumn);
+                series.setValue(value);
+                serieses.add(series);
+            }
             //有分组
             if (groupBy.size() != 0){
-                serieses.remove(0);
                 Iterator<String> itGroup = groupBy.iterator();  //分组数
 
                 //便利分组

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

@@ -11,7 +11,6 @@ import com.usoftchina.bi.server.model.vo.configVo.LineConfigInfo;
 import com.usoftchina.bi.server.model.vo.dataVo.ChartsDataInfo;
 import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
 import com.usoftchina.bi.server.utils.ScreenUtil;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -38,8 +37,9 @@ public class ShowLineService {
     /*
     Line数据展示
      */
-    public RepEntity showLine(LineConfigInfo lineConfigInfo, String token, int dashId){
+    public RepEntity showLine(LineConfigInfo lineConfigInfo, String token, int dashId, String styleConfig){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
+        chartsDataInfo.setStyleConfig(styleConfig);
         TimeReture timeReture = new TimeReture();
         if (lineConfigInfo == null || "".equals(lineConfigInfo)){
             return new RepEntity(RepCode.Null);
@@ -138,6 +138,8 @@ public class ShowLineService {
             while (itGroup.hasNext()){
                 String groupByName = (String) itGroup.next();
                 List<String> groupsData = showChartsMapper.getGroups(groupByName,tableName, screenToColumnS, lineConfigInfo.getMaxCount()); //查询每个分组系列
+                if (groupsData.size() == 0)
+                    continue;
                 Iterator itGroupsData = groupsData.iterator();
                 if (groupsData.size() > lineConfigInfo.getMaxCount()){
                     chartsDataInfo.setTooMany(true);

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

@@ -35,8 +35,9 @@ public class ShowPieService {
     /*
     Pie数据展示
      */
-    public RepEntity showPie(PieConfigInfo pieConfigInfo, String token, int dashId){
+    public RepEntity showPie(PieConfigInfo pieConfigInfo, String token, int dashId, String styleConfig){
         ChartsDataInfo<PieSeries> chartsDataInfo = new ChartsDataInfo();
+        chartsDataInfo.setStyleConfig(styleConfig);
         TimeReture timeReture = new TimeReture();
         if (pieConfigInfo == null || "".equals(pieConfigInfo)){
             return new RepEntity(RepCode.Null);

+ 8 - 6
bi-server/src/main/java/com/usoftchina/bi/server/service/chart/ShowPopulationService.java

@@ -30,7 +30,7 @@ public class ShowPopulationService {
     @Autowired
     ChartsUtilService chartsUtilService;
 
-    public RepEntity showPopulation(PopulationInfo populationInfo, String token, int dashId) throws SQLException {
+    public RepEntity<PopAndIndDataInfo> showPopulation(PopulationInfo populationInfo, String token, int dashId) throws SQLException {
         if (populationInfo == null || "".equals(populationInfo)){
             return new RepEntity(RepCode.Null);
         }
@@ -84,23 +84,25 @@ public class ShowPopulationService {
 
         //无分组
         if (groupByList.size() == 0) {
-            Iterator operatorsList = operators.iterator();
+            Iterator<String> operatorsList = operators.iterator();
             while (operatorsList.hasNext()) {
-                String operator = String.valueOf(operatorsList.next()).toUpperCase();
-                if ("75TH".equals(operator)) {
+                String operator = operatorsList.next();
+                if ("75TH".equalsIgnoreCase(operator)) {
                     String calculation = "MEDIAN";
                     Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
                     calculation = "MAX";
                     Double max = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
                     value = showChartsMapper.getValue(tableName, columnName, calculation, median, max);
-                } else if ("25TH".equals(operator)) {
+                } else if ("25TH".equalsIgnoreCase(operator)) {
                     String calculation = "MEDIAN";
                     Double median = showChartsMapper.getColumnDev(tableName, columnName, calculation, screen);
                     calculation = "MIN";
                     Double min = showChartsMapper.getColumnDev(tableName, columnName, calculation, screenStr);
                     value = showChartsMapper.getValue(tableName, columnName, calculation, min, median);
-                } else if ("PERCENT".equals(operator)) {
+                } else if ("PERCENT".equalsIgnoreCase(operator)) {
                     value = 1.00;
+                } else if("dictinctCount".equalsIgnoreCase(operator)){
+                    value = showChartsMapper.getDistinctCountColumnData(tableName, columnName, operator, screenStr);
                 } else {
                     value = showChartsMapper.getColumnData(tableName, columnName, operator, screenStr);
                 }

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

@@ -35,8 +35,9 @@ public class ShowScatterService {
     /*
     Line数据展示
      */
-    public RepEntity showScatter(ScatterConfigInfo scatterConfigInfo, String token, int dashId){
+    public RepEntity showScatter(ScatterConfigInfo scatterConfigInfo, String token, int dashId, String styleConfig){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
+        chartsDataInfo.setStyleConfig(styleConfig);
         TimeReture timeReture = new TimeReture();
         if (scatterConfigInfo == null || "".equals(scatterConfigInfo)){
             return new RepEntity(RepCode.Null);

+ 4 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsService.java

@@ -51,6 +51,8 @@ public class DashboardsService {
     private ChartsConfigMapper chartsConfigMapper;
     @Autowired
     private MessageLogService messageLogService;
+    @Autowired
+    private DefaultDashboardService defaultDashboardService;
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DashboardsService.class);
 
@@ -174,6 +176,8 @@ public class DashboardsService {
         dashboardsMapper.delDashboards(id);
         //删除报表-图表关联关系
         dashboardsMapper.deleteDashboardChartRelation(id);
+        //删除报表-首页默认报表
+        defaultDashboardService.delete(userId, id);
         messageLogService.delete("报表", name, BaseContextHolder.getUserName(), null);
         return new RepEntity(RepCode.success);
     }

+ 27 - 29
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DashboardsToChartsUtilService.java

@@ -12,6 +12,7 @@ import com.usoftchina.bi.core.base.TestPage;
 import com.usoftchina.bi.server.model.po.TokenData;
 import com.usoftchina.bi.server.model.po.User;
 import com.usoftchina.bi.server.model.vo.configVo.*;
+import com.usoftchina.bi.server.model.vo.dataVo.PopAndIndDataInfo;
 import com.usoftchina.bi.server.service.chart.*;
 import com.usoftchina.bi.server.service.user.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -47,22 +48,15 @@ public class DashboardsToChartsUtilService {
     @Autowired
     private UserService userService;
 
-    private int chartId;
-
-    private Lock lock = new ReentrantLock();
-
     public RepEntity getChartsInDash(ChartsToDashInfo chartsToDashInfo, String token) throws SQLException {
         if (StringUtils.isEmpty(token)) {
             User user = userService.getUserById(chartsToDashInfo.getDashboardCreatorId()).getData();
             LoginInfo loginInfo = new LoginInfo(user.getUserName(), EncryUtil.decryptPassword(user.getPassWord()));
             token = userService.login(loginInfo).getData().getToken();
         }
-        lock.lock();
-        try {
-            chartId = chartsToDashInfo.getChartId();
-        } finally {
-            lock.unlock();
-        }
+
+        int chartId = chartsToDashInfo.getChartId();
+
         //拿到图表配置
         ChartsConfigToDash chartsConfigToDash = chartsConfigMapper.getChartConfigToDash(chartId);
         if (chartsConfigToDash == null || "".equals(chartsConfigToDash)){
@@ -70,6 +64,7 @@ public class DashboardsToChartsUtilService {
         }
         String chartType = chartsConfigToDash.getChartType();
         String fetchConfig = chartsConfigToDash.getFetchConfig();
+        String styleConfig = chartsConfigToDash.getStyleConfig();
         if (fetchConfig == null || "".equals(fetchConfig)){
             return new RepEntity(RepCode.Null);
         }
@@ -77,27 +72,26 @@ public class DashboardsToChartsUtilService {
         //判断图表类型
         List<Screen> filters = chartsToDashInfo.getFilters();
         if ("Pie".equals(chartType)){
-            return getPie(fetchConfig, token, filters);
-
+            return getPie(fetchConfig, token, filters, chartId, styleConfig);
         }else if ("Histogram".equals(chartType)){
-            return getHistogram(fetchConfig, token, filters);
+            return getHistogram(fetchConfig, token, filters, chartId, styleConfig);
 
         }else if ("Line".equals(chartType)){
-            return getLine(fetchConfig, token, filters);
+            return getLine(fetchConfig, token, filters, chartId, styleConfig);
 
         }else if ("population".equals(chartType)){
-            return getPopulation(fetchConfig, token, filters);
+            return getPopulation(fetchConfig, token, filters, chartId, styleConfig);
 
         }else if ("individual".equals(chartType)){
-            return getIndividual(fetchConfig, token, filters, chartsToDashInfo.getTestPage());
+            return getIndividual(fetchConfig, token, filters, chartsToDashInfo.getTestPage(), chartId, styleConfig);
 
         }else if("scatter".equals(chartType)){
-            return getScatter(fetchConfig, token, filters);
+            return getScatter(fetchConfig, token, filters, chartId, styleConfig);
         }
         return new RepEntity(RepCode.success);
     }
 
-    public RepEntity getHistogram(String fetchConfig, String token, List<Screen> filters){
+    public RepEntity getHistogram(String fetchConfig, String token, List<Screen> filters, int chartId, String styleConfig){
         HistogramConfigInfo histogramConfigInfo = new HistogramConfigInfo();
         try {
             histogramConfigInfo = objectMapper.readValue(fetchConfig,HistogramConfigInfo.class);
@@ -105,10 +99,10 @@ public class DashboardsToChartsUtilService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return showHistogramService.showHistogram(histogramConfigInfo, token, chartId);
+        return showHistogramService.showHistogram(histogramConfigInfo, token, chartId, styleConfig);
     }
 
-    public RepEntity getScatter(String fetchConfig, String token, List<Screen> filters){
+    public RepEntity getScatter(String fetchConfig, String token, List<Screen> filters, int chartId, String styleConfig){
             ScatterConfigInfo scatterConfigInfo = new ScatterConfigInfo();
             try {
                 scatterConfigInfo = objectMapper.readValue(fetchConfig,ScatterConfigInfo.class);
@@ -116,10 +110,10 @@ public class DashboardsToChartsUtilService {
             } catch (Exception e) {
                 e.printStackTrace();
             }
-            return showScatterService.showScatter(scatterConfigInfo, token, chartId);
+            return showScatterService.showScatter(scatterConfigInfo, token, chartId, styleConfig);
     }
 
-    public RepEntity getLine(String fetchConfig, String token, List<Screen> filters){
+    public RepEntity getLine(String fetchConfig, String token, List<Screen> filters, int chartId, String styleConfig){
         LineConfigInfo lineConfigInfo = new LineConfigInfo();
         try {
             lineConfigInfo = objectMapper.readValue(fetchConfig,LineConfigInfo.class);
@@ -127,10 +121,10 @@ public class DashboardsToChartsUtilService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return showLineService.showLine(lineConfigInfo, token, chartId);
+        return showLineService.showLine(lineConfigInfo, token, chartId, styleConfig);
     }
 
-    public RepEntity getPopulation(String fetchConfig, String token, List<Screen> filters) throws SQLException {
+    public RepEntity getPopulation(String fetchConfig, String token, List<Screen> filters, int chartId, String styleConfig) throws SQLException {
         PopulationInfo populationInfo = new PopulationInfo();
         try {
             populationInfo = objectMapper.readValue(fetchConfig,PopulationInfo.class);
@@ -138,10 +132,12 @@ public class DashboardsToChartsUtilService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return showPopulationService.showPopulation(populationInfo, token, chartId);
+        RepEntity<PopAndIndDataInfo> repEntity = showPopulationService.showPopulation(populationInfo, token, chartId);
+        repEntity.getData().setStyleConfig(styleConfig);
+        return repEntity;
     }
 
-    public RepEntity getIndividual(String fetchConfig, String token, List<Screen> filters, TestPage testPage) throws SQLException {
+    public RepEntity getIndividual(String fetchConfig, String token, List<Screen> filters, TestPage testPage, int chartId, String styleConfig) throws SQLException {
         IndividualConfigInfo individualConfigInfo = new IndividualConfigInfo();
         try {
             individualConfigInfo = objectMapper.readValue(fetchConfig,IndividualConfigInfo.class);
@@ -150,10 +146,12 @@ public class DashboardsToChartsUtilService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return showIndividualService.showIndividual(individualConfigInfo, token, chartId);
+        RepEntity<PopAndIndDataInfo> repEntity = showIndividualService.showIndividual(individualConfigInfo, token, chartId);
+        repEntity.getData().setStyleConfig(styleConfig);
+        return repEntity;
     }
 
-    public RepEntity getPie(String fetchConfig, String token, List<Screen> filters){
+    public RepEntity getPie(String fetchConfig, String token, List<Screen> filters, int chartId, String styleConfig){
         PieConfigInfo pieConfigInfo = new PieConfigInfo();
         try {
             pieConfigInfo = objectMapper.readValue(fetchConfig,PieConfigInfo.class);
@@ -161,7 +159,7 @@ public class DashboardsToChartsUtilService {
         } catch (Exception e) {
             e.printStackTrace();
         }
-        return showPieService.showPie(pieConfigInfo, token, chartId);
+        return showPieService.showPie(pieConfigInfo, token, chartId, styleConfig);
     }
 
 }

+ 34 - 0
bi-server/src/main/java/com/usoftchina/bi/server/service/dashboard/DefaultDashboardService.java

@@ -0,0 +1,34 @@
+package com.usoftchina.bi.server.service.dashboard;
+
+import com.usoftchina.bi.server.dao.dashboard.DefaultDashboardMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+/**
+ * @Author chenwei
+ * @Date 2019-05-31
+ */
+@Service
+public class DefaultDashboardService {
+
+    @Autowired
+    private DefaultDashboardMapper defaultDashboardMapper;
+
+    public Map<String, String> read(int userId) {
+        return defaultDashboardMapper.selectDashboardIdByUserId(userId);
+    }
+
+    public void save(int userId, int dashboardId) {
+        //先删除用户已设置的默认报表
+        defaultDashboardMapper.deleteByUserId(userId);
+
+        defaultDashboardMapper.save(userId, dashboardId);
+    }
+
+    public void delete(int userId, int dashboardId) {
+        defaultDashboardMapper.delete(userId, dashboardId);
+    }
+
+}

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

@@ -30,7 +30,7 @@ public class SynchronizeEmpInfo {
                        + "WHEN MATCHED THEN "
                        + "  UPDATE  SET TARGETTABLE.BU_CLASS = SOURCETABLE.EM_CLASS, TARGETTABLE.PASS_WORD = SOURCETABLE.EM_PASSWORD "
                        + "WHEN NOT MATCHED THEN"
-                       + "  INSERT (BU_ID,BU_NAME,BU_DEPARTMENT,BU_POST,BU_USER_GROUP,USER_NAME,PASS_WORD,BU_ROLE,CREATE_DATE,UPDATA_DATE,USER_TOKEN,BU_PHONE,BU_CLASS) "
+                       + "  INSERT (BU_ID,BU_NAME,BU_POST,BU_DEPARTMENT,BU_USER_GROUP,USER_NAME,PASS_WORD,BU_ROLE,CREATE_DATE,UPDATA_DATE,USER_TOKEN,BU_PHONE,BU_CLASS) "
                        + "  VALUES (SOURCETABLE.EM_ID,SOURCETABLE.EM_NAME,SOURCETABLE.EM_DEFAULTHSNAME,SOURCETABLE.EM_DEPART,NULL,SOURCETABLE.EM_CODE,SOURCETABLE.EM_PASSWORD,SOURCETABLE.EM_TYPE,SYSDATE,NULL,NULL,SOURCETABLE.EM_MOBILE,SOURCETABLE.EM_CLASS)";
 
     @Scheduled(cron = "0 0 1 * * ?")

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

@@ -259,8 +259,7 @@ public class UserService {
 
     private void userGroupLog(List<Integer> userList, String username, String groupName, String type){
         //记录LOG
-        List<String> userIdsList = userList.stream().map(x -> x + "").collect(Collectors.toList());
-        String userIds = String.join(",", userIdsList);
+        String userIds = userList.stream().map(Object::toString).collect(Collectors.joining(","));
         String userNames = userMapper.getUserByIds(userIds);
         String[] userNameArray = userNames.split(",");
         StringBuilder sb = new StringBuilder();

File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.5ff87b47.js


File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.c10dd238.js


File diff suppressed because it is too large
+ 0 - 0
bi-server/src/main/resources/static/index.e49f5545.css


+ 2 - 2
bi-server/src/main/resources/static/index.html

@@ -4,8 +4,8 @@
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <title>BI 商业智能平台</title>
-<link rel="shortcut icon" href="favicon.png"><link href="index.47161842.css" rel="stylesheet"></head>
+<link rel="shortcut icon" href="favicon.png"><link href="index.e49f5545.css" rel="stylesheet"></head>
 <body>
   <div id="root"></div>
-<script type="text/javascript" src="index.5ff87b47.js"></script></body>
+<script type="text/javascript" src="index.c10dd238.js"></script></body>
 </html>

Some files were not shown because too many files changed in this diff