Exemplo n.º 1
0
        /// <summary>
        /// 获取包装信息。
        /// </summary>
        /// <param name="packageNo"></param>
        /// <returns></returns>
        public ActionResult GetPackageInfo(string packageNo)
        {
            double currentQuantity = 0;
            double fullQuantity = 25;
            string orderNumber = string.Empty;
            bool isLastestPackage = false;

            if (!string.IsNullOrEmpty(packageNo))
            {
                //获取当前数量
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult<Package> rst2 = client.Get(packageNo);
                    if (rst2.Code == 1000)
                    {
                        return Json(rst2);
                    }
                    if (rst2.Code <= 0 && rst2.Data != null && rst2.Data.PackageState==EnumPackageState.Packaging)
                    {
                        currentQuantity = rst2.Data.Quantity;
                        orderNumber = rst2.Data.OrderNumber;
                        isLastestPackage = rst2.Data.IsLastPackage;
                    }
                }

                if (!string.IsNullOrEmpty(orderNumber))
                {
                    //获取满包数量
                    using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
                    {
                        MethodReturnResult<WorkOrderAttribute> rst1 = client.Get(new WorkOrderAttributeKey()
                        {
                            OrderNumber = orderNumber,
                            AttributeName = "FullPackageQuantity"
                        });
                        if (rst1.Code == 1000)
                        {
                            return Json(rst1);
                        }

                        if (rst1.Data != null
                            && !string.IsNullOrEmpty(rst1.Data.AttributeValue))
                        {
                            double.TryParse(rst1.Data.AttributeValue, out fullQuantity);
                        }
                    }
                }
            }

            return Json(new{ 
                              CurrentQuantity = currentQuantity,
                              FullQuantity = fullQuantity,
                              IsLastestPackage = isLastestPackage
                            }, JsonRequestBehavior.AllowGet);
            
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Query(WorkOrderAttributeQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            where.AppendFormat(" {0} Key.OrderNumber = '{1}'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , model.OrderNumber);

                            if (!string.IsNullOrEmpty(model.AttributeName))
                            {
                                where.AppendFormat(" {0} Key.AttributeName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.AttributeName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <WorkOrderAttribute> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 3
0
        //
        // GET: /PPM/WorkOrderAttribute/
        public async Task <ActionResult> Index(string orderNumber)
        {
            using (WorkOrderServiceClient client = new WorkOrderServiceClient())
            {
                MethodReturnResult <WorkOrder> result = await client.GetAsync(orderNumber ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "WorkOrder"));
                }
                ViewBag.WorkOrder = result.Data;
            }

            using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.OrderNumber = '{0}'"
                                              , orderNumber),
                        OrderBy = "Key.OrderNumber,Key.AttributeName"
                    };
                    MethodReturnResult <IList <WorkOrderAttribute> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new WorkOrderAttributeQueryViewModel()
            {
                OrderNumber = orderNumber
            }));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <WorkOrderAttribute> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Exemplo n.º 5
