public void ProcessRequest(HttpContext context) { var orderId = int.Parse(context.Request["orderId"]); using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { var row = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId); if (row.Count() > 0) { if (row.First().Intention == 5) { row.First().Intention = -3; entities.SaveChanges(); context.Response.Write("ok"); return; } else if (row.First().Intention == 6) { row.First().Intention = -3; var newRow = new JDJS_WMS_Order_Queue_Table { isFlag = 0, OrderID = orderId }; entities.JDJS_WMS_Order_Queue_Table.Add(newRow); entities.SaveChanges(); context.Response.Write("ok"); return; } else { context.Response.Write("已提交"); return; } } } }
public void ProcessRequest(HttpContext context) { int orderId = int.Parse(context.Request["orderId"]); //关联的订单主键ID int output = int.Parse(context.Request["output"]); //订单需求量 string Order_Leader = context.Request["Order_Leader"]; //订单负责人 string Product_Name = context.Request["Product_Name"]; //产品名称 string Project_Name = context.Request["Project_Name"]; //项目名称 string Order_State = context.Request["Order_State"]; //订单状态 var patternStr = (context.Request["pattern"] == null ? "-100" : context.Request["pattern"]); int pattern = int.Parse(patternStr); //生产模式 int loginID = Convert.ToInt32(context.Session["id"]); DateTime Order_Plan_End_Time = Convert.ToDateTime(context.Request["Order_Plan_End_Time"]); //计划结束时间 var Order_Plan_Start_Time = DateTime.Now; var Customer = context.Request["Customer"]; //客户名称 var remark = context.Request["remark"]; #region 订单号 string year = DateTime.Now.Year.ToString().Substring(2, 2); string month = DateTime.Now.Month.ToString(); while (month.Length < 2) { month = month.Insert(0, "0"); } string day = DateTime.Now.Day.ToString(); while (day.Length < 2) { day = day.Insert(0, "0"); } string strOrderNum = year + month + day; int flag = 1; string flagStr = ""; using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { try { while (true) { flagStr = flag.ToString(); while (flagStr.Length < 5) { flagStr = flagStr.Insert(0, "0"); } var order = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == strOrderNum + flagStr); if (order.Count() < 1) { break; } flag++; } } catch (Exception ex) { context.Response.Write(ex.Message); return; } var OldOrder = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId).FirstOrDefault(); if (OldOrder == null) { context.Response.Write("被关联订单不存在,请确认后再试!"); return; } var clientInfo = entities.JDJS_WMS_Order_Guide_Schedu_Table.Where(r => r.OrderID == orderId).FirstOrDefault(); Order_Leader = Order_Leader == null ? OldOrder.Order_Leader : Order_Leader; Product_Name = Product_Name == null? OldOrder.Product_Name : Product_Name; Project_Name = Project_Name == null? OldOrder.ProjectName : Project_Name; Order_State = Order_State == null ? OldOrder.Order_State : Order_State; Customer = Customer == null ?(clientInfo == null?"无": clientInfo.ClientName) : Customer; pattern = pattern == -100 ? ((int)(OldOrder.ProofingORProduct == null?-1: OldOrder.ProofingORProduct)) : pattern; using (System.Data.Entity.DbContextTransaction date = entities.Database.BeginTransaction()) { try { JDJS_WMS_Order_Entry_Table orderentry = new JDJS_WMS_Order_Entry_Table() { Order_Number = strOrderNum + flagStr, Order_Leader = Order_Leader, Product_Name = Product_Name, Product_Material = OldOrder.Product_Material, Product_Output = output, Order_Plan_Start_Time = Order_Plan_Start_Time, Order_Actual_Start_Time = null, Order_Actual_End_Time = null, Order_Plan_End_Time = Order_Plan_End_Time, Engine_Program_Manager = OldOrder.Engine_Program_Manager, Engine_Technology_Manager = OldOrder.Engine_Technology_Manager, Engine_Program_ManagerId = OldOrder.Engine_Program_ManagerId, Engine_Technology_ManagerId = OldOrder.Engine_Technology_ManagerId, Engine_Status = "未进行", Intention = 6, ProjectName = Project_Name, CreateTime = DateTime.Now, CreatePersonID = loginID, Order_State = Order_State, virtualProgPersId = OldOrder.virtualProgPersId, virtualReturnTime = OldOrder.virtualReturnTime, AuditResult = "待审核", CtratPersonID = loginID, //audit_Result = OldOrder.audit_Result, craftPerson = OldOrder.craftPerson, Priority = 1, craftPersonId = OldOrder.craftPersonId, ProofingORProduct = pattern, program_audit_result = null, ParentId = orderId, Remark = remark }; entities.JDJS_WMS_Order_Entry_Table.Add(orderentry); entities.SaveChanges(); int orderIdNew = orderentry.Order_ID; JDJS_WMS_Order_Guide_Schedu_Table guide = new JDJS_WMS_Order_Guide_Schedu_Table() { OrderID = orderIdNew, ClientName = Customer }; entities.JDJS_WMS_Order_Guide_Schedu_Table.Add(guide); entities.SaveChanges(); var queue = new JDJS_WMS_Order_Queue_Table { OrderID = orderIdNew, isFlag = 3 }; entities.JDJS_WMS_Order_Queue_Table.Add(queue); entities.SaveChanges(); date.Commit(); PathInfo pathInfo = new PathInfo(); var NewFolder = Path.Combine(pathInfo.upLoadPath(), strOrderNum + flagStr); var OldFolder = Path.Combine(pathInfo.upLoadPath(), OldOrder.Order_Number); List <string> srcPath = new List <string>(); string[] src = Directory.GetFileSystemEntries(OldFolder); foreach (var item in src) { copyDir(item, NewFolder, strOrderNum + flagStr); } context.Response.Write("ok"); return; } catch (Exception ex) { date.Rollback(); context.Response.Write(ex.Message); return; } } } #endregion }
public void ProcessRequest(HttpContext context) { var form = context.Request.Form; { //写入队列表,先将队列表数据清空,再按照前端传入的数据的顺序写入 List <OrderQueueWrite> orderQueueWrites = new List <OrderQueueWrite>();//定义的一个用于接收前端传入数据的类 for (int i = 0; i < form.Count; i++) { if (form[i] != null) { string[] str = form[i].ToString().Split(','); OrderQueueWrite write = new OrderQueueWrite(); write.OrderID = Convert.ToInt32(str[0]); write.sign = Convert.ToInt32(str[1]); orderQueueWrites.Add(write);//向类的实例中添加数据。每个订单占一个 } } if (true)//是否修改 { using (JDJS_WMS_DB_USEREntities JDJSWMS = new JDJS_WMS_DB_USEREntities()) { using (System.Data.Entity.DbContextTransaction mytran = JDJSWMS.Database.BeginTransaction()) { try { foreach (var item in orderQueueWrites) { if (item.sign == 1) { var queue = JDJSWMS.JDJS_WMS_Order_Queue_Table.Where(r => r.OrderID == item.OrderID && r.isFlag == 1); foreach (var real in queue) { JDJSWMS.JDJS_WMS_Order_Queue_Table.Remove(real);//将订单队列表中的不是意向的清空 } JDJSWMS.SaveChanges(); var procesDevice = JDJSWMS.JDJS_WMS_Order_Process_Scheduling_Table.Where(r => r.OrderID == item.OrderID && r.isFlag == 1); foreach (var real in procesDevice) { JDJSWMS.JDJS_WMS_Order_Process_Scheduling_Table.Remove(real); } JDJSWMS.SaveChanges(); JDJS_WMS_Order_Queue_Table queue_Table = new JDJS_WMS_Order_Queue_Table() { OrderID = item.OrderID, isFlag = item.sign }; JDJSWMS.JDJS_WMS_Order_Queue_Table.Add(queue_Table); JDJSWMS.SaveChanges(); } } JDJSWMS.SaveChanges(); mytran.Commit(); } catch (Exception ex) { Console.WriteLine(ex.Message); mytran.Rollback(); return; } } } virScheduling virScheduling = new virScheduling(); string str = virScheduling.ProcessSchedule(1, 0); context.Response.Write(str); //调用排产程序 } else { context.Response.Write("ok"); } } }
public void ProcessRequest(HttpContext context) { var form = context.Request.Form; var file = context.Request.Files; var projectName = form["projectName"]; var remark = form["remark"]; //备注 var loginID = Convert.ToInt32(context.Session["id"]); int priority = 1; //优先级 string year = DateTime.Now.Year.ToString().Substring(2, 2); string month = DateTime.Now.Month.ToString(); while (month.Length < 2) { month = month.Insert(0, "0"); } string day = DateTime.Now.Day.ToString(); while (day.Length < 2) { day = day.Insert(0, "0"); } string strOrderNum = year + month + day; int flag = 1; string flagStr = ""; // var folder = @"D:\服务器文件勿动\" + form[0]; using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { using (System.Data.Entity.DbContextTransaction date = entities.Database.BeginTransaction()) { try { while (true) { flagStr = flag.ToString(); while (flagStr.Length < 5) { flagStr = flagStr.Insert(0, "0"); } var order = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == strOrderNum + flagStr); if (order.Count() < 1) { break; } flag++; } if (form[0] == "0") { var Order_Number = strOrderNum + flagStr; var Order_Leader = form[2]; var Product_Name = form[3]; var Product_Material = form[4]; var Product_Output = int.Parse(form[5]); var Order_Plan_End_Time = DateTime.Parse(form[6]); var Order_State = form[7]; var Order_Plan_Start_Time = DateTime.Now; var Customer = form[8]; var pattern = int.Parse(form["pattern"]); var judge = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == Order_Number); if (judge.Count() > 0) { context.Response.Write("该订单已存在"); return; } var row = new JDJS_WMS_Order_Entry_Table { Order_Number = Order_Number, Order_Leader = Order_Leader, Product_Name = Product_Name, Product_Material = Product_Material, Product_Output = Product_Output, Order_Plan_End_Time = Order_Plan_End_Time, Order_State = Order_State, Order_Plan_Start_Time = DateTime.Now, Intention = 3, ProjectName = projectName, ProofingORProduct = pattern, CtratPersonID = loginID, Priority = priority, CreateTime = DateTime.Now, CreatePersonID = loginID, AuditResult = "待审核", Remark = remark }; entities.JDJS_WMS_Order_Entry_Table.Add(row); entities.SaveChanges(); var orderId = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == Order_Number).FirstOrDefault().Order_ID; JDJS_WMS_Order_Guide_Schedu_Table guide = new JDJS_WMS_Order_Guide_Schedu_Table() { OrderID = orderId, ClientName = Customer }; entities.JDJS_WMS_Order_Guide_Schedu_Table.Add(guide); entities.SaveChanges(); var queue = new JDJS_WMS_Order_Queue_Table { OrderID = orderId, isFlag = 3 }; entities.JDJS_WMS_Order_Queue_Table.Add(queue); entities.SaveChanges(); PathInfo pathInfo = new PathInfo(); var folder = Path.Combine(pathInfo.upLoadPath(), Order_Number, form[1], @"客供图纸"); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } ; for (int i = 0; i < file.Count; i++) { var name = file[i].FileName; var size = file[i].ContentLength; string path = Path.Combine(folder, name); file[i].SaveAs(path); } entities.SaveChanges(); context.Response.Write("ok"); date.Commit(); } else { var Order_Number = strOrderNum + flagStr; var Order_Leader = form[2]; var oldOrderNumber = form[3]; var Product_Name = form[4]; var Product_Material = form[5]; var Product_Output = int.Parse(form[6]); var Order_Plan_End_Time = DateTime.Parse(form[7]); var Order_State = form[8]; var Order_Plan_Start_Time = DateTime.Now; var Customer = form[9]; { string OrderNum = Order_Number; string OrderOwener = Order_Leader; string OldOrderNum = oldOrderNumber; string ProductName = Product_Name; string ProductMertial = Product_Material; int ProductOutPut = Product_Output; string OrderState = Order_State; DateTime OverTime = DateTime.Now; using (JDJS_WMS_DB_USEREntities wms = new JDJS_WMS_DB_USEREntities()) { var orders = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OrderNum); if (orders.Count() > 0) { Console.WriteLine("该订单号已存在"); return; } else { using (System.Data.Entity.DbContextTransaction mytran = wms.Database.BeginTransaction()) { try { var OldOrderInfo = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OldOrderNum); if (OldOrderInfo.Count() > 0) { JDJS_WMS_Order_Entry_Table orderentry = new JDJS_WMS_Order_Entry_Table() { Order_Number = OrderNum, Order_Leader = OrderOwener, Product_Name = ProductName, Product_Material = ProductMertial, Product_Output = ProductOutPut, Order_Plan_Start_Time = null, Order_Actual_Start_Time = null, Order_Actual_End_Time = null, Order_Plan_End_Time = Order_Plan_End_Time, Engine_Program_Manager = OldOrderInfo.FirstOrDefault().Engine_Program_Manager, Engine_Technology_Manager = OldOrderInfo.FirstOrDefault().Engine_Technology_Manager, Engine_Program_ManagerId = OldOrderInfo.FirstOrDefault().Engine_Program_ManagerId, Engine_Technology_ManagerId = OldOrderInfo.FirstOrDefault().Engine_Technology_ManagerId, Engine_Status = "未进行", Intention = 3, ProjectName = projectName, CreateTime = DateTime.Now, CreatePersonID = loginID, Order_State = OrderState, virtualProgPersId = OldOrderInfo.FirstOrDefault().virtualProgPersId, virtualReturnTime = OldOrderInfo.FirstOrDefault().virtualReturnTime, // audit_Result = "待审核", AuditResult = "待审核", Remark = remark }; wms.JDJS_WMS_Order_Entry_Table.Add(orderentry); wms.SaveChanges(); mytran.Commit(); } } catch (Exception ex) { mytran.Rollback(); context.Response.Write(ex.Message); return; } } using (System.Data.Entity.DbContextTransaction mytran = wms.Database.BeginTransaction()) { try { var newOlder = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OrderNum).FirstOrDefault(); JDJS_WMS_Order_Blank_Table blank = new JDJS_WMS_Order_Blank_Table() { OrderID = newOlder.Order_ID, BlackNumber = newOlder.Product_Output, BlankAddition = 0, BlankSpecification = null, BlankState = null, BlanktotalPreparedNumber = 0, BlankType = null, }; wms.JDJS_WMS_Order_Blank_Table.Add(blank); wms.SaveChanges(); JDJS_WMS_Order_Guide_Schedu_Table guide = new JDJS_WMS_Order_Guide_Schedu_Table() { OrderID = newOlder.Order_ID, ClientName = Customer }; entities.JDJS_WMS_Order_Guide_Schedu_Table.Add(guide); entities.SaveChanges(); var oldOlder = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OldOrderNum).FirstOrDefault(); var oldProcessInfo = wms.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == oldOlder.Order_ID && r.sign == 1); foreach (var item in oldProcessInfo) { string oldprocessName = item.programName; string[] str = oldprocessName.Split('-'); string NewProcessNum = ""; if (str.Length == 2) { NewProcessNum = OrderNum + "-" + str[1]; } string oldToolName = item.toolChartName; string[] toolStr = oldToolName.Split('-'); string NewToolNum = ""; if (toolStr.Length == 3) { NewToolNum = "T" + "-" + OrderNum + "-" + toolStr[2]; } JDJS_WMS_Order_Process_Info_Table process = new JDJS_WMS_Order_Process_Info_Table() { OrderID = newOlder.Order_ID, ProcessID = item.ProcessID, BlankNumber = ProductOutPut, BlankSpecification = item.BlankSpecification, BlankType = item.BlankType, DeviceType = item.DeviceType, JigSpecification = item.JigSpecification, ProcessTime = item.ProcessTime, programName = NewProcessNum, sign = item.sign, toolChartName = NewToolNum, toolPreparation = item.toolPreparation, }; wms.JDJS_WMS_Order_Process_Info_Table.Add(process); } wms.SaveChanges(); mytran.Commit(); } catch (Exception ex) { mytran.Rollback(); context.Response.Write(ex.Message); return; } } using (System.Data.Entity.DbContextTransaction mytran = wms.Database.BeginTransaction()) { try { var newOlder = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OrderNum).FirstOrDefault(); var processes = wms.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == newOlder.Order_ID && r.sign == 1); foreach (var item in processes) { JDJS_WMS_Order_Fixture_Manager_Table fix = new JDJS_WMS_Order_Fixture_Manager_Table() { ProcessID = item.ID, FixtureAdditionNumber = 0, FixtureNumber = 0, FixtureFinishPerpareNumber = 0, }; wms.JDJS_WMS_Order_Fixture_Manager_Table.Add(fix); } //给每个工序添加治具一行 wms.SaveChanges(); mytran.Commit(); } catch (Exception ex) { mytran.Rollback(); context.Response.Write(ex.Message); return; } } using (System.Data.Entity.DbContextTransaction mytran = wms.Database.BeginTransaction()) { try { var newOlder = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OrderNum).FirstOrDefault(); var oldOlder = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_Number == OldOrderNum).FirstOrDefault(); var processes = wms.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == newOlder.Order_ID && r.sign == 1); foreach (var item in processes) { var oldProcess = wms.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == oldOlder.Order_ID && r.ProcessID == item.ProcessID && r.sign == 1).FirstOrDefault(); var OldTool = wms.JDJS_WMS_Order_Process_Tool_Info_Table.Where(r => r.ProcessID == oldProcess.ID); foreach (var real in OldTool) { JDJS_WMS_Order_Process_Tool_Info_Table tool = new JDJS_WMS_Order_Process_Tool_Info_Table() { ProcessID = item.ID, PathName = real.PathName, Shank = real.Shank, ToolAroidance = real.ToolAroidance, ToolDiameter = real.ToolDiameter, ToolLength = real.ToolLength, ToolName = real.ToolName, ToolNO = real.ToolNO }; wms.JDJS_WMS_Order_Process_Tool_Info_Table.Add(tool); } wms.SaveChanges(); } wms.SaveChanges(); mytran.Commit(); } catch (Exception ex) { mytran.Rollback(); context.Response.Write(ex.Message); return; } } { PathInfo pathInfo = new PathInfo(); var NewFolder = Path.Combine(pathInfo.upLoadPath(), OrderNum); var OldFolder = Path.Combine(pathInfo.upLoadPath(), OldOrderNum); List <string> srcPath = new List <string>(); string[] src = Directory.GetFileSystemEntries(OldFolder); foreach (var item in src) { copyDir(item, NewFolder, OrderNum); } context.Response.Write("ok"); return; } } } } } } catch (Exception ex) { date.Rollback(); context.Response.Write(ex.Message); } } } }
public void ProcessRequest(HttpContext context) { var orderId = int.Parse(context.Request["orderId"]); using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { using (System.Data.Entity.DbContextTransaction db = entities.Database.BeginTransaction()) { try { //if (entities.JDJS_WMS_Order_Queue_Table.Where(r => r.OrderID == orderId).Count() > 0) //{ // context.Response.Write("已提交"); // return; //} var userId = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId).First().virtualProgPersId; var sessionUserId = context.Session["id"]; if (userId == Convert.ToInt32(sessionUserId)) { var flag = new JDJS_WMS_Order_Queue_Table { OrderID = orderId, isFlag = 0 }; entities.JDJS_WMS_Order_Queue_Table.Add(flag); entities.SaveChanges(); db.Commit(); //Func<int, string> func = virScheduling.VirScheduleNeedDeviceNum; //IAsyncResult ar= func.BeginInvoke(orderId,null,null); //string result = func.EndInvoke(ar); string result = "ok"; //var result = virScheduling.VirSchedule(orderId); context.Response.Write(result); if (result == "ok") { entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId).First().Intention = 1; entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId).First().IntentionEndTime = DateTime.Now; var orderInter = entities.JDJS_WMS_Order_Intention_History_Table.Where(r => r.OrderID == orderId).FirstOrDefault(); if (orderInter != null) { orderInter.SubmitTime = DateTime.Now; orderInter.CraftPersonID = Convert.ToInt32(sessionUserId); orderInter.LastAlterPersonID = Convert.ToInt32(sessionUserId); orderInter.LastAlterTime = DateTime.Now; } else { JDJS_WMS_Order_Intention_History_Table jd = new JDJS_WMS_Order_Intention_History_Table() { OrderID = orderId, CraftPersonID = Convert.ToInt32(sessionUserId), CreatPersonID = Convert.ToInt32(sessionUserId), CreatTime = DateTime.Now, examineResult = "", flag = 1, LastAlterPersonID = Convert.ToInt32(sessionUserId), LastAlterTime = DateTime.Now, SubmitTime = DateTime.Now, }; entities.JDJS_WMS_Order_Intention_History_Table.Add(jd); } entities.SaveChanges(); return; } else { var row = entities.JDJS_WMS_Order_Queue_Table.Where(r => r.OrderID == orderId); if (row.Count() > 0) { entities.JDJS_WMS_Order_Queue_Table.Remove(row.First()); entities.SaveChanges(); //db.Commit(); return; } } } else { context.Response.Write("仅责任人可提交"); return; } } catch (Exception ex) { db.Rollback(); context.Response.Write(ex.Message); return; } } } }
public void ProcessRequest(HttpContext context) { var personId = Convert.ToInt32(context.Session["id"]); var orderNumberId = int.Parse(context.Request["orderNumberId"]); using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { var Engine_Program_ManagerId = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderNumberId).FirstOrDefault().Engine_Program_ManagerId; if (personId != Engine_Program_ManagerId) { context.Response.Write("您不是该订单编程负责人"); return; } using (System.Data.Entity.DbContextTransaction db = entities.Database.BeginTransaction()) { try { entities.JDJS_WMS_Order_Guide_Schedu_Table.Where(r => r.OrderID == orderNumberId).FirstOrDefault().EndTime = DateTime.Now; var row = entities.JDJS_WMS_Order_Queue_Table.Where(r => r.OrderID == orderNumberId); var judge = entities.JDJS_WMS_Order_Process_Scheduling_Table.Where(r => r.OrderID == orderNumberId & r.isFlag == 1); entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderNumberId).FirstOrDefault().Intention = 2; entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderNumberId).FirstOrDefault().Order_Actual_Start_Time = DateTime.Now; if (judge.Count() > 0) { context.Response.Write("请勿重复排产"); return; } var processInfos = entities.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == orderNumberId && r.sign != 0); foreach (var item in processInfos) { var blankInfo = item.BlankSpecification; if (blankInfo.Contains("#1#")) { item.BlankSpecification = blankInfo.Replace("#1#", ""); } } entities.SaveChanges(); var rows = entities.JDJS_WMS_Order_Process_Scheduling_Table.Where(r => r.OrderID == orderNumberId & r.isFlag == 0); if (rows.Count() > 0) { foreach (var item in rows) { entities.JDJS_WMS_Order_Process_Scheduling_Table.Remove(item); } } if (row.Count() > 0) { row.First().isFlag = 1; var confirm = entities.JDJS_WMS_Quality_Confirmation_Table.Where(r => r.OrderID == orderNumberId); if (confirm.Count() == 0) { var Quality_Confirmation = new JDJS_WMS_Quality_Confirmation_Table { OrderID = orderNumberId, CurrFinishedProductNumber = 0, DetectionNumber = 0, PassRate = 0, PefectiveProductNumber = 0, PendingNumber = 0, QualifiedProductNumber = 0 }; entities.JDJS_WMS_Quality_Confirmation_Table.Add(Quality_Confirmation); } var judge1 = entities.JDJS_WMS_Finished_Product_Manager.Where(r => r.OrderID == orderNumberId); if (judge1.Count() == 0) { var Finished_Product_Manager = new JDJS_WMS_Finished_Product_Manager { OrderID = orderNumberId, outputTime = DateTime.Now, warehousingTime = DateTime.Now, outputNumber = 0, stock = 0, waitForWarehousing = 0, warehousingNumber = 0, DefectiveProductNumber = 0 }; entities.JDJS_WMS_Finished_Product_Manager.Add(Finished_Product_Manager); } entities.SaveChanges(); db.Commit(); context.Response.Write(virScheduling.ProcessSchedule(orderNumberId, personId)); return; } else { var newRow = new JDJS_WMS_Order_Queue_Table { isFlag = 1, OrderID = orderNumberId }; entities.JDJS_WMS_Order_Queue_Table.Add(newRow); var Quality_Confirmation = new JDJS_WMS_Quality_Confirmation_Table { OrderID = orderNumberId, QualifiedProductNumber = 0, DetectionNumber = 0, CurrFinishedProductNumber = 0, PassRate = 0, PefectiveProductNumber = 0, PendingNumber = 0 }; entities.JDJS_WMS_Quality_Confirmation_Table.Add(Quality_Confirmation); var Finished_Product_Manager = new JDJS_WMS_Finished_Product_Manager { OrderID = orderNumberId, outputTime = DateTime.Now, warehousingTime = DateTime.Now, outputNumber = 0, stock = 0, waitForWarehousing = 0, warehousingNumber = 0, DefectiveProductNumber = 0 }; entities.JDJS_WMS_Finished_Product_Manager.Add(Finished_Product_Manager); entities.SaveChanges(); db.Commit(); context.Response.Write(virScheduling.ProcessSchedule(orderNumberId, personId)); return; } } catch (Exception ex) { db.Rollback(); context.Response.Write(ex.Message); return; } } } }
public void ProcessRequest(HttpContext context) { var form = context.Request.Form; var orderId = form[0]; int orderID = int.Parse(orderId); var personId = Convert.ToInt32(context.Session["id"]); Dictionary <int, List <int> > ProcessCncInfo = new Dictionary <int, List <int> >(); using (JDJS_WMS_DB_USEREntities entities = new JDJS_WMS_DB_USEREntities()) { //var personId = Convert.ToInt32(context.Session["id"]); //var Engine_Program_ManagerId = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderID).FirstOrDefault().Engine_Program_ManagerId; //if (personId != Engine_Program_ManagerId) //{ // context.Response.Write("您不是该订单编程负责人"); // return; //} entities.JDJS_WMS_Order_Guide_Schedu_Table.Where(r => r.OrderID == orderID).FirstOrDefault().EndTime = DateTime.Now; var row = entities.JDJS_WMS_Order_Queue_Table.Where(r => r.OrderID == orderID); var judge = entities.JDJS_WMS_Order_Process_Scheduling_Table.Where(r => r.OrderID == orderID & r.isFlag == 1); entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderID).FirstOrDefault().Intention = 2; entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderID).FirstOrDefault().Order_Actual_Start_Time = DateTime.Now; if (judge.Count() > 0) { context.Response.Write("请勿重复排产"); return; } var processInfos = entities.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == orderID && r.sign != 0); foreach (var item in processInfos) { var blankInfo = item.BlankSpecification; if (blankInfo.Contains("#1#")) { item.BlankSpecification = blankInfo.Replace("#1#", ""); } } entities.SaveChanges(); var rows = entities.JDJS_WMS_Order_Process_Scheduling_Table.Where(r => r.OrderID == orderID & r.isFlag == 0); if (rows.Count() > 0) { foreach (var item in rows) { entities.JDJS_WMS_Order_Process_Scheduling_Table.Remove(item); } } if (row.Count() > 0) { row.First().isFlag = 1; var confirm = entities.JDJS_WMS_Quality_Confirmation_Table.Where(r => r.OrderID == orderID); if (confirm.Count() == 0) { var Quality_Confirmation = new JDJS_WMS_Quality_Confirmation_Table { OrderID = orderID }; entities.JDJS_WMS_Quality_Confirmation_Table.Add(Quality_Confirmation); } var judge1 = entities.JDJS_WMS_Finished_Product_Manager.Where(r => r.OrderID == orderID); if (judge1.Count() == 0) { var Finished_Product_Manager = new JDJS_WMS_Finished_Product_Manager { OrderID = orderID, outputTime = DateTime.Now, warehousingTime = DateTime.Now, outputNumber = 0, stock = 0, waitForWarehousing = 0, warehousingNumber = 0 }; entities.JDJS_WMS_Finished_Product_Manager.Add(Finished_Product_Manager); } entities.SaveChanges(); for (int i = 1; i < form.Count; i++) { var cncIds = form[i]; var lists = cncIds.Split(',').ToList(); List <int> vs = new List <int>(); foreach (var item in lists) { vs.Add(int.Parse(item)); } ProcessCncInfo.Add(i, vs); } var flag = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderID).First().ProofingORProduct; if (flag == -1) { context.Response.Write(virScheduling.MassScheduling(ProcessCncInfo, orderID, personId)); } else { context.Response.Write(virScheduling.ManualScheduling(ProcessCncInfo, orderID, personId)); } return; } else { var newRow = new JDJS_WMS_Order_Queue_Table { isFlag = 1, OrderID = orderID }; entities.JDJS_WMS_Order_Queue_Table.Add(newRow); var Quality_Confirmation = new JDJS_WMS_Quality_Confirmation_Table { OrderID = orderID, QualifiedProductNumber = 0, DetectionNumber = 0, CurrFinishedProductNumber = 0, PassRate = 0, PefectiveProductNumber = 0, PendingNumber = 0 }; entities.JDJS_WMS_Quality_Confirmation_Table.Add(Quality_Confirmation); var Finished_Product_Manager = new JDJS_WMS_Finished_Product_Manager { OrderID = orderID, outputTime = DateTime.Now, warehousingTime = DateTime.Now, outputNumber = 0, stock = 0, waitForWarehousing = 0, warehousingNumber = 0 }; entities.JDJS_WMS_Finished_Product_Manager.Add(Finished_Product_Manager); entities.SaveChanges(); for (int i = 1; i < form.Count; i++) { var cncIds = form[i]; var lists = cncIds.Split(',').ToList(); List <int> vs = new List <int>(); foreach (var item in lists) { vs.Add(int.Parse(item)); } ProcessCncInfo.Add(i, vs); } var flag = entities.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderID).First().ProofingORProduct; if (flag == -1) { context.Response.Write(virScheduling.MassScheduling(ProcessCncInfo, orderID, personId)); } else { context.Response.Write(virScheduling.ManualScheduling(ProcessCncInfo, orderID, personId)); } return; } } }