Ejemplo n.º 1
0
 /// <summary>
 /// FD计算折扣 保留两位小数
 /// </summary>
 /// <param name="fditem"></param>
 /// <param name="YFdItem"></param>
 /// <returns></returns>
 private FdItemData JiSuanPrice(FdItemData fditem, List <FdItemData> YFdItem)
 {
     if (YFdItem != null && YFdItem.Count > 0)
     {
         FdItemData fdYitem = YFdItem.Find(delegate(FdItemData yfd)
         {
             if (yfd.Carry.Trim().ToUpper() == fditem.Carry.Trim().ToUpper())
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         });
         if (fdYitem != null)
         {
             fditem.DiscountRate = FormatPNR.GetZk(fdYitem.Fare1, fditem.Fare1).ToString();
         }
     }
     return(fditem);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 解析FD数据
        /// </summary>
        /// <param name="FdDataList"></param>
        /// <returns></returns>
        public FDModel GetFDData(List <string> FdDataList)
        {
            bool IsGetHeader = false;
            //是否计算折扣
            bool    IsJSPrice = true;
            FDModel fdmodel   = new FDModel();

            foreach (string item in FdDataList)
            {
                string[] strArr = item.Split(new string[] { "\r" }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var fdItem in strArr)
                {
                    if (!fdItem.StartsWith("PFD") && !fdItem.StartsWith("FD:"))
                    {
                        //每项数据处理
                        string FdPattern = @"\s*(?<num>\d{1,3})\s*(?<Carry>\w{2})\/(?<Seat>\w+)\s*\/\s*(?<Fare1>[\d|\.]+)\=\s*(?<Fare2>[\d|\.]+)\s*\/(?<seat1>\w{1,2})\/(?<seat2>\w{1,2})\/\s*\/\s*\.\s*\/(?<date>.*?)\s*\/(?<Orther>\w+)\s*";
                        Match  mchFd     = Regex.Match(fdItem, FdPattern, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                        if (mchFd.Success)
                        {
                            FdItemData fditem = new FdItemData();
                            fditem.num    = mchFd.Groups["num"].Value.Replace("", "");
                            fditem.Carry  = mchFd.Groups["Carry"].Value.Replace("", "");
                            fditem.Seat   = mchFd.Groups["Seat"].Value.Replace("", "");
                            fditem.Fare1  = mchFd.Groups["Fare1"].Value.Replace("", "");
                            fditem.Fare2  = mchFd.Groups["Fare2"].Value.Replace("", "");
                            fditem.seat1  = mchFd.Groups["seat1"].Value.Replace("", "");
                            fditem.seat2  = mchFd.Groups["seat2"].Value.Replace("", "");
                            fditem.date   = FormatPNR.GetYMD(mchFd.Groups["date"].Value.Replace("", ""), DataFormat.dayMonthYear);
                            fditem.Orther = mchFd.Groups["Orther"].Value.Replace("", "");
                            fdmodel.FdDataList.Add(fditem);
                            if (fditem.Seat.Trim().ToUpper() == "Y")
                            {
                                fdmodel.FdYDataList.Add(fditem);
                            }
                        }
                    }
                    else
                    {
                        if (!IsGetHeader)
                        {
                            string FdPattern = @"(?<=FD:)\s*(?<city>.*?)\/(?<date>.*?)\/\s*.*?(?<=\/TPM)\s*(?<Mileage>\d+)\/\s*";
                            Match  mchFd     = Regex.Match(fdItem, FdPattern, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);
                            if (mchFd.Success)
                            {
                                string city    = mchFd.Groups["city"].Value.Trim().ToUpper().Replace("", "");
                                string date    = mchFd.Groups["date"].Value.Trim().Replace("", "");
                                string Mileage = mchFd.Groups["Mileage"].Value.Trim() == "" ? "0" : mchFd.Groups["Mileage"].Value.Trim();
                                fdmodel.fdMileage = Mileage.Replace("", "");
                                fdmodel.fdDate    = FormatPNR.GetYMD(date, DataFormat.dayMonthYear);
                                fdmodel.strDate   = date;
                                fdmodel.fromCode  = city.Substring(0, 3);
                                fdmodel.toCode    = city.Substring(3);
                                IsGetHeader       = true;
                            }
                        }
                    }
                } //数据
            }     //PN
            if (IsJSPrice)
            {
                for (int i = 0; i < fdmodel.FdDataList.Count; i++)
                {
                    JiSuanPrice(fdmodel.FdDataList[i], fdmodel.FdYDataList);
                }
            }
            fdmodel.TotalCount = fdmodel.FdDataList.Count.ToString();
            return(fdmodel);
        }