Browse Source

民警信息及警民群信息接口变更

hotfix/yujt_opt
zhangyuan 5 years ago
parent
commit
f1a0b945c1
  1. 6
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java
  2. 13
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/dao/PoliceDao.java
  3. 4
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java
  4. 141
      epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/impl/PoliceServiceImpl.java
  5. 31
      epdc-cloud-property/src/main/resources/mapper/police/PoliceDao.xml

6
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/controller/PoliceController.java

@ -77,10 +77,10 @@ public class PoliceController {
} }
@PutMapping("supplement") @PutMapping("supplement")
public Result supplement(@RequestBody PoliceDTO[] dtos) { public Result supplement(@RequestBody PoliceDTO dto) {
//效验数据 //效验数据
AssertUtils.isArrayEmpty(dtos, "dto"); ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
policeService.supplement(dtos); policeService.supplement(dto);
return new Result(); return new Result();
} }

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

@ -21,6 +21,7 @@ import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.dto.group.GroupDTO; import com.elink.esua.epdc.dto.group.GroupDTO;
import com.elink.esua.epdc.dto.police.PoliceDTO; import com.elink.esua.epdc.dto.police.PoliceDTO;
import com.elink.esua.epdc.dto.police.form.PoliceFormDTO; import com.elink.esua.epdc.dto.police.form.PoliceFormDTO;
import com.elink.esua.epdc.dto.police.result.PoliceInfoResultDTO;
import com.elink.esua.epdc.dto.police.result.PoliceResultDTO; import com.elink.esua.epdc.dto.police.result.PoliceResultDTO;
import com.elink.esua.epdc.modules.police.entity.PoliceEntity; import com.elink.esua.epdc.modules.police.entity.PoliceEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -48,7 +49,7 @@ public interface PoliceDao extends BaseDao<PoliceEntity> {
List<PoliceEntity> selectListOfPolice(Map<String, Object> params); List<PoliceEntity> selectListOfPolice(Map<String, Object> params);
/** /**
* 民警信息及警民群信息 * 警民群信息
* *
* @return com.elink.esua.epdc.dto.police.result.PoliceResultDTO * @return com.elink.esua.epdc.dto.police.result.PoliceResultDTO
* @params [dto] * @params [dto]
@ -57,6 +58,16 @@ public interface PoliceDao extends BaseDao<PoliceEntity> {
*/ */
PoliceResultDTO selectPoliceGroupInfo(PoliceFormDTO dto); PoliceResultDTO selectPoliceGroupInfo(PoliceFormDTO dto);
/**
* 民警信息
*
* @return com.elink.esua.epdc.dto.police.result.PoliceResultDTO
* @params [dto]
* @author zhangyuan
* @since 2020/5/21 14:54
*/
List<PoliceInfoResultDTO> selectPoliceInfo(PoliceEntity entity);
/** /**
* 查询需要修改组织机构信息事件 * 查询需要修改组织机构信息事件
* *

4
epdc-cloud-property/src/main/java/com/elink/esua/epdc/modules/police/service/PoliceService.java

@ -100,12 +100,12 @@ public interface PoliceService extends BaseService<PoliceEntity> {
/** /**
* 群补建 * 群补建
* *
* @param ids * @param dto
* @return void * @return void
* @author zhangyuan * @author zhangyuan
* @date 2020-05-21 * @date 2020-05-21
*/ */
void supplement(PoliceDTO[] ids); void supplement(PoliceDTO dto);
/** /**
* 民警信息及警民群信息 * 民警信息及警民群信息

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

@ -72,13 +72,13 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
private AdminFeignClient adminFeignClient; private AdminFeignClient adminFeignClient;
@Autowired @Autowired
private PoliceRedis policeRedis; private EventFeignClient eventFeignClient;
@Autowired @Autowired
private TopicService topicService; private PoliceRedis policeRedis;
@Autowired @Autowired
private EventFeignClient eventFeignClient; private TopicService topicService;
@Autowired @Autowired
private GroupService groupService; private GroupService groupService;
@ -116,7 +116,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) { private List<DeptLevelAndLeaderDTO> getChildDeptList(String tyepKey, Long deptId) {
Result<List<DeptLevelAndLeaderDTO>> adminResult = adminFeignClient.listChildDeptLevelById(tyepKey, deptId); Result<List<DeptLevelAndLeaderDTO>> adminResult = adminFeignClient.listChildDeptLevelById(tyepKey, deptId);
if (!adminResult.success()) { if (!adminResult.success()) {
@ -168,9 +167,8 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
@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();
if (hasPolice(communityId)) { Boolean hasPolice = hasPolice(communityId);
return new Result().error("该社区已有民警,无法重复添加");
}
// 社区第一次添加民警,直接保存 // 社区第一次添加民警,直接保存
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class); PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class);
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId)); ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId));
@ -181,31 +179,22 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
entity.setDeptName(parentAndAllDeptDTO.getGrid()); entity.setDeptName(parentAndAllDeptDTO.getGrid());
insert(entity); insert(entity);
// 先查询该社区下所有网格 // 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。
List<DeptLevelAndLeaderDTO> deptList = getChildDeptList(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, entity.getDeptId()); if (!hasPolice) {
if (CollUtil.isEmpty(deptList)) { // 先查询该社区下所有网格
return new Result(); 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( List<DeptLevelAndLeaderDTO> withoutGroupDeptList = getDeptListWithoutGroup(deptList, communityId);
deptForGroup -> { if (CollUtil.isNotEmpty(withoutGroupDeptList)) {
GroupEntity groupEntity = new GroupEntity(); withoutGroupDeptList.forEach(
DeptEntityUtils.loadDeptInfo( deptForGroup -> {
ConvertUtils.sourceToTarget(deptForGroup, DeptEntityUtils.DeptDto.class), createGroup(entity.getId(), deptForGroup.getDeptId(), deptForGroup.getDeptName());
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);
}
);
} }
return new Result(); return new Result();
} }
@ -222,52 +211,40 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
public void delete(String[] ids) { public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解) // 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids)); baseDao.deleteBatchIds(Arrays.asList(ids));
groupDao.deleteGroupByProjectIds(Arrays.asList(ids));
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void supplement(PoliceDTO[] ids) { public void supplement(PoliceDTO dto) {
for (PoliceDTO dto : ids) { // 社区ID下有多少个网格信息
// 社区ID下有多少个网格信息 List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData();
List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData(); List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 现有的群的网格信息
// 现有的群的网格信息 List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + "");
List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + ""); List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList()); // 求差集,即为还没有创建过群的网格ID
// 求差集,即为还没有创建过群的网格ID List<Long> reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList());
List<Long> reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList());
// 补建群
// 补建群 reduce.forEach(gridId -> {
reduce.forEach(gridId -> { createGroup(dto.getId(), dto.getDeptId(), dto.getDeptName());
// 通过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);
}
});
}
} }
@Override @Override
public PoliceResultDTO getPoliceAndGroup(PoliceFormDTO dto) { 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; 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);
}
} }

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

@ -50,10 +50,6 @@
</select> </select>
<select id="selectPoliceGroupInfo" resultType="com.elink.esua.epdc.dto.police.result.PoliceResultDTO"> <select id="selectPoliceGroupInfo" resultType="com.elink.esua.epdc.dto.police.result.PoliceResultDTO">
SELECT SELECT
ep.id AS POLICE_ID,
ep.POLICE_AVATAR,
ep.POLICE_NAME,
ep.POLICE_TEL,
eg.id AS GROUP_ID, eg.id AS GROUP_ID,
eg.GROUP_NAME, eg.GROUP_NAME,
eg.GROUP_AVATAR, eg.GROUP_AVATAR,
@ -88,21 +84,38 @@
) AS GROUP_MEMBER_FLAG, ) AS GROUP_MEMBER_FLAG,
eg.STATE AS GROUP_STATE eg.STATE AS GROUP_STATE
FROM FROM
epdc_police ep epdc_group eg
LEFT JOIN epdc_group eg ON ep.id = eg.REFERENCE_BUSINESS_ID
LEFT JOIN epdc_user_group eu ON eg.id = eu.GROUP_ID LEFT JOIN epdc_user_group eu ON eg.id = eu.GROUP_ID
AND eu.DEL_FLAG = '0' AND eu.DEL_FLAG = '0'
WHERE WHERE
ep.DEL_FLAG = '0' eg.DEL_FLAG = '0'
AND eg.DEL_FLAG = '0' AND eg.GROUP_CATEGORY = '3'
AND (
eg.STATE = '10'
OR eg.STATE = '15'
)
<if test="gridId != null and gridId != ''"> <if test="gridId != null and gridId != ''">
AND (eg.GRID_ID = #{gridId} AND (eg.GRID_ID = #{gridId}
OR find_in_set(#{gridId},eg.ALL_DEPT_IDS)) OR find_in_set(#{gridId},eg.ALL_DEPT_IDS))
</if> </if>
GROUP BY GROUP BY
ep.ID eg.ID
</select> </select>
<select id="selectPoliceInfo" resultType="com.elink.esua.epdc.dto.police.result.PoliceInfoResultDTO">
SELECT
ID AS POLICE_ID,
POLICE_AVATAR,
POLICE_NAME,
POLICE_TEL
FROM
epdc_police
WHERE
DEL_FLAG = '0'
<if test="parentDeptIds != null and parentDeptIds != ''">
AND ALL_DEPT_IDS = #{parentDeptIds}
</if>
</select>
<select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.police.PoliceDTO"> <select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.police.PoliceDTO">
SELECT SELECT
ID, ID,

Loading…
Cancel
Save