| | |
| | | |
| | | 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; |
| | |
| | | if (!ObjectUtils.isEmpty(comPbOrgDOS)) { |
| | | comPbOrgDOS.forEach(comPbOrgDO -> { |
| | | PartyOrganizationVO partyOrganizationVO = new PartyOrganizationVO(); |
| | | partyOrganizationVO.setId(comPbOrgDO.getId()); |
| | | partyOrganizationVO.setName(comPbOrgDO.getName()); |
| | | partyOrganizationVO.setStatus(comPbOrgDO.getStatus()); |
| | | BeanUtils.copyProperties(comPbOrgDO,partyOrganizationVO); |
| | | partyOrganizationVOS.add(partyOrganizationVO); |
| | | }); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public R listPartyOrganizationAll(PartyOrganizationVO partyOrganizationVO) { |
| | | IPage<PartyOrganizationVO> orgPgaeList = this.comPbOrgDAO.listPartyOrganizationAll( |
| | | IPage<PartyOrganizationVO> orgPage = this.comPbOrgDAO.listPartyOrganizationAll( |
| | | new Page(partyOrganizationVO.getPageNum(), partyOrganizationVO.getPageSize()), partyOrganizationVO); |
| | | if (!ObjectUtils.isEmpty(orgPgaeList.getRecords())) { |
| | | orgPgaeList.getRecords().forEach(comPbOrgDO -> { |
| | | List<ComPbMemberDO> comPbMemberDOs = comPbMemberDAO.selectList( |
| | | new QueryWrapper<ComPbMemberDO>().lambda().eq(ComPbMemberDO::getOrgId, comPbOrgDO.getId())); |
| | | comPbOrgDO.setCountPerson(comPbMemberDOs.size()); |
| | | 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); |
| | | }); |
| | | } |
| | | return R.ok(orgPgaeList); |
| | | 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); |
| | | } |
| | | |
| | | /** |
| | |
| | | public R addPartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(1); |
| | | comPbOrgDO.setParentId(0L); |
| | | comPbOrgDO.setLevel(partyOrganizationVO.getType()); |
| | | 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(); |
| | |
| | | public R updatePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); |
| | | BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); |
| | | comPbOrgDO.setLevel(1); |
| | | comPbOrgDO.setParentId(0L); |
| | | 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(); |
| | |
| | | */ |
| | | @Override |
| | | public R deletePartyOrganization(PartyOrganizationVO partyOrganizationVO) { |
| | | List<ComPbMemberDO> comPbMemberDOs = comPbMemberDAO.selectList( |
| | | 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(comPbMemberDOs) && comPbMemberDOs.size() > 0) { |
| | | if (!CollectionUtils.isEmpty(comPbMemberList) && comPbMemberList.size() > 0) { |
| | | return R.fail("该党组织下已有党员,不能删除!"); |
| | | } |
| | | int insert = comPbOrgDAO.deleteById(partyOrganizationVO.getId()); |
| | |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public List<PartyOrganizationVO> listPartyOrganizationByApp(ComListPartyDTO comListPartyDTO) { |
| | | List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); |
| | | QueryWrapper<ComPbOrgDO> queryWrapper = new QueryWrapper<>(); |
| | |
| | | } |
| | | 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); |
| | | } |
| | | } |