From e4af85f87cb09cfb85ee6bf5ea6ff87c48c2f8a2 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 May 2022 17:41:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-71157=20alphafine=20=E9=AB=98?= =?UTF-8?q?=E7=BA=A7=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD=E5=A4=B1=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/component/AlphaFineFrame.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java index 218b244baa..100e58cd38 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java @@ -77,6 +77,18 @@ import javax.swing.Timer; public class AlphaFineFrame extends JFrame { private static final String ADVANCED_SEARCH_MARK = "k:"; + private static final String ACTION_MARK_SHORT = "k:1 "; + private static final String ACTION_MARK = "k:setting "; + private static final String DOCUMENT_MARK_SHORT = "k:2 "; + private static final String DOCUMENT_MARK = "k:help "; + private static final String FILE_MARK_SHORT = "k:3 "; + private static final String FILE_MARK = "k:reportlets "; + private static final String CPT_MARK = "k:cpt "; + private static final String FRM_MARK = "k:frm "; + private static final String DS_MARK = "k:ds "; + private static final String DS_NAME = "dsname=\""; + private static final String PLUGIN_MARK_SHORT = "k:4 "; + private static final String PLUGIN_MARK = "k:shop "; private static final int TIMER_DELAY = 300; @@ -663,7 +675,7 @@ public class AlphaFineFrame extends JFrame { private void doSearch(String text) { initSearchLoadingPane(); - SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult); + SearchTextBean searchTextBean = generateSearchTextBean(text); this.productNewsSearchWorkerManager.doSearch(searchTextBean); this.settingSearchWorkerManager.doSearch(searchTextBean); this.fileSearchWorkerManager.doSearch(searchTextBean); @@ -671,6 +683,21 @@ public class AlphaFineFrame extends JFrame { this.pluginSearchWorkerManager.doSearch(searchTextBean); } + private SearchTextBean generateSearchTextBean(String searchText) { + if (searchText.startsWith(ACTION_MARK_SHORT) || searchText.startsWith(ACTION_MARK) + || searchText.startsWith(DOCUMENT_MARK_SHORT) || searchText.startsWith(DOCUMENT_MARK)) { + return new SearchTextBean(StringUtils.EMPTY, new String[]{getStoreText(searchText)}); + } else if (searchText.startsWith(FILE_MARK_SHORT) || searchText.startsWith(FILE_MARK) + || searchText.startsWith(CPT_MARK) || searchText.startsWith(FRM_MARK) + || searchText.startsWith(PLUGIN_MARK_SHORT) || searchText.startsWith(PLUGIN_MARK)) { + return new SearchTextBean(getStoreText(searchText), new String[]{getStoreText(searchText)}); + } else if (searchText.startsWith(DS_MARK)) { + return new SearchTextBean(getStoreText(searchText), new String[]{DS_NAME + getStoreText(searchText)}); + } else { + return new SearchTextBean(searchText, segmentationResult); + } + } + /** * 仅搜索依赖网络的搜索项 * From 1a49e536029074c7204514d3e3054c0d17bbea46 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 9 May 2022 19:51:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-67417=20=E6=90=9C=E7=B4=A2=E5=8E=86?= =?UTF-8?q?=E5=8F=B2/=E5=B7=B2=E8=AF=BB=E5=8A=A8=E6=80=81=20=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alphafine/AlphaFineConfigManager.java | 66 ++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index a8970f9d10..892c57ff88 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -9,7 +9,7 @@ import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; -import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -99,7 +99,6 @@ public class AlphaFineConfigManager implements XMLable { private String cacheBuildNO; - // todo 暂不持久化 方便测试 /** * key: 登录的bbs用户 * value: alphaFine历史搜索记录 @@ -154,6 +153,10 @@ public class AlphaFineConfigManager implements XMLable { } else if (reader.isChildNode()) { if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) { readActionSearchTextCacheXML(reader); + } else if ("SearchHistory".equals(reader.getTagName())) { + readHistorySearch(reader); + } else if ("ReadSet".equals(reader.getTagName())) { + readReadSet(reader); } } } @@ -180,6 +183,47 @@ public class AlphaFineConfigManager implements XMLable { }); } + private void readHistorySearch(XMLableReader reader) { + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader xmLableReader) { + if (ComparatorUtils.equals(reader.getTagName(), "history")) { + String tmpVal = reader.getElementValue(); + if (tmpVal != null) { + tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY); + Stack stack = new SizedStack<>(3); + List historyList = Arrays.asList(tmpVal.split(",")); + for (String history : historyList) { + stack.add(history.trim()); + } + historySearchMap.put(reader.getAttrAsString("user", StringUtils.EMPTY), stack); + } + } + } + }); + } + + + private void readReadSet(XMLableReader reader) { + reader.readXMLObject(new XMLReadable() { + @Override + public void readXML(XMLableReader xmLableReader) { + if (ComparatorUtils.equals(reader.getTagName(), "readId")) { + String tmpVal = reader.getElementValue(); + if (tmpVal != null) { + tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY); + String[] idArr = tmpVal.split(","); + Set setId = new HashSet<>(); + for (String id : idArr) { + setId.add(Long.parseLong(id.trim())); + } + readSetMap.put(reader.getAttrAsString("user", StringUtils.EMPTY), setId); + } + } + } + }); + } + @Override public void writeXML(XMLPrintWriter writer) { writer.startTAG("AlphaFineConfigManager"); @@ -198,6 +242,8 @@ public class AlphaFineConfigManager implements XMLable { .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()) .attr("productDynamics", this.isProductDynamics()); writeActionSearchTextCacheXML(writer); + writeSearchHistory(writer); + writeReadSet(writer); writer.end(); } @@ -212,6 +258,22 @@ public class AlphaFineConfigManager implements XMLable { writer.end(); } + private void writeSearchHistory(XMLPrintWriter writer) { + writer.startTAG("SearchHistory"); + for (Map.Entry> entry : historySearchMap.entrySet()) { + writer.startTAG("history").attr("user", entry.getKey()).textNode(entry.getValue().toString()).end(); + } + writer.end(); + } + + private void writeReadSet(XMLPrintWriter writer) { + writer.startTAG("ReadSet"); + for (Map.Entry> entry : readSetMap.entrySet()) { + writer.startTAG("readId").attr("user", entry.getKey()).textNode(entry.getValue().toString()).end(); + } + writer.end(); + } + public boolean isSearchOnLine() { return searchOnLine; }