All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 15m33s
- 新增成对迁移 000231 与三张快照表:日级头行、设备粒度激活行、到期事件粒度续费行,以快照日期为唯一键 - 新增每日 03:30(Asia/Shanghai)日报快照生成任务与幂等整日替换,失败重试沿用同一目标日 - 新增六条受控入口:两张报表的汇总、日/月趋势与受控导出,配套查询层只读快照事实 - 新增 operations_activation 与 operations_renewal 两个导出场景,创建期冻结筛选与可见店铺范围、派发期冻结表头、执行期只按冻结值复核资格 - 采购数量口径按系统内未删除设备数实施并在 PRD 标注,附实测差额依据 - 同步证据链 requirement-evidence.json 与入口能力矩阵、ARCHITECTURE 与验证记录 - 归档 change add-operations-reports 并新建主 Spec openspec/specs/operations-report/spec.md
138 lines
4.2 KiB
Go
138 lines
4.2 KiB
Go
package operationsreport
|
|
|
|
// 报表分组维度:激活情况表七项、套餐续费表六项。
|
|
// 只支持单一分组维度,不支持同时按多个维度分组;未选择维度时汇总为一行,分组列值为「全部」。
|
|
const (
|
|
// DimensionDeviceName 表示设备名称维度。
|
|
DimensionDeviceName = "device_name"
|
|
// DimensionDeviceModel 表示设备型号维度。
|
|
DimensionDeviceModel = "device_model"
|
|
// DimensionManufacturer 表示制造商维度。
|
|
DimensionManufacturer = "manufacturer"
|
|
// DimensionBusinessUserGroup 表示用户组维度。
|
|
DimensionBusinessUserGroup = "business_user_group"
|
|
// DimensionAgent 表示代理维度。
|
|
DimensionAgent = "agent"
|
|
// DimensionShop 表示店铺维度。
|
|
DimensionShop = "shop"
|
|
// DimensionBusinessOwner 表示业务员维度。
|
|
DimensionBusinessOwner = "business_owner"
|
|
// DimensionPackageSeries 表示套餐系列维度。
|
|
DimensionPackageSeries = "package_series"
|
|
// DimensionPackageName 表示套餐名称维度。
|
|
DimensionPackageName = "package_name"
|
|
)
|
|
|
|
// DimensionAll 是未选择分组维度时唯一汇总行的分组列值。
|
|
const DimensionAll = "全部"
|
|
|
|
// 趋势粒度取值:只表达粒度,不引入月份参数。
|
|
const (
|
|
// GranularityDay 表示按日趋势。
|
|
GranularityDay = "day"
|
|
// GranularityMonth 表示按月趋势。
|
|
GranularityMonth = "month"
|
|
)
|
|
|
|
// NormalizeGranularity 归一趋势粒度,缺省为按日;返回 false 表示取值不受支持。
|
|
func NormalizeGranularity(value string) (string, bool) {
|
|
switch value {
|
|
case "", GranularityDay:
|
|
return GranularityDay, true
|
|
case GranularityMonth:
|
|
return GranularityMonth, true
|
|
default:
|
|
return "", false
|
|
}
|
|
}
|
|
|
|
// PlaceholderUnset 是分组取值为空时的固定占位展示。
|
|
const PlaceholderUnset = "未设置"
|
|
|
|
// activationDimensions 是有序的激活情况分组维度与其中文名。
|
|
var activationDimensions = []struct {
|
|
Code string
|
|
Name string
|
|
}{
|
|
{DimensionDeviceName, "设备名称"},
|
|
{DimensionDeviceModel, "设备型号"},
|
|
{DimensionManufacturer, "制造商"},
|
|
{DimensionBusinessUserGroup, "用户组"},
|
|
{DimensionAgent, "代理"},
|
|
{DimensionShop, "店铺"},
|
|
{DimensionBusinessOwner, "业务员"},
|
|
}
|
|
|
|
// renewalDimensions 是有序的套餐续费分组维度与其中文名。
|
|
var renewalDimensions = []struct {
|
|
Code string
|
|
Name string
|
|
}{
|
|
{DimensionPackageSeries, "套餐系列"},
|
|
{DimensionPackageName, "套餐名称"},
|
|
{DimensionBusinessUserGroup, "用户组"},
|
|
{DimensionAgent, "代理"},
|
|
{DimensionShop, "店铺"},
|
|
{DimensionBusinessOwner, "业务员"},
|
|
}
|
|
|
|
// ActivationDimensionCodes 返回激活情况支持的维度编码(按展示顺序)。
|
|
func ActivationDimensionCodes() []string {
|
|
codes := make([]string, 0, len(activationDimensions))
|
|
for _, dimension := range activationDimensions {
|
|
codes = append(codes, dimension.Code)
|
|
}
|
|
return codes
|
|
}
|
|
|
|
// RenewalDimensionCodes 返回套餐续费支持的维度编码(按展示顺序)。
|
|
func RenewalDimensionCodes() []string {
|
|
codes := make([]string, 0, len(renewalDimensions))
|
|
for _, dimension := range renewalDimensions {
|
|
codes = append(codes, dimension.Code)
|
|
}
|
|
return codes
|
|
}
|
|
|
|
// ActivationDimensionName 返回激活情况维度的中文名;不支持时返回 false。
|
|
func ActivationDimensionName(code string) (string, bool) {
|
|
return dimensionName(activationDimensions, code)
|
|
}
|
|
|
|
// RenewalDimensionName 返回套餐续费维度的中文名;不支持时返回 false。
|
|
func RenewalDimensionName(code string) (string, bool) {
|
|
return dimensionName(renewalDimensions, code)
|
|
}
|
|
|
|
// IsActivationDimension 判断是否为受支持的激活情况维度。
|
|
func IsActivationDimension(code string) bool {
|
|
_, ok := ActivationDimensionName(code)
|
|
return ok
|
|
}
|
|
|
|
// IsRenewalDimension 判断是否为受支持的套餐续费维度。
|
|
func IsRenewalDimension(code string) bool {
|
|
_, ok := RenewalDimensionName(code)
|
|
return ok
|
|
}
|
|
|
|
func dimensionName(dimensions []struct {
|
|
Code string
|
|
Name string
|
|
}, code string) (string, bool) {
|
|
for _, dimension := range dimensions {
|
|
if dimension.Code == code {
|
|
return dimension.Name, true
|
|
}
|
|
}
|
|
return "", false
|
|
}
|
|
|
|
// TextOrPlaceholder 返回非空文本,为空时返回固定占位。
|
|
func TextOrPlaceholder(value string) string {
|
|
if value == "" {
|
|
return PlaceholderUnset
|
|
}
|
|
return value
|
|
}
|