当前位置: 代码迷 >> PB >> PNR记录解析,该如何解决
  详细解决方案

PNR记录解析,该如何解决

热度:179   发布时间:2016-04-29 09:08:44.0
PNR记录解析
大家有谁对航空售票点的PNR记录解析比较了解,能谈谈怎么解析吗

------解决方案--------------------
没做过,帮你顶吧.
------解决方案--------------------
都没做过,lz还是把需求再说详细点
------解决方案--------------------
没见过,帮顶,楼主可以贴些资源看看
------解决方案--------------------
因为PB的正则不好用,所以只能用很多字符处理函数来硬写,比较繁琐,一共十几个函数。
我贴一下主要代码,给个思路,相关函数楼主自己想想:

If Trim(mle_1.Text) = '' Then
f_alert("请填写要解析的记录!")
Return
End If

f_split(mle_1.Text,ls_line,"~r~n")

DateTime ldt_CancelDate
Boolean IsLastGuest
String PNR,AirPNR
String ls_GuestList[],ls_AirLine[],ls_767[],ls_CertificateInter[],ls_CertificateCN[],ls_OKLine
Integer i,j = 1,k = 1,p = 1

For i = 1 To UpperBound(ls_line)
//处理每一行,去掉多余空格
ls_OKLine = wf_OneSpace(ls_line[i])
If AirPNR = '' Then AirPNR = wf_AirPNR(ls_OKLine)
//旅客信息
If IsLastGuest = False Then ls_GuestList[i] = ls_OKLine
If IsLastGuest = False Then IsLastGuest = wf_IsLastGuest(ls_line[i],PNR)
//国际票,旅客证件信息
If wf_certificate_inter(ls_OKLine) Then
ls_CertificateInter[k] = ls_OKLine
k++
End If
//国内票,旅客证件信息
If wf_certificate_CN_is(ls_OKLine) Then
ls_CertificateCN[p] = ls_OKLine
p++
End If
//行程信息  
If wf_IsAirLine(ls_OKLine) Then
ls_AirLine[j] = ls_OKLine
//机型
ls_767[j] = wf_767(ls_AirLine[j])
j++
End If
//机票取消截止日期
If wf_IsCancelDate(ls_OKLine) Then
ldt_CancelDate = wf_GetCancelDate(ls_OKLine)
End If
Next
Dec{2} discount,FullPrice,fuelfee[],tax
String Unit[],airname
String departairport,arriveairport
String Line_FlightNo,Line_Class,line_Date,line_city,line_time1,line_time2
String CityCode1,CityCode2,Carrier,Class,FlightNo,Day,Month,DepartCity,ArriveCity,BeginTime,EndTime
DateTime ldt_1,ldt_2
tax = 50
If UpperBound(ls_AirLine) > 0 And UpperBound(ls_GuestList) > 0 Then
//生成行程
For i = 1 To UpperBound(ls_AirLine)
//
f_split(ls_AirLine[i],Unit,' ')
Line_FlightNo = Unit[1]
Line_Class = Unit[2]
line_Date = Unit[3]
line_city = Unit[4]
line_time1 = Unit[6]
line_time2 = Unit[7]
//
CityCode1 = Left(line_city,3)
CityCode2 = Right(line_city,3)
Carrier = Left(Line_FlightNo,2)
airname = f_Air_Company(Carrier)
Class = f_class_discount(Carrier,Line_Class)
discount = f_get_air_ticket_disc(Class)
Month = f_MonthNum(Right(line_Date,3))
Day = Mid(line_Date,3,2)
BeginTime = f_FormatTime(line_time1)
EndTime = f_FormatTime(line_time2)
ldt_1 = DateTime(Date(String(Year(Today()))+'-'+Month+'-'+Day),Time(BeginTime))
ldt_2 = DateTime(Date(String(Year(Today()))+'-'+Month+'-'+Day),Time(EndTime))
FlightNo = Line_FlightNo
departairport = f_AirCity_Code2Name(CityCode1)
arriveairport = f_AirCity_Code2Name(CityCode2)
DepartCity = f_Airport2city(departairport)
ArriveCity = f_Airport2city(arriveairport)
//
FullPrice = f_Air_FullPrice(DepartCity,ArriveCity)
f_Air_fuelfee(DepartCity,ArriveCity,fuelfee[])
//
wf_Insert_tour(ldt_1,departairport,ldt_2,arriveairport,airname,FlightNo,Class,FullPrice,discount,fuelfee,tax,CityCode1,CityCode2,ls_767[i],ldt_CancelDate)
Next
//生成客人列表
String ls_guest[],ls_name,ls_ageType
For i = 1 To UpperBound(ls_GuestList)
If ls_GuestList[i] <> '' Then
ls_name = wf_Fullname(ls_GuestList[i])
ls_ageType = wf_AgeType(ls_GuestList[i])
wf_insert_guest(ls_name,ls_ageType)
End If
Next

String ls_cti[]
For i = 1 To UpperBound(ls_CertificateInter)
wf_Certificate_Inter(ls_CertificateInter[i],ls_cti)
  相关解决方案