|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -37,12 +38,14 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.PidUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dto.*; |
|
|
import com.epmet.dto.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
|
|
|
import com.epmet.dto.region.LogOperationResultDTO; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
import com.epmet.entity.CustomerDepartmentEntity; |
|
|
import com.epmet.entity.CustomerDepartmentEntity; |
|
|
@ -56,6 +59,8 @@ import com.epmet.feign.OperCrmFeignClient; |
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
import com.epmet.redis.CustomerAgencyRedis; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
import com.epmet.service.CustomerAgencyService; |
|
|
import com.epmet.util.ModuleConstant; |
|
|
import com.epmet.util.ModuleConstant; |
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -681,6 +686,17 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
return subAgencyList; |
|
|
return subAgencyList; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<AgencySubResultDTO> getDepartmentLevelList(String subAgencyPids) { |
|
|
|
|
|
List<AgencySubResultDTO> subAgencyList = baseDao.selectSubAgencyLevelList(subAgencyPids); |
|
|
|
|
|
if (subAgencyList.size() > NumConstant.ZERO) { |
|
|
|
|
|
for (AgencySubResultDTO sub : subAgencyList) { |
|
|
|
|
|
List<AgencySubResultDTO> subAgency = getDepartmentLevelList(sub.getPids() + ":" + sub.getAgencyId()); |
|
|
|
|
|
sub.setSubAgencyList(subAgency); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return subAgencyList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param staffId |
|
|
* @param staffId |
|
|
* @return |
|
|
* @return |
|
|
@ -1052,6 +1068,24 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
return resultDTO; |
|
|
return resultDTO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public StaffInAgencyListResultDTO staffinAgencyLevelList(String staffId) { |
|
|
|
|
|
StaffInAgencyListResultDTO resultDTO = new StaffInAgencyListResultDTO(); |
|
|
|
|
|
//1.查询工作人员所属组织信息
|
|
|
|
|
|
AgencyResultDTO agencyList = baseDao.selectAgencyByStaffId(staffId); |
|
|
|
|
|
if (null == agencyList) { |
|
|
|
|
|
logger.error(String.format("查询工作人员所属组织信息失败,staffId->%s", staffId)); |
|
|
|
|
|
throw new RenException(CustomerAgencyConstant.SELECT_STAFF_AGENCY_EXCEPTION); |
|
|
|
|
|
} |
|
|
|
|
|
resultDTO.setAgencyList(agencyList); |
|
|
|
|
|
|
|
|
|
|
|
//2.递归查询所有下级组织信息
|
|
|
|
|
|
List<AgencySubResultDTO> subAgencyList = getDepartmentLevelList(("".equals(agencyList.getPids()) ? "" : agencyList.getPids() + ":") + agencyList.getAgencyId()); |
|
|
|
|
|
resultDTO.setSubAgencyList(subAgencyList); |
|
|
|
|
|
|
|
|
|
|
|
return resultDTO; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @param customerId |
|
|
* @param customerId |
|
|
* @return com.epmet.dto.result.AgencyElementTreeResultDTO |
|
|
* @return com.epmet.dto.result.AgencyElementTreeResultDTO |
|
|
@ -1193,6 +1227,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
result.setOrgLevel(rootAgency.getAgencyId().concat("-").concat(rootAgency.getLevel())); |
|
|
result.setOrgLevel(rootAgency.getAgencyId().concat("-").concat(rootAgency.getLevel())); |
|
|
result.setLongitude(rootAgency.getLongitude()); |
|
|
result.setLongitude(rootAgency.getLongitude()); |
|
|
result.setLatitude(rootAgency.getLatitude()); |
|
|
result.setLatitude(rootAgency.getLatitude()); |
|
|
|
|
|
result.setOrgIdPath(rootAgency.getOrgIdPath()); |
|
|
|
|
|
|
|
|
String orgTreeCacheKey = RedisKeys.getOrgTreeCacheKey(rootAgency.getAgencyId(),customerId); |
|
|
String orgTreeCacheKey = RedisKeys.getOrgTreeCacheKey(rootAgency.getAgencyId(),customerId); |
|
|
Object o = redisUtils.get(orgTreeCacheKey); |
|
|
Object o = redisUtils.get(orgTreeCacheKey); |
|
|
@ -1624,6 +1659,14 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
} |
|
|
} |
|
|
return customerAgencyEntity.getPids().concat(StrConstant.COLON).concat(orgId); |
|
|
return customerAgencyEntity.getPids().concat(StrConstant.COLON).concat(orgId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description: |
|
|
|
|
|
* @param agencyId: |
|
|
|
|
|
* @Return java.util.List<com.epmet.dto.result.AgencyCountCensusResultDTO> |
|
|
|
|
|
* @Author: lichao |
|
|
|
|
|
* @Date: 2023/4/7 14:17 |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId) { |
|
|
public List<AgencyCountCensusResultDTO> getAgencyCountList(String agencyId) { |
|
|
|
|
|
|
|
|
@ -1631,24 +1674,89 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl<CustomerAgencyDao |
|
|
|
|
|
|
|
|
CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId); |
|
|
CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId); |
|
|
if (customerAgency != null){ |
|
|
if (customerAgency != null){ |
|
|
// pidu
|
|
|
String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids()); |
|
|
// 区县级
|
|
|
|
|
|
if (customerAgency.getLevel().equals("district")){ |
|
|
agencyCountCensusResultDTOS = baseDao.agencyCount(pids); |
|
|
// Integer count = baseDao.agencyCount()
|
|
|
AgencyCountCensusResultDTO agencyCountCensusResultDTOGrid = new AgencyCountCensusResultDTO(); |
|
|
// 镇街级
|
|
|
agencyCountCensusResultDTOGrid.setLevel("grid"); |
|
|
}else if (customerAgency.getLevel().equals("street")){ |
|
|
agencyCountCensusResultDTOGrid.setCount(baseDao.agencyGridCount(pids)); |
|
|
|
|
|
agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOGrid); |
|
|
|
|
|
|
|
|
|
|
|
AgencyCountCensusResultDTO agencyCountCensusResultDTOStaff = new AgencyCountCensusResultDTO(); |
|
|
|
|
|
agencyCountCensusResultDTOStaff.setLevel("staff"); |
|
|
|
|
|
agencyCountCensusResultDTOStaff.setCount(baseDao.agencyStaffCount(pids)); |
|
|
|
|
|
agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOStaff); |
|
|
|
|
|
|
|
|
}else{ |
|
|
}else{ |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常"); |
|
|
|
|
|
} |
|
|
|
|
|
return agencyCountCensusResultDTOS; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<CommunityCountCensusResultDTO> getCommunityCountList(CommunityCountCensusFormDTO dto) { |
|
|
|
|
|
|
|
|
|
|
|
List<CommunityCountCensusResultDTO> resultDTOS = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
CustomerAgencyEntity customerAgency = baseDao.selectById(dto.getAgencyId()); |
|
|
|
|
|
if (customerAgency!=null){ |
|
|
|
|
|
String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids()); |
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapper = new LambdaQueryWrapper<CustomerAgencyEntity>().eq(CustomerAgencyEntity::getPids,pids); |
|
|
|
|
|
List<CustomerAgencyEntity> agencyEntityList = baseDao.selectList(queryWrapper); |
|
|
|
|
|
agencyEntityList.forEach( |
|
|
|
|
|
entity->{ |
|
|
|
|
|
CommunityCountCensusResultDTO communityCountCensusResultDTO = new CommunityCountCensusResultDTO(); |
|
|
|
|
|
communityCountCensusResultDTO.setAgencyId(entity.getId()); |
|
|
|
|
|
communityCountCensusResultDTO.setAgencyName(entity.getOrganizationName()); |
|
|
|
|
|
String agencyPids = PidUtils.convertPid2OrgIdPath(entity.getId(),entity.getPids()); |
|
|
|
|
|
communityCountCensusResultDTO.setCount(baseDao.getCommunityCount(agencyPids,dto.getTimeStart(),dto.getTimeEnd())); |
|
|
|
|
|
resultDTOS.add(communityCountCensusResultDTO); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
return resultDTOS; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
}else{ |
|
|
@Override |
|
|
|
|
|
public PageData<CommunityListByAgencyIdResultDTO> getCommunityList(CommunityCountCensusFormDTO dto) { |
|
|
|
|
|
|
|
|
|
|
|
CustomerAgencyEntity customerAgency = baseDao.selectById(dto.getAgencyId()); |
|
|
|
|
|
if (customerAgency!=null){ |
|
|
|
|
|
|
|
|
|
|
|
String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids()); |
|
|
|
|
|
|
|
|
|
|
|
PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); |
|
|
|
|
|
List<CommunityListByAgencyIdResultDTO> entityList = baseDao.getCommunityByPidList(pids,dto.getTimeStart(),dto.getTimeEnd()); |
|
|
|
|
|
|
|
|
|
|
|
entityList.forEach( |
|
|
|
|
|
entity->{ |
|
|
|
|
|
String[] pidArray = entity.getPids().split(":"); |
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<CustomerAgencyEntity> queryWrapper = new LambdaQueryWrapper<CustomerAgencyEntity>().in(CustomerAgencyEntity::getId,pidArray); |
|
|
|
|
|
List<CustomerAgencyEntity> customerAgencyEntities = baseDao.selectList(queryWrapper); |
|
|
|
|
|
for (CustomerAgencyEntity customerAgencyEntity : customerAgencyEntities) { |
|
|
|
|
|
if (customerAgencyEntity.getLevel().equals("district")){ |
|
|
|
|
|
entity.setDistrictName(customerAgencyEntity.getOrganizationName()); |
|
|
|
|
|
} |
|
|
|
|
|
if (customerAgencyEntity.getLevel().equals("street")){ |
|
|
|
|
|
entity.setStreeName(customerAgencyEntity.getOrganizationName()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
PageInfo<CommunityListByAgencyIdResultDTO> pageInfo = new PageInfo<>(entityList); |
|
|
|
|
|
return new PageData<>(entityList, pageInfo.getTotal(),dto.getPageSize()); |
|
|
|
|
|
|
|
|
|
|
|
}else { |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常"); |
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"获取用户组织信息异常","获取用户组织信息异常"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return agencyCountCensusResultDTOS; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|