sueblue 6 năm trước cách đây
mục cha
commit
163a862ed8

+ 42 - 9
FCS.Crawler/Content/UpdateService/UpdateJobs/Update_RealTimeJob.cs

@@ -12,7 +12,6 @@ using FCS.Crawler.ZCLotteryGames;
 using FCS.Crawler.ZCLotteryGrouping;
 using FCS.Crawler.ZCLotteryIP;
 using FCS.Crawler.ZCLotteryMatchs;
-using FCS.Crawler.ZCLotteryOdds;
 using FCS.Crawler.ZCLotteryScore;
 using FCS.Crawler.ZCLotterySizeIndex;
 using FCS.Crawler.ZCLotteryTeam;
@@ -36,15 +35,49 @@ namespace FCS.Crawler
 
         public void Click()
         {
-            ThreadPool.SetMaxThreads(200, 200);
+            ThreadPool.SetMaxThreads(500, 500);
             CommonHelper.LogBD("开始Update_RealTime", logName);
-            List<F_Games> list = new List<F_Games>();
-            new GamesJob().Click(out list);
-            Task.Run(() => new GamesDetailsJob().Click());
-            Task.Run(() => new ScoreJob().Click());
-            Task.Run(() => new AgainstJob().Click());
-            while (!CommonHelper.ThreadsFinsh())
-                continue;
+            new GamesJob().Click();
+            #region 当天
+            var query = services.Query<F_Games>(" and StartDateTime>'" + DateTime.Now.AddDays(0).ToString("yyyy-MM-dd") + "' and StartDateTime < '" + DateTime.Now.AddDays(1).AddHours(1).ToString("yyyy-MM-dd") + "'").Where(a => a.StartDateTime < Convert.ToDateTime(DateTime.Now.AddDays(1)) && a.StartDateTime > Convert.ToDateTime(DateTime.Now.ToShortDateString())).ToList();
+            query = query.Where((x, i) => query.FindIndex(z => z.Id == x.Id) == i).ToList();//Lambda表达式去重
+            int page = query.Count % 500 == 0 ? query.Count / 500 : query.Count / 500 + 1;
+            for (int i = 0; i < page; i++)
+            {
+                var query1 = query.Skip(i * 500).Take(500).ToList();
+                // list = query;
+                var task1 = new Task(() =>
+                {
+                    new OddsJob().Click(query1, query1);
+                });
+                var task2 = new Task(() =>
+                {
+                    new AsianDishJob().Click(query1, query1);
+                });
+                var task3 = new Task(() =>
+                {
+                    new SizeIndexJob().Click(query1, query1);
+                });
+                task1.Start();
+                task2.Start();
+                task3.Start();
+                Task.WaitAll(task1, task2, task3);
+
+                List<string> listint = new List<string>();
+                foreach (var item in query1)
+                {
+                    listint.Add(item.Id);
+                }
+                if (listint.Count > 0)
+                    services.Update<F_Games>(" and Id in ('" + string.Join("','", listint) + "')");
+            }
+
+            #endregion
+            //Task.Run(() => new GamesDetailsJob().Click());
+            //Task.Run(() => new ScoreJob().Click());
+            //Task.Run(() => new AgainstJob().Click());
+            //while (!CommonHelper.ThreadsFinsh())
+            //    continue;
             CommonHelper.LogBD("结束Update_RealTime", logName);
         }
     }