Commit bf16fa1d authored by tianbo's avatar tianbo

refactor(amos-boot-module-statistics): 重构企业统计方法并添加新功能

- 重构了企业统计查询逻辑,提高了代码复用性和可维护性 - 新增了企业监管标签和行业主管部分的统计功能 - 优化了许可状态统计的实现方式 - 调整了统计结果的数据结构,使其更加清晰和易于使用 - 引入了新的枚举类 UnitCategoryEnum 来定义单位类别
parent 0eb4bc32
package com.yeejoin.amos.boot.module.statistics.api.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum UnitCategoryEnum {
use("使用单位", "use"),
license("许可单位", "license");
private final String name;
private final String code;
}
...@@ -44,7 +44,7 @@ public class QueryBuilderUtils { ...@@ -44,7 +44,7 @@ public class QueryBuilderUtils {
* @param spiltSymbol 分割符号,如:# * @param spiltSymbol 分割符号,如:#
* @param aggName 聚合名称,根据此名称从查询结果获取数据,如:Terms unitTypesTerms = searchResponse.getAggregations().get(aggName) * @param aggName 聚合名称,根据此名称从查询结果获取数据,如:Terms unitTypesTerms = searchResponse.getAggregations().get(aggName)
*/ */
public static void buildSplitFieldAggCondition(SearchSourceBuilder searchSourceBuilder, String field, String spiltSymbol, String aggName) { public static void buildSplitFieldAggCondition(SearchSourceBuilder searchSourceBuilder, String field, String spiltSymbol, String aggName, String params) {
// Painless 脚本内容 // Painless 脚本内容
String scriptSource = "if (doc['" + field + "'].size() > 0) {" + String scriptSource = "if (doc['" + field + "'].size() > 0) {" +
" String value = doc['" + field + "'].value;" + " String value = doc['" + field + "'].value;" +
...@@ -54,6 +54,6 @@ public class QueryBuilderUtils { ...@@ -54,6 +54,6 @@ public class QueryBuilderUtils {
"}" + "}" +
"return [];"; "return [];";
Script script = new Script(ScriptType.INLINE, "painless", scriptSource, Collections.emptyMap()); Script script = new Script(ScriptType.INLINE, "painless", scriptSource, Collections.emptyMap());
searchSourceBuilder.aggregation(AggregationBuilders.terms(aggName).script(script)); searchSourceBuilder.aggregation(AggregationBuilders.terms(aggName).script(script).missing(params).size(100));
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment