应付邮编优化和应付列表去除多余字段

This commit is contained in:
liuminghui
2026-11-20 18:01:43 +08:00
parent 5c2d4a23c2
commit 817545059e
9 changed files with 166 additions and 65 deletions
@@ -46,9 +46,11 @@ public class PayPostcodeController extends BaseController
@PreAuthorize("@ss.hasPermi('data:payPostcode:query')") @PreAuthorize("@ss.hasPermi('data:payPostcode:query')")
@GetMapping("/zones") @GetMapping("/zones")
public AjaxResult zones(PayPostcodeGroup query) public TableDataInfo zones(PayPostcodeGroup query)
{ {
return success(payPostcodeService.selectZoneList(query)); startPage();
List<PayPostcodeGroup> list = payPostcodeService.selectZoneList(query);
return getDataTable(list);
} }
@PreAuthorize("@ss.hasPermi('data:payPostcode:edit')") @PreAuthorize("@ss.hasPermi('data:payPostcode:edit')")
@@ -12,6 +12,9 @@ public interface PayPostcodeMapper
List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query); List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query);
/** 当前页国家的分区数和邮编数。 */
List<PayPostcodeGroup> selectCountryZoneStats(PayPostcodeGroup query);
List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query); List<PayPostcodeGroup> selectZoneList(PayPostcodeGroup query);
PayPostcodeGroup selectSampleGroup(PayPostcodeGroup query); PayPostcodeGroup selectSampleGroup(PayPostcodeGroup query);
@@ -1,8 +1,10 @@
package com.bms.price.service.impl; package com.bms.price.service.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import com.bms.common.exception.ServiceException; import com.bms.common.exception.ServiceException;
@@ -39,7 +41,57 @@ public class PayPostcodeServiceImpl implements IPayPostcodeService
@Override @Override
public List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query) public List<PayPostcodeGroup> selectCountryList(PayPostcodeGroup query)
{ {
return payPostcodeMapper.selectCountryList(query); List<PayPostcodeGroup> countries = payPostcodeMapper.selectCountryList(query);
if (countries == null || countries.isEmpty())
{
return countries;
}
List<Long> groupIds = new ArrayList<Long>();
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<PayPostcodeGroup> stats = payPostcodeMapper.selectCountryZoneStats(query);
if (stats == null || stats.isEmpty())
{
return countries;
}
Map<Long, PayPostcodeGroup> byId = new HashMap<Long, PayPostcodeGroup>();
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 @Override
@@ -96,6 +96,31 @@
end end
</sql> </sql>
<sql id="countryBucket">
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
</sql>
<sql id="countryListFilter">
<if test="countryName != null and countryName != ''">
and (g.country_name like concat('%', #{countryName}, '%') or g.country_code like concat('%', #{countryName}, '%') or g.catalog_country like concat('%', #{countryName}, '%'))
</if>
<if test="serviceType != null and serviceType != ''">and g.service_type like concat('%', #{serviceType}, '%')</if>
<if test="productName != null and productName != ''">and g.product_name like concat('%', #{productName}, '%')</if>
<if test="channelName != null and channelName != ''">and g.channel_name like concat('%', #{channelName}, '%')</if>
<if test="coverage != null and coverage != ''">and g.coverage = #{coverage}</if>
<if test="postcode != null and postcode != ''">
and exists (
select 1 from pay_postcode_line lp
where lp.group_id = g.group_id and lp.postcode like concat('%', #{postcode}, '%')
)
</if>
</sql>
<!-- 国家列表只汇总配置表。分区数和邮编数另查当前页,避免整表邮编先放大再聚合。 -->
<select id="selectCountryList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup"> <select id="selectCountryList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
select min(g.group_id) as groupId, select min(g.group_id) as groupId,
max(g.country_name) as countryName, max(g.country_name) as countryName,
@@ -104,50 +129,65 @@
group_concat(distinct nullif(trim(g.service_type), '') order by g.service_type separator '、') as serviceType, group_concat(distinct nullif(trim(g.service_type), '') order by g.service_type separator '、') as serviceType,
group_concat(distinct nullif(trim(g.product_name), '') order by g.product_name separator '、') as productName, group_concat(distinct nullif(trim(g.product_name), '') order by g.product_name separator '、') as productName,
group_concat(distinct nullif(trim(g.channel_name), '') order by g.channel_name separator '、') as channelName, group_concat(distinct nullif(trim(g.channel_name), '') order by g.channel_name separator '、') as channelName,
count(distinct case
when l.line_id is null and nullif(trim(g.block_title), '') is null then null
else concat(
case
when l.line_id is not null then
case
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
else '未分区'
end
else trim(g.block_title)
end,
'||',
lower(ifnull(trim(g.channel_name), ''))
)
end) as zoneCount,
count(l.line_id) as lineCount,
max(g.create_time) as createTime max(g.create_time) as createTime
from pay_postcode_group g from pay_postcode_group g
left join pay_postcode_line l on l.group_id = g.group_id
<where> <where>
<if test="countryName != null and countryName != ''"> <include refid="countryListFilter"/>
and (g.country_name like concat('%', #{countryName}, '%') or g.country_code like concat('%', #{countryName}, '%') or g.catalog_country like concat('%', #{countryName}, '%'))
</if>
<if test="serviceType != null and serviceType != ''">and g.service_type like concat('%', #{serviceType}, '%')</if>
<if test="productName != null and productName != ''">and g.product_name like concat('%', #{productName}, '%')</if>
<if test="channelName != null and channelName != ''">and g.channel_name like concat('%', #{channelName}, '%')</if>
<if test="coverage != null and coverage != ''">and g.coverage = #{coverage}</if>
<if test="postcode != null and postcode != ''">
and exists (
select 1 from pay_postcode_line lp
where lp.group_id = g.group_id and lp.postcode like concat('%', #{postcode}, '%')
)
</if>
</where> </where>
group by case group by <include refid="countryBucket"/>
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
order by max(g.create_time) desc order by max(g.create_time) desc
</select> </select>
<!-- 当前页国家的分区数、邮编数。有邮编的按分区名加渠道去重;没有邮编但有区块标题的算一个分区。 -->
<select id="selectCountryZoneStats" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
select min(t.group_id) as groupId,
count(distinct t.zone_key) as zoneCount,
count(case when t.line_flag = 1 then 1 end) as lineCount
from (
select g.group_id,
<include refid="countryBucket"/> as country_key,
concat(<include refid="zoneExpr"/>, '||', lower(ifnull(trim(g.channel_name), ''))) as zone_key,
1 as line_flag
from (
select g.group_id, g.block_title, g.channel_name, g.country_code, g.country_name
from pay_postcode_group g
<where>
<include refid="countryListFilter"/>
<include refid="pageCountryScope"/>
</where>
) g
inner join pay_postcode_line l on l.group_id = g.group_id
union all
select g.group_id,
<include refid="countryBucket"/> as country_key,
concat(trim(g.block_title), '||', lower(ifnull(trim(g.channel_name), ''))) as zone_key,
0 as line_flag
from pay_postcode_group g
<where>
<include refid="countryListFilter"/>
<include refid="pageCountryScope"/>
and nullif(trim(g.block_title), '') is not null
and not exists (select 1 from pay_postcode_line l where l.group_id = g.group_id)
</where>
) t
group by t.country_key
</select>
<sql id="pageCountryScope">
<if test="params != null and params.groupIds != null and params.groupIds.size() > 0">
and <include refid="countryBucket"/> 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
<foreach collection="params.groupIds" item="id" open="(" separator="," close=")">#{id}</foreach>
)
</if>
</sql>
<select id="selectZoneList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup"> <select id="selectZoneList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
select t.zone_name as zoneName, select t.zone_name as zoneName,
min(t.group_id) as groupId, min(t.group_id) as groupId,
@@ -148,7 +148,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) )
left join pay_product cur on cur.product_id = t.product_id left join pay_product cur on cur.product_id = t.product_id
<include refid="payProductWhere"/> <include refid="payProductWhere"/>
order by ifnull(t.effective_start, pay_product.effective_date) desc, pay_product.product_id desc order by pay_product.create_time desc, pay_product.product_id desc
</select> </select>
<select id="selectPayProductById" parameterType="long" resultMap="PayProductResult"> <select id="selectPayProductById" parameterType="long" resultMap="PayProductResult">
+1
View File
@@ -42,6 +42,7 @@ CREATE TABLE IF NOT EXISTS `pay_postcode_line` (
`sort_no` int(11) NOT NULL DEFAULT 0 COMMENT 'Excel中的先后顺序', `sort_no` int(11) NOT NULL DEFAULT 0 COMMENT 'Excel中的先后顺序',
PRIMARY KEY (`line_id`), PRIMARY KEY (`line_id`),
KEY `idx_pay_postcode_line_group` (`group_id`), KEY `idx_pay_postcode_line_group` (`group_id`),
KEY `idx_pay_postcode_line_zone` (`group_id`, `zone_name`, `region_name`),
KEY `idx_pay_postcode_line_code` (`postcode`) KEY `idx_pay_postcode_line_code` (`postcode`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='应付邮编明细,一行对应Excel一条邮编'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='应付邮编明细,一行对应Excel一条邮编';
@@ -0,0 +1,2 @@
-- `pay_postcode_line` 增加分区统计覆盖索引,国家列表按配置汇总分区数时不必回表读整行邮编
ALTER TABLE `bms`.`pay_postcode_line` ADD INDEX `idx_pay_postcode_line_zone` (`group_id`, `zone_name`, `region_name`);
@@ -6,16 +6,16 @@
<span v-if="country" class="drawer-sub"> <span v-if="country" class="drawer-sub">
{{ country.countryName || '未填写国家' }} {{ country.countryName || '未填写国家' }}
<template v-if="country.countryCode">({{ country.countryCode }})</template> <template v-if="country.countryCode">({{ country.countryCode }})</template>
,共 {{ zoneList.length }} 个分区 ,共 {{ total }} 个分区
</span> </span>
</div> </div>
</template> </template>
<div v-loading="loading"> <div>
<div class="zone-toolbar"> <div class="zone-toolbar">
<el-button type="primary" plain icon="Plus" size="small" :disabled="!country" @click="handleAdd" v-hasPermi="['data:payPostcode:edit']">新增分区</el-button> <el-button type="primary" plain icon="Plus" size="small" :disabled="!country" @click="handleAdd" v-hasPermi="['data:payPostcode:edit']">新增分区</el-button>
</div> </div>
<el-table :data="zoneList" border :row-key="rowKey" :empty-text="country ? '这个国家还没有分区' : '请选择国家'"> <el-table v-loading="loading" :data="zoneList" border :row-key="rowKey" :empty-text="country ? '这个国家还没有分区' : '请选择国家'">
<el-table-column label="分区" min-width="180" align="center"> <el-table-column label="分区" min-width="180" align="center">
<template #default="{ row }"> <template #default="{ row }">
<div class="zone-country-cell"> <div class="zone-country-cell">
@@ -42,6 +42,17 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="drawer-pager">
<el-pagination
v-model:current-page="query.pageNum"
v-model:page-size="query.pageSize"
:total="total"
:page-sizes="[20, 50, 100, 200]"
layout="total, sizes, prev, pager, next"
@size-change="loadList"
@current-change="loadList"
/>
</div>
</div> </div>
<pay-zone-form-dialog ref="formRef" :country="country" @success="onChanged" /> <pay-zone-form-dialog ref="formRef" :country="country" @success="onChanged" />
@@ -61,6 +72,8 @@ const visible = ref(false)
const loading = ref(false) const loading = ref(false)
const country = ref(null) const country = ref(null)
const zoneList = ref([]) const zoneList = ref([])
const total = ref(0)
const query = ref({ pageNum: 1, pageSize: 20 })
const formRef = ref() const formRef = ref()
const lineRef = ref() const lineRef = ref()
@@ -92,6 +105,7 @@ function rowKey(row) {
function open(row) { function open(row) {
country.value = row country.value = row
query.value = { pageNum: 1, pageSize: 20 }
visible.value = true visible.value = true
loadList() loadList()
} }
@@ -99,17 +113,22 @@ function open(row) {
function loadList() { function loadList() {
if (!country.value) { if (!country.value) {
zoneList.value = [] zoneList.value = []
total.value = 0
return return
} }
loading.value = true loading.value = true
listPayPostcodeZone({ listPayPostcodeZone({
countryCode: country.value.countryCode, countryCode: country.value.countryCode,
countryName: country.value.countryName, countryName: country.value.countryName,
allChannels: true allChannels: true,
pageNum: query.value.pageNum,
pageSize: query.value.pageSize
}).then(res => { }).then(res => {
zoneList.value = res.data || [] zoneList.value = res.rows || []
total.value = res.total || 0
}).catch(() => { }).catch(() => {
zoneList.value = [] zoneList.value = []
total.value = 0
}).finally(() => { }).finally(() => {
loading.value = false loading.value = false
}) })
@@ -158,4 +177,5 @@ defineExpose({ open })
.zone-country-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; } .zone-country-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.zone-title { font-weight: 500; } .zone-title { font-weight: 500; }
.zone-click { padding: 0; height: auto; font-size: 12px; } .zone-click { padding: 0; height: auto; font-size: 12px; }
.drawer-pager { margin-top: 16px; display: flex; justify-content: flex-end; }
</style> </style>
@@ -40,10 +40,6 @@
<span v-else>{{ row.sourceFile || '-' }}</span> <span v-else>{{ row.sourceFile || '-' }}</span>
</template> </template>
<template #col-parseStatus="{ row }">
<el-tag :type="statusType(row.parseStatus)" size="small">{{ statusText(row.parseStatus) }}</el-tag>
</template>
<template #col-termRange="{ row }"> <template #col-termRange="{ row }">
<span>{{ termText(row) }}</span> <span>{{ termText(row) }}</span>
</template> </template>
@@ -262,19 +258,14 @@ const statusOptions = [
const columns = [ const columns = [
{ label: '应付价卡名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' }, { label: '应付价卡名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
{ label: '价卡归属', prop: 'supplierName', align: 'center', width: 100 },
{ label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true }, { label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true },
{ label: '费用类型', prop: 'chargeType', align: 'center', width: 110 }, { label: '费用类型', prop: 'chargeType', align: 'center', width: 110 },
{ label: '每公斤加价', prop: 'extraPerKg', align: 'center', width: 120 }, { label: '每公斤加价', prop: 'extraPerKg', align: 'center', width: 120 },
{ label: '报价工作表', prop: 'sheetName', align: 'center', minWidth: 140, showOverflowTooltip: true },
{ label: '关联分区表', prop: 'relatedSheet', align: 'center', minWidth: 140, showOverflowTooltip: true },
{ label: '版本', prop: 'versionNo', align: 'center', width: 70 }, { label: '版本', prop: 'versionNo', align: 'center', width: 70 },
{ label: '有效期', prop: 'termRange', align: 'center', minWidth: 180, showOverflowTooltip: true }, { label: '有效期', prop: 'termRange', align: 'center', minWidth: 180, showOverflowTooltip: true },
{ label: '状态', prop: 'termStatus', align: 'center', width: 100 }, { label: '状态', prop: 'termStatus', align: 'center', width: 100 },
{ label: '币种', prop: 'currency', align: 'center', width: 80 }, { label: '币种', prop: 'currency', align: 'center', width: 80 },
{ label: '重量段', prop: 'weightCount', align: 'center', width: 80 }, { label: '重量段', prop: 'weightCount', align: 'center', width: 80 },
{ label: '附加费', prop: 'surchargeCount', align: 'center', width: 80 },
{ label: '识别结果', prop: 'parseStatus', align: 'center', width: 120 },
{ label: '来源文件', prop: 'sourceFile', align: 'center', minWidth: 180, showOverflowTooltip: true }, { label: '来源文件', prop: 'sourceFile', align: 'center', minWidth: 180, showOverflowTooltip: true },
{ label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true }, { label: '创建时间', prop: 'createTime', align: 'center', width: 160, parseTime: true },
{ label: '操作', prop: 'action', align: 'center', width: 340, fixed: 'right', showInToolbar: false } { label: '操作', prop: 'action', align: 'center', width: 340, fixed: 'right', showInToolbar: false }
@@ -588,16 +579,6 @@ function changeStatus(row, field, status) {
}) })
} }
function statusText(status) {
return statusOptions.find(item => item.value === status)?.label || status || '-'
}
function statusType(status) {
if (status === 'OK') return 'success'
if (status === 'EMPTY') return 'warning'
if (status === 'MISSING') return 'danger'
return 'info'
}
</script> </script>
<style scoped> <style scoped>