|
|
@@ -4,12 +4,17 @@ import com.usoftchina.bi.core.base.RepCode;
|
|
|
import com.usoftchina.bi.core.base.RepEntity;
|
|
|
import com.usoftchina.bi.core.utils.CalculationJudgeUtil;
|
|
|
import com.usoftchina.bi.core.utils.CollectionUtils;
|
|
|
+import com.usoftchina.bi.core.utils.EncryUtil;
|
|
|
import com.usoftchina.bi.server.dao.chart.ChartsConfigMapper;
|
|
|
import com.usoftchina.bi.server.dao.chart.ShowChartsMapper;
|
|
|
+import com.usoftchina.bi.server.dao.dashboard.DashboardsMapper;
|
|
|
import com.usoftchina.bi.server.model.bo.*;
|
|
|
+import com.usoftchina.bi.server.model.po.User;
|
|
|
import com.usoftchina.bi.server.model.vo.configVo.LineConfigInfo;
|
|
|
+import com.usoftchina.bi.server.model.vo.configVo.LoginInfo;
|
|
|
import com.usoftchina.bi.server.model.vo.dataVo.ChartsDataInfo;
|
|
|
import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;
|
|
|
+import com.usoftchina.bi.server.service.user.UserService;
|
|
|
import com.usoftchina.bi.server.utils.ScreenUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -32,11 +37,17 @@ public class ShowLineService {
|
|
|
ScreenUtil screenUtil;
|
|
|
@Autowired
|
|
|
ChartsUtilService chartsUtilService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ UserService userService;
|
|
|
/*
|
|
|
Line数据展示
|
|
|
*/
|
|
|
public RepEntity showLine(LineConfigInfo lineConfigInfo, String token, int dashId, String styleConfig){
|
|
|
+ if (StringUtils.isEmpty(token) || "null".equals(token)) {
|
|
|
+ User user = userService.getUserById(chartsConfigMapper.getCreateId(lineConfigInfo.getId())).getData();
|
|
|
+ LoginInfo loginInfo = new LoginInfo(user.getUserName(), EncryUtil.decryptPassword(user.getPassWord()));
|
|
|
+ token = userService.login(loginInfo).getData().getToken();
|
|
|
+ }
|
|
|
Assert.notNull(lineConfigInfo, "请求参数不能为空");
|
|
|
/* 变量定义 */
|
|
|
ChartsDataInfo chartsDataInfo = new ChartsDataInfo();
|
|
|
@@ -151,8 +162,9 @@ public class ShowLineService {
|
|
|
}
|
|
|
chartsDataInfo.setxAxis(xAxisData);
|
|
|
/* 数据处理 */
|
|
|
+ //limit(5) 是分组显示数 现在是最大是5
|
|
|
List<String> groupList = histogramGroupList.stream().map(HistogramGroupData::getGroupName).distinct().limit(5).collect(Collectors.toList());
|
|
|
- Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy(HistogramGroupData::getName));
|
|
|
+ Map<String, List<HistogramGroupData>> histogramNameMap = histogramGroupList.stream().collect(Collectors.groupingBy( histogramGroupData -> StringUtils.isEmpty(histogramGroupData.getName())?"空":histogramGroupData.getName() ));
|
|
|
Set<String> keyset = histogramNameMap.keySet();
|
|
|
Iterator<String> keyIt= keyset.iterator();
|
|
|
List<HistogramGroupData> histogramGroupListAfterHandle = new ArrayList<>();
|
|
|
@@ -165,6 +177,11 @@ public class ShowLineService {
|
|
|
histogramGroupDataList.add(new HistogramGroupData(key, null, groupName));
|
|
|
}
|
|
|
});
|
|
|
+ histogramGroupDataList.forEach( histogramGroupData -> {
|
|
|
+ if( StringUtils.isEmpty(histogramGroupData.getName()) ){
|
|
|
+ histogramGroupData.setName("空");
|
|
|
+ }
|
|
|
+ });
|
|
|
histogramGroupListAfterHandle.addAll(histogramGroupDataList);
|
|
|
}
|
|
|
/* 返回数据对象组装 */
|
|
|
@@ -179,7 +196,7 @@ public class ShowLineService {
|
|
|
value = histogramGroupDataList.stream().map(HistogramGroupData::getValue).collect(Collectors.toList()).subList(0, xAxisData.size());
|
|
|
Series series = new Series(key, value, groupBy.get(0));
|
|
|
serieses.add(series);
|
|
|
- }while (it.hasNext() && i <= 20);
|
|
|
+ }while (it.hasNext() && i <= xAxisData.size());
|
|
|
}
|
|
|
chartsDataInfo.setStyleConfig(styleConfig);
|
|
|
chartsDataInfo.setChartsColumnConfig(chartsColumn);
|