From 7ac3a6b72f62955ee050db66ec38d6d5b5a9f7ce Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Fri, 22 May 2020 16:21:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=97=E6=AE=B5=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=EF=BC=8Cdept->grid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PoliceServiceImpl.java | 34 +++++++++---------- 1 file changed, 17 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 785c55b..4d59dc0 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 @@ -105,9 +105,9 @@ public class PoliceServiceImpl extends BaseServiceImpl public Result save(PoliceDTO dto) { PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); // 先查询该社区下有没有网格群,没有就同时创建民警和群,有就表示已经创建过。 - List deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()).getData(); + List gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()).getData(); // 社区下没有网格 - if (deptList.size() == 0 || dto.getDeptId() == null) { + if (gridList.size() == 0 || dto.getDeptId() == null) { return new Result().error("新增失败"); } List groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId() + ""); @@ -123,7 +123,7 @@ public class PoliceServiceImpl extends BaseServiceImpl insert(entity); // 创民警的同时创建群 - deptList.forEach(dept -> { + gridList.forEach(dept -> { ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); GroupEntity groupEntity = new GroupEntity(); DeptEntityUtils.loadDeptInfo( @@ -166,22 +166,22 @@ 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 gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); + List gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 现有的群的网格信息 - List existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); - List existedDeptIdList = existedDeptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); + List existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); + List existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 求差集,即为还没有创建过群的网格ID - List reduce = deptIdList.stream().filter(item -> !existedDeptIdList.contains(item)).collect(toList()); + List reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList()); // 补建群 - reduce.forEach(deptId -> { - // 通过deptID反向找出该网格信息 - Optional deptOptional = deptList.stream().filter(item -> item.getDeptId().equals(deptId)).findFirst(); - if (deptOptional.isPresent()) { + reduce.forEach(gridId -> { + // 通过gridId反向找出该网格信息 + Optional gridOptional = gridList.stream().filter(item -> item.getDeptId().equals(gridId)).findFirst(); + if (gridOptional.isPresent()) { // 存在 - DeptLevelAndLeaderDTO dept = deptOptional.get(); - ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); + DeptLevelAndLeaderDTO grid = gridOptional.get(); + ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(grid.getDeptId() + ""); GroupEntity groupEntity = new GroupEntity(); DeptEntityUtils.loadDeptInfo( ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), @@ -190,10 +190,10 @@ public class PoliceServiceImpl extends BaseServiceImpl groupEntity.setReferenceBusinessId(dto.getId()); groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); - groupEntity.setGroupName(dept.getDeptName() + "警民群"); + groupEntity.setGroupName(grid.getDeptName() + "警民群"); groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); - groupEntity.setGrid(dept.getDeptName()); - groupEntity.setGridId(dept.getDeptId()); + groupEntity.setGrid(grid.getDeptName()); + groupEntity.setGridId(grid.getDeptId()); groupDao.insert(groupEntity); } });