mirror of
https://github.com/tencentmusic/supersonic.git
synced 2026-04-29 04:14:20 +08:00
Compare commits
3 Commits
b6f561f18c
...
008f1443cb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
008f1443cb | ||
|
|
29c1119ee2 | ||
|
|
d658e437fb |
@@ -12,4 +12,6 @@ public class DictSingleTaskReq {
|
||||
private TypeEnums type;
|
||||
@NotNull
|
||||
private Long itemId;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,8 @@ import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.tencent.supersonic.common.pojo.DimensionConstants.DIMENSION_TIME_FORMAT;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ModelServiceImpl implements ModelService {
|
||||
@@ -530,17 +532,23 @@ public class ModelServiceImpl implements ModelService {
|
||||
Optional<Dimension> dimOptional = modelDetail.getDimensions().stream().filter(
|
||||
dimension -> dimension.getBizName().equals(dimensionReq.getBizName()))
|
||||
.findFirst();
|
||||
String dateFormat = null;
|
||||
if (dimensionReq.getExt().containsKey(DIMENSION_TIME_FORMAT)) {
|
||||
dateFormat = (String) dimensionReq.getExt().get(DIMENSION_TIME_FORMAT);
|
||||
}
|
||||
if (dimOptional.isPresent()) {
|
||||
Dimension dimension = dimOptional.get();
|
||||
dimension.setExpr(dimensionReq.getExpr());
|
||||
dimension.setName(dimensionReq.getName());
|
||||
dimension.setType(DimensionType.valueOf(dimensionReq.getType()));
|
||||
dimension.setDescription(dimensionReq.getDescription());
|
||||
dimension.setDateFormat(dateFormat);
|
||||
} else {
|
||||
Dimension dimension = Dimension.builder().name(dimensionReq.getName())
|
||||
.bizName(dimensionReq.getBizName()).expr(dimensionReq.getExpr())
|
||||
.type(DimensionType.valueOf(dimensionReq.getType()))
|
||||
.description(dimensionReq.getDescription()).build();
|
||||
.dateFormat(dateFormat).description(dimensionReq.getDescription())
|
||||
.build();
|
||||
modelDetail.getDimensions().add(dimension);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -445,14 +445,29 @@ public class DictUtils {
|
||||
if (DateConf.DateMode.ALL.equals(config.getDateConf().getDateMode())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 静态日期
|
||||
if (DateConf.DateMode.BETWEEN.equals(config.getDateConf().getDateMode())) {
|
||||
String dateFormat = partitionTimeDimension.getDateFormat();
|
||||
if (StringUtils.isEmpty(dateFormat)) {
|
||||
dateFormat = "yyyy-MM-dd"; // 默认格式
|
||||
}
|
||||
|
||||
// 格式化起止日期
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
|
||||
String startDate =
|
||||
LocalDate.parse(config.getDateConf().getStartDate()).format(formatter);
|
||||
String endDate = LocalDate.parse(config.getDateConf().getEndDate()).format(formatter);
|
||||
|
||||
return String.format("( %s >= '%s' and %s <= '%s' )",
|
||||
config.getDateConf().getDateField(), config.getDateConf().getStartDate(),
|
||||
config.getDateConf().getDateField(), config.getDateConf().getEndDate());
|
||||
partitionTimeDimension.getBizName(), startDate,
|
||||
partitionTimeDimension.getBizName(), endDate);
|
||||
}
|
||||
|
||||
// 动态日期
|
||||
if (DateConf.DateMode.RECENT.equals(config.getDateConf().getDateMode())) {
|
||||
dictItemResp.getConfig().getDateConf()
|
||||
.setDateField(partitionTimeDimension.getBizName());
|
||||
return generateDictDateFilterRecent(dictItemResp);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user