mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 20:51:48 +00:00
Opt knowledge data (#1769)
This commit is contained in:
@@ -5,6 +5,7 @@ import com.tencent.supersonic.headless.api.pojo.request.DictValueReq;
|
|||||||
import com.tencent.supersonic.headless.api.pojo.response.DictValueResp;
|
import com.tencent.supersonic.headless.api.pojo.response.DictValueResp;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@@ -26,6 +27,10 @@ import java.util.stream.Stream;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class FileHandlerImpl implements FileHandler {
|
public class FileHandlerImpl implements FileHandler {
|
||||||
|
|
||||||
|
@Value("${dict.value.max.count.page:1000}")
|
||||||
|
private int dictValueMaxCountPage;
|
||||||
|
|
||||||
public static final String FILE_SPILT = File.separator;
|
public static final String FILE_SPILT = File.separator;
|
||||||
|
|
||||||
private final LocalFileConfig localFileConfig;
|
private final LocalFileConfig localFileConfig;
|
||||||
@@ -92,10 +97,9 @@ public class FileHandlerImpl implements FileHandler {
|
|||||||
Long fileLineNum = getFileLineNum(filePath);
|
Long fileLineNum = getFileLineNum(filePath);
|
||||||
Integer startLine = 1;
|
Integer startLine = 1;
|
||||||
List<DictValueResp> dictValueRespList =
|
List<DictValueResp> dictValueRespList =
|
||||||
getFileData(filePath, startLine, fileLineNum.intValue());
|
getFileData(filePath, startLine, fileLineNum.intValue()).stream().filter(
|
||||||
dictValueRespList = dictValueRespList.stream()
|
dictValue -> dictValue.getValue().contains(dictValueReq.getKeyValue()))
|
||||||
.filter(dictValue -> dictValue.getValue().contains(dictValueReq.getKeyValue()))
|
.collect(Collectors.toList());
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isEmpty(dictValueRespList)) {
|
if (CollectionUtils.isEmpty(dictValueRespList)) {
|
||||||
dictValueRespPageInfo.setList(new ArrayList<>());
|
dictValueRespPageInfo.setList(new ArrayList<>());
|
||||||
return dictValueRespPageInfo;
|
return dictValueRespPageInfo;
|
||||||
@@ -120,7 +124,7 @@ public class FileHandlerImpl implements FileHandler {
|
|||||||
DictValueReq dictValueReq) {
|
DictValueReq dictValueReq) {
|
||||||
PageInfo<DictValueResp> dictValueRespPageInfo = new PageInfo<>();
|
PageInfo<DictValueResp> dictValueRespPageInfo = new PageInfo<>();
|
||||||
String filePath = localFileConfig.getDictDirectoryLatest() + FILE_SPILT + fileName;
|
String filePath = localFileConfig.getDictDirectoryLatest() + FILE_SPILT + fileName;
|
||||||
Long fileLineNum = getFileLineNum(filePath);
|
Long fileLineNum = Math.min(dictValueMaxCountPage, getFileLineNum(filePath));
|
||||||
Integer startLine = 1;
|
Integer startLine = 1;
|
||||||
Integer endLine = Integer.valueOf(
|
Integer endLine = Integer.valueOf(
|
||||||
Math.min(dictValueReq.getCurrent() * dictValueReq.getPageSize(), fileLineNum) + "");
|
Math.min(dictValueReq.getCurrent() * dictValueReq.getPageSize(), fileLineNum) + "");
|
||||||
|
|||||||
@@ -467,6 +467,9 @@ public class DictUtils {
|
|||||||
|
|
||||||
private String generateDictDateFilter(DictItemResp dictItemResp) {
|
private String generateDictDateFilter(DictItemResp dictItemResp) {
|
||||||
ItemValueConfig config = dictItemResp.getConfig();
|
ItemValueConfig config = dictItemResp.getConfig();
|
||||||
|
if (!partitionedModel(dictItemResp.getModelId())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
// 未进行设置
|
// 未进行设置
|
||||||
if (Objects.isNull(config) || Objects.isNull(config.getDateConf())) {
|
if (Objects.isNull(config) || Objects.isNull(config.getDateConf())) {
|
||||||
return defaultDateFilter();
|
return defaultDateFilter();
|
||||||
@@ -489,6 +492,17 @@ public class DictUtils {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean partitionedModel(Long modelId) {
|
||||||
|
ModelResp model = modelService.getModel(modelId);
|
||||||
|
if (Objects.nonNull(model)) {
|
||||||
|
List<Dim> timeDims = model.getTimeDimension();
|
||||||
|
if (!CollectionUtils.isEmpty(timeDims)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private String generateDictDateFilterRecent(DictItemResp dictItemResp) {
|
private String generateDictDateFilterRecent(DictItemResp dictItemResp) {
|
||||||
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
ModelResp model = modelService.getModel(dictItemResp.getModelId());
|
||||||
if (Objects.nonNull(model)) {
|
if (Objects.nonNull(model)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user