| | |
| | | package com.panzhihua.service_grid.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.*; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.service_grid.dao.*; |
| | | import com.panzhihua.service_grid.model.dos.*; |
| | | import com.panzhihua.service_grid.dao.EventGridDataMapper; |
| | | import com.panzhihua.service_grid.dao.EventMapper; |
| | | import com.panzhihua.service_grid.dao.LcCompareCodeMapper; |
| | | import com.panzhihua.service_grid.model.dos.EventGridDataDO; |
| | | import com.panzhihua.service_grid.model.dos.EventGridMemberRelationDO; |
| | | import com.panzhihua.service_grid.model.dos.LcCompareCodeDO; |
| | | 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; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class EventGridDataServiceImpl extends ServiceImpl<EventGridDataMapper, EventGridDataDO> implements EventGridDataService { |
| | | public class EventGridDataServiceImpl extends ServiceImpl<EventGridDataMapper, EventGridDataDO> |
| | | implements EventGridDataService { |
| | | |
| | | @Resource |
| | | private EventGridDataMapper eventGridDataMapper; |
| | |
| | | private EventGridMemberRelationService eventGridMemberRelationService; |
| | | @Resource |
| | | private LcCompareCodeMapper lcCompareCodeMapper; |
| | | |
| | | /** |
| | | * 新增区县/街道/社区/网格员网格数据管理 |
| | | * |
| | | * @param eventGridDataAddDTO |
| | | * @return 新增结果 |
| | | */ |
| | | public R add(EventGridDataAddDTO eventGridDataAddDTO){ |
| | | public R add(EventGridDataAddDTO eventGridDataAddDTO) { |
| | | EventGridDataDO eventGridDataDO = new EventGridDataDO(); |
| | | BeanUtils.copyProperties(eventGridDataAddDTO, eventGridDataDO); |
| | | eventGridDataDO.setCreateAt(new Date()); |
| | | if(eventGridDataMapper.insert(eventGridDataDO)>0){ |
| | | if (eventGridDataMapper.insert(eventGridDataDO) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | |
| | | /** |
| | | * 修改区县/街道/社区/网格员网格数据管理 |
| | | * |
| | | * @param eventGridDataEditDTO |
| | | * @return 维护结果 |
| | | */ |
| | | public R edit(EventGridDataEditDTO eventGridDataEditDTO){ |
| | | public R edit(EventGridDataEditDTO eventGridDataEditDTO) { |
| | | EventGridDataDO eventGridDataDO = new EventGridDataDO(); |
| | | BeanUtils.copyProperties(eventGridDataEditDTO, eventGridDataDO); |
| | | //eventGridDataDO.setUpdateAt(new Date()); |
| | | if(eventGridDataMapper.updateById(eventGridDataDO)>0){ |
| | | // eventGridDataDO.setUpdateAt(new Date()); |
| | | if (eventGridDataMapper.updateById(eventGridDataDO) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail(); |
| | |
| | | |
| | | /** |
| | | * 删除区县/街道/社区/网格员网格数据管理 |
| | | * |
| | | * @param EventGridDataDeleteDTO |
| | | * @return 平台用户信息 |
| | | */ |
| | | public R delete(EventGridDataDeleteDTO EventGridDataDeleteDTO){ |
| | | public R delete(EventGridDataDeleteDTO EventGridDataDeleteDTO) { |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 查询区县/街道/社区/网格员网格数据管理详细信息 |
| | | * @param id 区县/街道/社区/网格员网格数据管理 id |
| | | * |
| | | * @param id |
| | | * 区县/街道/社区/网格员网格数据管理 id |
| | | * @return 查找结果 |
| | | */ |
| | | public R<EventGridDataDetailsVO> eventGridDataDetails(Long id){ |
| | | public R<EventGridDataDetailsVO> eventGridDataDetails(Long id) { |
| | | EventGridDataDO eventGridDataDO = eventGridDataMapper.selectById(id); |
| | | if(eventGridDataDO!=null) { |
| | | if (eventGridDataDO != null) { |
| | | EventGridDataDetailsVO eventGridDataDetailsVO = new EventGridDataDetailsVO(); |
| | | BeanUtils.copyProperties(eventGridDataDO, eventGridDataDetailsVO); |
| | | return R.ok(eventGridDataDetailsVO); |
| | |
| | | |
| | | @Override |
| | | public R getUserGrid(PageEventGridDataDTO pageEventGridDataDTO) { |
| | | Page page = new Page(1,10); |
| | | if(pageEventGridDataDTO.getPageNum()!=null) { |
| | | Page page = new Page(1, 10); |
| | | if (pageEventGridDataDTO.getPageNum() != null) { |
| | | page.setCurrent(pageEventGridDataDTO.getPageNum()); |
| | | } |
| | | if(pageEventGridDataDTO.getPageSize()!=null) { |
| | | if (pageEventGridDataDTO.getPageSize() != null) { |
| | | page.setSize(pageEventGridDataDTO.getPageSize()); |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 地图模块-根据网格id查询网格详细信息 |
| | | * @param gridId 网格id |
| | | * @return 网格详细信息 |
| | | * |
| | | * @param gridId |
| | | * 网格id |
| | | * @return 网格详细信息 |
| | | */ |
| | | @Override |
| | | public R getMapGridDetail(Long gridId){ |
| | | public R getMapGridDetail(Long gridId) { |
| | | ComMapGridDetailVO gridDetailVO = new ComMapGridDetailVO(); |
| | | //查询网格信息 |
| | | // 查询网格信息 |
| | | EventGridDataDO eventGridDataDO = this.baseMapper.selectById(gridId); |
| | | if(eventGridDataDO == null){ |
| | | if (eventGridDataDO == null) { |
| | | return R.fail("未查询到网格信息"); |
| | | } |
| | | BeanUtils.copyProperties(eventGridDataDO,gridDetailVO); |
| | | //查询网格待办事件 |
| | | BeanUtils.copyProperties(eventGridDataDO, gridDetailVO); |
| | | // 查询网格待办事件 |
| | | List<ComMapGridEventVO> gridEventList = eventMapper.getEventByGridId(gridId); |
| | | if(!gridEventList.isEmpty()){ |
| | | if (!gridEventList.isEmpty()) { |
| | | gridDetailVO.setGridEventList(gridEventList); |
| | | } |
| | | return R.ok(gridDetailVO); |
| | |
| | | |
| | | /** |
| | | * 分页查询网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 网格列表 |
| | | * |
| | | * @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()){ |
| | | 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()){ |
| | | if (!members.isEmpty()) { |
| | | gridMember.setGridMembers(members); |
| | | } |
| | | }); |
| | |
| | | |
| | | /** |
| | | * 查询社区下所有网格员 |
| | | * @param communityId 社区id |
| | | * @return 网格员列表 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 网格员列表 |
| | | */ |
| | | @Override |
| | | public R getGridMemberLists(Long communityId){ |
| | | public R getGridMemberLists(Long communityId) { |
| | | return R.ok(this.baseMapper.getGridMemberLists(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 后台新增网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 新增结果 |
| | | * |
| | | * @param eventGridDataDTO |
| | | * 请求参数 |
| | | * @return 新增结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public R addGridDataByAdmin(EventGridDataAddAdminDTO eventGridDataDTO){ |
| | | //查询社区信息 |
| | | public R addGridDataByAdmin(EventGridDataAddAdminDTO eventGridDataDTO) { |
| | | // 查询社区信息 |
| | | ComGridActVO gridAct = this.baseMapper.getComActByActId(eventGridDataDTO.getGridCommunityId()); |
| | | if(gridAct != null){ |
| | | if (gridAct != null) { |
| | | EventGridDataDO gridDataDO = new EventGridDataDO(); |
| | | BeanUtils.copyProperties(eventGridDataDTO,gridDataDO); |
| | | 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()){ |
| | | 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.setGridMemberId(memberId); |
| | | memberRelationDOList.add(memberRelationDO); |
| | | }); |
| | | if(!memberRelationDOList.isEmpty()){ |
| | | //添加网格与网格员关联关系 |
| | | if (!memberRelationDOList.isEmpty()) { |
| | | // 添加网格与网格员关联关系 |
| | | eventGridMemberRelationService.saveBatch(memberRelationDOList); |
| | | } |
| | | } |
| | | |
| | | if(eventGridDataDTO.getLcGridId() != null){ |
| | | //关联市平台网格 |
| | | LcCompareCodeDO compareCodeDO = lcCompareCodeMapper.selectOne(new QueryWrapper<LcCompareCodeDO>().lambda() |
| | | .eq(LcCompareCodeDO::getLcGridId,eventGridDataDTO.getLcGridId())); |
| | | if(compareCodeDO != null){ |
| | | if (eventGridDataDTO.getLcGridId() != null) { |
| | | // 关联市平台网格 |
| | | LcCompareCodeDO compareCodeDO = lcCompareCodeMapper.selectOne(new QueryWrapper<LcCompareCodeDO>() |
| | | .lambda().eq(LcCompareCodeDO::getLcGridId, eventGridDataDTO.getLcGridId())); |
| | | if (compareCodeDO != null) { |
| | | compareCodeDO.setLocalGridId(gridDataDO.getId().toString()); |
| | | compareCodeDO.setGridName(gridDataDO.getGridName()); |
| | | compareCodeDO.setUpdateAt(new Date()); |
| | | lcCompareCodeMapper.updateById(compareCodeDO); |
| | | }else{ |
| | | } else { |
| | | compareCodeDO = new LcCompareCodeDO(); |
| | | compareCodeDO.setId(Snowflake.getId()); |
| | | compareCodeDO.setLocalGridId(gridDataDO.getId().toString()); |
| | |
| | | |
| | | /** |
| | | * 后台修改网格 |
| | | * @param eventGridDataDTO 请求参数 |
| | | * @return 修改结果 |
| | | * |
| | | * @param eventGridDataDTO |
| | | * 请求参数 |
| | | * @return 修改结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public R editGridDataByAdmin(EventGridDataEditAdminDTO eventGridDataDTO){ |
| | | public R editGridDataByAdmin(EventGridDataEditAdminDTO eventGridDataDTO) { |
| | | |
| | | EventGridDataDO gridDataDO = this.baseMapper.selectById(eventGridDataDTO.getGridId()); |
| | | if(gridDataDO != null){ |
| | | BeanUtils.copyProperties(eventGridDataDTO,gridDataDO); |
| | | if (gridDataDO != null) { |
| | | BeanUtils.copyProperties(eventGridDataDTO, gridDataDO); |
| | | gridDataDO.setRemarks(eventGridDataDTO.getRemarks()); |
| | | gridDataDO.setUpdateBy(eventGridDataDTO.getUserId()); |
| | | if(this.baseMapper.updateById(gridDataDO) > 0){ |
| | | //移除网格员和网格关系 |
| | | if (this.baseMapper.updateById(gridDataDO) > 0) { |
| | | // 移除网格员和网格关系 |
| | | this.baseMapper.removeGridRelationByGridId(gridDataDO.getId()); |
| | | |
| | | if(!eventGridDataDTO.getMemberIds().isEmpty()){ |
| | | if (!eventGridDataDTO.getMemberIds().isEmpty()) { |
| | | List<EventGridMemberRelationDO> memberRelationDOList = new ArrayList<>(); |
| | | //绑定网格与网格员关系 |
| | | // 绑定网格与网格员关系 |
| | | eventGridDataDTO.getMemberIds().forEach(memberId -> { |
| | | EventGridMemberRelationDO memberRelationDO = new EventGridMemberRelationDO(); |
| | | memberRelationDO.setGridId(gridDataDO.getId()); |
| | |
| | | memberRelationDO.setGridMemberId(memberId); |
| | | memberRelationDOList.add(memberRelationDO); |
| | | }); |
| | | if(!memberRelationDOList.isEmpty()){ |
| | | //添加网格与网格员关联关系 |
| | | if (!memberRelationDOList.isEmpty()) { |
| | | // 添加网格与网格员关联关系 |
| | | eventGridMemberRelationService.saveBatch(memberRelationDOList); |
| | | } |
| | | } |
| | | |
| | | //查询已存在的关系需要清除 |
| | | lcCompareCodeMapper.delete(new QueryWrapper<LcCompareCodeDO>() |
| | | .lambda().eq(LcCompareCodeDO::getLocalGridId,gridDataDO.getId())); |
| | | if(eventGridDataDTO.getLcGridId() != null){ |
| | | //关联市平台网格 |
| | | LcCompareCodeDO compareCodeDO = lcCompareCodeMapper.selectOne(new QueryWrapper<LcCompareCodeDO>().lambda() |
| | | .eq(LcCompareCodeDO::getLcGridId,eventGridDataDTO.getLcGridId())); |
| | | if(compareCodeDO != null){ |
| | | // 查询已存在的关系需要清除 |
| | | lcCompareCodeMapper.delete(new QueryWrapper<LcCompareCodeDO>().lambda() |
| | | .eq(LcCompareCodeDO::getLocalGridId, gridDataDO.getId())); |
| | | if (eventGridDataDTO.getLcGridId() != null) { |
| | | // 关联市平台网格 |
| | | LcCompareCodeDO compareCodeDO = lcCompareCodeMapper.selectOne(new QueryWrapper<LcCompareCodeDO>() |
| | | .lambda().eq(LcCompareCodeDO::getLcGridId, eventGridDataDTO.getLcGridId())); |
| | | if (compareCodeDO != null) { |
| | | compareCodeDO.setLocalGridId(gridDataDO.getId().toString()); |
| | | compareCodeDO.setGridName(gridDataDO.getGridName()); |
| | | compareCodeDO.setUpdateAt(new Date()); |
| | | lcCompareCodeMapper.updateById(compareCodeDO); |
| | | }else{ |
| | | } else { |
| | | compareCodeDO = new LcCompareCodeDO(); |
| | | compareCodeDO.setId(Snowflake.getId()); |
| | | compareCodeDO.setLocalGridId(gridDataDO.getId().toString()); |
| | |
| | | |
| | | @Override |
| | | public R getGridDataListByCommunity(Long communityId) { |
| | | List<EventGridDataAreaVO> eventGridDataAreaVOList = this.getBaseMapper().getGridDataListByCommunity(communityId); |
| | | List<EventGridDataAreaVO> eventGridDataAreaVOList = |
| | | this.getBaseMapper().getGridDataListByCommunity(communityId); |
| | | return R.ok(eventGridDataAreaVOList); |
| | | } |
| | | |
| | | @Override |
| | | public R deleteGridDataByAdmin(List<Long> Ids){ |
| | | public R deleteGridDataByAdmin(List<Long> Ids) { |
| | | Integer count = eventMapper.getEventCountByGridIds(Ids); |
| | | if(count > 0){ |
| | | if (count > 0) { |
| | | return R.fail("您选择的网格已发布过事件,不可删除"); |
| | | } |
| | | if(this.baseMapper.deleteBatchIds(Ids) > 0){ |
| | | if (this.baseMapper.deleteBatchIds(Ids) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | |