| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.logging.log4j.util.Strings; |
| | | import org.springblade.common.cache.SysCache; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.node.TreeStringNode; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.ComplexNumberStringComparator; |
| | | import org.springblade.common.utils.NodeTreeUtil; |
| | | import org.springblade.common.utils.SpringUtils; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.modules.backblast.entity.BackblastPubRecordEntity; |
| | | import org.springblade.modules.category.dto.CategoryDTO; |
| | | import org.springblade.modules.category.service.ICategoryService; |
| | | import org.springblade.modules.community.entity.CommunityEntity; |
| | |
| | | import org.springblade.modules.doorplateAddress.vo.DoorplateAddressVOTree; |
| | | import org.springblade.modules.doorplateAddress.vo.FuncNode; |
| | | 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.service.IGridRangeService; |
| | | import org.springblade.modules.grid.service.IGridService; |
| | | import org.springblade.modules.grid.service.IGridmanService; |
| | | import org.springblade.modules.house.entity.HouseEntity; |
| | | import org.springblade.modules.house.entity.UserHouseLabelEntity; |
| | | import org.springblade.modules.house.service.IHouseRentalService; |
| | | import org.springblade.modules.house.service.IHouseService; |
| | | import org.springblade.modules.house.service.IHouseholdService; |
| | | import org.springblade.modules.house.service.IUserHouseLabelService; |
| | | import org.springblade.modules.house.vo.HouseParam; |
| | | import org.springblade.modules.house.vo.HouseRentalVO; |
| | | import org.springblade.modules.house.vo.HouseholdVO; |
| | |
| | | import org.springblade.modules.place.service.IPlaceExtService; |
| | | import org.springblade.modules.place.service.IPlaceService; |
| | | import org.springblade.modules.place.vo.PlaceVO; |
| | | import org.springblade.modules.police.entity.PoliceAffairsGridEntity; |
| | | import org.springblade.modules.police.service.IPoliceAffairsGridService; |
| | | import org.springblade.modules.system.entity.Region; |
| | | import org.springblade.modules.system.service.IRegionService; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | } |
| | | if (roleName.equals("民警")) { |
| | | // 查询对应的社区编号 |
| | | communityList = policeAffairsGridService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | communityList = SysCache.getPoliceRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | } |
| | | } |
| | | // 查询街道 |
| | |
| | | }); |
| | | // 排序 |
| | | sortUnit(tempList, list); |
| | | // List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getUnitName())).collect(Collectors.toList()); |
| | | // list.addAll(sortList); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } else if (funcNode.getUnitName().contains("六")) { |
| | | funcNode.setSort(6); |
| | | } else { |
| | | funcNode.setSort(1); |
| | | if (!containsNumber(funcNode.getUnitName())) { |
| | | funcNode.setSort(1); |
| | | } else { |
| | | funcNode.setSort(getNumber(funcNode.getUnitName())); |
| | | } |
| | | } |
| | | } |
| | | // 排序 |
| | | List<FuncNode> sortList = tempList.stream().sorted(Comparator.comparing(X -> X.getSort())).collect(Collectors.toList()); |
| | | list.addAll(sortList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 判断是否包含数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static boolean containsNumber(String str) { |
| | | Pattern pattern = Pattern.compile(".*\\d+.*"); |
| | | Matcher matcher = pattern.matcher(str); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | /** |
| | | * 取出字符串中的数字 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | | public static int getNumber(String str) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (char c : str.toCharArray()) { |
| | | if (Character.isDigit(c)) { |
| | | sb.append(c); |
| | | } |
| | | } |
| | | return Integer.parseInt(sb.toString()); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if (houseParam.getRoleName().equals("网格员") && !userId.equals("1726859808689696770")) { |
| | | // 查询对应的房屋地址code |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | stringList = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),null); |
| | | } |
| | | } |
| | | return stringList; |
| | |
| | | houseParam.setUserId(userId); |
| | | if (null != houseParam.getRoleName() && !houseParam.getRoleName().equals("")) { |
| | | if (houseParam.getRoleName().equals("民警") && !userId.equals("1726859808689696770")) { |
| | | // 查询对应的房屋地址code |
| | | stringList = policeAffairsGridService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | // 查询对应社区编号集合 |
| | | stringList = SysCache.getPoliceRegionChildCodesByDeptId(AuthUtil.getDeptId()); |
| | | } |
| | | } |
| | | return stringList; |
| | |
| | | private void handleHouseData(String townName) { |
| | | // 查询总数 |
| | | Integer count = baseMapper.getNotHouseListCount(townName); |
| | | if (count>0) { |
| | | int num = count/1000; |
| | | for (int i = 0; i <= num+1; i++) { |
| | | if (count > 0) { |
| | | int num = count / 1000; |
| | | for (int i = 0; i <= num + 1; i++) { |
| | | // 查询所有户室数据(未入库的) |
| | | List<DoorplateAddressEntity> list = baseMapper.getHouseList(townName); |
| | | // 需要新增的房屋 list |
| | |
| | | houseEntity.setUpdateTime(new Date()); |
| | | // 设置来源 1:地址总表 2:国控采集 |
| | | houseEntity.setSource(1); |
| | | // 根据位置设置网格,警格编号 |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | houseEntity.setGridId(gridEntity.getId()); |
| | | houseEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | //点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | houseEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | // 加入集合 |
| | | houseList.add(houseEntity); |
| | | } |
| | |
| | | // 加入集合 |
| | | districtService.save(districtEntity); |
| | | // aoiList.add(districtEntity); |
| | | }else { |
| | | } else { |
| | | // 更新 |
| | | one.setCommunityCode(addressEntity.getNeiCode()); |
| | | one.setAoiCode(addressEntity.getAoiCode()); |
| | |
| | | for (DoorplateAddressEntity addressEntity : list) { |
| | | // pio 名称不为空的进行插入操作 |
| | | // if (!Strings.isBlank(addressEntity.getPoi())) { |
| | | PlaceEntity placeEntity = new PlaceEntity(); |
| | | placeEntity.setHouseCode(addressEntity.getAddressCode()); |
| | | placeEntity.setPlaceName(addressEntity.getPoi()); |
| | | placeEntity.setLng(addressEntity.getX()); |
| | | placeEntity.setLat(addressEntity.getY()); |
| | | placeEntity.setLocation(addressEntity.getAddressName()); |
| | | // 设置来源( 1:地址总表 2:国控采集 3:商超) |
| | | placeEntity.setSource(1); |
| | | // 待完善 |
| | | placeEntity.setStatus(1); |
| | | // 默认为非九小场所 |
| | | placeEntity.setIsNine(2); |
| | | // 默认为现场采集 |
| | | placeEntity.setIsScene(1); |
| | | // 加入集合 |
| | | PlaceEntity placeEntity = new PlaceEntity(); |
| | | placeEntity.setHouseCode(addressEntity.getAddressCode()); |
| | | placeEntity.setPlaceName(addressEntity.getPoi()); |
| | | placeEntity.setLng(addressEntity.getX()); |
| | | placeEntity.setLat(addressEntity.getY()); |
| | | placeEntity.setLocation(addressEntity.getAddressName()); |
| | | // 设置来源( 1:地址总表 2:国控采集 3:商超) |
| | | placeEntity.setSource(1); |
| | | // 待完善 |
| | | placeEntity.setStatus(1); |
| | | // 默认为非九小场所 |
| | | placeEntity.setIsNine(2); |
| | | // 默认为现场采集 |
| | | placeEntity.setIsScene(1); |
| | | // 根据位置设置网格,警格编号 |
| | | String point = "'POINT(" + addressEntity.getX() + " " + addressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | placeEntity.setGridId(gridEntity.getId()); |
| | | placeEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | //点坐标解析警格 |
| | | List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | if (policeAffairsGridEntityList.size()>0){ |
| | | PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | placeEntity.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | } |
| | | // 加入集合 |
| | | // placeList.add(placeEntity); |
| | | // 保存 |
| | | placeService.save(placeEntity); |
| | | // 新增场所详情 |
| | | savePlaceExtAndTaskInfo(placeEntity); |
| | | // 保存 |
| | | placeService.save(placeEntity); |
| | | // 新增场所详情 |
| | | savePlaceExtAndTaskInfo(placeEntity); |
| | | // } |
| | | } |
| | | // 批量插入 |
| | |
| | | |
| | | /** |
| | | * 新增场所详情 |
| | | * |
| | | * @param placeEntity |
| | | */ |
| | | public void savePlaceExtAndTaskInfo(PlaceEntity placeEntity) { |
| | |
| | | placeExtEntity.setPlaceId(placeEntity.getId()); |
| | | // 判断是否已存在,已存在则不新增 |
| | | QueryWrapper<PlaceExtEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("is_deleted",0) |
| | | .eq("place_id",placeEntity.getId()); |
| | | wrapper.eq("is_deleted", 0) |
| | | .eq("place_id", placeEntity.getId()); |
| | | PlaceExtEntity one = placeExtService.getOne(wrapper); |
| | | if (null == one) { |
| | | placeExtEntity.setPlaceId(placeEntity.getId()); |
| | |
| | | public Object getDetail(DoorplateAddressVO doorplateAddress) { |
| | | List<String> list = new ArrayList<>(); |
| | | // 扫码时调用,需判断是否有权限查看 |
| | | DoorplateAddressVO one = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null != one) { |
| | | DoorplateAddressVO doorplateAddressVO = baseMapper.getDoorplateAddressVODetail(doorplateAddress); |
| | | if (null != doorplateAddressVO) { |
| | | // 不限制 |
| | | one.setIsJur(1); |
| | | doorplateAddressVO.setIsJur(1); |
| | | if (!Strings.isBlank(doorplateAddress.getRoleName())) { |
| | | // 判断是否有权限 |
| | | if (doorplateAddress.getRoleName().equals("网格员")) { |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId()); |
| | | boolean contains = list.contains(doorplateAddress.getAddressCode()); |
| | | if (list.size() == 0 || !contains) { |
| | | list = gridService.getAddressCodeListByUserId(AuthUtil.getUserId(),doorplateAddress.getAddressCode()); |
| | | if (list.size() == 0) { |
| | | // 无权限 |
| | | one.setIsJur(2); |
| | | doorplateAddressVO.setIsJur(2); |
| | | } else { |
| | | one.setIsJur(1); |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } else if (doorplateAddress.getRoleName().equals("民警")) { |
| | | // 无权限 |
| | | one.setIsJur(2); |
| | | doorplateAddressVO.setIsJur(2); |
| | | // 查询对应的社区code |
| | | list = policeAffairsGridService.getCommunityCodeListByUserId(AuthUtil.getUserId()); |
| | | if (null!=list && list.size()>0){ |
| | | boolean contains = list.contains(one.getNeiCode()); |
| | | if (null != list && list.size() > 0) { |
| | | boolean contains = list.contains(doorplateAddressVO.getNeiCode()); |
| | | if (contains) { |
| | | one.setIsJur(1); |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } |
| | | } else { |
| | | // 不限制 |
| | | one.setIsJur(1); |
| | | doorplateAddressVO.setIsJur(1); |
| | | } |
| | | } |
| | | return one; |
| | | if(doorplateAddressVO != null ){ |
| | | // 获取房屋标签 |
| | | IUserHouseLabelService userHouseLabelService = SpringUtils.getBean(IUserHouseLabelService.class); |
| | | List<UserHouseLabelEntity> houseLabelEntityList = userHouseLabelService.list(Wrappers.<UserHouseLabelEntity>lambdaQuery() |
| | | .eq(UserHouseLabelEntity::getHouseCode, doorplateAddressVO.getAddressCode()) |
| | | .eq(UserHouseLabelEntity::getLableType, 2)); |
| | | doorplateAddressVO.setUserHouseLabelVOList(houseLabelEntityList); |
| | | } |
| | | return doorplateAddressVO; |
| | | } |
| | | return null; |
| | | } |
| | |
| | | |
| | | /** |
| | | * 查询场所标准地址数据 |
| | | * |
| | | * @param doorplateAddress |
| | | * @param size |
| | | * @return |
| | |
| | | @Override |
| | | public Object getPlaceList(DoorplateAddressVO doorplateAddress, Integer size) { |
| | | // 公共参数设置 |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(DoorplateAddressVO.class,doorplateAddress); |
| | | CommonParamSet commonParamSet = new CommonParamSet().invoke(DoorplateAddressVO.class, doorplateAddress); |
| | | return baseMapper.getPlaceList(doorplateAddress, |
| | | null==size?10:size, |
| | | null == size ? 10 : size, |
| | | commonParamSet.getGridCodeList(), |
| | | commonParamSet.getRegionChildCodesList(), |
| | | commonParamSet.getIsAdministrator() |
| | | ); |
| | | ); |
| | | } |
| | | |
| | | /** |
| | | * 通过小区id 查询楼栋编码 |
| | | * |
| | | * @param districtId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<DoorplateAddressVO> getHouseBuildingCode(String districtId) { |
| | | public List<DoorplateAddressVO> getHouseBuildingCode(String districtId) { |
| | | return baseMapper.getHouseBuildingCode(districtId); |
| | | } |
| | | |
| | | /** |
| | | * 网格范围数据处理 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean gridRangeDataHandle(String townName,String communityName) { |
| | | // 查询未匹配的网格范围地址信息 |
| | | // 查询总数 |
| | | Integer count = baseMapper.getNotBindGridRangeDoorListCount(townName,communityName); |
| | | if (count > 0) { |
| | | IGridRangeService gridRangeService = SpringUtils.getBean(IGridRangeService.class); |
| | | int num = count / 1000; |
| | | for (int i = 0; i <= num + 1; i++) { |
| | | // 查询所有未匹配的网格范围地址数据 |
| | | List<DoorplateAddressEntity> list = baseMapper.getNotBindGridRangeDoorList(townName,communityName); |
| | | // 需要新增的网格范围 list |
| | | List<GridRangeEntity> gridRangeEntityList = new ArrayList<>(); |
| | | // 处理户室数据 |
| | | for (DoorplateAddressEntity doorplateAddressEntity : list) { |
| | | // 查询是否已存在,存在就插入,不存在则插入 |
| | | QueryWrapper<GridRangeEntity> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("house_code", doorplateAddressEntity.getAddressCode()); |
| | | GridRangeEntity one = gridRangeService.getOne(wrapper); |
| | | if (null == one) { |
| | | // 设置网格 |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridRangeEntity gridRangeEntity = new GridRangeEntity(); |
| | | gridRangeEntity.setHouseCode(doorplateAddressEntity.getAddressCode()); |
| | | gridRangeEntity.setDistrictCode(doorplateAddressEntity.getAoiCode()); |
| | | gridRangeEntity.setBuilding(doorplateAddressEntity.getBuildingCode()); |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | // 加入集合 |
| | | gridRangeEntityList.add(gridRangeEntity); |
| | | } |
| | | } |
| | | } |
| | | // 批量插入 |
| | | gridRangeService.saveBatch(gridRangeEntityList); |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | | * 设置警格网格信息 |
| | | * @param doorplateAddressEntity |
| | | */ |
| | | public void setGridInfo(DoorplateAddressEntity doorplateAddressEntity,GridRangeEntity gridRangeEntity) { |
| | | // 根据位置设置网格,警格编号 |
| | | // IPoliceAffairsGridService policeAffairsGridService = SpringUtils.getBean(IPoliceAffairsGridService.class); |
| | | String point = "'POINT(" + doorplateAddressEntity.getX() + " " + doorplateAddressEntity.getY() + ")'"; |
| | | //点坐标解析网格 |
| | | List<GridEntity> gridEntityList = gridService.spatialAnalysis(point); |
| | | if (gridEntityList.size()>0){ |
| | | GridEntity gridEntity = gridEntityList.get(0); |
| | | gridRangeEntity.setGridId(gridEntity.getId()); |
| | | gridRangeEntity.setGridCode(gridEntity.getGridCode()); |
| | | } |
| | | // //点坐标解析警格 |
| | | // List<PoliceAffairsGridEntity> policeAffairsGridEntityList = policeAffairsGridService.spatialAnalysis(point); |
| | | // if (policeAffairsGridEntityList.size()>0){ |
| | | // PoliceAffairsGridEntity policeAffairsGridEntity = policeAffairsGridEntityList.get(0); |
| | | // backblastPubRecord.setJwGridCode(policeAffairsGridEntity.getJwGridCode()); |
| | | // } |
| | | } |
| | | } |