Browse Source

REPORT-75093 运营产品化二期

1、根据设计器id进行动态过滤
2、模板资源下载修改
3、添加埋点
feature/x
Link.Zhao 3 years ago
parent
commit
59a340c132
  1. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java
  2. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java
  3. 51
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  4. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java
  5. 49
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/ProductNews.java
  6. 8
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  7. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java
  8. 29
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java
  9. 68
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java

@ -5,8 +5,9 @@ import com.fr.base.svg.IconUtils;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.general.CloudCenter; import com.fr.general.CloudCenter;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import javax.swing.Icon;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Font; import java.awt.Font;
@ -14,7 +15,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import javax.swing.Icon;
/** /**
@ -154,7 +154,11 @@ public class AlphaFineConstants {
public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview"); public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview");
public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid", "https://cid.fanruan.com/api/nav/alphafine"); public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid", "https://cid.fanruan.com/api/alphafine/indexlist");
public static final String ALPHA_CID_USER_GROUP_INFO = CloudCenter.getInstance().acquireUrlByKind("af.cid.user.group.info", "https://cid.fanruan.com/api/alphafine/viewlist");
public static final String SEARCH_BY_ID = "?id=";
private static final String DEFAULT_RECOMMEND = "[ { \"name\":\"快速入门指南\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1335.html?source=3\" }, { \"name\":\"报表应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1336.html?source=3\" }, { \"name\":\"参数应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4219.html?source=3\" }, { \"name\":\"填报学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4103.html?source=3\" }, { \"name\":\"API接口汇总\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4327.html?source=3\" }, { \"name\":\"文档月刊\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4613.html?source=3\" } ]"; private static final String DEFAULT_RECOMMEND = "[ { \"name\":\"快速入门指南\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1335.html?source=3\" }, { \"name\":\"报表应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-1336.html?source=3\" }, { \"name\":\"参数应用学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4219.html?source=3\" }, { \"name\":\"填报学习路径\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4103.html?source=3\" }, { \"name\":\"API接口汇总\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4327.html?source=3\" }, { \"name\":\"文档月刊\", \"link\":\"https://help.fanruan.com/finereport/doc-view-4613.html?source=3\" } ]";

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java

@ -22,7 +22,7 @@ public class StartUseAction implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String url = FineMarketClientHelper.getInstance().getTemplateDownLoadUrl(resourceDetail.getRoot()); String url = FineMarketClientHelper.getInstance().getResourceDownloadUrl(resourceDetail.getRoot());
if (url == null) { if (url == null) {
// 如果获取失败,跳转到所有模板页面 // 如果获取失败,跳转到所有模板页面
url = FineMarketClientHelper.getInstance().getFineMarketTemplateUrl(); url = FineMarketClientHelper.getInstance().getFineMarketTemplateUrl();

51
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java

@ -506,7 +506,35 @@ public class AlphaFineFrame extends JFrame {
tabPane.repaint(); tabPane.repaint();
// 选中事件 // 选中事件
switch (selectedLabel.getCellType()) { switchTab(selectedLabel.getCellType(), readLabel);
if (currentSearchWorkerManager != null) {
AlphaFineList alphaFineList = currentSearchWorkerManager.getSearchResultList();
if (alphaFineList != null) {
alphaFineList.setSelectedIndex(0);
}
}
}
private Color defaultColor;
@Override
public void mouseEntered(MouseEvent e) {
defaultColor = selectedLabel.getForeground();
selectedLabel.setForeground(AlphaFineConstants.SUSPENDED_COLOR);
}
@Override
public void mouseExited(MouseEvent e) {
selectedLabel.setForeground(defaultColor);
}
};
}
// 方便记埋点
private void switchTab(CellType cellType, UILabel readLabel) {
switch (cellType) {
case PRODUCT_NEWS: case PRODUCT_NEWS:
readLabel.setVisible(true); readLabel.setVisible(true);
switchType(CellType.PRODUCT_NEWS); switchType(CellType.PRODUCT_NEWS);
@ -532,27 +560,6 @@ public class AlphaFineFrame extends JFrame {
switchType(CellType.TEMPLATE_SHOP); switchType(CellType.TEMPLATE_SHOP);
break; break;
} }
if (currentSearchWorkerManager != null) {
AlphaFineList alphaFineList = currentSearchWorkerManager.getSearchResultList();
if (alphaFineList != null) {
alphaFineList.setSelectedIndex(0);
}
}
}
private Color defaultColor;
@Override
public void mouseEntered(MouseEvent e) {
defaultColor = selectedLabel.getForeground();
selectedLabel.setForeground(AlphaFineConstants.SUSPENDED_COLOR);
}
@Override
public void mouseExited(MouseEvent e) {
selectedLabel.setForeground(defaultColor);
}
};
} }
private List<SelectedLabel> createSelectedLabelList() { private List<SelectedLabel> createSelectedLabelList() {

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java

@ -5,18 +5,15 @@ import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.mainframe.alphafine.model.ProductNews;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListModel;
import java.awt.Cursor; import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Point; import java.awt.Point;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter; import java.awt.event.MouseMotionAdapter;
import java.net.URI;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListModel;
/** /**
* @author hades * @author hades
@ -64,11 +61,16 @@ public class ProductNewsList extends JList<ProductNews> {
private void dealWithClick() { private void dealWithClick() {
ProductNews productNews = getSelectedValue(); ProductNews productNews = getSelectedValue();
BrowseUtils.browser(productNews.getUrl()); openNewsInBrowser(productNews.getUrl());
DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet().add(productNews.getId()); DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet().add(productNews.getId());
AlphaFineHelper.getAlphaFineDialog().repaint(); AlphaFineHelper.getAlphaFineDialog().repaint();
} }
// 方便埋点
private void openNewsInBrowser(String url) {
BrowseUtils.browser(url);
}
public int getHoverIndex() { public int getHoverIndex() {
return hoverIndex; return hoverIndex;
} }

49
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/ProductNews.java

@ -1,8 +1,12 @@
package com.fr.design.mainframe.alphafine.model; package com.fr.design.mainframe.alphafine.model;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import java.awt.Image; import java.awt.Image;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 产品动态 * 产品动态
@ -17,7 +21,9 @@ public class ProductNews {
private String title; private String title;
private Tag tag; private Tag tag;
private Target target;
// 推送对象,对象为 list<用户组id>
private List<String> target;
private Status status; private Status status;
private String url; private String url;
@ -26,6 +32,8 @@ public class ProductNews {
private Date pushDate; private Date pushDate;
public static final String ALL_USER_TARGET = "0";
/** /**
* 创建cid的用户 * 创建cid的用户
*/ */
@ -58,11 +66,11 @@ public class ProductNews {
return this; return this;
} }
public Target getTarget() { public List<String> getTarget() {
return target; return target;
} }
public ProductNews setTarget(Target target) { public ProductNews setTarget(List<String> target) {
this.target = target; this.target = target;
return this; return this;
} }
@ -172,29 +180,18 @@ public class ProductNews {
} }
} }
public enum Target { /**
ALL_USER(0); * 将接口中的target字段转换一下
* 原始数据是字符串例如"1,2,3,4"
private final int code; * 转换为 List<int>{1,2,3,4}
* */
Target(int code) { public static List<String> ParseTarget(String s) {
this.code = code; List<String> list = new ArrayList<>();
} if (s != null) {
String[] targets = s.split(",");
public int getCode() { list.addAll(Arrays.asList(targets));
return code; }
} return list;
public static Target parseCode(int code) {
for (Target target : values()) {
if (target.code == code) {
return target;
}
}
throw new IllegalArgumentException();
}
} }
} }

