|
|
@ -6,6 +6,7 @@ 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.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
@ -14,13 +15,16 @@ 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.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.enums.OrgLevelEnums; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
|
|
|
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity; |
|
|
|
import com.epmet.modules.partyOrg.service.IcPartyOrgService; |
|
|
|
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.GetParentOrgFormDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.form.PartyOrgTreeListDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.BranchlistTreeDTO; |
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.BranchlistTreeSubDTO; |
|
|
@ -48,6 +52,9 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
@Autowired |
|
|
|
private IcPartyMemberDao icPartyMemberDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcPartyOrgDTO> page(Map<String, Object> params) { |
|
|
@ -65,8 +72,8 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
return ConvertUtils.sourceToTarget(entityList, IcPartyOrgDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<IcPartyOrgEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<IcPartyOrgEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<IcPartyOrgEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -84,47 +91,47 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result save(IcPartyOrgDTO dto) { |
|
|
|
//同一个客户下,名称和编码不可重复
|
|
|
|
IcPartyOrgEntity repeatName = baseDao.selectByCuIdAndNameOrCode(dto.getPartyOrgName(),null,dto.getCustomerId()); |
|
|
|
if(null != repeatName){ |
|
|
|
IcPartyOrgEntity repeatName = baseDao.selectByCuIdAndNameOrCode(dto.getPartyOrgName(), null, dto.getCustomerId()); |
|
|
|
if (null != repeatName) { |
|
|
|
throw new EpmetException("行政组织名称不可重复!"); |
|
|
|
} |
|
|
|
if(StringUtils.isNotBlank(dto.getPartyOrgCode())){ |
|
|
|
IcPartyOrgEntity repeatCode = baseDao.selectByCuIdAndNameOrCode(null,dto.getPartyOrgCode(),dto.getCustomerId()); |
|
|
|
if(null != repeatCode){ |
|
|
|
if (StringUtils.isNotBlank(dto.getPartyOrgCode())) { |
|
|
|
IcPartyOrgEntity repeatCode = baseDao.selectByCuIdAndNameOrCode(null, dto.getPartyOrgCode(), dto.getCustomerId()); |
|
|
|
if (null != repeatCode) { |
|
|
|
throw new EpmetException("行政组织编码不可重复!"); |
|
|
|
} |
|
|
|
} |
|
|
|
IcPartyOrgEntity parentOrg = baseDao.selectById(dto.getOrgPid()); |
|
|
|
//判断当前党组织的类型是否是所选上级党组织类型的直接下级
|
|
|
|
if("0".equals(dto.getOrgPid())){ |
|
|
|
if(PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){ |
|
|
|
if ("0".equals(dto.getOrgPid())) { |
|
|
|
if (PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())) { |
|
|
|
throw new EpmetException("支部不可设为一级组织!"); |
|
|
|
} |
|
|
|
//一个客户下只能有一个一级组织
|
|
|
|
IcPartyOrgEntity levelOneOrg = baseDao.selectLevelOneOrgByCustomerId(dto.getCustomerId()); |
|
|
|
if(null != levelOneOrg){ |
|
|
|
if (null != levelOneOrg) { |
|
|
|
throw new EpmetException("当前客户下已存在一级组织,不可重复添加!"); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
checkOrgType(parentOrg.getPartyOrgType(),dto.getPartyOrgType()); |
|
|
|
} else { |
|
|
|
checkOrgType(parentOrg.getPartyOrgType(), dto.getPartyOrgType()); |
|
|
|
} |
|
|
|
//如果不是支部,需要判断行政组织是否重复
|
|
|
|
if(!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){ |
|
|
|
IcPartyOrgEntity isAgency = baseDao.selectByAgencyId(dto.getAgencyId(),PartyOrgTypeEnum.BRANCH.getCode()); |
|
|
|
if(null != isAgency){ |
|
|
|
if (!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())) { |
|
|
|
IcPartyOrgEntity isAgency = baseDao.selectByAgencyId(dto.getAgencyId(), PartyOrgTypeEnum.BRANCH.getCode()); |
|
|
|
if (null != isAgency) { |
|
|
|
throw new EpmetException("该行政组织已被关联!"); |
|
|
|
} |
|
|
|
AgencyInfoCache agency = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
//判断该所选的行政组织类型是否与当前党组织的类型一致
|
|
|
|
checnAgencyLevel(agency.getLevel(),dto.getPartyOrgType()); |
|
|
|
checnAgencyLevel(agency.getLevel(), dto.getPartyOrgType()); |
|
|
|
dto.setAgencyPids(agency.getPids()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
//类型为支部时,行政组织信息与上级党组织一致
|
|
|
|
dto.setAgencyId(parentOrg.getAgencyId()); |
|
|
|
dto.setAgencyPids(parentOrg.getAgencyPids()); |
|
|
|
} |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
if (null == agencyInfo){ |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new EpmetException("组织信息获取失败"); |
|
|
|
} |
|
|
|
IcPartyOrgEntity entity = ConvertUtils.sourceToTarget(dto, IcPartyOrgEntity.class); |
|
|
@ -133,43 +140,43 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return void |
|
|
|
* @describe: 判断当前党组织的类型是否是所选上级党组织类型的直接下级 |
|
|
|
* @author wangtong |
|
|
|
* @date 2022/5/25 10:09 |
|
|
|
* @params [parentOrg, partyOrgType] |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
private void checkOrgType(String parentOrgType, String partyOrgType) { |
|
|
|
if(PartyOrgTypeEnum.BRANCH.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.PARTY.getCode().equals(parentOrgType)){ |
|
|
|
if (PartyOrgTypeEnum.BRANCH.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.PARTY.getCode().equals(parentOrgType)) { |
|
|
|
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择党委作为上级组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.PARTY.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.WORKING.getCode().equals(parentOrgType)){ |
|
|
|
} else if (PartyOrgTypeEnum.PARTY.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.WORKING.getCode().equals(parentOrgType)) { |
|
|
|
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择党工委作为上级组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.WORKING.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.DISTRICT.getCode().equals(parentOrgType)){ |
|
|
|
} else if (PartyOrgTypeEnum.WORKING.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.DISTRICT.getCode().equals(parentOrgType)) { |
|
|
|
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择区委作为上级组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.DISTRICT.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.MUNICIPAL.getCode().equals(parentOrgType)){ |
|
|
|
} else if (PartyOrgTypeEnum.DISTRICT.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.MUNICIPAL.getCode().equals(parentOrgType)) { |
|
|
|
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择市委作为上级组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.MUNICIPAL.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.PROVINCIAL.getCode().equals(parentOrgType)){ |
|
|
|
} else if (PartyOrgTypeEnum.MUNICIPAL.getCode().equals(partyOrgType) && !PartyOrgTypeEnum.PROVINCIAL.getCode().equals(parentOrgType)) { |
|
|
|
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择省委作为上级组织!"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return void |
|
|
|
* @describe: 判断该所选的行政组织类型是否与当前党组织的类型一致 |
|
|
|
* @author wangtong |
|
|
|
* @date 2022/5/25 9:45 |
|
|
|
* @params [agencyLevel, partyOrgType] |
|
|
|
* @return void |
|
|
|
*/ |
|
|
|
private void checnAgencyLevel(String agencyLevel, String partyOrgType) { |
|
|
|
if(PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.PROVINCE.getLevel().equals(agencyLevel)){ |
|
|
|
if (PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.PROVINCE.getLevel().equals(agencyLevel)) { |
|
|
|
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择省级的行政组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.MUNICIPAL.getCode().equals(partyOrgType) && !OrgLevelEnums.CITY.getLevel().equals(agencyLevel)){ |
|
|
|
} else if (PartyOrgTypeEnum.MUNICIPAL.getCode().equals(partyOrgType) && !OrgLevelEnums.CITY.getLevel().equals(agencyLevel)) { |
|
|
|
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择市级的行政组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.DISTRICT.getCode().equals(partyOrgType) && !OrgLevelEnums.DISTRICT.getLevel().equals(agencyLevel)){ |
|
|
|
} else if (PartyOrgTypeEnum.DISTRICT.getCode().equals(partyOrgType) && !OrgLevelEnums.DISTRICT.getLevel().equals(agencyLevel)) { |
|
|
|
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择区级的行政组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.WORKING.getCode().equals(partyOrgType) && !OrgLevelEnums.STREET.getLevel().equals(agencyLevel)){ |
|
|
|
} else if (PartyOrgTypeEnum.WORKING.getCode().equals(partyOrgType) && !OrgLevelEnums.STREET.getLevel().equals(agencyLevel)) { |
|
|
|
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择街道级的行政组织!"); |
|
|
|
}else if(PartyOrgTypeEnum.PARTY.getCode().equals(partyOrgType) && !OrgLevelEnums.COMMUNITY.getLevel().equals(agencyLevel)){ |
|
|
|
} else if (PartyOrgTypeEnum.PARTY.getCode().equals(partyOrgType) && !OrgLevelEnums.COMMUNITY.getLevel().equals(agencyLevel)) { |
|
|
|
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择社区级的行政组织!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -192,15 +199,15 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
// baseDao.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
for(String id : ids){ |
|
|
|
for (String id : ids) { |
|
|
|
//判断该组织是否有下级党组织
|
|
|
|
List<IcPartyOrgEntity> orgList = baseDao.selectAllByOrgId(id); |
|
|
|
if(!CollectionUtils.isEmpty(orgList)){ |
|
|
|
if (!CollectionUtils.isEmpty(orgList)) { |
|
|
|
throw new EpmetException("请先删除下级党组织!"); |
|
|
|
} |
|
|
|
//判断该组织下是否有党员
|
|
|
|
List<IcPartyMemberEntity> memberList = icPartyMemberDao.selectAllByOrgId(id); |
|
|
|
if(!CollectionUtils.isEmpty(memberList)){ |
|
|
|
if (!CollectionUtils.isEmpty(memberList)) { |
|
|
|
throw new EpmetException("该组织下有党员信息暂时不可删除!"); |
|
|
|
} |
|
|
|
baseDao.deleteById(id); |
|
|
@ -215,15 +222,15 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<BranchlistTreeDTO>> branchlist(TokenDto tokenDto) { |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(),tokenDto.getUserId()); |
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); |
|
|
|
List<BranchlistTreeDTO> resultList = new ArrayList<>(); |
|
|
|
BranchlistTreeDTO result = new BranchlistTreeDTO(); |
|
|
|
result.setValue(staffInfo.getAgencyId()); |
|
|
|
// result.setOrgPids(staffInfo.getAgencyPIds());
|
|
|
|
result.setLabel(staffInfo.getAgencyName()); |
|
|
|
//该行政组织下的所有类型为支部的党组织
|
|
|
|
List<BranchlistTreeSubDTO> orgList = baseDao.selectAllBranchByAgencyId(staffInfo.getAgencyId(),tokenDto.getCustomerId()); |
|
|
|
if(CollectionUtils.isEmpty(orgList)){ |
|
|
|
List<BranchlistTreeSubDTO> orgList = baseDao.selectAllBranchByAgencyId(staffInfo.getAgencyId(), tokenDto.getCustomerId()); |
|
|
|
if (CollectionUtils.isEmpty(orgList)) { |
|
|
|
return new Result<List<BranchlistTreeDTO>>().ok(resultList); |
|
|
|
} |
|
|
|
result.setChildren(orgList); |
|
|
@ -237,6 +244,32 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
return new Result<List<IcPartyOrgTreeDTO>>().ok(build(list)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result<List<IcPartyOrgTreeDTO>> getParentOrgList(GetParentOrgFormDTO formDTO) { |
|
|
|
Result<CustomerAgencyDTO> agencyDTOResult = govOrgOpenFeignClient.getAgencyById(formDTO.getAgencyId()); |
|
|
|
if (!agencyDTOResult.success() || null == agencyDTOResult || null == agencyDTOResult.getData()) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询行政组织信息错误", "查询行政组织信息错误"); |
|
|
|
} |
|
|
|
String agencyPid = agencyDTOResult.getData().getPid(); |
|
|
|
List<IcPartyOrgTreeDTO> list = new ArrayList<>(); |
|
|
|
//如果本工作人员的级别是该客户下的最高级别,并且没有一级组织时,添加一级组织选项
|
|
|
|
IcPartyOrgEntity entity = baseDao.selectByCustomerIdAndFirstOrg(formDTO.getCustomerId()); |
|
|
|
if("0".equals(agencyPid) && null == entity){ |
|
|
|
IcPartyOrgTreeDTO firstOrg = new IcPartyOrgTreeDTO(); |
|
|
|
firstOrg.setId("0"); |
|
|
|
firstOrg.setPartyOrgName("一级组织"); |
|
|
|
list.add(firstOrg); |
|
|
|
} |
|
|
|
//如果类型为支部,则查询该行政组织下的所有党委(列表)
|
|
|
|
if(PartyOrgTypeEnum.BRANCH.getCode().equals(formDTO.getPartyOrgType())){ |
|
|
|
list.addAll(baseDao.selectParentOrgByAgencyPid(agencyPid,formDTO.getCustomerId(),PartyOrgTypeEnum.PARTY.getCode())); |
|
|
|
}else{ |
|
|
|
//查询该行政组织对应上级所关联的党组织(单个实体类)
|
|
|
|
list.addAll(baseDao.selectParentOrgByAgencyPid(agencyPid,formDTO.getCustomerId(),null)); |
|
|
|
} |
|
|
|
return new Result<List<IcPartyOrgTreeDTO>>().ok(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 构建树节点 |
|
|
|
*/ |
|
|
@ -245,13 +278,13 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
|
|
|
|
|
//list转map
|
|
|
|
Map<String, IcPartyOrgTreeDTO> nodeMap = new LinkedHashMap<>(treeNodes.size()); |
|
|
|
for(IcPartyOrgTreeDTO treeNode : treeNodes){ |
|
|
|
for (IcPartyOrgTreeDTO treeNode : treeNodes) { |
|
|
|
nodeMap.put(treeNode.getId(), treeNode); |
|
|
|
} |
|
|
|
|
|
|
|
for(IcPartyOrgTreeDTO node : nodeMap.values()) { |
|
|
|
for (IcPartyOrgTreeDTO node : nodeMap.values()) { |
|
|
|
IcPartyOrgTreeDTO parent = nodeMap.get(node.getPid()); |
|
|
|
if(parent != null && !(node.getId().equals(parent.getId()))){ |
|
|
|
if (parent != null && !(node.getId().equals(parent.getId()))) { |
|
|
|
parent.getChildren().add(node); |
|
|
|
continue; |
|
|
|
} |
|
|
|