diff --git a/bms-back/bms-admin/src/main/java/com/bms/web/controller/data/PayPostcodeController.java b/bms-back/bms-admin/src/main/java/com/bms/web/controller/data/PayPostcodeController.java index e79e6e3b..2aedd7dd 100644 --- a/bms-back/bms-admin/src/main/java/com/bms/web/controller/data/PayPostcodeController.java +++ b/bms-back/bms-admin/src/main/java/com/bms/web/controller/data/PayPostcodeController.java @@ -46,9 +46,11 @@ public class PayPostcodeController extends BaseController @PreAuthorize("@ss.hasPermi('data:payPostcode:query')") @GetMapping("/zones") - public AjaxResult zones(PayPostcodeGroup query) + public TableDataInfo zones(PayPostcodeGroup query) { - return success(payPostcodeService.selectZoneList(query)); + startPage(); + List list = payPostcodeService.selectZoneList(query); + return getDataTable(list); } @PreAuthorize("@ss.hasPermi('data:payPostcode:edit')") diff --git a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayPostcodeMapper.java b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayPostcodeMapper.java index 07796b2d..6c96abb7 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayPostcodeMapper.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/mapper/PayPostcodeMapper.java @@ -12,6 +12,9 @@ public interface PayPostcodeMapper List selectCountryList(PayPostcodeGroup query); + /** 当前页国家的分区数和邮编数。 */ + List selectCountryZoneStats(PayPostcodeGroup query); + List selectZoneList(PayPostcodeGroup query); PayPostcodeGroup selectSampleGroup(PayPostcodeGroup query); diff --git a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayPostcodeServiceImpl.java b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayPostcodeServiceImpl.java index e62af876..579c6bb6 100644 --- a/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayPostcodeServiceImpl.java +++ b/bms-back/bms-system/src/main/java/com/bms/price/service/impl/PayPostcodeServiceImpl.java @@ -1,8 +1,10 @@ package com.bms.price.service.impl; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; import com.bms.common.exception.ServiceException; @@ -39,7 +41,57 @@ public class PayPostcodeServiceImpl implements IPayPostcodeService @Override public List selectCountryList(PayPostcodeGroup query) { - return payPostcodeMapper.selectCountryList(query); + List countries = payPostcodeMapper.selectCountryList(query); + if (countries == null || countries.isEmpty()) + { + return countries; + } + List groupIds = new ArrayList(); + for (PayPostcodeGroup row : countries) + { + row.setZoneCount(0); + row.setLineCount(0); + if (row.getGroupId() != null) + { + groupIds.add(row.getGroupId()); + } + } + if (groupIds.isEmpty()) + { + return countries; + } + query.getParams().put("groupIds", groupIds); + try + { + List stats = payPostcodeMapper.selectCountryZoneStats(query); + if (stats == null || stats.isEmpty()) + { + return countries; + } + Map byId = new HashMap(); + for (PayPostcodeGroup stat : stats) + { + if (stat.getGroupId() != null) + { + byId.put(stat.getGroupId(), stat); + } + } + for (PayPostcodeGroup row : countries) + { + PayPostcodeGroup stat = byId.get(row.getGroupId()); + if (stat == null) + { + continue; + } + row.setZoneCount(stat.getZoneCount() == null ? 0 : stat.getZoneCount()); + row.setLineCount(stat.getLineCount() == null ? 0 : stat.getLineCount()); + } + return countries; + } + finally + { + query.getParams().remove("groupIds"); + } } @Override diff --git a/bms-back/bms-system/src/main/resources/mapper/price/PayPostcodeMapper.xml b/bms-back/bms-system/src/main/resources/mapper/price/PayPostcodeMapper.xml index 89f180a4..348119aa 100644 --- a/bms-back/bms-system/src/main/resources/mapper/price/PayPostcodeMapper.xml +++ b/bms-back/bms-system/src/main/resources/mapper/price/PayPostcodeMapper.xml @@ -96,6 +96,31 @@ end + + case + when nullif(trim(g.country_code), '') is not null then upper(trim(g.country_code)) + when nullif(trim(g.country_name), '') is not null then trim(g.country_name) + else '未填写国家' + end + + + + + and (g.country_name like concat('%', #{countryName}, '%') or g.country_code like concat('%', #{countryName}, '%') or g.catalog_country like concat('%', #{countryName}, '%')) + + and g.service_type like concat('%', #{serviceType}, '%') + and g.product_name like concat('%', #{productName}, '%') + and g.channel_name like concat('%', #{channelName}, '%') + and g.coverage = #{coverage} + + and exists ( + select 1 from pay_postcode_line lp + where lp.group_id = g.group_id and lp.postcode like concat('%', #{postcode}, '%') + ) + + + + + + + + + + and in ( + select case + when nullif(trim(src.country_code), '') is not null then upper(trim(src.country_code)) + when nullif(trim(src.country_name), '') is not null then trim(src.country_name) + else '未填写国家' + end + from pay_postcode_group src + where src.group_id in + #{id} + ) + + +