Commit b020e6c6 authored by tianyiming's avatar tianyiming

fix(tcm): 更新人员管理列表查询

parent d90b7d12
...@@ -107,6 +107,12 @@ public class UserPermissionDto { ...@@ -107,6 +107,12 @@ public class UserPermissionDto {
private String superviseOrgCode; private String superviseOrgCode;
/** /**
* 管辖机构CompanyCode
*/
@JsonIgnore
private String superviseCompanyCode;
/**
* 使用单位统一信用代码 * 使用单位统一信用代码
*/ */
private String useCode; private String useCode;
......
...@@ -112,8 +112,8 @@ ...@@ -112,8 +112,8 @@
or tzBaseEnterpriseInfoDto.unitType == '检测机构' or tzBaseEnterpriseInfoDto.unitType == '检测机构'
or tzBaseEnterpriseInfoDto.unitType == '' or tzBaseEnterpriseInfoDto.unitType == ''
or tzBaseEnterpriseInfoDto.unitType == null ) and tzBaseEnterpriseInfoDto.orgCode!= '' "> or tzBaseEnterpriseInfoDto.unitType == null ) and tzBaseEnterpriseInfoDto.orgCode!= '' ">
and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{orgCode}, '%')) and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{orgCode}, '%'))
or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{regionCode}, '%'))) or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{regionCode}, '%')))
</when> </when>
<otherwise> <otherwise>
and supervise_org_code LIKE CONCAT(#{orgCode}, '%') and supervise_org_code LIKE CONCAT(#{orgCode}, '%')
...@@ -156,8 +156,8 @@ ...@@ -156,8 +156,8 @@
or tzBaseEnterpriseInfoDto.unitType == '检测机构' or tzBaseEnterpriseInfoDto.unitType == '检测机构'
or tzBaseEnterpriseInfoDto.unitType == '' or tzBaseEnterpriseInfoDto.unitType == ''
or tzBaseEnterpriseInfoDto.unitType == null"> or tzBaseEnterpriseInfoDto.unitType == null">
and ((b.supervise_org_code != '50' and b.supervise_org_code LIKE CONCAT (#{tzBaseEnterpriseInfoDto.superviseOrgCode}, '%')) and ((supervise_org_code != '50' and supervise_org_code LIKE CONCAT (#{tzBaseEnterpriseInfoDto.superviseOrgCode}, '%'))
or (b.supervise_org_code = '50' and b.office_region LIKE CONCAT ('%', #{tzBaseEnterpriseInfoDto.OfficeRegionStr}, '%'))) or (supervise_org_code = '50' and office_region LIKE CONCAT ('%', #{tzBaseEnterpriseInfoDto.OfficeRegionStr}, '%')))
</when> </when>
<otherwise> <otherwise>
and supervise_org_code LIKE CONCAT(#{orgCode}, '%') and supervise_org_code LIKE CONCAT(#{orgCode}, '%')
......
...@@ -343,7 +343,6 @@ ...@@ -343,7 +343,6 @@
<foreach collection="postList" item="item" separator=","> <foreach collection="postList" item="item" separator=",">
#{item} #{item}
</foreach> </foreach>
]
</if> </if>
<if test="filter.postCode != null and filter.postCode != ''"> <if test="filter.postCode != null and filter.postCode != ''">
and u.new_post like concat('%',#{filter.postCode}, '%') and u.new_post like concat('%',#{filter.postCode}, '%')
...@@ -352,7 +351,8 @@ ...@@ -352,7 +351,8 @@
and u.sub_post like concat('%',#{filter.subPostCode}, '%') and u.sub_post like concat('%',#{filter.subPostCode}, '%')
</if> </if>
<if test="filter.superviseOrgCode != null and filter.superviseOrgCode != ''"> <if test="filter.superviseOrgCode != null and filter.superviseOrgCode != ''">
and e.supervise_org_code like concat('%',#{filter.superviseOrgCode}, '%') and ((e.supervise_org_code != '50' and e.supervise_org_code LIKE CONCAT (#{filter.superviseOrgCode}, '%'))
or (e.supervise_org_code = '50' and e.office_region LIKE CONCAT ('%', #{regionCode}, '%')))
</if> </if>
<if test="filter.createDateStart != null and filter.createDateEnd != null"> <if test="filter.createDateStart != null and filter.createDateEnd != null">
and (u.create_date between #{filter.createDateStart} and #{filter.createDateEnd}) and (u.create_date between #{filter.createDateStart} and #{filter.createDateEnd})
......
...@@ -54,6 +54,7 @@ import com.yeejoin.amos.boot.module.tcm.api.vo.SortVo; ...@@ -54,6 +54,7 @@ import com.yeejoin.amos.boot.module.tcm.api.vo.SortVo;
import com.yeejoin.amos.boot.module.tcm.api.vo.TzsUserInfoVo; import com.yeejoin.amos.boot.module.tcm.api.vo.TzsUserInfoVo;
import com.yeejoin.amos.boot.module.tcm.api.vo.UserInfoVo; import com.yeejoin.amos.boot.module.tcm.api.vo.UserInfoVo;
import com.yeejoin.amos.boot.module.tcm.biz.refresh.handler.UserRefreshHandler; import com.yeejoin.amos.boot.module.tcm.biz.refresh.handler.UserRefreshHandler;
import com.yeejoin.amos.boot.module.tcm.biz.utils.EnhancedDynamicQueryBuilder;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitInfo; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitInfo;
import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.RegUnitInfoServiceImpl; import com.yeejoin.amos.boot.module.tcm.flc.biz.service.impl.RegUnitInfoServiceImpl;
import com.yeejoin.amos.component.feign.config.InnerInvokException; import com.yeejoin.amos.component.feign.config.InnerInvokException;
...@@ -1089,6 +1090,12 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -1089,6 +1090,12 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
Page<UserPermissionDto> permissionDtoPage = new Page<>(current, size); Page<UserPermissionDto> permissionDtoPage = new Page<>(current, size);
List<String> post = this.getPostByType(type); List<String> post = this.getPostByType(type);
SortVo sortMap = this.sortFieldConversion(sort); SortVo sortMap = this.sortFieldConversion(sort);
if (!ObjectUtils.isEmpty(filter.getSuperviseOrgCode())) {
FeignClientResult<CompanyModel> result = Privilege.companyClient.queryByOrgcode(filter.getSuperviseOrgCode());
if (result.getStatus() == 200 ){
filter.setSuperviseCompanyCode(result.getResult().getCompanyCode());
}
}
Page<UserPermissionDto> result = this.getBaseMapper().queryUserByPermissionPage(permissionDtoPage, post, filter, sortMap); Page<UserPermissionDto> result = this.getBaseMapper().queryUserByPermissionPage(permissionDtoPage, post, filter, sortMap);
result.getRecords().forEach(d -> { result.getRecords().forEach(d -> {
if (StringUtils.isNotEmpty(d.getIdentificationStr())) { if (StringUtils.isNotEmpty(d.getIdentificationStr())) {
...@@ -2835,9 +2842,21 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI ...@@ -2835,9 +2842,21 @@ public class TzsUserInfoServiceImpl extends BaseService<TzsUserInfoDto, TzsUserI
// 属地监管部门 // 属地监管部门
if (!ObjectUtils.isEmpty(map.get("superviseOrgCode"))) { if (!ObjectUtils.isEmpty(map.get("superviseOrgCode"))) {
String superviseOrgCode = map.get("superviseOrgCode"); String superviseOrgCode = map.get("superviseOrgCode");
BoolQueryBuilder meBuilder = QueryBuilders.boolQuery(); FeignClientResult<CompanyModel> feignClientResult = Privilege.companyClient.queryByOrgcode(superviseOrgCode);
meBuilder.must(QueryBuilders.prefixQuery("superviseOrgCode", superviseOrgCode)); String companyCode = null;
boolMust.must(meBuilder); if (ObjectUtils.isEmpty(feignClientResult) && feignClientResult.getStatus() == 200) {
companyCode = feignClientResult.getResult().getCompanyCode();
}
BoolQueryBuilder queryBuilder1 = QueryBuilders.boolQuery();
BoolQueryBuilder queryBuilder2 = QueryBuilders.boolQuery();
EnhancedDynamicQueryBuilder enhancedDynamicQueryBuilder = new EnhancedDynamicQueryBuilder();
queryBuilder1.must(QueryBuilders.termQuery("superviseOrgCode", "50"))
.must(QueryBuilders.wildcardQuery("officeRegion", "*" + companyCode + "*"));
queryBuilder2.mustNot(QueryBuilders.termQuery("superviseOrgCode", "50"))
.must(QueryBuilders.prefixQuery("superviseOrgCode", superviseOrgCode));
enhancedDynamicQueryBuilder.add(queryBuilder1, "or");
enhancedDynamicQueryBuilder.add(queryBuilder2, "or");
boolMust.must(enhancedDynamicQueryBuilder.build());
} }
// 资质状态 // 资质状态
......
package com.yeejoin.amos.boot.module.tcm.biz.utils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import java.util.ArrayList;
import java.util.List;
public class EnhancedDynamicQueryBuilder {
private final List<QueryBuilder> initialClauses = new ArrayList<>();
private String groupLogic; // "AND" 或 "OR"
private final List<QueryBuilder> mustClauses = new ArrayList<>();
private final List<QueryBuilder> shouldClauses = new ArrayList<>();
private final List<QueryBuilder> mustNotClauses = new ArrayList<>();
public EnhancedDynamicQueryBuilder() {
this("AND"); // 默认组间关系为AND
}
public EnhancedDynamicQueryBuilder(String groupLogic) {
this.groupLogic = groupLogic != null ? groupLogic : "AND";
}
/**
* 添加条件,自动处理第一个条件为null的情况
* @param query 查询条件
* @param logic 逻辑关系 (AND/OR/NOT),第一个条件可为null
*/
public EnhancedDynamicQueryBuilder add(QueryBuilder query, String logic) {
if (logic == null) {
if (isEmpty()) {
// 第一个条件,默认作为must条件
mustClauses.add(query);
} else {
// 后续条件未指定逻辑,使用组间默认逻辑
if ("OR".equalsIgnoreCase(groupLogic)) {
shouldClauses.add(query);
} else {
mustClauses.add(query);
}
}
} else {
switch (logic.toUpperCase()) {
case "AND":
mustClauses.add(query);
break;
case "OR":
shouldClauses.add(query);
break;
case "NOT":
mustNotClauses.add(query);
break;
default:
throw new IllegalArgumentException("Unsupported logic: " + logic);
}
}
return this;
}
public BoolQueryBuilder build() {
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery();
// 处理must条件
mustClauses.forEach(boolQuery::must);
// 处理should条件
if (!shouldClauses.isEmpty()) {
shouldClauses.forEach(boolQuery::should);
// 如果没有must条件,至少满足一个should
if (mustClauses.isEmpty()) {
boolQuery.minimumShouldMatch(1);
}
}
// 处理mustNot条件
mustNotClauses.forEach(boolQuery::mustNot);
return boolQuery;
}
private boolean isEmpty() {
return mustClauses.isEmpty() && shouldClauses.isEmpty() && mustNotClauses.isEmpty();
}
}
\ No newline at end of file
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