forked from github/dataease
Merge pull request #2657 from dataease/pr@dev@perf_map_setting
perf(仪表板): 自定义地图文件与系统地图文件解耦
This commit is contained in:
commit
46eb021bfa
@ -9,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@Configuration
|
||||
public class WebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Value("${geo.rootpath:file:/opt/dataease/data/feature/}")
|
||||
@Value("${geo.custom.rootpath:file:/opt/dataease/data/custom/}")
|
||||
private String geoPath;
|
||||
|
||||
@Override
|
||||
|
@ -11,6 +11,7 @@ import io.dataease.map.utils.MapUtils;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobal;
|
||||
import io.dataease.plugins.common.base.domain.AreaMappingGlobalExample;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -26,7 +27,9 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class MapService {
|
||||
|
||||
private static final String dirPath = "/opt/dataease/data/feature/";
|
||||
@Value("${geo.custom.rootpath:/opt/dataease/data/custom/}")
|
||||
private String rootGeoPath;
|
||||
|
||||
|
||||
@Cacheable("sys_map_areas")
|
||||
public List<AreaEntity> areaEntities() {
|
||||
@ -93,7 +96,7 @@ public class MapService {
|
||||
Set<String> sets = nodes.stream().flatMap(node -> codesByNode(node, pLevel).stream()).collect(Collectors.toSet());
|
||||
sets.forEach(code -> {
|
||||
String countryCode = code.substring(0, 3);
|
||||
String path = dirPath + "/full/" + countryCode + "/" + code +"_full.json";
|
||||
String path = rootGeoPath + "/full/" + countryCode + "/" + code +"_full.json";
|
||||
if (FileUtil.exist(path)) {
|
||||
FileUtil.del(path);
|
||||
}
|
||||
@ -194,7 +197,7 @@ public class MapService {
|
||||
|
||||
private void validateFile(MultipartFile file) {
|
||||
long size = file.getSize();
|
||||
String name = file.getName();
|
||||
String name = file.getOriginalFilename();
|
||||
if (size / 1024 / 1024 > 30) {
|
||||
DEException.throwException("large file that exceed 30M is not supported");
|
||||
}
|
||||
@ -318,13 +321,15 @@ public class MapService {
|
||||
}
|
||||
|
||||
public void uploadMapFile(MultipartFile file, String areaCode) throws Exception{
|
||||
String dir = dirPath + "full/";
|
||||
|
||||
String countryCode = areaCode.substring(0, 3);
|
||||
String dir = rootGeoPath + "full/" + countryCode + "/";
|
||||
File fileDir = new File(dir);
|
||||
if (!fileDir.exists()) {
|
||||
fileDir.mkdirs();
|
||||
}
|
||||
String countryCode = areaCode.substring(0, 3);
|
||||
String targetPath = dir + countryCode + "/" + areaCode+"_full.json";
|
||||
|
||||
String targetPath = dir + areaCode+"_full.json";
|
||||
File target = new File(targetPath);
|
||||
file.transferTo(target);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package io.dataease.map.service;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.ChartView;
|
||||
@ -24,6 +25,10 @@ public class MapTransferService {
|
||||
@Value("${geo.rootpath:/opt/dataease/data/feature/}")
|
||||
private String geoPath;
|
||||
|
||||
|
||||
@Value("${geo.custom.rootpath:/opt/dataease/data/custom/}")
|
||||
private String customGeoPath;
|
||||
|
||||
private static final List<String> MATCH_TYPES = new ArrayList<>();
|
||||
private static final Gson gson = new Gson();
|
||||
private static final String AREA_CODE_KEY = "areaCode";
|
||||
@ -65,23 +70,45 @@ public class MapTransferService {
|
||||
String chinaRootPath = geoPath + FULL_KEY + FILE_SEPARATOR;
|
||||
File chinaRootDir = new File(chinaRootPath);
|
||||
File[] files = chinaRootDir.listFiles();
|
||||
if(ArrayUtil.isEmpty(files)) return;
|
||||
Map<String, List<File>> listMap = Arrays.stream(files).filter(FileUtil::isFile).collect(Collectors.groupingBy(this::fileType));
|
||||
if (ObjectUtils.isEmpty(listMap)) return;
|
||||
moveFiles(listMap, BORDER_KEY);
|
||||
moveFiles(listMap, FULL_KEY);
|
||||
moveGlobalFile();
|
||||
|
||||
}
|
||||
|
||||
private void moveFiles(Map<String, List<File>> listMap, String fileType) {
|
||||
String dirPath = geoPath + fileType + FILE_SEPARATOR;
|
||||
String dirPath = customGeoPath + fileType + FILE_SEPARATOR;
|
||||
Optional.ofNullable(listMap.get(fileType)).ifPresent(files -> {
|
||||
files.forEach(file -> {
|
||||
String fileName = file.getName();
|
||||
String newFilePath = dirPath + GLOBAL_CHINA_PREFIX + FILE_SEPARATOR + GLOBAL_CHINA_PREFIX + fileName;
|
||||
FileUtil.move(file, new File(newFilePath), true);
|
||||
FileUtil.move(file, new File(newFilePath), false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void moveGlobalFile() {
|
||||
String fileName = "000000000" + FULL_FILE_SUFFIX;
|
||||
String sourcePath = geoPath + FULL_KEY + FILE_SEPARATOR + "000" + FILE_SEPARATOR + fileName;
|
||||
File sourceFile = new File(sourcePath);
|
||||
if (!sourceFile.exists()) return;
|
||||
|
||||
String targetDirPath = customGeoPath + FULL_KEY + FILE_SEPARATOR + "000" + FILE_SEPARATOR;
|
||||
File targetDir = new File(targetDirPath);
|
||||
if (!targetDir.exists()) {
|
||||
targetDir.mkdirs();
|
||||
}
|
||||
String targetPath = targetDirPath + fileName;
|
||||
|
||||
File targetFile = new File(targetPath);
|
||||
|
||||
FileUtil.move(sourceFile, targetFile, false);
|
||||
|
||||
}
|
||||
|
||||
private String fileType(File file) {
|
||||
return file.getName().endsWith(FULL_FILE_SUFFIX) ? FULL_KEY : BORDER_KEY;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<de-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]" style="height: calc(100vh - 150px);">
|
||||
|
||||
<de-aside-container type="mapset">
|
||||
<de-aside-container type="mapset" style="height: 100%;">
|
||||
<map-setting-left ref="map_setting_tree" :tree-datas="treeDatas" @emit-add="emitAdd" @refresh-tree="refreshTree" @show-node-info="loadForm" />
|
||||
</de-aside-container>
|
||||
|
||||
<de-main-container>
|
||||
<de-main-container style="height: 100%;">
|
||||
<map-setting-right ref="map_setting_form" :tree-datas="treeDatas" :status="formStatus" @refresh-tree="refreshTree" />
|
||||
</de-main-container>
|
||||
</de-container>
|
||||
|
@ -10,6 +10,10 @@
|
||||
<email-setting />
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :lazy="true" :label="$t('sysParams.map')" name="ten">
|
||||
<map-setting v-if="activeName === 'ten'" ref="mapSetting" />
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane v-if="isPluginLoaded" :lazy="true" :label="$t('sysParams.display')" name="second">
|
||||
<plugin-com v-if="isPluginLoaded" ref="DisplaySetting" component-name="DisplaySetting" />
|
||||
</el-tab-pane>
|
||||
@ -42,10 +46,6 @@
|
||||
<plugin-com v-if="isPluginLoaded" ref="CasSetting" component-name="CasSetting" />
|
||||
</el-tab-pane>
|
||||
|
||||
<el-tab-pane :lazy="true" :label="$t('sysParams.map')" name="ten">
|
||||
<map-setting v-if="activeName === 'ten'" ref="mapSetting" />
|
||||
</el-tab-pane>
|
||||
|
||||
</el-tabs>
|
||||
</layout-content>
|
||||
</template>
|
||||
|
Loading…
Reference in New Issue
Block a user