예제 #1
0
        private void ForecastDHLandEUB()
        {
            string     errorWayBills        = "";
            List <int> inShippingMethodIds  = new List <int>();
            List <int> dhlShippingMethodIds = new List <int>();
            List <int> eubShippingMethodIds = new List <int>();
            var        dhlcodes             = dhlshippingMethodCode.Split(',').ToList();
            var        eubcodes             = eubshippingMethodCode.Split(',').ToList();
            var        shippingMethod       = _freightService.GetShippingMethods("", true);

            shippingMethod.ForEach(p =>
            {
                if (dhlcodes.Contains(p.Code))
                {
                    inShippingMethodIds.Add(p.ShippingMethodId);
                    dhlShippingMethodIds.Add(p.ShippingMethodId);
                }
                else if (eubcodes.Contains(p.Code))
                {
                    inShippingMethodIds.Add(p.ShippingMethodId);
                    eubShippingMethodIds.Add(p.ShippingMethodId);
                }
            });
            int number = 0;

            while (true)
            {
                var wayBillList = _orderService.GetDHLandEUBWayBillInfos(inShippingMethodIds, number);
                if (wayBillList.Count < 1)
                {
                    break;
                }
                List <WayBillInfo> dhlwayBills = new List <WayBillInfo>();
                List <WayBillInfo> eubWayBills = new List <WayBillInfo>();
                wayBillList.ForEach(p =>
                {
                    if (dhlShippingMethodIds.Contains(p.InShippingMethodID.Value))
                    {
                        dhlwayBills.Add(p);
                    }
                    else if (eubShippingMethodIds.Contains(p.InShippingMethodID.Value))
                    {
                        eubWayBills.Add(p);
                    }
                });
                //DHL预报
                if (dhlwayBills.Count > 0)
                {
                    var errors = PostDHLShipment(dhlwayBills);
                    errorWayBills = errors.Aggregate(errorWayBills, (current, error) => current + ("[" + error.Key + "]"));
                    UpdateWayBillInfo(errors);
                }
                //EUB预报
                if (eubWayBills.Count > 0)
                {
                    EubWayBillParam param = new EubWayBillParam()
                    {
                        WayBillInfos     = eubWayBills,
                        PrintFormat      = 2,
                        PrintFormatValue = "01"
                    };
                    var errors = _customerOrderService.ForecastEubWayBillInfo(param, true);
                    if (errors.Count > 0)
                    {
                        errorWayBills = errors.Aggregate(errorWayBills, (current, error) => current + ("[" + error.Key + "]"));

                        UpdateWayBillInfo(errors);
                        //errors.ForEach(p=> errorWayBills+="["+p+"]");
                    }
                }
                number += wayBillList.Count;
            }
            Log.Info("预报失败运单:" + errorWayBills);
        }