Browse Source

Pull request #15907: REPORT-143943_【fr-fbp】设计器远程下,首次插入图表时非常慢

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp/release to fbp/release

* commit 'd239c24217a6c7b1af2d7173fac17b6b810aceb4':
  REPORT-143943_【fr-fbp】设计器远程下,首次插入图表时非常慢
fbp/release
parent
commit
8d02ef4a8a
  1. 49
      designer-chart/src/main/java/com/fanruan/map/DesignGEOJSONHelper.java
  2. 4
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java

49
designer-chart/src/main/java/com/fanruan/map/DesignGEOJSONHelper.java

@ -1,12 +1,22 @@
package com.fanruan.map;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.decision.webservice.v10.map.geojson.MapDataType;
import com.fr.decision.webservice.v10.map.geojson.bean.GeoJSONFactory;
import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelper;
import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.third.org.apache.commons.lang3.time.StopWatch;
import com.fr.workspace.server.repository.map.MapRepository;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
/**
* 设计器地图资源Helper
*
@ -22,9 +32,21 @@ public class DesignGEOJSONHelper extends GEOJSONHelper {
StopWatch watch = new StopWatch();
watch.start();
URL_JSON_MAP.putAll(MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.GEOGRAPHIC)));
URL_JSON_MAP.putAll(MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.IMAGE)));
ExecutorService executorService = Executors.newFixedThreadPool(2, new NamedThreadFactory("[design-map] initGeoJSON"));
List<Callable<Void>> tasks = new ArrayList<>();
tasks.add(() -> {
updateGeographic();
return null;
});
tasks.add(() -> {
updateImage();
return null;
});
List<Future<Void>> resultList = executorService.invokeAll(tasks);
for (Future<Void> result : resultList) {
result.get();
}
executorService.shutdown();
FineLoggerFactory.getLogger().info("Load chart map resources spend time {} ms", watch.getTime());
watch.stop();
@ -33,4 +55,25 @@ public class DesignGEOJSONHelper extends GEOJSONHelper {
}
}
private void updateGeographic() {
try {
Map<String, String> geographic = MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.GEOGRAPHIC));
for (Map.Entry<String, String> entry : geographic.entrySet()) {
URL_JSON_MAP.put(entry.getKey(), GeoJSONFactory.create(entry.getValue(), entry.getKey()));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private void updateImage() {
try {
Map<String, String> image = MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.IMAGE));
for (Map.Entry<String, String> entry : image.entrySet()) {
URL_JSON_MAP.put(entry.getKey(), GeoJSONFactory.create(entry.getValue(), entry.getKey()));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

4
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java vendored

@ -1,11 +1,14 @@
package com.fanruan.boot.env.function;
import com.fanruan.boot.ChartBaseComponent;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.DependsOn;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
import com.fanruan.carina.annotions.Stop;
import com.fanruan.carina.annotions.Supplemental;
import com.fanruan.map.DesignGEOJSONHelper;
import com.fr.decision.webservice.v10.map.geojson.helper.GEOJSONHelperShell;
/**
@ -41,6 +44,7 @@ public class DesignChartBaseComponent extends ChartBaseComponent {
*/
@Supplemental
public void prepare() {
Carina.getApplicationContext().singleton(GEOJSONHelperShell.class).set(DesignGEOJSONHelper.class);
super.prepare();
}

Loading…
Cancel
Save