U8_to_Wang.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. using cuidian.Sql;
  2. using log4net;
  3. using Quartz;
  4. using System;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using TempDbToUfida;
  12. using TempDbToUfida.OpenApi;
  13. using TempDbToWang;
  14. using UfidaToTempDb;
  15. using WangToTempDb;
  16. namespace TaskSchedule
  17. {
  18. [DisallowConcurrentExecution]
  19. public class U8_to_Wang : IJob
  20. {
  21. private static readonly ILog Logger = LogManager.GetLogger("job1");
  22. #region U8到中间初始化
  23. List<BaseTrans> btList = new List<BaseTrans>{
  24. new TransRdrecord08(),
  25. new TransRdrecord09()
  26. };
  27. Hashtable args = new Hashtable();
  28. List<string> entityTypeStr1List = new List<string>("其他入库,其他出库,采购入库,材料出库,组装入库,组装出库,委外加工".Split(','));
  29. #endregion
  30. #region 中间到旺店通初始化
  31. //List<string> entityTypeStr2List = new List<string>("其他入库,其他出库,采购入库,材料出库,组装入库,组装出库,委外加工".Split(','));
  32. Hashtable argss = new Hashtable();
  33. List<TempDbToWang.BaseUpload> buList = new List<TempDbToWang.BaseUpload>
  34. {
  35. new UploadRdrecord08(),
  36. new UploadRdrecord09()
  37. };
  38. #endregion
  39. //u8到中间
  40. public void Execute(IJobExecutionContext context)
  41. {
  42. //取表数据
  43. DataTable dt = DbUtils.Fill(string.Format("select entitytype,lasttime2 from transtime where entitytype in('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", entityTypeStr1List[0], entityTypeStr1List[1], entityTypeStr1List[2], entityTypeStr1List[3], entityTypeStr1List[4], entityTypeStr1List[5], entityTypeStr1List[6]), ConnectionUtils.Instance.GetConnection("TempDB"));
  44. #region U8到中间实现
  45. for (int i = 0; i < btList.Count; i++)
  46. {
  47. if (i == 0)
  48. {
  49. Console.WriteLine("-------------------正在入库---------------------");
  50. //取初始时间
  51. args["Start"] = dt.Rows[i].ItemArray[1].ToString();
  52. //记录现在时间
  53. args["End"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
  54. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  55. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime2=DATEADD(SECOND,+1,'{0}') where entitytype='{1}' or entitytype='{2}' or entitytype='{3}' or entitytype='{4}'",
  56. args["End"],
  57. dt.Rows[0].ItemArray[0].ToString(), dt.Rows[2].ItemArray[0].ToString(), dt.Rows[4].ItemArray[0].ToString(), dt.Rows[6].ItemArray[0].ToString()),
  58. ConnectionUtils.Instance.GetConnection("TempDB"));
  59. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\U8到中间.txt", true))
  60. {
  61. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "go1()." + btList[i]);
  62. }
  63. Console.WriteLine(args["Start"]);
  64. Console.WriteLine(args["End"]);
  65. btList[i].TransData(args);
  66. Console.WriteLine("入库完成");
  67. }
  68. else if (i == 1)
  69. {
  70. Console.WriteLine("-------------------正在出库---------------------");
  71. //取初始时间
  72. args["Start"] = dt.Rows[i].ItemArray[1].ToString();
  73. //记录现在时间
  74. args["End"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
  75. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  76. DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime2=DATEADD(SECOND,+1,'{0}') where entitytype='{1}' or entitytype='{2}' or entitytype='{3}'",
  77. args["End"],
  78. dt.Rows[1].ItemArray[0].ToString(), dt.Rows[3].ItemArray[0].ToString(), dt.Rows[5].ItemArray[0].ToString()),
  79. ConnectionUtils.Instance.GetConnection("TempDB"));
  80. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\U8到中间.txt", true))
  81. {
  82. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "go1()." + btList[i]);
  83. }
  84. Console.WriteLine(args["Start"]);
  85. Console.WriteLine(args["End"]);
  86. btList[i].TransData(args);
  87. Console.WriteLine("出库完成");
  88. }
  89. }
  90. #endregion
  91. #region 中间到旺店通实现
  92. foreach (var item in buList)
  93. {
  94. item.UploadToWang(argss);
  95. Console.WriteLine("---------旺店通从中间下载完成--------------");
  96. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到旺店通.txt", true))
  97. {
  98. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endgo2()." + item);
  99. }
  100. }
  101. #endregion
  102. //旺店通到U8,U8到旺店通
  103. WangToU8();
  104. }
  105. #region 旺店通到U8
  106. #region 初始化
  107. #region 旺店通到中间初始化
  108. List<IUpLoad> iup = new List<IUpLoad>
  109. {
  110. new VendorUpLoad(),//供应商0
  111. new WarehouseUpLoad(),//仓库1
  112. new InventoryUpLoad(),//存货2
  113. new StockinUpLoad(),//其他入库3
  114. new StockoutUpLoad(),//其他出库4
  115. new PO_PomainUpLoad(),//采购订单5
  116. new InvoiceItemaUpLoad(),//采购入库6
  117. new PurchaseUpLoad(),//采购退货7
  118. new DispatchListSendUpLoad(),//销售发货8
  119. new DispatchListUpLoad()//销售退货9
  120. };
  121. #endregion
  122. #region 中间到U8初始化
  123. //List<IDownLoad> idow = new List<IDownLoad>
  124. // {
  125. // new DownLoadVendor(),//供应商
  126. // new DownLoadWarehouse(),//仓库
  127. // new DownLoadInventory(),//存货
  128. // new DownLoadOtherin(),//其他入库
  129. // new DownLoadPurchasein(),//采购入库
  130. // new DownLoadPurchaseorder(),//采购订单
  131. // new DownLoadPurchasereturn(),//采购退货
  132. // new DownLoadOtherout(),//其他出库
  133. // //new DownLoadSaleorder()//销售订单
  134. // //new DownLoadReturnorder(),//销售出库
  135. // new DownLoadSellReturn()//销售退货
  136. // };
  137. #endregion
  138. List<string> entitys = new List<string>("供应商,仓库,存货,其他入库,其他出库,采购订单,采购入库,采购退货,销售出库,销售订单".Split(','));
  139. Dictionary<string, string> argsTwo = new Dictionary<string, string>();
  140. #endregion
  141. public void WangToU8()
  142. {
  143. #region 实现旺店通到中间
  144. for (int i = 0; i < iup.Count; i++)
  145. {
  146. if (i==8 || i==9)
  147. {
  148. continue;
  149. }
  150. if (i <= 1)
  151. {
  152. iup[i].UpLoad(argsTwo);
  153. }
  154. else
  155. {
  156. Print(i);
  157. }
  158. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\旺店通到中间.txt", true))
  159. {
  160. Console.WriteLine("旺店通到中间" + iup[i]);
  161. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "job3().to____" + iup[i]);
  162. }
  163. }
  164. #endregion
  165. #region 中间到u8
  166. new DownLoadVendor().DownLoad();
  167. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  168. {
  169. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "供应商");
  170. }
  171. new DownLoadWarehouse().DownLoad();
  172. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  173. {
  174. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "仓库");
  175. }
  176. new DownLoadInventory().DownLoad();
  177. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  178. {
  179. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "存货");
  180. }
  181. new DownLoadOtherin().DownLoad();
  182. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  183. {
  184. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "其他入库");
  185. }
  186. new DownLoadPurchasein().DownLoad();
  187. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  188. {
  189. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购入库");
  190. }
  191. new DownLoadPurchaseorder().DownLoad();
  192. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  193. {
  194. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购订单");
  195. }
  196. new DownLoadPurchasereturn().DownLoad();
  197. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  198. {
  199. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购退货");
  200. }
  201. new DownLoadOtherout().DownLoad();
  202. using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  203. {
  204. sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "其他出库");
  205. }
  206. //new DownLoadSellReturn().DownLoad();
  207. //using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
  208. //{
  209. // sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "销售退货");
  210. //}
  211. //if (DateTime.Now.ToString("HH") == "18" || DateTime.Now.ToString("HH") == "19")
  212. //{
  213. // Dictionary<string, string> argsDis = new Dictionary<string, string>();
  214. // argsDis["start_time"] = DateTime.Now.AddDays(-1).ToString();
  215. // argsDis["end_time"] = DateTime.Now.AddMinutes(-10).ToString();
  216. // new DispatchListSendUpLoad().UpLoad(argsDis);//销售退货8
  217. // new DispatchListUpLoad().UpLoad(argsDis);//销售退货9
  218. // new DownLoadReturnorder().DownLoad();
  219. // using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\销售出库到U8.txt", true))
  220. // {
  221. // sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "中间到U8的销售单");
  222. // }
  223. //}
  224. #endregion
  225. }
  226. private void Print(int i)
  227. {
  228. //取表数据
  229. DataTable dt = DbUtils.Fill("select entitytype,lasttime from transtime", ConnectionUtils.Instance.GetConnection("TempDB"));
  230. //取初始时间
  231. argsTwo["start_time"] = Convert.ToDateTime(dt.Rows[i].ItemArray[1].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
  232. //记录现在时间
  233. argsTwo["end_time"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
  234. //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
  235. //DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
  236. // args["end_time"],
  237. // dt.Rows[i].ItemArray[0].ToString()),
  238. // ConnectionUtils.Instance.GetConnection("TempDB"));
  239. //遍历表数据
  240. if (i == 6)
  241. {
  242. argsTwo["status"] = "60";
  243. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  244. }
  245. else if (i == 5)
  246. {
  247. string _argStarTime = argsTwo["start_time"];
  248. string _argEndTime = argsTwo["end_time"];
  249. argsTwo["start_time"] = _argStarTime;
  250. argsTwo["end_time"] = _argEndTime;
  251. argsTwo["status"] = "30";
  252. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  253. argsTwo["start_time"] = _argStarTime;
  254. argsTwo["end_time"] = _argEndTime;
  255. argsTwo["status"] = "40";
  256. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  257. argsTwo["start_time"] = _argStarTime;
  258. argsTwo["end_time"] = _argEndTime;
  259. argsTwo["status"] = "43";
  260. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  261. argsTwo["start_time"] = _argStarTime;
  262. argsTwo["end_time"] = _argEndTime;
  263. argsTwo["status"] = "48";
  264. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  265. argsTwo["start_time"] = _argStarTime;
  266. argsTwo["end_time"] = _argEndTime;
  267. argsTwo["status"] = "70";
  268. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  269. }
  270. else
  271. {
  272. Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
  273. }
  274. }
  275. #endregion
  276. }
  277. }