| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.panzhihua.common.model.dtos.grid.*; |
| | | import com.google.common.base.Joiner; |
| | | import com.panzhihua.common.model.dtos.grid.EventGridDataAddDTO; |
| | | import com.panzhihua.common.model.dtos.grid.EventGridDataDeleteDTO; |
| | | import com.panzhihua.common.model.dtos.grid.EventGridDataEditDTO; |
| | | import com.panzhihua.common.model.dtos.grid.PageEventGridDataDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.grid.EventGridDataDetailsVO; |
| | | import com.panzhihua.common.model.vos.grid.EventGridDataVO; |
| | | import com.panzhihua.common.model.vos.grid.*; |
| | | 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.EventGridMemberRelationService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | |
| | | @Resource |
| | | private EventGridDataMapper eventGridDataMapper; |
| | | @Resource |
| | | private EventMapper eventMapper; |
| | | @Resource |
| | | private EventGridMemberRelationService eventGridMemberRelationService; |
| | | /** |
| | | * 新增区县/街道/社区/网格员网格数据管理 |
| | | * @param eventGridDataAddDTO |
| | |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 分页查找区县/街道/社区/网格员网格数据管理 |
| | | * @param pageEventGridDataDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R<IPage<EventGridDataVO>> query(PageEventGridDataDTO pageEventGridDataDTO){ |
| | | Page page = new Page(1,10); |
| | | if(pageEventGridDataDTO.getPageNum()!=null) { |
| | | page.setCurrent(pageEventGridDataDTO.getPageNum()); |
| | | } |
| | | if(pageEventGridDataDTO.getPageSize()!=null) { |
| | | page.setSize(pageEventGridDataDTO.getPageSize()); |
| | | } |
| | | return R.ok(eventGridDataMapper.findByPage(page, pageEventGridDataDTO)); |
| | | } |
| | | |
| | | /** |
| | |
| | | return R.ok(eventGridDataMapper.selectUserGrid(page, pageEventGridDataDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 地图模块-根据网格id查询网格详细信息 |
| | | * @param gridId 网格id |
| | | * @return 网格详细信息 |
| | | */ |
| | | @Override |
| | | public R getMapGridDetail(Long gridId){ |
| | | ComMapGridDetailVO gridDetailVO = new ComMapGridDetailVO(); |
| | | //查询网格信息 |
| | | EventGridDataDO eventGridDataDO = this.baseMapper.selectById(gridId); |
| | | if(eventGridDataDO == null){ |
| | | return R.fail("未查询到网格信息"); |
| | | } |
| | | BeanUtils.copyProperties(eventGridDataDO,gridDetailVO); |
| | | //查询网格待办事件 |
| | | List<ComMapGridEventVO> gridEventList = eventMapper.getEventByGridId(gridId); |
| | | if(!gridEventList.isEmpty()){ |
| | | gridDetailVO.setGridEventList(gridEventList); |
| | | } |
| | | return R.ok(gridDetailVO); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridTodoData(EventGridTodoDataDTO eventGridTodoDataDTO) { |
| | | List<UserEventGridDataVO> userEventGridDataVO = eventGridDataMapper.getGridTodoData(eventGridTodoDataDTO); |
| | | return R.ok(userEventGridDataVO); |
| | | } |
| | | |
| | | /** |
| | | * 分页查询网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 网格列表 |
| | | */ |
| | | @Override |
| | | public R getGridMemberList(PageEventGridDataAdminDTO eventGridDataDTO){ |
| | | IPage<EventGridAdminVO> gridAdminVOIPage = this.baseMapper.findByPage(new Page(eventGridDataDTO.getPageNum(),eventGridDataDTO.getPageSize()),eventGridDataDTO); |
| | | if(!gridAdminVOIPage.getRecords().isEmpty()){ |
| | | gridAdminVOIPage.getRecords().forEach(gridMember -> { |
| | | List<GridMemberAdminVO> members = this.baseMapper.getGridMember(gridMember.getId()); |
| | | if(!members.isEmpty()){ |
| | | gridMember.setGridMembers(members); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(gridAdminVOIPage); |
| | | } |
| | | |
| | | /** |
| | | * 查询社区下所有网格员 |
| | | * @param communityId 社区id |
| | | * @return 网格员列表 |
| | | */ |
| | | @Override |
| | | public R getGridMemberLists(Long communityId){ |
| | | return R.ok(this.baseMapper.getGridMemberLists(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 后台新增网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 新增结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public R addGridDataByAdmin(EventGridDataAddAdminDTO eventGridDataDTO){ |
| | | //查询社区信息 |
| | | ComGridActVO gridAct = this.baseMapper.getComActByActId(eventGridDataDTO.getGridCommunityId()); |
| | | if(gridAct != null){ |
| | | EventGridDataDO gridDataDO = new EventGridDataDO(); |
| | | BeanUtils.copyProperties(eventGridDataDTO,gridDataDO); |
| | | gridDataDO.setType(EventGridDataDO.type.sq); |
| | | gridDataDO.setGridStreetId(gridAct.getStreetId()); |
| | | gridDataDO.setGridCommunityId(gridAct.getCommunityId()); |
| | | gridDataDO.setZoneId(Long.parseLong(gridAct.getAreaCode())); |
| | | gridDataDO.setCreateBy(eventGridDataDTO.getUserId()); |
| | | if(this.baseMapper.insert(gridDataDO) > 0){ |
| | | if(!eventGridDataDTO.getMemberIds().isEmpty()){ |
| | | List<EventGridMemberRelationDO> memberRelationDOList = new ArrayList<>(); |
| | | //新增网格成功 绑定网格与网格员关系 |
| | | eventGridDataDTO.getMemberIds().forEach(memberId -> { |
| | | EventGridMemberRelationDO memberRelationDO = new EventGridMemberRelationDO(); |
| | | memberRelationDO.setGridId(gridDataDO.getId()); |
| | | memberRelationDO.setGridCommunityId(gridDataDO.getGridCommunityId()); |
| | | memberRelationDO.setGridStreetId(gridDataDO.getGridStreetId()); |
| | | memberRelationDO.setGridName(gridDataDO.getGridName()); |
| | | memberRelationDO.setGridMemberId(memberId); |
| | | memberRelationDOList.add(memberRelationDO); |
| | | }); |
| | | if(!memberRelationDOList.isEmpty()){ |
| | | //添加网格与网格员关联关系 |
| | | eventGridMemberRelationService.saveBatch(memberRelationDOList); |
| | | } |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail("添加失败"); |
| | | } |
| | | |
| | | /** |
| | | * 后台修改网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public R editGridDataByAdmin(EventGridDataEditAdminDTO eventGridDataDTO){ |
| | | |
| | | EventGridDataDO gridDataDO = this.baseMapper.selectById(eventGridDataDTO.getGridId()); |
| | | if(gridDataDO != null){ |
| | | BeanUtils.copyProperties(eventGridDataDTO,gridDataDO); |
| | | gridDataDO.setUpdateBy(eventGridDataDTO.getUserId()); |
| | | if(this.baseMapper.updateById(gridDataDO) > 0){ |
| | | //移除网格员和网格关系 |
| | | this.baseMapper.removeGridRelationByGridId(gridDataDO.getId()); |
| | | |
| | | if(!eventGridDataDTO.getMemberIds().isEmpty()){ |
| | | List<EventGridMemberRelationDO> memberRelationDOList = new ArrayList<>(); |
| | | //绑定网格与网格员关系 |
| | | eventGridDataDTO.getMemberIds().forEach(memberId -> { |
| | | EventGridMemberRelationDO memberRelationDO = new EventGridMemberRelationDO(); |
| | | memberRelationDO.setGridId(gridDataDO.getId()); |
| | | memberRelationDO.setGridCommunityId(gridDataDO.getGridCommunityId()); |
| | | memberRelationDO.setGridStreetId(gridDataDO.getGridStreetId()); |
| | | memberRelationDO.setGridName(gridDataDO.getGridName()); |
| | | memberRelationDO.setGridMemberId(memberId); |
| | | memberRelationDOList.add(memberRelationDO); |
| | | }); |
| | | if(!memberRelationDOList.isEmpty()){ |
| | | //添加网格与网格员关联关系 |
| | | eventGridMemberRelationService.saveBatch(memberRelationDOList); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridMemberListsByGrid(Long gridId) { |
| | | List<EventGridMemberAdminVO> eventGridMemberAdminVOList = this.getBaseMapper().getGridMemberListsByGrid(gridId); |
| | | return R.ok(eventGridMemberAdminVOList); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridDataListByCommunity(Long communityId) { |
| | | List<EventGridDataAreaVO> eventGridDataAreaVOList = this.getBaseMapper().getGridDataListByCommunity(communityId); |
| | | return R.ok(eventGridDataAreaVOList); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteGridDataByAdmin(List<Long> Ids){ |
| | | Integer count = eventMapper.getEventCountByGridIds(Ids); |
| | | if(count > 0){ |
| | | return R.fail("您选择的网格已发布过事件,不可删除"); |
| | | } |
| | | if(this.baseMapper.deleteBatchIds(Ids) > 0){ |
| | | return R.ok(); |
| | | }else{ |
| | | return R.fail(); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |