wangchuanjin 5 månader sedan
förälder
incheckning
63e2fb2395
1 ändrade filer med 8 tillägg och 9 borttagningar
  1. 8 9
      pushsubscribe/push/job/nomsgtipjob.go

+ 8 - 9
pushsubscribe/push/job/nomsgtipjob.go

@@ -59,16 +59,12 @@ func (n *NoMsgTipJob) Execute(taskType int) {
 	lock := &sync.Mutex{}
 	allTipsA, allTipsB := []*UserInfo{}, []*UserInfo{}
 	for temp := make(map[string]interface{}); it.Next(&temp); {
-		isTake := MonitorTimeOut(pushPool, time.Minute, Config.TimeoutWarn, func() {
-			logger.Error("推送任务", taskType, "推送放入通道超时,", temp["_id"])
-		})
+		pushPool <- true
 		pushWait.Add(1)
-		go func(m map[string]interface{}, take bool) {
+		go func(m map[string]interface{}) {
 			defer util.Catch()
 			defer func() {
-				if take {
-					<-pushPool
-				}
+				<-pushPool
 				pushWait.Done()
 			}()
 			user := NewUserInfo(m, 1)
@@ -91,7 +87,7 @@ func (n *NoMsgTipJob) Execute(taskType int) {
 				}
 				lock.Unlock()
 			}
-		}(temp, isTake)
+		}(temp)
 		temp = make(map[string]interface{})
 	}
 	pushWait.Wait()
@@ -108,7 +104,9 @@ func (n *NoMsgTipJob) Execute(taskType int) {
 	}
 	n.beforeTip(taskType, allTipsA, wxTplSurplus, noMsgTipLastId)
 	n.beforeTip(taskType, allTipsB, wxTplSurplus, noMsgTipLastId)
-	Task.NoMsgTipLastId = noMsgTipLastId.Load().(string)
+	if noMsgTipLastId.Load() != nil {
+		Task.NoMsgTipLastId = noMsgTipLastId.Load().(string)
+	}
 	util.WriteSysConfig("./task.json", &Task)
 	logger.Info("无消息提醒任务结束。。。", taskType)
 }
@@ -159,6 +157,7 @@ func (n *NoMsgTipJob) beforeTip(taskType int, allTip []*UserInfo, wxTplSurplus i
 			n.toTip(taskType, user, wxTplSurplus, noMsgTipLastId)
 		}(v, isTake)
 	}
+	pushWait.Wait()
 }
 
 //