开放接口,修复上游同步不对的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m55s
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// PollingCardStatusHandler 卡开停机状态轮询任务处理器
|
||||
// 职责:调 Gateway 查卡状态(准备/正常/停机)→ 映射为 network_status → 写 DB → 触发停复机评估
|
||||
// 职责:调 Gateway 查卡状态(正常/停机/准备)→ 映射为 network_status → 写 DB → 触发停复机评估
|
||||
// 不做:直接停复机决策,委托给 StopResumeService.EvaluateAndAct
|
||||
type PollingCardStatusHandler struct {
|
||||
base *PollingBase
|
||||
@@ -63,7 +63,8 @@ func (h *PollingCardStatusHandler) Handle(ctx context.Context, t *asynq.Task) er
|
||||
return h.base.requeueCard(ctx, cardID, constants.TaskTypePollingCardStatus)
|
||||
}
|
||||
|
||||
var newNetworkStatus int
|
||||
newNetworkStatus := card.NetworkStatus
|
||||
gatewayCardStatus := ""
|
||||
if h.gateway != nil {
|
||||
result, gwErr := h.gateway.QueryCardStatus(ctx, &gateway.CardStatusReq{CardNo: card.ICCID})
|
||||
if gwErr != nil {
|
||||
@@ -72,22 +73,26 @@ func (h *PollingCardStatusHandler) Handle(ctx context.Context, t *asynq.Task) er
|
||||
h.base.updateStats(ctx, constants.TaskTypePollingCardStatus, false, time.Since(startTime))
|
||||
return h.base.requeueCard(ctx, cardID, constants.TaskTypePollingCardStatus)
|
||||
}
|
||||
// "停机" → 0(停机),"准备"/"正常" → 1(开机)
|
||||
if result.CardStatus == "停机" {
|
||||
newNetworkStatus = constants.NetworkStatusOffline
|
||||
gatewayCardStatus = result.CardStatus
|
||||
parsedStatus, ok := gateway.ParseCardNetworkStatus(result.CardStatus, result.Extend)
|
||||
if !ok {
|
||||
h.base.logger.Warn("卡状态轮询:未知 Gateway 卡状态",
|
||||
zap.Uint("card_id", cardID),
|
||||
zap.String("iccid", card.ICCID),
|
||||
zap.String("card_status", result.CardStatus),
|
||||
zap.String("extend", result.Extend))
|
||||
} else {
|
||||
newNetworkStatus = constants.NetworkStatusOnline
|
||||
newNetworkStatus = parsedStatus
|
||||
}
|
||||
if h.base.verboseLog {
|
||||
h.base.logger.Info("卡状态轮询详情",
|
||||
zap.Uint("card_id", cardID),
|
||||
zap.String("iccid", card.ICCID),
|
||||
zap.String("card_status", result.CardStatus),
|
||||
zap.String("extend", result.Extend),
|
||||
zap.Int("new_network_status", newNetworkStatus),
|
||||
zap.Bool("changed", newNetworkStatus != card.NetworkStatus))
|
||||
}
|
||||
} else {
|
||||
newNetworkStatus = card.NetworkStatus
|
||||
}
|
||||
|
||||
statusChanged := newNetworkStatus != card.NetworkStatus
|
||||
@@ -98,7 +103,9 @@ func (h *PollingCardStatusHandler) Handle(ctx context.Context, t *asynq.Task) er
|
||||
if statusChanged {
|
||||
fields["network_status"] = newNetworkStatus
|
||||
// 网关侧停机事件:补写 stop_reason,便于状态追踪和区分手动停机
|
||||
if newNetworkStatus == constants.NetworkStatusOffline && card.StopReason == "" {
|
||||
if newNetworkStatus == constants.NetworkStatusOffline &&
|
||||
card.StopReason == "" &&
|
||||
gateway.IsGatewayCardStopped(gatewayCardStatus) {
|
||||
fields["stop_reason"] = constants.StopReasonCarrierStopped
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user