| | |
| | | import javax.annotation.Resource; |
| | | import java.io.OutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @Override |
| | | public IPage<UserTopicsVO> selectUserTopicsPage(IPage<UserTopicsVO> page, UserTopicsVO userTopics) { |
| | | if (StringUtils.isNotBlank(userTopics.getDistrictId())) { |
| | | List<String> longs = JSON.parseArray(userTopics.getDistrictId()).toJavaList(String.class); |
| | | List<String> longs = Arrays.asList(userTopics.getDistrictId().split(",")); |
| | | IDistrictService bean = SpringUtils.getBean(IDistrictService.class); |
| | | List<DistrictEntity> list = bean.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, longs)); |
| | | List<String> collect = list.stream().map(item -> |
| | |
| | | @Override |
| | | public List<UserTopicsExcel> exportUser(UserTopicsVO userTopics) { |
| | | if (StringUtils.isNotBlank(userTopics.getDistrictId())) { |
| | | List<String> longs = JSON.parseArray(userTopics.getDistrictId()).toJavaList(String.class); |
| | | List<String> longs = Arrays.asList(userTopics.getDistrictId().split(",")); |
| | | IDistrictService bean = SpringUtils.getBean(IDistrictService.class); |
| | | List<DistrictEntity> list = bean.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, longs)); |
| | | List<String> collect = list.stream().map(item -> |
| | |
| | | List<holdExcel> resultList = new ArrayList<>(); |
| | | try { |
| | | // 检查区域ID字符串是否有效 |
| | | JSONArray objects1 = validateAndParseDistrictId(userTopics.getDistrictId()); |
| | | List<String> strings = validateAndParseDistrictId(userTopics.getDistrictId()); |
| | | // 获取区域服务和话题服务的实例 |
| | | IDistrictService districtService = SpringUtils.getBean(IDistrictService.class); |
| | | ITopicsService topicsService = SpringUtils.getBean(ITopicsService.class); |
| | | // 处理区域ID并查询对应的区域实体列表 |
| | | List<String> aoiCodeList = processDistrictIds(districtService, objects1); |
| | | List<String> aoiCodeList = processDistrictIds(districtService, strings); |
| | | // 设置AOI代码列表到用户话题对象中 |
| | | userTopics.setAoiCodeList(aoiCodeList); |
| | | // 查询并处理房屋列表信息 |
| | |
| | | * @return 返回一个JSONArray对象,包含解析后的区域ID。 |
| | | * @throws IllegalArgumentException 如果区域ID字符串为空或空白字符串,抛出此异常。 |
| | | */ |
| | | private JSONArray validateAndParseDistrictId(String districtIdStr) throws IllegalArgumentException { |
| | | private List<String> validateAndParseDistrictId(String districtIdStr) throws IllegalArgumentException { |
| | | // 验证区域ID字符串是否为空 |
| | | if (StringUtils.isBlank(districtIdStr)) { |
| | | throw new IllegalArgumentException("区域ID不能为空"); |
| | | } |
| | | // 解析区域ID字符串为JSONArray对象 |
| | | return JSON.parseArray(districtIdStr); |
| | | return Arrays.asList(districtIdStr.split(",")); |
| | | } |
| | | |
| | | private List<String> processDistrictIds(IDistrictService districtService, JSONArray districtIds) { |
| | | private List<String> processDistrictIds(IDistrictService districtService, List<String> districtIds) { |
| | | List<String> collect1 = districtIds.stream().map(item -> (String) item).collect(Collectors.toList()); |
| | | List<DistrictEntity> list3 = districtService.list(Wrappers.<DistrictEntity>lambdaQuery().in(DistrictEntity::getId, collect1)); |
| | | return list3.stream().map(item -> item.getAoiCode()).collect(Collectors.toList()); |