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")
public Result supplement(@RequestBody PoliceDTO[] dtos) {
public Result supplement(@RequestBody PoliceDTO dto) {
//效验数据
AssertUtils.isArrayEmpty(dtos, "dto");
policeService.supplement(dtos);
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
policeService.supplement(dto);
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.police.PoliceDTO;
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.modules.police.entity.PoliceEntity;
import org.apache.ibatis.annotations.Mapper;
@ -48,7 +49,7 @@ public interface PoliceDao extends BaseDao<PoliceEntity> {
List<PoliceEntity> selectListOfPolice(Map<String, Object> params);
/**
* 民警信息及警民群信息
* 警民群信息
*
* @return com.elink.esua.epdc.dto.police.result.PoliceResultDTO
* @params [dto]
@ -57,6 +58,16 @@ public interface PoliceDao extends BaseDao<PoliceEntity> {
*/
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
* @author zhangyuan
* @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;
@Autowired
private PoliceRedis policeRedis;
private EventFeignClient eventFeignClient;
@Autowired
private TopicService topicService;
private PoliceRedis policeRedis;
@Autowired
private EventFeignClient eventFeignClient;
private TopicService topicService;
@Autowired
private GroupService groupService;
@ -116,7 +116,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()) {
@ -168,9 +167,8 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
@Transactional(rollbackFor = Exception.class)
public Result save(PoliceDTO dto) {
Long communityId = dto.getDeptId();
if (hasPolice(communityId)) {
return new Result().error("该社区已有民警,无法重复添加");
}
Boolean hasPolice = hasPolice(communityId);
// 社区第一次添加民警,直接保存
PoliceEntity entity = ConvertUtils.sourceToTarget(dto, PoliceEntity.class);
ParentAndAllDeptDTO parentAndAllDeptDTO = getParentAndAllDeptDTO(String.valueOf(communityId));
@ -181,31 +179,22 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
entity.setDeptName(parentAndAllDeptDTO.getGrid());
insert(entity);
// 先查询该社区下所有网格
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 -> {
GroupEntity groupEntity = new GroupEntity();
DeptEntityUtils.loadDeptInfo(
ConvertUtils.sourceToTarget(deptForGroup, DeptEntityUtils.DeptDto.class),
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);
}
);
// 如果社区之前没有民警,就初始化所有的网格,增加警民群,有的话不再补充,等待补充操作。
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());
}
);
}
}
return new Result();
}
@ -222,52 +211,40 @@ public class PoliceServiceImpl extends BaseServiceImpl<PoliceDao, PoliceEntity>
public void delete(String[] ids) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
groupDao.deleteGroupByProjectIds(Arrays.asList(ids));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void supplement(PoliceDTO[] ids) {
for (PoliceDTO dto : ids) {
// 社区ID下有多少个网格信息
List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData();
List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 现有的群的网格信息
List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + "");
List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 求差集,即为还没有创建过群的网格ID
List<Long> reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList());
// 补建群
reduce.forEach(gridId -> {
// 通过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);
}
});
}
public void supplement(PoliceDTO dto) {
// 社区ID下有多少个网格信息
List<DeptLevelAndLeaderDTO> gridList = adminFeignClient.listChildDeptLevelById(OrganizationTypeConstant.ORG_TYPE_GRID_PARTY, dto.getDeptId()).getData();
List<Long> gridIdList = gridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 现有的群的网格信息
List<DeptLevelAndLeaderDTO> existedGridList = groupDao.selectListOfGroupByDeptId(dto.getDeptId() + "");
List<Long> existedGridIdList = existedGridList.stream().map(DeptLevelAndLeaderDTO::getDeptId).collect(toList());
// 求差集,即为还没有创建过群的网格ID
List<Long> reduce = gridIdList.stream().filter(item -> !existedGridIdList.contains(item)).collect(toList());
// 补建群
reduce.forEach(gridId -> {
createGroup(dto.getId(), dto.getDeptId(), dto.getDeptName());
});
}
@Override
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;
}
/**
* 生成群
*
* @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 id="selectPoliceGroupInfo" resultType="com.elink.esua.epdc.dto.police.result.PoliceResultDTO">
SELECT
ep.id AS POLICE_ID,
ep.POLICE_AVATAR,
ep.POLICE_NAME,
ep.POLICE_TEL,
eg.id AS GROUP_ID,
eg.GROUP_NAME,
eg.GROUP_AVATAR,
@ -88,21 +84,38 @@
) AS GROUP_MEMBER_FLAG,
eg.STATE AS GROUP_STATE
FROM
epdc_police ep
LEFT JOIN epdc_group eg ON ep.id = eg.REFERENCE_BUSINESS_ID
epdc_group eg
LEFT JOIN epdc_user_group eu ON eg.id = eu.GROUP_ID
AND eu.DEL_FLAG = '0'
WHERE
ep.DEL_FLAG = '0'
AND eg.DEL_FLAG = '0'
eg.DEL_FLAG = '0'
AND eg.GROUP_CATEGORY = '3'
AND (
eg.STATE = '10'
OR eg.STATE = '15'
)
<if test="gridId != null and gridId != ''">
AND (eg.GRID_ID = #{gridId}
OR find_in_set(#{gridId},eg.ALL_DEPT_IDS))
</if>
GROUP BY
ep.ID
eg.ID
</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,

Loading…
Cancel
Save