| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.panzhihua.common.model.dtos.community.PageComMngVillageDTO; |
| | | import com.panzhihua.common.model.dtos.grid.ComMngVillageListAppDTO; |
| | | import com.panzhihua.common.model.dtos.grid.PageComMngVillageBuildHouseAppDTO; |
| | | import com.panzhihua.common.model.dtos.grid.admin.ComMngPopulationListDTO; |
| | | import com.panzhihua.common.model.dtos.grid.admin.ComMngVillageListExportAdminDTO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.community.ComMngVillageServeExcelVO; |
| | | import com.panzhihua.common.model.vos.community.ComMngVillageVO; |
| | | import com.panzhihua.common.model.vos.grid.ComMngVillageBuildingHouseVO; |
| | | import com.panzhihua.common.model.vos.grid.ComMngVillageBuildingVO; |
| | | import com.panzhihua.common.model.vos.grid.admin.ComMngVillageStatisticsVO; |
| | | import com.panzhihua.common.utlis.Snowflake; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.service_community.dao.ComActDAO; |
| | | import com.panzhihua.service_community.dao.ComActVillageDAO; |
| | | import com.panzhihua.service_community.dao.ComMngPopulationDAO; |
| | | import com.panzhihua.service_community.dao.ComMngVolunteerMngDAO; |
| | | import com.panzhihua.service_community.dao.ComMngPopulationHouseDAO; |
| | | import com.panzhihua.service_community.model.dos.ComActDO; |
| | | import com.panzhihua.service_community.model.dos.ComActDiscussDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationHouseDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVillageDO; |
| | | import com.panzhihua.service_community.service.ComMngVillageService; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author: llming |
| | |
| | | ComActDAO comActDAO; |
| | | @Resource |
| | | ComMngPopulationDAO populationDAO; |
| | | @Resource |
| | | private ComMngPopulationHouseDAO comMngPopulationHouseDAO; |
| | | |
| | | @Override |
| | | public R addComActVillage(ComMngVillageVO comMngVillageVO) { |
| | |
| | | } |
| | | BeanUtils.copyProperties(comMngVillageVO, comMngVillageDO); |
| | | ComActDO comActDO = comActDAO.selectById(comMngVillageDO.getCommunityId()); |
| | | if (comActDO == null || comActDO.getStreetId() == null) { |
| | | return R.fail("社区没有绑定街道,请绑定后操作!"); |
| | | } |
| | | comMngVillageDO.setVillageId(Snowflake.getId()); |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | comMngVillageDO.setUpdateAt(new Date()); |
| | | int insert = comActVillageDAO.insert(comMngVillageDO); |
| | | if (insert > 0) { |
| | | param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley()); |
| | | param.eq(ComMngVillageDO::getHouseNum, comMngVillageVO.getHouseNum()); |
| | | ComMngVillageDO comMngVillageDO1 = comActVillageDAO.selectOne(param); |
| | | BeanUtils.copyProperties(comMngVillageDO1, comMngVillageVO); |
| | | // param.eq(ComMngVillageDO::getAlley, comMngVillageVO.getAlley()); |
| | | // param.eq(ComMngVillageDO::getHouseNum, comMngVillageVO.getHouseNum()); |
| | | // ComMngVillageDO comMngVillageDO1 = comActVillageDAO.selectOne(param); |
| | | BeanUtils.copyProperties(comMngVillageDO, comMngVillageVO); |
| | | return R.ok(comMngVillageVO); |
| | | } |
| | | return R.fail(); |
| | |
| | | return R.ok(vos); |
| | | } |
| | | |
| | | @Override |
| | | public ComMngVillageDO getVillageById(Long villageId) { |
| | | ComMngVillageDO comMngVillageDO = new ComMngVillageDO(); |
| | | comMngVillageDO = comActVillageDAO.selectById(villageId); |
| | | return comMngVillageDO; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R pageComActVillage(PageComMngVillageDTO pageComMngVillageDTO) { |
| | | Page page = new Page<>(); |
| | | Long pageNum = pageComMngVillageDTO.getPageNum(); |
| | | Long pageSize = pageComMngVillageDTO.getPageSize(); |
| | | if (null == pageNum || 0 == pageNum) { |
| | | pageNum = 1l; |
| | | } |
| | | if (null == pageSize || 0 == pageSize) { |
| | | pageSize = 10l; |
| | | } |
| | | page.setSize(pageSize); |
| | | page.setCurrent(pageNum); |
| | | LambdaQueryWrapper<ComMngVillageDO> userLambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | if(pageComMngVillageDTO.getCommunityId() != null){ |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getCommunityId,pageComMngVillageDTO.getCommunityId()); |
| | | } |
| | | if (pageComMngVillageDTO.getAlley() != null) { |
| | | userLambdaQueryWrapper.like(ComMngVillageDO::getAlley, pageComMngVillageDTO.getAlley()); |
| | | } |
| | | Page userPage = new Page(pageNum, pageSize); |
| | | if (StringUtils.isNotEmpty(pageComMngVillageDTO.getHouseNum())) { |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getHouseNum, pageComMngVillageDTO.getHouseNum()); |
| | | } |
| | | if (StringUtils.isNotEmpty(pageComMngVillageDTO.getGroupAt())) { |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getGroupAt, pageComMngVillageDTO.getGroupAt()); |
| | | } |
| | | if(pageComMngVillageDTO.getType() != null){ |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getType, pageComMngVillageDTO.getType()); |
| | | } |
| | | Page userPage = new Page(pageComMngVillageDTO.getPageNum(), pageComMngVillageDTO.getPageSize()); |
| | | IPage<ComMngVillageDO> doPager = comActVillageDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComMngVillageDO::getCreateAt)); |
| | | return R.ok(doPager); |
| | | |
| | | IPage<ComMngVillageVO> villageVOIPage = new Page<>(); |
| | | villageVOIPage.setCurrent(doPager.getCurrent()); |
| | | villageVOIPage.setPages(doPager.getPages()); |
| | | villageVOIPage.setSize(doPager.getSize()); |
| | | villageVOIPage.setTotal(doPager.getTotal()); |
| | | if(!doPager.getRecords().isEmpty()){ |
| | | List<ComMngVillageVO> villageVOList = new ArrayList<>(); |
| | | //统计小区下的数据 |
| | | doPager.getRecords().forEach(village -> { |
| | | ComMngVillageVO villageVO = new ComMngVillageVO(); |
| | | BeanUtils.copyProperties(village,villageVO); |
| | | //查询小区统计数据 |
| | | ComMngVillageVO villageTotal = comActVillageDAO.getStatisticsCount(village.getVillageId()); |
| | | if(villageTotal != null){ |
| | | villageVO.setFloorTotal(villageTotal.getFloorTotal()); |
| | | villageVO.setCarTotal(villageTotal.getCarTotal()); |
| | | villageVO.setHouseTotal(villageTotal.getHouseTotal()); |
| | | villageVO.setPopulationTotal(villageTotal.getPopulationTotal()); |
| | | } |
| | | villageVOList.add(villageVO); |
| | | |
| | | }); |
| | | villageVOIPage.setRecords(villageVOList); |
| | | } |
| | | return R.ok(villageVOIPage); |
| | | } |
| | | |
| | | @Override |
| | | public R delecComActVillage(List<Long> Ids) { |
| | | LambdaQueryWrapper<ComMngPopulationHouseDO> paramHouseWrapper = Wrappers.lambdaQuery(); |
| | | paramHouseWrapper.in(ComMngPopulationHouseDO::getVillageId,Ids); |
| | | List<ComMngPopulationHouseDO> populationHouseDOList = comMngPopulationHouseDAO.selectList(paramHouseWrapper); |
| | | if (!populationHouseDOList.isEmpty()) { |
| | | return R.fail("无法删除,已绑定实有房屋!"); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ComMngPopulationDO> paramWrapper = Wrappers.lambdaQuery(); |
| | | paramWrapper.in(ComMngPopulationDO::getVillageId, Ids); |
| | | ComMngPopulationDO mngPopulationDO = populationDAO.selectOne(paramWrapper); |
| | | if (mngPopulationDO != null) { |
| | | List<ComMngPopulationDO> mngPopulationDOList = populationDAO.selectList(paramWrapper); |
| | | if (!mngPopulationDOList.isEmpty()) { |
| | | return R.fail("无法删除,已绑定实有人口!"); |
| | | } |
| | | int delete = comActVillageDAO.deleteBatchIds(Ids); |
| | |
| | | return R.fail("街路巷第" + index + "行为空!"); |
| | | } |
| | | //判断DB和exel数据重复判断 |
| | | boolean result = comMngVillageDOs.stream().anyMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().intValue() == vo.getHouseNum().intValue()); |
| | | boolean result = comMngVillageDOs.stream().anyMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().equals(vo.getHouseNum())); |
| | | if (result) { |
| | | return R.fail("导入街路巷已存在(" + vo.getAlley() + ")"); |
| | | } |
| | | index++; |
| | | } |
| | | ComActDO comActDO = comActDAO.selectById(communityId); |
| | | if(comActDO.getStreetId()==null||comActDO.getStreetId().toString().equals("")){ |
| | | return R.fail("请绑定街道,再操作!"); |
| | | } |
| | | ArrayList<ComMngVillageDO> comMngVillageDOS = Lists.newArrayList(); |
| | | list.forEach(vo -> { |
| | | ComMngVillageDO comMngVillageDO = new ComMngVillageDO(); |
| | | BeanUtils.copyProperties(vo, comMngVillageDO); |
| | | comMngVillageDO.setCommunityId(comActDO.getCommunityId()); |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | StringBuilder path = new StringBuilder(); |
| | | path.append(vo.getAlley()).append(">").append(vo.getHouseNum()).append(">").append(vo.getGroupAt()); |
| | | comMngVillageDO.setPath(path.toString()); |
| | | comMngVillageDO.setUpdateAt(new Date()); |
| | | comMngVillageDOS.add(comMngVillageDO); |
| | | }); |
| | | this.saveBatch(comMngVillageDOS); |
| | | return R.ok("共计导入实有房屋数量:" + comMngVillageDOS.size()); |
| | | } |
| | | |
| | | @Override |
| | | public R editVillage(Long villageId, ComMngVillageVO comMngVillageVO) { |
| | | ComMngVillageDO comMngVillageDO = this.baseMapper.selectById(villageId); |
| | | if (comMngVillageDO == null) { |
| | | return R.fail("id有误!"); |
| | | } |
| | | BeanUtils.copyProperties(comMngVillageVO, comMngVillageDO); |
| | | ComActDO comActDO = comActDAO.selectById(comMngVillageDO.getCommunityId()); |
| | | if (comActDO == null || comActDO.getStreetId() == null) { |
| | | return R.fail("社区没有绑定街道,请绑定后操作!"); |
| | | } |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | int update = this.baseMapper.update(comMngVillageDO, new LambdaQueryWrapper<ComMngVillageDO>() |
| | | .eq(ComMngVillageDO::getVillageId, villageId)); |
| | | if(update>0){ |
| | | return R.ok(comMngVillageVO); |
| | | } |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 统计社区内小区数量 |
| | | * @param communityId 社区id |
| | | * @return 统计小区数量 |
| | | */ |
| | | @Override |
| | | public R villageStatistics(Long communityId){ |
| | | return R.ok(this.baseMapper.getVillageStatisticsCount(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 小区详情 |
| | | * @param villageId 小区id |
| | | * @return 小区详情 |
| | | */ |
| | | @Override |
| | | public R getVillage(Long villageId){ |
| | | return R.ok(this.baseMapper.getVillageById(villageId)); |
| | | } |
| | | |
| | | /** |
| | | * 综治app-小区列表 |
| | | * @param villageListAppDTO 请求参数 |
| | | * @return 小区列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageList(ComMngVillageListAppDTO villageListAppDTO){ |
| | | return R.ok(this.baseMapper.getGridVillageList(new Page(villageListAppDTO.getPageNum(),villageListAppDTO.getPageSize()),villageListAppDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 综治app-根据小区id查询小区下楼栋列表 |
| | | * @param villageId 小区id |
| | | * @return 楼栋列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingList(Long villageId){ |
| | | |
| | | List<ComMngVillageBuildingVO> villageBuildingList = this.baseMapper.getGridVillageBuildingList(villageId); |
| | | if(!villageBuildingList.isEmpty()){ |
| | | villageBuildingList.forEach(villageBuilding -> { |
| | | if(!villageBuilding.getFloor().contains("栋")){ |
| | | villageBuilding.setFloorString(villageBuilding.getFloor() + "栋"); |
| | | }else{ |
| | | villageBuilding.setFloorString(villageBuilding.getFloor()); |
| | | } |
| | | if(!villageBuilding.getUnitNo().contains("单元")){ |
| | | villageBuilding.setUnitNoString(villageBuilding.getUnitNo() + "单元"); |
| | | }else{ |
| | | villageBuilding.setUnitNoString(villageBuilding.getUnitNo()); |
| | | } |
| | | }); |
| | | } |
| | | return R.ok(villageBuildingList); |
| | | } |
| | | |
| | | @Override |
| | | public R delGridVillage(List<Long> villageIds){ |
| | | |
| | | if(villageIds.isEmpty()){ |
| | | return R.fail("请选择需要删除的小区"); |
| | | } |
| | | //查询需要删除的小区下面是否绑定的有房屋 |
| | | Integer count = this.baseMapper.getVillageHouseCount(villageIds); |
| | | if(count > 0){ |
| | | return R.fail("您选择的小区已被引用,无法删除"); |
| | | } |
| | | if(this.baseMapper.deleteBatchIds(villageIds) > 0){ |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridVillageStatistics(){ |
| | | return R.ok(this.baseMapper.getGridVillageStatistics()); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridVillageListExport(ComMngVillageListExportAdminDTO villageListAppDTO){ |
| | | return R.ok(this.baseMapper.getGridVillageLists(villageListAppDTO)); |
| | | } |
| | | |
| | | } |