From 9b9f4921466f46aadbb8de072f8166ac59b29351 Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Fri, 22 May 2020 16:00:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AD=A6=E6=B0=91=E8=A1=A5=E5=BB=BA=E7=BE=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B0=91=E8=AD=A6=E5=90=8C=E6=97=B6=E8=A7=A3?= =?UTF-8?q?=E6=95=A3=E7=BE=A4=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PoliceServiceImpl.java | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java index f82ea58..a49e2bc 100644 --- a/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java +++ b/epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java @@ -48,6 +48,7 @@ import javax.annotation.Resource; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Optional; import static java.util.stream.Collectors.toList; @@ -156,6 +157,7 @@ public class PoliceServiceImpl extends BaseServiceImpl public void delete(String[] ids) { // 逻辑删除(@TableLogic 注解) baseDao.deleteBatchIds(Arrays.asList(ids)); + groupDao.deleteGroupByProjectIds(Arrays.asList(ids)); } @Override @@ -165,30 +167,37 @@ public class PoliceServiceImpl extends BaseServiceImpl for (PoliceDTO dto : ids) { // 社区ID下有多少个网格信息 List deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); + List deptIdList = deptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 现有的群的网格信息 List existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); + List existedDeptIdList = existedDeptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 求差集,即为还没有创建过群的网格ID - List reduce = deptList.stream().filter(item -> !existedDeptList.contains(item)).collect(toList()); + List reduce = deptIdList.stream().filter(item -> !existedDeptIdList.contains(item)).collect(toList()); // 补建群 - reduce.forEach(dept -> { - ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); - GroupEntity groupEntity = new GroupEntity(); - DeptEntityUtils.loadDeptInfo( - ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), - groupEntity - ); - groupEntity.setReferenceBusinessId(dto.getId()); - groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); - groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); - groupEntity.setGroupName(dto.getDeptName() + "警民群"); - groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); - groupEntity.setGrid(dept.getDeptName()); - groupEntity.setGridId(dept.getDeptId()); - groupDao.insert(groupEntity); + reduce.forEach(deptId -> { + // 通过deptID反向找出该网格信息 + Optional deptOptional = deptList.stream().filter(item -> item.getDeptId().equals(deptId)).findFirst(); + if (deptOptional.isPresent()) { + // 存在 + DeptLevelAndLeaderDTO dept = deptOptional.get(); + ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); + GroupEntity groupEntity = new GroupEntity(); + DeptEntityUtils.loadDeptInfo( + ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), + groupEntity + ); + groupEntity.setReferenceBusinessId(dto.getId()); + groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); + groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); + groupEntity.setGroupName(dept.getDeptName() + "警民群"); + groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); + groupEntity.setGrid(dept.getDeptName()); + groupEntity.setGridId(dept.getDeptId()); + groupDao.insert(groupEntity); + } }); } - baseDao.deleteBatchIds(Arrays.asList(ids)); } /**