Browse Source

警民补建群功能完善,增加删除民警同时解散群功能。

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

43
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<PoliceDao, PoliceEntity>
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<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> existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + "");
List<Long> existedDeptIdList = existedDeptList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 求差集,即为还没有创建过群的网格ID
List<DeptLevelAndLeaderDTO> reduce = deptList.stream().filter(item -> !existedDeptList.contains(item)).collect(toList());
List<Long> 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<DeptLevelAndLeaderDTO> 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));
}
/**

Loading…
Cancel
Save