| | |
| | | package com.panzhihua.service_dangjian.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ComListPartyDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.partybuilding.PartyOrganizationVO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbMemberDAO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbOrgDAO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbMemberDO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbOrgDO; |
| | | import com.panzhihua.service_dangjian.service.PartyOrganizationService; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ComListPartyDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.partybuilding.west.PartyOrganizationVO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbMemberDAO; |
| | | import com.panzhihua.service_dangjian.dao.ComPbOrgDAO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbMemberDO; |
| | | import com.panzhihua.service_dangjian.model.dos.ComPbOrgDO; |
| | | import com.panzhihua.service_dangjian.service.PartyOrganizationService; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | **/ |
| | | @Service |
| | | public class PartyOrganizationServiceImpl implements PartyOrganizationService { |
| | | @Resource |
| | | private ComPbOrgDAO comPbOrgDAO; |
| | | @Resource |
| | | private ComPbMemberDAO comPbMemberDAO; |
| | | @Resource |
| | | private ComPbOrgDAO comPbOrgDAO; |
| | | @Resource |
| | | private ComPbMemberDAO comPbMemberDAO; |
| | | |
| | | /** |
| | | * 社区所有启用的党组织列表 |
| | | * |
| | | * @return 党组织集合 |
| | | */ |
| | | @Override |
| | | public List<PartyOrganizationVO> listPartyOrganization(Long communityId) { |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | List<ComPbOrgDO> comPbOrgDOS = comPbOrgDAO.selectList(new QueryWrapper<ComPbOrgDO>().lambda() |
| | | .eq(ComPbOrgDO::getCommunityId, communityId).eq(ComPbOrgDO::getStatus, 1)); |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | partyOrganizationVO.setId(comPbOrgDO.getId()); |
| | | partyOrganizationVO.setName(comPbOrgDO.getName()); |
| | | partyOrganizationVO.setStatus(comPbOrgDO.getStatus()); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | | return partyOrganizationVOS; |
| | | } |
| | | /** |
| | | * 社区所有启用的党组织列表 |
| | | * |
| | | * @return 党组织集合 |
| | | */ |
| | | @Override |
| | | public List<PartyOrganizationVO> listPartyOrganization(Long communityId) { |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | List<ComPbOrgDO> comPbOrgDOS = comPbOrgDAO.selectList(new QueryWrapper<ComPbOrgDO>().lambda() |
| | | .eq(ComPbOrgDO::getCommunityId, communityId).eq(ComPbOrgDO::getStatus, 1)); |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | BeanUtils.copyProperties(comPbOrgDO,partyOrganizationVO); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | | return partyOrganizationVOS; |
| | | } |
| | | |
| | | /** |
| | | * 社区所有党组织列表 |
| | | * |
| | | * @return 党组织集合 |
| | | */ |
| | | @Override |
| | | public List<PartyOrganizationVO> listPartyOrganizationAll(Long communityId) { |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | List<ComPbOrgDO> comPbOrgDOS = comPbOrgDAO |
| | | .selectList(new QueryWrapper<ComPbOrgDO>().lambda().eq(ComPbOrgDO::getCommunityId, communityId)); |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | List<ComPbMemberDO> comPbMemberDOs = comPbMemberDAO.selectList( |
| | | new QueryWrapper<ComPbMemberDO>().lambda().eq(ComPbMemberDO::getOrgId, comPbOrgDO.getId())); |
| | | partyOrganizationVO.setId(comPbOrgDO.getId()); |
| | | partyOrganizationVO.setName(comPbOrgDO.getName()); |
| | | partyOrganizationVO.setStatus(comPbOrgDO.getStatus()); |
| | | partyOrganizationVO.setCountPerson(comPbMemberDOs.size()); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | | return partyOrganizationVOS; |
| | | } |
| | | /** |
| | | * 社区所有党组织列表 |
| | | * |
| | | * @return 党组织集合 |
| | | */ |
| | | @Override |
| | | public R listPartyOrganizationAll(PartyOrganizationVO partyOrganizationVO) { |
| | | IPage<PartyOrganizationVO> orgPage = this.comPbOrgDAO.listPartyOrganizationAll( |
| | | new Page(partyOrganizationVO.getPageNum(), partyOrganizationVO.getPageSize()), partyOrganizationVO); |
| | | if (!ObjectUtils.isEmpty(orgPage.getRecords()) && StringUtils.isEmpty(partyOrganizationVO.getKeyWord())) { |
| | | //遍历第一级党组织列表 |
| | | orgPage.getRecords().forEach(org -> { |
| | | partyOrganizationVO.setParentId(org.getId()); |
| | | List<PartyOrganizationVO> twoChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(twoChildList)){ |
| | | //遍历第二级党组织列表 |
| | | twoChildList.forEach(twoChild -> { |
| | | partyOrganizationVO.setParentId(twoChild.getId()); |
| | | List<PartyOrganizationVO> thirdChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(thirdChildList)){ |
| | | //遍历第三级党组织列表 |
| | | thirdChildList.forEach(thirdChild -> { |
| | | partyOrganizationVO.setParentId(thirdChild.getId()); |
| | | List<PartyOrganizationVO> fourChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(fourChildList)){ |
| | | fourChildList.forEach(fourChild -> { |
| | | partyOrganizationVO.setParentId(fourChild.getId()); |
| | | List<PartyOrganizationVO> fiveChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | fourChild.setCountPerson(fourChild.getCountPerson() + fiveChildList.stream().mapToInt(five -> five.getCountPerson()).sum()); |
| | | fourChild.setChildList(fiveChildList); |
| | | }); |
| | | } |
| | | thirdChild.setCountPerson(thirdChild.getCountPerson() + fourChildList.stream().mapToInt(four -> four.getCountPerson()).sum()); |
| | | thirdChild.setChildList(fourChildList); |
| | | }); |
| | | } |
| | | twoChild.setCountPerson(twoChild.getCountPerson() + thirdChildList.stream().mapToInt(third -> third.getCountPerson()).sum()); |
| | | twoChild.setChildList(thirdChildList); |
| | | }); |
| | | } |
| | | org.setCountPerson(org.getCountPerson() + twoChildList.stream().mapToInt(two -> two.getCountPerson()).sum()); |
| | | org.setChildList(twoChildList); |
| | | }); |
| | | } |
| | | return R.ok(orgPage); |
| | | } |
| | | |
| | | /** |
| | | * 新增党支部 |
| | | * |
| | | * @param partyOrganizationVO 党支部基本信息 |
| | | * @return 新增结果 |
| | | */ |
| | | @Override |
| | | public R addPartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(1); |
| | | comPbOrgDO.setParentId(0L); |
| | | int insert = comPbOrgDAO.insert(comPbOrgDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | /** |
| | | * 新增党支部 |
| | | * |
| | | * @param partyOrganizationVO |
| | | * 党支部基本信息 |
| | | * @return 新增结果 |
| | | */ |
| | | @Override |
| | | public R addPartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(partyOrganizationVO.getType()); |
| | | if(partyOrganizationVO.getType().equals(ComPbOrgDO.Type.JCDW)){ |
| | | comPbOrgDO.setParentId(0L); |
| | | } |
| | | ComPbOrgDO oldComPbOrgDO = null; |
| | | int insert = comPbOrgDAO.insert(comPbOrgDO); |
| | | if (insert > 0) { |
| | | switch (partyOrganizationVO.getType()){ |
| | | case ComPbOrgDO.Type.JCDW: |
| | | comPbOrgDO.setParentId(0L); |
| | | comPbOrgDO.setOneId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.EJJCDW: |
| | | comPbOrgDO.setOneId(partyOrganizationVO.getParentId()); |
| | | comPbOrgDO.setTwoId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DZZ: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | } |
| | | comPbOrgDO.setThirdId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DZB: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | comPbOrgDO.setThirdId(oldComPbOrgDO.getThirdId()); |
| | | } |
| | | comPbOrgDO.setFourId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DXZ: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | comPbOrgDO.setThirdId(oldComPbOrgDO.getThirdId()); |
| | | comPbOrgDO.setFourId(oldComPbOrgDO.getFourId()); |
| | | } |
| | | comPbOrgDO.setFiveId(comPbOrgDO.getId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | this.comPbOrgDAO.updateById(comPbOrgDO); |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 编辑党支部 |
| | | * |
| | | * @param partyOrganizationVO 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R updatePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(1); |
| | | comPbOrgDO.setParentId(0L); |
| | | int insert = comPbOrgDAO.updateById(comPbOrgDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | /** |
| | | * 编辑党支部 |
| | | * |
| | | * @param partyOrganizationVO |
| | | * 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R updatePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(partyOrganizationVO.getType()); |
| | | ComPbOrgDO oldComPbOrgDO = null; |
| | | int insert = comPbOrgDAO.updateById(comPbOrgDO); |
| | | if (insert > 0) { |
| | | switch (partyOrganizationVO.getType()){ |
| | | case ComPbOrgDO.Type.JCDW: |
| | | comPbOrgDO.setParentId(0L); |
| | | comPbOrgDO.setOneId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.EJJCDW: |
| | | comPbOrgDO.setOneId(partyOrganizationVO.getParentId()); |
| | | comPbOrgDO.setTwoId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DZZ: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | } |
| | | comPbOrgDO.setThirdId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DZB: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | comPbOrgDO.setThirdId(oldComPbOrgDO.getThirdId()); |
| | | } |
| | | comPbOrgDO.setFourId(comPbOrgDO.getId()); |
| | | break; |
| | | case ComPbOrgDO.Type.DXZ: |
| | | oldComPbOrgDO = this.comPbOrgDAO.selectById(partyOrganizationVO.getParentId()); |
| | | if(oldComPbOrgDO != null){ |
| | | comPbOrgDO.setOneId(oldComPbOrgDO.getOneId()); |
| | | comPbOrgDO.setTwoId(oldComPbOrgDO.getTwoId()); |
| | | comPbOrgDO.setThirdId(oldComPbOrgDO.getThirdId()); |
| | | comPbOrgDO.setFourId(oldComPbOrgDO.getFourId()); |
| | | } |
| | | comPbOrgDO.setFiveId(comPbOrgDO.getId()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 启用,禁用党支部 |
| | | * |
| | | * @param partyOrganizationVO 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R resetPartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = comPbOrgDAO.selectById(partyOrganizationVO.getId()); |
| | | if (ObjectUtils.isEmpty(comPbOrgDO)) { |
| | | return R.fail("没有此党支部"); |
| | | } |
| | | comPbOrgDO.setStatus(partyOrganizationVO.getStatus()); |
| | | int insert = comPbOrgDAO.updateById(comPbOrgDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | /** |
| | | * 启用,禁用党支部 |
| | | * |
| | | * @param partyOrganizationVO |
| | | * 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R resetPartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = comPbOrgDAO.selectById(partyOrganizationVO.getId()); |
| | | if (ObjectUtils.isEmpty(comPbOrgDO)) { |
| | | return R.fail("没有此党支部"); |
| | | } |
| | | comPbOrgDO.setStatus(partyOrganizationVO.getStatus()); |
| | | int insert = comPbOrgDAO.updateById(comPbOrgDO); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 删除党支部 |
| | | * |
| | | * @param partyOrganizationVO 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R deletePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | List<ComPbMemberDO> comPbMemberDOs = comPbMemberDAO.selectList( |
| | | new QueryWrapper<ComPbMemberDO>().lambda().eq(ComPbMemberDO::getOrgId, partyOrganizationVO.getId())); |
| | | if (!CollectionUtils.isEmpty(comPbMemberDOs) && comPbMemberDOs.size() > 0) { |
| | | return R.fail("该党组织下已有党员,不能删除!"); |
| | | } |
| | | int insert = comPbOrgDAO.deleteById(partyOrganizationVO.getId()); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | /** |
| | | * 删除党支部 |
| | | * |
| | | * @param partyOrganizationVO |
| | | * 党支部基本信息 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R deletePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | Integer count = comPbOrgDAO.selectCount(new QueryWrapper<ComPbOrgDO>().lambda().eq(ComPbOrgDO::getParentId,partyOrganizationVO.getId())); |
| | | if(count > 0){ |
| | | return R.fail("该组织下已有子组织,不能删除!"); |
| | | } |
| | | List<ComPbMemberDO> comPbMemberList = comPbMemberDAO.selectList( |
| | | new QueryWrapper<ComPbMemberDO>().lambda().eq(ComPbMemberDO::getOrgId, partyOrganizationVO.getId())); |
| | | if (!CollectionUtils.isEmpty(comPbMemberList) && comPbMemberList.size() > 0) { |
| | | return R.fail("该党组织下已有党员,不能删除!"); |
| | | } |
| | | int insert = comPbOrgDAO.deleteById(partyOrganizationVO.getId()); |
| | | if (insert > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | public List<PartyOrganizationVO> listPartyOrganizationByApp(ComListPartyDTO comListPartyDTO){ |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | QueryWrapper<ComPbOrgDO> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(ComPbOrgDO::getCommunityId, comListPartyDTO.getCommunityId()).eq(ComPbOrgDO::getStatus, 1); |
| | | if(!StringUtils.isEmpty(comListPartyDTO.getName())){ |
| | | queryWrapper.lambda().like(ComPbOrgDO::getName,comListPartyDTO.getName()); |
| | | } |
| | | List<ComPbOrgDO> comPbOrgDOS = comPbOrgDAO.selectList(queryWrapper); |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | partyOrganizationVO.setId(comPbOrgDO.getId()); |
| | | partyOrganizationVO.setName(comPbOrgDO.getName()); |
| | | partyOrganizationVO.setStatus(comPbOrgDO.getStatus()); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | | return partyOrganizationVOS; |
| | | } |
| | | @Override |
| | | public List<PartyOrganizationVO> listPartyOrganizationByApp(ComListPartyDTO comListPartyDTO) { |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | QueryWrapper<ComPbOrgDO> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.lambda().eq(ComPbOrgDO::getStatus, 1); |
| | | if (comListPartyDTO.getCommunityId() != null) { |
| | | queryWrapper.lambda().eq(ComPbOrgDO::getCommunityId, comListPartyDTO.getCommunityId()); |
| | | } |
| | | if (!StringUtils.isEmpty(comListPartyDTO.getName())) { |
| | | queryWrapper.lambda().like(ComPbOrgDO::getName, comListPartyDTO.getName()); |
| | | } |
| | | List<ComPbOrgDO> comPbOrgDOS = comPbOrgDAO.selectList(queryWrapper); |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | partyOrganizationVO.setId(comPbOrgDO.getId()); |
| | | partyOrganizationVO.setName(comPbOrgDO.getName()); |
| | | partyOrganizationVO.setStatus(comPbOrgDO.getStatus()); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | | return partyOrganizationVOS; |
| | | } |
| | | |
| | | /** |
| | | * 查询所有党组织列表 |
| | | * @param partyOrganizationVO 请求参数 |
| | | * @return 党组织列表 |
| | | */ |
| | | @Override |
| | | public R getPbOrgAllList(PartyOrganizationVO partyOrganizationVO){ |
| | | List<PartyOrganizationVO> orgList = this.comPbOrgDAO.getPbOrgAllList(partyOrganizationVO); |
| | | if (!ObjectUtils.isEmpty(orgList) && StringUtils.isEmpty(partyOrganizationVO.getKeyWord())) { |
| | | //遍历第一级党组织列表 |
| | | orgList.forEach(org -> { |
| | | partyOrganizationVO.setParentId(org.getId()); |
| | | List<PartyOrganizationVO> twoChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(twoChildList)){ |
| | | //遍历第二级党组织列表 |
| | | twoChildList.forEach(twoChild -> { |
| | | partyOrganizationVO.setParentId(twoChild.getId()); |
| | | List<PartyOrganizationVO> thirdChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(thirdChildList)){ |
| | | //遍历第三级党组织列表 |
| | | thirdChildList.forEach(thirdChild -> { |
| | | partyOrganizationVO.setParentId(thirdChild.getId()); |
| | | List<PartyOrganizationVO> fourChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | if(!ObjectUtils.isEmpty(fourChildList)){ |
| | | fourChildList.forEach(fourChild -> { |
| | | partyOrganizationVO.setParentId(fourChild.getId()); |
| | | List<PartyOrganizationVO> fiveChildList = comPbOrgDAO.getChildOrgList(partyOrganizationVO); |
| | | fourChild.setCountPerson(fourChild.getCountPerson() + fiveChildList.stream().mapToInt(five -> five.getCountPerson()).sum()); |
| | | fourChild.setChildList(fiveChildList); |
| | | }); |
| | | } |
| | | thirdChild.setCountPerson(thirdChild.getCountPerson() + fourChildList.stream().mapToInt(four -> four.getCountPerson()).sum()); |
| | | thirdChild.setChildList(fourChildList); |
| | | }); |
| | | } |
| | | twoChild.setCountPerson(twoChild.getCountPerson() + thirdChildList.stream().mapToInt(third -> third.getCountPerson()).sum()); |
| | | twoChild.setChildList(thirdChildList); |
| | | }); |
| | | } |
| | | org.setCountPerson(org.getCountPerson() + twoChildList.stream().mapToInt(two -> two.getCountPerson()).sum()); |
| | | org.setChildList(twoChildList); |
| | | }); |
| | | } |
| | | return R.ok(orgList); |
| | | } |
| | | } |