|
|
@ -20,12 +20,17 @@ package com.elink.esua.epdc.modules.police.service.impl; |
|
|
|
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.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.ParentAndAllDeptDTO; |
|
|
|
import com.elink.esua.epdc.dto.constant.GroupConstant; |
|
|
|
import com.elink.esua.epdc.dto.enums.GroupStateEnum; |
|
|
|
import com.elink.esua.epdc.dto.group.GroupListDTO; |
|
|
|
import com.elink.esua.epdc.modules.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.modules.group.dao.GroupDao; |
|
|
|
import com.elink.esua.epdc.modules.group.entity.GroupEntity; |
|
|
|
import com.elink.esua.epdc.modules.police.dao.PoliceDao; |
|
|
@ -52,6 +57,9 @@ import java.util.Map; |
|
|
|
@Service |
|
|
|
public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> implements PoliceService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PoliceRedis policeRedis; |
|
|
|
|
|
|
@ -92,15 +100,25 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(PoliceDTO dto) { |
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
|
// TODO 冗余字段。
|
|
|
|
|
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(dto.getDeptId() + ""); |
|
|
|
|
|
|
|
// 保存机构,及其他冗余字段。
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
entity |
|
|
|
); |
|
|
|
entity.setDeptName(parentAndAllDeptDTO.getGrid()); |
|
|
|
insert(entity); |
|
|
|
|
|
|
|
List<GroupListDTO> groupList = groupDao.selectListOfGroupByDeptId(entity.getDeptId()); |
|
|
|
if (groupList.size() == 0) { |
|
|
|
// 创民警的同时创建群
|
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
|
|
|
|
// TODO 冗余字段。
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
groupEntity.setReferenceBusinessId(entity.getId()); |
|
|
|
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
@ -116,14 +134,25 @@ 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) { |
|
|
|
// 创民警的同时创建群
|
|
|
|
GroupEntity groupEntity = new GroupEntity(); |
|
|
|
|
|
|
|
// TODO 冗余字段。
|
|
|
|
//保存用户居住地所在网格,及其他冗余字段。
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
groupEntity |
|
|
|
); |
|
|
|
groupEntity.setReferenceBusinessId(entity.getId()); |
|
|
|
groupEntity.setState(GroupStateEnum.GROUP_STATE_EXAMINATION_PASSED.getValue()); |
|
|
|
groupEntity.setGroupAvatar(GroupConstant.PROPERTY_GROUP_AVATAR); |
|
|
@ -142,4 +171,22 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据网格ID获取冗余的组织机构信息 |
|
|
|
* |
|
|
|
* @param |
|
|
|
* @return com.elink.esua.epdc.dto.ParentAndAllDeptDTO |
|
|
|
* @author rongchao |
|
|
|
* @since 2019-12-19 |
|
|
|
*/ |
|
|
|
private ParentAndAllDeptDTO getParentAndAllDeptDTO(String gridId) { |
|
|
|
// 获取组织结构冗余信息
|
|
|
|
Result<ParentAndAllDeptDTO> parentAndAllDeptDTOResult = adminFeignClient.getParentAndAllDept(gridId); |
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = parentAndAllDeptDTOResult.getData(); |
|
|
|
|
|
|
|
if (!parentAndAllDeptDTOResult.success()) { |
|
|
|
throw new RenException(parentAndAllDeptDTOResult.getMsg()); |
|
|
|
} |
|
|
|
return parentAndAllDeptDTO; |
|
|
|
} |
|
|
|
} |