8
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java

@ -117,13 +117,17 @@ public class TemplateResourceDetailPane extends JPanel {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
String url = data.getResourceUrl(); openResourceUrl(data.getResourceUrl());
BrowseUtils.browser(url);
} }
}); });
return linkLabel; return linkLabel;
} }
// 方便埋点
void openResourceUrl(String url) {
BrowseUtils.browser(url);
}
JButton createStartUseButton() { JButton createStartUseButton() {
JButton starUseButton = new JButton(START_USE); JButton starUseButton = new JButton(START_USE);
starUseButton.addActionListener(new StartUseAction(data)); starUseButton.addActionListener(new StartUseAction(data));

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java

@ -20,12 +20,12 @@ public class TemplateShopPane extends JPanel {
return INSTANCE; return INSTANCE;
} }
// public 方便埋点
private static final String DEFAULT_PAGE_PANEL = "defaultPagePane"; public static final String DEFAULT_PAGE_PANEL = "defaultPagePane";
private static final String PAGE_PANEL = "pagePane"; public static final String PAGE_PANEL = "pagePane";
private static final String DETAIL_PANEL = "detailPane"; public static final String DETAIL_PANEL = "detailPane";
private static final String LOADING_PANEL = "loadingPane"; public static final String LOADING_PANEL = "loadingPane";
private String currentCard = Strings.EMPTY; public String currentCard = Strings.EMPTY;
private CardLayout cardLayout = new CardLayout(); private CardLayout cardLayout = new CardLayout();
@ -99,6 +99,10 @@ public class TemplateShopPane extends JPanel {
} }
// 方便埋点,勿删
public String getCurrentCard() {
return currentCard;
}
private JPanel createContentPane(List<TemplateResource> templateResources) { private JPanel createContentPane(List<TemplateResource> templateResources) {
return new TemplateResourcePageGridPane(templateResources); return new TemplateResourcePageGridPane(templateResources);

29
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

@ -22,6 +22,7 @@ public class FineMarketClientHelper {
public static final String FINE_MARKET_TEMPLATE_INFO = CloudCenter.getInstance().acquireUrlByKind("market.template.info", "https://market.fanruan.com/templates/"); public static final String FINE_MARKET_TEMPLATE_INFO = CloudCenter.getInstance().acquireUrlByKind("market.template.info", "https://market.fanruan.com/templates/");
public static final String FINE_MARKET_TEMPLATE_URL = CloudCenter.getInstance().acquireUrlByKind("market.template.url", "https://market.fanruan.com/template/"); public static final String FINE_MARKET_TEMPLATE_URL = CloudCenter.getInstance().acquireUrlByKind("market.template.url", "https://market.fanruan.com/template/");
public static final String FILE_DOWNLOAD = "file/"; public static final String FILE_DOWNLOAD = "file/";
public static final String PACKAGE_DOWNLOAD = "package/download/";
public static final String TEMPLATES_PARENT_PACKAGE = "parent/"; public static final String TEMPLATES_PARENT_PACKAGE = "parent/";
public static final String TEMPLATES_TAGS = "filter"; public static final String TEMPLATES_TAGS = "filter";
public static final String NAME_SEARCH = "?searchKeyword="; public static final String NAME_SEARCH = "?searchKeyword=";
@ -39,17 +40,33 @@ public class FineMarketClientHelper {
/** /**
* 获取模板的下载链接 * 获取模板资源的下载链接
* */ * */
public String getTemplateDownLoadUrl(TemplateResource templateResource) { public String getResourceDownloadUrl(TemplateResource templateResource) {
String url = FINE_MARKET_TEMPLATE_INFO + FILE_DOWNLOAD; if (TemplateResource.Type.SCENARIO_SOLUTION.equals(templateResource.getType())) {
if (templateResource != null) { return getPackageDownloadUrl(templateResource.getId());
return url + templateResource.getId();
} else { } else {
return null; return getFileDownLoadUrl(templateResource.getId());
}
}
/**
* 打开浏览器打包并下载模板资源包可能会很慢
* */
private String getPackageDownloadUrl(String id) {
return FINE_MARKET_TEMPLATE_INFO + PACKAGE_DOWNLOAD + id;
} }
/**
* 打开浏览器下载单一模板
* */
private String getFileDownLoadUrl(String id) {
return FINE_MARKET_TEMPLATE_INFO + FILE_DOWNLOAD + id;
} }
/** /**
* 获取帆软市场模板资源页面链接 * 获取帆软市场模板资源页面链接
* */ * */

68
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager.impl; package com.fr.design.mainframe.alphafine.search.manager.impl;
import com.fr.concurrent.NamedThreadFactory; import com.fr.concurrent.NamedThreadFactory;
import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.mainframe.alphafine.model.ProductNews;
@ -12,17 +13,19 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.imageio.ImageIO;
import java.awt.Image; import java.awt.Image;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.imageio.ImageIO;
public class ProductNewsSearchManager { public class ProductNewsSearchManager {
@ -91,7 +94,7 @@ public class ProductNewsSearchManager {
setImage(getCoverImage(obj.getString("pic"))). setImage(getCoverImage(obj.getString("pic"))).
setUrl(obj.getString("url")).setTag(ProductNews.Tag.parseCode(obj.getInt("tag"))). setUrl(obj.getString("url")).setTag(ProductNews.Tag.parseCode(obj.getInt("tag"))).
setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget( setStatus(ProductNews.Status.parseCode(obj.getInt("status"))).setTarget(
ProductNews.Target.parseCode(obj.getInt("target"))). ProductNews.ParseTarget(obj.getString("target"))).
setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time"))); setCreator(obj.getInt("creator")).setPushDate(new Date(obj.getLong("push_time")));
Date currentDate = new Date(System.currentTimeMillis()); Date currentDate = new Date(System.currentTimeMillis());
// 推送时间check // 推送时间check
@ -100,9 +103,70 @@ public class ProductNewsSearchManager {
idSet.add(productNews.getId()); idSet.add(productNews.getId());
} }
} }
filterByDesignerId(productNewsList);
return productNewsList; return productNewsList;
} }
/**
* 将productNews根据设计器id进行过滤
* productNews有个target字段代表推送对象用户组检查设计器id是否在用户组中来进行过滤
* */
private List<ProductNews> filterByDesignerId(List<ProductNews> list) {
//设计器id
String designId = DesignerEnvManager.getEnvManager().getUUID();
HashMap<String, Set<String>> userGroupInfoCache = new HashMap<>();
//遍历资源,获取target下的所有用户组信息,检查是否包含设计器id
Iterator<ProductNews> iterator = list.iterator();
while (iterator.hasNext()) {
List<String> targets = iterator.next().getTarget();
boolean targetsContainDesignerId = false;
// 每条推送可能推送至多个用户组,需要逐一判断
for (String userGroupId : targets) {
// 没有记录的用户组信息需要请求一下
if (!userGroupInfoCache.containsKey(userGroupId)) {
userGroupInfoCache.put(userGroupId, searchUserGroupInfo(userGroupId));
}
// 判断设计器id是否在这个用户组中,在则退出判断,不在则继续
if (userGroupInfoCache.get(userGroupId).contains(designId) || userGroupId.equals(ProductNews.ALL_USER_TARGET)) {
targetsContainDesignerId = true;
break;
}
}
if (!targetsContainDesignerId) {
iterator.remove();
}
}
return list;
}
/**
* 根据用户组id查询用户组信息改用户组中的所有设计器id
* */
private Set<String> searchUserGroupInfo(String userGroupId) {
String url = AlphaFineConstants.ALPHA_CID_USER_GROUP_INFO + AlphaFineConstants.SEARCH_BY_ID + userGroupId;
Set<String> idSet = new HashSet<>();
try {
String jsonStr = HttpToolbox.get(url);
JSONObject jsonObject = new JSONObject(jsonStr);
JSONArray idArray = jsonObject.getJSONArray("data");
for (int i = 0; i < idArray.length(); i++) {
idSet.add(idArray.getJSONObject(i).getString("userid"));
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return idSet;
}
public List<ProductNews> getCachedProductNewsList() { public List<ProductNews> getCachedProductNewsList() {
return productNewsList; return productNewsList;
} }

Loading…
Cancel
Save