Example #1
0
        /// <summary>
        /// 检查运单是否正确 add by huhaiyou 2014-4-24
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static CheckOnWayBillResponseResult CheckOnWayBill(InStorageFormModel filter)
        {
            try
            {
                // var resultModel = HttpHelper.DoRequest<string>(sysConfig.LMSAPIPath + "api/LMS/CheckOnInStorage?model=" + model, EnumHttpMethod.GET);
                // var resultModel = HttpHelper.DoRequest<ResponseResultModel>(sysConfig.LMSAPIPath + "api/Lms/PostBatchAddReturnGoods", EnumHttpMethod.POST, EnumContentType.Json, returnGoodsList);
                var resultModel = HttpHelper.DoRequest <CheckOnWayBillResponseResult>(sysConfig.LMSAPIPath + "api/WayBill/CheckOnWayBillCS", EnumHttpMethod.POST, EnumContentType.Json, filter);

                Log.Info(resultModel.RawValue);
                return(resultModel.Value);
            }
            catch (Exception ex)
            {
                Log.Error("错误地址:" + sysConfig.LMSAPIPath + "api/WayBill/CheckOnWayBillCS/");
                Log.Exception(ex);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// 检查运单号
        /// </summary>
        private bool CheckWayBill()
        {
            this.lblTsg.Text        = "";
            this.lblCountyName.Text = "";

            if (string.IsNullOrWhiteSpace(this.txtCustomers.Text))
            {
                this.lblTsg.Text = "客户不能为空!";
                return(false);
            }

            if (cbbInStorage.SelectedValue == null)
            {
                this.lblTsg.Text = "运输方式不能为空!";
                return(false);
            }

            if (waybillList.Exists(p => p.WayBillNumber.Equals(this.txtNumber.Text.Trim()) || p.CustomerOrderNumber.Equals(this.txtNumber.Text.Trim())))
            {
                lblTsg.Text = "数据已经存在,不能重复添加";
                return(false);
            }

            clearLeft(false);

            InStorageFormModel model = new InStorageFormModel();

            model.CustomerCode     = this.txtCustomers.Text.Trim();
            model.GoodsTypeID      = (int)cbbGoodsType.SelectedValue;
            model.ShippingMethodId = (int)cbbInStorage.SelectedValue;
            model.WayBillNumber    = this.txtNumber.Text.Trim();
            model.CustomerType     = int.Parse(CustomerTypeID);
            model.OperatorUserName = LoginHelper.CurrentUserName;


            inStorageModel = InvokeWebApiHelper.CheckOnWayBill(model);
            if (inStorageModel != null)
            {
                this.btnSubmit.Enabled = inStorageModel.Result;

                if (inStorageModel.Result)
                {
                    this.lblTsg.Text        = "运单: " + model.WayBillNumber + " 扫描通过";
                    this.lblCountyName.Text = inStorageModel.Message;

                    if (this.txtPieces.Enabled && !cbxPieces.Checked)
                    {
                        this.txtPieces.Focus();
                    }
                    else
                    {
                        txtPiecesNext();
                    }

                    return(true);
                }
                else    //如果扫描不通过,清空数据
                {
                    this.lblTsg.Text    = inStorageModel.Message.Replace("<br/>", "");
                    this.txtNumber.Text = "";

                    waybilldetailList.Clear();
                    this.dgvPackageList.Rows.Clear();

                    this.txtNumber.Focus();

                    this.lblCountyName.Text = string.Empty;

                    if (!cbxWeight.Checked && this.txtWeights.Enabled)
                    {
                        this.txtWeights.Text = string.Empty;
                    }

                    //if (!cbxVolume.Checked)
                    //{
                    //    this.txtLong.Text = string.Empty;
                    //    this.txtWidth.Text = string.Empty;
                    //    this.txtHeight.Text = string.Empty;
                    //}
                }
            }
            else
            {
                MessageBox.Show("网络异常");
            }
            return(false);
        }
        public InStorageWayBillModel CheckOnInStorageSingele(InStorageFormModel filter)
        {
            var model     = new InStorageWayBillModel();
            var error     = new StringBuilder();
            var NumberStr = string.Empty;

            if (!string.IsNullOrWhiteSpace(filter.WayBillNumber))
            {
                NumberStr = filter.WayBillNumber;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(filter.TrackingNumber))
                {
                    NumberStr = filter.TrackingNumber;
                }
            }
            var waybillinfo = _wayBillInfoRepository.GetWayBillInfoExtSilm(NumberStr);

            if (!string.IsNullOrWhiteSpace(NumberStr) && waybillinfo != null)
            {
                //if (!string.IsNullOrWhiteSpace(filter.TrackingNumber) && waybillinfo.TrackingNumber != filter.TrackingNumber)
                //{
                //    error.AppendLine("跟踪号与输入的跟踪号不一样!<br/>");
                //}
                if (error.Length == 0 && WayBill.StatusToValue(WayBill.StatusEnum.Submitted) != waybillinfo.Status)
                {
                    error.AppendLine(string.Format("运单:{0}状态不是已提交!<br/>", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.GoodsTypeID != filter.GoodsTypeID)
                {
                    error.AppendLine(string.Format("运单:{0}货物类型不是一致", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.IsHold)
                {
                    error.AppendLine(string.Format("运单:{0}已经Hold!<br/>", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.InShippingMethodID.HasValue &&
                    waybillinfo.InShippingMethodID.Value != filter.ShippingMethodId)
                {
                    error.AppendLine(string.Format("入仓运输方式与运单运输方式:{0}不一致!<br/>", waybillinfo.InShippingMethodName));
                    //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("运单号:{0}国家或运输方式异常", waybillinfo.WayBillNumber));
                }
                if (error.Length == 0 && waybillinfo.CustomerCode.ToUpper().Trim() != filter.CustomerCode.ToUpper().Trim())
                {
                    error.AppendLine(string.Format("入仓客户与运单客户:{0}不一致!<br/>", waybillinfo.CustomerCode));
                    //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("入仓客户与运单客户:{0}不一致", waybillinfo.CustomerCode.ToUpper()));
                }

                //小包检查重量偏差
                if (error.Length == 0 && !filter.IsBusinessExpress)
                {
                    //该客户该运输方式设置的重量偏差值
                    var weightDeviations = GetWeightDeviations(filter.CustomerCode, filter.ShippingMethodId);

                    //预报重量与称重的偏差
                    var diff = Math.Abs((filter.Weight - waybillinfo.Weight ?? 0) * 1000);

                    if (weightDeviations != 0 && diff > weightDeviations)
                    {
                        string errMessage = string.Format("称重重量与预报重量相差" + diff + "g大于配置的 " + weightDeviations + "g不能入仓!");
                        error.AppendLine(errMessage);

                        //增加运单异常日志
                        _orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InStorageWeightAbnormal, errMessage, filter.OperatorUserName);

                        if (_orderService.IsExistInStorageWeightAbnormal(waybillinfo.WayBillNumber))
                        {
                            _orderService.UpdateInStorageWeightAbnormal(waybillinfo.WayBillNumber, filter.Weight);
                        }
                        else
                        {
                            //增加入仓对比重量异常单
                            _orderService.AddInStorageWeightAbnormal(new WeightAbnormalLog
                            {
                                CustomerCode    = waybillinfo.CustomerCode,
                                WayBillNumber   = waybillinfo.WayBillNumber,
                                CustomerOrderID = waybillinfo.CustomerOrderID,
                                TrackingNumber  = waybillinfo.TrackingNumber,
                                Length          = filter.Length ?? waybillinfo.Length,
                                Width           = filter.Width ?? waybillinfo.Width,
                                Height          = filter.Height ?? waybillinfo.Height,
                                Weight          = filter.Weight,//称重重量
                                CreatedOn       = DateTime.Now,
                                CreatedBy       = filter.OperatorUserName
                            });
                        }
                    }
                }
                if (error.Length > 0)
                {
                    model.IsSuccess = false;
                    model.Message   = error.ToString();
                }
                else
                {
                    // 根据转换重量转换包裹类型 Add by zhengsong
                    #region
                    var shippingMethod = _freightService.GetShippingMethod(filter.ShippingMethodId);
                    if (shippingMethod != null)
                    {
                        if (shippingMethod.Enabled && shippingMethod.ShippingMethodTypeId == 4)
                        {
                            if (filter.Weight <= shippingMethod.PackageTransformFileWeight)
                            {
                                filter.GoodsTypeID = 2;
                            }
                        }
                    }
                    #endregion

                    Guid     customerId = Guid.Empty;
                    Customer customer   = GetGetCustomerListFromCache().Find(p => p.CustomerCode == waybillinfo.CustomerCode);
                    if (customer != null)
                    {
                        customerId = customer.CustomerID;
                    }

                    //判断是否超周长
                    var result = _freightService.IsOverMaxGirthSingle(new CustomerInfoPackageModel()
                    {
                        CountryCode      = waybillinfo.CountryCode,
                        CustomerTypeId   = filter.CustomerType,
                        Height           = filter.Height ?? 0,
                        Length           = filter.Length ?? 0,
                        ShippingMethodId = filter.ShippingMethodId,
                        Weight           = filter.Weight,
                        Width            = filter.Width ?? 0,
                        ShippingTypeId   = filter.GoodsTypeID,
                        CustomerId       = customerId
                    });

                    //如果没有超周长
                    if (!result.Result)
                    {
                        model.IsSuccess           = true;
                        model.Message             = "";
                        model.WayBillNumber       = waybillinfo.WayBillNumber;
                        model.CountryCode         = waybillinfo.CountryCode;
                        model.CountryName         = _freightService.GetChineseName(waybillinfo.CountryCode);
                        model.CustomerOrderNumber = waybillinfo.CustomerOrderNumber;
                        model.SettleWeight        = Convert.ToDecimal(result.Message); //结算重量
                        model.EnableTariffPrepay  = waybillinfo.EnableTariffPrepay;    //是否启用关税预付服务
                        model.TrackingNumber      = !string.IsNullOrWhiteSpace(waybillinfo.TrackingNumber) ? waybillinfo.TrackingNumber : "";
                    }
                    else
                    {
                        model.IsSuccess = false;
                        model.Message   = result.Message;
                    }
                }
            }
            else
            {
                model.IsSuccess = false;
                model.Message   = string.Format("单号:{0}系统找不到!", NumberStr);
            }
            return(model);
        }
        /// <summary>
        /// CS版 检查入库 add by huhaiyou 2014-4-23
        /// </summary>
        /// <returns></returns>
        public InStorageWayBillModel CheckOnInStorageCS(InStorageFormModel filter)
        {
            var model     = new InStorageWayBillModel();
            var error     = new StringBuilder();
            var NumberStr = string.Empty;

            if (!string.IsNullOrWhiteSpace(filter.WayBillNumber))
            {
                NumberStr = filter.WayBillNumber;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(filter.TrackingNumber))
                {
                    NumberStr = filter.TrackingNumber;
                }
            }
            var waybillinfo = _inStorageService.GetWayBillInfo(NumberStr, filter.CustomerCode); //.ToModel<WayBillInfoModel>();

            if (!string.IsNullOrWhiteSpace(NumberStr) && waybillinfo != null)
            {
                //if (!string.IsNullOrWhiteSpace(filter.TrackingNumber) && waybillinfo.TrackingNumber != filter.TrackingNumber)
                //{
                //    error.AppendLine("跟踪号与输入的跟踪号不一样!<br/>");
                //}_orderService.AddAbnormalWayBill
                if (error.Length == 0 && WayBill.StatusToValue(WayBill.StatusEnum.Submitted) != waybillinfo.Status)
                {
                    error.AppendLine(string.Format("运单:{0}状态不是已提交!<br/>", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.GoodsTypeID != filter.GoodsTypeID)
                {
                    error.AppendLine(string.Format("运单:{0}货物类型不是一致", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.IsHold)
                {
                    error.AppendLine(string.Format("运单:{0}已经Hold!<br/>", NumberStr));
                }
                if (error.Length == 0 && waybillinfo.InShippingMethodID.HasValue &&
                    waybillinfo.InShippingMethodID.Value != filter.ShippingMethodId)
                {
                    error.AppendLine(string.Format("入仓运输方式与运单运输方式:{0}不一致!<br/>", waybillinfo.InShippingMethodName));
                    //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("运单号:{0}国家或运输方式异常", waybillinfo.WayBillNumber));
                }
                if (error.Length == 0 && waybillinfo.CustomerCode.ToUpper().Trim() != filter.CustomerCode.ToUpper().Trim())
                {
                    error.AppendLine(string.Format("入仓客户与运单客户:{0}不一致!<br/>", waybillinfo.CustomerCode));
                    //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, string.Format("入仓客户与运单客户:{0}不一致", waybillinfo.CustomerCode.ToUpper()));
                }
                if (error.Length > 0)
                {
                    model.IsSuccess = false;
                    model.Message   = error.ToString();
                }
                else
                {
                    // 根据转换重量转换包裹类型 Add by zhengsong
                    #region
                    var shippingMethod = _freightService.GetShippingMethod(filter.ShippingMethodId);
                    if (shippingMethod != null)
                    {
                        if (shippingMethod.Enabled && shippingMethod.ShippingMethodTypeId == 4)
                        {
                            if (filter.Weight <= shippingMethod.PackageTransformFileWeight)
                            {
                                filter.GoodsTypeID = 2;
                            }
                        }
                    }
                    #endregion

                    Guid     customerId = Guid.Empty;
                    Customer customer   = _customerService.GetCustomer(waybillinfo.CustomerCode);
                    if (customer != null)
                    {
                        customerId = customer.CustomerID;
                    }
                    var result = _freightService.GetCustomerShippingPrice(new CustomerInfoPackageModel()
                    {
                        CountryCode      = waybillinfo.CountryCode,
                        CustomerTypeId   = filter.CustomerType,
                        Height           = filter.Height ?? 0,
                        Length           = filter.Length ?? 0,
                        ShippingMethodId = filter.ShippingMethodId,
                        Weight           = filter.Weight,
                        Width            = filter.Width ?? 0,
                        ShippingTypeId   = filter.GoodsTypeID,
                        CustomerId       = customerId
                    });
                    if (result.CanShipping)
                    {
                        model.IsSuccess           = true;
                        model.Message             = "";
                        model.WayBillNumber       = waybillinfo.WayBillNumber;
                        model.CountryCode         = waybillinfo.CountryCode;
                        model.CountryName         = _freightService.GetChineseName(waybillinfo.CountryCode);
                        model.CustomerOrderNumber = waybillinfo.CustomerOrderNumber;
                        model.Freight             = result.ShippingFee;                     //运费
                        model.FuelCharge          = result.FuelFee;                         //燃油费
                        model.Register            = result.RegistrationFee;                 //挂号费
                        model.Surcharge           = result.RemoteAreaFee + result.OtherFee; //附加费
                        model.SettleWeight        = result.Weight;                          //结算重量
                        //if (!string.IsNullOrWhiteSpace(filter.TrackingNumber) &&
                        //    filter.TrackingNumber != waybillinfo.TrackingNumber)
                        //{
                        //    model.TrackingNumber = filter.TrackingNumber;
                        //}
                        //else
                        //{
                        //    model.TrackingNumber = !string.IsNullOrWhiteSpace(waybillinfo.TrackingNumber) ? waybillinfo.TrackingNumber : "";
                        //}
                        model.TrackingNumber = !string.IsNullOrWhiteSpace(waybillinfo.TrackingNumber) ? waybillinfo.TrackingNumber : "";

                        //if (filter.ChkPrint)
                        //{
                        //    var customerOrder = GetPrinterInfo(waybillinfo.CustomerOrderID);
                        //    if (customerOrder != null)
                        //    {
                        //        var wayBillTemplateModel = _wayBillTemplateService.GetWayBillTemplateByNameAndShippingMethod(filter.PrintTemplateName, filter.ShippingMethodId).FirstOrDefault();
                        //        if (wayBillTemplateModel != null)
                        //        {
                        //            //model.HtmlString = this.RenderPartialViewToString("_PrintTNTOrder", customerOrderInfosModels);
                        //            if (!string.IsNullOrWhiteSpace(customerOrder.TrackingNumber))
                        //            {
                        //                model.HtmlString =
                        //                    System.Web.WebPages.Razor.Parse(HttpUtility.HtmlDecode(wayBillTemplateModel.TemplateContent),
                        //                                customerOrder);
                        //            }
                        //        }
                        //    }
                        //}
                    }
                    else
                    {
                        // _orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber, WayBill.AbnormalTypeEnum.InAbnormal, result.Message);  //入仓扫描时取消因重量价格不对自动拦截运单  by:bookers  date:2013.10.25
                        model.IsSuccess = false;
                        model.Message   = result.Message;
                    }
                }
            }
            else
            {
                model.IsSuccess = false;
                model.Message   = string.Format("单号:{0}系统找不到!", NumberStr);
            }
            return(model);
        }
        public CheckOnWayBillResponseResult CheckOnWayBillCS(InStorageFormModel filter)
        {
            var model = new CheckOnWayBillResponseResult();
            var error = new StringBuilder();

            if (string.IsNullOrWhiteSpace(filter.CustomerCode))
            {
                model.Result  = false;
                model.Message = "客户为空!";
            }
            else
            {
                var NumberStr = string.Empty;
                if (!string.IsNullOrWhiteSpace(filter.WayBillNumber))
                {
                    NumberStr = filter.WayBillNumber.Trim();
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(filter.TrackingNumber))
                    {
                        NumberStr = filter.TrackingNumber.Trim();
                    }
                }
                if (string.IsNullOrWhiteSpace(NumberStr))
                {
                    model.Result  = false;
                    model.Message = "单号为空!";
                }
                else
                {
                    var waybillinfo = _wayBillInfoRepository.GetWayBillInfoExtSilm(NumberStr);

                    if (waybillinfo != null)
                    {
                        if (WayBill.StatusToValue(WayBill.StatusEnum.Submitted) != waybillinfo.Status)
                        {
                            error.AppendLine(string.Format("运单:{0}状态为{1}!<br/>", NumberStr, WayBill.GetStatusDescription(waybillinfo.Status)));
                        }
                        if (error.Length == 0 && waybillinfo.GoodsTypeID != filter.GoodsTypeID)
                        {
                            error.AppendLine(string.Format("运单:{0}货物类型不是一致", NumberStr));
                        }
                        if (error.Length == 0 && !string.IsNullOrWhiteSpace(filter.TrackingNumber))
                        {
                            var w = _wayBillInfoRepository.GetWayBillByTrackingNumber(filter.TrackingNumber.Trim());
                            if (w != null && w.WayBillNumber != waybillinfo.WayBillNumber)
                            {
                                error.AppendLine(string.Format("跟踪号:{0}系统已经存在", filter.TrackingNumber));
                            }
                        }
                        if (error.Length == 0 && waybillinfo.IsHold)
                        {
                            error.AppendLine(string.Format("运单:{0}已经Hold!<br/>", NumberStr));
                        }
                        if (error.Length == 0 && waybillinfo.InShippingMethodID.HasValue &&
                            waybillinfo.InShippingMethodID.Value != filter.ShippingMethodId)
                        {
                            error.AppendLine(string.Format("入仓运输方式与运单运输方式:{0}不一致!<br/>",
                                                           waybillinfo.InShippingMethodName));
                            //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                            //WayBill.AbnormalTypeEnum.InAbnormal,
                            //string.Format("运单号:{0}国家或运输方式异常", waybillinfo.WayBillNumber));
                        }
                        if (error.Length == 0 && waybillinfo.CustomerCode.ToUpper() != filter.CustomerCode.ToUpper())
                        {
                            error.AppendLine(string.Format("入仓客户与运单客户:{0}不一致!<br/>", waybillinfo.CustomerCode));
                            //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                            //                                 WayBill.AbnormalTypeEnum.InAbnormal,
                            //                                 string.Format("入仓客户与运单客户:{0}不一致", waybillinfo.CustomerCode));
                        }
                        if (error.Length > 0)
                        {
                            model.Result  = false;
                            model.Message = error.ToString();
                        }
                        else
                        {
                            var chineseName = GetGetCountryListFromCache().Find(p => p.CountryCode == waybillinfo.CountryCode).ChineseName;


                            //var areaIdList =
                            //    _freightService.GetCountryArea(filter.ShippingMethodId, waybillinfo.CountryCode)
                            //                   .FirstOrDefault();


                            var listShippingMethodCountryModel = GetShippingMethodCountriesFromCache(filter.ShippingMethodId);
                            var areaIdList = listShippingMethodCountryModel.Find(p => p.CountryCode == waybillinfo.CountryCode);

                            if (areaIdList != null)
                            {
                                model.Result  = true;
                                model.Message = chineseName + "(" + areaIdList.AreaId + "区)";
                            }
                            else
                            {
                                //_orderService.AddAbnormalWayBill(waybillinfo.WayBillNumber,
                                //                                 WayBill.AbnormalTypeEnum.InAbnormal,
                                //                                 string.Format("该运输方式无法送达该目的地国家{0} ", chineseName));
                                model.Result  = false;
                                model.Message = string.Format("该运输方式无法送达该目的地国家{0} ", chineseName);
                            }
                        }
                        model.TrackingNumber = waybillinfo.TrackingNumber;

                        //返回运单的重量weight
                        model.ErrorWayBillNumber = waybillinfo.Weight.HasValue ? waybillinfo.Weight.ToString() : "0";

                        model.ShippingInfo = new ShippingInfoModel();

                        _wayBillInfoRepository.Get(waybillinfo.WayBillNumber).ShippingInfo.CopyTo(model.ShippingInfo);
                    }
                    else
                    {
                        NoForecastAbnormal noForecastAbnormal = new NoForecastAbnormal()
                        {
                            CustomerCode     = filter.CustomerCode,
                            Number           = NumberStr,
                            ShippingMethodId = filter.ShippingMethodId,
                            Weight           = filter.Weight,
                            CreatedOn        = DateTime.Now,
                            CreatedBy        = filter.OperatorUserName,
                            LastUpdatedOn    = DateTime.Now,
                            LastUpdatedBy    = filter.OperatorUserName,
                        };
                        _orderService.UpdateNoForecastAbnormal(noForecastAbnormal);

                        model.Result  = false;
                        model.Message = string.Format("单号:{0}无预报,不能扫描入仓!", NumberStr);
                    }
                }
            }
            return(model);
        }