Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加件
        /// </summary>
        private void AddPiece()
        {
            #region 检查数据

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

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) == dgvPackageList.Rows.Count)
            {
                lblTsg.Text = "输入件数与行数相等,请确认提交!";
                btnSubmit.Focus();
                return;
            }

            if (int.Parse(this.txtPieces.Text.Trim()) < dgvPackageList.Rows.Count)
            {
                lblTsg.Text = "行数与列表数不对!";
                return;
            }


            if (string.IsNullOrWhiteSpace(this.txtNumber.Text))
            {
                this.lblTsg.Text = "请输入订单号/运单号!";
                this.txtNumber.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtPieces.Text))
            {
                this.lblTsg.Text = "请输入件数!";
                this.txtPieces.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtWeights.Text))
            {
                this.lblTsg.Text = "请输入重量!";
                this.txtWeights.Focus();
                return;
            }

            double weightValue;
            double.TryParse(this.txtWeights.Text, out weightValue);
            if (Convert.ToDouble(weightValue) < 0.005)
            {
                this.lblTsg.Text = "重量不能小于0.005!";
                this.txtWeights.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtLong.Text))
            {
                this.lblTsg.Text = "请输入长!";
                this.txtLong.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtWidth.Text))
            {
                this.lblTsg.Text = "请输入宽!";
                this.txtWidth.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(this.txtHeight.Text))
            {
                this.lblTsg.Text = "请输入高!";
                this.txtHeight.Focus();
                return;
            }

            #endregion

            decimal[] wlw       = new decimal[] { decimal.Parse(txtLong.Text.Trim()), decimal.Parse(txtWidth.Text.Trim()), decimal.Parse(txtHeight.Text.Trim()) };
            decimal[] wlwSorted = wlw.OrderByDescending(m => m).ToArray();
            WaybillPackageDetailModel waybillDetailModel = new WaybillPackageDetailModel()
            {
                PackageDetailID = Guid.NewGuid().ToString(),     //唯一包裹序号
            };

            requestModel.CustomerCode         = this.txtCustomers.Text.Trim();
            requestModel.GoodsTypeID          = (int)cbbGoodsType.SelectedValue;
            requestModel.ShippingMethodId     = (int)cbbInStorage.SelectedValue;
            requestModel.IsBusinessExpress    = ((ShippingMethodModel)cbbInStorage.SelectedItem).ShippingMethodTypeId == 2;
            requestModel.OperatorUserName     = LoginHelper.CurrentUserName;
            requestModel.WayBillNumber        = this.txtNumber.Text.Trim();
            requestModel.CustomerType         = int.Parse(CustomerTypeID);
            requestModel.Weight               = decimal.Parse(txtWeights.Text.Trim());
            requestModel.Length               = wlwSorted[0];
            requestModel.Width                = wlwSorted[1];
            requestModel.Height               = wlwSorted[2];
            waybillDetailModel.ShippingMethod = cbbInStorage.SelectedText;
            waybillDetailModel.WayBillNumber  = txtWaybillNumber.Text.Trim();
            waybillDetailModel.Weight         = decimal.Parse(txtWeights.Text.Trim());
            waybillDetailModel.Length         = wlwSorted[0];
            waybillDetailModel.Width          = wlwSorted[1];
            waybillDetailModel.Height         = wlwSorted[2];

            //检查单个包裹
            ResponseModel = InvokeWebApiHelper.CheckOnInStorage(requestModel);
            if (ResponseModel == null)
            {
                return;
            }

            //检查失败
            if (!ResponseModel.IsSuccess)
            {
                this.lblTsg.Text = ResponseModel.Message.Replace("<br/>", "");
                PlayFailSound();
                return;
            }

            if (ResponseModel.SettleWeight == 0)
            {
                MessageBox.Show("错误:结算重量为零");
                return;
            }


            waybilldetailList.Add(waybillDetailModel);
            this.dgvPackageList.Rows.Insert(0, new object[] { 0, waybillDetailModel.PackageDetailID, waybillDetailModel.Weight, waybillDetailModel.Length, waybillDetailModel.Width, waybillDetailModel.Height });

            #region 清空数据,重新定位光标

            if (!cbxWeight.Checked)
            {
                txtWeights.Focus();
            }
            else if (cbxVolume.Checked)
            {
                txtHeight.Focus();
            }
            else
            {
                txtLong.Focus();
            }

            if (!cbxWeight.Checked && txtWeights.Enabled)
            {
                txtWeights.Text = "";
            }
            if (!cbxVolume.Checked && (txtLong.Enabled && txtWidth.Enabled && txtHeight.Enabled))
            {
                txtLong.Text   = "";
                txtWidth.Text  = "";
                txtHeight.Text = "";
            }

            #endregion


            //如果件数与已录入的件数相等,直接提交
            if (int.Parse(this.txtPieces.Text.Trim()) == dgvPackageList.Rows.Count)
            {
                if (btnSubmit.Enabled)
                {
                    btnSubmit_Click(null, null);
                }
            }
        }
Exemplo n.º 3
0
        /// <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);
        }