Commit b1a4aa7c authored by suhuiguang's avatar suhuiguang

1.es查询增加转义要不数据会查询多余数据

parent b809ee89
......@@ -22,6 +22,7 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
......@@ -293,7 +294,7 @@ public class DPStatisticsServiceImpl {
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", orgCode + "*"));
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 设备类别精确查询气瓶
boolMust.must(QueryBuilders.termsQuery("EQU_CATEGORY_CODE", EQU_CATEGORY_CYLINDER));
// 纳管状态为已纳管
......@@ -324,7 +325,7 @@ public class DPStatisticsServiceImpl {
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", orgCode + "*"));
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 纳管状态为已纳管
boolMust.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", true));
SearchSourceBuilder builder = new SearchSourceBuilder();
......@@ -514,12 +515,15 @@ public class DPStatisticsServiceImpl {
}
private long countEquipNumFromES(DPFilterParamDto dpFilterParamDto, Integer... states) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
long num;
CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// 区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*" + dpFilterParamDto.getCityCode() + "*"));
// 按照管辖机构区域信息模糊查询
boolMust.must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*"));
// 纳管状态为已纳管
boolMust.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", true));
// 设备状态过滤
boolMust.must(QueryBuilders.termsQuery("EQU_STATE", states));
request.query(boolMust);
......@@ -597,7 +601,7 @@ public class DPStatisticsServiceImpl {
private long countCompanyByOperatingStatus(DPFilterParamDto dpFilterParamDto, String operatingStatus) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
return enterpriseInfoMapper.countByOperatingStatusAndOrgCode(orgCode, operatingStatus);
return enterpriseInfoMapper.countByOperatingStatusAndOrgCode(orgCode, operatingStatus, dpFilterParamDto.getCityCode());
}
private Map<String, CountDto> countUserNum(DPFilterParamDto dpFilterParamDto) {
......
......@@ -75,7 +75,8 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
*
* @param orgCode 公司的orgCode
* @param operatingStatus 营业状态
* @param cityCode 区域code
* @return Long 统计数量
*/
Long countByOperatingStatusAndOrgCode(@Param("orgCode") String orgCode, @Param("operatingStatus") String operatingStatus);
Long countByOperatingStatusAndOrgCode(@Param("orgCode") String orgCode, @Param("operatingStatus") String operatingStatus, @Param("cityCode") String cityCode);
}
......@@ -221,7 +221,8 @@
FROM
"tz_base_enterprise_info"
where
supervise_org_code like concat(#{orgCode},'%')
1=1
and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{cityCode}, '%')))
and operating_status = #{operatingStatus}
</select>
</mapper>
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