| | |
| | | |
| | | @Override |
| | | public PageInfo<XpElectronicFence> pageList(ElectronicPageListQuery query) { |
| | | if (query == null) { |
| | | return new PageInfo<>(); |
| | | } |
| | | normalizeProhibitedAreaCountFilter(query); |
| | | PageInfo<XpElectronicFence> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | if (StringUtils.isEmpty(query.getCreateSort())&& StringUtils.isEmpty(query.getUpdateSort())){ |
| | | query.setCreateSort("2"); |
| | |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | private void normalizeProhibitedAreaCountFilter(ElectronicPageListQuery query) { |
| | | Integer prohibitedAreaCountMin = query.getProhibitedAreaCountMin(); |
| | | Integer prohibitedAreaCountMax = query.getProhibitedAreaCountMax(); |
| | | if (prohibitedAreaCountMin != null || prohibitedAreaCountMax != null) { |
| | | if (prohibitedAreaCountMin != null && prohibitedAreaCountMax != null) { |
| | | int min = Math.min(prohibitedAreaCountMin, prohibitedAreaCountMax); |
| | | int max = Math.max(prohibitedAreaCountMin, prohibitedAreaCountMax); |
| | | if (min < 0) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | query.setProhibitedAreaCountMin(min); |
| | | query.setProhibitedAreaCountMax(max); |
| | | query.setElectronicAreaId(null); |
| | | return; |
| | | } |
| | | if (prohibitedAreaCountMin != null) { |
| | | if (prohibitedAreaCountMin < 0) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | query.setElectronicAreaId(null); |
| | | return; |
| | | } |
| | | if (prohibitedAreaCountMax < 0) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | query.setElectronicAreaId(null); |
| | | return; |
| | | } |
| | | |
| | | String electronicAreaId = query.getElectronicAreaId(); |
| | | if (StringUtils.isEmpty(electronicAreaId)) { |
| | | return; |
| | | } |
| | | try { |
| | | if (electronicAreaId.contains(",")) { |
| | | String[] parts = electronicAreaId.split(","); |
| | | if (parts.length != 2) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | int left = Integer.parseInt(parts[0].trim()); |
| | | int right = Integer.parseInt(parts[1].trim()); |
| | | int min = Math.min(left, right); |
| | | int max = Math.max(left, right); |
| | | if (min < 0) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | query.setProhibitedAreaCountMin(min); |
| | | query.setProhibitedAreaCountMax(max); |
| | | query.setElectronicAreaId(null); |
| | | return; |
| | | } |
| | | int threshold = Integer.parseInt(electronicAreaId.trim()); |
| | | if (threshold < 0 || threshold == Integer.MAX_VALUE) { |
| | | clearAreaFilter(query); |
| | | return; |
| | | } |
| | | query.setProhibitedAreaCountMin(threshold + 1); |
| | | query.setProhibitedAreaCountMax(null); |
| | | query.setElectronicAreaId(null); |
| | | } catch (Exception e) { |
| | | clearAreaFilter(query); |
| | | } |
| | | } |
| | | |
| | | private void clearAreaFilter(ElectronicPageListQuery query) { |
| | | query.setElectronicAreaId(null); |
| | | query.setProhibitedAreaCountMin(null); |
| | | query.setProhibitedAreaCountMax(null); |
| | | } |
| | | public static String getPinyinInitials(String chinese) { |
| | | StringBuilder pinyinInitials = new StringBuilder(); |
| | | for (char c : chinese.toCharArray()) { |