package service import ( "gat1400Exchange/client" "gat1400Exchange/config" "gat1400Exchange/models" "gat1400Exchange/pkg" "gat1400Exchange/pkg/logger" "gat1400Exchange/vo" ) var resendTaskRunning bool func ResendImageData() { if resendTaskRunning { return } resendTaskRunning = true defer func() { resendTaskRunning = false }() var cacheMod models.Cache total, _ := cacheMod.Count() if total == 0 { return } logger.Info("Start resend task. cache len:%d", total) for i := 0; i < int(total); i++ { var c models.Cache err := c.First() if err != nil { logger.Error(err.Error()) return } if c.Type == "1400-face" { if client.FaceCapture([]byte(c.Data)) != vo.StatusSuccess { c.UpdateRetryCount() logger.Warn("The data resend failed. retry count %d", c.Retry+1) return } } else if c.Type == "1400-person" { if client.PersonCapture([]byte(c.Data)) != vo.StatusSuccess { c.UpdateRetryCount() logger.Warn("The data resend failed. retry count %d", c.Retry+1) return } } else { if !pkg.SendData([]byte(c.Data), config.ForwardConf.SyncServer) { c.UpdateRetryCount() logger.Warn("The data resend failed. retry count %d", c.Retry+1) return } } c.Delete() logger.Debug("The data resend successful.") } }