Example #1
0
        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 orderId    = int.Parse(context.Request["orderId"]);
            int oldOrderId = 0;

            using (JDJS_WMS_DB_USEREntities wms = new JDJS_WMS_DB_USEREntities())
            {
                var order = wms.JDJS_WMS_Order_Entry_Table.Where(r => r.Order_ID == orderId).FirstOrDefault();
                if (order == null)
                {
                    context.Response.Write("该订单不存在,请确认后再试!");
                    return;
                }
                if (order.ParentId == null)
                {
                    context.Response.Write("该订单无关联订单,请确认后再试!");
                    return;
                }
                using (System.Data.Entity.DbContextTransaction mytran = wms.Database.BeginTransaction())
                {
                    try
                    {
                        oldOrderId = int.Parse(order.ParentId.ToString());
                        var blankInfo = wms.JDJS_WMS_Order_Blank_Table.Where(r => r.OrderID == oldOrderId).FirstOrDefault();
                        if (blankInfo != null)
                        {
                            JDJS_WMS_Order_Blank_Table jdBlank = new JDJS_WMS_Order_Blank_Table()
                            {
                                OrderID                  = orderId,
                                BlackNumber              = order.Product_Output,
                                BlankAddition            = 0,
                                BlankSpecification       = blankInfo.BlankSpecification.Contains("#1#")? blankInfo.BlankSpecification.Replace("#1#", "") : blankInfo.BlankSpecification,
                                BlankState               = "待备料",
                                BlanktotalPreparedNumber = 0,
                                BlankType                = blankInfo.BlankType,
                                Expected_Completion_Time = DateTime.Now
                            };
                            wms.JDJS_WMS_Order_Blank_Table.Add(jdBlank);
                        }

                        JDJS_WMS_Quality_Confirmation_Table jdQuality = new JDJS_WMS_Quality_Confirmation_Table()
                        {
                            OrderID                   = orderId,
                            DetectionNumber           = 0,
                            CurrFinishedProductNumber = 0,
                            PassRate                  = 0,
                            PefectiveProductNumber    = 0,
                            PendingNumber             = 0,
                            QualifiedProductNumber    = 0
                        };
                        wms.JDJS_WMS_Quality_Confirmation_Table.Add(jdQuality);
                        wms.SaveChanges();
                        JDJS_WMS_Finished_Product_Manager jdFinish = new JDJS_WMS_Finished_Product_Manager()
                        {
                            outputNumber           = 0,
                            DefectiveProductNumber = 0,
                            OrderID            = orderId,
                            stock              = 0,
                            waitForWarehousing = 0,
                            warehousingNumber  = 0,
                        };
                        wms.JDJS_WMS_Finished_Product_Manager.Add(jdFinish);
                        wms.SaveChanges();
                        var guide = wms.JDJS_WMS_Order_Guide_Schedu_Table.Where(r => r.OrderID == orderId).FirstOrDefault();
                        if (guide != null)
                        {
                            guide.ExpectEndTime = DateTime.Now;
                            guide.EndTime       = DateTime.Now;
                            wms.SaveChanges();
                        }
                        var processes = wms.JDJS_WMS_Order_Process_Info_Table.Where(r => r.OrderID == oldOrderId && r.sign != 0);
                        JDJS_WMS_Order_DelayTime_Table jdDelay = new JDJS_WMS_Order_DelayTime_Table()
                        {
                            OrderID = orderId,
                        };
                        wms.JDJS_WMS_Order_DelayTime_Table.Add(jdDelay);
                        foreach (var item in processes)
                        {
                            JDJS_WMS_Order_Process_Info_Table jd = new JDJS_WMS_Order_Process_Info_Table()
                            {
                                DeviceType                   = item.DeviceType,
                                ProcessID                    = item.ProcessID,
                                JigSpecification             = item.JigSpecification.Contains("#1#")? item.JigSpecification.Replace("#1#", ""): item.JigSpecification,
                                JigType                      = item.JigType,
                                Jig_Expected_Completion_Time = DateTime.Now,
                                BlankNumber                  = order.Product_Output,
                                sign = 1,
                                program_audit_sign = 1,
                                programName        = order.Order_Number + "-" + item.programName.Split('-')[1],
                                ProcessTime        = item.ProcessTime,
                                BlankSpecification = item.BlankSpecification.Contains("#1#")?item.BlankSpecification.Replace("#1#", ""):item.BlankSpecification,
                                BlankType          = item.BlankType,
                                MachNumber         = item.MachNumber,
                                Modulus            = item.Modulus,
                                NonCuttingTime     = item.NonCuttingTime,
                                toolChartName      = "T-" + order.Order_Number + "-" + item.toolChartName.Split('-')[2],
                                toolPreparation    = 0,
                                ProgramePassTime   = DateTime.Now,
                                OrderID            = orderId
                            };
                            wms.JDJS_WMS_Order_Process_Info_Table.Add(jd);
                            order.audit_Result         = "。" + DateTime.Now.ToString() + ":审核通过";
                            order.program_audit_result = "。" + DateTime.Now.ToString() + ":审核通过";
                            wms.SaveChanges();
                            int processId   = jd.ID;
                            var processInfo = wms.JDJS_WMS_Order_Process_Information_Table.Where(r => r.ProcessID == item.ID).FirstOrDefault();
                            if (processInfo != null)
                            {
                                JDJS_WMS_Order_Process_Information_Table jdInfo = new JDJS_WMS_Order_Process_Information_Table()
                                {
                                    Note         = processInfo.Note,
                                    ProcessID    = processId,
                                    WorkMaterial = processInfo.WorkMaterial,
                                    XPoint       = processInfo.XPoint,
                                    YPoint       = processInfo.YPoint,
                                    ZPoint       = processInfo.ZPoint
                                };
                                wms.JDJS_WMS_Order_Process_Information_Table.Add(jdInfo);
                                wms.SaveChanges();
                            }

                            var tools = wms.JDJS_WMS_Order_Process_Tool_Info_Table.Where(r => r.ProcessID == item.ID);
                            foreach (var tool in tools)
                            {
                                JDJS_WMS_Order_Process_Tool_Info_Table jdTool = new JDJS_WMS_Order_Process_Tool_Info_Table()
                                {
                                    BladeLenth      = tool.BladeLenth,
                                    EffectiveLength = tool.EffectiveLength,
                                    ProcessID       = processId,
                                    ToolDiameter    = tool.ToolDiameter,
                                    isFine          = tool.isFine,
                                    Shank           = tool.Shank,
                                    PathName        = tool.PathName,
                                    ToolAroidance   = tool.ToolAroidance,
                                    ToolLength      = tool.ToolLength,
                                    ToolName        = tool.ToolName,
                                    ToolNO          = tool.ToolNO
                                };
                                wms.JDJS_WMS_Order_Process_Tool_Info_Table.Add(jdTool);
                            }
                            wms.SaveChanges();
                            JDJS_WMS_Order_Fixture_Manager_Table jdFix = new JDJS_WMS_Order_Fixture_Manager_Table()
                            {
                                ProcessID                  = processId,
                                FixtureAdditionNumber      = 0,
                                FixtureFinishPerpareNumber = 0,
                                FixtureNumber              = 0
                            };
                            wms.JDJS_WMS_Order_Fixture_Manager_Table.Add(jdFix);
                            JDJS_WMS_Warehouse_InOut_History_Table jdInout = new JDJS_WMS_Warehouse_InOut_History_Table()
                            {
                                InNum     = 0,
                                OutNum    = 0,
                                ProcessId = processId
                            };
                            wms.JDJS_WMS_Warehouse_InOut_History_Table.Add(jdInout);
                        }
                        order.Intention = 3;
                        wms.SaveChanges();
                        mytran.Commit();
                        context.Response.Write("ok");
                        return;
                    }
                    catch (Exception ex)
                    {
                        mytran.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;
                }
            }
        }