123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- using cuidian.Sql;
- using log4net;
- using Quartz;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using TempDbToUfida;
- using TempDbToUfida.OpenApi;
- using TempDbToWang;
- using UfidaToTempDb;
- using WangToTempDb;
- namespace TaskSchedule
- {
- [DisallowConcurrentExecution]
- public class U8_to_Wang : IJob
- {
- private static readonly ILog Logger = LogManager.GetLogger("job1");
- #region U8到中间初始化
- List<BaseTrans> btList = new List<BaseTrans>{
- new TransRdrecord08(),
- new TransRdrecord09()
- };
- Hashtable args = new Hashtable();
- List<string> entityTypeStr1List = new List<string>("其他入库,其他出库,采购入库,材料出库,组装入库,组装出库,委外加工".Split(','));
- #endregion
- #region 中间到旺店通初始化
- //List<string> entityTypeStr2List = new List<string>("其他入库,其他出库,采购入库,材料出库,组装入库,组装出库,委外加工".Split(','));
- Hashtable argss = new Hashtable();
- List<TempDbToWang.BaseUpload> buList = new List<TempDbToWang.BaseUpload>
- {
- new UploadRdrecord08(),
- new UploadRdrecord09()
- };
- #endregion
- //u8到中间
- public void Execute(IJobExecutionContext context)
- {
- //取表数据
- 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"));
- #region U8到中间实现
- for (int i = 0; i < btList.Count; i++)
- {
- if (i == 0)
- {
- Console.WriteLine("-------------------正在入库---------------------");
- //取初始时间
- args["Start"] = dt.Rows[i].ItemArray[1].ToString();
- //记录现在时间
- args["End"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime2=DATEADD(SECOND,+1,'{0}') where entitytype='{1}' or entitytype='{2}' or entitytype='{3}' or entitytype='{4}'",
- args["End"],
- dt.Rows[0].ItemArray[0].ToString(), dt.Rows[2].ItemArray[0].ToString(), dt.Rows[4].ItemArray[0].ToString(), dt.Rows[6].ItemArray[0].ToString()),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\U8到中间.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "go1()." + btList[i]);
- }
- Console.WriteLine(args["Start"]);
- Console.WriteLine(args["End"]);
- btList[i].TransData(args);
- Console.WriteLine("入库完成");
- }
- else if (i == 1)
- {
- Console.WriteLine("-------------------正在出库---------------------");
- //取初始时间
- args["Start"] = dt.Rows[i].ItemArray[1].ToString();
- //记录现在时间
- args["End"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime2=DATEADD(SECOND,+1,'{0}') where entitytype='{1}' or entitytype='{2}' or entitytype='{3}'",
- args["End"],
- dt.Rows[1].ItemArray[0].ToString(), dt.Rows[3].ItemArray[0].ToString(), dt.Rows[5].ItemArray[0].ToString()),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\U8到中间.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "go1()." + btList[i]);
- }
- Console.WriteLine(args["Start"]);
- Console.WriteLine(args["End"]);
- btList[i].TransData(args);
- Console.WriteLine("出库完成");
- }
- }
- #endregion
- #region 中间到旺店通实现
- foreach (var item in buList)
- {
- item.UploadToWang(argss);
- Console.WriteLine("---------旺店通从中间下载完成--------------");
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到旺店通.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endgo2()." + item);
- }
- }
- #endregion
- //旺店通到U8,U8到旺店通
- WangToU8();
- }
- #region 旺店通到U8
- #region 初始化
- #region 旺店通到中间初始化
- List<IUpLoad> iup = new List<IUpLoad>
- {
- new VendorUpLoad(),//供应商0
- new WarehouseUpLoad(),//仓库1
- new InventoryUpLoad(),//存货2
- new StockinUpLoad(),//其他入库3
- new StockoutUpLoad(),//其他出库4
- new PO_PomainUpLoad(),//采购订单5
- new InvoiceItemaUpLoad(),//采购入库6
- new PurchaseUpLoad(),//采购退货7
- new DispatchListSendUpLoad(),//销售发货8
- new DispatchListUpLoad()//销售退货9
- };
- #endregion
- #region 中间到U8初始化
- //List<IDownLoad> idow = new List<IDownLoad>
- // {
- // new DownLoadVendor(),//供应商
- // new DownLoadWarehouse(),//仓库
- // new DownLoadInventory(),//存货
- // new DownLoadOtherin(),//其他入库
- // new DownLoadPurchasein(),//采购入库
- // new DownLoadPurchaseorder(),//采购订单
- // new DownLoadPurchasereturn(),//采购退货
- // new DownLoadOtherout(),//其他出库
- // //new DownLoadSaleorder()//销售订单
- // //new DownLoadReturnorder(),//销售出库
- // new DownLoadSellReturn()//销售退货
- // };
- #endregion
- List<string> entitys = new List<string>("供应商,仓库,存货,其他入库,其他出库,采购订单,采购入库,采购退货,销售出库,销售订单".Split(','));
- Dictionary<string, string> argsTwo = new Dictionary<string, string>();
- #endregion
- public void WangToU8()
- {
- #region 实现旺店通到中间
- for (int i = 0; i < iup.Count; i++)
- {
- if (i==8 || i==9)
- {
- continue;
- }
- if (i <= 1)
- {
- iup[i].UpLoad(argsTwo);
- }
- else
- {
- Print(i);
- }
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\旺店通到中间.txt", true))
- {
- Console.WriteLine("旺店通到中间" + iup[i]);
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "job3().to____" + iup[i]);
- }
- }
- #endregion
- #region 中间到u8
- new DownLoadVendor().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "供应商");
- }
- new DownLoadWarehouse().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "仓库");
- }
- new DownLoadInventory().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "存货");
- }
- new DownLoadOtherin().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "其他入库");
- }
- new DownLoadPurchasein().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购入库");
- }
- new DownLoadPurchaseorder().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购订单");
- }
- new DownLoadPurchasereturn().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "采购退货");
- }
- new DownLoadOtherout().DownLoad();
- using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- {
- sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "其他出库");
- }
- //new DownLoadSellReturn().DownLoad();
- //using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\中间到U8.txt", true))
- //{
- // sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "销售退货");
- //}
- //if (DateTime.Now.ToString("HH") == "18" || DateTime.Now.ToString("HH") == "19")
- //{
- // Dictionary<string, string> argsDis = new Dictionary<string, string>();
- // argsDis["start_time"] = DateTime.Now.AddDays(-1).ToString();
- // argsDis["end_time"] = DateTime.Now.AddMinutes(-10).ToString();
- // new DispatchListSendUpLoad().UpLoad(argsDis);//销售退货8
- // new DispatchListUpLoad().UpLoad(argsDis);//销售退货9
- // new DownLoadReturnorder().DownLoad();
- // using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\销售出库到U8.txt", true))
- // {
- // sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ") + "endjob4().to____" + "中间到U8的销售单");
- // }
- //}
- #endregion
- }
- private void Print(int i)
- {
- //取表数据
- DataTable dt = DbUtils.Fill("select entitytype,lasttime from transtime", ConnectionUtils.Instance.GetConnection("TempDB"));
- //取初始时间
- argsTwo["start_time"] = Convert.ToDateTime(dt.Rows[i].ItemArray[1].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
- //记录现在时间
- argsTwo["end_time"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- //DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
- // args["end_time"],
- // dt.Rows[i].ItemArray[0].ToString()),
- // ConnectionUtils.Instance.GetConnection("TempDB"));
- //遍历表数据
- if (i == 6)
- {
- argsTwo["status"] = "60";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- }
- else if (i == 5)
- {
- string _argStarTime = argsTwo["start_time"];
- string _argEndTime = argsTwo["end_time"];
- argsTwo["start_time"] = _argStarTime;
- argsTwo["end_time"] = _argEndTime;
- argsTwo["status"] = "30";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- argsTwo["start_time"] = _argStarTime;
- argsTwo["end_time"] = _argEndTime;
- argsTwo["status"] = "40";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- argsTwo["start_time"] = _argStarTime;
- argsTwo["end_time"] = _argEndTime;
- argsTwo["status"] = "43";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- argsTwo["start_time"] = _argStarTime;
- argsTwo["end_time"] = _argEndTime;
- argsTwo["status"] = "48";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- argsTwo["start_time"] = _argStarTime;
- argsTwo["end_time"] = _argEndTime;
- argsTwo["status"] = "70";
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- }
- else
- {
- Realize.GetDaysAndExecute(argsTwo, iup[i], entitys[i]);
- }
-
- }
- #endregion
- }
- }
|