|
|
@ -105,9 +105,9 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
public Result save(PoliceDTO dto) { |
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
|
// 先查询该社区下有没有网格群,没有就同时创建民警和群,有就表示已经创建过。
|
|
|
|
List<DeptLevelAndLeaderDTO> deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()).getData(); |
|
|
|
List<DeptLevelAndLeaderDTO> 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<DeptLevelAndLeaderDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId() + ""); |
|
|
@ -123,7 +123,7 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
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<PoliceDao, PoliceEntity> |
|
|
|
|
|
|
|
for (PoliceDTO dto : ids) { |
|
|
|
// 社区ID下有多少个网格信息
|
|
|
|
List<DeptLevelAndLeaderDTO> deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); |
|
|
|
List<Long> deptIdList = deptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); |
|
|
|
List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); |
|
|
|
List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); |
|
|
|
// 现有的群的网格信息
|
|
|
|
List<DeptLevelAndLeaderDTO> existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); |
|
|
|
List<Long> existedDeptIdList = existedDeptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); |
|
|
|
List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); |
|
|
|
List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); |
|
|
|
// 求差集,即为还没有创建过群的网格ID
|
|
|
|
List<Long> reduce = deptIdList.stream().filter(item -> !existedDeptIdList.contains(item)).collect(toList()); |
|
|
|
List<Long> reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList()); |
|
|
|
|
|
|
|
// 补建群
|
|
|
|
reduce.forEach(deptId -> { |
|
|
|
// 通过deptID反向找出该网格信息
|
|
|
|
Optional<DeptLevelAndLeaderDTO> deptOptional = deptList.stream().filter(item -> item.getDeptId().equals(deptId)).findFirst(); |
|
|
|
if (deptOptional.isPresent()) { |
|
|
|
reduce.forEach(gridId -> { |
|
|
|
// 通过gridId反向找出该网格信息
|
|
|
|
Optional<DeptLevelAndLeaderDTO> 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<PoliceDao, PoliceEntity> |
|
|
|
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); |
|
|
|
} |
|
|
|
}); |
|
|
|