|
@@ -2,6 +2,7 @@ package com.usoftchina.bi.server.service.chart;
|
|
|
|
|
|
|
|
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.core.jdbc.DynamicDataSourceContextHolder;
|
|
|
import com.usoftchina.bi.core.utils.CalculationJudgeUtil;
|
|
import com.usoftchina.bi.core.utils.CalculationJudgeUtil;
|
|
|
import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
|
|
import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
|
|
|
import com.usoftchina.bi.server.dao.chart.ShowChartsMapper;
|
|
import com.usoftchina.bi.server.dao.chart.ShowChartsMapper;
|
|
@@ -35,6 +36,8 @@ public class ShowIndicatorService {
|
|
|
private ChartsConfigMapper chartsConfigMapper;
|
|
private ChartsConfigMapper chartsConfigMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ScreenUtil screenUtil;
|
|
private ScreenUtil screenUtil;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GetChartsDataUtilService getChartsDataUtilService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 指标图
|
|
* 指标图
|
|
@@ -67,10 +70,23 @@ public class ShowIndicatorService {
|
|
|
}
|
|
}
|
|
|
condition += "," + String.join(",", indicatorConfigInfo.getOtherColumn());
|
|
condition += "," + String.join(",", indicatorConfigInfo.getOtherColumn());
|
|
|
}
|
|
}
|
|
|
- List<Map<String, Object>> indicatorSeriesMapList = showChartsMapper.getIndicatorValue(fields, tableName, condition, sort, indicatorConfigInfo.getRule(), indicatorConfigInfo.getThreshold());
|
|
|
|
|
- chartsDataInfo.setChartsColumnConfig(chartsConfigMapper.getChartsColumn(indicatorConfigInfo.getId()));
|
|
|
|
|
- chartsDataInfo.setSerieses(indicatorSeriesMapList);
|
|
|
|
|
- chartsDataInfo.setStyleConfig(styleConfig);
|
|
|
|
|
|
|
+ int baseId = getChartsDataUtilService.getBaseId(indicatorConfigInfo.getId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (!DynamicDataSourceContextHolder.isContainsDataSource(baseId)) {
|
|
|
|
|
+ return new RepEntity(RepCode.DataSourceNull);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ DynamicDataSourceContextHolder.setDataSourceType(baseId);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<Map<String, Object>> indicatorSeriesMapList = showChartsMapper.getIndicatorValue(fields, tableName, condition, sort, indicatorConfigInfo.getRule(), indicatorConfigInfo.getThreshold());
|
|
|
|
|
+ chartsDataInfo.setChartsColumnConfig(chartsConfigMapper.getChartsColumn(indicatorConfigInfo.getId()));
|
|
|
|
|
+ chartsDataInfo.setSerieses(indicatorSeriesMapList);
|
|
|
|
|
+ chartsDataInfo.setStyleConfig(styleConfig);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ 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);
|
|
|
}
|
|
}
|
|
|
|
|
|