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

            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;
                        materialCode    = rst2.Data.MaterialCode;
                        isLatestPackage = rst2.Data.IsLastPackage;
                        nPackageState   = Convert.ToInt32(rst2.Data.PackageState);
                    }
                }

                if (!string.IsNullOrEmpty(orderNumber))
                {
                    //获取满包数量
                    using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
                    {
                        MethodReturnResult <WorkOrderRule> rst1 = client.Get(new WorkOrderRuleKey()
                        {
                            OrderNumber  = orderNumber,
                            MaterialCode = materialCode
                        });
                        if (rst1.Code == 0 &&
                            rst1.Data != null)
                        {
                            fullPackageQty = rst1.Data.FullPackageQty;
                        }
                    }
                }
            }
            return(Json(new{
                CurrentQuantity = currentQuantity,
                FullPackageQty = fullPackageQty,
                IsLastestPackage = isLatestPackage,
                PackageState = nPackageState
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public WorkOrderRule GetWorkOrderRule(string orderNumber, string materialCode)
 {
     using (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
     {
         MethodReturnResult <WorkOrderRule> result = client.Get(new WorkOrderRuleKey()
         {
             MaterialCode = materialCode,
             OrderNumber  = orderNumber
         });
         if (result.Code <= 0)
         {
             return(result.Data);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        public ActionResult Finish(ZPVMLotPackageViewModel model)
        {
            MethodReturnResult result = new MethodReturnResult();

            try
            {
                //如果包装号为空。
                if (string.IsNullOrEmpty(model.PackageNo))
                {
                    result.Code    = 1001;
                    result.Message = string.Format("包装号不能为空。");
                    return(Json(result));
                }
                else
                {
                    model.PackageNo = model.PackageNo.ToUpper().Trim();
                }
                Package obj = null;
                //如果当前数量为空,获取当前数量
                using (PackageQueryServiceClient client = new PackageQueryServiceClient())
                {
                    MethodReturnResult <Package> rst2 = client.Get(model.PackageNo.ToUpper().Trim());
                    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().Trim()
                                                       , 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 (WorkOrderRuleServiceClient client = new WorkOrderRuleServiceClient())
                    {
                        MethodReturnResult <WorkOrderRule> rst1 = client.Get(new WorkOrderRuleKey()
                        {
                            OrderNumber  = obj.OrderNumber,
                            MaterialCode = obj.MaterialCode
                        });
                        if (rst1.Code == 0 &&
                            rst1.Data != null)
                        {
                            model.FullQuantity = rst1.Data.FullPackageQty;
                        }
                    }
                }
                //非尾包,不能完成包装并过站
                if (model.IsFinishPackage == true &&
                    (model.IsLastestPackage == false && obj.IsLastPackage == 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 = FinishPackage(model);
                //result = Package(model);

                //返回包装结果。
                if (result.Code <= 0)
                {
                    MethodReturnResult <ZPVMLotPackageViewModel> rstFinal = new MethodReturnResult <ZPVMLotPackageViewModel>()
                    {
                        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));
        }