| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- package com.server;
- import com.dao.ChartsConfigMapper;
- import com.fasterxml.jackson.databind.ObjectMapper;
- import com.model.bo.Screen;
- import com.model.po.ChartsConfigToDash;
- import com.model.pojo.RepCode;
- import com.model.pojo.RepEntity;
- import com.model.vo.configVo.*;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.sql.SQLException;
- import java.util.List;
- /*
- 看板中调用生成图表
- */
- @Service
- public class DashboardsToChartsUtilService {
- @Autowired
- ChartsConfigMapper chartsConfigMapper;
- @Autowired
- ObjectMapper objectMapper;
- @Autowired
- ShowHistogramService showHistogramService;
- @Autowired
- ShowIndividualService showIndividualService;
- @Autowired
- ShowLineService showLineService;
- @Autowired
- ShowPieService showPieService;
- @Autowired
- ShowPopulationService showPopulationService;
- @Autowired
- ShowScatterService showScatterService;
- public RepEntity getChartsInDash(ChartsToDashInfo chartsToDashInfo, String token) throws SQLException {
- int chartId = chartsToDashInfo.getDashCreateId();
- ChartsConfigToDash chartsConfigToDash = chartsConfigMapper.getChartConfigToDash(chartId);
- if (chartsConfigToDash == null || "".equals(chartsConfigToDash)){
- return new RepEntity(RepCode.Null);
- }
- String chartType = chartsConfigToDash.getChartType();
- String fetchConfig = chartsConfigToDash.getFetchConfig();
- List<Screen> filters = chartsToDashInfo.getFilters();
- if ("Pie".equals(chartType)){
- return getPie(fetchConfig, token, filters);
- }else if ("Histogram".equals(chartType)){
- return getHistogram(fetchConfig, token, filters);
- }else if ("Line".equals(chartType)){
- return getLine(fetchConfig, token, filters);
- }else if ("population".equals(chartType)){
- return getPopulation(fetchConfig, token, filters);
- }else if ("individual".equals(chartType)){
- getIndividual(fetchConfig, token, filters);
- }else if("scatter".equals(chartType)){
- return getScatter(fetchConfig, token, filters);
- }
- return new RepEntity(RepCode.success);
- }
- public RepEntity getHistogram(String fetchConfig, String token, List<Screen> filters){
- HistogramConfigInfo histogramConfigInfo = new HistogramConfigInfo();
- try {
- histogramConfigInfo = objectMapper.readValue(fetchConfig,HistogramConfigInfo.class);
- histogramConfigInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showHistogramService.showHistogram(histogramConfigInfo, token);
- }
- public RepEntity getScatter(String fetchConfig, String token, List<Screen> filters){
- ScatterConfigInfo scatterConfigInfo = new ScatterConfigInfo();
- try {
- System.out.println(fetchConfig);
- scatterConfigInfo = objectMapper.readValue(fetchConfig,ScatterConfigInfo.class);
- scatterConfigInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showScatterService.showScatter(scatterConfigInfo, token);
- }
- public RepEntity getLine(String fetchConfig, String token, List<Screen> filters){
- LineConfigInfo lineConfigInfo = new LineConfigInfo();
- try {
- System.out.println(fetchConfig);
- lineConfigInfo = objectMapper.readValue(fetchConfig,LineConfigInfo.class);
- lineConfigInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showLineService.showLine(lineConfigInfo, token);
- }
- public RepEntity getPopulation(String fetchConfig, String token, List<Screen> filters) throws SQLException {
- PopulationInfo populationInfo = new PopulationInfo();
- try {
- System.out.println(fetchConfig);
- populationInfo = objectMapper.readValue(fetchConfig,PopulationInfo.class);
- populationInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showPopulationService.showPopulation(populationInfo, token);
- }
- public RepEntity getIndividual(String fetchConfig, String token, List<Screen> filters) throws SQLException {
- IndividualConfigInfo individualConfigInfo = new IndividualConfigInfo();
- try {
- System.out.println(fetchConfig);
- individualConfigInfo = objectMapper.readValue(fetchConfig,IndividualConfigInfo.class);
- individualConfigInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showIndividualService.showIndividual(individualConfigInfo, token);
- }
- public RepEntity getPie(String fetchConfig, String token, List<Screen> filters){
- PieConfigInfo pieConfigInfo = new PieConfigInfo();
- try {
- System.out.println(fetchConfig);
- pieConfigInfo = objectMapper.readValue(fetchConfig,PieConfigInfo.class);
- pieConfigInfo.setFilters(filters);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return showPieService.showPie(pieConfigInfo, token);
- }
- }
|