| | |
| | | package org.springblade.modules.grid.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.BeanUtil; |
| | | import org.springblade.modules.doorplateAddress.entity.DoorplateAddressEntity; |
| | | import org.springblade.modules.doorplateAddress.service.IDoorplateAddressService; |
| | | import org.springblade.modules.grid.entity.GridEntity; |
| | | import org.springblade.modules.grid.entity.GridRangeEntity; |
| | | import org.springblade.modules.grid.entity.GridmanEntity; |
| | | import org.springblade.modules.grid.excel.GridExcel; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.modules.grid.mapper.GridMapper; |
| | | import org.springblade.modules.grid.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springblade.modules.grid.vo.GridVO; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 网格表 服务实现类 |
| | |
| | | |
| | | @Override |
| | | public IPage<GridVO> selectGridPage(IPage<GridVO> page, GridVO grid) { |
| | | Dept dept = deptService.getById(AuthUtil.getDeptId()); |
| | | if (null!=dept){ |
| | | grid.setRegionCode(dept.getRegionCode()); |
| | | } |
| | | return page.setRecords(baseMapper.selectGridPage(page, grid)); |
| | | } |
| | | |
| | |
| | | * @param isCovered |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importGrid(List<GridExcel> data, Boolean isCovered) { |
| | | List<GridEntity> list = new ArrayList<>(); |
| | | // 遍历 |
| | | for (GridExcel gridExcel : data) { |
| | | // 取出名称分隔 |
| | | String[] split = gridExcel.getGridName().split("居民委员会"); |
| | | String[] split = gridExcel.getGridName().split("第"); |
| | | GridEntity gridEntity = new GridEntity(); |
| | | String communityName = split[0] + "居民委员会"; |
| | | gridEntity.setCommunityName(communityName); |
| | | // 通过社区名称查询对应的社区编号 |
| | | QueryWrapper<Region> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("name",split[0]); |
| | | wrapper.like("name",split[0]); |
| | | System.out.println("社区名称 = " + split[0]); |
| | | Region region = regionService.getOne(wrapper); |
| | | if (null!=region){ |
| | | gridEntity.setCommunityCode(region.getCode()); |
| | | } |
| | | gridEntity.setGridName(split[1]); |
| | | gridEntity.setGeom(gridExcel.getGeom()); |
| | | gridEntity.setCreateUser(AuthUtil.getUserId()); |
| | | gridEntity.setCreateTime(new Date()); |
| | | gridEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | gridEntity.setUpdateTime(new Date()); |
| | | list.add(gridEntity); |
| | | // 比对网格是否存在,如果已存在则更新,否则则新增 |
| | | QueryWrapper<GridEntity> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("is_deleted",0) |
| | | .eq("grid_name","第" + split[1]) |
| | | .eq("community_code",region.getCode()); |
| | | GridEntity one = getOne(queryWrapper); |
| | | if (null!=one){ |
| | | one.setGridCode(gridExcel.getGridCode()); |
| | | one.setGridName("第" + split[1]); |
| | | one.setGeom(gridExcel.getGeom()); |
| | | one.setUpdateUser(AuthUtil.getUserId()); |
| | | one.setUpdateTime(new Date()); |
| | | // 更新 |
| | | updateById(one); |
| | | }else { |
| | | // 设置网格数据 |
| | | gridEntity.setGridCode(gridExcel.getGridCode()); |
| | | gridEntity.setGridName("第" + split[1]); |
| | | gridEntity.setGeom(gridExcel.getGeom()); |
| | | gridEntity.setCreateUser(AuthUtil.getUserId()); |
| | | gridEntity.setCreateTime(new Date()); |
| | | gridEntity.setUpdateUser(AuthUtil.getUserId()); |
| | | gridEntity.setUpdateTime(new Date()); |
| | | list.add(gridEntity); |
| | | } |
| | | } |
| | | // 批量导入 |
| | | saveBatch(list); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Object spatialAnalysis() { |
| | | // 按社区 |
| | | String name = "万达社区居民委员会"; |
| | | String name = null; |
| | | // String name = "茶山路社区居民委员会"; |
| | | //查询社区信息 |
| | | List<DoorplateAddressEntity> doorplateAddressEntities = doorplateAddressService.getAllDoorplateAddress(name); |
| | |
| | | |
| | | /** |
| | | * 网格树 |
| | | * |
| | | * @param grid |
| | | * @return |
| | | */ |
| | |
| | | public Object getGridTree(GridVO grid) { |
| | | return NodeTreeUtil.getStringNodeTree(baseMapper.getGridTree()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Object gridInfoByHouseCode(String houseCode) { |
| | | Map<String, Object> objectObjectHashMap = new HashMap<>(); |
| | | List<GridmanEntity> gridmanEntities = baseMapper.gridInfo(houseCode); |
| | | Integer id = gridmanEntities.get(0).getId(); |
| | | objectObjectHashMap.put("grid", gridmanEntities); |
| | | List<DoorplateAddressEntity> result = baseMapper.gridAoiName(id); |
| | | objectObjectHashMap.put("doorplateAddress", result); |
| | | return objectObjectHashMap; |
| | | } |
| | | |
| | | /** |
| | | * 网格集合查询 |
| | | * @param grid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object getGridList(GridVO grid) { |
| | | return baseMapper.getGridList(grid); |
| | | } |
| | | |
| | | /** |
| | | * 查询小区网格绑定 |
| | | * @param aoiCode 小区aoiCode |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<GridVO> getGridListByAoiCode(String aoiCode) { |
| | | return baseMapper.getGridListByAoiCode(aoiCode); |
| | | } |
| | | } |