Browse Source

党组织和行政组织添加上下级校验

dev
Jackwang 3 years ago
parent
commit
8cc7ec7f0b
  1. 9
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/dao/IcPartyOrgDao.java
  2. 60
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partyOrg/service/impl/IcPartyOrgServiceImpl.java
  3. 5
      epmet-module/resi-partymember/resi-partymember-server/src/main/resources/mapper/partyOrg/IcPartyOrgDao.xml

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

@ -55,4 +55,13 @@ public interface IcPartyOrgDao extends BaseDao<IcPartyOrgEntity> {
* @return com.epmet.modules.partyOrg.entity.IcPartyOrgEntity
*/
IcPartyOrgEntity selectByAgencyId(@Param("agencyId") String agencyId,@Param("partyOrgType") String partyOrgType);
/**
* @describe: 查询当前客户下的一级组织
* @author wangtong
* @date 2022/5/25 10:47
* @params [customerId]
* @return com.epmet.modules.partyOrg.entity.IcPartyOrgEntity
*/
IcPartyOrgEntity selectLevelOneOrgByCustomerId(@Param("customerId") String customerId);
}

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

@ -11,6 +11,7 @@ import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.enums.OrgLevelEnums;
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao;
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity;
import com.epmet.modules.partyOrg.service.IcPartyOrgService;
@ -88,6 +89,20 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
return new Result().error("行政组织编码不可重复!");
}
}
IcPartyOrgEntity parentOrg = baseDao.selectById(dto.getOrgPid());
//判断当前党组织的类型是否是所选上级党组织类型的直接下级
if("0".equals(dto.getOrgPid())){
if(PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){
return new Result().error("支部不可设为一级组织!");
}
//一个客户下只能有一个一级组织
IcPartyOrgEntity levelOneOrg = baseDao.selectLevelOneOrgByCustomerId(dto.getCustomerId());
if(null != levelOneOrg){
return new Result().error("当前客户下已存在一级组织,不可重复添加!");
}
}else{
checkOrgType(parentOrg.getPartyOrgType(),dto.getPartyOrgType());
}
//如果不是支部,需要判断行政组织是否重复
if(!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){
IcPartyOrgEntity isAgency = baseDao.selectByAgencyId(dto.getAgencyId(),PartyOrgTypeEnum.BRANCH.getCode());
@ -95,10 +110,11 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
return new Result().error("该行政组织已被关联!");
}
AgencyInfoCache agency = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId());
//判断该所选的行政组织类型是否与当前党组织的类型一致
checnAgencyLevel(agency.getLevel(),dto.getPartyOrgType());
dto.setAgencyPids(agency.getPids());
}else{
//类型为支部时,行政组织信息与上级党组织一致
IcPartyOrgEntity parentOrg = baseDao.selectById(dto.getOrgPid());
dto.setAgencyId(parentOrg.getAgencyId());
dto.setAgencyPids(parentOrg.getAgencyPids());
}
@ -111,6 +127,48 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart
return new Result();
}
/**
* @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)){
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择党委作为上级组织!");
}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)){
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择区委作为上级组织!");
}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)){
throw new EpmetException("请保持上级党组织的类型与当前党组织类型为直接的上下级关系,选择省委作为上级组织!");
}
}
/**
* @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)){
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择省级的行政组织!");
}else if(PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.CITY.getLevel().equals(agencyLevel)){
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择市级的行政组织!");
}else if(PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.DISTRICT.getLevel().equals(agencyLevel)){
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择区级的行政组织!");
}else if(PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.STREET.getLevel().equals(agencyLevel)){
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择街道级的行政组织!");
}else if(PartyOrgTypeEnum.PROVINCIAL.getCode().equals(partyOrgType) && !OrgLevelEnums.COMMUNITY.getLevel().equals(agencyLevel)){
throw new EpmetException("请保持党组织类型与行政组织类型一致,选择社区级的行政组织!");
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(IcPartyOrgDTO dto) {

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

@ -63,6 +63,11 @@
and PARTY_ORG_TYPE!=#{partyOrgType}
and AGENCY_ID =#{agencyId}
</select>
<select id="selectLevelOneOrgByCustomerId" resultType="com.epmet.modules.partyOrg.entity.IcPartyOrgEntity">
select * from ic_party_org
where DEL_FLAG='0'
and CUSTOMER_ID=#{customerId}
</select>
</mapper>

Loading…
Cancel
Save