Browse Source

新增党组织添加层级校验,统一报错提示

dev
Jackwang 3 years ago
parent
commit
25dd13b59d
  1. 34
      epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/BranchListResultDTO.java
  2. 13
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcPartyOrgController.java
  3. 9
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcPartyOrgDao.java
  4. 11
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcPartyOrgService.java
  5. 22
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcPartyOrgServiceImpl.java
  6. 18
      epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcPartyOrgDao.xml

34
epmet-module/resi-partymember/resi-partymember-client/src/main/java/com/epmet/resi/partymember/dto/partyOrg/result/BranchListResultDTO.java

@ -0,0 +1,34 @@
package com.epmet.resi.partymember.dto.partyOrg.result;
import lombok.Data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @program: epmet-cloud
* @description:
* @author: wangtong
* @create: 2022-05-25 11:15
**/
@Data
public class BranchListResultDTO implements Serializable {
/**
* 工作人员所属组织ID
*/
private String agencyId;
/**
* 工作人员所属组织ID的pids
*/
private String agencyPIds;
/**
* 工作人员所属组织名称
*/
private String agencyName;
private List<IcPartyOrgTreeDTO> children = new ArrayList<>();
}

13
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/controller/IcPartyOrgController.java

@ -15,6 +15,7 @@ import com.epmet.modules.partyOrg.excel.IcPartyOrgExcel;
import com.epmet.modules.partyOrg.service.IcPartyOrgService;
import com.epmet.resi.partymember.dto.partyOrg.IcPartyOrgDTO;
import com.epmet.resi.partymember.dto.partyOrg.form.PartyOrgTreeListDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.BranchListResultDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -95,6 +96,18 @@ public class IcPartyOrgController {
return icPartyOrgService.getTreelist(formDTO);
}
/**
* @describe: 当前登录用户所属行政组织及下级的党组织只限支部
* @author wangtong
* @date 2022/5/25 15:24
* @params [tokenDto]
* @return com.epmet.commons.tools.utils.Result<com.epmet.resi.partymember.dto.partyOrg.result.BranchListResultDTO>
*/
@GetMapping("branchlist")
public Result<BranchListResultDTO> branchlist(@LoginUser TokenDto tokenDto){
return icPartyOrgService.branchlist(tokenDto);
}
}

9
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcPartyOrgDao.java

@ -64,4 +64,13 @@ public interface IcPartyOrgDao extends BaseDao<IcPartyOrgEntity> {
* @return com.epmet.modules.partyOrg.entity.IcPartyOrgEntity
*/
IcPartyOrgEntity selectLevelOneOrgByCustomerId(@Param("customerId") String customerId);
/**
* @describe: 查询行政组织下的所有支部党组织
* @author wangtong
* @date 2022/5/25 15:30
* @params [agencyId, customerId]
* @return java.util.List<com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO>
*/
List<IcPartyOrgTreeDTO> selectAllBranchByAgencyId(@Param("agencyId") String agencyId,@Param("customerId") String customerId);
}

11
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/IcPartyOrgService.java

@ -2,10 +2,12 @@ package com.epmet.modules.partyOrg.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity;
import com.epmet.resi.partymember.dto.partyOrg.IcPartyOrgDTO;
import com.epmet.resi.partymember.dto.partyOrg.form.PartyOrgTreeListDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.BranchListResultDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO;
import java.util.List;
@ -87,4 +89,13 @@ public interface IcPartyOrgService extends BaseService<IcPartyOrgEntity> {
* @return com.epmet.commons.tools.page.PageData<com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO>
*/
Result<List<IcPartyOrgTreeDTO>> getTreelist(PartyOrgTreeListDTO formDTO);
/**
* @describe: 当前登录用户所属行政组织及下级的党组织只限支部
* @author wangtong
* @date 2022/5/25 15:25
* @params [tokenDto]
* @return com.epmet.commons.tools.utils.Result<com.epmet.resi.partymember.dto.partyOrg.result.BranchListResultDTO>
*/
Result<BranchListResultDTO> branchlist(TokenDto tokenDto);
}

