| | |
| | | package com.panzhihua.service_community.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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | 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.model.dos.ComMngPopulationHouseDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVillageDO; |
| | | import com.panzhihua.service_community.service.ComMngVillageService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author: llming |
| | | * @description: 实有房屋 |
| | | **/ |
| | | @Service |
| | | public class ComMngVillageServiceImpl extends ServiceImpl<ComActVillageDAO, ComMngVillageDO> implements ComMngVillageService { |
| | | public class ComMngVillageServiceImpl extends ServiceImpl<ComActVillageDAO, ComMngVillageDO> |
| | | implements ComMngVillageService { |
| | | @Resource |
| | | ComActVillageDAO comActVillageDAO; |
| | | @Resource |
| | |
| | | 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); |
| | | // 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 comMngVillageDO; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R pageComActVillage(PageComMngVillageDTO pageComMngVillageDTO) { |
| | | LambdaQueryWrapper<ComMngVillageDO> userLambdaQueryWrapper = Wrappers.lambdaQuery(); |
| | | if(pageComMngVillageDTO.getCommunityId() != null){ |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getCommunityId,pageComMngVillageDTO.getCommunityId()); |
| | | if (pageComMngVillageDTO.getCommunityId() != null) { |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getCommunityId, pageComMngVillageDTO.getCommunityId()); |
| | | } |
| | | if (pageComMngVillageDTO.getAlley() != null) { |
| | | userLambdaQueryWrapper.like(ComMngVillageDO::getAlley, pageComMngVillageDTO.getAlley()); |
| | |
| | | if (StringUtils.isNotEmpty(pageComMngVillageDTO.getGroupAt())) { |
| | | userLambdaQueryWrapper.eq(ComMngVillageDO::getGroupAt, pageComMngVillageDTO.getGroupAt()); |
| | | } |
| | | if(pageComMngVillageDTO.getType() != null){ |
| | | 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)); |
| | | IPage<ComMngVillageDO> doPager = |
| | | comActVillageDAO.selectPage(userPage, userLambdaQueryWrapper.orderByDesc(ComMngVillageDO::getCreateAt)); |
| | | |
| | | 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()){ |
| | | if (!doPager.getRecords().isEmpty()) { |
| | | List<ComMngVillageVO> villageVOList = new ArrayList<>(); |
| | | //统计小区下的数据 |
| | | // 统计小区下的数据 |
| | | doPager.getRecords().forEach(village -> { |
| | | ComMngVillageVO villageVO = new ComMngVillageVO(); |
| | | BeanUtils.copyProperties(village,villageVO); |
| | | //查询小区统计数据 |
| | | BeanUtils.copyProperties(village, villageVO); |
| | | // 查询小区统计数据 |
| | | ComMngVillageVO villageTotal = comActVillageDAO.getStatisticsCount(village.getVillageId()); |
| | | if(villageTotal != null){ |
| | | if (villageTotal != null) { |
| | | villageVO.setFloorTotal(villageTotal.getFloorTotal()); |
| | | villageVO.setCarTotal(villageTotal.getCarTotal()); |
| | | villageVO.setHouseTotal(villageTotal.getHouseTotal()); |
| | |
| | | @Override |
| | | public R delecComActVillage(List<Long> Ids) { |
| | | LambdaQueryWrapper<ComMngPopulationHouseDO> paramHouseWrapper = Wrappers.lambdaQuery(); |
| | | paramHouseWrapper.in(ComMngPopulationHouseDO::getVillageId,Ids); |
| | | paramHouseWrapper.in(ComMngPopulationHouseDO::getVillageId, Ids); |
| | | List<ComMngPopulationHouseDO> populationHouseDOList = comMngPopulationHouseDAO.selectList(paramHouseWrapper); |
| | | if (!populationHouseDOList.isEmpty()) { |
| | | return R.fail("无法删除,已绑定实有房屋!"); |
| | |
| | | |
| | | @Override |
| | | public R listSaveVillage(List<ComMngVillageServeExcelVO> list, Long communityId) { |
| | | //思路:获取社区下所有的实有房屋(小区),打印已经存在的重复数据 |
| | | // 思路:获取社区下所有的实有房屋(小区),打印已经存在的重复数据 |
| | | if (list.size() == 0) { |
| | | return R.fail("数据为空!"); |
| | | } |
| | | List<ComMngVillageDO> comMngVillageDOs = comActVillageDAO.selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId)); |
| | | List<ComMngVillageDO> comMngVillageDOs = comActVillageDAO |
| | | .selectList(new QueryWrapper<ComMngVillageDO>().lambda().eq(ComMngVillageDO::getCommunityId, communityId)); |
| | | int index = 2; |
| | | for (ComMngVillageServeExcelVO vo : list) { |
| | | if (vo.getHouseNum() == null) { |
| | |
| | | if (vo.getAlley() == null) { |
| | | return R.fail("街路巷第" + index + "行为空!"); |
| | | } |
| | | //判断DB和exel数据重复判断 |
| | | boolean result = comMngVillageDOs.stream().anyMatch(village -> village.getAlley().equals(vo.getAlley()) && village.getHouseNum().equals(vo.getHouseNum())); |
| | | // 判断DB和exel数据重复判断 |
| | | 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("")){ |
| | | if (comActDO.getStreetId() == null || comActDO.getStreetId().toString().equals("")) { |
| | | return R.fail("请绑定街道,再操作!"); |
| | | } |
| | | ArrayList<ComMngVillageDO> comMngVillageDOS = Lists.newArrayList(); |
| | |
| | | return R.fail("社区没有绑定街道,请绑定后操作!"); |
| | | } |
| | | comMngVillageDO.setStreetId(comActDO.getStreetId()); |
| | | int update = this.baseMapper.update(comMngVillageDO, new LambdaQueryWrapper<ComMngVillageDO>() |
| | | .eq(ComMngVillageDO::getVillageId, villageId)); |
| | | if(update>0){ |
| | | 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 统计小区数量 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 统计小区数量 |
| | | */ |
| | | @Override |
| | | public R villageStatistics(Long communityId){ |
| | | public R villageStatistics(Long communityId) { |
| | | return R.ok(this.baseMapper.getVillageStatisticsCount(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 小区详情 |
| | | * @param villageId 小区id |
| | | * @return 小区详情 |
| | | * |
| | | * @param villageId |
| | | * 小区id |
| | | * @return 小区详情 |
| | | */ |
| | | @Override |
| | | public R getVillage(Long villageId){ |
| | | public R getVillage(Long villageId) { |
| | | return R.ok(this.baseMapper.getVillageById(villageId)); |
| | | } |
| | | |
| | | /** |
| | | * 综治app-小区列表 |
| | | * @param villageListAppDTO 请求参数 |
| | | * @return 小区列表 |
| | | * |
| | | * @param villageListAppDTO |
| | | * 请求参数 |
| | | * @return 小区列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageList(ComMngVillageListAppDTO villageListAppDTO){ |
| | | return R.ok(this.baseMapper.getGridVillageList(new Page(villageListAppDTO.getPageNum(),villageListAppDTO.getPageSize()),villageListAppDTO)); |
| | | public R getGridVillageList(ComMngVillageListAppDTO villageListAppDTO) { |
| | | return R.ok(this.baseMapper.getGridVillageList( |
| | | new Page(villageListAppDTO.getPageNum(), villageListAppDTO.getPageSize()), villageListAppDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 综治app-根据小区id查询小区下楼栋列表 |
| | | * @param villageId 小区id |
| | | * @return 楼栋列表 |
| | | * |
| | | * @param villageId |
| | | * 小区id |
| | | * @return 楼栋列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingList(Long villageId){ |
| | | public R getGridVillageBuildingList(Long villageId) { |
| | | |
| | | List<ComMngVillageBuildingVO> villageBuildingList = this.baseMapper.getGridVillageBuildingList(villageId); |
| | | if(!villageBuildingList.isEmpty()){ |
| | | if (!villageBuildingList.isEmpty()) { |
| | | villageBuildingList.forEach(villageBuilding -> { |
| | | if(!villageBuilding.getFloor().contains("栋")){ |
| | | if (!villageBuilding.getFloor().contains("栋")) { |
| | | villageBuilding.setFloorString(villageBuilding.getFloor() + "栋"); |
| | | }else{ |
| | | } else { |
| | | villageBuilding.setFloorString(villageBuilding.getFloor()); |
| | | } |
| | | if(!villageBuilding.getUnitNo().contains("单元")){ |
| | | if (!villageBuilding.getUnitNo().contains("单元")) { |
| | | villageBuilding.setUnitNoString(villageBuilding.getUnitNo() + "单元"); |
| | | }else{ |
| | | } else { |
| | | villageBuilding.setUnitNoString(villageBuilding.getUnitNo()); |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R delGridVillage(List<Long> villageIds){ |
| | | public R delGridVillage(List<Long> villageIds) { |
| | | |
| | | if(villageIds.isEmpty()){ |
| | | if (villageIds.isEmpty()) { |
| | | return R.fail("请选择需要删除的小区"); |
| | | } |
| | | //查询需要删除的小区下面是否绑定的有房屋 |
| | | // 查询需要删除的小区下面是否绑定的有房屋 |
| | | Integer count = this.baseMapper.getVillageHouseCount(villageIds); |
| | | if(count > 0){ |
| | | if (count > 0) { |
| | | return R.fail("您选择的小区已被引用,无法删除"); |
| | | } |
| | | if(this.baseMapper.deleteBatchIds(villageIds) > 0){ |
| | | if (this.baseMapper.deleteBatchIds(villageIds) > 0) { |
| | | return R.ok(); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridVillageStatistics(){ |
| | | public R getGridVillageStatistics() { |
| | | return R.ok(this.baseMapper.getGridVillageStatistics()); |
| | | } |
| | | |
| | | @Override |
| | | public R getGridVillageListExport(ComMngVillageListExportAdminDTO villageListAppDTO){ |
| | | public R getGridVillageListExport(ComMngVillageListExportAdminDTO villageListAppDTO) { |
| | | return R.ok(this.baseMapper.getGridVillageLists(villageListAppDTO)); |
| | | } |
| | | |