Realize.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using cuidian.Sql;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using WangToTempDb;
  8. namespace TaskSchedule
  9. {
  10. public class Realize
  11. {
  12. //public static bool ______flag=true;
  13. /// <summary>
  14. /// 按天遍历
  15. /// </summary>
  16. /// <param name="dic" iup="iup"></param>
  17. public static void GetDaysAndExecute(Dictionary<string, string> dic, IUpLoad iup, string entity)
  18. {
  19. //保存最末时间
  20. string endTimeStr = dic["end_time"];
  21. //两个时间间隔
  22. double end = Convert.ToDateTime(dic["end_time"]).Subtract(Convert.ToDateTime(dic["start_time"])).TotalDays;
  23. //判断间隔是否大于30天,是则一天一天遍历
  24. if (end > 30)
  25. {
  26. for (int i = 0; i <= end; i++)
  27. {
  28. if (i == (int)end)
  29. {
  30. dic["end_time"] = endTimeStr;
  31. iup.UpLoad(dic);
  32. if (entity == "其他入库")
  33. {
  34. IUpLoad iupThree = new StockinUpLoad();
  35. dic.Add("status", "60");
  36. dic.Add("order_type", "2");
  37. iupThree.UpLoad(dic);
  38. dic.Remove("status");
  39. dic.Remove("order_type");
  40. }
  41. }
  42. else
  43. {
  44. dic["start_time"] = (Convert.ToDateTime(dic["start_time"])).ToString();
  45. //给endTime//天数加1
  46. dic["end_time"] = (Convert.ToDateTime(dic["start_time"]).AddDays(1)).ToString();
  47. //旺店通到中间
  48. iup.UpLoad(dic);
  49. if (entity == "其他入库")
  50. {
  51. IUpLoad iupThree = new StockinUpLoad();
  52. dic.Add("status", "60");
  53. dic.Add("order_type", "2");
  54. iupThree.UpLoad(dic);
  55. dic.Remove("status");
  56. dic.Remove("order_type");
  57. }
  58. }
  59. Console.WriteLine("---------------");
  60. Console.WriteLine(dic["start_time"]);
  61. Console.WriteLine(dic["end_time"]);
  62. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  63. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
  64. dic["end_time"],
  65. entity),
  66. ConnectionUtils.Instance.GetConnection("TempDB"));
  67. //实现后更新遍历时间
  68. dic["start_time"] = (Convert.ToDateTime(dic["end_time"]).AddSeconds(1)).ToString();
  69. }
  70. }
  71. else
  72. {
  73. iup.UpLoad(dic);
  74. if (entity == "其他入库")
  75. {
  76. IUpLoad iupThree = new StockinUpLoad();
  77. dic.Add("status", "60");
  78. dic.Add("order_type", "2");
  79. iupThree.UpLoad(dic);
  80. dic.Remove("status");
  81. dic.Remove("order_type");
  82. }
  83. Console.WriteLine("------------------");
  84. Console.WriteLine(dic["start_time"]);
  85. Console.WriteLine(dic["end_time"]);
  86. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  87. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
  88. dic["end_time"],
  89. entity),
  90. ConnectionUtils.Instance.GetConnection("TempDB"));
  91. }
  92. }
  93. /// <summary>
  94. /// 按小时遍历
  95. /// </summary>
  96. /// <param name="dic" iup="iup"></param>
  97. public static void GetHoursAndExecute(Dictionary<string, string> dic, IUpLoad iup, string entity)
  98. {
  99. //保存最末时间
  100. string endTimeStr = dic["end_time"];
  101. //两个时间间隔
  102. double end = Convert.ToDateTime(dic["end_time"]).Subtract(Convert.ToDateTime(dic["start_time"])).TotalHours;
  103. //判断间隔是否大于1个小时,是则按小时遍历
  104. if (end > 1)
  105. {
  106. for (int i = 0; i <= end; i++)
  107. {
  108. if (i == (int)end)
  109. {
  110. dic["end_time"] = endTimeStr;
  111. iup.UpLoad(dic);
  112. if (entity == "销售出库")
  113. {
  114. IUpLoad iupTwo = new DispatchListSendUpLoad();
  115. iupTwo.UpLoad(dic);
  116. }
  117. else if (entity == "其他入库")
  118. {
  119. IUpLoad iupThree = new StockinUpLoad();
  120. dic.Add("status", "60");
  121. dic.Add("order_type", "2");
  122. iupThree.UpLoad(dic);
  123. dic.Remove("status");
  124. dic.Remove("order_type");
  125. }
  126. }
  127. else
  128. {
  129. dic["start_time"] = (Convert.ToDateTime(dic["start_time"])).ToString();
  130. //给endTime//天数加1
  131. dic["end_time"] = (Convert.ToDateTime(dic["start_time"]).AddHours(1)).ToString();
  132. //旺店通到中间
  133. iup.UpLoad(dic);
  134. if (entity == "销售出库")
  135. {
  136. IUpLoad iupTwo = new DispatchListSendUpLoad();
  137. iupTwo.UpLoad(dic);
  138. }
  139. else if (entity == "其他入库")
  140. {
  141. IUpLoad iupThree = new StockinUpLoad();
  142. dic.Add("status", "60");
  143. dic.Add("order_type", "2");
  144. iupThree.UpLoad(dic);
  145. dic.Remove("status");
  146. dic.Remove("order_type");
  147. }
  148. }
  149. Console.WriteLine("---------------");
  150. Console.WriteLine(dic["start_time"]);
  151. Console.WriteLine(dic["end_time"]);
  152. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  153. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
  154. dic["end_time"],
  155. entity),
  156. ConnectionUtils.Instance.GetConnection("TempDB"));
  157. //实现后更新遍历时间
  158. dic["start_time"] = (Convert.ToDateTime(dic["end_time"]).AddSeconds(1)).ToString();
  159. }
  160. }
  161. else
  162. {
  163. iup.UpLoad(dic);
  164. if (entity == "销售出库")
  165. {
  166. IUpLoad iupTwo = new DispatchListSendUpLoad();
  167. iupTwo.UpLoad(dic);
  168. }
  169. else if (entity == "其他入库")
  170. {
  171. IUpLoad iupThree = new StockinUpLoad();
  172. dic.Add("status", "60");
  173. dic.Add("order_type", "2");
  174. iupThree.UpLoad(dic);
  175. dic.Remove("status");
  176. dic.Remove("order_type");
  177. }
  178. Console.WriteLine("------------------");
  179. Console.WriteLine(dic["start_time"]);
  180. Console.WriteLine(dic["end_time"]);
  181. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  182. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
  183. dic["end_time"],
  184. entity),
  185. ConnectionUtils.Instance.GetConnection("TempDB"));
  186. }
  187. }
  188. }
  189. }