22
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcPartyOrgServiceImpl.java

@ -4,11 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.PartyOrgTypeEnum;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.enums.OrgLevelEnums;
@ -19,6 +22,7 @@ import com.epmet.modules.partymember.dao.IcPartyMemberDao;
import com.epmet.modules.partymember.entity.IcPartyMemberEntity;
import com.epmet.resi.partymember.dto.partyOrg.IcPartyOrgDTO;
import com.epmet.resi.partymember.dto.partyOrg.form.PartyOrgTreeListDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.BranchListResultDTO;
import com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -81,24 +85,24 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
//同一个客户下,名称和编码不可重复
IcPartyOrgEntity repeatName = baseDao.selectByCuIdAndNameOrCode(dto.getPartyOrgName(),null,dto.getCustomerId());
if(null != repeatName){
return new Result().error("行政组织名称不可重复!");
throw new EpmetException("行政组织名称不可重复!");
}
if(StringUtils.isNotBlank(dto.getPartyOrgCode())){
IcPartyOrgEntity repeatCode = baseDao.selectByCuIdAndNameOrCode(null,dto.getPartyOrgCode(),dto.getCustomerId());
if(null != repeatCode){
return new Result().error("行政组织编码不可重复!");
throw new EpmetException("行政组织编码不可重复!");
}
}
IcPartyOrgEntity parentOrg = baseDao.selectById(dto.getOrgPid());
//判断当前党组织的类型是否是所选上级党组织类型的直接下级
if("0".equals(dto.getOrgPid())){
if(PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){
return new Result().error("支部不可设为一级组织!");
throw new EpmetException("支部不可设为一级组织!");
}
//一个客户下只能有一个一级组织
IcPartyOrgEntity levelOneOrg = baseDao.selectLevelOneOrgByCustomerId(dto.getCustomerId());
if(null != levelOneOrg){
return new Result().error("当前客户下已存在一级组织,不可重复添加!");
throw new EpmetException("当前客户下已存在一级组织,不可重复添加!");
}
}else{
checkOrgType(parentOrg.getPartyOrgType(),dto.getPartyOrgType());
@ -107,7 +111,7 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
if(!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){
IcPartyOrgEntity isAgency = baseDao.selectByAgencyId(dto.getAgencyId(),PartyOrgTypeEnum.BRANCH.getCode());
if(null != isAgency){
return new Result().error("该行政组织已被关联!");
throw new EpmetException("该行政组织已被关联!");
}
AgencyInfoCache agency = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
//判断该所选的行政组织类型是否与当前党组织的类型一致
@ -208,6 +212,14 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
return new Result<List<IcPartyOrgTreeDTO>>().ok(build(list));
}
@Override
public Result<BranchListResultDTO> branchlist(TokenDto tokenDto) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(),tokenDto.getUserId());
BranchListResultDTO result = ConvertUtils.sourceToTarget(staffInfo, BranchListResultDTO.class);
result.setChildren(baseDao.selectAllBranchByAgencyId(staffInfo.getAgencyId(),tokenDto.getCustomerId()));
return new Result<BranchListResultDTO>().ok(result);
}
/**
* 构建树节点
*/

18
epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcPartyOrgDao.xml

@ -68,6 +68,24 @@
where DEL_FLAG='0'
and CUSTOMER_ID=#{customerId}
</select>
<select id="selectAllBranchByAgencyId"
resultType="com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO">
select ID,
CUSTOMER_ID,
ORG_PID as pid,
ORG_PIDS,
AGENCY_ID,
AGENCY_PIDS,
PARTY_ORG_TYPE,
PARTY_ORG_NAME
from ic_party_org
where DEL_FLAG=0
and CUSTOMER_ID=#{customerId}
and PARTY_ORG_TYPE = '5'
<if test="agencyId != null and agencyId != ''">
AND (AGENCY_ID = #{agencyId} or AGENCY_PIDS LIKE concat('%',#{agencyId}, '%' ))
</if>
</select>
</mapper>

Loading…
Cancel
Save