Browse Source

1.看板生成图表
2.看板公共参数

heqinwei 7 years ago
parent
commit
23e74c529b

+ 1 - 1
src/main/java/com/controller/DataConnectorController.java

@@ -36,7 +36,7 @@ public class DataConnectorController {
     public RepEntity inputDataConnector(@RequestHeader String token, @RequestBody DataConnectorInfo body) {
         System.out.println("-----------");
         System.out.println(body);
-        return dataConnectorService.setDataConnector(body);
+        return dataConnectorService.setDataConnector(token,body);
     }
 
     /*

+ 39 - 0
src/main/java/com/controller/RecodeController.java

@@ -0,0 +1,39 @@
+package com.controller;
+
+import com.model.pojo.RepCode;
+import com.model.pojo.RepEntity;
+import com.model.vo.configVo.RecordInfo;
+import com.server.ChartsUtilService;
+import com.server.RecodeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class RecodeController {
+    @Autowired
+    RecodeService recodeService;
+    @Autowired
+    ChartsUtilService chartsUtilService;
+
+    @CheckToken
+    @RequestMapping("/getChartRecode")
+    public RepEntity getChartRecode(@RequestHeader String token){
+        return recodeService.getChartRecode(token);
+    }
+
+    @CheckToken
+    @RequestMapping("/getDashRecode")
+    public RepEntity getDashRecode(@RequestHeader String token){
+        return recodeService.getDashRecode(token);
+    }
+
+    @CheckToken
+    @RequestMapping("/addRecord")
+    public RepEntity inputRecord(@RequestHeader String token,@RequestBody RecordInfo body){
+        chartsUtilService.inputRecord(token, body);
+        return new RepEntity(RepCode.success);
+    }
+}

+ 1 - 1
src/main/java/com/dao/ChartsConfigMapper.java

@@ -17,7 +17,7 @@ import java.util.Map;
 public interface ChartsConfigMapper {
 
     @Insert("insert into bi_charts(id,CHART_NAME,CHART_TYPE,BD_DATA_ID,CHART_CONFIG,GROUP_BY,ACCESS_AUTHORITY,UPDATE_AUTHORITY,BC_CHARTS_GROUP,CHART_DESCRIBES,BC_CHART_STYLE," +
-            "create_by,create_date, bc_charts_option, create_Id, BC_FETCHCONFIG) " +
+            "create_by,create_date, bc_charts_option, create_id, BC_FETCHCONFIG) " +
             "VALUES (#{chartId},#{chartName},#{chartType}, #{dataId}, #{chartConfig}, #{groupBy}, #{accessAuthority}, #{updateAuthority}, #{chartsGroup}," +
             "#{describes},#{style}, #{createBy},to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'),  #{chartOption}, #{createId}, #{fetchConfig})" )
 //    @Options(useGeneratedKeys=false, keyProperty = "chartId",keyColumn = "id")

+ 4 - 4
src/main/java/com/dao/DataConnectorMapper.java

@@ -60,8 +60,8 @@ public interface DataConnectorMapper {
     /*
     插入数据源配置
      */
-    @Insert("INSERT INTO bi_data_connectors(id,data_name,data_note,data_tag,con_type,LOAD_OBJECT,DB_CONFIG,columns_config,used_number,create_by,create_date, table_name, BD_GROUP) " +
-            "VALUES (#{dataId},#{dataName}, #{note}, #{dataTag}, #{type}, #{loadObject}, #{dbConfig},#{columnConfig}, #{usedNumber},#{createBy}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{tableName}, #{connectorGroup})")
+    @Insert("INSERT INTO bi_data_connectors(id,data_name,data_note,data_tag,con_type,LOAD_OBJECT,DB_CONFIG,columns_config,used_number,create_by,create_date, table_name, BD_GROUP, create_id) " +
+            "VALUES (#{dataId},#{dataName}, #{note}, #{dataTag}, #{type}, #{loadObject}, #{dbConfig},#{columnConfig}, #{usedNumber},#{createBy}, to_date(#{createDate},'YYYY-MM-DD hh24:mi:ss'), #{tableName}, #{connectorGroup},#{createId})")
     @SelectKey(before=true,keyProperty="dataId",resultType=int.class,statement="SELECT BI_DASHBOARDS_squence.nextval from dual",keyColumn = "id")
     void insertDataConnector(DataConnector dataConnector);
 
@@ -178,8 +178,8 @@ public interface DataConnectorMapper {
     /*
     创建数据源分组
      */
-    @Insert("insert into bi_base_group_by(bb_id, bb_group_name, bb_index, bb_father_id, create_by, create_date)" +
-            "values(#{id}, #{groupName}, #{groupIndex}, #{fatherId}, #{createBy}, to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))")
+    @Insert("insert into bi_base_group_by(bb_id, bb_group_name, bb_index, bb_father_id, create_date)" +
+            "values(#{id}, #{groupName}, #{groupIndex}, #{fatherId}, to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))")
     @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_base_group_by_squence.nextval from dual",keyColumn = "bb_id")
     void setConnectorGroup(GroupInfo group);
 

+ 64 - 0
src/main/java/com/dao/RecordMapper.java

@@ -0,0 +1,64 @@
+package com.dao;
+
+import com.model.po.ChartConfigList;
+import com.model.po.Dashboards;
+import org.apache.ibatis.annotations.*;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+@Mapper
+@Repository
+public interface RecordMapper {
+    @Select("select count(*) from bi_record where bre_type = #{type} and bre_user_id = #{userId}")
+    int getCount(@Param("type") String type, @Param("userId") int userId);
+
+    /*
+    插入
+     */
+    @Insert("insert into bi_record(bre_id, bre_type, bre_user_id, re_date, item_id) " +
+            "values(#{id}, #{type}, #{userId}, to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'), #{itemId})")
+    @SelectKey(before=true,keyProperty="id",resultType=Integer.class,statement="SELECT bi_record_squence.nextval from dual",keyColumn = "bre_id")
+    void inputRecord(@Param("type") String type, @Param("userId") int userId, @Param("itemId") int itemId);
+
+    /*
+    删除
+     */
+    @Delete("delete from bi_record where bre_id in (select bre_id from" +
+            "(" +
+            "select * from BI_RECORD where bre_type = #{type} and bre_user_id = #{userId} order by RE_DATE asc" +
+            ") where rownum <= 1)")
+    void deleteRecord(@Param("type") String type, @Param("userId") int userId);
+
+    /*
+    查询最新List数据
+     */
+    @Select("select item_id from BI_RECORD where bre_type = #{type} and bre_user_id = #{userId} order by RE_DATE desc")
+    List<Integer> getListId(@Param("type") String type, @Param("userId") int userId);
+
+    /*
+     更新
+      */
+    @Update("update bi_record set re_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') " +
+            "where bre_type = #{type} and item_id = #{itemId}  ")
+    void updateRecord(@Param("type") String type, @Param("itemId") int itemId);
+
+    /*
+    查询图表10条纪录
+     */
+    @Select("select id as chartId, chart_name as chartName, chart_type as chartType, create_by as createBy, create_date as createDate, BC_FILTERS as filters" +
+            "  ,bc_filters as filters, CHART_DESCRIBES as describes, bc_charts_group as chartsGroup, bc_charts_option as chartOption ,bd_data_id as dataId, create_id as createId " +
+            "from bi_charts left join BI_RECORD on id = item_id where bre_type = '0' and " +
+            "bre_user_id = #{userId} order by RE_DATE desc")
+    List<ChartConfigList> chartsRecode(int userId);
+
+    /*
+    查询图表10条纪录
+     */
+    @Select("select id, bd_note as bdNote, bd_name as bdName, CONFIGURATION as bdConfiguration, CREATE_BY as createBy, create_id as createId, " +
+            "CREATE_DATE as createDate, BD_THUMBNAIL as thumbnail from BI_DASHBOARDS left join " +
+            "BI_RECORD on id = item_id where bre_type = '1' and " +
+            "bre_user_id = #{userId} order by RE_DATE desc")
+    List<Dashboards> DashRecode(int userId);
+
+}

+ 1 - 1
src/main/java/com/dao/ShowChartsMapper.java

@@ -157,7 +157,7 @@ public interface ShowChartsMapper {
     /*
     查询筛选列信息
      */
-    @Select("select distinct ${columnName} from ${tableName}")
+    @Select("select distinct ${columnName} from ${tableName} where rownum <= 20")
     List<Object> getScreenData(@Param("columnName") String columnName, @Param("tableName") String tableName);
 
 }

+ 2 - 2
src/main/java/com/dao/StrategysBdMapper.java

@@ -14,8 +14,8 @@ public interface StrategysBdMapper {
     /*
    保存数据源策略
     */
-    @Insert("insert into bi_db_strategys(bs_id, bs_db_id, bs_rule,rule_str, bs_name, createBy, create_date) values" +
-            "(#{id}, #{tarId}, #{rule}, #{ruleStr}, #{name}, #{createBy}, " +
+    @Insert("insert into bi_db_strategys(bs_id, bs_db_id, bs_rule,rule_str, bs_name, create_date) values" +
+            "(#{id}, #{tarId}, #{rule}, #{ruleStr}, #{name}, " +
             "to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))")
     @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_db_strategys_squence.nextval from dual",keyColumn = "bs_id")
     void addStrategys(Strategys strategys);

+ 2 - 2
src/main/java/com/dao/StrategysChartMapper.java

@@ -14,8 +14,8 @@ public interface StrategysChartMapper {
     /*
    保存数据源策略
     */
-    @Insert("insert into bi_chart_strategys(bc_id, bc_chart_id, bc_rule, rule_str, bc_name, createBy, create_date) values" +
-            "(#{id}, #{tarId}, #{rule}, #{ruleStr}, #{name}, #{createBy}, " +
+    @Insert("insert into bi_chart_strategys(bc_id, bc_chart_id, bc_rule, rule_str, bc_name, create_date) values" +
+            "(#{id}, #{tarId}, #{rule}, #{ruleStr}, #{name}, " +
             "to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss'))")
     @SelectKey(before=true,keyProperty="id",resultType=int.class,statement="SELECT bi_chart_strategys_squence.nextval from dual",keyColumn = "bc_id")
     void addStrategys(Strategys strategys);

+ 8 - 0
src/main/java/com/model/vo/configVo/DataConnectorInfo.java

@@ -17,7 +17,15 @@ public class DataConnectorInfo<T> {
     private int usedNumber;
     private int connectorGroup;
     private String createBy;
+    private int createId;
 
+    public int getCreateId() {
+        return createId;
+    }
+
+    public void setCreateId(int createId) {
+        this.createId = createId;
+    }
 
     public int getDataId() {
         return dataId;

+ 22 - 0
src/main/java/com/model/vo/configVo/RecordInfo.java

@@ -0,0 +1,22 @@
+package com.model.vo.configVo;
+
+public class RecordInfo {
+    private int tarId;
+    private String type;
+
+    public int getTarId() {
+        return tarId;
+    }
+
+    public void setTarId(int tarId) {
+        this.tarId = tarId;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+}

+ 6 - 0
src/main/java/com/server/ChartsConfigService.java

@@ -77,6 +77,9 @@ public class ChartsConfigService {
             e.printStackTrace();
         }
 
+        if ("".equals(style) || style == null){
+            chartConfig.setStyle("");
+        }
 
         chartConfig.setGroupBy(groupBy);
         chartConfig.setAccessAuthority(accessAuthority);
@@ -93,6 +96,9 @@ public class ChartsConfigService {
             chartConfig.setChartOption("");
             System.out.println("=======11111==================");
         }
+        if (chartConfig.getFetchConfig() == null || "".equals(chartConfig.getFetchConfig())){
+            chartConfig.setFetchConfig("");
+        }
 
         chartsConfigMapper.insertCharts(chartConfig);
         int id = chartConfig.getChartId();

+ 23 - 5
src/main/java/com/server/ChartsUtilService.java

@@ -1,9 +1,7 @@
 package com.server;
 
-import com.dao.ChartsConfigMapper;
-import com.dao.DataConnectorMapper;
-import com.dao.StrategysBdMapper;
-import com.dao.StrategysChartMapper;
+import com.dao.*;
+import com.model.vo.configVo.RecordInfo;
 import com.util.GetTokenData;
 import org.apache.ibatis.binding.BindingException;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +24,8 @@ public class ChartsUtilService {
     StrategysBdMapper strategysBdMapper;
     @Autowired
     StrategysChartMapper strategysChartMapper;
+    @Autowired
+    RecordMapper recordMapper;
 
     public String getSqlStr(String token, int id) {
         Map<String, String> resultMap = getTokenData.getTokenData(token);
@@ -101,6 +101,24 @@ public class ChartsUtilService {
     }
 
     /*
-    判断图表是否有权限
+    浏览记录
      */
+    public void inputRecord(String token, RecordInfo recordInfo){
+        int tarId = recordInfo.getTarId();
+        String type = recordInfo.getType();
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resultMap.get("id"));
+        int count = recordMapper.getCount(type, userId);
+
+
+        List<Integer> integerList = recordMapper.getListId(type, userId);
+        if (integerList.contains(tarId)){
+            recordMapper.updateRecord(type, tarId);
+        }else {
+            if (count >= 10) {
+                recordMapper.deleteRecord(type, userId);
+            }
+            recordMapper.inputRecord(type, userId, tarId);
+        }
+    }
 }

+ 2 - 0
src/main/java/com/server/DashboardsService.java

@@ -30,6 +30,8 @@ public class DashboardsService {
     GetTokenData getTokenData;
     @Autowired
     UserMapper userMapper;
+    @Autowired
+    ChartsUtilService chartsUtilService;
 
     /*
     保存看板

+ 4 - 1
src/main/java/com/server/DashboardsToChartsUtilService.java

@@ -43,6 +43,9 @@ public class DashboardsToChartsUtilService {
         }
         String chartType = chartsConfigToDash.getChartType();
         String fetchConfig = chartsConfigToDash.getFetchConfig();
+        if (fetchConfig == null || "".equals(fetchConfig)){
+            return new RepEntity(RepCode.Null);
+        }
         List<Screen> filters = chartsToDashInfo.getFilters();
         if ("Pie".equals(chartType)){
             return getPie(fetchConfig, token, filters);
@@ -57,7 +60,7 @@ public class DashboardsToChartsUtilService {
             return getPopulation(fetchConfig, token, filters);
 
         }else if ("individual".equals(chartType)){
-            getIndividual(fetchConfig, token, filters);
+            return getIndividual(fetchConfig, token, filters);
 
         }else if("scatter".equals(chartType)){
             return getScatter(fetchConfig, token, filters);

+ 9 - 5
src/main/java/com/server/DataConnectorService.java

@@ -64,7 +64,11 @@ public class DataConnectorService {
     /*
     保存数据源
      */
-    public RepEntity setDataConnector(DataConnectorInfo dataConnectorInfo){
+    public RepEntity setDataConnector(String token, DataConnectorInfo dataConnectorInfo){
+
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        int id = Integer.parseInt(resultMap.get("id"));
+        String userName = resultMap.get("name");
 
         if (dataConnectorInfo == null || "".equals(dataConnectorInfo)){
             return new RepEntity(RepCode.Null);
@@ -117,9 +121,11 @@ public class DataConnectorService {
 
         System.out.println(dataConnector);
 
+        dataConnector.setCreateBy(userName);
+        dataConnector.setCreateId(id);
         dataConnectorMapper.insertDataConnector(dataConnector);
-        int id = dataConnector.getDataId();
-        return new RepEntity(RepCode.success,id);
+        int dataId = dataConnector.getDataId();
+        return new RepEntity(RepCode.success,dataId);
     }
 
     //查看数据源列表
@@ -128,8 +134,6 @@ public class DataConnectorService {
         String id = resultMap.get("id");
         System.out.println("id:" + id);
         List<DataConnectorList> listConnector = dataConnectorMapper.getDataConnectorList(Integer.parseInt(id));
-//        listConnector.addAll(dataConnectorMapper.getDataConnectorUList(Integer.parseInt(id)));
-//        listConnector.addAll(dataConnectorMapper.getDataConnectorUgList(Integer.parseInt(id)));
         List<DataConnectorList> listConnectors = new ArrayList<>();
         Iterator isList = listConnector.iterator();
         while (isList.hasNext()){

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

@@ -27,7 +27,7 @@ public class ImplementSqlService {
     执行数据源
      */
     public RepEntity implementSql(ToSql toSql) {
-        String sqlStr = toSql.getStrSql();
+        String sqlStr = "select * from (" + toSql.getStrSql() + ") where rownum <=100";
         System.out.println(sqlStr);
         if ("".equals(sqlStr) || sqlStr == null) {
             return new RepEntity(RepCode.ChartsNameNull);

+ 30 - 0
src/main/java/com/server/RecodeService.java

@@ -0,0 +1,30 @@
+package com.server;
+
+import com.dao.RecordMapper;
+import com.model.pojo.RepCode;
+import com.model.pojo.RepEntity;
+import com.util.GetTokenData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Service
+public class RecodeService {
+    @Autowired
+    RecordMapper recordMapper;
+    @Autowired
+    GetTokenData getTokenData;
+
+    public RepEntity getChartRecode(String token){
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resultMap.get("id"));
+        return new RepEntity(RepCode.success, recordMapper.chartsRecode(userId));
+    }
+
+    public RepEntity getDashRecode(String token){
+        Map<String, String> resultMap = getTokenData.getTokenData(token);
+        int userId = Integer.parseInt(resultMap.get("id"));
+        return new RepEntity(RepCode.success, recordMapper.DashRecode(userId));
+    }
+}

+ 3 - 0
src/main/java/com/server/ShowHistogramService.java

@@ -53,6 +53,9 @@ public class ShowHistogramService {
         int id = histogramConfigInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         chartsDataInfo.setChartsConfig(config);

+ 3 - 0
src/main/java/com/server/ShowIndividualService.java

@@ -45,6 +45,9 @@ public class ShowIndividualService {
         int id = individualConfigInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         popAndIndDataInfo.setChartsConfig(config);

+ 3 - 0
src/main/java/com/server/ShowLineService.java

@@ -45,6 +45,9 @@ public class ShowLineService {
         int id = lineConfigInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         chartsDataInfo.setChartsConfig(config);

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

@@ -45,6 +45,9 @@ public class ShowPieService {
         int id = pieConfigInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         chartsDataInfo.setChartsConfig(config);

+ 3 - 0
src/main/java/com/server/ShowPopulationService.java

@@ -39,6 +39,9 @@ public class ShowPopulationService {
         int id = populationInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         popAndIndDataInfo.setChartsConfig(config);

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

@@ -45,6 +45,9 @@ public class ShowScatterService {
         int id = scatterConfigInfo.getId();
         //获取列配置
         ChartsColumnConfig chartsColumn = chartsConfigMapper.getChartsColumn(id);
+        if (chartsColumn == null || "".equals(chartsColumn)){
+            return new RepEntity(RepCode.Null);
+        }
         String style = chartsColumn.getChartStyle();
         String config = chartsColumn.getChartConfig();
         chartsDataInfo.setChartsConfig(config);

+ 1 - 0
src/main/java/com/util/ContextUtil.java

@@ -16,6 +16,7 @@ public class ContextUtil {
 		synchronized (ContextUtil.class) {
 			while (applicationContext == null) {
 				try {
+					System.out.println("1111111111");
 					ContextUtil.class.wait(6000);
 				} catch (InterruptedException ex) {
 				}

+ 3 - 2
src/main/resources/application.properties

@@ -64,6 +64,7 @@ pagehelper-params=count=countSql
 #mybatis.mapperLocations=classpath:config/dao/*.xml
 
 
-#server.port=8011
+server.port=8011
 #server.session.timeout=10
-server.tomcat.uri-encoding=UTF-8
+server.tomcat.uri-encoding=UTF-8
+hystrix.command.default.execution.timeout.enabled=false