0
        public ActionResult Save(LotPackageViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //获取批次数据。
                string lotNumber = model.LotNumber.ToUpper();
                result = GetLot(lotNumber);
                if (result.Code > 0)
                {
                    return(Json(result));
                }
                MethodReturnResult <Lot> rst = result as MethodReturnResult <Lot>;
                Lot obj = rst.Data;

                //如果包装号为空。生成包装号。
                if (string.IsNullOrEmpty(model.PackageNo))
                {
                    using (LotPackageServiceClient client = new LotPackageServiceClient())
                    {
                        MethodReturnResult <string> rst1 = client.Generate(model.LotNumber, model.IsLastestPackage);
                        if (rst1.Code > 0)
                        {
                            return(Json(rst1));
                        }
                        else
                        {
                            model.PackageNo = rst1.Data;
                        }
                    }
                }
                //重新获取当前数量。
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <Package> rst2 = client.Get(model.PackageNo);
                    if (rst2.Code == 1000)
                    {
                        return(Json(rst2));
                    }
                    //检查包装状态
                    if (rst2.Data != null && rst2.Data.PackageState != EnumPackageState.Packaging)
                    {
                        result.Code    = 1001;
                        result.Message = string.Format("包 {0} 非 [{1}] 状态,不能包装。"
                                                       , model.PackageNo.ToUpper()
                                                       , EnumPackageState.Packaging.GetDisplayName());
                        return(Json(result));
                    }
                    //设置当前数量。
                    if (rst2.Code <= 0 && rst2.Data != null)
                    {
                        model.CurrentQuantity = rst2.Data.Quantity;
                    }
                }
                //如果满包数量为空,获取满包数量
                if (model.FullQuantity == 0)
                {
                    using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
                    {
                        MethodReturnResult <WorkOrderAttribute> rst1 = client.Get(new WorkOrderAttributeKey()
                        {
                            OrderNumber   = obj.OrderNumber,
                            AttributeName = "FullPackageQuantity"
                        });
                        double fullQuantity = 25;
                        if (rst1.Code == 1000)
                        {
                            return(Json(rst1));
                        }

                        if (rst1.Data != null &&
                            !string.IsNullOrEmpty(rst1.Data.AttributeValue))
                        {
                            double.TryParse(rst1.Data.AttributeValue, out fullQuantity);
                        }
                        model.FullQuantity = fullQuantity;
                    }
                }


                double newCurrentQuantity = model.CurrentQuantity + obj.Quantity;
                //当前数量超过满包数量,不能继续包装。
                if (newCurrentQuantity > model.FullQuantity)
                {
                    result.Code    = 1;
                    result.Message = string.Format("包({0}) 当前数量({1})加上批次({2})数量({3}),超过满包数量。"
                                                   , model.PackageNo.ToUpper()
                                                   , model.CurrentQuantity
                                                   , obj.Key
                                                   , obj.Quantity);
                    return(Json(result));
                }
                model.CurrentQuantity = newCurrentQuantity;

                //判断批次工序是否在当前工序。
                if (obj.RouteStepName != model.RouteOperationName)
                {
                    result.Code    = 2;
                    result.Message = string.Format("批次({0})当前所在工序({1}),不能在({2})工序上操作。"
                                                   , obj.Key
                                                   , obj.RouteStepName
                                                   , model.RouteOperationName);
                    return(Json(result));
                }
                //判断批次所在车间和当前线所在车间是否匹配。
                //获取线别车间。
                string locationName = string.Empty;
                using (ProductionLineServiceClient client = new ProductionLineServiceClient())
                {
                    MethodReturnResult <ProductionLine> r = client.Get(model.LineCode);
                    if (r.Code <= 0)
                    {
                        locationName = r.Data.LocationName;
                    }
                }
                if (!string.IsNullOrEmpty(locationName))
                {
                    using (LocationServiceClient client = new LocationServiceClient())
                    {
                        MethodReturnResult <Location> r = client.Get(locationName);
                        if (r.Code <= 0)
                        {
                            locationName = r.Data.ParentLocationName;
                        }
                    }
                }
                //检查批次车间和线别车间是否匹配。
                if (obj.LocationName != locationName)
                {
                    result.Code    = 3;
                    result.Message = string.Format("批次({0})属于({1})车间,不能在({2})车间线别上操作。"
                                                   , lotNumber.ToUpper()
                                                   , obj.LocationName
                                                   , locationName);
                    return(Json(result));
                }
                result = Package(model);
                //返回包装结果。
                if (result.Code <= 0)
                {
                    MethodReturnResult <LotPackageViewModel> rstFinal = new MethodReturnResult <LotPackageViewModel>()
                    {
                        Code     = result.Code,
                        Data     = model,
                        Detail   = result.Detail,
                        HelpLink = result.HelpLink,
                        Message  = result.Message
                    };
                    return(Json(rstFinal));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }
