Ver código fonte

增加ehcache缓存应用到柱状图取数

chenw 6 anos atrás
pai
commit
e71ac9eeff

+ 10 - 0
bi-server/pom.xml

@@ -45,6 +45,16 @@
       <artifactId>java-jwt</artifactId>
     </dependency>
 
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-cache</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>net.sf.ehcache</groupId>
+      <artifactId>ehcache</artifactId>
+    </dependency>
+
     <!--<dependency>
       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tomcat</artifactId>

+ 1 - 0
bi-server/src/main/java/com/usoftchina/bi/server/Application.java

@@ -16,6 +16,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 @Import({DynamicDataSourceRegister.class})
 @EnableScheduling
 @ComponentScan("com.usoftchina.bi")
+@EnableCaching
 public class Application {
 
     public static void main(String[] args) {

+ 7 - 3
bi-server/src/main/java/com/usoftchina/bi/server/model/vo/configVo/HistogramConfigInfo.java

@@ -1,6 +1,8 @@
 package com.usoftchina.bi.server.model.vo.configVo;
 
 
+import com.alibaba.fastjson.JSON;
+import com.usoftchina.bi.core.utils.JsonUtils;
 import com.usoftchina.bi.server.model.bo.Column;
 import com.usoftchina.bi.server.model.bo.Screen;
 
@@ -69,9 +71,11 @@ public class HistogramConfigInfo {
     public String toString() {
         return "HistogramConfigInfo{" +
                 "id=" + id +
-                ", xAxis=" + xAxis +
-                ", yAxis=" + yAxis +
-                ", groups=" + groups +
+                ", xAxis=" + xAxis.toString() +
+                ", yAxis=" + yAxis.toString() +
+                ", groups=" + JSON.toJSONString(groups) +
+                ", filters=" + JSON.toJSONString(filters) +
+                ", maxCount=" + maxCount +
                 '}';
     }
 }

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

@@ -12,6 +12,7 @@ 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.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Repository;
 
 import java.util.ArrayList;
@@ -38,6 +39,7 @@ public class ShowHistogramService {
     /*
     柱状图数据展示
      */
+    @Cacheable(value = "Histogram", key = "#histogramConfigInfo.toString()+#dashId")
     public RepEntity showHistogram(HistogramConfigInfo histogramConfigInfo, String token, int dashId){
         ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
         TimeReture timeReture = new TimeReture();

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

@@ -19,6 +19,7 @@ import com.usoftchina.bi.server.model.vo.configVo.UserGroupSetInfo;
 import com.usoftchina.bi.server.service.common.MessageLogService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -142,6 +143,7 @@ public class UserService {
     /*
     查询用户列表
      */
+    @Cacheable(value = "userList")
     public RepEntity getUserList(){
         List<User> userList = userMapper.getUserList();
         return new RepEntity(RepCode.success, userList);