From 0d96e549ab542c6902d734dbad7a644e5a4efc27 Mon Sep 17 00:00:00 2001 From: o2sword <171715986@qq.com> Date: Wed, 6 Jan 2021 16:32:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E8=AE=A1=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E8=BF=94=E5=9B=9E=E5=86=85=E5=AE=B9=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/core/project/jaxrs/WrapDesigner.java | 82 +++++++++++++++---- .../control/jaxrs/designer/ActionSearch.java | 2 +- .../designer/jaxrs/designer/ActionSearch.java | 2 +- .../designer/jaxrs/designer/ActionSearch.java | 2 +- .../center/jaxrs/designer/ActionSearch.java | 2 +- .../designer/jaxrs/designer/ActionSearch.java | 2 +- .../processing/jaxrs/design/ActionSearch.java | 17 +++- .../processing/jaxrs/design/BaseAction.java | 18 ++-- 8 files changed, 94 insertions(+), 33 deletions(-) diff --git a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapDesigner.java b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapDesigner.java index 99a881f2f6..966e643a36 100644 --- a/o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapDesigner.java +++ b/o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/WrapDesigner.java @@ -4,10 +4,7 @@ import com.x.base.core.entity.enums.DesignerType; import com.x.base.core.project.annotation.FieldDescribe; import com.x.base.core.project.gson.GsonPropertyObject; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; public class WrapDesigner extends GsonPropertyObject { @@ -93,7 +90,13 @@ public class WrapDesigner extends GsonPropertyObject { for (String key : map.keySet()){ DesignerPattern pattern = new DesignerPattern(); pattern.setProperty(key); - pattern.setPropertyValue(map.get(key)); + String propertyValue = map.get(key); + if(!DesignerType.script.toString().equals(this.getDesignerType())) { + if (propertyValue != null && propertyValue.length() > 255) { + propertyValue = propertyValue.substring(0, 255); + } + } + pattern.setPropertyValue(propertyValue); patternList.add(pattern); } this.patternList = patternList; @@ -106,7 +109,13 @@ public class WrapDesigner extends GsonPropertyObject { DesignerPattern pattern = new DesignerPattern(); pattern.setElementType(elementType); pattern.setProperty(key); - pattern.setPropertyValue(map.get(key)); + String propertyValue = map.get(key); + if(!DesignerType.script.toString().equals(this.getDesignerType())) { + if (propertyValue != null && propertyValue.length() > 255) { + propertyValue = propertyValue.substring(0, 255); + } + } + pattern.setPropertyValue(propertyValue); this.patternList.add(pattern); } } @@ -120,7 +129,13 @@ public class WrapDesigner extends GsonPropertyObject { pattern.setElementId(elementId); pattern.setElementName(elementName); pattern.setProperty(key); - pattern.setPropertyValue(map.get(key)); + String propertyValue = map.get(key); + if(!DesignerType.script.toString().equals(this.getDesignerType())) { + if (propertyValue != null && propertyValue.length() > 255) { + propertyValue = propertyValue.substring(0, 255); + } + } + pattern.setPropertyValue(propertyValue); this.patternList.add(pattern); } } @@ -138,12 +153,8 @@ public class WrapDesigner extends GsonPropertyObject { for (DesignerPattern pattern : this.patternList){ if ("text".equals(pattern.getProperty())){ designerPattern = pattern; - }else{ - pattern.setPropertyValue(null); } } - }else{ - this.clearPatternValue(); } return designerPattern; } @@ -160,11 +171,27 @@ public class WrapDesigner extends GsonPropertyObject { @FieldDescribe("设计属性.") private String property; - @FieldDescribe("设计属性.") + @FieldDescribe("设计属性值.") private String propertyValue; - @FieldDescribe("匹配行") - private List lines; + @FieldDescribe("script匹配行") + private List lines; + + public void setLines(Map map){ + if(map!=null){ + List lines = new ArrayList<>(); + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry entry = iterator.next(); + PatternLine patternLine = new PatternLine(); + patternLine.setLine(entry.getKey()); + patternLine.setLineValue(entry.getValue()); + lines.add(patternLine); + } + this.lines = lines; + map.clear(); + } + } public String getElementType() { return elementType; @@ -198,11 +225,11 @@ public class WrapDesigner extends GsonPropertyObject { this.property = property; } - public List getLines() { + public List getLines() { return lines; } - public void setLines(List lines) { + public void setLines(List lines) { this.lines = lines; } @@ -215,4 +242,27 @@ public class WrapDesigner extends GsonPropertyObject { } } + public class PatternLine extends GsonPropertyObject { + @FieldDescribe("第几行匹配到") + private Integer line; + @FieldDescribe("匹配行内容") + private String lineValue; + + public Integer getLine() { + return line; + } + + public void setLine(Integer line) { + this.line = line; + } + + public String getLineValue() { + return lineValue; + } + + public void setLineValue(String lineValue) { + this.lineValue = lineValue; + } + } + } diff --git a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/designer/ActionSearch.java b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/designer/ActionSearch.java index 9eb0917ef7..b8605dc594 100644 --- a/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/designer/ActionSearch.java +++ b/o2server/x_cms_assemble_control/src/main/java/com/x/cms/assemble/control/jaxrs/designer/ActionSearch.java @@ -37,7 +37,7 @@ class ActionSearch extends BaseAction { throw new ExceptionAccessDenied(effectivePerson); } Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - logger.info("{}开始内容管理设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); + logger.debug("{}开始内容管理设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } diff --git a/o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/designer/ActionSearch.java b/o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/designer/ActionSearch.java index 8bd7b95b32..f4d3903921 100644 --- a/o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/designer/ActionSearch.java +++ b/o2server/x_portal_assemble_designer/src/main/java/com/x/portal/assemble/designer/jaxrs/designer/ActionSearch.java @@ -38,7 +38,7 @@ class ActionSearch extends BaseAction { throw new ExceptionAccessDenied(effectivePerson); } Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - logger.info("{}开始门户设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); + logger.debug("{}开始门户设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } diff --git a/o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/designer/ActionSearch.java b/o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/designer/ActionSearch.java index c47a93642c..872bb7e23c 100644 --- a/o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/designer/ActionSearch.java +++ b/o2server/x_processplatform_assemble_designer/src/main/java/com/x/processplatform/assemble/designer/jaxrs/designer/ActionSearch.java @@ -39,7 +39,7 @@ class ActionSearch extends BaseAction { throw new ExceptionAccessDenied(effectivePerson); } Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - logger.info("{}开始流程平台设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); + logger.debug("{}开始流程平台设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } diff --git a/o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/designer/ActionSearch.java b/o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/designer/ActionSearch.java index 054bd002ca..5b2880e7ed 100644 --- a/o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/designer/ActionSearch.java +++ b/o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/designer/ActionSearch.java @@ -35,7 +35,7 @@ class ActionSearch extends BaseAction { throw new ExceptionAccessDenied(effectivePerson); } Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - logger.info("{}开始服务管理设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); + logger.debug("{}开始服务管理设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } diff --git a/o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/designer/ActionSearch.java b/o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/designer/ActionSearch.java index 0b1795b605..61e0a32a26 100644 --- a/o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/designer/ActionSearch.java +++ b/o2server/x_query_assemble_designer/src/main/java/com/x/query/assemble/designer/jaxrs/designer/ActionSearch.java @@ -38,7 +38,7 @@ class ActionSearch extends BaseAction { throw new ExceptionAccessDenied(effectivePerson); } Wi wi = this.convertToWrapIn(jsonElement, Wi.class); - logger.info("{}开始数据中心设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); + logger.debug("{}开始数据中心设计搜索,关键字:{}", effectivePerson.getDistinguishedName(), wi.getKeyword()); if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } diff --git a/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java b/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java index 28f802aa68..c7877214e7 100644 --- a/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java +++ b/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/ActionSearch.java @@ -19,10 +19,12 @@ import org.apache.commons.lang3.StringUtils; import java.util.*; import java.util.concurrent.*; +import java.util.concurrent.locks.ReentrantLock; class ActionSearch extends BaseAction { private static Logger logger = LoggerFactory.getLogger(ActionSearch.class); + private static ReentrantLock lock = new ReentrantLock(); ActionResult execute(EffectivePerson effectivePerson, JsonElement jsonElement) throws Exception { @@ -31,8 +33,17 @@ class ActionSearch extends BaseAction { if(StringUtils.isBlank(wi.getKeyword())){ throw new ExceptionFieldEmpty("keyword"); } - logger.print("{}搜索全局设计:{}", effectivePerson.getDistinguishedName(), wi); - result.setData(search(wi)); + logger.info("{}搜索全局设计:{}", effectivePerson.getDistinguishedName(), wi); + if (ListTools.isEmpty(wi.getModuleList())) { + result.setData(search(wi)); + }else{ + lock.lock(); + try { + result.setData(search(wi)); + } finally { + lock.unlock(); + } + } return result; } @@ -132,7 +143,7 @@ class ActionSearch extends BaseAction { for (WrapDesigner designer : designerList) { WrapDesigner.DesignerPattern pattern = designer.getScriptDesigner(); if(pattern!=null) { - List lines = patternLines(designer.getDesignerId() + "-" + designer.getUpdateTime().getTime(), + Map lines = patternLines(designer.getDesignerId() + "-" + designer.getUpdateTime().getTime(), wi.getKeyword(), pattern.getPropertyValue(), wi.getCaseSensitive(), wi.getMatchWholeWord(), wi.getMatchRegExp()); pattern.setLines(lines); pattern.setPropertyValue(null); diff --git a/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java b/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java index c3bacb9551..3ecb2d80c4 100644 --- a/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java +++ b/o2server/x_query_service_processing/src/main/java/com/x/query/service/processing/jaxrs/design/BaseAction.java @@ -2,24 +2,21 @@ package com.x.query.service.processing.jaxrs.design; import com.x.base.core.project.config.Config; import com.x.base.core.project.jaxrs.StandardJaxrsAction; +import com.x.base.core.project.jaxrs.WrapDesigner; import com.x.base.core.project.tools.DefaultCharset; import com.x.base.core.project.tools.FileTools; import com.x.base.core.project.tools.StringTools; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.*; abstract class BaseAction extends StandardJaxrsAction { - protected List patternLines(String id, String keyword, String content, Boolean caseSensitive, Boolean matchWholeWord, Boolean matchRegExp){ - List list = new ArrayList<>(); + protected Map patternLines(String id, String keyword, String content, Boolean caseSensitive, Boolean matchWholeWord, Boolean matchRegExp){ + Map map = new LinkedHashMap<>(); File file = readFile(id, content); if (file!=null){ try (RandomAccessFile randomFile = new RandomAccessFile(file, "r")) { @@ -31,7 +28,10 @@ abstract class BaseAction extends StandardJaxrsAction { String lineStr = new String(bytes); if(StringUtils.isNotBlank(lineStr) && lineStr.length()>=keyword.length()){ if(StringTools.matchKeyword(keyword, lineStr, caseSensitive, matchWholeWord, matchRegExp)){ - list.add(curReadLine); + if(lineStr.length()>500){ + lineStr = lineStr.substring(0, 500); + } + map.put(curReadLine, lineStr); } } } @@ -39,7 +39,7 @@ abstract class BaseAction extends StandardJaxrsAction { e.printStackTrace(); } } - return list; + return map; } private synchronized File readFile(String id, String content){ -- GitLab