feat: 下线设备保护期
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m30s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m30s
- 后台设备停复机不再设置 1 小时保护期,也不再因保护期拒绝相反操作;单卡手动停复机去掉保护期检查 - 删除保护期一致性轮询(polling:protect)及其强制停复机方法;调度、初始化、监控、匹配预览不再包含保护期;已入队的旧任务由空处理函数直接确认,下一次发布移除 - 轮询配置接口不再接受与返回 protect_check_interval;并发配置不再返回 protect,查询、更新、重置该类型时拒绝 - 资产详情 device_protect_status 固定返回 none 并标记废弃,兼容老版本客户端 - 删除保护期 Redis key 与时长常量;停机原因 protect_period 保留供历史数据与开放接口映射 - 迁移 000249 只把 protect_check_interval、last_protect_check_at 列注释标记为已废弃,不删列不改数据
This commit is contained in:
@@ -295,8 +295,8 @@ func (s *Service) buildDeviceResolveResponse(ctx context.Context, device *model.
|
||||
// 查套餐系列名称
|
||||
s.fillSeriesName(ctx, resp)
|
||||
|
||||
// 查 Redis 保护期
|
||||
resp.DeviceProtectStatus = s.getDeviceProtectStatus(ctx, device.ID)
|
||||
// 保护期已下线,字段固定返回无保护期,兼容老版本客户端。
|
||||
resp.DeviceProtectStatus = constants.DeviceProtectStatusNone
|
||||
|
||||
// 关联手机号:详情为单资产单次查询,按数据范围返回完整手机号。
|
||||
phones, err := s.resolveAssociatedPhones(ctx, constants.AssetTypeDevice, device.ID)
|
||||
@@ -525,7 +525,7 @@ func (s *Service) GetRealtimeStatus(ctx context.Context, assetType string, id ui
|
||||
})
|
||||
}
|
||||
}
|
||||
resp.DeviceProtectStatus = s.getDeviceProtectStatus(ctx, id)
|
||||
resp.DeviceProtectStatus = constants.DeviceProtectStatusNone
|
||||
|
||||
// 实时查询 Gateway 设备状态(不缓存,per D-05)
|
||||
// Gateway 失败不阻断主流程,DeviceRealtime 始终非 nil,失败时仅填 GatewayMsg(per D-06)
|
||||
@@ -1035,19 +1035,6 @@ func (s *Service) UpdatePackageUsage(ctx context.Context, assetType string, asse
|
||||
return s.buildAssetPackageResponse(ctx, updated, constants.OwnerTypePlatform), nil
|
||||
}
|
||||
|
||||
// getDeviceProtectStatus 查询设备保护期状态
|
||||
func (s *Service) getDeviceProtectStatus(ctx context.Context, deviceID uint) string {
|
||||
stopKey := constants.RedisDeviceProtectKey(deviceID, "stop")
|
||||
startKey := constants.RedisDeviceProtectKey(deviceID, "start")
|
||||
if s.redis.Exists(ctx, stopKey).Val() > 0 {
|
||||
return "stop"
|
||||
}
|
||||
if s.redis.Exists(ctx, startKey).Val() > 0 {
|
||||
return "start"
|
||||
}
|
||||
return "none"
|
||||
}
|
||||
|
||||
// nonZeroTimePtr 将非零时间转为指针,零值返回 nil(避免序列化出历史时区偏移 +08:05)
|
||||
func nonZeroTimePtr(t time.Time) *time.Time {
|
||||
if t.IsZero() {
|
||||
|
||||
@@ -1378,17 +1378,6 @@ func (s *Service) StopDevice(ctx context.Context, deviceID uint) (*dto.DeviceSus
|
||||
return nil, errors.New(errors.CodeNotFound, "设备不存在")
|
||||
}
|
||||
|
||||
// 复机保护期内禁止停机
|
||||
if s.redis != nil {
|
||||
exists, _ := s.redis.Exists(ctx, constants.RedisDeviceProtectKey(deviceID, "start")).Result()
|
||||
if exists > 0 {
|
||||
appErr := errors.New(errors.CodeForbidden, "设备复机保护期内,禁止停机")
|
||||
s.recordDeviceCommandAudit(ctx, constants.AuditActionDeviceStopped, "停用设备绑定卡网络被拒绝",
|
||||
constants.AuditResultDenied, device, nil, nil, nil, nil, appErr)
|
||||
return nil, appErr
|
||||
}
|
||||
}
|
||||
|
||||
bindings, err := s.deviceSimBindingStore.ListByDeviceID(ctx, deviceID)
|
||||
if err != nil {
|
||||
appErr := errors.Wrap(errors.CodeInternalError, err, "查询设备绑定卡失败")
|
||||
@@ -1505,12 +1494,6 @@ func (s *Service) StopDevice(ctx context.Context, deviceID uint) (*dto.DeviceSus
|
||||
successCount++
|
||||
}
|
||||
|
||||
// 成功停机至少一张卡后设置保护期
|
||||
if successCount > 0 && s.redis != nil {
|
||||
s.redis.Set(ctx, constants.RedisDeviceProtectKey(deviceID, "stop"), uuid.NewString(), constants.DeviceProtectPeriodDuration)
|
||||
s.redis.Del(ctx, constants.RedisDeviceProtectKey(deviceID, "start"))
|
||||
}
|
||||
|
||||
if successCount == 0 && len(failedItems) == 0 {
|
||||
s.recordDeviceCommandAudit(ctx, constants.AuditActionDeviceStopped, "设备绑定卡网络无需停用",
|
||||
constants.AuditResultSuccess, device, nil, nil, nil,
|
||||
@@ -1541,17 +1524,6 @@ func (s *Service) StartDevice(ctx context.Context, deviceID uint) error {
|
||||
return errors.New(errors.CodeNotFound, "设备不存在")
|
||||
}
|
||||
|
||||
// 停机保护期内禁止复机
|
||||
if s.redis != nil {
|
||||
exists, _ := s.redis.Exists(ctx, constants.RedisDeviceProtectKey(deviceID, "stop")).Result()
|
||||
if exists > 0 {
|
||||
appErr := errors.New(errors.CodeForbidden, "设备停机保护期内,禁止复机")
|
||||
s.recordDeviceCommandAudit(ctx, constants.AuditActionDeviceStarted, "恢复设备绑定卡网络被拒绝",
|
||||
constants.AuditResultDenied, device, nil, nil, nil, nil, appErr)
|
||||
return appErr
|
||||
}
|
||||
}
|
||||
|
||||
bindings, err := s.deviceSimBindingStore.ListByDeviceID(ctx, deviceID)
|
||||
if err != nil {
|
||||
appErr := errors.Wrap(errors.CodeInternalError, err, "查询设备绑定卡失败")
|
||||
@@ -1664,12 +1636,6 @@ func (s *Service) StartDevice(ctx context.Context, deviceID uint) error {
|
||||
successCount++
|
||||
}
|
||||
|
||||
// 成功复机至少一张卡后设置保护期
|
||||
if successCount > 0 && s.redis != nil {
|
||||
s.redis.Set(ctx, constants.RedisDeviceProtectKey(deviceID, "start"), uuid.NewString(), constants.DeviceProtectPeriodDuration)
|
||||
s.redis.Del(ctx, constants.RedisDeviceProtectKey(deviceID, "stop"))
|
||||
}
|
||||
|
||||
// 全部失败时返回 error
|
||||
if successCount == 0 && lastErr != nil {
|
||||
appErr := errors.Wrap(errors.CodeGatewayError, lastErr, "设备复机失败,所有卡均复机失败")
|
||||
|
||||
@@ -27,16 +27,10 @@ import (
|
||||
)
|
||||
|
||||
// StopResumeServiceInterface 停复机服务接口
|
||||
// 供 4 个 Task Handler 通过接口注入,避免循环依赖
|
||||
// 供轮询 Task Handler 通过接口注入,避免循环依赖
|
||||
type StopResumeServiceInterface interface {
|
||||
// EvaluateAndAct 停复机统一入口,根据卡的当前状态自动判断并执行停机或复机
|
||||
EvaluateAndAct(ctx context.Context, card *model.IotCard) error
|
||||
// ForceStopCard 强制停机单张卡,不执行正常停机条件判断。
|
||||
ForceStopCard(ctx context.Context, card *model.IotCard, stopReason string) error
|
||||
// ForceStartCard 强制复机单张卡,不执行正常复机条件判断。
|
||||
ForceStartCard(ctx context.Context, card *model.IotCard) error
|
||||
// ProtectCheckSkipsForRealname 判定保护期一致性检查是否因实名跳过该卡。
|
||||
ProtectCheckSkipsForRealname(ctx context.Context, card *model.IotCard) (bool, error)
|
||||
}
|
||||
|
||||
// 编译时验证 StopResumeService 实现了 StopResumeServiceInterface
|
||||
@@ -220,7 +214,7 @@ func containsStopReason(reasons []string, target string) bool {
|
||||
//
|
||||
// 三个前置条件缺一不可:
|
||||
// 1. 已注入优先轮询 Writer;
|
||||
// 2. 本次评估来自普通套餐轮询(观测消费者、手动实名、保护期轮询等调用链不打标,一律不写);
|
||||
// 2. 本次评估来自普通套餐轮询(观测消费者、手动实名等调用链不打标,一律不写);
|
||||
// 3. 该载体存在待生效的套餐使用记录,否则每个普通套餐周期都重新入队会形成自激循环。
|
||||
//
|
||||
// 事件资源为该载体对应的资产(独立卡为自身,绑定设备为设备),卡快照由 Writer 在同一事务内冻结。
|
||||
@@ -547,53 +541,6 @@ func (s *StopResumeService) ResumeCardIfStopped(ctx context.Context, carrierType
|
||||
}
|
||||
}
|
||||
|
||||
// ForceStopCard 强制停机单张卡,不执行正常停机条件判断。
|
||||
func (s *StopResumeService) ForceStopCard(ctx context.Context, card *model.IotCard, stopReason string) error {
|
||||
if card == nil || card.ID == 0 {
|
||||
return errors.New(errors.CodeInvalidParam)
|
||||
}
|
||||
_, err := s.stopCardWithRetry(ctx, card, stopReason)
|
||||
return err
|
||||
}
|
||||
|
||||
// ForceStartCard 强制复机单张卡,不执行正常复机条件判断。
|
||||
// 持通道阈值锁的卡必须先拒绝,再走既有保护期一致性检查,避免强行复机锁定期内的卡。
|
||||
func (s *StopResumeService) ForceStartCard(ctx context.Context, card *model.IotCard) error {
|
||||
if card == nil || card.ID == 0 {
|
||||
return errors.New(errors.CodeInvalidParam)
|
||||
}
|
||||
actionCode, summary := constants.AuditActionIotCardAutoStarted, "自动恢复 IoT 卡网络"
|
||||
blocked, err := s.channelThresholdBlocked(ctx, card)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if blocked {
|
||||
s.recordChannelThresholdDenial(ctx, card, actionCode, summary)
|
||||
return channelThresholdDenyError()
|
||||
}
|
||||
attempt, integrationID, err := s.resumeCardWithRetry(ctx, card, actionCode, summary)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.updateCardAndAppendNetworkSeries(ctx, card, map[string]any{
|
||||
"network_status": constants.NetworkStatusOnline,
|
||||
"resumed_at": time.Now(),
|
||||
"stop_reason": "",
|
||||
}, constants.CardObservationSceneBusinessResume, "online", uuid.NewString(), actionCode, summary, integrationID); err != nil {
|
||||
if logErr := s.completeCardCommandAttempt(ctx, attempt, nil, false); logErr != nil {
|
||||
s.logger.Error("终结保护期复机 Integration Log 失败", zap.String("integration_id", attempt.log.IntegrationID), zap.Error(logErr))
|
||||
}
|
||||
s.recordCardCommandAudit(ctx, card, actionCode, summary+"结果待核对", constants.AuditResultUnknown,
|
||||
attempt.log.IntegrationID, cardSnapshot(card), map[string]any{"requested_network_status": constants.NetworkStatusOnline}, err)
|
||||
return err
|
||||
}
|
||||
s.reschedulePolling(ctx, card.ID)
|
||||
if err := s.completeCardCommandAttempt(ctx, attempt, nil, true); err != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, err, "终结保护期复机 Integration Log 失败")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// resumeSingleCard 对单张卡执行复机逻辑
|
||||
// 依次检查:持通道阈值锁则拒绝 → 已开机则跳过 → 非轮询停机原因则跳过 → 不满足复机条件则跳过 → 加锁 → 调 Gateway → 更新 DB
|
||||
func (s *StopResumeService) resumeSingleCard(ctx context.Context, cardID uint) error {
|
||||
@@ -615,7 +562,7 @@ func (s *StopResumeService) resumeSingleCard(ctx context.Context, cardID uint) e
|
||||
|
||||
// 持通道阈值锁:周期内拒绝一切复机,记录拒绝事实并保留锁。
|
||||
// 该入口被轮询评估、套餐激活/重置与设备维度复机复用,返回 nil 表示本次不动作,
|
||||
// 避免让自动链路按失败重试;用户可见入口由 ManualStartCard/ForceStartCard 返回拒绝错误。
|
||||
// 避免让自动链路按失败重试;用户可见入口由 ManualStartCard 返回拒绝错误。
|
||||
blocked, blockErr := s.channelThresholdBlocked(ctx, card)
|
||||
if blockErr != nil {
|
||||
return blockErr
|
||||
@@ -982,24 +929,6 @@ func (s *StopResumeService) ManualStopCard(ctx context.Context, iccid string) er
|
||||
return denyErr
|
||||
}
|
||||
|
||||
// 检查绑定设备是否在复机保护期
|
||||
if s.deviceSimBindingStore != nil && s.redis != nil {
|
||||
binding, bindErr := s.deviceSimBindingStore.GetActiveBindingByCardID(ctx, card.ID)
|
||||
if bindErr == nil && binding != nil {
|
||||
exists, _ := s.redis.Exists(ctx, constants.RedisDeviceProtectKey(binding.DeviceID, "start")).Result()
|
||||
if exists > 0 {
|
||||
denyErr := errors.New(errors.CodeForbidden, "设备复机保护期内,禁止停机")
|
||||
s.recordCardCommandAudit(ctx, card, actionCode, summary+"被拒绝", constants.AuditResultDenied, "",
|
||||
cardSnapshot(card), map[string]any{"device_id": binding.DeviceID}, denyErr)
|
||||
return denyErr
|
||||
}
|
||||
} else if bindErr != nil && !stderrors.Is(bindErr, gorm.ErrRecordNotFound) {
|
||||
wrapErr := errors.Wrap(errors.CodeInternalError, bindErr, "查询卡绑定关系失败")
|
||||
s.recordCardCommandAudit(ctx, card, actionCode, summary+"失败", constants.AuditResultFailed, "", cardSnapshot(card), nil, wrapErr)
|
||||
return wrapErr
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := s.stopCardWithRetry(ctx, card, constants.StopReasonManual); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1049,24 +978,6 @@ func (s *StopResumeService) ManualStartCard(ctx context.Context, iccid string) e
|
||||
return denyErr
|
||||
}
|
||||
|
||||
// 检查绑定设备是否在停机保护期
|
||||
if s.deviceSimBindingStore != nil && s.redis != nil {
|
||||
binding, bindErr := s.deviceSimBindingStore.GetActiveBindingByCardID(ctx, card.ID)
|
||||
if bindErr == nil && binding != nil {
|
||||
exists, _ := s.redis.Exists(ctx, constants.RedisDeviceProtectKey(binding.DeviceID, "stop")).Result()
|
||||
if exists > 0 {
|
||||
denyErr := errors.New(errors.CodeForbidden, "设备停机保护期内,禁止复机")
|
||||
s.recordCardCommandAudit(ctx, card, actionCode, summary+"被拒绝", constants.AuditResultDenied, "",
|
||||
cardSnapshot(card), map[string]any{"device_id": binding.DeviceID}, denyErr)
|
||||
return denyErr
|
||||
}
|
||||
} else if bindErr != nil && !stderrors.Is(bindErr, gorm.ErrRecordNotFound) {
|
||||
wrapErr := errors.Wrap(errors.CodeInternalError, bindErr, "查询卡绑定关系失败")
|
||||
s.recordCardCommandAudit(ctx, card, actionCode, summary+"失败", constants.AuditResultFailed, "", cardSnapshot(card), nil, wrapErr)
|
||||
return wrapErr
|
||||
}
|
||||
}
|
||||
|
||||
attempt, integrationID, err := s.resumeCardWithRetry(ctx, card, actionCode, summary)
|
||||
if err != nil {
|
||||
wrapErr := errors.Wrap(errors.CodeGatewayError, err, "调用运营商复机失败,请稍后重试")
|
||||
|
||||
@@ -80,19 +80,3 @@ func (s *StopResumeService) unifiedRealnameOK(ctx context.Context, card *model.I
|
||||
}
|
||||
return card.RealNameStatus == constants.RealNameStatusVerified, nil
|
||||
}
|
||||
|
||||
// ProtectCheckSkipsForRealname 判定保护期一致性检查是否因实名跳过该卡。
|
||||
// 总开关关闭时与原有行为一致(未实名即跳过);开启时只在通道开启实名管控且卡未实名时跳过。
|
||||
func (s *StopResumeService) ProtectCheckSkipsForRealname(ctx context.Context, card *model.IotCard) (bool, error) {
|
||||
if card.RealNameStatus == constants.RealNameStatusVerified {
|
||||
return false, nil
|
||||
}
|
||||
if !unifiedStopResumeEnabled() {
|
||||
return true, nil
|
||||
}
|
||||
controlled, err := s.channelRealnameControlled(ctx, card)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return controlled, nil
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func pollingConfigState(config *model.PollingConfig) map[string]any {
|
||||
"config_name": config.ConfigName, "card_condition": config.CardCondition,
|
||||
"card_category": config.CardCategory, "carrier_id": config.CarrierID, "priority": config.Priority,
|
||||
"realname_check_interval": config.RealnameCheckInterval, "carddata_check_interval": config.CarddataCheckInterval,
|
||||
"package_check_interval": config.PackageCheckInterval, "protect_check_interval": config.ProtectCheckInterval,
|
||||
"package_check_interval": config.PackageCheckInterval,
|
||||
"card_status_check_interval": config.CardStatusCheckInterval, "status": config.Status,
|
||||
"package_state": config.PackageState, "asset_status": config.AssetStatus,
|
||||
"pre_reset_window": config.PreResetWindow, "pre_reset_carddata_interval": config.PreResetCarddataInterval,
|
||||
|
||||
@@ -58,6 +58,9 @@ func (s *ConcurrencyService) List(ctx context.Context) ([]*ConcurrencyStatus, er
|
||||
|
||||
result := make([]*ConcurrencyStatus, 0, len(configs))
|
||||
for _, cfg := range configs {
|
||||
if isRetiredConcurrencyTaskType(cfg.TaskType) {
|
||||
continue
|
||||
}
|
||||
status := &ConcurrencyStatus{
|
||||
TaskType: cfg.TaskType,
|
||||
TaskTypeName: s.getTaskTypeName(cfg.TaskType),
|
||||
@@ -91,6 +94,9 @@ func (s *ConcurrencyService) List(ctx context.Context) ([]*ConcurrencyStatus, er
|
||||
|
||||
// GetByTaskType 根据任务类型获取并发配置及状态
|
||||
func (s *ConcurrencyService) GetByTaskType(ctx context.Context, taskType string) (*ConcurrencyStatus, error) {
|
||||
if isRetiredConcurrencyTaskType(taskType) {
|
||||
return nil, retiredConcurrencyTaskTypeError()
|
||||
}
|
||||
cfg, err := s.store.GetByTaskType(ctx, taskType)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(errors.CodeNotFound, err, "并发配置不存在")
|
||||
@@ -130,6 +136,9 @@ func (s *ConcurrencyService) UpdateMaxConcurrency(ctx context.Context, taskType
|
||||
if maxConcurrency < 1 || maxConcurrency > constants.PollingMaxConcurrencyLimit {
|
||||
return errors.New(errors.CodeInvalidParam, "并发数必须为 1-1000")
|
||||
}
|
||||
if isRetiredConcurrencyTaskType(taskType) {
|
||||
return retiredConcurrencyTaskTypeError()
|
||||
}
|
||||
|
||||
// 验证任务类型存在
|
||||
config, err := s.store.GetByTaskType(ctx, taskType)
|
||||
@@ -177,6 +186,9 @@ func (s *ConcurrencyService) ResetConcurrency(ctx context.Context, taskType stri
|
||||
if operatorID == 0 {
|
||||
return errors.New(errors.CodeUnauthorized, "未授权访问")
|
||||
}
|
||||
if isRetiredConcurrencyTaskType(taskType) {
|
||||
return retiredConcurrencyTaskTypeError()
|
||||
}
|
||||
// 验证任务类型存在
|
||||
config, err := s.store.GetByTaskType(ctx, taskType)
|
||||
if err != nil {
|
||||
@@ -249,6 +261,9 @@ func (s *ConcurrencyService) InitFromDB(ctx context.Context) error {
|
||||
}
|
||||
|
||||
for _, cfg := range configs {
|
||||
if isRetiredConcurrencyTaskType(cfg.TaskType) {
|
||||
continue
|
||||
}
|
||||
configKey := constants.RedisPollingConcurrencyConfigKey(cfg.TaskType)
|
||||
if err := s.redis.Set(ctx, configKey, cfg.MaxConcurrency, 24*time.Hour).Err(); err != nil {
|
||||
// 忽略单个配置同步失败
|
||||
@@ -256,6 +271,7 @@ func (s *ConcurrencyService) InitFromDB(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
_ = s.redis.Del(ctx, constants.RedisPollingConcurrencyConfigKey("stop_start")).Err()
|
||||
_ = s.redis.Del(ctx, constants.RedisPollingConcurrencyConfigKey(retiredProtectConcurrencyTaskType)).Err()
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -283,11 +299,21 @@ func (s *ConcurrencyService) getTaskTypeName(taskType string) string {
|
||||
return "流量检查"
|
||||
case "package":
|
||||
return "套餐检查"
|
||||
case "protect":
|
||||
return "保护期检查"
|
||||
case "card_status":
|
||||
return "卡状态检查"
|
||||
default:
|
||||
return taskType
|
||||
}
|
||||
}
|
||||
|
||||
// retiredProtectConcurrencyTaskType 是已下线的保护期检查并发配置;数据库行保留但不再返回或维护。
|
||||
const retiredProtectConcurrencyTaskType = "protect"
|
||||
|
||||
// isRetiredConcurrencyTaskType 判断并发配置是否属于已下线的轮询任务(兼容带 polling: 前缀的写法)。
|
||||
func isRetiredConcurrencyTaskType(taskType string) bool {
|
||||
return strings.TrimPrefix(strings.TrimSpace(taskType), "polling:") == retiredProtectConcurrencyTaskType
|
||||
}
|
||||
|
||||
func retiredConcurrencyTaskTypeError() error {
|
||||
return errors.New(errors.CodeInvalidParam, "保护期检查已下线,不再维护并发配置")
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ func (s *ConfigService) Create(ctx context.Context, req *dto.CreatePollingConfig
|
||||
RealnameCheckInterval: req.RealnameCheckInterval,
|
||||
CarddataCheckInterval: req.CarddataCheckInterval,
|
||||
PackageCheckInterval: req.PackageCheckInterval,
|
||||
ProtectCheckInterval: req.ProtectCheckInterval,
|
||||
CardStatusCheckInterval: req.CardStatusCheckInterval,
|
||||
PackageState: req.PackageState,
|
||||
AssetStatus: req.AssetStatus,
|
||||
@@ -188,9 +187,6 @@ func (s *ConfigService) Update(ctx context.Context, id uint, req *dto.UpdatePoll
|
||||
if req.PackageCheckInterval != nil {
|
||||
config.PackageCheckInterval = req.PackageCheckInterval
|
||||
}
|
||||
if req.ProtectCheckInterval != nil {
|
||||
config.ProtectCheckInterval = req.ProtectCheckInterval
|
||||
}
|
||||
if req.CardStatusCheckInterval != nil {
|
||||
config.CardStatusCheckInterval = req.CardStatusCheckInterval
|
||||
}
|
||||
@@ -402,7 +398,6 @@ func (s *ConfigService) toResponse(c *model.PollingConfig) *dto.PollingConfigRes
|
||||
RealnameCheckInterval: c.RealnameCheckInterval,
|
||||
CarddataCheckInterval: c.CarddataCheckInterval,
|
||||
PackageCheckInterval: c.PackageCheckInterval,
|
||||
ProtectCheckInterval: c.ProtectCheckInterval,
|
||||
CardStatusCheckInterval: c.CardStatusCheckInterval,
|
||||
PackageState: c.PackageState,
|
||||
AssetStatus: c.AssetStatus,
|
||||
|
||||
@@ -149,7 +149,7 @@ func (s *ConfigService) MatchPreview(ctx context.Context, req *dto.PollingConfig
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
var previewTaskTypes = []string{constants.TaskTypePollingCardStatus, constants.TaskTypePollingCarddata, constants.TaskTypePollingRealname, constants.TaskTypePollingPackage, constants.TaskTypePollingProtect}
|
||||
var previewTaskTypes = []string{constants.TaskTypePollingCardStatus, constants.TaskTypePollingCarddata, constants.TaskTypePollingRealname, constants.TaskTypePollingPackage}
|
||||
|
||||
// applyPreviewOverrides 把未保存修改合并进启用配置快照并重新排序;返回草稿配置标记。
|
||||
func applyPreviewOverrides(configs []*model.PollingConfig, overrides []dto.PollingConfigOverride) ([]*model.PollingConfig, map[*model.PollingConfig]bool, error) {
|
||||
@@ -176,8 +176,8 @@ func applyPreviewOverrides(configs []*model.PollingConfig, overrides []dto.Polli
|
||||
ID: item.ID, ConfigName: item.ConfigName, CardCondition: item.CardCondition, CardCategory: item.CardCategory,
|
||||
CarrierID: item.CarrierID, Priority: item.Priority, RealnameCheckInterval: item.RealnameCheckInterval,
|
||||
CarddataCheckInterval: item.CarddataCheckInterval, PackageCheckInterval: item.PackageCheckInterval,
|
||||
ProtectCheckInterval: item.ProtectCheckInterval, CardStatusCheckInterval: item.CardStatusCheckInterval,
|
||||
PackageState: item.PackageState, AssetStatus: item.AssetStatus, PreResetWindow: item.PreResetWindow,
|
||||
CardStatusCheckInterval: item.CardStatusCheckInterval,
|
||||
PackageState: item.PackageState, AssetStatus: item.AssetStatus, PreResetWindow: item.PreResetWindow,
|
||||
PreResetCarddataInterval: item.PreResetCarddataInterval, Status: 1,
|
||||
}
|
||||
if draft.ConfigName == "" {
|
||||
@@ -336,11 +336,8 @@ func (s *ConfigService) TierStats(ctx context.Context) (*dto.PollingTierStatsRes
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// previewTaskTypeName 返回检查类型中文名称(保护期检查在优先轮询名称表之外单独处理)。
|
||||
// previewTaskTypeName 返回检查类型中文名称。
|
||||
func previewTaskTypeName(taskType string) string {
|
||||
if taskType == constants.TaskTypePollingProtect {
|
||||
return "保护期检查"
|
||||
}
|
||||
return constants.PollingPriorityTaskTypeName(taskType)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ func validatePollingConfig(cfg *model.PollingConfig) error {
|
||||
{"实名检查间隔", cfg.RealnameCheckInterval, 30},
|
||||
{"流量检查间隔", cfg.CarddataCheckInterval, 60},
|
||||
{"套餐检查间隔", cfg.PackageCheckInterval, 60},
|
||||
{"保护期一致性检查间隔", cfg.ProtectCheckInterval, 30},
|
||||
{"卡状态检查间隔", cfg.CardStatusCheckInterval, 30},
|
||||
}
|
||||
configured := false
|
||||
|
||||
@@ -265,8 +265,6 @@ func (s *MonitoringService) getTaskTypeName(taskType string) string {
|
||||
return "流量检查"
|
||||
case constants.TaskTypePollingPackage:
|
||||
return "套餐检查"
|
||||
case constants.TaskTypePollingProtect:
|
||||
return "保护期检查"
|
||||
case constants.TaskTypePollingCardStatus:
|
||||
return "卡状态检查"
|
||||
default:
|
||||
@@ -280,7 +278,6 @@ func pollingMonitorTaskTypes() []string {
|
||||
constants.TaskTypePollingRealname,
|
||||
constants.TaskTypePollingCarddata,
|
||||
constants.TaskTypePollingPackage,
|
||||
constants.TaskTypePollingProtect,
|
||||
constants.TaskTypePollingCardStatus,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user