Exemplo n.º 6
0
        public ActionResult Finish(LotPackageViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //如果包装号为空。
                if (string.IsNullOrEmpty(model.PackageNo))
                {
                    result.Code    = 1001;
                    result.Message = string.Format("包装号不能为空。");
                    return(Json(result));
                }
                Package obj = null;
                //如果当前数量为空,获取当前数量
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <Package> rst2 = client.Get(model.PackageNo);
                    if (rst2.Code > 0)
                    {
                        return(Json(rst2));
                    }
                    //检查包装状态
                    if (rst2.Data.PackageState != EnumPackageState.Packaging)
                    {
                        result.Code    = 1001;
                        result.Message = string.Format("包 {0} 非{1}状态,不能操作。"
                                                       , model.PackageNo.ToUpper()
                                                       , EnumPackageState.Packaging.GetDisplayName());
                        return(Json(result));
                    }
                    //设置当前数量。
                    if (rst2.Code <= 0 && rst2.Data != null)
                    {
                        obj = rst2.Data;
                        model.CurrentQuantity = rst2.Data.Quantity;
                    }
                }
                //如果满包数量为空,获取满包数量
                if (model.FullQuantity == 0)
                {
                    using (WorkOrderAttributeServiceClient client = new WorkOrderAttributeServiceClient())
                    {
                        MethodReturnResult <WorkOrderAttribute> rst1 = client.Get(new WorkOrderAttributeKey()
                        {
                            OrderNumber   = obj.OrderNumber,
                            AttributeName = "FullPackageQuantity"
                        });
                        double fullQuantity = 25;
                        if (rst1.Code == 1000)
                        {
                            return(Json(rst1));
                        }

                        if (rst1.Data != null &&
                            !string.IsNullOrEmpty(rst1.Data.AttributeValue))
                        {
                            double.TryParse(rst1.Data.AttributeValue, out fullQuantity);
                        }
                        model.FullQuantity = fullQuantity;
                    }
                }
                //非尾包,不能完成包装并过站
                if (model.IsFinishPackage == true &&
                    model.IsLastestPackage == false &&
                    model.CurrentQuantity != model.FullQuantity)
                {
                    result.Code    = 1;
                    result.Message = string.Format("包({0})非尾包,包装数量未达到满包数量,不能完成包装。"
                                                   , model.PackageNo);
                    return(Json(result));
                }
                //判断批次所在车间和当前线所在车间是否匹配。
                //获取线别车间。
                string locationName = string.Empty;
                using (ProductionLineServiceClient client = new ProductionLineServiceClient())
                {
                    MethodReturnResult <ProductionLine> r = client.Get(model.LineCode);
                    if (r.Code <= 0)
                    {
                        locationName = r.Data.LocationName;
                    }
                }
                if (!string.IsNullOrEmpty(locationName))
                {
                    using (LocationServiceClient client = new LocationServiceClient())
                    {
                        MethodReturnResult <Location> r = client.Get(locationName);
                        if (r.Code <= 0)
                        {
                            locationName = r.Data.ParentLocationName;
                        }
                    }
                }
                //获取包装号所在车间。
                string currentLocationName = string.Empty;
                using (WorkOrderServiceClient client = new WorkOrderServiceClient())
                {
                    MethodReturnResult <WorkOrder> rst1 = client.Get(obj.OrderNumber);
                    if (rst1.Code <= 0 && rst1.Data != null)
                    {
                        currentLocationName = rst1.Data.LocationName;
                    }
                }
                //检查包所在车间和线别车间是否匹配。
                if (currentLocationName != locationName)
                {
                    result.Code    = 3;
                    result.Message = string.Format("包({0})属于({1})车间,不能在({2})车间线别上操作。"
                                                   , obj.Key
                                                   , currentLocationName
                                                   , locationName);
                    return(Json(result));
                }
                result = Package(model);
                //返回包装结果。
                if (result.Code <= 0)
                {
                    MethodReturnResult <LotPackageViewModel> rstFinal = new MethodReturnResult <LotPackageViewModel>()
                    {
                        Code     = result.Code,
                        Data     = model,
                        Detail   = result.Detail,
                        HelpLink = result.HelpLink,
                        Message  = result.Message
                    };
                    return(Json(rstFinal));
                }
            }
            catch (Exception ex)
            {
                result.Code    = 1000;
                result.Message = ex.Message;
                result.Detail  = ex.ToString();
            }
            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            return(Json(result));
        }