| | |
| | | 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 请求参数 |
| | | * @return 菜单列表 |
| | | * |
| | | * @param cascadeHouseDTO |
| | | * 请求参数 |
| | | * @return 菜单列表 |
| | | */ |
| | | @Override |
| | | public R getCascadeHouseAddress(CascadeHouseDTO cascadeHouseDTO){ |
| | | public R getCascadeHouseAddress(CascadeHouseDTO cascadeHouseDTO) { |
| | | List<ComMngCascadeHouseVO> cascadeHouseVOList = new ArrayList<>(); |
| | | |
| | | ComMngPopulationHouseDO houseDO = null; |
| | | if(cascadeHouseDTO.getHouseId() != null){ |
| | | if (cascadeHouseDTO.getHouseId() != null) { |
| | | houseDO = this.baseMapper.selectById(cascadeHouseDTO.getHouseId()); |
| | | } |
| | | |
| | | switch (cascadeHouseDTO.getLevel()){ |
| | | 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()); |
| | | }); |
| | | }); |
| | | break; |
| | | case 2: |
| | | if(houseDO != null){ |
| | | 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()); |
| | | }); |
| | | } |
| | | break; |
| | | case 3: |
| | | if(houseDO != null) { |
| | | 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)); |
| | | 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.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)); |
| | | 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.forEach(cascade -> { |
| | | cascade.setName(cascade.getHouseNo()); |
| | | }); |
| | |
| | | |
| | | /** |
| | | * 分页查询房屋列表 |
| | | * @param populationHouseAdminDTO 请求参数 |
| | | * @return 房屋列表 |
| | | * |
| | | * @param populationHouseAdminDTO |
| | | * 请求参数 |
| | | * @return 房屋列表 |
| | | */ |
| | | @Override |
| | | public R getPageHouse(ComMngPopulationHouseAdminDTO populationHouseAdminDTO){ |
| | | public R getPageHouse(ComMngPopulationHouseAdminDTO populationHouseAdminDTO) { |
| | | |
| | | if(populationHouseAdminDTO.getHouseId() != null){ |
| | | if (populationHouseAdminDTO.getHouseId() != null) { |
| | | ComMngPopulationHouseDO houseDO = this.baseMapper.selectById(populationHouseAdminDTO.getHouseId()); |
| | | if(houseDO != null){ |
| | | switch (populationHouseAdminDTO.getLevel()){ |
| | | if (houseDO != null) { |
| | | switch (populationHouseAdminDTO.getLevel()) { |
| | | case 1: |
| | | populationHouseAdminDTO.setRoad(houseDO.getAlley()); |
| | | break; |
| | |
| | | } |
| | | } |
| | | } |
| | | 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 |
| | | * @return 房屋信息 |
| | | * |
| | | * @param houseId |
| | | * 房屋id |
| | | * @return 房屋信息 |
| | | */ |
| | | @Override |
| | | public R getHouseDetail(Long houseId){ |
| | | public R getHouseDetail(Long houseId) { |
| | | ComMngPopulationHouseDetailAdminVO houseDetailAdminVO = this.baseMapper.getHouseDetail(houseId); |
| | | if(houseDetailAdminVO != null){ |
| | | //查询房屋下住户信息 |
| | | List<ComMngPopulationHouseUserAdminVO> houseUserList = comMngPopulationHouseUserDAO.getHouseUserByHouseId(houseDetailAdminVO.getId()); |
| | | if(!houseUserList.isEmpty()){ |
| | | if (houseDetailAdminVO != null) { |
| | | // 查询房屋下住户信息 |
| | | List<ComMngPopulationHouseUserAdminVO> houseUserList = |
| | | comMngPopulationHouseUserDAO.getHouseUserByHouseId(houseDetailAdminVO.getId()); |
| | | if (!houseUserList.isEmpty()) { |
| | | houseDetailAdminVO.setHouseUserList(houseUserList); |
| | | } |
| | | } |
| | |
| | | |
| | | /** |
| | | * 编辑实有房屋信息 |
| | | * @param houseEditAdminDTO 请求参数 |
| | | * @return 编辑结果 |
| | | * |
| | | * @param houseEditAdminDTO |
| | | * 请求参数 |
| | | * @return 编辑结果 |
| | | */ |
| | | @Override |
| | | public R editHouse(ComMngPopulationHouseEditAdminDTO houseEditAdminDTO){ |
| | | public R editHouse(ComMngPopulationHouseEditAdminDTO houseEditAdminDTO) { |
| | | |
| | | //查询实有房屋信息 |
| | | // 查询实有房屋信息 |
| | | ComMngPopulationHouseDO houseDO = this.baseMapper.selectById(houseEditAdminDTO.getHouseId()); |
| | | if(houseDO == null){ |
| | | if (houseDO == null) { |
| | | return R.fail("参数错误"); |
| | | } |
| | | |
| | | BeanUtils.copyProperties(houseEditAdminDTO,houseDO); |
| | | BeanUtils.copyProperties(houseEditAdminDTO, houseDO); |
| | | houseDO.setUpdateAt(new Date()); |
| | | if(this.baseMapper.updateById(houseDO) > 0){ |
| | | if (this.baseMapper.updateById(houseDO) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据房屋id列表删除房屋信息 |
| | | * @param Ids 请求参数 |
| | | * @return 删除结果 |
| | | * |
| | | * @param Ids |
| | | * 请求参数 |
| | | * @return 删除结果 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R deleteHouses(List<Long> Ids){ |
| | | public R deleteHouses(List<Long> Ids) { |
| | | LambdaQueryWrapper<ComMngPopulationHouseUserDO> paramWrapper = Wrappers.lambdaQuery(); |
| | | paramWrapper.in(ComMngPopulationHouseUserDO::getHouseId, Ids); |
| | | List<ComMngPopulationHouseUserDO> mngPopulationDOList = comMngPopulationHouseUserDAO.selectList(paramWrapper); |
| | |
| | | return R.fail("无法删除,已绑定实有人口!"); |
| | | } |
| | | |
| | | if(this.baseMapper.deleteBatchIds(Ids) > 0){ |
| | | if (this.baseMapper.deleteBatchIds(Ids) > 0) { |
| | | return R.ok(); |
| | | }else{ |
| | | } else { |
| | | return R.fail(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 实有房屋统计 |
| | | * @param communityId 社区id |
| | | * @return 统计结果 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 统计结果 |
| | | */ |
| | | @Override |
| | | public R getHouseTotalByAdmin(Long communityId){ |
| | | public R getHouseTotalByAdmin(Long communityId) { |
| | | ComMngPopulationHouseTotalVO houseTotalVO = new ComMngPopulationHouseTotalVO(); |
| | | if(communityId != null){ |
| | | if (communityId != null) { |
| | | houseTotalVO = this.baseMapper.getHouseTotalByAdmin(communityId); |
| | | } |
| | | return R.ok(houseTotalVO); |
| | |
| | | |
| | | /** |
| | | * 根据社区id查询社区所有省市区 |
| | | * @param communityId 社区id |
| | | * @return 社区所在省市区 |
| | | * |
| | | * @param communityId |
| | | * 社区id |
| | | * @return 社区所在省市区 |
| | | */ |
| | | @Override |
| | | public R getRegion(Long communityId){ |
| | | public R getRegion(Long communityId) { |
| | | return R.ok(this.baseMapper.getRegion(communityId)); |
| | | } |
| | | |
| | | /** |
| | | * 小区楼栋下房屋列表 |
| | | * @param buildHouseAppDTO 请求参数 |
| | | * @return 房屋列表 |
| | | * |
| | | * @param buildHouseAppDTO |
| | | * 请求参数 |
| | | * @return 房屋列表 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingHouseList(PageComMngVillageBuildHouseAppDTO buildHouseAppDTO){ |
| | | public R getGridVillageBuildingHouseList(PageComMngVillageBuildHouseAppDTO 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]+"); |
| | | if(result){//该字段为纯数字 |
| | | if(house.getHouseNo().length() == 4){ |
| | | house.setBuildingNum(house.getHouseNo().substring(0,2).replaceAll("^(0+)", "")); |
| | | }else if(house.getHouseNo().length() == 3){ |
| | | house.setBuildingNum(house.getHouseNo().substring(0,1).replaceAll("^(0+)", "")); |
| | | 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]+"); |
| | | if (result) {// 该字段为纯数字 |
| | | if (house.getHouseNo().length() == 4) { |
| | | house.setBuildingNum(house.getHouseNo().substring(0, 2).replaceAll("^(0+)", "")); |
| | | } else if (house.getHouseNo().length() == 3) { |
| | | house.setBuildingNum(house.getHouseNo().substring(0, 1).replaceAll("^(0+)", "")); |
| | | } |
| | | }else{ |
| | | } else { |
| | | house.setBuildingNum("-"); |
| | | } |
| | | }); |
| | |
| | | |
| | | /** |
| | | * 小区楼栋下房屋信息 |
| | | * @param houseId 房屋id |
| | | * @return 房屋信息 |
| | | * |
| | | * @param houseId |
| | | * 房屋id |
| | | * @return 房屋信息 |
| | | */ |
| | | @Override |
| | | public R getGridVillageBuildingHouseDetail(Long houseId){ |
| | | public R getGridVillageBuildingHouseDetail(Long houseId) { |
| | | |
| | | ComMngVillageBuildingHouseDetailVO buildingHouseDetailVO = this.baseMapper.getGridVillageBuildingHouseDetail(houseId); |
| | | if(buildingHouseDetailVO != null){ |
| | | ComMngVillageBuildingHouseDetailVO buildingHouseDetailVO = |
| | | this.baseMapper.getGridVillageBuildingHouseDetail(houseId); |
| | | if (buildingHouseDetailVO != null) { |
| | | |
| | | //转换楼层数 |
| | | // 转换楼层数 |
| | | String houseNo = buildingHouseDetailVO.getHouseNo(); |
| | | boolean result = houseNo.matches("[0-9]+"); |
| | | if(result){//该字段为纯数字 |
| | | if(houseNo.length() == 4){ |
| | | buildingHouseDetailVO.setBuildingNum(houseNo.substring(0,2).replaceAll("^(0+)", "")); |
| | | }else if(houseNo.length() == 3){ |
| | | buildingHouseDetailVO.setBuildingNum(houseNo.substring(0,1).replaceAll("^(0+)", "")); |
| | | if (result) {// 该字段为纯数字 |
| | | if (houseNo.length() == 4) { |
| | | buildingHouseDetailVO.setBuildingNum(houseNo.substring(0, 2).replaceAll("^(0+)", "")); |
| | | } else if (houseNo.length() == 3) { |
| | | buildingHouseDetailVO.setBuildingNum(houseNo.substring(0, 1).replaceAll("^(0+)", "")); |
| | | } |
| | | }else{ |
| | | } else { |
| | | buildingHouseDetailVO.setBuildingNum("-"); |
| | | } |
| | | |
| | | //查询该房屋的户主信息 |
| | | List<PopulationListVO> householderList = this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(),1,null); |
| | | if(!householderList.isEmpty()){ |
| | | // 查询该房屋的户主信息 |
| | | List<PopulationListVO> householderList = |
| | | this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(), 1, null); |
| | | if (!householderList.isEmpty()) { |
| | | householderList.forEach(householder -> { |
| | | try { |
| | | Integer age = IdcardUtil.getAgeByIdCard(householder.getCardNo()); |
| | | householder.setAge(age); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | log.error("身份证号码转换年龄失败,人员id:" + householder.getId()); |
| | | } |
| | | }); |
| | | buildingHouseDetailVO.setHouseholderList(householderList); |
| | | } |
| | | //查询该房屋的住户信息 |
| | | List<PopulationListVO> populationList = this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(),null,1); |
| | | if(!populationList.isEmpty()){ |
| | | // 查询该房屋的住户信息 |
| | | List<PopulationListVO> populationList = |
| | | this.baseMapper.getGridVillageBuildingPopulationList(buildingHouseDetailVO.getId(), null, 1); |
| | | if (!populationList.isEmpty()) { |
| | | populationList.forEach(population -> { |
| | | try { |
| | | Integer age = IdcardUtil.getAgeByIdCard(population.getCardNo()); |
| | | population.setAge(age); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | log.error("身份证号码转换年龄失败,人员id:" + population.getId()); |
| | | } |
| | | }); |
| | |
| | | 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){ |
| | | public R subordinate(ComMngPopulationSubordinateDTO subordinateDTO) { |
| | | |
| | | List<ComMngSubordinateVO> subordinateList = new ArrayList<>(); |
| | | |
| | | ComMngPopulationHouseDO houseDO = null; |
| | | if(subordinateDTO.getHouseId() != null){ |
| | | if (subordinateDTO.getHouseId() != null) { |
| | | houseDO = this.baseMapper.selectById(subordinateDTO.getHouseId()); |
| | | } |
| | | |
| | | switch (subordinateDTO.getType()){ |
| | | 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("栋")){ |
| | | if (cascade.getFloor().contains("栋")) { |
| | | cascade.setName(cascade.getFloor()); |
| | | }else{ |
| | | } else { |
| | | 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)); |
| | | 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.forEach(cascade -> { |
| | | if(cascade.getUnitNo().contains("单元")){ |
| | | if (cascade.getUnitNo().contains("单元")) { |
| | | cascade.setName(cascade.getUnitNo()); |
| | | }else{ |
| | | } else { |
| | | 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)); |
| | | 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.forEach(cascade -> { |
| | | cascade.setName(cascade.getHouseNo()); |
| | | }); |
| | |
| | | return R.ok(subordinateList); |
| | | } |
| | | |
| | | public R populationRelationHouse(ComMngPopulationRelationHouseDTO relationHouseDTO){ |
| | | public R populationRelationHouse(ComMngPopulationRelationHouseDTO relationHouseDTO) { |
| | | |
| | | if(relationHouseDTO.getPopulationId().isEmpty()){ |
| | | if (relationHouseDTO.getPopulationId().isEmpty()) { |
| | | return R.fail("请选择居民"); |
| | | } |
| | | |
| | | //查询房屋信息 |
| | | // 查询房屋信息 |
| | | ComMngPopulationHouseDO houseDO = comMngPopulationHouseDAO.selectById(relationHouseDTO.getHouseId()); |
| | | if(houseDO == null){ |
| | | if (houseDO == null) { |
| | | return R.fail("未查到房屋信息"); |
| | | } |
| | | |
| | | relationHouseDTO.getPopulationId().forEach(population -> { |
| | | //修改人口信息 |
| | | // 修改人口信息 |
| | | ComMngPopulationDO populationDO = new ComMngPopulationDO(); |
| | | populationDO.setId(population); |
| | | populationDO.setHouseId(houseDO.getId()); |
| | |
| | | populationDO.setHouseNo(houseDO.getHouseNo()); |
| | | comMngPopulationDAO.updateById(populationDO); |
| | | |
| | | //添加房屋关系 |
| | | ComMngPopulationHouseUserDO houseUserDO = comMngPopulationHouseUserDAO.selectOne(new QueryWrapper<ComMngPopulationHouseUserDO>() |
| | | .lambda().eq(ComMngPopulationHouseUserDO::getPopulId,population).eq(ComMngPopulationHouseUserDO::getHouseId,relationHouseDTO.getHouseId())); |
| | | if(houseUserDO == null){ |
| | | // 添加房屋关系 |
| | | 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()); |
| | | houseUserDO.setHouseId(relationHouseDTO.getHouseId()); |
| | | houseUserDO.setPopulId(population); |
| | | houseUserDO.setRelationId(ComMngPopulationHouseUserDO.relationId.zizhu); |
| | | comMngPopulationHouseUserDAO.insert(houseUserDO); |
| | | }else{ |
| | | } else { |
| | | houseUserDO.setRelationId(ComMngPopulationHouseUserDO.relationId.zizhu); |
| | | comMngPopulationHouseUserDAO.updateById(houseUserDO); |
| | | } |