From 044c0d629317055c4b519c053f70182f0cc92c60 Mon Sep 17 00:00:00 2001 From: Yann Date: Tue, 28 Feb 2023 15:57:49 +0800 Subject: [PATCH 1/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/manager/impl/PluginSearchManager.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 520d396f1e..e9455d39d6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -44,6 +44,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { private static final String TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; private static final String UPLOAD_TIME = "uploadTime"; + private static final String CURRENT_VERSION = "v10"; private PluginSearchManager() { @@ -214,12 +215,19 @@ public class PluginSearchManager implements AlphaFineSearchProvider { } return time; } - })); + }).reversed()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } - for (int i = 0; i < DEFAULT_LIST_SIZE; i++) { - pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); + int pluginModelsCount = 0; + for (Map obj : jsonObjects) { + if (pluginModelsCount == DEFAULT_LIST_SIZE) { + break; + } + if (((Integer) obj.get(CURRENT_VERSION)) == 1) { + pluginModels.add(getPluginModel(new JSONObject(obj), false)); + pluginModelsCount++; + } } } return pluginModels; From 8dabaf517d57a3a76bdf5a10ecbf2fb477ad3c26 Mon Sep 17 00:00:00 2001 From: Yann Date: Tue, 28 Feb 2023 16:53:12 +0800 Subject: [PATCH 2/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/impl/PluginSearchManager.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index e9455d39d6..7d3767f0fd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -204,18 +204,16 @@ public class PluginSearchManager implements AlphaFineSearchProvider { if (!Collections.isEmpty(jsonObjects)) { SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); try { - jsonObjects.sort(Comparator.comparingLong(new ToLongFunction() { - @Override - public long applyAsLong(Map value) { - long time = 0L; - try { - time = format.parse((String) value.get(UPLOAD_TIME)).getTime(); - } catch (ParseException e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } - return time; + jsonObjects.sort((v1, v2) -> { + try { + long t1 = format.parse((String) v1.get(UPLOAD_TIME)).getTime(); + long t2 = format.parse((String) v2.get(UPLOAD_TIME)).getTime(); + return Long.compare(t2, t1); + } catch (ParseException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); } - }).reversed()); + return 0; + }); } catch (Exception e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } From 0d3f5e8447b4747306eddb2921bde7e0eec30e96 Mon Sep 17 00:00:00 2001 From: Yann Date: Tue, 28 Feb 2023 17:56:27 +0800 Subject: [PATCH 3/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/impl/PluginSearchManager.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 7d3767f0fd..aa0f84feea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -20,16 +20,15 @@ import com.fr.plugin.basic.version.Version; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; +import com.fr.stable.ProductConstants; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.function.ToLongFunction; /** * Created by XiaXiang on 2017/3/27. @@ -44,7 +43,6 @@ public class PluginSearchManager implements AlphaFineSearchProvider { private static final String TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; private static final String UPLOAD_TIME = "uploadTime"; - private static final String CURRENT_VERSION = "v10"; private PluginSearchManager() { @@ -121,7 +119,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { return lessModelList; } SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); - if(noConnectList != null){ + if (noConnectList != null) { return noConnectList; } for (int j = 0; j < searchText.length; j++) { @@ -185,7 +183,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { List pluginModels = new ArrayList<>(); pluginModels.addAll(parseDefaultPluginModel(plugins)); - pluginModels.forEach(m->this.defaultModelList.add(m)); + pluginModels.forEach(m -> this.defaultModelList.add(m)); } catch (Exception e) { FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage()); @@ -198,31 +196,18 @@ public class PluginSearchManager implements AlphaFineSearchProvider { /** * 将jsonobject转化为PluginModel * 并按照更新时间排序,取最新的10个 - * */ + */ List parseDefaultPluginModel(List jsonObjects) { List pluginModels = new ArrayList<>(); if (!Collections.isEmpty(jsonObjects)) { - SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); - try { - jsonObjects.sort((v1, v2) -> { - try { - long t1 = format.parse((String) v1.get(UPLOAD_TIME)).getTime(); - long t2 = format.parse((String) v2.get(UPLOAD_TIME)).getTime(); - return Long.compare(t2, t1); - } catch (ParseException e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } - return 0; - }); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } + jsonObjects.sort(PluginSearchManager::sortPluginByUploadTime); int pluginModelsCount = 0; + String version = "v" + ProductConstants.MAIN_VERSION; for (Map obj : jsonObjects) { if (pluginModelsCount == DEFAULT_LIST_SIZE) { break; } - if (((Integer) obj.get(CURRENT_VERSION)) == 1) { + if (((Integer) obj.get(version)) == 1) { pluginModels.add(getPluginModel(new JSONObject(obj), false)); pluginModelsCount++; } @@ -231,4 +216,20 @@ public class PluginSearchManager implements AlphaFineSearchProvider { return pluginModels; } + private static int sortPluginByUploadTime(Map v1, Map v2) { + SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); + long t1 = 0L, t2 = 0L; + try { + t1 = format.parse((String) v1.get(UPLOAD_TIME)).getTime(); + } catch (ParseException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + try { + t2 = format.parse((String) v2.get(UPLOAD_TIME)).getTime(); + } catch (ParseException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return Long.compare(t2, t1); + } + } From c3394664351510790d23e27c3dac37fcfd31700e Mon Sep 17 00:00:00 2001 From: Yann Date: Wed, 1 Mar 2023 10:02:13 +0800 Subject: [PATCH 4/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/impl/PluginSearchManager.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index aa0f84feea..46c24e1c61 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * Created by XiaXiang on 2017/3/27. @@ -195,22 +196,19 @@ public class PluginSearchManager implements AlphaFineSearchProvider { /** * 将jsonobject转化为PluginModel - * 并按照更新时间排序,取最新的10个 + * 并按照更新时间排序,取最新的10个,并过滤掉不是当前版本的 */ List parseDefaultPluginModel(List jsonObjects) { List pluginModels = new ArrayList<>(); + String version = "v" + ProductConstants.MAIN_VERSION; if (!Collections.isEmpty(jsonObjects)) { - jsonObjects.sort(PluginSearchManager::sortPluginByUploadTime); - int pluginModelsCount = 0; - String version = "v" + ProductConstants.MAIN_VERSION; - for (Map obj : jsonObjects) { - if (pluginModelsCount == DEFAULT_LIST_SIZE) { - break; - } - if (((Integer) obj.get(version)) == 1) { - pluginModels.add(getPluginModel(new JSONObject(obj), false)); - pluginModelsCount++; - } + jsonObjects = jsonObjects.stream() + .filter(o -> ((Integer) o.get(version)) == 1) + .sorted(PluginSearchManager::sortPluginByUploadTime) + .collect(Collectors.toList()); + int size = Math.min(DEFAULT_LIST_SIZE, jsonObjects.size()); + for (int i = 0; i < size; i++) { + pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); } } return pluginModels; From 8570e88822efbef405dc1cfe9e33c2824ab1fbee Mon Sep 17 00:00:00 2001 From: Yann Date: Wed, 1 Mar 2023 10:20:09 +0800 Subject: [PATCH 5/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/manager/impl/PluginSearchManager.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 46c24e1c61..787bb0e83b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -27,6 +27,7 @@ import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -204,7 +205,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { if (!Collections.isEmpty(jsonObjects)) { jsonObjects = jsonObjects.stream() .filter(o -> ((Integer) o.get(version)) == 1) - .sorted(PluginSearchManager::sortPluginByUploadTime) + .sorted(Comparator.comparingLong(PluginSearchManager::parseTime).reversed()) .collect(Collectors.toList()); int size = Math.min(DEFAULT_LIST_SIZE, jsonObjects.size()); for (int i = 0; i < size; i++) { @@ -214,20 +215,15 @@ public class PluginSearchManager implements AlphaFineSearchProvider { return pluginModels; } - private static int sortPluginByUploadTime(Map v1, Map v2) { + private static long parseTime(Map value) { SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); - long t1 = 0L, t2 = 0L; + long t = 0L; try { - t1 = format.parse((String) v1.get(UPLOAD_TIME)).getTime(); + t = format.parse((String) value.get(UPLOAD_TIME)).getTime(); } catch (ParseException e) { FineLoggerFactory.getLogger().error(e, e.getMessage()); } - try { - t2 = format.parse((String) v2.get(UPLOAD_TIME)).getTime(); - } catch (ParseException e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } - return Long.compare(t2, t1); + return t; } } From a6541bb43f68ff7d92240e0c63a6ae839b188e0b Mon Sep 17 00:00:00 2001 From: Yann Date: Wed, 1 Mar 2023 11:01:18 +0800 Subject: [PATCH 6/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/manager/impl/PluginSearchManager.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 787bb0e83b..685645c22e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -203,14 +203,12 @@ public class PluginSearchManager implements AlphaFineSearchProvider { List pluginModels = new ArrayList<>(); String version = "v" + ProductConstants.MAIN_VERSION; if (!Collections.isEmpty(jsonObjects)) { - jsonObjects = jsonObjects.stream() + pluginModels = jsonObjects.stream() .filter(o -> ((Integer) o.get(version)) == 1) - .sorted(Comparator.comparingLong(PluginSearchManager::parseTime).reversed()) + .sorted((Map map1, Map map2) -> Long.compare(parseTime(map2), parseTime(map1))) + .limit(DEFAULT_LIST_SIZE) + .map(jsonObject -> getPluginModel(new JSONObject(jsonObject), false)) .collect(Collectors.toList()); - int size = Math.min(DEFAULT_LIST_SIZE, jsonObjects.size()); - for (int i = 0; i < size; i++) { - pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); - } } return pluginModels; } From d37fb6df92afd28b2d1cd4f7fc812b8ba66cb341 Mon Sep 17 00:00:00 2001 From: Yann Date: Wed, 1 Mar 2023 15:12:27 +0800 Subject: [PATCH 7/7] =?UTF-8?q?REPORT-86430=20AlphaFine=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E5=BF=83tab=E9=A1=B5=E6=98=BE=E7=A4=BA=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/impl/PluginSearchManager.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 520d396f1e..685645c22e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -20,6 +20,7 @@ import com.fr.plugin.basic.version.Version; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; +import com.fr.stable.ProductConstants; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; @@ -29,7 +30,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.function.ToLongFunction; +import java.util.stream.Collectors; /** * Created by XiaXiang on 2017/3/27. @@ -120,7 +121,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { return lessModelList; } SearchResult noConnectList = AlphaFineHelper.getNoConnectList(Holder.INSTANCE); - if(noConnectList != null){ + if (noConnectList != null) { return noConnectList; } for (int j = 0; j < searchText.length; j++) { @@ -184,7 +185,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { List pluginModels = new ArrayList<>(); pluginModels.addAll(parseDefaultPluginModel(plugins)); - pluginModels.forEach(m->this.defaultModelList.add(m)); + pluginModels.forEach(m -> this.defaultModelList.add(m)); } catch (Exception e) { FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage()); @@ -196,33 +197,31 @@ public class PluginSearchManager implements AlphaFineSearchProvider { /** * 将jsonobject转化为PluginModel - * 并按照更新时间排序,取最新的10个 - * */ + * 并按照更新时间排序,取最新的10个,并过滤掉不是当前版本的 + */ List parseDefaultPluginModel(List jsonObjects) { List pluginModels = new ArrayList<>(); + String version = "v" + ProductConstants.MAIN_VERSION; if (!Collections.isEmpty(jsonObjects)) { - SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); - try { - jsonObjects.sort(Comparator.comparingLong(new ToLongFunction() { - @Override - public long applyAsLong(Map value) { - long time = 0L; - try { - time = format.parse((String) value.get(UPLOAD_TIME)).getTime(); - } catch (ParseException e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } - return time; - } - })); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e, e.getMessage()); - } - for (int i = 0; i < DEFAULT_LIST_SIZE; i++) { - pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); - } + pluginModels = jsonObjects.stream() + .filter(o -> ((Integer) o.get(version)) == 1) + .sorted((Map map1, Map map2) -> Long.compare(parseTime(map2), parseTime(map1))) + .limit(DEFAULT_LIST_SIZE) + .map(jsonObject -> getPluginModel(new JSONObject(jsonObject), false)) + .collect(Collectors.toList()); } return pluginModels; } + private static long parseTime(Map value) { + SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); + long t = 0L; + try { + t = format.parse((String) value.get(UPLOAD_TIME)).getTime(); + } catch (ParseException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return t; + } + }