Browse Source

民警群修改为绑定社区ID

hotfix/yujt_opt
zhangyuan 5 years ago
parent
commit
99b7911b8c
  1. 2
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/dao/PoliceDao.java
  2. 111
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java
  3. 6
      epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml
  4. 9
      epdc-cloud-property/src/main/resources/mapper/police/PoliceDao.xml

2
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/dao/PoliceDao.java

@ -66,7 +66,7 @@ public interface PoliceDao extends BaseDao<PoliceEntity> {
* @author zhangyuan
* @since 2020/5/21 14:54
*/
List<PoliceInfoResultDTO> selectPoliceInfo(PoliceEntity entity);
List<PoliceInfoResultDTO> selectPoliceInfo(PoliceFormDTO dto);
/**
* 查询需要修改组织机构信息事件

111
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java

@ -17,7 +17,6 @@
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.metadata.IPage;
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);
}
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
* @date 2020/5/22 16:56
*/
private boolean hasPolice(Long deptId) {
QueryWrapper<PoliceEntity> wrapper = new QueryWrapper<>();
private boolean hasGroup(Long deptId) {
QueryWrapper<GroupEntity> wrapper = new QueryWrapper<>();
wrapper.eq("DEPT_ID", deptId);
return baseDao.selectCount(wrapper) > NumConstant.ZERO;
}
/**
* 查询社区下未创建警民群的网格
*
* @param deptList 社区下所有的网格
* @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;
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);
return groupDao.selectCount(wrapper) > NumConstant.ZERO;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result save(PoliceDTO dto) {
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);
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId));
DeptEntityUtils.loadDeptInfo(
ConvertUtils.sourceToTarget(parentAndAllDeptDTO, DeptEntityUtils.DeptDto.class),
ConvertUtils.sourceToTarget(deptLevelAndLeaderDTO, DeptEntityUtils.DeptDto.class),
entity
);
entity.setDeptName(parentAndAllDeptDTO.getGrid());
entity.setDeptName(deptLevelAndLeaderDTO.getDeptName());
insert(entity);
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。7.3改为初始化社区
if (!hasPolice) {
// 先查询该社区下所有网格
List<DeptLevelAndLeaderDTO> deptList = getChildDeptList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId());
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());
}
);
}
// 警民群改为和社区ID绑定,首次创建民警时只需要创建一个群
createGroup(entity.getId(), deptLevelAndLeaderDTO.getDeptId(), deptLevelAndLeaderDTO.getDeptName());
}
return new Result();
}
@ -238,16 +204,14 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
@Override
public PoliceResultDTO getPoliceAndGroup(PoliceFormDTO dto) {
// 根据用户网格,获取用户所在社区
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(dto.getGridId()));
dto.setParentDeptIds(parentAndAllDeptDTO.getParentDeptIds());
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
);
// 查询民警使用的gridID是最末级,而警民群保存的是其父级gridID,需要用最末级的parentID,来匹配警民群的AllID。
policeResultDTO.setPoliceList(baseDao.selectPoliceInfo(entity));
// 查询民警使用的gridID是最末级,而警民群保存的是其父级commID,需要用grid的parentIDs,来匹配警民群的AllIDs。
policeResultDTO.setPoliceList(baseDao.selectPoliceInfo(dto));
}
return policeResultDTO;
}
@ -392,4 +356,23 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
groupEntity.setDeptId(gridId);
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;
}
}

6
epdc-cloud-property/src/main/resources/mapper/group/GroupDao.xml

@ -59,7 +59,7 @@
gp.DEL_FLAG = '0'
AND gp.SECTION_CODE = 'theme_group'
AND gp.CATEGORY_CODE = 'police_group'
AND gp.TYPE_KEY = 'grid_party'
AND gp.TYPE_KEY = 'community_party'
<if test="state != null and state != ''">
AND gp.STATE = #{state}
</if>
@ -309,7 +309,7 @@ ORDER BY
DEL_FLAG = '0'
AND SECTION_CODE = 'theme_group'
AND CATEGORY_CODE = 'police_group'
AND TYPE_KEY = 'grid_party'
AND TYPE_KEY = 'community_party'
AND STATE IN ( 10, 15, 20 )
AND DEPT_ID = #{deptId}
</select>
@ -324,7 +324,7 @@ ORDER BY
DEL_FLAG = '0'
AND SECTION_CODE = 'theme_group'
AND CATEGORY_CODE = 'police_group'
AND TYPE_KEY = 'grid_party'
AND TYPE_KEY = 'community_party'
AND STATE IN ( 10, 15 )
AND PARENT_DEPT_IDS LIKE CONCAT( '%', #{deptId} )
</select>

9
epdc-cloud-property/src/main/resources/mapper/police/PoliceDao.xml

@ -64,12 +64,9 @@
eg.DEL_FLAG = '0'
AND eg.SECTION_CODE = 'theme_group'
AND eg.CATEGORY_CODE = 'police_group'
AND eg.TYPE_KEY = 'grid_party'
AND eg.TYPE_KEY = 'community_party'
AND ( eg.STATE = '10' OR eg.STATE = '15' )
<if test="gridId != null and gridId != ''">
AND (eg.DEPT_ID = #{gridId}
OR find_in_set(#{gridId},eg.ALL_DEPT_IDS))
</if>
AND eg.ALL_DEPT_IDS = #{parentDeptIds}
GROUP BY eg.ID
</select>
@ -115,6 +112,6 @@
FIND_IN_SET( #{deptId}, ALL_DEPT_IDS )
AND SECTION_CODE = 'theme_group'
AND CATEGORY_CODE = 'police_group'
AND TYPE_KEY = 'grid_party'
AND TYPE_KEY = 'community_party'
</select>
</mapper>
Loading…
Cancel
Save