瀏覽代碼

Merge remote-tracking branch 'origin/master'

master
PoffyZhang 1 年之前
父節點
當前提交
f12f061dab
共有 5 個文件被更改,包括 64 次插入9 次删除
  1. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionLimitHelper.java
  2. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionLimitHelper.java
  3. +43
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionLimitHelperImpl.java
  4. +3
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java
  5. +4
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertAdminManage.java

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionLimitHelper.java 查看文件

@@ -39,4 +39,14 @@ public interface RegionLimitHelper {
*/
RegionContainsBO getContainsRegionBo(Integer regionLevel, String regionCode);



/**
* 根据专家管理员用户id 获取专家管理员管辖区域列表
*
* @param expertAdminUserId 专家管理员用户id
* @return
*/
List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId);

}

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/basic/AbstractRegionLimitHelper.java 查看文件

@@ -5,6 +5,8 @@ import com.ningdatech.pmapi.common.helper.RegionLimitHelper;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import com.ningdatech.pmapi.sys.service.IRegionService;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import lombok.AllArgsConstructor;

import java.util.Objects;
@@ -22,6 +24,8 @@ public abstract class AbstractRegionLimitHelper implements RegionLimitHelper {

protected final RegionCacheHelper regionCache;
protected final IExpertUserFullInfoService expertUserFullInfoService;
protected final IUserInfoService iUserInfoService;
protected final IRegionService regionService;


/**


+ 43
- 7
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionLimitHelperImpl.java 查看文件

@@ -1,9 +1,16 @@
package com.ningdatech.pmapi.common.helper.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.basic.AbstractRegionLimitHelper;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.bo.RegionContainsBO;
import com.ningdatech.pmapi.sys.model.entity.Region;
import com.ningdatech.pmapi.sys.service.IRegionService;
import com.ningdatech.pmapi.user.entity.UserInfo;
import com.ningdatech.pmapi.user.service.IUserInfoService;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,8 +31,9 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {

private static final Logger logger = LoggerFactory.getLogger(RegionLimitHelperImpl.class);

public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService) {
super(regionCache, expertUserFullInfoService);
public RegionLimitHelperImpl(RegionCacheHelper regionCache, IExpertUserFullInfoService expertUserFullInfoService
, IUserInfoService iUserInfoService, IRegionService regionService) {
super(regionCache, expertUserFullInfoService, iUserInfoService, regionService);
}

public static Boolean contains(Integer adminRegionLevel, List<String> adminAllContainsRegionCodes
@@ -57,16 +65,12 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {
public List<RegionContainsBO> queryContainsRegionAssembler(RegionContainsBO queryRegionContainBo, List<RegionContainsBO> expertAdminContainsRegionList) {
List<RegionContainsBO> resultBoList = new ArrayList<>();
if (Objects.nonNull(queryRegionContainBo)) {
resultBoList.add(queryRegionContainBo);
Integer parentRegionTreeLevel = queryRegionContainBo.getParentRegionTreeLevel();
List<String> containsRegionCodeList = queryRegionContainBo.getContainsRegionCodeList();

// 查询取并级
if (CollectionUtils.isNotEmpty(expertAdminContainsRegionList)) {
for (RegionContainsBO regionContainsBO : expertAdminContainsRegionList) {
regionContainsBO.setParentRegionTreeLevel(parentRegionTreeLevel);
List<String> regionCodeList = regionContainsBO.getContainsRegionCodeList();
regionCodeList = regionCodeList.stream().filter(containsRegionCodeList::contains).collect(Collectors.toList());
regionCodeList.retainAll(containsRegionCodeList);
if (CollectionUtils.isNotEmpty(regionCodeList)) {
regionContainsBO.setContainsRegionCodeList(regionCodeList);
resultBoList.add(regionContainsBO);
@@ -89,4 +93,36 @@ public class RegionLimitHelperImpl extends AbstractRegionLimitHelper {
}


@Override
public List<RegionContainsBO> getExpertAdminContainsRegion(Long expertAdminUserId) {
if (Objects.isNull(expertAdminUserId)) {
logger.error("getExpertAdminContainsRegion expertAdminUserId is null");
return new ArrayList<>();
}

UserInfo userInfo = iUserInfoService.getById(expertAdminUserId);

if (Objects.isNull(userInfo) || StringUtils.isBlank(userInfo.getRegionCode())) {
logger.error("getExpertAdminContainsRegion userInfo is null Or regionCode is null");
return new ArrayList<>();
}

String regionCode = userInfo.getRegionCode();
List<Region> regionList = regionService.list(Wrappers.lambdaQuery(Region.class)
.eq(Region::getRegionCode, regionCode)
.orderByDesc(Region::getRegionLevel));

Region region = regionList.get(0);
Collection<String> regionCodes = regionCache
.listChildRegionCodeList(region.getRegionCode(), region.getRegionLevel());
RegionContainsBO regionContainsBO = new RegionContainsBO();
regionContainsBO.setContainsRegionCodeList(new ArrayList<>(regionCodes));
regionContainsBO.setParentRegionTreeLevel(region.getRegionLevel());

ArrayList<RegionContainsBO> regionContainsBOS = CollectionUtil.toList(regionContainsBO);

return regionContainsBOS;
}


}

+ 3
- 2
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java 查看文件

@@ -40,7 +40,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
@Override
public String getRegionName(String code, int level) {
RegionDTO dto = getByCodeAndLevel(code, level);
if(Objects.nonNull(dto)){
if (Objects.nonNull(dto)) {
return dto.getRegionName();
}
return StringUtils.EMPTY;
@@ -54,7 +54,7 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
@Override
public Collection<String> listChildRegionCodeList(String regionCode, int regionLevel) {
RegionDTO currRegion = getByCodeAndLevel(regionCode, regionLevel);
if(Objects.isNull(currRegion)){
if (Objects.isNull(currRegion)) {
return Collections.emptyList();
}
if (currRegion.getParentCode().equals(regionCode)) {
@@ -217,4 +217,5 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
buildUnionPathStrList(regionDTO.getParentCode(), level - 1, unionPathStrList);
}
}

}

+ 4
- 0
pmapi/src/main/java/com/ningdatech/pmapi/expert/manage/ExpertAdminManage.java 查看文件

@@ -152,6 +152,10 @@ public class ExpertAdminManage {
}

List<RegionContainsBO> expertAdminContainsRegionList = new ArrayList<>();
// 如果为超级管理员,可以查看所有的专家,包括没有层级的专家
if (!permissionCheckHelper.isSuperAdmin()) {
expertAdminContainsRegionList = regionLimitHelper.getExpertAdminContainsRegion(userId);
}

List<RegionContainsBO> containsRegion = new ArrayList<>();
if (Objects.nonNull(query.getExpertRegionInfo())) {


Loading…
取消
儲存