Merge pull request #10320 from dataease/pr@dev-v2@fix_drill

fix(图表): 修复下钻日期SQL拼接错误的问题
This commit is contained in:
Junjun 2024-06-17 15:40:05 +08:00 committed by GitHub
commit 8fce17ea22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -541,11 +541,18 @@ public class ChartDataManage {
ChartExtFilterDTO tmpFilter = new ChartExtFilterDTO();
DatasetTableFieldDTO datasetTableField = datasetTableFieldManage.selectById(tmpField.getId());
tmpFilter.setDatasetTableField(datasetTableField);
tmpFilter.setOperator("in");
tmpFilter.setDateStyle(fieldMap.get(tmpField.getId()).getDateStyle());
tmpFilter.setDatePattern(fieldMap.get(tmpField.getId()).getDatePattern());
tmpFilter.setFieldId(String.valueOf(tmpField.getId()));
tmpFilter.setValue(Collections.singletonList(dimValMap.get(tmpField.getId())));
if (datasetTableField.getDeType() == 1) {
tmpFilter.setOperator("between");
// 把value类似过滤组件处理获得start time和end time
Map<String, Long> stringLongMap = Utils.parseDateTimeValue(dimValMap.get(tmpField.getId()));
tmpFilter.setValue(Arrays.asList(String.valueOf(stringLongMap.get("startTime")), String.valueOf(stringLongMap.get("endTime"))));
} else {
tmpFilter.setOperator("in");
tmpFilter.setValue(Collections.singletonList(dimValMap.get(tmpField.getId())));
}
extFilterList.add(tmpFilter);
drillFilters.add(tmpFilter);
}
@ -614,11 +621,14 @@ public class ChartDataManage {
if (Arrays.asList(ChartConstants.M_Y).contains(compareCalc.getType())) {
if (StringUtils.equalsIgnoreCase(compareCalc.getField() + "", filterDTO.getFieldId())) {
// -1 year
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(Long.parseLong(filterDTO.getValue().getFirst())));
calendar.add(Calendar.YEAR, -1);
filterDTO.getValue().set(0, String.valueOf(calendar.getTime().getTime()));
isYOY = true;
try {
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date(Long.parseLong(filterDTO.getValue().getFirst())));
calendar.add(Calendar.YEAR, -1);
filterDTO.getValue().set(0, String.valueOf(calendar.getTime().getTime()));
isYOY = true;
} catch (Exception e) {
}
}
}
}