|
@@ -8,6 +8,7 @@ import cn.cslg.pas.common.dto.PatentStarListDTO;
|
|
import cn.cslg.pas.common.dto.business.ContentDetailDTO;
|
|
import cn.cslg.pas.common.dto.business.ContentDetailDTO;
|
|
import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
|
|
import cn.cslg.pas.common.dto.business.EsPatentFamilyDTO;
|
|
import cn.cslg.pas.common.dto.business.SelectClaimDTO;
|
|
import cn.cslg.pas.common.dto.business.SelectClaimDTO;
|
|
|
|
+import cn.cslg.pas.common.dto.es.EsCustomFieldValueDTO;
|
|
import cn.cslg.pas.common.model.request.MapRequest;
|
|
import cn.cslg.pas.common.model.request.MapRequest;
|
|
import cn.cslg.pas.common.model.request.OrderDTO;
|
|
import cn.cslg.pas.common.model.request.OrderDTO;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
import cn.cslg.pas.common.model.request.QueryRequest;
|
|
@@ -130,6 +131,10 @@ public class EsService {
|
|
PatentDTO dto = new PatentDTO();
|
|
PatentDTO dto = new PatentDTO();
|
|
|
|
|
|
String searchCondition = "";
|
|
String searchCondition = "";
|
|
|
|
+ List<EsCustomFieldValueDTO> customFields = queryRequest.getCustomFields();
|
|
|
|
+ if (CollectionUtils.isEmpty(customFields)) {
|
|
|
|
+ searchCondition = this.parseCustomField(customFields);
|
|
|
|
+ }
|
|
Integer projectId = queryRequest.getProjectId();
|
|
Integer projectId = queryRequest.getProjectId();
|
|
Long current = queryRequest.getCurrent();
|
|
Long current = queryRequest.getCurrent();
|
|
Long size = queryRequest.getSize();
|
|
Long size = queryRequest.getSize();
|
|
@@ -222,6 +227,67 @@ public class EsService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 解析自定义栏位和值
|
|
|
|
+ * @param customFields
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public String parseCustomField(List<EsCustomFieldValueDTO> customFields) {
|
|
|
|
+ int m = 1;
|
|
|
|
+ int n = 0;
|
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
|
+ if (customFields.size() > m) {
|
|
|
|
+ builder.append("(");
|
|
|
|
+ for (int i = 0; i < customFields.size(); i++) {
|
|
|
|
+ EsCustomFieldValueDTO customField = customFields.get(i);
|
|
|
|
+ if (i != n) {
|
|
|
|
+ builder.append(" ").append("and").append(" ").append("(");
|
|
|
|
+ this.appendStr(customField, builder, m);
|
|
|
|
+ } else {
|
|
|
|
+ this.appendStr(customField, builder, m);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (int i = 0; i < customFields.size(); i++) {
|
|
|
|
+ EsCustomFieldValueDTO customField = customFields.get(i);
|
|
|
|
+ int num = customFields.size() - m;
|
|
|
|
+ if (i != n) {
|
|
|
|
+ builder.append(" ").append("and").append(" ");
|
|
|
|
+ this.appendStr(customField, builder, m);
|
|
|
|
+ } else {
|
|
|
|
+ this.appendStr(customField, builder, m);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
|
+ System.out.println("耗时" + (end-start));
|
|
|
|
+ return builder.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void appendStr(EsCustomFieldValueDTO customField, StringBuilder builder, int m) {
|
|
|
|
+ List<String> values = customField.getFieldValue();
|
|
|
|
+ builder.append("field").append("=").append(customField.getFieldId());
|
|
|
|
+ builder.append(" ").append("and").append(" ");
|
|
|
|
+ builder.append("fieldValue").append("=");
|
|
|
|
+ if (values.size() > m) {
|
|
|
|
+ builder.append("(");
|
|
|
|
+ for (int j = 0; j < values.size(); j++) {
|
|
|
|
+ String s = values.get(j);
|
|
|
|
+ if (j != values.size() - m) {
|
|
|
|
+ builder.append(s).append(" ").append("or").append(" ");
|
|
|
|
+ } else {
|
|
|
|
+ builder.append(s).append(")").append(")");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ for (String value : values) {
|
|
|
|
+ builder.append(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* @param key
|
|
* @param key
|
|
* @param page
|
|
* @param page
|
|
* @param limit
|
|
* @param limit
|