fix(仪表板、数据大屏): 修复部分富文本图表多次模板应用出现报错情况 #10384

This commit is contained in:
wangjiahao 2024-06-19 18:56:29 +08:00
parent 7a9cc483ce
commit 041fe35920

View File

@ -6,6 +6,7 @@ import io.dataease.exception.DEException;
import io.dataease.template.dao.auto.entity.VisualizationTemplateExtendData; import io.dataease.template.dao.auto.entity.VisualizationTemplateExtendData;
import io.dataease.template.dao.auto.mapper.VisualizationTemplateExtendDataMapper; import io.dataease.template.dao.auto.mapper.VisualizationTemplateExtendDataMapper;
import io.dataease.utils.JsonUtil; import io.dataease.utils.JsonUtil;
import io.dataease.utils.LogUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -28,8 +29,15 @@ public class VisualizationTemplateExtendDataManage {
queryWrapper.eq("view_id",viewId); queryWrapper.eq("view_id",viewId);
List<VisualizationTemplateExtendData> extendDataList = extendDataMapper.selectList(queryWrapper); List<VisualizationTemplateExtendData> extendDataList = extendDataMapper.selectList(queryWrapper);
if (CollectionUtils.isNotEmpty(extendDataList)) { if (CollectionUtils.isNotEmpty(extendDataList)) {
try{
ChartViewDTO chartViewTemplate = JsonUtil.parseObject(extendDataList.get(0).getViewDetails(),ChartViewDTO.class); ChartViewDTO chartViewTemplate = JsonUtil.parseObject(extendDataList.get(0).getViewDetails(),ChartViewDTO.class);
if(chartViewTemplate != null){
view.setData(chartViewTemplate.getData()); view.setData(chartViewTemplate.getData());
}
}catch (Exception e){
LogUtil.error("未获取内置数据:"+viewId);
}
} else { } else {
DEException.throwException("模板缓存数据中未获取指定图表数据:" + viewId); DEException.throwException("模板缓存数据中未获取指定图表数据:" + viewId);
} }