|
@ -17,7 +17,6 @@ |
|
|
|
|
|
|
|
|
package com.elink.esua.epdc.modules.police.service.impl; |
|
|
package com.elink.esua.epdc.modules.police.service.impl; |
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|
@ -116,14 +115,6 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
return ConvertUtils.sourceToTarget(entity, PoliceDTO.class); |
|
|
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()) { |
|
|
|
|
|
throw new RenException(adminResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
return adminResult.getData(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 社区是否已有民警 |
|
|
* 社区是否已有民警 |
|
|
* |
|
|
* |
|
@ -132,69 +123,44 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
* @author work@yujt.net.cn |
|
|
* @author work@yujt.net.cn |
|
|
* @date 2020/5/22 16:56 |
|
|
* @date 2020/5/22 16:56 |
|
|
*/ |
|
|
*/ |
|
|
private boolean hasPolice(Long deptId) { |
|
|
private boolean hasGroup(Long deptId) { |
|
|
QueryWrapper<PoliceEntity> wrapper = new QueryWrapper<>(); |
|
|
QueryWrapper<GroupEntity> wrapper = new QueryWrapper<>(); |
|
|
wrapper.eq("DEPT_ID", deptId); |
|
|
wrapper.eq("DEPT_ID", deptId); |
|
|
return baseDao.selectCount(wrapper) > NumConstant.ZERO; |
|
|
wrapper.eq("CATEGORY_CODE", GroupConstant.POLICE_GROUP_CATEGORY_CODE); |
|
|
} |
|
|
List<Integer> list = new ArrayList<>(); |
|
|
|
|
|
// 10正常,15禁言
|
|
|
/** |
|
|
list.add(NumConstant.TEN); |
|
|
* 查询社区下未创建警民群的网格 |
|
|
list.add(NumConstant.FIFTEEN); |
|
|
* |
|
|
wrapper.in("STATE", list); |
|
|
* @param deptList 社区下所有的网格 |
|
|
return groupDao.selectCount(wrapper) > NumConstant.ZERO; |
|
|
* @param communityId 社区id |
|
|
|
|
|
* @return java.util.List<com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO> |
|
|
|
|
|
* @author work@yujt.net.cn |
|
|
|
|
|
* @date 2020/5/22 16:55 |
|
|
|
|
|
*/ |
|
|
|
|
|
private List<DeptLevelAndLeaderDTO> getDeptListWithoutGroup(List<DeptLevelAndLeaderDTO> deptList, Long communityId) { |
|
|
|
|
|
// 查询社区下已创建群组的网格
|
|
|
|
|
|
List<DeptLevelAndLeaderDTO> hasGroupList = groupDao.selectListOfGroupByDeptId(String.valueOf(communityId)); |
|
|
|
|
|
if (CollUtil.isNotEmpty(hasGroupList)) { |
|
|
|
|
|
for (int i = deptList.size() - 1; i >= 0; i--) { |
|
|
|
|
|
for (DeptLevelAndLeaderDTO dto : hasGroupList) { |
|
|
|
|
|
if (deptList.get(i).getDeptId().equals(dto.getDeptId())) { |
|
|
|
|
|
deptList.remove(i); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return deptList; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public Result save(PoliceDTO dto) { |
|
|
public Result save(PoliceDTO dto) { |
|
|
Long communityId = dto.getDeptId(); |
|
|
Long communityId = dto.getDeptId(); |
|
|
boolean hasPolice = hasPolice(communityId); |
|
|
|
|
|
|
|
|
DeptLevelAndLeaderDTO deptLevelAndLeaderDTO = getDeptlevelById(dto.getDeptId()); |
|
|
|
|
|
|
|
|
|
|
|
if (!GroupConstant.POLICE_GROUP_TYPE.equals(deptLevelAndLeaderDTO.getTypeKey())) { |
|
|
|
|
|
throw new RenException("请选择社区机构"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean hasPolice = hasGroup(communityId); |
|
|
|
|
|
|
|
|
// 社区第一次添加民警,直接保存
|
|
|
// 社区第一次添加民警,直接保存
|
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId)); |
|
|
|
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
ConvertUtils.sourceToTarget(deptLevelAndLeaderDTO, DeptEntityUtils.DeptDto.class), |
|
|
entity |
|
|
entity |
|
|
); |
|
|
); |
|
|
entity.setDeptName(parentAndAllDeptDTO.getGrid()); |
|
|
entity.setDeptName(deptLevelAndLeaderDTO.getDeptName()); |
|
|
insert(entity); |
|
|
insert(entity); |
|
|
|
|
|
|
|
|
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。
|
|
|
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。7.3改为初始化社区
|
|
|
if (!hasPolice) { |
|
|
if (!hasPolice) { |
|
|
// 先查询该社区下所有网格
|
|
|
// 警民群改为和社区ID绑定,首次创建民警时只需要创建一个群
|
|
|
List<DeptLevelAndLeaderDTO> deptList = getChildDeptList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()); |
|
|
createGroup(entity.getId(), deptLevelAndLeaderDTO.getDeptId(), deptLevelAndLeaderDTO.getDeptName()); |
|
|
if (CollUtil.isEmpty(deptList)) { |
|
|
|
|
|
return new Result(); |
|
|
|
|
|
} |
|
|
|
|
|
// 未创建社区的网格
|
|
|
|
|
|
List<DeptLevelAndLeaderDTO> withoutGroupDeptList = getDeptListWithoutGroup(deptList, communityId); |
|
|
|
|
|
if (CollUtil.isNotEmpty(withoutGroupDeptList)) { |
|
|
|
|
|
withoutGroupDeptList.forEach( |
|
|
|
|
|
deptForGroup -> { |
|
|
|
|
|
createGroup(entity.getId(), deptForGroup.getDeptId(), deptForGroup.getDeptName()); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
return new Result(); |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
@ -238,16 +204,14 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PoliceResultDTO getPoliceAndGroup(PoliceFormDTO dto) { |
|
|
public PoliceResultDTO getPoliceAndGroup(PoliceFormDTO dto) { |
|
|
|
|
|
// 根据用户网格,获取用户所在社区
|
|
|
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(dto.getGridId())); |
|
|
|
|
|
dto.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds()); |
|
|
|
|
|
|
|
|
PoliceResultDTO policeResultDTO = baseDao.selectPoliceGroupInfo(dto); |
|
|
PoliceResultDTO policeResultDTO = baseDao.selectPoliceGroupInfo(dto); |
|
|
if (policeResultDTO != null) { |
|
|
if (policeResultDTO != null) { |
|
|
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); |
|
|
// 查询民警使用的gridID是最末级,而警民群保存的是其父级commID,需要用grid的parentIDs,来匹配警民群的AllIDs。
|
|
|
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(dto.getGridId())); |
|
|
policeResultDTO.setPoliceList(baseDao.selectPoliceInfo(dto)); |
|
|
DeptEntityUtils.loadDeptInfo( |
|
|
|
|
|
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class), |
|
|
|
|
|
entity |
|
|
|
|
|
); |
|
|
|
|
|
// 查询民警使用的gridID是最末级,而警民群保存的是其父级gridID,需要用最末级的parentID,来匹配警民群的AllID。
|
|
|
|
|
|
policeResultDTO.setPoliceList(baseDao.selectPoliceInfo(entity)); |
|
|
|
|
|
} |
|
|
} |
|
|
return policeResultDTO; |
|
|
return policeResultDTO; |
|
|
} |
|
|
} |
|
@ -392,4 +356,23 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity> |
|
|
groupEntity.setDeptId(gridId); |
|
|
groupEntity.setDeptId(gridId); |
|
|
groupDao.insert(groupEntity); |
|
|
groupDao.insert(groupEntity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据网格ID获取冗余的组织机构信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param |
|
|
|
|
|
* @return com.elink.esua.epdc.dto.ParentAndAllDeptDTO |
|
|
|
|
|
* @author rongchao |
|
|
|
|
|
* @since 2019-12-19 |
|
|
|
|
|
*/ |
|
|
|
|
|
private DeptLevelAndLeaderDTO getDeptlevelById(Long gridId) { |
|
|
|
|
|
// 获取组织结构冗余信息
|
|
|
|
|
|
Result<DeptLevelAndLeaderDTO> parentAndAllDeptDTOResult = adminFeignClient.getDeptlevelById(gridId); |
|
|
|
|
|
DeptLevelAndLeaderDTO parentAndAllDeptDTO = parentAndAllDeptDTOResult.getData(); |
|
|
|
|
|
|
|
|
|
|
|
if (!parentAndAllDeptDTOResult.success()) { |
|
|
|
|
|
throw new RenException(parentAndAllDeptDTOResult.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
return parentAndAllDeptDTO; |
|
|
|
|
|
} |
|
|
} |
|
|
} |