|
|
@ -72,13 +72,13 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PoliceRedis policeRedis; |
|
|
|
private EventFeignClient eventFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private TopicService topicService; |
|
|
|
private PoliceRedis policeRedis; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EventFeignClient eventFeignClient; |
|
|
|
private TopicService topicService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GroupService groupService; |
|
|
@ -116,7 +116,6 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
return ConvertUtils.sourceToTarget(entity, PoliceDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<DeptLevelAndLeaderDTO> getChildDeptList(String tyepKey, Long deptId) { |
|
|
|
Result<List<DeptLevelAndLeaderDTO>> adminResult = adminFeignClient.listChildDeptLevelById(tyepKey, deptId); |
|
|
|
if (!adminResult.success()) { |
|
|
@ -168,9 +167,8 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Result save(PoliceDTO dto) { |
|
|
|
Long communityId = dto.getDeptId(); |
|
|
|
if (hasPolice(communityId)) { |
|
|
|
return new Result().error("该社区已有民警,无法重复添加"); |
|
|
|
} |
|
|
|
Boolean hasPolice = hasPolice(communityId); |
|
|
|
|
|
|
|
// 社区第一次添加民警,直接保存
|
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId)); |
|
|
@ -181,6 +179,8 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
entity.setDeptName(parentAndAllDeptDTO.getGrid()); |
|
|
|
insert(entity); |
|
|
|
|
|
|
|
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。
|
|
|
|
if (!hasPolice) { |
|
|
|
// 先查询该社区下所有网格
|
|
|
|
List<DeptLevelAndLeaderDTO> deptList = getChildDeptList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()); |
|
|
|
if (CollUtil.isEmpty(deptList)) { |
|
|
@ -191,22 +191,11 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
if (CollUtil.isNotEmpty(withoutGroupDeptList)) { |
|
|
|
withoutGroupDeptList.forEach( |
|
|
|
deptForGroup -> { |
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(deptForGroup, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
groupEntity.setReferenceBusinessId(entity.getId()); |
|
|
|
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
|
groupEntity.setGroupName(deptForGroup.getDeptName() + "警民群"); |
|
|
|
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); |
|
|
|
groupEntity.setGrid(deptForGroup.getDeptName()); |
|
|
|
groupEntity.setGridId(deptForGroup.getDeptId()); |
|
|
|
groupDao.insert(groupEntity); |
|
|
|
createGroup(entity.getId(), deptForGroup.getDeptId(), deptForGroup.getDeptName()); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
@ -222,14 +211,12 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
groupDao.deleteGroupByProjectIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void supplement(PoliceDTO[] ids) { |
|
|
|
public void supplement(PoliceDTO dto) { |
|
|
|
|
|
|
|
for (PoliceDTO dto : ids) { |
|
|
|
// 社区ID下有多少个网格信息
|
|
|
|
List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); |
|
|
|
List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); |
|
|
@ -241,33 +228,23 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
|
|
|
|
// 补建群
|
|
|
|
reduce.forEach(gridId -> { |
|
|
|
// 通过gridId反向找出该网格信息
|
|
|
|
Optional<DeptLevelAndLeaderDTO> gridOptional = gridList.stream().filter(item -> item.getDeptId().equals(gridId)).findFirst(); |
|
|
|
if (gridOptional.isPresent()) { |
|
|
|
// 存在
|
|
|
|
DeptLevelAndLeaderDTO grid = gridOptional.get(); |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(grid.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(grid.getDeptName() + "警民群"); |
|
|
|
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); |
|
|
|
groupEntity.setGrid(grid.getDeptName()); |
|
|
|
groupEntity.setGridId(grid.getDeptId()); |
|
|
|
groupDao.insert(groupEntity); |
|
|
|
} |
|
|
|
createGroup(dto.getId(), dto.getDeptId(), dto.getDeptName()); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PoliceResultDTO getPoliceAndGroup(PoliceFormDTO dto) { |
|
|
|
return baseDao.selectPoliceGroupInfo(dto); |
|
|
|
PoliceResultDTO policeResultDTO = baseDao.selectPoliceGroupInfo(dto); |
|
|
|
if (policeResultDTO != null) { |
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(dto.getGridId())); |
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
entity |
|
|
|
); |
|
|
|
policeResultDTO.setPoliceList(baseDao.selectPoliceInfo(entity)); |
|
|
|
} |
|
|
|
return policeResultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -383,4 +360,28 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
|
|
|
|
return groupEntities; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成群 |
|
|
|
* |
|
|
|
* @param businessId 业务ID |
|
|
|
* @param gridId 网格ID |
|
|
|
* @param gridName 网格名称 |
|
|
|
*/ |
|
|
|
private void createGroup(String businessId, Long gridId, String gridName) { |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(gridId + ""); |
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
// groupEntity.setReferenceBusinessId(businessId);
|
|
|
|
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
|
groupEntity.setGroupName(gridName + "警民群"); |
|
|
|
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); |
|
|
|
groupEntity.setGrid(gridName); |
|
|
|
groupEntity.setGridId(gridId); |
|
|
|
groupDao.insert(groupEntity); |
|
|
|
} |
|
|
|
} |