Commit 023cb216 authored by 麻笑宇's avatar 麻笑宇

调整设备区域查询方法

parent 923b2211
...@@ -24,4 +24,6 @@ public interface ScreenMapper { ...@@ -24,4 +24,6 @@ public interface ScreenMapper {
List<Map<String, String>> userCount(@Param("screenDto") ScreenDto screenDto); List<Map<String, String>> userCount(@Param("screenDto") ScreenDto screenDto);
List<Map<String, Object>> supervisorCount(@Param("screenDto") ScreenDto screenDto); List<Map<String, Object>> supervisorCount(@Param("screenDto") ScreenDto screenDto);
String getOrgCodeByCompanyCode(@Param("cityCode") String cityCode);
} }
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
GROUP BY GROUP BY
bi.industry_supervisor bi.industry_supervisor
</select> </select>
<select id="getOrgCodeByCompanyCode" resultType="java.lang.String">
select org_code from privilege_company where company_code = #{cityCode} limit 1
</select>
</mapper> </mapper>
......
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.tcm.api.dto.ScreenDto; import com.yeejoin.amos.boot.module.tcm.api.dto.ScreenDto;
import com.yeejoin.amos.boot.module.tcm.api.mapper.ScreenMapper; import com.yeejoin.amos.boot.module.tcm.api.mapper.ScreenMapper;
import com.yeejoin.amos.boot.module.tcm.api.service.statistics.IScreenService; import com.yeejoin.amos.boot.module.tcm.api.service.statistics.IScreenService;
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;
...@@ -22,6 +23,7 @@ import java.util.ArrayList; ...@@ -22,6 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Service @Service
public class ScreenImpl implements IScreenService { public class ScreenImpl implements IScreenService {
...@@ -31,6 +33,7 @@ public class ScreenImpl implements IScreenService { ...@@ -31,6 +33,7 @@ public class ScreenImpl implements IScreenService {
@Autowired @Autowired
RestHighLevelClient restHighLevelClient; RestHighLevelClient restHighLevelClient;
private static Map<String, String> regionCodeOrgCodeMap = new ConcurrentHashMap<>();
@Override @Override
public List<Map<String,Object>> companyInfo(ScreenDto screenDto) { public List<Map<String,Object>> companyInfo(ScreenDto screenDto) {
...@@ -450,9 +453,9 @@ public class ScreenImpl implements IScreenService { ...@@ -450,9 +453,9 @@ public class ScreenImpl implements IScreenService {
SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all"); SearchRequest searchRequest = new SearchRequest("idx_biz_view_jg_all");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
//设置模糊搜索 //设置模糊搜索
String orgCode = getAndSetOrgCode(screenDto.getCityCode());
searchSourceBuilder.query(QueryBuilders.boolQuery() searchSourceBuilder.query(QueryBuilders.boolQuery()
.must(QueryBuilders.wildcardQuery("USE_PLACE_CODE", "*"+screenDto.getCityCode()+"*")) .must(QueryBuilders.wildcardQuery("ORG_BRANCH_CODE.keyword", QueryParser.escape(orgCode) + "*")));
.must(QueryBuilders.termQuery("IS_INTO_MANAGEMENT", true)));
searchSourceBuilder.aggregation( searchSourceBuilder.aggregation(
AggregationBuilders.terms("USE_SITE_CODE").field("USE_SITE_CODE") AggregationBuilders.terms("USE_SITE_CODE").field("USE_SITE_CODE")
); );
...@@ -533,5 +536,14 @@ public class ScreenImpl implements IScreenService { ...@@ -533,5 +536,14 @@ public class ScreenImpl implements IScreenService {
} }
return returnList; return returnList;
} }
private String getAndSetOrgCode(String cityCode) {
String orgCode = regionCodeOrgCodeMap.get(cityCode);
if (orgCode == null) {
orgCode = screenMapper.getOrgCodeByCompanyCode(cityCode);
if (orgCode != null) {
regionCodeOrgCodeMap.put(cityCode, orgCode);
}
}
return orgCode;
}
} }
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