Commit b1a4aa7c authored by suhuiguang's avatar suhuiguang

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

parent b809ee89
...@@ -22,6 +22,7 @@ import com.yeejoin.amos.feign.systemctl.Systemctl; ...@@ -22,6 +22,7 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
...@@ -293,7 +294,7 @@ public class DPStatisticsServiceImpl { ...@@ -293,7 +294,7 @@ public class DPStatisticsServiceImpl {
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); 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)); boolMust.must(QueryBuilders.termsQuery("EQU_CATEGORY_CODE", EQU_CATEGORY_CYLINDER));
// 纳管状态为已纳管 // 纳管状态为已纳管
...@@ -324,7 +325,7 @@ public class DPStatisticsServiceImpl { ...@@ -324,7 +325,7 @@ public class DPStatisticsServiceImpl {
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); 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)); boolMust.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", true));
SearchSourceBuilder builder = new SearchSourceBuilder(); SearchSourceBuilder builder = new SearchSourceBuilder();
...@@ -514,12 +515,15 @@ public class DPStatisticsServiceImpl { ...@@ -514,12 +515,15 @@ public class DPStatisticsServiceImpl {
} }
private long countEquipNumFromES(DPFilterParamDto dpFilterParamDto, Integer... states) { private long countEquipNumFromES(DPFilterParamDto dpFilterParamDto, Integer... states) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
long num; long num;
CountRequest request = new CountRequest(); CountRequest request = new CountRequest();
request.indices("idx_biz_view_jg_all"); request.indices("idx_biz_view_jg_all");
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); 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)); boolMust.must(QueryBuilders.termsQuery("EQU_STATE", states));
request.query(boolMust); request.query(boolMust);
...@@ -597,7 +601,7 @@ public class DPStatisticsServiceImpl { ...@@ -597,7 +601,7 @@ public class DPStatisticsServiceImpl {
private long countCompanyByOperatingStatus(DPFilterParamDto dpFilterParamDto, String operatingStatus) { private long countCompanyByOperatingStatus(DPFilterParamDto dpFilterParamDto, String operatingStatus) {
String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = getAndSetOrgCode(dpFilterParamDto.getCityCode());
return enterpriseInfoMapper.countByOperatingStatusAndOrgCode(orgCode, operatingStatus); return enterpriseInfoMapper.countByOperatingStatusAndOrgCode(orgCode, operatingStatus, dpFilterParamDto.getCityCode());
} }
private Map<String, CountDto> countUserNum(DPFilterParamDto dpFilterParamDto) { private Map<String, CountDto> countUserNum(DPFilterParamDto dpFilterParamDto) {
......
...@@ -75,7 +75,8 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI ...@@ -75,7 +75,8 @@ public interface TzBaseEnterpriseInfoMapper extends BaseMapper<TzBaseEnterpriseI
* *
* @param orgCode 公司的orgCode * @param orgCode 公司的orgCode
* @param operatingStatus 营业状态 * @param operatingStatus 营业状态
* @param cityCode 区域code
* @return Long 统计数量 * @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 @@ ...@@ -221,7 +221,8 @@
FROM FROM
"tz_base_enterprise_info" "tz_base_enterprise_info"
where 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} and operating_status = #{operatingStatus}
</select> </select>
</mapper> </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