|  |  | @ -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); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * 构建树节点 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
	
		
			
				
					|  |  | 
 |