Update_RealTimeJobCeshi.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using FCS.Common;
  9. using FCS.Crawler.ZCLotteryAgainst;
  10. using FCS.Crawler.ZCLotteryAsianDish;
  11. using FCS.Crawler.ZCLotteryGames;
  12. using FCS.Crawler.ZCLotteryGrouping;
  13. using FCS.Crawler.ZCLotteryIP;
  14. using FCS.Crawler.ZCLotteryMatchs;
  15. using FCS.Crawler.ZCLotteryScore;
  16. using FCS.Crawler.ZCLotterySizeIndex;
  17. using FCS.Crawler.ZCLotteryTeam;
  18. using FCS.Interface;
  19. using FCS.Models;
  20. using Quartz;
  21. namespace FCS.Crawler
  22. {
  23. public class Update_RealTimeJobCeshi : CommonJob, IJob
  24. {
  25. public void Execute(IJobExecutionContext context)
  26. {
  27. Config = CommonHelper.GetConfigFromDataMap(context.JobDetail.JobDataMap);
  28. Click();
  29. }
  30. public void Click()
  31. {
  32. ThreadPool.SetMaxThreads(500, 500);
  33. CommonHelper.LogBD("Update_RealTimeJobCeshi", "Update_RealTimeJobCeshi");
  34. Trace.WriteLine("Update_RealTimeJobCeshi" + DateTime.Now);
  35. List<int> rlist = new List<int>();
  36. //概率
  37. //var query = services.Query_delete<F_Compensate>("(select * from (select COUNT(GameId) as PK,GameId,BankerCompanyId,CompensateType from F_Compensate where CompensateType='20f77e31d96ae811ab3100ac6a4a134f' group by GameId,BankerCompanyId,CompensateType) as a where a.PK>1)").ToList();
  38. //for (int i = 0; i < query.Count(); i++)
  39. //{
  40. // services.Delete<F_Compensate>(@" and BankerCompanyId = '" + query[i].BankerCompanyId + "' and GameId = '" + query[i].GameId + "' and CompensateType = '" + query[i].CompensateType + "' and PK not in (select top 1 PK from F_Compensate where BankerCompanyId = '" + query[i].BankerCompanyId + "' and GameId = '" + query[i].GameId + "' and CompensateType = '" + query[i].CompensateType + "' order by CreateDateTime desc)");
  41. //}
  42. //foreach (var item in query)
  43. //{
  44. // //delete F_Compensate where GameId='' and BankerCompanyId='' and CompensateType='' and PK not in (select top 1 PK from F_Compensate where GameId='' and BankerCompanyId='' and CompensateType='' order by CreateDateTime desc)
  45. // services.Delete<F_Compensate>(@" and BankerCompanyId = '" + item.BankerCompanyId+ "' and GameId = '"+item.GameId+ "' and CompensateType = '"+item.CompensateType+"' and PK not in (select top 1 PK from F_Compensate where BankerCompanyId = '" + item.BankerCompanyId+ "' and GameId = '"+item.GameId+ "' and CompensateType = '"+item.CompensateType+"' order by CreateDateTime desc)");
  46. // //for (int i = 0; i < querylist.Count; i++)
  47. // //{
  48. // // if (i == 0)
  49. // // continue;
  50. // // rlist.Add(querylist[i].PK);
  51. // //}
  52. //}
  53. //if (rlist.Count > 0)
  54. //{
  55. // int pg = rlist.Count % 1000 == 0 ? rlist.Count / 1000 : rlist.Count / 1000 + 1;
  56. // for (int i = 0; i < pg; i++)
  57. // {
  58. // var listint1 = rlist.Skip(i * 1000).Take(1000).ToList();
  59. // string sql = "delete F_Compensate where PK in (" + string.Join(",", listint1) + ")";
  60. // CommonHelper.LogBD(sql, "Update_RealTimeJobCeshi");
  61. // //services.Delete<F_Compensate>(" and PK in (" + string.Join(",", listint1) + ")");
  62. // }
  63. //}
  64. rlist = new List<int>();
  65. //凯利指数
  66. var query = services.Query_delete<F_Compensate>("(select * from (select COUNT(GameId) as PK,GameId,BankerCompanyId,CompensateType from F_Compensate where CompensateType='21f77e31d96ae811ab3100ac6a4a134f' group by GameId,BankerCompanyId,CompensateType) as a where a.PK>1)").ToList();
  67. foreach (var item in query)
  68. {
  69. var querylist = services.Query<F_Compensate>(" and BankerCompanyId='" + item.BankerCompanyId + "' and GameId='" + item.GameId + "' and CompensateType='" + item.CompensateType + "'").OrderByDescending(a => a.CreateDateTime).ToList();
  70. for (int i = 0; i < querylist.Count; i++)
  71. {
  72. if (i == 0)
  73. continue;
  74. rlist.Add(querylist[i].PK);
  75. }
  76. }
  77. //赔付率
  78. query = services.Query_delete<F_Compensate>("(select * from (select COUNT(GameId) as PK,GameId,BankerCompanyId,CompensateType from F_Compensate where CompensateType='a1bfa33cd96ae811ab3100ac6a4a134f' group by GameId,BankerCompanyId,CompensateType) as a where a.PK>1)").ToList();
  79. foreach (var item in query)
  80. {
  81. var querylist = services.Query<F_Compensate>(" and BankerCompanyId='" + item.BankerCompanyId + "' and GameId='" + item.GameId + "' and CompensateType='" + item.CompensateType + "'").OrderByDescending(a => a.CreateDateTime).ToList();
  82. for (int i = 0; i < querylist.Count; i++)
  83. {
  84. if (i == 0)
  85. continue;
  86. rlist.Add(querylist[i].PK);
  87. }
  88. }
  89. if (rlist.Count > 0)
  90. {
  91. for (int i = 0; i < rlist.Count(); i++)
  92. {
  93. services.Delete<F_Compensate>(" and PK = " + rlist[i] + "");
  94. }
  95. //foreach (var item in rlist)
  96. //{
  97. // services.Delete<F_Compensate>(" and PK = "+item+"");
  98. //}
  99. //int pg = rlist.Count % 1000 == 0 ? rlist.Count / 1000 : rlist.Count / 1000 + 1;
  100. //for (int i = 0; i < pg; i++)
  101. //{
  102. // var listint1 = rlist.Skip(i * 1000).Take(1000).ToList();
  103. // string sql = "delete F_Compensate where PK in (" + string.Join(",", listint1) + ")";
  104. // CommonHelper.LogBD(sql, "Update_RealTimeJobCeshi");
  105. // //services.Delete<F_Compensate>(" and PK in (" + string.Join(",", listint1) + ")");
  106. //}
  107. }
  108. //List<int> rlist = new List<int>();
  109. //var querygame = services.Query<F_Games>().ToList();
  110. //querygame = new List<F_Games>();
  111. ////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表达式去重
  112. ////var q1 = querygame.OrderBy(a => a.CreateDateTime).GroupBy(p => new { p.HomeTeamId, p.VisitingTeamId, p.StartDateTime, p.GroupingId }).Select(g => g.Last()).ToList();
  113. ////foreach (var item in querygame)
  114. ////{
  115. //// if (q1.Where(a => a.PK == item.PK).ToList().Count > 0)
  116. //// {
  117. //// continue;
  118. //// }
  119. //// else
  120. //// {
  121. //// rlist.Add(item.PK);
  122. //// }
  123. ////}
  124. ////if (rlist.Count > 0)
  125. ////{
  126. //// int pg = rlist.Count % 10000 == 0 ? rlist.Count / 10000 : rlist.Count / 10000 + 1;
  127. //// for (int i = 0; i < pg; i++)
  128. //// {
  129. //// var listint1 = rlist.Skip(i * 10000).Take(10000).ToList();
  130. //// services.Delete<F_Games>(" and PK in (" + string.Join(",", listint1) + ")");
  131. //// }
  132. ////}
  133. //rlist = new List<int>();
  134. //var q2 = querygame.OrderBy(a => a.CreateDateTime).GroupBy(p => new { p.HomeTeamId, p.VisitingTeamId,p.GroupingId }).Select(g => g.Last()).ToList();
  135. //foreach (var item in q2)
  136. //{
  137. // if (querygame.Where(a => a.HomeTeamId == item.HomeTeamId && a.VisitingTeamId == item.VisitingTeamId && a.GroupingId == item.GroupingId).ToList().Count > 1)
  138. // {
  139. // var q3 = querygame.Where(a => a.HomeTeamId == item.HomeTeamId && a.VisitingTeamId == item.VisitingTeamId && a.GroupingId == item.GroupingId).ToList();
  140. // foreach (var item1 in q3)
  141. // {
  142. // if (item1.PK != item.PK)
  143. // {
  144. // rlist.Add(item.PK);
  145. // }
  146. // }
  147. // }
  148. //}
  149. //if (rlist.Count > 0)
  150. //{
  151. // int pg = rlist.Count % 10000 == 0 ? rlist.Count / 10000 : rlist.Count / 10000 + 1;
  152. // for (int i = 0; i < pg; i++)
  153. // {
  154. // var listint1 = rlist.Skip(i * 10000).Take(10000).ToList();
  155. // services.Delete<F_Games>(" and PK in (" + string.Join(",", listint1) + ")");
  156. // }
  157. //}
  158. CommonHelper.LogBD("获取完Update_RealTimeJobToDay10", "Update_RealTimeJobCeshi");
  159. Trace.WriteLine("获取完Update_RealTimeJobToDay10" + DateTime.Now);
  160. }
  161. }
  162. }