| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -138,128 +138,4 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return new Result<List<StaffOrgsResultDTO>>().ok(list); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 添加组织 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result<AddAgencyResultDTO> addAgency(AddAgencyFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Result<AddAgencyResultDTO> result = new Result<AddAgencyResultDTO>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AddAgencyResultDTO addAgencyResultDTO = new AddAgencyResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //0:属性映射赋值
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerAgencyEntity entity = ConvertUtils.sourceToTarget(formDTO, CustomerAgencyEntity.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entity.setOrganizationName(formDTO.getAgencyName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entity.setTotalUser(NumConstant.ZERO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1:查询上级机关信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerAgencyEntity parentEntity = baseDao.selectById(formDTO.getPid()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entity.setCustomerId(parentEntity.getCustomerId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (null == parentEntity.getPid()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setPids(parentEntity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setAllParentName(parentEntity.getOrganizationName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setPids(":" + parentEntity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            entity.setAllParentName("-" + parentEntity.getOrganizationName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2:保存组织信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (baseDao.insert(entity) < NumConstant.ONE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            logger.error(CustomerAgencyConstant.SAVE_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException(CustomerAgencyConstant.SAVE_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //3:返回新组织Id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        addAgencyResultDTO.setAgencyId(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result.ok(addAgencyResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 组织名称编辑 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result editAgency(EditAgencyFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Result result = new Result(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerAgencyEntity entity = new CustomerAgencyEntity(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entity.setId(formDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        entity.setOrganizationName(formDTO.getAgencyName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (baseDao.updateById(entity) < NumConstant.ONE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            logger.error(CustomerAgencyConstant.UPDATE_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException(CustomerAgencyConstant.UPDATE_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 删除组织机关 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Transactional(rollbackFor = Exception.class) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result removeAgency(RemoveAgencyFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Result result = new Result(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1:查询当前机关是否存在所属下级机关,存在下级的不能删除
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (null != agencyList && agencyList.size() > NumConstant.ZERO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            result.setCode(EpmetErrorCode.NOT_DEL_AGENCY.getCode()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            result.setMsg(EpmetErrorCode.NOT_DEL_AGENCY.getMsg()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2:删除当前机关组织(逻辑删)
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (baseDao.deleteById(formDTO.getAgencyId()) < NumConstant.ONE) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            logger.error(CustomerAgencyConstant.DEL_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            throw new RenException(CustomerAgencyConstant.DEL_EXCEPTION); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 组织首页-获取组织机构信息 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result<AgencydetailResultDTO> agencyDetail(AgencydetailFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        AgencydetailResultDTO agencydetailResultDTO = new AgencydetailResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1:查询本机关详细信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerAgencyEntity entity = baseDao.selectById(formDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (null == entity) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agencydetailResultDTO = ConvertUtils.sourceToTarget(entity, AgencydetailResultDTO.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agencydetailResultDTO.setAgencyId(entity.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agencydetailResultDTO.setAgencyName(entity.getOrganizationName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2:查询本机关的所有上级机关,按自上而下层级顺序
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (null == entity.getPids()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<String> listStr = Arrays.asList(entity.getPids().split(":")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<ParentListResultDTO> parentList = baseDao.selectPAgencyById(listStr); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        agencydetailResultDTO.setParentList(parentList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return new Result<AgencydetailResultDTO>().ok(agencydetailResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @param formDTO | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @return | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Author sun | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @Description 组织首页-下级机关列表 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public Result<SubAgencyResultDTO> subAgencyList(SubAgencyFormDTO formDTO) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        SubAgencyResultDTO subAgencyResultDTO = new SubAgencyResultDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //1:根据当前机关Id查询直属下一级机关列表
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<SubListResultDTO> agencyList = baseDao.selectSubAgencyById(formDTO.getAgencyId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        subAgencyResultDTO.setAgencyList(agencyList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //2:统计下一级机关数
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        subAgencyResultDTO.setSubAgencyCount(agencyList.size()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return new Result<SubAgencyResultDTO>().ok(subAgencyResultDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} |