Commit 508f1e88 authored by tianyiming's avatar tianyiming

综合查询高级搜索增加officeRegion过滤

parent 1d8700d8
...@@ -12,4 +12,6 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -12,4 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
public interface CommonBaseMapper { public interface CommonBaseMapper {
String getOrgCodeByCompanyCode(String companyCode); String getOrgCodeByCompanyCode(String companyCode);
String getCompanyCodeByOrgCode(String companyCode);
} }
...@@ -5,4 +5,8 @@ ...@@ -5,4 +5,8 @@
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String"> <select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{companyCode} limit 1 select org_code from privilege_company where company_code = #{companyCode} limit 1
</select> </select>
<select id="getCompanyCodeByOrgCode" resultType="java.lang.String">
select companyCode from privilege_company where org_code = #{org_code} limit 1
</select>
</mapper> </mapper>
...@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.module.statistcs.biz.utils.QueryBuilderUtils; ...@@ -30,6 +30,7 @@ import com.yeejoin.amos.boot.module.statistcs.biz.utils.QueryBuilderUtils;
import com.yeejoin.amos.boot.module.statistcs.factory.DynamicQueryBuilder; import com.yeejoin.amos.boot.module.statistcs.factory.DynamicQueryBuilder;
import com.yeejoin.amos.boot.module.statistcs.factory.EnhancedDynamicQueryBuilder; import com.yeejoin.amos.boot.module.statistcs.factory.EnhancedDynamicQueryBuilder;
import com.yeejoin.amos.boot.module.statistics.api.enums.*; import com.yeejoin.amos.boot.module.statistics.api.enums.*;
import com.yeejoin.amos.boot.module.statistics.api.mapper.CommonBaseMapper;
import com.yeejoin.amos.boot.module.statistics.api.mapper.TzsCustomFilterMapper; import com.yeejoin.amos.boot.module.statistics.api.mapper.TzsCustomFilterMapper;
import com.yeejoin.amos.boot.module.statistics.api.vo.CompanyInfoVo; import com.yeejoin.amos.boot.module.statistics.api.vo.CompanyInfoVo;
import com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo; import com.yeejoin.amos.boot.module.statistics.api.vo.EquipInfoVo;
...@@ -142,6 +143,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -142,6 +143,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper; private final IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
private final TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper; private final TzBaseEnterpriseInfoMapper tzBaseEnterpriseInfoMapper;
private final TzsUserInfoMapper tzsUserInfoMapper; private final TzsUserInfoMapper tzsUserInfoMapper;
private final CommonBaseMapper commonMapper;
private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); private final ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
...@@ -301,10 +303,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -301,10 +303,6 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
SearchSourceBuilder builder = new SearchSourceBuilder(); SearchSourceBuilder builder = new SearchSourceBuilder();
builder.trackTotalHits(true); builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
String orgCode = filter.getString("orgCode");
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
JSONObject filterParams = null; JSONObject filterParams = null;
String licensesStatusStr = ""; String licensesStatusStr = "";
String filterType = filter.getString("filterType"); String filterType = filter.getString("filterType");
...@@ -321,7 +319,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -321,7 +319,8 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
} }
} }
// 组装人员过滤条件 // 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType); String orgCode = filter.getString("orgCode");
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType, orgCode);
if ("custom".equals(filterType)) { if ("custom".equals(filterType)) {
JSONArray leftGroup = filterParams.getJSONArray("group1"); JSONArray leftGroup = filterParams.getJSONArray("group1");
JSONArray rightGroup = filterParams.getJSONArray("group2"); JSONArray rightGroup = filterParams.getJSONArray("group2");
...@@ -404,10 +403,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -404,10 +403,25 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
/** /**
* 组装人员过滤条件 * 组装人员过滤条件
*/ */
private void getPersonBoolQueryBuilder(JSONObject filterParams, BoolQueryBuilder boolMust, String filterType) { private void getPersonBoolQueryBuilder(JSONObject filterParams, BoolQueryBuilder boolMust, String filterType, String orgCode) {
deleteUnitCategory(filterParams); deleteUnitCategory(filterParams);
// 快捷筛选和自定义筛选解析筛选规则不一致 // 快捷筛选和自定义筛选解析筛选规则不一致
if (filterType.equals("advanced")) { if (filterType.equals("advanced")) {
JSONArray unitType = filterParams.getJSONArray("unitType");
if (!ObjectUtils.isEmpty(unitType)) {
if (unitType.contains("检验机构") || unitType.contains("检测机构")) {
String officeRegion = commonMapper.getOrgCodeByCompanyCode(orgCode);
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery();
BoolQueryBuilder queryBuilder2 = QueryBuilders.boolQuery();
queryBuilder1.must(QueryBuilders.termQuery("superviseOrgCode", "50"))
.must(QueryBuilders.wildcardQuery("officeRegion", "*" + officeRegion + "*"));
queryBuilder2.mustNot(QueryBuilders.termQuery("superviseOrgCode", "50"))
.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
boolMust.should(queryBuilder1).should(queryBuilder2).minimumShouldMatch(1);
} else {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
}
}
filterParams.forEach((k, v) -> { filterParams.forEach((k, v) -> {
if (v instanceof JSONArray) { if (v instanceof JSONArray) {
if (!((JSONArray) v).contains("all") && ((JSONArray) v).size() > 0) { if (!((JSONArray) v).contains("all") && ((JSONArray) v).size() > 0) {
...@@ -3067,13 +3081,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3067,13 +3081,13 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode)); boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode));
data = queryDpCompanyStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpCompanyStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.person.getCode().equals(businessType)) { } else if (StatisticalAnalysisEnum.person.getCode().equals(businessType)) {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode)); // boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
data = queryDpPersonStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpPersonStatistics(filter, request, builder, boolMust, tabTotalMap);
} else if (StatisticalAnalysisEnum.inspectionCompany.getCode().equals(businessType)) { } else if (StatisticalAnalysisEnum.inspectionCompany.getCode().equals(businessType)) {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode)); boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode.keyword", orgCode));
data = queryDpInspectionCompanyStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpInspectionCompanyStatistics(filter, request, builder, boolMust, tabTotalMap);
} else { } else {
boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode)); // boolMust.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
data = queryDpInspectionPersonStatistics(filter, request, builder, boolMust, tabTotalMap); data = queryDpInspectionPersonStatistics(filter, request, builder, boolMust, tabTotalMap);
} }
...@@ -3090,7 +3104,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3090,7 +3104,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams"))); JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
String filterType = "advanced"; String filterType = "advanced";
// 组装人员过滤条件 // 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType); this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType, filter.getString("orgCode"));
// 通过是否传参 unitType 单位类型 区分一二级查询 // 通过是否传参 unitType 单位类型 区分一二级查询
boolean is2LeveFlag = Optional.of(filter) boolean is2LeveFlag = Optional.of(filter)
.map(obj -> obj.getJSONObject("filterParams")) .map(obj -> obj.getJSONObject("filterParams"))
...@@ -3274,7 +3288,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3274,7 +3288,7 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
String filterType = "advanced"; String filterType = "advanced";
String unitCategory = filterParams.getString("unitCategory"); String unitCategory = filterParams.getString("unitCategory");
// 组装人员过滤条件 // 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType); this.getPersonBoolQueryBuilder(filterParams, boolMust, filterType, filter.getString("orgCode"));
// 通过是否传参 unitType 单位类型 区分一二级查询 // 通过是否传参 unitType 单位类型 区分一二级查询
boolean is2LeveFlag = Optional.of(filter) boolean is2LeveFlag = Optional.of(filter)
...@@ -3951,12 +3965,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl { ...@@ -3951,12 +3965,12 @@ public class ComprehensiveStatisticalAnalysisServiceImpl {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
String orgCode = filter.getString("orgCode"); String orgCode = filter.getString("orgCode");
boolQuery.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode)); // boolQuery.must(QueryBuilders.prefixQuery("superviseOrgCode", orgCode));
JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams"))); JSONObject filterParams = JSONObject.parseObject(JSONObject.toJSONString(filter.get("filterParams")));
String filterType = "advanced"; String filterType = "advanced";
// 组装人员过滤条件 // 组装人员过滤条件
this.getPersonBoolQueryBuilder(filterParams, boolQuery, filterType); this.getPersonBoolQueryBuilder(filterParams, boolQuery, filterType, orgCode);
// 查询 // 查询
JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolQuery); JSONObject expiryDateStatus = this.getExpiryDateStatusGroupStatistics(boolQuery);
......
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