From 85cf42314fc04a637f1a44e78c1e476a445bf0f3 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期一, 14 三月 2022 13:29:18 +0800 Subject: [PATCH] Merge branch 'dev' --- springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/PartyOrganizationServiceImpl.java | 201 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 181 insertions(+), 20 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/PartyOrganizationServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/PartyOrganizationServiceImpl.java index b62b984..7119fca 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/PartyOrganizationServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_partybuilding/src/main/java/com/panzhihua/service_dangjian/service/impl/PartyOrganizationServiceImpl.java @@ -2,9 +2,11 @@ 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; @@ -49,9 +51,7 @@ 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); }); } @@ -65,21 +65,49 @@ */ @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); + }); + } + 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(orgPgaeList); + return R.ok(orgPage); } /** * 新增党支部 - * + * * @param partyOrganizationVO * 党支部基本信息 * @return 新增结果 @@ -88,10 +116,53 @@ public R addPartyOrganization(PartyOrganizationVO partyOrganizationVO) { ComPbOrgDO comPbOrgDO = new ComPbOrgDO(); BeanUtils.copyProperties(partyOrganizationVO, comPbOrgDO); - comPbOrgDO.setLevel(1); - comPbOrgDO.setParentId(0L); + 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(); @@ -99,7 +170,7 @@ /** * 编辑党支部 - * + * * @param partyOrganizationVO * 党支部基本信息 * @return 编辑结果 @@ -108,10 +179,49 @@ 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(); @@ -119,7 +229,7 @@ /** * 启用,禁用党支部 - * + * * @param partyOrganizationVO * 党支部基本信息 * @return 编辑结果 @@ -140,16 +250,20 @@ /** * 删除党支部 - * + * * @param partyOrganizationVO * 党支部基本信息 * @return 编辑结果 */ @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()); @@ -159,6 +273,7 @@ return R.fail(); } + @Override public List<PartyOrganizationVO> listPartyOrganizationByApp(ComListPartyDTO comListPartyDTO) { List<PartyOrganizationVO> partyOrganizationVOS = new ArrayList<>(); QueryWrapper<ComPbOrgDO> queryWrapper = new QueryWrapper<>(); @@ -181,4 +296,50 @@ } 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); + } } -- Gitblit v1.7.1