Browse Source

修改字段名称,dept->grid

hotfix/yujt_opt
zhangyuan 5 years ago
parent
commit
7ac3a6b72f
  1. 34
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java

34
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<PoliceDao, PoliceEntity>
public Result save(PoliceDTO dto) { public Result save(PoliceDTO dto) {
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); 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("新增失败"); return new Result().error("新增失败");
} }
List<DeptLevelAndLeaderDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId() + ""); List<DeptLevelAndLeaderDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId() + "");
@ -123,7 +123,7 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
insert(entity); insert(entity);
// 创民警的同时创建群 // 创民警的同时创建群
deptList.forEach(dept -> { gridList.forEach(dept -> {
ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + "");
GroupEntity groupEntity = new GroupEntity(); GroupEntity groupEntity = new GroupEntity();
DeptEntityUtils.loadDeptInfo( DeptEntityUtils.loadDeptInfo(
@ -166,22 +166,22 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
for (PoliceDTO dto : ids) { for (PoliceDTO dto : ids) {
// 社区ID下有多少个网格信息 // 社区ID下有多少个网格信息
List<DeptLevelAndLeaderDTO> deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData();
List<Long> deptIdList = deptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 现有的群的网格信息 // 现有的群的网格信息
List<DeptLevelAndLeaderDTO> existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + "");
List<Long> existedDeptIdList = existedDeptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 求差集,即为还没有创建过群的网格ID // 求差集,即为还没有创建过群的网格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 -> { reduce.forEach(gridId -> {
// 通过deptID反向找出该网格信息 // 通过gridId反向找出该网格信息
Optional<DeptLevelAndLeaderDTO> deptOptional = deptList.stream().filter(item -> item.getDeptId().equals(deptId)).findFirst(); Optional<DeptLevelAndLeaderDTO> gridOptional = gridList.stream().filter(item -> item.getDeptId().equals(gridId)).findFirst();
if (deptOptional.isPresent()) { if (gridOptional.isPresent()) {
// 存在 // 存在
DeptLevelAndLeaderDTO dept = deptOptional.get(); DeptLevelAndLeaderDTO grid = gridOptional.get();
ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(grid.getDeptId() + "");
GroupEntity groupEntity = new GroupEntity(); GroupEntity groupEntity = new GroupEntity();
DeptEntityUtils.loadDeptInfo( DeptEntityUtils.loadDeptInfo(
ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class),
@ -190,10 +190,10 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
groupEntity.setReferenceBusinessId(dto.getId()); groupEntity.setReferenceBusinessId(dto.getId());
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue());
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR);
groupEntity.setGroupName(dept.getDeptName() + "警民群"); groupEntity.setGroupName(grid.getDeptName() + "警民群");
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY);
groupEntity.setGrid(dept.getDeptName()); groupEntity.setGrid(grid.getDeptName());
groupEntity.setGridId(dept.getDeptId()); groupEntity.setGridId(grid.getDeptId());
groupDao.insert(groupEntity); groupDao.insert(groupEntity);
} }
}); });

Loading…
Cancel
Save