| | |
| | | package com.panzhihua.service_community.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.function.Function; |
| | | import java.util.function.Predicate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | 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.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.panzhihua.service_community.model.dos.ComMngPopulationHouseUserDO; |
| | | import com.panzhihua.service_community.model.dos.ComMngVillageDO; |
| | | import com.panzhihua.service_community.service.ComMngPopulationHouseService; |
| | | import com.panzhihua.service_community.service.ComMngVillageService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.function.Function; |
| | | import java.util.function.Predicate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import cn.hutool.core.util.IdcardUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @auther lyq |
| | |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ComMngPopulationHouseServiceImpl extends ServiceImpl<ComMngPopulationHouseDAO, ComMngPopulationHouseDO> implements ComMngPopulationHouseService { |
| | | public class ComMngPopulationHouseServiceImpl extends ServiceImpl<ComMngPopulationHouseDAO, ComMngPopulationHouseDO> |
| | | implements ComMngPopulationHouseService { |
| | | |
| | | @Resource |
| | | private ComMngPopulationHouseUserDAO comMngPopulationHouseUserDAO; |
| | |
| | | @Resource |
| | | private ComMngPopulationHouseDAO comMngPopulationHouseDAO; |
| | | |
| | | private static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) { |
| | | Map<Object, Boolean> seen = new ConcurrentHashMap<>(); |
| | | return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; |
| | | } |
| | | |
| | | /** |
| | | * 查询房屋级联菜单 |
| | | * @param cascadeHouseDTO 请求参数 |
| | | * |
| | | * @param cascadeHouseDTO |
| | | * 请求参数 |
| | | * @return 菜单列表 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | switch (cascadeHouseDTO.getLevel()){ |
| | | case 1: |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByAlley(cascadeHouseDTO.getCommunityId(),cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley()))), ArrayList::new)); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByAlley(cascadeHouseDTO.getCommunityId(), |
| | | cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream() |
| | | .collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley()))), |
| | | ArrayList::new)); |
| | | cascadeHouseVOList.forEach(cascade -> { |
| | | cascade.setName(cascade.getAlley()); |
| | | }); |
| | |
| | | case 2: |
| | | if(houseDO != null){ |
| | | ComMngVillageDO villageDO = comActVillageDAO.selectById(houseDO.getVillageId()); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByHouseNum(villageDO.getAlley(),cascadeHouseDTO.getCommunityId(),cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum()))), ArrayList::new)); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByHouseNum(villageDO.getAlley(), |
| | | cascadeHouseDTO.getCommunityId(), cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = |
| | | cascadeHouseVOList.stream() |
| | | .collect(Collectors.collectingAndThen(Collectors.toCollection( |
| | | () -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum()))), |
| | | ArrayList::new)); |
| | | cascadeHouseVOList.forEach(cascade -> { |
| | | cascade.setName(cascade.getHouseNum()); |
| | | }); |
| | |
| | | case 3: |
| | | if(houseDO != null) { |
| | | ComMngVillageDO villageDO = comActVillageDAO.selectById(houseDO.getVillageId()); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByFloor(villageDO.getAlley(), villageDO.getHouseNum(), cascadeHouseDTO.getCommunityId(),cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum() + ";" + o.getFloor()))), ArrayList::new)); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByFloor(villageDO.getAlley(), |
| | | villageDO.getHouseNum(), cascadeHouseDTO.getCommunityId(), cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream() |
| | | .collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>( |
| | | Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum() + ";" + o.getFloor()))), |
| | | ArrayList::new)); |
| | | cascadeHouseVOList.forEach(cascade -> { |
| | | cascade.setName(cascade.getFloor()); |
| | | }); |
| | |
| | | break; |
| | | case 4: |
| | | if(houseDO != null) { |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByUnitNo(houseDO.getAlley(), houseDO.getHouseNum(), houseDO.getFloor(), cascadeHouseDTO.getCommunityId(),cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum() + ";" + o.getFloor() + ";" + o.getUnitNo()))), ArrayList::new)); |
| | | cascadeHouseVOList = |
| | | this.baseMapper.getHouseLevelByUnitNo(houseDO.getAlley(), houseDO.getHouseNum(), |
| | | houseDO.getFloor(), cascadeHouseDTO.getCommunityId(), cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream() |
| | | .collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing( |
| | | o -> o.getAlley() + ";" + o.getHouseNum() + ";" + o.getFloor() + ";" + o.getUnitNo()))), |
| | | ArrayList::new)); |
| | | cascadeHouseVOList.forEach(cascade -> { |
| | | cascade.setName(cascade.getUnitNo()); |
| | | }); |
| | |
| | | break; |
| | | case 5: |
| | | if(houseDO != null) { |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByHouseNo(houseDO.getAlley(), houseDO.getHouseNum(), houseDO.getFloor(), houseDO.getUnitNo(), cascadeHouseDTO.getCommunityId(),cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" + o.getHouseNum() + ";" + o.getFloor() + ";" + o.getUnitNo() + ";" + o.getHouseNo()))), ArrayList::new)); |
| | | cascadeHouseVOList = this.baseMapper.getHouseLevelByHouseNo(houseDO.getAlley(), |
| | | houseDO.getHouseNum(), houseDO.getFloor(), houseDO.getUnitNo(), |
| | | cascadeHouseDTO.getCommunityId(), cascadeHouseDTO.getVillageId()); |
| | | cascadeHouseVOList = cascadeHouseVOList.stream() |
| | | .collect(Collectors.collectingAndThen( |
| | | Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getAlley() + ";" |
| | | + o.getHouseNum() + ";" + o.getFloor() + ";" + o.getUnitNo() + ";" + o.getHouseNo()))), |
| | | ArrayList::new)); |
| | | cascadeHouseVOList.forEach(cascade -> { |
| | | cascade.setName(cascade.getHouseNo()); |
| | | }); |
| | |
| | | |
| | | /** |
| | | * 分页查询房屋列表 |
| | | * @param populationHouseAdminDTO 请求参数 |
| | | * |
| | | * @param populationHouseAdminDTO |
| | | * 请求参数 |
| | | * @return 房屋列表 |
| | | */ |
| | | @Override |
| | |
| | | } |
| | | } |
| | | } |
| | | return R.ok(this.baseMapper.getPageHouse(new Page(populationHouseAdminDTO.getPageNum(),populationHouseAdminDTO.getPageSize()),populationHouseAdminDTO)); |
| | | return R.ok(this.baseMapper.getPageHouse( |
| | | new Page(populationHouseAdminDTO.getPageNum(), populationHouseAdminDTO.getPageSize()), |
| | | populationHouseAdminDTO)); |
| | | } |
| | | |
| | | /** |
| | | * 根据id查询实有房屋信息 |
| | | * @param houseId 房屋id |
| | | * |
| | | * @param houseId |
| | | * 房屋id |
| | | * @return 房屋信息 |
| | | */ |
| | | @Override |
| | |
| | | ComMngPopulationHouseDetailAdminVO houseDetailAdminVO = this.baseMapper.getHouseDetail(houseId); |
| | | if(houseDetailAdminVO != null){ |
| | | //查询房屋下住户信息 |
| | | List<ComMngPopulationHouseUserAdminVO> houseUserList = comMngPopulationHouseUserDAO.getHouseUserByHouseId(houseDetailAdminVO.getId()); |
| | | List<ComMngPopulationHouseUserAdminVO> houseUserList = |
| | | comMngPopulationHouseUserDAO.getHouseUserByHouseId(houseDetailAdminVO.getId()); |
| | | if(!houseUserList.isEmpty()){ |
| | | houseDetailAdminVO.setHouseUserList(houseUserList); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 编辑实有房屋信息 |
| | | * @param houseEditAdminDTO 请求参数 |
| | | * |
| | | * @param houseEditAdminDTO |
| | | * 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 根据房屋id列表删除房屋信息 |
| | | * @param Ids 请求参数 |
| | | * |
| | | * @param Ids |
| | | * 请求参数 |
| | | * @return 删除结果 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 实有房屋统计 |
| | | * @param communityId 社区id |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 统计结果 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询社区所有省市区 |
| | | * @param communityId 社区id |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 社区所在省市区 |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 小区楼栋下房屋列表 |
| | | * @param buildHouseAppDTO 请求参数 |
| | | * |
| | | * @param buildHouseAppDTO |
| | | * 请求参数 |
| | | * @return 房屋列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingHouseList(PageComMngVillageBuildHouseAppDTO buildHouseAppDTO){ |
| | | |
| | | IPage<ComMngVillageBuildingHouseVO> buildingHouseVOIPage = this.baseMapper.getGridVillageBuildingHouseList(new Page(buildHouseAppDTO.getPageNum(),buildHouseAppDTO.getPageSize()),buildHouseAppDTO); |
| | | IPage<ComMngVillageBuildingHouseVO> buildingHouseVOIPage = this.baseMapper.getGridVillageBuildingHouseList( |
| | | new Page(buildHouseAppDTO.getPageNum(), buildHouseAppDTO.getPageSize()), buildHouseAppDTO); |
| | | if(!buildingHouseVOIPage.getRecords().isEmpty()){ |
| | | buildingHouseVOIPage.getRecords().forEach(house ->{ |
| | | boolean result=house.getHouseNo().matches("[0-9]+"); |
| | |
| | | |
| | | /** |
| | | * 小区楼栋下房屋信息 |
| | | * @param houseId 房屋id |
| | | * |
| | | * @param houseId |
| | | * 房屋id |
| | | * @return 房屋信息 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingHouseDetail(Long houseId){ |
| | | |
| | | ComMngVillageBuildingHouseDetailVO buildingHouseDetailVO = this.baseMapper.getGridVillageBuildingHouseDetail(houseId); |
| | | ComMngVillageBuildingHouseDetailVO buildingHouseDetailVO = |
| | | this.baseMapper.getGridVillageBuildingHouseDetail(houseId); |
| | | if(buildingHouseDetailVO != null){ |
| | | |
| | | //转换楼层数 |
| | |
| | | } |
| | | |
| | | //查询该房屋的户主信息 |
| | | List<PopulationListVO> householderList = this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(),1,null); |
| | | List<PopulationListVO> householderList = |
| | | this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(), 1, null); |
| | | if(!householderList.isEmpty()){ |
| | | householderList.forEach(householder -> { |
| | | try { |
| | |
| | | buildingHouseDetailVO.setHouseholderList(householderList); |
| | | } |
| | | //查询该房屋的住户信息 |
| | | List<PopulationListVO> populationList = this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(),null,1); |
| | | List<PopulationListVO> populationList = |
| | | this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(), null, 1); |
| | | if(!populationList.isEmpty()){ |
| | | populationList.forEach(population -> { |
| | | try { |
| | |
| | | return R.ok(buildingHouseDetailVO); |
| | | } |
| | | |
| | | private static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) { |
| | | Map<Object, Boolean> seen = new ConcurrentHashMap<>(); |
| | | return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; |
| | | } |
| | | |
| | | @Override |
| | | public R subordinate(ComMngPopulationSubordinateDTO subordinateDTO){ |
| | | |
| | |
| | | switch (subordinateDTO.getType()){ |
| | | case 1: |
| | | subordinateList = this.baseMapper.getHouseLevelByFloors(subordinateDTO.getVillageId()); |
| | | // subordinateList = subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getFloor()))), ArrayList::new)); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getFloor)).collect(Collectors.toList()); |
| | | // subordinateList = |
| | | // subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new |
| | | // TreeSet<>(Comparator.comparing(o -> o.getFloor()))), ArrayList::new)); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getFloor)) |
| | | .collect(Collectors.toList()); |
| | | subordinateList.forEach(cascade -> { |
| | | if(cascade.getFloor().contains("栋")){ |
| | | cascade.setName(cascade.getFloor()); |
| | |
| | | break; |
| | | case 2: |
| | | if(houseDO != null){ |
| | | subordinateList = this.baseMapper.getHouseLevelByUnitNos(houseDO.getVillageId(),houseDO.getFloor()); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getUnitNo)).collect(Collectors.toList()); |
| | | // subordinateList = subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getUnitNo()))), ArrayList::new)); |
| | | subordinateList = |
| | | this.baseMapper.getHouseLevelByUnitNos(houseDO.getVillageId(), houseDO.getFloor()); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getUnitNo)) |
| | | .collect(Collectors.toList()); |
| | | // subordinateList = |
| | | // subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new |
| | | // TreeSet<>(Comparator.comparing(o -> o.getUnitNo()))), ArrayList::new)); |
| | | subordinateList.forEach(cascade -> { |
| | | if(cascade.getUnitNo().contains("单元")){ |
| | | cascade.setName(cascade.getUnitNo()); |
| | |
| | | break; |
| | | case 3: |
| | | if(houseDO != null) { |
| | | subordinateList = this.baseMapper.getHouseLevelByHouseNos(houseDO.getVillageId(), houseDO.getFloor(), houseDO.getUnitNo()); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getHouseNo)).collect(Collectors.toList()); |
| | | // subordinateList = subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getHouseNo()))), ArrayList::new)); |
| | | subordinateList = this.baseMapper.getHouseLevelByHouseNos(houseDO.getVillageId(), |
| | | houseDO.getFloor(), houseDO.getUnitNo()); |
| | | subordinateList = subordinateList.stream().filter(distinctByKey(ComMngSubordinateVO::getHouseNo)) |
| | | .collect(Collectors.toList()); |
| | | // subordinateList = |
| | | // subordinateList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new |
| | | // TreeSet<>(Comparator.comparing(o -> o.getHouseNo()))), ArrayList::new)); |
| | | subordinateList.forEach(cascade -> { |
| | | cascade.setName(cascade.getHouseNo()); |
| | | }); |
| | |
| | | comMngPopulationDAO.updateById(populationDO); |
| | | |
| | | //添加房屋关系 |
| | | ComMngPopulationHouseUserDO houseUserDO = comMngPopulationHouseUserDAO.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>() |
| | | .lambda().eq(ComMngPopulationHouseUserDO::getPopulId,population).eq(ComMngPopulationHouseUserDO::getHouseId,relationHouseDTO.getHouseId())); |
| | | ComMngPopulationHouseUserDO houseUserDO = |
| | | comMngPopulationHouseUserDAO.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>().lambda() |
| | | .eq(ComMngPopulationHouseUserDO::getPopulId, population) |
| | | .eq(ComMngPopulationHouseUserDO::getHouseId, relationHouseDTO.getHouseId())); |
| | | if(houseUserDO == null){ |
| | | houseUserDO = new ComMngPopulationHouseUserDO(); |
| | | houseUserDO.setId(Snowflake.getId()); |