Пример #1
0
        public void SchedulingProductionOrder(Sender sender, SchedulingProductionOrderArgs args)
        {
            try
            {
                using (ObjectProxy op = new ObjectProxy(true))
                {
                    if (op.LoadProductionOrderScheduling(args.ProductionOrderScheduling) == 0)
                    {
                        args.ProductionOrderScheduling.Created   = DateTime.Now;
                        args.ProductionOrderScheduling.CreatedBy = sender.UserCode + "." + sender.UserName;
                        op.InsertProductionOrderScheduling(args.ProductionOrderScheduling);
                    }
                    else
                    {
                        args.ProductionOrderScheduling.Created   = DateTime.Now;
                        args.ProductionOrderScheduling.CreatedBy = sender.UserCode + "." + sender.UserName;
                        op.UpdateProductionOrderSchedulingBySchedulingID(args.ProductionOrderScheduling);
                    }

                    if (args.ProductionSetDayDetail != null)
                    {
                        op.UpdateProductionSetDayDetailByID(args.ProductionSetDayDetail);
                    }

                    if (args.ProductionOrder != null)
                    {
                        op.UpdateProductionOrderByProductionID(args.ProductionOrder);
                    }

                    if (args.OrderStepLog != null)
                    {
                        args.OrderStepLog.Started   = DateTime.Now;
                        args.OrderStepLog.StartedBy = sender.UserCode + "." + sender.UserName;
                        op.InsertOrderStepLog(args.OrderStepLog);
                    }

                    op.CommitTransaction();
                }
            }
            catch (Exception ex)
            {
                PLogger.LogError(ex);
                throw ex;
            }
        }
Пример #2
0
        public void SchedulingProductionOrder()
        {
            try
            {
                using (ProxyBE p = new ProxyBE())
                {
                    SchedulingProductionOrderArgs args = new SchedulingProductionOrderArgs();

                    if (string.IsNullOrEmpty(Request["ProductionIDs"]))
                    {
                        throw new Exception("参数错误!");
                    }
                    string[] array = Request["ProductionIDs"].TrimEnd(',').Split(',');
                    for (int i = 0; i < array.Length; i++)
                    {
                        Guid            ProductionID    = new Guid(array[i]);
                        ProductionOrder productionorder = p.Client.GetProductionOrder(SenderUser, ProductionID);
                        if (productionorder == null)
                        {
                            throw new Exception(string.Format("订单{0}不存在!", productionorder.OrderNo));
                        }
                        if (productionorder.Status.Trim() != "N")
                        {
                            throw new Exception(string.Format("订单{0}已排单!", productionorder.OrderNo));
                        }

                        List <ProductComponent> componentlist = p.Client.GetProductComponentByOrderID(SenderUser, productionorder.OrderID);
                        if (componentlist.Count < 1)
                        {
                            throw new Exception(string.Format("订单{0}未查询到组件!", productionorder.OrderNo));
                        }
                        int ComponentTypeID = int.Parse(System.Configuration.ConfigurationManager.AppSettings["ComponentTypeID"]);
                        var SumAmount       = componentlist.Where(t => t.ComponentTypeID == ComponentTypeID).ToList().Sum(t => t.Amount);
                        if (SumAmount < 1)
                        {
                            throw new Exception("订单面积有误!");
                        }
                        ProductionSetDayDetail detail = p.Client.GetProductionSetDayDetailByMadeTotalAreal(SenderUser, SumAmount);
                        if (detail == null)
                        {
                            throw new Exception("请先进行排单参数设置!");
                        }
                        //排产记录
                        ProductionOrderScheduling scheduling = new ProductionOrderScheduling()
                        {
                            SchedulingID = Guid.NewGuid(),
                            OrderID      = productionorder.OrderID,
                            ProductionID = ProductionID,
                            DaysDetailID = detail.ID,
                            TotalAreal   = SumAmount,
                        };
                        args.ProductionOrderScheduling = scheduling;

                        //更新已排单量和未排单量
                        detail.MadeTotalAreal       = detail.MadeTotalAreal + SumAmount;
                        args.ProductionSetDayDetail = detail;

                        //更新生产订单状态,预计完工时间
                        productionorder.Status     = ProductionOrderStatus.Y.ToString();
                        productionorder.FinishDate = detail.Datetime;
                        args.ProductionOrder       = productionorder;

                        //订单日志
                        OrderStepLog ot = new OrderStepLog();
                        ot.StepID         = Guid.NewGuid();
                        ot.OrderID        = scheduling.OrderID;
                        ot.StepNo         = 0;
                        ot.StepName       = "订单已排单";
                        ot.Remark         = string.Format("预计完工日期:{0}", detail.Datetime.ToString("D"));
                        args.OrderStepLog = ot;

                        p.Client.SchedulingProductionOrder(SenderUser, args);
                    }
                }
                WriteSuccess();
            }
            catch (Exception ex)
            {
                WriteError(ex.Message, ex);
            }
        }