sueblue 6 years ago
parent
commit
6d5208a895

+ 12 - 12
FCS.Crawler/Content/UpdateService/UpdateJobs/Update_RealTimeJobBefore.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;
@@ -24,6 +23,10 @@ namespace FCS.Crawler
 {
     public class Update_RealTimeJobBefore : CommonJob, IJob
     {
+        public Update_RealTimeJobBefore()
+        {
+            logName = "Update_RealTimeJobBefore";
+        }
         public void Execute(IJobExecutionContext context)
         {
             Config = CommonHelper.GetConfigFromDataMap(context.JobDetail.JobDataMap);
@@ -33,15 +36,17 @@ namespace FCS.Crawler
         public void Click()
         {
             ThreadPool.SetMaxThreads(200, 200);
-            CommonHelper.LogBD("开始Update_RealTimeJobBefore" + DateTime.Now);
+            CommonHelper.LogBD("开始Update_RealTimeJobBefore", logName);
+            Trace.WriteLine("开始Update_RealTimeJobBefore" + DateTime.Now);
 
             #region 从第十天之前的数据
-            var querylist1 = services.Query<F_Games>(" AND IsObtain=0 ").Where(a => a.StartDateTime < Convert.ToDateTime(DateTime.Now.AddDays(10).ToShortDateString())).ToList();
+            var querylist1 = services.Query<F_Games>(" AND IsObtain=0 ").Where(a => a.StartDateTime < Convert.ToDateTime(DateTime.Now.ToShortDateString())).ToList();
             querylist1 = querylist1.Where((x, i) => querylist1.FindIndex(z => z.Id == x.Id) == i).ToList();//Lambda表达式去重
-            int pagelist1 = querylist1.Count % 500 == 0 ? querylist1.Count / 500 : querylist1.Count / 500 + 1;
+            int pagelist1 = querylist1.Count % 300 == 0 ? querylist1.Count / 300 : querylist1.Count / 300 + 1;
             for (int i = 0; i < pagelist1; i++)
             {
-                var query1 = querylist1.Skip(i * 500).Take(500).ToList();
+                //Thread.Sleep(50000);
+                var query1 = querylist1.Skip(i * 300).Take(300).ToList();
                 // list = query;
                 var task1 = new Task(() =>
                 {
@@ -69,13 +74,8 @@ namespace FCS.Crawler
                     services.Update<F_Games>(" and Id in ('" + string.Join("','", listint) + "')");
             }
             #endregion
-
-            while (true)
-            {
-                if (CommonHelper.ThreadsFinsh())
-                    break;
-            }
-            CommonHelper.LogBD("获取完Update_RealTimeJobBefore" + DateTime.Now);
+            CommonHelper.LogBD("获取完Update_RealTimeJobBefore", logName);
+            Trace.WriteLine("获取完Update_RealTimeJobBefore" + DateTime.Now);
         }
     }
 

+ 97 - 0
FCS.Crawler/Content/UpdateService/UpdateJobs/Update_RealTimeJobCeshi.cs

@@ -0,0 +1,97 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using FCS.Common;
+using FCS.Crawler.ZCLotteryAgainst;
+using FCS.Crawler.ZCLotteryAsianDish;
+using FCS.Crawler.ZCLotteryGames;
+using FCS.Crawler.ZCLotteryGrouping;
+using FCS.Crawler.ZCLotteryIP;
+using FCS.Crawler.ZCLotteryMatchs;
+using FCS.Crawler.ZCLotteryScore;
+using FCS.Crawler.ZCLotterySizeIndex;
+using FCS.Crawler.ZCLotteryTeam;
+using FCS.Interface;
+using FCS.Models;
+using Quartz;
+
+namespace FCS.Crawler
+{
+    public class Update_RealTimeJobCeshi : CommonJob, IJob
+    {
+        public void Execute(IJobExecutionContext context)
+        {
+            Config = CommonHelper.GetConfigFromDataMap(context.JobDetail.JobDataMap);
+            Click();
+        }
+
+        public void Click()
+        {
+            ThreadPool.SetMaxThreads(500, 500);
+            CommonHelper.LogBD("Update_RealTimeJobCeshi" + DateTime.Now);
+            Trace.WriteLine("Update_RealTimeJobCeshi" + DateTime.Now);
+
+            List<int> rlist = new List<int>();
+            var querygame = services.Query<F_Games>().ToList();
+            querygame = new List<F_Games>();
+            //var q1 = querygame.Where((x, i) => querygame.FindIndex(z => z.HomeTeamId == x.HomeTeamId&& z.VisitingTeamId == x.VisitingTeamId && z.StartDateTime == x.StartDateTime && z.GroupingId == x.GroupingId && z.Season == x.Season) == i).ToList();//Lambda表达式去重
+            //var q1 = querygame.OrderBy(a => a.CreateDateTime).GroupBy(p => new { p.HomeTeamId, p.VisitingTeamId, p.StartDateTime, p.GroupingId }).Select(g => g.Last()).ToList();
+            //foreach (var item in querygame)
+            //{
+            //    if (q1.Where(a => a.PK == item.PK).ToList().Count > 0)
+            //    {
+            //        continue;
+            //    }
+            //    else
+            //    {
+            //        rlist.Add(item.PK);
+            //    }
+            //}
+            //if (rlist.Count > 0)
+            //{
+            //    int pg = rlist.Count % 10000 == 0 ? rlist.Count / 10000 : rlist.Count / 10000 + 1;
+            //    for (int i = 0; i < pg; i++)
+            //    {
+            //        var listint1 = rlist.Skip(i * 10000).Take(10000).ToList();
+            //        services.Delete<F_Games>(" and PK in (" + string.Join(",", listint1) + ")");
+            //    }
+            //}
+
+            rlist = new List<int>();
+            var q2 = querygame.OrderBy(a => a.CreateDateTime).GroupBy(p => new { p.HomeTeamId, p.VisitingTeamId,p.GroupingId }).Select(g => g.Last()).ToList();
+            foreach (var item in q2)
+            {
+                if (querygame.Where(a => a.HomeTeamId == item.HomeTeamId && a.VisitingTeamId == item.VisitingTeamId && a.GroupingId == item.GroupingId).ToList().Count > 1)
+                {
+                    var q3 = querygame.Where(a => a.HomeTeamId == item.HomeTeamId && a.VisitingTeamId == item.VisitingTeamId && a.GroupingId == item.GroupingId).ToList();
+                    foreach (var item1 in q3)
+                    {
+                        if (item1.PK != item.PK)
+                        {
+                            rlist.Add(item.PK);
+                        }
+                    }
+                    
+                }
+            }
+            if (rlist.Count > 0)
+            {
+                int pg = rlist.Count % 10000 == 0 ? rlist.Count / 10000 : rlist.Count / 10000 + 1;
+                for (int i = 0; i < pg; i++)
+                {
+                    var listint1 = rlist.Skip(i * 10000).Take(10000).ToList();
+                    services.Delete<F_Games>(" and PK in (" + string.Join(",", listint1) + ")");
+                }
+            }
+
+
+            CommonHelper.LogBD("获取完Update_RealTimeJobToDay10" + DateTime.Now);
+            Trace.WriteLine("获取完Update_RealTimeJobToDay10" + DateTime.Now);
+        }
+    }
+
+}

+ 10 - 9
FCS.Crawler/Content/UpdateService/UpdateJobs/Update_RealTimeJobToDay10.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;
@@ -24,6 +23,10 @@ namespace FCS.Crawler
 {
     public class Update_RealTimeJobToDay10 : CommonJob, IJob
     {
+        public Update_RealTimeJobToDay10()
+        {
+            logName = "Update_RealTimeJobToDay10";
+        }
         public void Execute(IJobExecutionContext context)
         {
             Config = CommonHelper.GetConfigFromDataMap(context.JobDetail.JobDataMap);
@@ -33,10 +36,11 @@ namespace FCS.Crawler
         public void Click()
         {
             ThreadPool.SetMaxThreads(200, 200);
-            CommonHelper.LogBD("开始Update_RealTimeJobToDay10" + DateTime.Now);
+            CommonHelper.LogBD("开始Update_RealTimeJobToDay10", logName);
+            Trace.WriteLine("开始Update_RealTimeJobToDay10" + DateTime.Now);
 
             #region 从第二天开始到第十天的数据
-            var querylist = services.Query<F_Games>(" AND IsObtain=0 ").Where(a => a.StartDateTime > Convert.ToDateTime(DateTime.Now.AddDays(1).ToShortDateString())&&a.StartDateTime< Convert.ToDateTime(DateTime.Now.AddDays(10).ToShortDateString())).ToList();
+            var querylist = services.Query<F_Games>("  and StartDateTime>'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "' and StartDateTime < '" + DateTime.Now.AddDays(10).AddHours(1).ToString("yyyy-MM-dd") + "'").Where(a => a.StartDateTime > Convert.ToDateTime(DateTime.Now.AddDays(1).ToShortDateString())&&a.StartDateTime< Convert.ToDateTime(DateTime.Now.AddDays(10).ToShortDateString())).ToList();
             querylist = querylist.Where((x, i) => querylist.FindIndex(z => z.Id == x.Id) == i).ToList();//Lambda表达式去重
             int pagelist = querylist.Count % 500 == 0 ? querylist.Count / 500 : querylist.Count / 500 + 1;
             for (int i = 0; i < pagelist; i++)
@@ -70,12 +74,9 @@ namespace FCS.Crawler
             }
             #endregion
 
-            while (true)
-            {
-                if (CommonHelper.ThreadsFinsh())
-                    break;
-            }
-            CommonHelper.LogBD("获取完Update_RealTimeJobToDay10" + DateTime.Now);
+
+            CommonHelper.LogBD("获取完Update_RealTimeJobToDay10", logName);
+            Trace.WriteLine("获取完Update_RealTimeJobToDay10" + DateTime.Now);
         }
     }