|
@ -14,13 +14,21 @@ import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
|
|
import com.epmet.modules.partyOrg.dao.IcPartyOrgDao; |
|
|
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity; |
|
|
import com.epmet.modules.partyOrg.entity.IcPartyOrgEntity; |
|
|
import com.epmet.modules.partyOrg.service.IcPartyOrgService; |
|
|
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.IcPartyOrgDTO; |
|
|
|
|
|
import com.epmet.resi.partymember.dto.partyOrg.form.PartyOrgTreeListDTO; |
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO; |
|
|
import com.epmet.resi.partymember.dto.partyOrg.result.IcPartyOrgTreeDTO; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 党组织表 |
|
|
* 党组织表 |
|
@ -31,6 +39,9 @@ import java.util.*; |
|
|
@Service |
|
|
@Service |
|
|
public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPartyOrgEntity> implements IcPartyOrgService { |
|
|
public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPartyOrgEntity> implements IcPartyOrgService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IcPartyMemberDao icPartyMemberDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<IcPartyOrgDTO> page(Map<String, Object> params) { |
|
|
public PageData<IcPartyOrgDTO> page(Map<String, Object> params) { |
|
@ -66,19 +77,34 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result save(IcPartyOrgDTO dto) { |
|
|
public Result save(IcPartyOrgDTO dto) { |
|
|
|
|
|
//同一个客户下,名称和编码不可重复
|
|
|
|
|
|
IcPartyOrgEntity repeatName = baseDao.selectByCuIdAndNameOrCode(dto.getPartyOrgName(),null,dto.getCustomerId()); |
|
|
|
|
|
if(null != repeatName){ |
|
|
|
|
|
return new Result().error("行政组织名称不可重复!"); |
|
|
|
|
|
} |
|
|
|
|
|
IcPartyOrgEntity repeatCode = baseDao.selectByCuIdAndNameOrCode(null,dto.getPartyOrgCode(),dto.getCustomerId()); |
|
|
|
|
|
if(null != repeatCode){ |
|
|
|
|
|
return new Result().error("行政组织编码不可重复!"); |
|
|
|
|
|
} |
|
|
//如果不是支部,需要判断行政组织是否重复
|
|
|
//如果不是支部,需要判断行政组织是否重复
|
|
|
if(!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){ |
|
|
if(!PartyOrgTypeEnum.BRANCH.getCode().equals(dto.getPartyOrgType())){ |
|
|
if(StringUtils.isBlank(dto.getAgencyId())){ |
|
|
IcPartyOrgEntity isAgency = baseDao.selectByAgencyId(dto.getAgencyId(),PartyOrgTypeEnum.BRANCH.getCode()); |
|
|
return new Result().error("组织类型不为支部时,行政组织不可为空"); |
|
|
if(null != isAgency){ |
|
|
} |
|
|
return new Result().error("该行政组织已被关联!"); |
|
|
//判断行政组织是否重复
|
|
|
} |
|
|
|
|
|
AgencyInfoCache agency = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
|
|
dto.setAgencyPids(agency.getPids()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
//类型为支部时,行政组织信息与上级党组织一致
|
|
|
|
|
|
IcPartyOrgEntity parentOrg = baseDao.selectById(dto.getOrgPid()); |
|
|
|
|
|
dto.setAgencyId(parentOrg.getAgencyId()); |
|
|
|
|
|
dto.setAgencyPids(parentOrg.getAgencyPids()); |
|
|
} |
|
|
} |
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
if (null == agencyInfo){ |
|
|
if (null == agencyInfo){ |
|
|
throw new EpmetException("组织信息获取失败"); |
|
|
throw new EpmetException("组织信息获取失败"); |
|
|
} |
|
|
} |
|
|
IcPartyOrgEntity entity = ConvertUtils.sourceToTarget(dto, IcPartyOrgEntity.class); |
|
|
IcPartyOrgEntity entity = ConvertUtils.sourceToTarget(dto, IcPartyOrgEntity.class); |
|
|
entity.setAgencyPids(agencyInfo.getPids().replaceAll(":",",")); |
|
|
|
|
|
insert(entity); |
|
|
insert(entity); |
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
@ -100,11 +126,24 @@ public class IcPartyOrgServiceImpl extends BaseServiceImpl<IcPartyOrgDao, IcPart |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void delete(String[] ids) { |
|
|
public void delete(String[] ids) { |
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
// baseDao.deleteBatchIds(Arrays.asList(ids));
|
|
|
|
|
|
for(String id : ids){ |
|
|
|
|
|
//判断该组织是否有下级党组织
|
|
|
|
|
|
List<IcPartyOrgEntity> orgList = baseDao.selectAllByOrgId(id); |
|
|
|
|
|
if(!CollectionUtils.isEmpty(orgList)){ |
|
|
|
|
|
throw new EpmetException("请先删除下级党组织!"); |
|
|
|
|
|
} |
|
|
|
|
|
//判断该组织下是否有党员
|
|
|
|
|
|
List<IcPartyMemberEntity> memberList = icPartyMemberDao.selectAllByOrgId(id); |
|
|
|
|
|
if(!CollectionUtils.isEmpty(memberList)){ |
|
|
|
|
|
throw new EpmetException("该组织下有党员信息暂时不可删除!"); |
|
|
|
|
|
} |
|
|
|
|
|
baseDao.deleteById(id); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<List<IcPartyOrgTreeDTO>> getTreelist(IcPartyOrgDTO formDTO) { |
|
|
public Result<List<IcPartyOrgTreeDTO>> getTreelist(PartyOrgTreeListDTO formDTO) { |
|
|
List<IcPartyOrgTreeDTO> list = baseDao.getTreelist(formDTO); |
|
|
List<IcPartyOrgTreeDTO> list = baseDao.getTreelist(formDTO); |
|
|
return new Result<List<IcPartyOrgTreeDTO>>().ok(build(list)); |
|
|
return new Result<List<IcPartyOrgTreeDTO>>().ok(build(list)); |
|
|
} |
|
|
} |
|
|