|
|
@ -21,11 +21,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.elink.esua.epdc.commons.mybatis.utils.DeptEntityUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|
|
|
import com.elink.esua.epdc.commons.tools.page.PageData; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; |
|
|
|
import com.elink.esua.epdc.dto.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.constant.GroupConstant; |
|
|
|
import com.elink.esua.epdc.dto.enums.GroupStateEnum; |
|
|
@ -48,6 +50,8 @@ import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import static java.util.stream.Collectors.toList; |
|
|
|
|
|
|
|
/** |
|
|
|
* 民警表 |
|
|
|
* |
|
|
@ -98,9 +102,12 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(PoliceDTO dto) { |
|
|
|
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<GroupListDTO> groupList = groupDao.selectListOfGroupByDeptIds(deptList); |
|
|
|
if (groupList.size() == 0) { |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId() + ""); |
|
|
|
|
|
|
|
// 保存机构,及其他冗余字段。
|
|
|
@ -111,12 +118,12 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
entity.setDeptName(parentAndAllDeptDTO.getGrid()); |
|
|
|
insert(entity); |
|
|
|
|
|
|
|
List<GroupListDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId()); |
|
|
|
if (groupList.size() == 0) { |
|
|
|
// 创民警的同时创建群
|
|
|
|
deptList.forEach(dept -> { |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); |
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
groupEntity.setReferenceBusinessId(entity.getId()); |
|
|
@ -124,9 +131,13 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
|
groupEntity.setGroupName(entity.getDeptName() + "警民群"); |
|
|
|
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); |
|
|
|
groupEntity.setGrid(entity.getDeptName()); |
|
|
|
groupEntity.setGridId(entity.getDeptId()); |
|
|
|
groupEntity.setGrid(dept.getDeptName()); |
|
|
|
groupEntity.setGridId(dept.getDeptId()); |
|
|
|
groupDao.insert(groupEntity); |
|
|
|
}); |
|
|
|
return new Result(); |
|
|
|
} else { |
|
|
|
return new Result().error(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -134,40 +145,46 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(PoliceDTO dto) { |
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
|
|
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId()+""); |
|
|
|
// 保存机构,及其他冗余字段。
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
entity |
|
|
|
); |
|
|
|
entity.setDeptName(parentAndAllDeptDTO.getGrid()); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
List<GroupListDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId()); |
|
|
|
if (groupList.size() == 0) { |
|
|
|
// 创民警的同时创建群
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void supplement(PoliceDTO[] ids) { |
|
|
|
|
|
|
|
for (PoliceDTO dto : ids) { |
|
|
|
// 社区ID下有多少个网格信息
|
|
|
|
List<DeptLevelAndLeaderDTO> deptList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); |
|
|
|
// 现有的群的网格信息
|
|
|
|
List<DeptLevelAndLeaderDTO> existedDeptList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); |
|
|
|
// 求差集,即为还没有创建过群的网格ID
|
|
|
|
List<DeptLevelAndLeaderDTO> reduce = deptList.stream().filter(item -> !existedDeptList.contains(item)).collect(toList()); |
|
|
|
|
|
|
|
// 补建群
|
|
|
|
reduce.forEach(dept -> { |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTOChild = getParentAndAllDeptDTO(dept.getDeptId() + ""); |
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
//保存用户居住地所在网格,及其他冗余字段。
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTOChild, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
groupEntity.setReferenceBusinessId(entity.getId()); |
|
|
|
groupEntity.setReferenceBusinessId(dto.getId()); |
|
|
|
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
|
groupEntity.setGroupName(entity.getDeptName() + "警民群"); |
|
|
|
groupEntity.setGroupName(dto.getDeptName() + "警民群"); |
|
|
|
groupEntity.setGroupCategory(GroupConstant.POLICE_GROUP_CATEGORY); |
|
|
|
groupEntity.setGrid(entity.getDeptName()); |
|
|
|
groupEntity.setGridId(entity.getDeptId()); |
|
|
|
groupEntity.setGrid(dept.getDeptName()); |
|
|
|
groupEntity.setGridId(dept.getDeptId()); |
|
|
|
groupDao.insert(groupEntity); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|