Browse Source

REPORT-86430 AlphaFine插件中心tab页显示内容有误

release/11.0
Yann 2 years ago
parent
commit
4059c001cf
  1. 43
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java

43
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.Function;
/**
* 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 = "v11";
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<PluginModel> 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());
@ -197,32 +195,23 @@ public class PluginSearchManager implements AlphaFineSearchProvider {
/**
* 将jsonobject转化为PluginModel
* 并按照更新时间排序取最新的10个
* */
* 并按照更新时间排序取最新的10个并过滤掉不是当前版本的
*/
List<PluginModel> parseDefaultPluginModel(List<Map> jsonObjects) {
List<PluginModel> 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;
});
jsonObjects.sort(PluginSearchManager::sortPluginByUploadTime);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
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 +220,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);
}
}

Loading…
Cancel
Save