Fchlj36x7.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. using CP.Cache;
  2. using CP.Common;
  3. using CP.Model;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace CP.Business
  10. {
  11. public class Fchlj36x7
  12. {
  13. /// <summary>
  14. /// 缓存
  15. /// </summary>
  16. static WMCache cache = WMCache.GetCacheService();
  17. /// <summary>
  18. /// cache中的南粤36选7所有数据
  19. /// </summary>
  20. /// <returns></returns>
  21. public static List<Fchlj36x7Info> GetFchlj36x7List()
  22. {
  23. string key = CacheKeys.FCHLJ36X7_DATALIST;
  24. List<Fchlj36x7Info> list = cache.GetObject<List<Fchlj36x7Info>>(key) as List<Fchlj36x7Info>;
  25. if (list == null)
  26. {
  27. list = Fchlj36x7Data.GetFchlj36x7List();
  28. cache.AddObject(key, list, (int)CacheTime.Data);
  29. }
  30. return list;
  31. }
  32. /// <summary>
  33. /// 按条件筛选的36x7数据
  34. /// </summary>
  35. /// <param name="pagesize"></param>
  36. /// <param name="year"></param>
  37. /// <param name="sqi"></param>
  38. /// <param name="eqi"></param>
  39. /// <param name="week"></param>
  40. /// <returns></returns>
  41. public static List<Fchlj36x7Info> GetFchlj36x7List(ref List<Fchlj36x7Info> datalist, int pagesize, int year, int sqi, int eqi, int week = 0)
  42. {
  43. List<Fchlj36x7Info> list = new List<Fchlj36x7Info>();
  44. ///星期x的条件时
  45. ///数据来源不一样.
  46. if (week > 0)
  47. list = GetFchlj36x7WeekList(ref datalist, week);
  48. else
  49. {
  50. list = datalist;
  51. }
  52. List<Fchlj36x7Info> rlist = new List<Fchlj36x7Info>();
  53. if (list != null && list.Count > 0)
  54. {
  55. int size = list.Count;
  56. if (pagesize > 0)
  57. {
  58. for (int i = (size - pagesize); i < size; i++)
  59. {
  60. rlist.Add(list[i]);
  61. }
  62. return rlist;
  63. }
  64. if (year > 0)
  65. {
  66. rlist.Clear();
  67. for (int i = 0; i < size; i++)
  68. {
  69. if (TypeConverter.StrToInt(list[i].qi.ToString().Substring(0, 4), 0) == year)
  70. rlist.Add(list[i]);
  71. }
  72. return rlist;
  73. }
  74. if (sqi > 0 && eqi > 0)
  75. {
  76. rlist.Clear();
  77. int srank = GetFchlj36x7Info(ref list, sqi).rank;
  78. int erank = GetFchlj36x7Info(ref list, eqi).rank;
  79. if (erank != 0 && srank != 0 && erank > srank)
  80. {
  81. for (int i = srank - 1; i < erank && i < size; i++)
  82. {
  83. rlist.Add(list[i]);
  84. }
  85. }
  86. return rlist;
  87. }
  88. if (pagesize == 0 && year == 0 && eqi == 0 && sqi == 0 && week == 0)
  89. return list;
  90. }
  91. return rlist;
  92. }
  93. /// <summary>
  94. /// 36x7星期x的所有数据列表
  95. /// </summary>
  96. /// <param name="week"></param>
  97. /// <returns></returns>
  98. public static List<Fchlj36x7Info> GetFchlj36x7WeekList(ref List<Fchlj36x7Info> list, int week)
  99. {
  100. List<Fchlj36x7Info> rlist = new List<Fchlj36x7Info>();
  101. if (list != null && list.Count > 0)
  102. {
  103. int size = list.Count;
  104. for (int i = 0; i < size; i++)
  105. {
  106. if (list[i].week == week)
  107. rlist.Add(list[i]);
  108. }
  109. }
  110. return rlist;
  111. }
  112. /// <summary>
  113. /// 取某一期的数据
  114. /// 根据期数值
  115. /// </summary>
  116. /// <param name="qi"></param>
  117. /// <returns></returns>
  118. public static Fchlj36x7Info GetFchlj36x7Info(ref List<Fchlj36x7Info> list, int qi)
  119. {
  120. Fchlj36x7Info info = new Fchlj36x7Info();
  121. int size = list.Count;
  122. for (int i = 0; i < size; i++)
  123. {
  124. if (list[i].qi == qi)
  125. {
  126. info = list[i];
  127. break;
  128. }
  129. }
  130. return info;
  131. }
  132. /// <summary>
  133. /// 取出个排名的上一次数据
  134. /// </summary>
  135. /// <param name="rank"></param>
  136. /// <returns></returns>
  137. public static Fchlj36x7Info GetLastFchlj36x7Info(ref List<Fchlj36x7Info> list, int rank)
  138. {
  139. Fchlj36x7Info info = new Fchlj36x7Info();
  140. if (list != null && list.Count > 0)
  141. {
  142. for (int i = rank - 2; i >= 0; i--)
  143. {
  144. if (list[i].rank == rank - 1)
  145. {
  146. info = list[i];
  147. return info;
  148. }
  149. }
  150. }
  151. return info;
  152. }
  153. /// <summary>
  154. /// 取出个排名的下一次数据, 用于开奖公告
  155. /// </summary>
  156. /// <param name="rank"></param>
  157. /// <returns></returns>
  158. public static Fchlj36x7Info GetNextFchlj36x7Info(ref List<Fchlj36x7Info> list, int rank)
  159. {
  160. Fchlj36x7Info info = new Fchlj36x7Info();
  161. if (list != null && list.Count > 0)
  162. {
  163. for (int i = rank - 1; i < list.Count; i++)
  164. {
  165. if (list[i].rank == rank + 1)
  166. {
  167. info = list[i];
  168. return info;
  169. }
  170. }
  171. }
  172. return info;
  173. }
  174. #region 上一次出现时的情况
  175. /// <summary>
  176. /// 上次某个号码出现时的情况
  177. /// </summary>
  178. /// <param name="val"></param>
  179. /// <param name="rank"></param>
  180. /// <returns></returns>
  181. public static Fchlj36x7Info GetLastFchlj36x7Info(ref List<Fchlj36x7Info> list, int val, int rank)
  182. {
  183. Fchlj36x7Info info = new Fchlj36x7Info();
  184. if (list != null && list.Count > 0)
  185. {
  186. int size = list.Count;
  187. for (int i = rank - 2; i >= 0; i--)
  188. {
  189. List<int> kjh = new List<int> { list[i].n1, list[i].n2, list[i].n3, list[i].n4, list[i].n5, list[i].n6, list[i].n7 };
  190. if (kjh.Contains(val))
  191. {
  192. info = list[i];
  193. return info;
  194. }
  195. }
  196. }
  197. return info;
  198. }
  199. /// <summary>
  200. /// 上一次和值val的数据
  201. /// </summary>
  202. /// <param name="val"></param>
  203. /// <param name="rank"></param>
  204. /// <returns></returns>
  205. public static Fchlj36x7Info GetLastHzFchlj36x7Info(ref List<Fchlj36x7Info> list, int shz, int ehz, int rank)
  206. {
  207. Fchlj36x7Info info = new Fchlj36x7Info();
  208. if (list != null && list.Count > 0)
  209. {
  210. for (int i = rank - 2; i >= 0; i--)
  211. {
  212. if (list[i].hz >= shz && list[i].hz <= ehz)
  213. {
  214. info = list[i];
  215. return info;
  216. }
  217. }
  218. }
  219. return info;
  220. }
  221. /// <summary>
  222. /// 上一次和值奇偶形态的数据
  223. /// </summary>
  224. /// <param name="xt"></param>
  225. /// <param name="rank"></param>
  226. /// <returns></returns>
  227. public static Fchlj36x7Info GetLastHzJoFchlj36x7Info(ref List<Fchlj36x7Info> list, int xt, int rank)
  228. {
  229. Fchlj36x7Info info = new Fchlj36x7Info();
  230. if (list != null && list.Count > 0)
  231. {
  232. for (int i = rank - 2; i >= 0; i--)
  233. {
  234. if (xt == 0)
  235. {
  236. if (list[i].hz % 2 != 0)
  237. {
  238. info = list[i];
  239. return info;
  240. }
  241. }
  242. if (xt == 1)
  243. {
  244. if (list[i].hz % 2 == 0)
  245. {
  246. info = list[i];
  247. return info;
  248. }
  249. }
  250. }
  251. }
  252. return info;
  253. }
  254. /// <summary>
  255. /// 上一其和尾val的数据
  256. /// </summary>
  257. /// <param name="val"></param>
  258. /// <param name="rank"></param>
  259. /// <returns></returns>
  260. public static Fchlj36x7Info GetLastHwFchlj36x7Info(ref List<Fchlj36x7Info> list, int val, int rank)
  261. {
  262. Fchlj36x7Info info = new Fchlj36x7Info();
  263. if (list != null && list.Count > 0)
  264. {
  265. for (int i = rank - 2; i >= 0; i--)
  266. {
  267. if (ZstUtils.GetHw(list[i].hz) == val)
  268. {
  269. info = list[i];
  270. return info;
  271. }
  272. }
  273. }
  274. return info;
  275. }
  276. /// <summary>
  277. /// 上一次跨度val的数据
  278. /// </summary>
  279. /// <param name="val"></param>
  280. /// <param name="rank"></param>
  281. /// <returns></returns>
  282. public static Fchlj36x7Info GetLastkdFchlj36x7Info(ref List<Fchlj36x7Info> list, int val, int rank)
  283. {
  284. Fchlj36x7Info info = new Fchlj36x7Info();
  285. if (list != null && list.Count > 0)
  286. {
  287. for (int i = rank - 2; i >= 0; i--)
  288. {
  289. if (list[i].kd == val)
  290. {
  291. info = list[i];
  292. return info;
  293. }
  294. }
  295. }
  296. return info;
  297. }
  298. /// <summary>
  299. /// 上一次跨度奇偶的情况
  300. /// </summary>
  301. /// <param name="xt"></param>
  302. /// <param name="rank"></param>
  303. /// <returns></returns>
  304. public static Fchlj36x7Info GetLastKdJoFchlj36x7Info(ref List<Fchlj36x7Info> list, int xt, int rank)
  305. {
  306. Fchlj36x7Info info = new Fchlj36x7Info();
  307. if (list != null && list.Count > 0)
  308. {
  309. for (int i = rank - 2; i >= 0; i--)
  310. {
  311. if (xt == 0)
  312. {
  313. if (list[i].kd % 2 != 0)
  314. {
  315. info = list[i];
  316. return info;
  317. }
  318. }
  319. if (xt == 1)
  320. {
  321. if (list[i].kd % 2 == 0)
  322. {
  323. info = list[i];
  324. return info;
  325. }
  326. }
  327. }
  328. }
  329. return info;
  330. }
  331. /// <summary>
  332. /// 36x7上次跨度大小的情况
  333. /// </summary>
  334. /// <param name="xt"></param>
  335. /// <param name="rank"></param>
  336. /// <returns></returns>
  337. public static Fchlj36x7Info GetLastKdDxFchlj36x7Info(ref List<Fchlj36x7Info> list, int xt, int rank)
  338. {
  339. Fchlj36x7Info info = new Fchlj36x7Info();
  340. if (list != null && list.Count > 0)
  341. {
  342. for (int i = rank - 2; i >= 0; i--)
  343. {
  344. if (xt == 0)
  345. {
  346. if (list[i].kd > 0)
  347. {
  348. info = list[i];
  349. return info;
  350. }
  351. }
  352. if (xt == 1)
  353. {
  354. if (list[i].kd < 21)
  355. {
  356. info = list[i];
  357. return info;
  358. }
  359. }
  360. }
  361. }
  362. return info;
  363. }
  364. /// <summary>
  365. /// 上次跨度质合的情况
  366. /// </summary>
  367. /// <param name="xt"></param>
  368. /// <param name="rank"></param>
  369. /// <returns></returns>
  370. public static Fchlj36x7Info GetLastKdZhFchlj36x7Info(ref List<Fchlj36x7Info> list, int xt, int rank)
  371. {
  372. Fchlj36x7Info info = new Fchlj36x7Info();
  373. List<int> zh = new List<int> { 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36 };
  374. if (list != null && list.Count > 0)
  375. {
  376. for (int i = rank - 2; i >= 0; i--)
  377. {
  378. if (xt == 0)
  379. {
  380. if (!zh.Contains(list[i].kd))
  381. {
  382. info = list[i];
  383. return info;
  384. }
  385. }
  386. if (xt == 1)
  387. {
  388. if (zh.Contains(list[i].kd))
  389. {
  390. info = list[i];
  391. return info;
  392. }
  393. }
  394. }
  395. }
  396. return info;
  397. }
  398. #endregion
  399. /// <summary>
  400. /// 某期南粤36x7前N期的数据
  401. /// 用于计算南粤36x7基本号冷热情况
  402. /// </summary>
  403. /// <param name="rank">当前期的排名</param>
  404. /// <param name="pagesize">前n期</param>
  405. /// <returns></returns>
  406. public static List<int> GetFchlj36x7HotList(ref List<Fchlj36x7Info> list, int rank, int pagesize)
  407. {
  408. List<int> rlist = new List<int>();
  409. if (list != null && list.Count > 0)
  410. {
  411. int size = list.Count;
  412. for (int i = rank - 2; i >= (rank - pagesize - 1) && i >= 0; i--)
  413. {
  414. rlist.Add(list[i].n1);
  415. rlist.Add(list[i].n2);
  416. rlist.Add(list[i].n3);
  417. rlist.Add(list[i].n4);
  418. rlist.Add(list[i].n5);
  419. rlist.Add(list[i].n6);
  420. rlist.Add(list[i].n7);
  421. }
  422. }
  423. return rlist;
  424. }
  425. #region 开奖公告相关方法
  426. /// <summary>
  427. /// 南粤36选7最近30期开奖数据,完整开奖信息,有缓存
  428. /// </summary>
  429. /// <returns></returns>
  430. public static List<Fchlj36x7LongInfo> GetFchlj36x7ListTop30()
  431. {
  432. string key = string.Format(CacheKeys.FCHLJ36X7_KJH_DATA);
  433. List<Fchlj36x7LongInfo> list = cache.GetObject<List<Fchlj36x7LongInfo>>(key) as List<Fchlj36x7LongInfo>;
  434. if (list == null)
  435. {
  436. list = Fchlj36x7Data.GetFchlj36x7Top30();
  437. cache.AddObject(key, list, (int)CacheTime.Kjh);
  438. }
  439. return list;
  440. }
  441. /// <summary>
  442. /// 获取最新一期开奖信息,完整开奖信息,有缓存
  443. /// </summary>
  444. /// <returns></returns>
  445. public static Fchlj36x7LongInfo GetFchlj36x7InfoTop1(ref List<Fchlj36x7LongInfo> list)
  446. {
  447. Fchlj36x7LongInfo info = new Fchlj36x7LongInfo();
  448. if (list.Count > 0)
  449. {
  450. info = list[0];
  451. }
  452. return info;
  453. }
  454. /// <summary>
  455. /// 根据期数返回某期完整开奖信息,无缓存
  456. /// </summary>
  457. /// <param name="qi"></param>
  458. /// <returns></returns>
  459. public static Fchlj36x7LongInfo GetFchlj36x7InfoByqi(int qi)
  460. {
  461. return Fchlj36x7Data.GetFchlj36x7InfoByQi(qi);
  462. }
  463. /// <summary>
  464. /// 返回某年对应的期数列表,有缓存
  465. /// </summary>
  466. /// <param name="year"></param>
  467. /// <returns></returns>
  468. public static List<int> GetFchlj36x7QiListByYear(int year)
  469. {
  470. string key = string.Format(CacheKeys.FCHLJ36X7_KJH_DATA + "/qilistbyyear/{0}", year);
  471. List<int> list = cache.GetObject<List<int>>(key) as List<int>;
  472. if (list == null)
  473. {
  474. list = Fchlj36x7Data.GetFchlj36x7QiListByYear(year);
  475. cache.AddObject(key, list, (int)CacheTime.System);
  476. }
  477. return list;
  478. }
  479. #endregion
  480. ///end
  481. }
  482. }