| | |
| | | import com.panzhihua.common.model.dtos.grid.*; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComActVO; |
| | | import com.panzhihua.common.model.vos.grid.EventDetailsVO; |
| | | import com.panzhihua.common.model.vos.grid.EventResourceVO; |
| | | import com.panzhihua.common.model.vos.grid.EventTransferRecordVO; |
| | | import com.panzhihua.common.model.vos.grid.EventVO; |
| | | import com.panzhihua.common.model.vos.grid.*; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.utlis.LngLatUtils; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_grid.dao.*; |
| | | import com.panzhihua.service_grid.model.dos.*; |
| | | import com.panzhihua.service_grid.service.EventGridDataService; |
| | | import com.panzhihua.service_grid.service.EventResourceService; |
| | | import com.panzhihua.service_grid.service.EventService; |
| | | import com.panzhihua.service_grid.service.EventTransferRecordService; |
| | |
| | | private EventGridDataMapper eventGridDataMapper; |
| | | @Resource |
| | | private EventGridMemberRelationMapper eventGridMemberRelationMapper; |
| | | @Resource |
| | | private EventGridDataService eventGridDataService; |
| | | |
| | | /** |
| | | * 分页查找事件 |
| | | * |
| | | * @param pageEventDTO |
| | | * @return 维护结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 删除事件 |
| | | * |
| | | * @param commonEventDeleteDTO |
| | | * @return 平台用户信息 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询事件详细信息 |
| | | * |
| | | * @param id 事件 id |
| | | * @return 查找结果 |
| | | */ |
| | |
| | | eventDetailsVO.setAudios(audioList); |
| | | eventDetailsVO.setPics(picList); |
| | | eventDetailsVO.setVideos(videoList); |
| | | |
| | | |
| | | |
| | | //查询事件流转记录 |
| | |
| | | |
| | | /** |
| | | * 生成服务单号 |
| | | * |
| | | * @param eventType 事件类型,宣传事件默认为20 |
| | | * @return |
| | | */ |
| | |
| | | eventDO.setGridMemberId(publicityEventAddDTO.getUserId()); |
| | | eventDO.setEventCategory(2l);//宣传事件 |
| | | eventDO.setEventStatus(2);//事件状态 2发布 |
| | | eventDO.setEventType(8); |
| | | if(publicityEventAddDTO.getGridMemberId()!=null) { |
| | | eventDO.setGridMemberId(publicityEventAddDTO.getGridMemberId()); |
| | | }else{ |
| | | eventDO.setGridMemberId(publicityEventAddDTO.getUserId()); |
| | | } |
| | | eventDO.setGridMemberName(publicityEventAddDTO.getUserName()); |
| | | eventDO.setGridMemberTelephone(publicityEventAddDTO.getPhone()); |
| | | eventDO.setCreateBy(publicityEventAddDTO.getUserId()); |
| | |
| | | eventDO.setGridMemberName(publicityEventEditDTO.getUserName()); |
| | | eventDO.setGridMemberTelephone(publicityEventEditDTO.getPhone()); |
| | | eventDO.setEventDealStatus(5);//草稿状态 |
| | | eventDO.setEventType(8); |
| | | if (eventMapper.insert(eventDO) > 0) { |
| | | //添加音频 |
| | | if (StringUtils.isNotEmpty(publicityEventEditDTO.getAudio())) { |
| | |
| | | |
| | | /** |
| | | * 添加发布事件流转记录 |
| | | * |
| | | * @param eventId 事件ID |
| | | * @param userId 操作用户ID |
| | | * @param userName 操作用户姓名 |
| | |
| | | |
| | | /** |
| | | * 查询最后的流转记录,并添加事件流转记录 |
| | | * |
| | | * @param eventId 事件ID |
| | | * @param toId 流转到 ID |
| | | * @param toName 流转到 名称 |
| | |
| | | |
| | | /** |
| | | * 根据子状态 查询用户事件处理状态 |
| | | * |
| | | * @param eventId 事件ID |
| | | */ |
| | | private EventDO updateEventDealStatus(Long eventId){ |
| | |
| | | |
| | | /** |
| | | * 根据子状态 查询用户事件处理状态 |
| | | * |
| | | * @param eventDO 事件 |
| | | */ |
| | | private Integer getEventDealStatus(EventDO eventDO){ |
| | |
| | | |
| | | /** |
| | | * 后台管理-统计模块 |
| | | * |
| | | * @param communityId 社区id |
| | | * @return 统计信息 |
| | | */ |
| | |
| | | public R eventStatistics(Long communityId){ |
| | | return R.ok(this.baseMapper.eventStatistics(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 后台管理-网格员统计 |
| | | * |
| | | * @param statisticsAdminDTO 请求参数 |
| | | * @return 网格员统计信息 |
| | | */ |
| | |
| | | public R gridMemberStatistics(MemberStatisticsAdminDTO statisticsAdminDTO){ |
| | | return R.ok(eventGridMemberRelationMapper.gridMemberStatistics(new Page(statisticsAdminDTO.getPageNum(),statisticsAdminDTO.getPageSize()),statisticsAdminDTO)); |
| | | } |
| | | |
| | | @Override |
| | | public R getNearByGrid(PageEventGridNearbyDTO pageEventGridNearbyDTO) { |
| | | Page page = new Page(pageEventGridNearbyDTO.getPageNum(), pageEventGridNearbyDTO.getPageSize()); |
| | | String latLng = pageEventGridNearbyDTO.getHappentLatLng(); |
| | | if(!latLng.matches("^[\\-\\+]?((0|([1-8]\\d?))(\\.\\d{1,10})?|90(\\.0{1,10})?),[\\-\\+]?(0(\\.\\d{1,10})?|([1-9](\\d)?)(\\.\\d{1,10})?|1[0-7]\\d{1}(\\.\\d{1,10})?|180\\.0{1,10})$")){ |
| | | return R.fail("经纬度参数错误"); |
| | | } |
| | | String latLngArr[] = latLng.split(","); |
| | | try { |
| | | Double lat = Double.valueOf(latLngArr[1]); |
| | | Double lng = Double.valueOf(latLngArr[0]); |
| | | List<EventGridDataAreaVO> gridList = |
| | | eventGridDataMapper.selectGridWithArea(page, pageEventGridNearbyDTO); |
| | | if (gridList != null && gridList.size() > 0) { |
| | | List<EventGridDataVO> rtEventGridList = new ArrayList<>(); |
| | | for (EventGridDataAreaVO eventGridDataDO : gridList) { |
| | | String data = eventGridDataDO.getData(); |
| | | if(data!=null) { |
| | | List<LatLngVO> latLngList = LngLatUtils.getLatLngFromText(data); |
| | | boolean inGrid = LngLatUtils.isInPolygon(latLngList, lng, lat); |
| | | if (inGrid) { |
| | | EventGridDataVO eventGridDataVO = new EventGridDataVO(); |
| | | BeanUtils.copyProperties(eventGridDataDO, eventGridDataVO); |
| | | rtEventGridList.add(eventGridDataVO); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(rtEventGridList); |
| | | } else { |
| | | return R.ok("未找到社区"); |
| | | } |
| | | }catch (Exception e){ |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteEventBatch(EventDeleteDTO eventDeleteDTO) { |
| | | List<Long> eventIds = eventDeleteDTO.getId(); |
| | | if (eventIds != null && eventIds.size() > 0) { |
| | | R rt = null; |
| | | Long userId = eventDeleteDTO.getUserId(); |
| | | for (Long id : eventIds) { |
| | | EventDO eventDO = eventMapper.selectById(id); |
| | | if (eventDO == null) { |
| | | throw new ServiceException("id为" + id + "的事件不存在"); |
| | | } |
| | | if (eventDO.getEventStatus() != null && |
| | | (eventDO.getEventStatus().intValue() == 1 || eventDO.getEventStatus().intValue() == 4)) {//草稿 或者 已撤销 的事件可以删除 |
| | | eventDO.setEventStatus(3);//逻辑删除 |
| | | eventDO.setUpdateBy(userId); |
| | | int updated = this.getBaseMapper().updateById(eventDO); |
| | | if (updated != 1) { |
| | | throw new ServiceException("删除事件失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail("参数错误"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R batchRepublishEvent(CommonEventBatchRepublishDTO commonEventBatchRepublishDTO) { |
| | | List<Long> ids = commonEventBatchRepublishDTO.getId(); |
| | | if (ids != null && ids.size() > 0) { |
| | | Long userId = commonEventBatchRepublishDTO.getUserId(); |
| | | String userName = commonEventBatchRepublishDTO.getUserName(); |
| | | for (Long id : ids) { |
| | | EventDO eventDO = this.getBaseMapper().selectById(id); |
| | | if (eventDO == null) { |
| | | throw new ServiceException("id为" + id + "的事件不存在"); |
| | | } |
| | | boolean canRepublishByUser = eventDO.getEventStatus() != null && |
| | | eventDO.getEventStatus() == 4 || eventDO.getEventStatus() == 1; |
| | | if (!canRepublishByUser) { |
| | | throw new ServiceException("当前不是撤销/草稿状态"); |
| | | } |
| | | eventDO.setEventStatus(2);//2 发布 |
| | | eventDO.setEventProcessStatus(1); //待解决 |
| | | eventDO.setProcessType(1); //网格员处理 |
| | | eventDO.setUpdateBy(userId); |
| | | int updated = this.getBaseMapper().updateById(eventDO); |
| | | if (updated != 1) { |
| | | throw new ServiceException("更新事件状态失败"); |
| | | } |
| | | addTransferRecord(eventDO.getId(), userId, userName, 1, |
| | | "重新发布已撤销事件", userId, userName, 8); |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail("参数错误"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R batchMarkEventInvalid(EventBatchRevokeDTO eventBatchRevokeDTO) { |
| | | List<Long> ids = eventBatchRevokeDTO.getId(); |
| | | if (ids != null && ids.size() > 0) { |
| | | Long userId = eventBatchRevokeDTO.getUserId(); |
| | | String userName = eventBatchRevokeDTO.getUserName(); |
| | | Long communityId = eventBatchRevokeDTO.getCommunityId(); |
| | | String communityName = eventBatchRevokeDTO.getCommunityName(); |
| | | for (Long id : ids) { |
| | | EventDO eventDO = this.getBaseMapper().selectById(id); |
| | | if (eventDO == null) { |
| | | throw new ServiceException("id为" + id + "的事件不存在"); |
| | | } |
| | | if (eventDO.getEventCategory() != null) { |
| | | if (eventDO.getEventCategory() == 1) { |
| | | boolean canRevoke = eventDO.getEventDealStatus() == 3; //上报状态 |
| | | if (!canRevoke) { |
| | | throw new ServiceException("当前事件不是上报状态,不允许标为无效"); |
| | | } |
| | | } else if (eventDO.getEventCategory() == 2) { |
| | | boolean canRevoke = eventDO.getEventDealStatus() == 8; //发布状态 |
| | | if (!canRevoke) { |
| | | throw new ServiceException("当前事件不是发布状态,不允许标为无效"); |
| | | } |
| | | } else { |
| | | throw new ServiceException("事件分类错误"); |
| | | } |
| | | } else { |
| | | throw new ServiceException("事件所属错误"); |
| | | } |
| | | eventDO.setInvalid(false); |
| | | //标为无效后, 交给网格员处理 |
| | | eventDO.setUpdateBy(userId); |
| | | eventDO.setEventStatus(4);//4、撤销 |
| | | eventDO.setProcessType(1);//网格员处理 |
| | | eventDO.setCommunityProcess(0);//非 社区处理 |
| | | int updated = this.getBaseMapper().updateById(eventDO); |
| | | if (updated == 1) { |
| | | addTransferRecord(eventDO.getId(), userId, userName, 1, "标为无效", communityId, communityName, 4); |
| | | } else { |
| | | throw new ServiceException("事件流转信息添加错误"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.fail("参数错误"); |
| | | } |
| | | } |
| | | } |