Ejemplo n.º 1
0
        public async Task <ActionResult> SaveModify(WorkOrderViewModel model)
        {
            MethodReturnResult rst = new MethodReturnResult();

            try
            {
                using (WorkOrderServiceClient client = new WorkOrderServiceClient())
                {
                    MethodReturnResult <WorkOrder> result = await client.GetAsync(model.OrderNumber);

                    if (result.Code == 0 && result.Data != null)
                    {
                        result.Data.CloseType     = model.CloseType;
                        result.Data.Description   = model.Description;
                        result.Data.FinishTime    = model.FinishTime;
                        result.Data.LocationName  = model.LocationName.ToUpper();
                        result.Data.MaterialCode  = model.MaterialCode.ToUpper();
                        result.Data.LeftQuantity  = result.Data.LeftQuantity + (model.OrderQuantity - result.Data.OrderQuantity);
                        result.Data.OrderQuantity = model.OrderQuantity;
                        result.Data.OrderState    = model.OrderState;
                        result.Data.OrderType     = model.OrderType;
                        result.Data.Priority      = model.Priority;
                        result.Data.RevenueType   = model.RevenueType;
                        result.Data.StartTime     = model.StartTime;
                        result.Data.Description   = model.Description;
                        result.Data.Editor        = User.Identity.Name;
                        result.Data.EditTime      = DateTime.Now;

                        rst = await client.ModifyAsync(result.Data);

                        if (rst.Code == 0)
                        {
                            rst.Message = string.Format(PPMResources.StringResource.WorkOrder_Save_Success
                                                        , model.OrderNumber);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                rst.Code    = 1000;
                rst.Message = ex.Message;
                rst.Detail  = ex.ToString();
            }
            return(Json(rst));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> SaveModify(WorkOrderViewModel model)
        {
            MethodReturnResult rst = new MethodReturnResult();

            try
            {
                using (WorkOrderServiceClient client = new WorkOrderServiceClient())
                {
                    MethodReturnResult <WorkOrder> result = await client.GetAsync(model.OrderNumber);

                    if (result.Code == 0 && result.Data != null)
                    {
                        //判断工单数量是否满足已投批数量
                        if (result.Data.LeftQuantity + (model.OrderQuantity - result.Data.OrderQuantity) < 0)
                        {
                            rst.Code    = 1000;
                            rst.Message = string.Format("工单数量({0})小于已创批数量({1})!",
                                                        model.OrderQuantity,
                                                        result.Data.OrderQuantity - result.Data.LeftQuantity);
                            rst.Detail = rst.Message;

                            return(Json(rst));
                        }

                        result.Data.PlanStartTime  = model.PlanStartTime;                                                          //计划开工日期
                        result.Data.PlanFinishTime = model.PlanFinishTime;                                                         //计划完工日期
                        result.Data.LeftQuantity   = result.Data.LeftQuantity + (model.OrderQuantity - result.Data.OrderQuantity); //剩余数量
                        result.Data.OrderQuantity  = model.OrderQuantity;                                                          //工单数量
                        result.Data.OrderType      = model.OrderType;                                                              //工单类型

                        result.Data.StartTime   = model.PlanStartTime;                                                             //开工时间
                        result.Data.FinishTime  = model.PlanFinishTime;                                                            //完工时间
                        result.Data.Description = model.Description;                                                               //描述

                        result.Data.Editor     = User.Identity.Name;                                                               //编辑人
                        result.Data.EditTime   = DateTime.Now;                                                                     //编辑日期
                        result.Data.CloseType  = model.CloseType;                                                                  //工单关闭类型
                        result.Data.OrderState = model.OrderState;                                                                 //工单状态

                        //result.Data.Description = model.Description;
                        //result.Data.FinishTime = model.FinishTime;
                        //result.Data.LocationName = model.LocationName.ToUpper();
                        //result.Data.MaterialCode = model.MaterialCode.ToUpper();
                        //result.Data.LeftQuantity = result.Data.LeftQuantity + (model.OrderQuantity - result.Data.OrderQuantity);
                        //result.Data.OrderQuantity = model.OrderQuantity;
                        //result.Data.OrderState = model.OrderState;
                        //result.Data.OrderType = model.OrderType;
                        //result.Data.Priority = model.Priority;
                        //result.Data.RevenueType = model.RevenueType;
                        //result.Data.StartTime = model.StartTime;
                        //result.Data.Description = model.Description;
                        //result.Data.Editor = User.Identity.Name;
                        //result.Data.EditTime = DateTime.Now;

                        rst = await client.ModifyAsync(result.Data);

                        if (rst.Code == 0)
                        {
                            rst.Message = string.Format(PPMResources.StringResource.WorkOrder_Save_Success
                                                        , model.OrderNumber);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                rst.Code    = 1000;
                rst.Message = ex.Message;
                rst.Detail  = ex.ToString();
            }

            return(Json(rst));
        }