Commit 6ff3668e authored by suhuiguang's avatar suhuiguang

1.人员过滤修改,代码优化

parent e63fd598
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
ei.legal_person, ei.legal_person,
ei.use_contact, ei.use_contact,
ei.contact_phone, ei.contact_phone,
(select count(1) from tzs_user_info u where u.unit_code = ei.use_unit_code and u.is_delete = false) as personNum, (select count(1) from tzs_user_info u where u.unit_code = ei.use_code and u.is_delete = false) as personNum,
( (
select select
group_concat(concat(a.cert_no,'#',a.expiry_date)) cert_no group_concat(concat(a.cert_no,'#',a.expiry_date)) cert_no
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
FROM FROM
( SELECT org_code FROM privilege_company WHERE company_code = #{screenDto.cityCode} ) AS subquery ( SELECT org_code FROM privilege_company WHERE company_code = #{screenDto.cityCode} ) AS subquery
INNER JOIN tz_base_enterprise_info bi ON bi.supervise_org_code LIKE CONCAT ( subquery.org_code, '%' ) INNER JOIN tz_base_enterprise_info bi ON bi.supervise_org_code LIKE CONCAT ( subquery.org_code, '%' )
INNER JOIN tzs_user_info tui ON bi.use_unit_code = tui.unit_code INNER JOIN tzs_user_info tui ON bi.use_code = tui.unit_code
WHERE WHERE
tui.post LIKE concat ( '%', '6552', '%' ) tui.post LIKE concat ( '%', '6552', '%' )
AND bi.unit_type IS NOT NULL AND bi.unit_type IS NOT NULL
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
FROM FROM
( SELECT org_code FROM privilege_company WHERE company_code = #{screenDto.cityCode} ) AS subquery ( SELECT org_code FROM privilege_company WHERE company_code = #{screenDto.cityCode} ) AS subquery
INNER JOIN tz_base_enterprise_info bi ON bi.supervise_org_code LIKE CONCAT ( subquery.org_code, '%' ) INNER JOIN tz_base_enterprise_info bi ON bi.supervise_org_code LIKE CONCAT ( subquery.org_code, '%' )
INNER JOIN tzs_user_info tui ON bi.use_unit_code = tui.unit_code INNER JOIN tzs_user_info tui ON bi.use_code = tui.unit_code
WHERE WHERE
bi.unit_type IS NOT NULL bi.unit_type IS NOT NULL
AND tui.post IS NOT NULL AND tui.post IS NOT NULL
......
...@@ -17,7 +17,6 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper; ...@@ -17,7 +17,6 @@ import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.RegionModel; import com.yeejoin.amos.feign.systemctl.model.RegionModel;
import org.apache.lucene.queryparser.classic.QueryParser; import org.apache.lucene.queryparser.classic.QueryParser;
import org.bouncycastle.pqc.crypto.newhope.NHOtherInfoGenerator;
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;
...@@ -108,7 +107,7 @@ public class StCommonServiceImpl { ...@@ -108,7 +107,7 @@ public class StCommonServiceImpl {
regionModels.add(r); regionModels.add(r);
this.loopSetChildRegin(regionModels, r.getChildren()); this.loopSetChildRegin(regionModels, r.getChildren());
}); });
regionCodeRegionMap = regionModels.stream().collect(Collectors.toMap(RegionModel::getRegionCode, Function.identity(),(k1,k2)->k2)); regionCodeRegionMap = regionModels.stream().collect(Collectors.toMap(RegionModel::getRegionCode, Function.identity(), (k1, k2) -> k2));
} }
private void loopSetChildRegin(List<RegionModel> regionModels, Collection<RegionModel> children) { private void loopSetChildRegin(List<RegionModel> regionModels, Collection<RegionModel> children) {
...@@ -122,14 +121,7 @@ public class StCommonServiceImpl { ...@@ -122,14 +121,7 @@ public class StCommonServiceImpl {
public String getAndSetOrgCode(DPFilterParamDto dpFilterParamDto) { public String getAndSetOrgCode(DPFilterParamDto dpFilterParamDto) {
String cityCode = dpFilterParamDto.getCityCode(); String cityCode = dpFilterParamDto.getCityCode();
String orgCode = regionCodeOrgCodeMap.get(cityCode); return getAndSetOrgCode(cityCode);
if (orgCode == null) {
orgCode = commonMapper.getOrgCodeByCompanyCode(cityCode);
if (orgCode != null) {
regionCodeOrgCodeMap.put(cityCode, orgCode);
}
}
return orgCode;
} }
public String getAndSetOrgCode(String cityCode) { public String getAndSetOrgCode(String cityCode) {
...@@ -154,17 +146,13 @@ public class StCommonServiceImpl { ...@@ -154,17 +146,13 @@ public class StCommonServiceImpl {
} }
public List<RegionModel> setRegionIfRootParent(DPFilterParamDto dpFilterParamDto) { public List<RegionModel> setRegionIfRootParent(DPFilterParamDto dpFilterParamDto) {
List<RegionModel> regions = regionModels.parallelStream().filter(e -> e.getParentRegionCode() != null && (e.getParentRegionCode().toString()).equals(dpFilterParamDto.getCityCode())).collect(Collectors.toList()); String regionCode = dpFilterParamDto.getCityCode();
// 陕西省时需要在地图返回独立的地级市:韩城、杨凌、西咸 return setRegionIfRootParent(regionCode);
if (dpFilterParamDto.getCityCode().equals(TZSCommonConstant.SHAN_XI_REGION_CODE)) {
List<RegionModel> independentRegions = ReginStepEnum.enum2RegionList("map");
regions.addAll(independentRegions);
}
return regions;
} }
/** /**
* 获取指定区域下的子区域 * 获取指定区域下的子区域
*
* @param regionCode 行政区划 * @param regionCode 行政区划
* @return List<RegionModel> * @return List<RegionModel>
*/ */
...@@ -181,30 +169,26 @@ public class StCommonServiceImpl { ...@@ -181,30 +169,26 @@ public class StCommonServiceImpl {
/** /**
* 获取指定区域下的子区域,独立地市及区县级不再下钻,直接返回当前区域信息 * 获取指定区域下的子区域,独立地市及区县级不再下钻,直接返回当前区域信息
* *
* @param dpFilterParamDto 行政区划过滤条件 * @param dpFilterParamDto 行政区划过滤条件
* @return List<RegionModel> * @return List<RegionModel>
*/ */
public List<RegionModel> setRegionIfRootParentAndNoAccessIf3Level(DPFilterParamDto dpFilterParamDto) { public List<RegionModel> setRegionIfRootParentAndNoAccessIf3Level(DPFilterParamDto dpFilterParamDto) {
String regionCode = dpFilterParamDto.getCityCode(); String regionCode = dpFilterParamDto.getCityCode();
// 独立地市、区县级别时(level=3),直接返回当前区域信息,不在显示街道 return setRegionIfRootParentAndNoAccessIf3Level(regionCode);
if((Arrays.stream(ReginStepEnum.values())).anyMatch(e->e.getCode().equals(regionCode)) || regionCodeRegionMap.get(Integer.parseInt(regionCode)).getLevel().trim().equals(REGION_LEVEL_THIRD)){
return Collections.singletonList(regionCodeRegionMap.get(Integer.parseInt(regionCode)));
} else {
return setRegionIfRootParent(regionCode);
}
} }
/** /**
* 获取指定区域下的子区域,独立地市及区县级不再下钻,直接返回当前区域信息 * 获取指定区域下的子区域,独立地市及区县级不再下钻,直接返回当前区域信息
*
* @param regionCode 行政区划 * @param regionCode 行政区划
* @return List<RegionModel> * @return List<RegionModel>
*/ */
public List<RegionModel> setRegionIfRootParentAndNoAccessIf3Level(String regionCode) { public List<RegionModel> setRegionIfRootParentAndNoAccessIf3Level(String regionCode) {
if(regionCodeRegionMap.get(Integer.parseInt(regionCode)) != null && regionCodeRegionMap.get(Integer.parseInt(regionCode)).getLevel().trim().equals(REGION_LEVEL_THIRD)){ if (regionCodeRegionMap.get(Integer.parseInt(regionCode)) != null && regionCodeRegionMap.get(Integer.parseInt(regionCode)).getLevel().trim().equals(REGION_LEVEL_THIRD)) {
// 区县级别时(level=3),直接返回当前区域信息,不在显示街道 // 区县级别时(level=3),直接返回当前区域信息,不在显示街道
return Collections.singletonList(regionCodeRegionMap.get(Integer.parseInt(regionCode))); return Collections.singletonList(regionCodeRegionMap.get(Integer.parseInt(regionCode)));
} else if((Arrays.stream(ReginStepEnum.values())).anyMatch(e->e.getCode().equals(regionCode))) { } else if ((Arrays.stream(ReginStepEnum.values())).anyMatch(e -> e.getCode().equals(regionCode))) {
// 独立地市,直接返回当前区域信息,不在显示街道 // 独立地市,直接返回当前区域信息,不在显示街道
return ReginStepEnum.getOne(regionCode); return ReginStepEnum.getOne(regionCode);
} else { } else {
...@@ -249,7 +233,8 @@ public class StCommonServiceImpl { ...@@ -249,7 +233,8 @@ public class StCommonServiceImpl {
boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode())); boolMust.must(QueryBuilders.termQuery("EQU_STATE", EquimentEnum.ZAIYONG.getCode()));
SearchSourceBuilder builder = new SearchSourceBuilder(); SearchSourceBuilder builder = new SearchSourceBuilder();
builder.query(boolMust); builder.query(boolMust);
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE"); // 默认size为10 ,数据库有脏数据,所以需要多查询一些
TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms("count_by_equ_list_code").field("EQU_LIST_CODE").size(20);
builder.aggregation(aggregationBuilder); builder.aggregation(aggregationBuilder);
request.source(builder); request.source(builder);
try { try {
...@@ -260,7 +245,7 @@ public class StCommonServiceImpl { ...@@ -260,7 +245,7 @@ public class StCommonServiceImpl {
// 压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量 // 压力容器里包括气瓶所以需要特殊处理,在统计压力容器时去掉气瓶的数量
if (bucket.getKeyAsString().equals(EQU_LIST_CYLINDER)) { if (bucket.getKeyAsString().equals(EQU_LIST_CYLINDER)) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount() - cylinderNum); countMap.put(bucket.getKeyAsString(), bucket.getDocCount() - cylinderNum);
} else { } else if (equipmentCategoryDtos.stream().anyMatch(e -> e.getCode().equalsIgnoreCase(bucket.getKeyAsString()))) {
countMap.put(bucket.getKeyAsString(), bucket.getDocCount()); countMap.put(bucket.getKeyAsString(), bucket.getDocCount());
} }
} }
...@@ -305,7 +290,6 @@ public class StCommonServiceImpl { ...@@ -305,7 +290,6 @@ public class StCommonServiceImpl {
} }
private long countCompanyForCertDateTemporary(DPFilterParamDto dpFilterParamDto) { private long countCompanyForCertDateTemporary(DPFilterParamDto dpFilterParamDto) {
String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode()); String orgCode = this.getAndSetOrgCode(dpFilterParamDto.getCityCode());
// 临期6个月 // 临期6个月
......
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
count(1) count(1)
FROM FROM
tz_base_enterprise_info u tz_base_enterprise_info u
RIGHT JOIN tzs_user_info ui ON ui.unit_code = u.use_unit_code RIGHT JOIN tzs_user_info ui ON ui.unit_code = u.use_code
WHERE WHERE
u.data_sources = '陕西省内企业' u.data_sources = '陕西省内企业'
AND u.unit_type LIKE'%充装单位%' AND u.unit_type LIKE'%充装单位%'
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
tzs_user_info tui, tzs_user_info tui,
tz_base_enterprise_info bi tz_base_enterprise_info bi
WHERE WHERE
tui.unit_code = bi.use_unit_code tui.unit_code = bi.use_code
and tui.post LIKE concat ( '%', #{post}, '%' ) and tui.post LIKE concat ( '%', #{post}, '%' )
and ((bi.supervise_org_code != '50' and bi.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (bi.supervise_org_code = '50' and bi.office_region LIKE CONCAT ('%', #{regionCode}, '%'))) and ((bi.supervise_org_code != '50' and bi.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) or (bi.supervise_org_code = '50' and bi.office_region LIKE CONCAT ('%', #{regionCode}, '%')))
and tui.is_delete=false and tui.is_delete=false
......
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