大家看看源码吧,帮我分析一下,谢谢了
unit Ubwfy_tread;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, DB, Grids, DBGrids,StrUtils, ActiveX,
ComCtrls, OoMisc, AdPort,Registry,Buttons,DBCtrls,ImgList, Mask, CRGrid,MsgExch,
Ora, Tel_DM,USend_message_tthread,
OraSmart, MemDS, DBAccess,IdUDPServer;
const
WM_myPROCESS = WM_USER + 100;
type
TBWFY_TREAD = class(TThread)
private
{ Private declarations }
m_ysbw:string;
tmp_str,mytmp_xh:string;
tmp_recno:string;
my_memo1:tmemo;
OraSession,local_OraSession: TOraSession;
my_num:integer;
fieldlist,valuelist:tstrings;
my_tmpqry1:TOraQuery;
protected
Function Tran_AFTN_DEP(BW_String:string):string;
//00 起飞报 DEP 已发 ( departure message)
procedure create_orasession;
procedure memo_add;
procedure memo_clear;
procedure Execute;
override;
public
constructor create(ysbw:string;memo1:tmemo;tmp_xh:string);
destructor Destroy;
override;
end;
var
bwfy_session: TBWFY_TREAD;
implementation
uses Tel_ParseTranslation;
constructor TBWFY_TREAD.create(ysbw: string;memo1:tmemo;tmp_xh:string);
begin
m_ysbw:= ysbw;
my_memo1:= memo1;
mytmp_xh:= tmp_xh;
tread_numadd;
fieldlist:=tstringlist.Create;
valuelist:=tstringlist.Create;
freeonterminate:=true;
inherited Create(False);
end;
procedure TBWFY_TREAD.create_orasession;
begin
CoInitialize(nil);
OraSession:=TOraSession.Create(nil);
OraSession.Options.Net:=true;
OraSession.Username := 'garims';
OraSession.Password := 'garims';
OraSession.Server := '192.168.0.17:1521:tharims';
OraSession.ConnectPrompt:=false;
OraSession.AutoCommit:=true;
OraSession.Connected := false;
////////////////
local_OraSession:=TOraSession.Create(nil);
local_OraSession.Options.Net:=true;
local_OraSession.Username := 'bwxx';
local_OraSession.Password := 'bwxx';
local_OraSession.Server := '127.0.0.1:1521:bwxx';
local_OraSession.ConnectPrompt:=false;
local_OraSession.AutoCommit:=true;
local_OraSession.Connected := false;
my_tmpqry1:=TOraQuery.Create(nil);
my_tmpqry1.Session:= local_OraSession;
end;
procedure TBWFY_TREAD.Execute;
var
str1:string;
begin
create_orasession;
try
str1:=Tran_loop(m_ysbw);
//Tran_loop中调用Tran_AFTN_DEP函数
tmp_str:=tmp_str+ str1;
Synchronize(memo_add);
if trim(mytmp_xh)<>'' then
begin
my_tmpqry1.Close;
my_tmpqry1.SQL.Clear;
my_tmpqry1.SQL.Add('delete from bwxx where myid='''+mytmp_xh+'''');
my_tmpqry1.ExecSQL;
my_tmpqry1.Close;
end;
except
on e:exception do
begin
exception_resolve;
end;
end;
try
tread_numsub;
self.Terminate;
except
end;
//Synchronize(postmymessage);
end;
procedure TBWFY_TREAD.memo_add;
begin
if my_memo1.Lines.Count>1000 then
my_memo1.Lines.Clear;
my_memo1.Lines.Add(tmp_str);
my_memo1.Update;
my_memo1.Refresh;
end;
procedure TBWFY_TREAD.memo_clear;
begin
if my_memo1.Lines.Count>1000 then
my_memo1.Lines.Clear;
end;
destructor TBWFY_TREAD.Destroy;
begin
try
try
//my_tmpqry1.Close;
freeandnil(fieldlist);
freeandnil(valuelist);
freeandnil(my_tmpqry1);
// orasession.Connected:=false;
// local_OraSession.Connected:=false;
freeandnil(orasession);
freeandnil(local_OraSession);
CoUnInitialize;
except
end;
finally
inherited;
end;
end;
Function TBWFY_TREAD.Tran_AFTN_DEP(BW_String:string):string;
var
BW_Recno:string;
BW_Rectime:string;
XBW_Rectime:string;
BW_WarnClass:string;
BW_RecieveAirport:string;
BW_Sendtime:string;
XBW_Sendtime:string;
BW_SendAirport:string;
BW_Flightno:string;
BW_Plantype:string;
BW_Depairport:string;
BW_Deptime:string;
BW_Arrairport:string;
// BW_Arrtime:string;
// BW_city:string;
// BW_Height:string;
// BW_REMARK:STRING;
Loop_tempstring:string;
// Temp_BW_string:string;
BW_CoFlt:string;
// i:integer;
Add_T:double;
Add_T_S:string;
ATable:TOraTable;
AQuery:TOraQuery;
MsgExchSend : TMsgExch;
MsgText :TStringList ;
xs_str,zx_str,sql_str,xx_rq:string;
ss,str55,my_date,my_specialtm,stid:string;
begin
{(DEP-CCA1301/A3031-ZBAA1430-ZGGG)
说明;CCA1301航班于1430从北京机场起飞,应答机编码A3031,目的地广州机场。
}
///// AFTN-DEP
//取流水帐号
MsgText:=TStringList.Create;
//send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
BW_Rectime :=formatdatetime('ddHHnn',now);
//收报时间
BW_Sendtime:=formatdatetime('ddHHnn',now);
//发报时间
Loop_tempstring:=F_dispart(BW_String,'(');
Loop_tempstring:=S_dispart(BW_String,LocalTelAdd);
if Get_Bw_RecandSendDate(F_dispart(Loop_tempstring,'('),XBW_Rectime,XBW_Sendtime) then
begin
BW_Rectime :=XBW_Rectime;
BW_Sendtime:=XBW_Sendtime;
end;
Loop_tempstring:=DeleteNull(Loop_tempstring);
Loop_tempstring:=DeleteEnter(Loop_tempstring);
BW_Recno:=copy(Loop_tempstring,1,4);
{BW_WarnClass:=copy(Loop_tempstring,11,2);
BW_RecieveAirport:=copy(Loop_tempstring,13,4);
BW_SendAirport:=copy(Loop_tempstring,27,4);
}
// BW_SendAirport:=copy(S_dispart(Loop_tempstring,BW_Sendtime),1,4);
//wzh add
ss:=inttostr(pos(chr(10),BW_String));
ss:=copy(BW_String,strtoint(ss)+1,length(BW_String)) ;
ss:= DeleteNull(ss);
ss:= DeleteEnter(ss);
BW_WarnClass:=copy(ss,1,2);
BW_RecieveAirport:=copy(ss,3,4);
BW_SendAirport:=copy(ss,17,4);
///
Loop_tempstring:=S_dispart(BW_String,'(');
Loop_tempstring:=F_dispart(Loop_tempstring,')');
Loop_tempstring:=S_dispart(Loop_tempstring,'-');
//CCA1301/A3031-ZBAA1430-ZGGG
BW_Flightno:=F_dispart(F_dispart(Loop_tempstring,'-'),'/');
///航班号 CCA1301
BW_Plantype:=S_dispart(F_dispart(Loop_tempstring,'-'),'/');
//应答机编码 A3031
Loop_tempstring:=S_dispart(Loop_tempstring,'-');
//ZBAA1430-ZGGG
BW_Depairport:=copy(Loop_tempstring,1,4);
// 起飞机场
BW_Deptime:=copy(Loop_tempstring,5,4);
//起飞时间
BW_Arrairport:=leftstr(S_dispart(Loop_tempstring,'-'),4);
// 到达机场
result:='流水帐号:'+BW_Recno+',收报时间:'+BW_Rectime+',电报等级:'+BW_WarnClass
+chr(13)+chr(10)+',接报机场:'+BW_RecieveAirport+',发报时间:'+BW_Sendtime+',发报机场:'+BW_SendAirport
+chr(13)+chr(10)+',航班号:'+BW_Flightno+',应答机编码:'+BW_Plantype
+chr(13)+chr(10)+',起飞机场:'+BW_Depairport+',起飞时间:'+BW_Deptime
+chr(13)+chr(10)+',到达机场:'+BW_Arrairport;
BW_CoFlt:=copy(trim(BW_Flightno),4,length(trim(BW_Flightno))-3);
// 1301
if (Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))='XX') and (ord(BW_Flightno[3])>=48) and (ord(BW_Flightno[3])<=57) then
BW_CoFlt:=BW_Flightno;
ATable:=TOraTable.Create(nil);
try //修改起飞信息
ATable.Session:=OraSession;
ATable.TableName:='bw_dynflt';
ATable.Open;
// ATable.Edit;
ATable.Append;
if IS_BW_time_Type(BW_Sendtime) then
ATable.FieldByName('PLANDATE').AsString:=Localplandate;//formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24);
ATable.FieldByName('AIRCORP').AsString:=Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3));
ATable.FieldByName('FLTNO').AsString:=BW_CoFlt;
ATable.FieldByName('TKFP').AsString:=Get_PLN_Place(BW_Depairport);
ATable.FieldByName('ARRP').AsString:=Get_PLN_Place(BW_Arrairport);
check_time(BW_Sendtime,BW_Deptime,my_date) ;
if IS_Time_Type(BW_Deptime) and IS_BW_time_Type(BW_Sendtime) then
begin
if my_date='' then
ATable.FieldByName('RtkfTM').AsDateTime:=
strtodatetime(formatdatetime('yyyy-MM-dd',strtodatetime(Pek_time(BW_Sendtime)))+' '
+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2))+8/24
else
ATable.FieldByName('RtkfTM').AsDateTime:=
strtodatetime(formatdatetime('yyyy-MM-dd',strtodatetime(my_date))+' '
+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2))+8/24 ;
end;
ATable.FieldByName('FSTATUS').AsString:='AFTN-DEP';
ATable.FieldByName('BWID').AsString:=BW_Recno;
ATable.FieldByName('remark').AsString:=result;
ATable.FieldByName('TexRes').AsVariant:=BW_String;
ATable.FieldByName('RECNO').AsString:='1';
//ATable.FieldByName('SENDTIME').AsString:=formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime))+8/24);
ATable.Post;
// ATable.ApplyUpdates;
ATable.Close;
finally
//ATable.Free;
freeandnil(ATable);
end;
//更新航班动态[进港]
if (Get_PLN_Place(BW_Arrairport)=LocalCity) and
IS_Time_Type(BW_Deptime) and
IS_BW_time_Type(BW_Sendtime) then
begin
AQuery:=TOraQuery.Create(nil);
try
AQuery.Session:=OraSession;
//实际起飞时间更新
//sql_str:='select t.*,t.aid as id from dynarrflt t where t.PLANDATE='''+Localplandate+''' and
t.AIRCORP='''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''' and t.FLTNO='''+BW_CoFlt+'''';
sql_str:='select t.*,t.aid as id from dynarrflt t where t.AIRCORP='''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))
+''' and t.FLTNO='''+BW_CoFlt+'''';
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add(sql_str);
AQuery.Open;
if AQuery.RecordCount<=1 then
begin
AQuery.Close;
AQuery.SQL.Clear;
if my_date='' then
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime)))+' '+copy
(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24'
else
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+' '+copy(BW_Deptime,1,2)
+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24' ;
check_special_time(my_specialtm,stid,Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'J','1') ;
{if my_date='' then
AQuery.SQL.Text:='update dynarrflt set rtkftm=to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime)))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24,'
+'fstatus='+''''+'COM'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''''
else
AQuery.SQL.Text:='update dynarrflt set rtkftm=to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime
(my_date))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24,'
+'fstatus='+''''+'COM'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+'''';
}
AQuery.SQL.Text:='update dynarrflt set rtkftm='+my_specialtm+','
+'fstatus='+''''+'COM'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+'''';
AQuery.ExecSQL;
///////
com_makeplan(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt);
end
else
begin
//sql_str:='select t.*,t.aid as id from dynarrflt t where t.PLANDATE='''''+Localplandate+''''' and
t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
sql_str:='select t.*,t.aid as id from dynarrflt t where t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim
(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
xs_str:='进港航班'+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+BW_CoFlt+'实际起飞时间更新';
xx_rq:= datetostr(now)+' '+timetostr(now);
if my_date='' then
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime)))+' '+copy
(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24'
else
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+' '+copy(BW_Deptime,1,2)
+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24' ;
stid:='';
check_special_time(my_specialtm,stid,Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'J','1') ;
if stid<>'' then
begin
zx_str:='update dynarrflt set rtkftm='+my_specialtm+','
+'fstatus='+''''+'COM'+''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''' and AID='''+stid+'''';
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add(zx_str) ;
AQuery.ExecSQL;
com_makeplan(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,stid);
end
else
begin
get_sql_insertdate(my_specialtm);
zx_str:='update dynarrflt set rtkftm=to_date('+''''''+my_specialtm+''''''+','+''''''+'yyyy-mm-dd
hh24:mi:ss'+''''''+'),'
+'fstatus='+''''''+'COM'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and AID=';
send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
end;
{if my_date='' then
zx_str:='update dynarrflt set rtkftm=to_date('+''''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime)))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''''+','+''''''+'yyyy-mm-dd hh24:mi'+''''''+')+8/24,'
+'fstatus='+''''''+'COM'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and AID='
else
zx_str:='update dynarrflt set rtkftm=to_date('+''''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+'
'+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''''+','+''''''+'yyyy-mm-dd hh24:mi'+''''''+')+8/24,'
+'fstatus='+''''''+'COM'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and AID=';
send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
}
end;
//AQuery.DataBase.Commit;
//取飞行时间
Add_T:=0;
//if AQuery.RecordCount=1 then
if stid<>'' then
Add_T:=get_my_flytime(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,stid)
else
Add_T:=get_my_flytime(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt);
if Add_T=0 then
begin
if IS_Time_Type(BW_Deptime) and IS_BW_time_Type(BW_Sendtime) then
begin
if my_date='' then
str55:= formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime))) +' '+copy(BW_Deptime,1,2)
+':'+copy(BW_Deptime,3,2)
else
str55:= formatdatetime('yyyy-mm-dd',strtodatetime(my_date)) +' '+copy(BW_Deptime,1,2)+':'+copy
(BW_Deptime,3,2);
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Text:='select flytm from bw_dynflt WHERE FSTATUS='+''''+'AFTN-FPL'+''''
//+' and PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' and AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''''
+' and ARRP='+''''+LocalCity+''''
+' and (sendtime>=((to_date('''+str55+''',''yyyy-mm-dd hh24:mi:ss'')+8/24)-6/24)) '
+'and (sendtime<=((to_date('''+str55+''',''yyyy-mm-dd hh24:mi:ss'')+8/24)-0.75/24))';
AQuery.ExecSQL;
if AQuery.RecordCount<>0 then
begin
Add_T_S:=AQuery.fieldbyname('flytm').asstring;
Add_T:=(strtoint(leftstr(Add_T_S,1))*10+ strtoint(copy(Add_T_S,2,1)))*60+strtoint(copy
(Add_T_S,3,1))*10+ strtoint(copy(Add_T_S,4,1));
end;
end;
end;
if Add_T<>0 then
begin
//预达时间更新
//AQuery.Close;
//AQuery.SQL.Clear;
//sql_str:='select * from dynarrflt where PLANDATE='''+Localplandate+''' and AIRCORP='''+Get_PLN_Aircorp(leftstr
(trim(BW_Flightno),3))+''' and FLTNO='''+BW_CoFlt+'''';
sql_str:='select * from dynarrflt where AIRCORP='''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''' and
FLTNO='''+BW_CoFlt+'''';
AQuery.Close;
AQuery.sql.Clear;
AQuery.SQL.Add(sql_str);
AQuery.Open;
if AQuery.RecordCount<=1 then
begin
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Text:='update dynarrflt set parrtm=rtkftm+'+floattostr(Add_T)+'/60/24'
+',fstatus='+''''+'COM'+''''
+' where '
//+'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+'''';
AQuery.ExecSQL;
end
else
begin
//sql_str:='select t.*,t.aid as id from dynarrflt t where t.PLANDATE='''''+Localplandate+''''' and
t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
sql_str:='select t.*,t.aid as id from dynarrflt t where t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim
(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
xs_str:='进港航班'+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+BW_CoFlt+'预达时间更新';
xx_rq:= datetostr(now)+' '+timetostr(now);
if stid<>'' then
begin
zx_str:='update dynarrflt set parrtm=rtkftm+'+floattostr(Add_T)+'/60/24'
+',fstatus='+''''+'COM'+''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''' and AID='''+stid+'''';
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add(zx_str) ;
AQuery.ExecSQL;
end
else
begin
zx_str:='update dynarrflt set parrtm=rtkftm+'+floattostr(Add_T)+'/60/24'
+',fstatus='+''''''+'COM'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime))+8/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and AID=';
send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
end;
end;
//AQuery.DataBase.Commit;
end;
finally
//AQuery.Close;
//AQuery.Free;
freeandnil(AQuery);
end;
MsgText.Clear;
MsgText.Add('进港航班'+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+BW_CoFlt+'-'+'前方起飞!');
SendMsg(20078,MsgText);
SendMsg(30000,MsgText);
not_found_fpl(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'进港');
result:=result+chr(13)+chr(10)+'航班动态已更新!'
end;
//更新航班动态[出港]
if Get_PLN_Place(BW_depairport)=LocalCity then
begin
AQuery:=TOraQuery.Create(nil);
try
AQuery.Session:=OraSession;
//sql_str:='select * from dyndepflt where PLANDATE='''+Localplandate+''' and AIRCORP='''+Get_PLN_Aircorp(leftstr(trim
(BW_Flightno),3))+''' and FLTNO='''+BW_CoFlt+'''';
sql_str:='select * from dyndepflt where AIRCORP='''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''' and
FLTNO='''+BW_CoFlt+'''';
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add(sql_str);
AQuery.Open;
if AQuery.RecordCount<=1 then
begin
//实际起飞时间更新
AQuery.Close;
AQuery.SQL.Clear;
if my_date='' then
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime)))+' '+copy
(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24'
else
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+' '+copy(BW_Deptime,1,2)
+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24' ;
check_special_time(my_specialtm,stid,Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'C','4') ;
{ if my_date='' then
AQuery.SQL.Text:='update dyndepflt set rtkftm=to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime
(Pek_time(BW_Sendtime)))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24,'
+'fstatus='+''''+'DEP'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''''
else
AQuery.SQL.Text:='update dyndepflt set rtkftm=to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime
(my_date))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24,'
+'fstatus='+''''+'DEP'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+'''';
}
AQuery.SQL.Text:='update dyndepflt set rtkftm='+my_specialtm+','
+'fstatus='+''''+'DEP'+''''
+' where '
// +'PLANDATE='+''''+Localplandate+'''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+'''';
AQuery.ExecSQL;
set_to_history(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'C');
end
else
begin
//sql_str:='select t.*,t.did as id from dyndepflt t where t.PLANDATE='''''+Localplandate+''''' and
t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
sql_str:='select t.*,t.did as id from dyndepflt t where t.AIRCORP='''''+Get_PLN_Aircorp(leftstr(trim
(BW_Flightno),3))+''''' and t.FLTNO='''''+BW_CoFlt+'''''';
xs_str:='出港航班'+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+BW_CoFlt+'实际起飞时间更新';
xx_rq:= datetostr(now)+' '+timetostr(now);
if my_date='' then
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time(BW_Sendtime)))+' '+copy
(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24'
else
my_specialtm:= 'to_date('+''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+' '+copy(BW_Deptime,1,2)
+':'+copy(BW_Deptime,3,2)+''''+','+''''+'yyyy-mm-dd hh24:mi'+''''+')+8/24' ;
stid:='';
check_special_time(my_specialtm,stid,Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'C','4') ;
if stid<>'' then
begin
zx_str:='update dyndepflt set rtkftm='+my_specialtm+','
+'fstatus='+''''+'DEP'+''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''
+' and FLTNO='+''''+BW_CoFlt+''' and DID='''+stid+'''' ;
AQuery.Close;
AQuery.SQL.Clear;
AQuery.SQL.Add(zx_str) ;
AQuery.ExecSQL;
set_to_history(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'C',stid);
end
else
begin
get_sql_insertdate(my_specialtm);
zx_str:='update dyndepflt set rtkftm=to_date('+''''''+my_specialtm+''''''+','+''''''+'yyyy-mm-dd
hh24:mi:ss'+''''''+'),'
+'fstatus='+''''''+'DEP'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and DID=' ;
send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
end;
{ if my_date='' then
zx_str:='update dyndepflt set rtkftm=to_date('+''''''+formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime)))+' '+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''''+','+''''''+'yyyy-mm-dd hh24:mi'+''''''+')+8/24,'
+'fstatus='+''''''+'DEP'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and DID='
else
zx_str:='update dyndepflt set rtkftm=to_date('+''''''+formatdatetime('yyyy-mm-dd',strtodatetime(my_date))+'
'+copy(BW_Deptime,1,2)+':'+copy(BW_Deptime,3,2)+''''''+','+''''''+'yyyy-mm-dd hh24:mi'+''''''+')+8/24,'
+'fstatus='+''''''+'DEP'+''''''
+' where '
// +'PLANDATE='+''''''+Localplandate+'''''' //formatdatetime('yyyy-mm-dd',strtodatetime(Pek_time
(BW_Sendtime))+8/24-LocalDayChange/24)+''''
+' AIRCORP='+''''''+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+''''''
+' and FLTNO='+''''''+BW_CoFlt+''''' and DID=';
send_message_togarims(xs_str,zx_str,sql_str,xx_rq);
}
end;
finally
// AQuery.Close;
//AQuery.Free;
freeandnil(AQuery);
end;
MsgText.Clear;
MsgText.Add('出港航班'+Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3))+BW_CoFlt+'已经起飞!');
SendMsg(20078,MsgText);
SendMsg(30000,MsgText);
not_found_fpl(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt,'出港');
dep_release_port(Get_PLN_Aircorp(leftstr(trim(BW_Flightno),3)),BW_CoFlt);
result:=result+chr(13)+chr(10)+'航班动态已更新!'
end;
ATable:=TOraTable.Create(nil);
try
ATable.Session:=OraSession;
ATable.TableName:='bwxx';
ATable.Open;
// ATable.Edit;
ATable.Append;
ATable.FieldByName('RECADD').AsString:=LocalTelAdd;
ATable.FieldByName('RECCOUNT').AsString:=BW_Recno;
if IS_BW_time_Type(BW_Rectime) then
ATable.FieldByName('RECTIME').AsDateTime:=strtodatetime(Pek_time(BW_Rectime))+8/24;
ATable.FieldByName('TEXGLASS').AsString:=BW_WarnClass;
ATable.FieldByName('RECICAO').AsString:=BW_RecieveAirport;
if IS_BW_time_Type(BW_Sendtime) then
ATable.FieldByName('SENDTIME').AsDateTime:=strtodatetime(Pek_time(BW_Sendtime))+8/24;
ATable.FieldByName('SENDICAO').AsString:=BW_SendAirport;
ATable.FieldByName('TEXTYPE').AsString:='AFTN-DEP';
ATable.FieldByName('TEXRES').AsVariant:=BW_String;
ATable.FieldByName('TexResult').AsVariant:=result;
ATable.FieldByName('TEXSTATUS').AsString:='OK';
ATable.FieldByName('TEXREMARK').AsString:='OK';
ATable.FieldByName('RECNO').AsString:='1';
ATable.Post;
ATable.Close;
finally
//ATable.Free;
freeandnil(ATable);
end;
//MsgText.Free;
freeandnil(MsgText);
end;