From c720020cc1e8d85b3e72e3592c3c3e97f332c746 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 19 Dec 2024 17:25:53 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-143943=5F=E3=80=90fr-fbp=E3=80=91?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E5=99=A8=E8=BF=9C=E7=A8=8B=E4=B8=8B=EF=BC=8C?= =?UTF-8?q?=E9=A6=96=E6=AC=A1=E6=8F=92=E5=85=A5=E5=9B=BE=E8=A1=A8=E6=97=B6?= =?UTF-8?q?=E9=9D=9E=E5=B8=B8=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/map/DesignGEOJSONHelper.java | 49 +++++++++++++++++-- .../function/DesignChartBaseComponent.java | 4 ++ 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/designer-chart/src/main/java/com/fanruan/map/DesignGEOJSONHelper.java b/designer-chart/src/main/java/com/fanruan/map/DesignGEOJSONHelper.java index 740ccd72b2..4c42f1cf5e 100644 --- a/designer-chart/src/main/java/com/fanruan/map/DesignGEOJSONHelper.java +++ b/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> tasks = new ArrayList<>(); + tasks.add(() -> { + updateGeographic(); + return null; + }); + tasks.add(() -> { + updateImage(); + return null; + }); + List> resultList = executorService.invokeAll(tasks); + for (Future 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 geographic = MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.GEOGRAPHIC)); + for (Map.Entry 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 image = MapRepository.getInstance().getMapResource(GEOJSONUtils.getMapDataTypePath(MapDataType.IMAGE)); + for (Map.Entry entry : image.entrySet()) { + URL_JSON_MAP.put(entry.getKey(), GeoJSONFactory.create(entry.getValue(), entry.getKey())); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } } diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java index 3a41a04c13..145c195809 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignChartBaseComponent.java @@ -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(); }