fix(仪表板): 仪表板日期字段联动、跳转、外部参数不生效

修复仪表板使用时间或日期字段作为视图联动、跳转、外部参数时不生效的问题。
https://www.tapd.cn/55578866/bugtrace/bugs/view/1155578866001025861
This commit is contained in:
王嘉豪 2023-05-23 12:50:25 +08:00 committed by wisonic-s
commit 07bd16d606
4 changed files with 21 additions and 8 deletions

View File

@ -17,6 +17,8 @@ public interface ExtPanelGroupMapper {
//会级联删除pid 下的所有数据
int deleteCircle(@Param("pid") String pid, @Param("nodeType") String nodeType);
int deleteLinkDefaultCircle(@Param("pid") String pid);
int deleteCircleView(@Param("pid") String pid, @Param("nodeType") String nodeType);
int deleteCircleViewCache(@Param("pid") String pid, @Param("nodeType") String nodeType);

View File

@ -202,6 +202,10 @@
ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk)
</select>
<delete id="deleteLinkDefaultCircle">
delete from panel_group where FIND_IN_SET(panel_group.source, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
</delete>
<delete id="deleteCircle">
delete
from panel_group
@ -211,7 +215,6 @@
panel_group.source = #{pid}
<if test="nodeType == 'folder'">
or FIND_IN_SET(panel_group.id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
or FIND_IN_SET(panel_group.source, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
</if>
</delete>

View File

@ -725,7 +725,9 @@ public class ChartViewService {
xAxis = xAxis.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
yAxis = yAxis.stream().filter(item -> chartViewFieldNameList.contains(item.getDataeaseName()) || (!desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName()))).collect(Collectors.toList());
}
Map<String, ChartViewFieldDTO> chartFieldMap = Stream.of(xAxisBase, xAxisExt, extStack)
.flatMap(Collection::stream)
.collect(Collectors.toMap(ChartViewFieldDTO::getId, o -> o, ((p, n) -> p)));
// 过滤来自仪表板的条件
List<ChartExtFilterRequest> extFilterList = new ArrayList<>();
//组件过滤条件
@ -834,6 +836,14 @@ public class ChartViewService {
if (!desensitizationList.keySet().contains(datasetTableField.getDataeaseName()) && dataeaseNames.contains(datasetTableField.getDataeaseName())) {
request.setDatasetTableField(datasetTableField);
if (StringUtils.equalsIgnoreCase(datasetTableField.getTableId(), view.getTableId())) {
// 设置日期格式以视图字段设置的格式为准先不处理组件的条件因为格式无法统一
if (request.getDatasetTableField() != null) {
ChartViewFieldDTO chartViewFieldDTO = chartFieldMap.get(request.getDatasetTableField().getId());
if (chartViewFieldDTO != null) {
request.setDatePattern(chartViewFieldDTO.getDatePattern());
request.setDateStyle(chartViewFieldDTO.getDateStyle());
}
}
if (CollectionUtils.isNotEmpty(request.getViewIds())) {
if (request.getViewIds().contains(view.getId())) {
extFilterList.add(request);
@ -883,9 +893,6 @@ public class ChartViewService {
ChartDrillRequest head = drillRequestList.get(0);
Map<String, String> dimValMap = new HashMap<>();
head.getDimensionList().forEach(item -> dimValMap.put(item.getId(), item.getValue()));
Map<String, ChartViewFieldDTO> fieldMap = Stream.of(xAxisBase, xAxisExt, extStack)
.flatMap(Collection::stream)
.collect(Collectors.toMap(ChartViewFieldDTO::getId, o -> o, ((p, n) -> p)));
for (int i = 0; i < drillRequestList.size(); i++) {
ChartDrillRequest request = drillRequestList.get(i);
ChartViewFieldDTO chartViewFieldDTO = drill.get(i);
@ -896,7 +903,7 @@ public class ChartViewService {
fieldsToFilter.add(chartViewFieldDTO);
dimValMap.put(requestDimension.getId(), requestDimension.getValue());
if (!checkDrillExist(xAxis, extStack, requestDimension.getId(), view)) {
fieldMap.put(chartViewFieldDTO.getId(), chartViewFieldDTO);
chartFieldMap.put(chartViewFieldDTO.getId(), chartViewFieldDTO);
xAxis.add(chartViewFieldDTO);
}
if (i == drillRequestList.size() - 1) {
@ -916,8 +923,8 @@ public class ChartViewService {
DatasetTableField datasetTableField = dataSetTableFieldsService.get(tmpField.getId());
tmpFilter.setDatasetTableField(datasetTableField);
tmpFilter.setOperator("in");
tmpFilter.setDateStyle(fieldMap.get(tmpField.getId()).getDateStyle());
tmpFilter.setDatePattern(fieldMap.get(tmpField.getId()).getDatePattern());
tmpFilter.setDateStyle(chartFieldMap.get(tmpField.getId()).getDateStyle());
tmpFilter.setDatePattern(chartFieldMap.get(tmpField.getId()).getDatePattern());
tmpFilter.setFieldId(tmpField.getId());
tmpFilter.setValue(Collections.singletonList(dimValMap.get(tmpField.getId())));
extFilterList.add(tmpFilter);

View File

@ -305,6 +305,7 @@ public class PanelGroupService {
extPanelGroupMapper.deleteCircleView(id, nodeType);
extPanelGroupMapper.deleteCircleViewCache(id, nodeType);
// 同时会删除对应默认仪表盘
extPanelGroupMapper.deleteLinkDefaultCircle(id);
extPanelGroupMapper.deleteCircle(id, nodeType);
storeService.removeByPanelId(id);
shareService.delete(id, null);