unit u_op_seae_qiandan_add; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, XPMenu, Menus, dxDBTLCl, dxGrClms, dxDBCtrl, dxDBGrid, dxTL, dxCntner, DB, ADODB, Mask, wwdbedit, Wwdotdot, Wwdbcomb, wwdblook, RxLookup, wwdbdatetimepicker, StdCtrls, bsSkinCtrls, ExtCtrls, ComCtrls, bsSkinTabs, DBCtrls, kbmMemTable,IdHTTP; type Tfrm_op_seae_qiandan_add = class(TForm) Panel2: TPanel; Panel3: TPanel; bsSkinButton10: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinPanel1: TbsSkinPanel; Label1: TLabel; Label10: TLabel; Label5: TLabel; Label9: TLabel; Label30: TLabel; Label125: TLabel; Label16: TLabel; Edit2: TEdit; wwDBDateTimePicker1: TwwDBDateTimePicker; wwDBDateTimePicker2: TwwDBDateTimePicker; RxDBLookupCombo2: TRxDBLookupCombo; Edit7: TEdit; wwDBLookupCombo49: TwwDBLookupCombo; RxDBLookupCombo6: TRxDBLookupCombo; t_op_seae: TADOQuery; t_op_seae1: TDataSource; dxDBGrid1: TdxDBGrid; XPMenu1: TXPMenu; PopupMenu3: TPopupMenu; MenuItem2: TMenuItem; kbmcl: TkbmMemTable; kbmclField: TStringField; kbmclField2: TStringField; kbmclField3: TStringField; kbmclField4: TStringField; kbmclField5: TIntegerField; kbmclField6: TIntegerField; kbmclField7: TIntegerField; kbmclField8: TStringField; kbmclField9: TStringField; kbmclField10: TStringField; kbmclField11: TStringField; dxDBGrid1Column1: TdxDBGridColumn; dxDBGrid1Column2: TdxDBGridColumn; dxDBGrid1Column3: TdxDBGridColumn; dxDBGrid1Column4: TdxDBGridColumn; dxDBGrid1Column5: TdxDBGridColumn; dxDBGrid1Column6: TdxDBGridColumn; dxDBGrid1Column7: TdxDBGridColumn; dxDBGrid1Column8: TdxDBGridColumn; dxDBGrid1Column9: TdxDBGridColumn; dxDBGrid1Column10: TdxDBGridColumn; dxDBGrid1Column11: TdxDBGridColumn; t_op_seae_ctn: TADOQuery; dxDBGrid1Column12: TdxDBGridColumn; kbmclStringField: TStringField; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure MenuItem2Click(Sender: TObject); private { Private declarations } public { Public declarations } ctn_sum,ctn_1,ctn_2:integer; ydzt,fxzt:string; procedure getczwebmsg_1(mblno:string); procedure analyzeListData_1(mblno:string;aList:TStringlist); procedure analyzeData_1(mblno,s:string); procedure getwebmsg_1(bsno,mblno,fmblno:string); procedure getwebmsg_new_1(bsno,mblno,fmblno:string); procedure getqqctuydfx_1(bsno,mblno,fmblno:string);//qqctu获取运抵报告和报关信息 end; var frm_op_seae_qiandan_add: Tfrm_op_seae_qiandan_add; implementation uses my_sys_function, u_main, my_sys_chat,u_sys_progress; {$R *.dfm} procedure Tfrm_op_seae_qiandan_add.getwebmsg_1(bsno,mblno,fmblno:string); var aQuery,aQuery2:TAdoQuery; sl,slcz:tstringlist; IdHTTP1:TidHTTP; i,j,k,m:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..10] of string[50]; begin sl:=tstringlist.Create; slcz:=tstringlist.Create; aQuery:=createAdoQuery; aQuery2:=createAdoQuery; IdHTTP1 := TidHTTP.Create(nil); IdHTTP1.HandleRedirects:=true; QQCT:=false; istrue:=false; try inmsg:=false; sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqct/dpcx/ydbg.jsp?tdh='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('  海关运抵报告信息',sl[i])>0 then j:=i; if pos('',sl[i])>0 then begin { aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关运抵报告信息'' and 编号='''+bsno+''''; aQuery.open; if aQuery.IsEmpty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_ydbg where 编号='''+bsno+''''; aQuery2.open; } end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; end; if istrue and (i=j) then begin sldata[1]:=twsou('','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=copy(sl[i],length(sl[i])-19,11); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('','',sl[i]); end; if istrue and (i=j+9) then begin QQCT:=true; if inmsg then begin { aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关运抵报告信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; } inmsg:=false; end; sldata[10]:=twsou('','',sl[i]); if trim(sldata[5])<>'' then ydzt:='是'; { if not aQuery2.Locate('箱号',trim(sldata[5]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('船名').AsString:=sldata[1]; aQuery2.FieldByName('航次').AsString:=sldata[2]; aQuery2.FieldByName('主单号').AsString:=sldata[3]; aQuery2.FieldByName('分单号').AsString:=sldata[4]; aQuery2.FieldByName('箱号').AsString:=sldata[5]; aQuery2.FieldByName('进港时间').AsString:=sldata[6]; aQuery2.FieldByName('发送时间').AsString:=sldata[7]; aQuery2.FieldByName('回执时间').AsString:=sldata[8]; aQuery2.FieldByName('回执状态').AsString:=sldata[9]; aQuery2.FieldByName('回执信息').AsString:=sldata[10]; aQuery2.FieldByName('类型').AsString:='QQCT'; aQuery2.post; end; } end; end; istrue:=false; inmsg:=false; sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqct/dpcx/hgfx.jsp?val='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('海关放行信息',sl[i])>0 then j:=i; if pos('',sl[i])>0 then begin { aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关放行信息'' and 编号='''+bsno+''''; aQuery.open; if aQuery.isempty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_bg where 编号='''+bsno+''''; aQuery2.open; } end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; end; if istrue and (i=j) then begin sldata[1]:=twsou('','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('','',sl[i]); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('','',sl[i]); end; if istrue and (i=j+9) then begin if inmsg then begin { aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关放行信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; } inmsg:=false; end; sldata[10]:=twsou('','',sl[i]); QQCT:=true; if trim(sldata[9])<>'' then fxzt:=sldata[9]; { if not aQuery2.Locate('报关单号',trim(sldata[1]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('报关单号').AsString:=sldata[1]; aQuery2.FieldByName('放行时间').AsString:=sldata[2]; aQuery2.FieldByName('放行件数').Asinteger:=strtointdef(sldata[3],0); aQuery2.FieldByName('船名').AsString:=sldata[4]; aQuery2.FieldByName('航次').AsString:=sldata[5]; aQuery2.FieldByName('提单号').AsString:=sldata[6]; aQuery2.FieldByName('净重').Asfloat:=strtofloatdef(sldata[7],0); aQuery2.FieldByName('毛重').Asfloat:=strtofloatdef(sldata[8],0); aQuery2.FieldByName('海关状态').AsString:=sldata[9]; aQuery2.FieldByName('导入时间').AsString:=sldata[10]; aQuery2.FieldByName('类型').AsString:='QQCT'; aQuery2.post; end; } end; end; istrue:=false; inmsg:=false; if not QQCT then begin sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqctu/customs_arrschema.jsp?tdh='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('  海关运抵报告信息',sl[i])>0 then j:=i; if pos('',sl[i])>0 then begin aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关运抵报告信息'' and 编号='''+bsno+''''; aQuery.open; if aqUery.IsEmpty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_ydbg where 编号='''+bsno+''''; aQuery2.open; end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; end; if istrue and (i=j) then begin sldata[1]:=twsou('','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('','',sl[i]); // sldata[5]:=copy(sl[i],length(sl[i])-19,11); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('','',sl[i]); end; if istrue and (i=j+9) then begin if inmsg then begin { aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关运抵报告信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; } inmsg:=false; end; sldata[10]:=twsou('','',sl[i]); if trim(sldata[5])<>'' then ydzt:='是'; { if not aQuery2.Locate('箱号',trim(sldata[6]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('船名').AsString:=sldata[2]; // aQuery2.FieldByName('航次').AsString:=sldata[3]; aQuery2.FieldByName('主单号').AsString:=sldata[4]; aQuery2.FieldByName('分单号').AsString:=sldata[5]; aQuery2.FieldByName('箱号').AsString:=sldata[6]; aQuery2.FieldByName('进港时间').AsString:=sldata[7]; aQuery2.FieldByName('发送时间').AsString:=sldata[8]; aQuery2.FieldByName('回执时间').AsString:=sldata[9]; aQuery2.FieldByName('回执状态').AsString:=sldata[10]; // aQuery2.FieldByName('回执信息').AsString:=sldata[11]; aQuery2.FieldByName('类型').AsString:='QQCTU'; aQuery2.post; end; } end; end; istrue:=false; inmsg:=false; sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqctu/customs_release.jsp?val='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('  海关放行信息',sl[i])>0 then j:=i; if pos('',sl[i])>0 then begin { aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关放行信息'' and 编号='''+bsno+''''; aQuery.open; if aquery.IsEmpty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_bg where 编号='''+bsno+''''; aQuery2.open; } end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; end; if istrue and (i=j) then begin sldata[1]:=twsou('','',sl[i]); end; if istrue and (i=j+1) then begin sldata[2]:=twsou('','',sl[i]); end; if istrue and (i=j+2) then begin sldata[3]:=twsou('','',sl[i]); end; if istrue and (i=j+3) then begin sldata[4]:=twsou('','',sl[i]); end; if istrue and (i=j+4) then begin sldata[5]:=twsou('','',sl[i]); end; if istrue and (i=j+5) then begin sldata[6]:=twsou('','',sl[i]); end; if istrue and (i=j+6) then begin sldata[7]:=twsou('','',sl[i]); end; if istrue and (i=j+7) then begin sldata[8]:=twsou('','',sl[i]); end; if istrue and (i=j+8) then begin sldata[9]:=twsou('','',sl[i]); end; if istrue and (i=j+9) then begin sldata[10]:=twsou('','',sl[i]); if inmsg then begin { aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关放行信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; } inmsg:=false; end; if trim(sldata[9])<>'' then fxzt:=sldata[9]; { if not aQuery2.Locate('报关单号',trim(sldata[1]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('报关单号').AsString:=sldata[1]; aQuery2.FieldByName('放行时间').AsString:=sldata[2]; aQuery2.FieldByName('放行件数').Asinteger:=strtointdef(sldata[3],0); aQuery2.FieldByName('船名').AsString:=sldata[4]; aQuery2.FieldByName('航次').AsString:=sldata[5]; aQuery2.FieldByName('提单号').AsString:=sldata[6]; aQuery2.FieldByName('净重').Asfloat:=strtofloatdef(sldata[7],0); aQuery2.FieldByName('毛重').Asfloat:=strtofloatdef(sldata[8],0); aQuery2.FieldByName('海关状态').AsString:=sldata[9]; aQuery2.FieldByName('导入时间').AsString:=sldata[10]; aQuery2.FieldByName('类型').AsString:='QQCTU'; aQuery2.post; end; } end; end; end; finally freeandnil(aQuery); freeandnil(sl); freeandnil(slcz); end; end; procedure Tfrm_op_seae_qiandan_add.getwebmsg_new_1(bsno,mblno,fmblno:string); var aQuery,aQuery2:TAdoQuery; sl:tstringlist; IdHTTP1:TidHTTP; i,j,k,m,n:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..13] of string[50]; begin sl:=tstringlist.Create; aQuery:=createAdoQuery; aQuery2:=createAdoQuery; IdHTTP1 := TidHTTP.Create(nil); IdHTTP1.HandleRedirects:=true; QQCT:=false; istrue:=false; for i:=1 to 13 do begin sldata[i]:=''; end; n:=0; try istrue:=false; inmsg:=false; sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqct/dpcx/cargoDya.jsp?tdh='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('海关放行信息',sl[i])>0 then begin { aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关放行信息'' and 编号='''+bsno+''''; aQuery.open; if aQuery.isempty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_bg where 编号='''+bsno+''''; aQuery2.open; } j:=i; n:=i; end; if (i>=n) and (n<>0) then begin if pos('',sl[i])>0 then begin end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; Exit; end; // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sl[i]); if istrue and (i=j+1) then begin sldata[1]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[1]); end; if istrue and (i=j+1+1) then begin sldata[2]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[2]); end; if istrue and (i=j+2+1) then begin sldata[3]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[3]); end; if istrue and (i=j+3+1) then begin sldata[4]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[4]); end; if istrue and (i=j+4+1) then begin sldata[5]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[5]); end; if istrue and (i=j+5+1) then begin sldata[6]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[6]); end; if istrue and (i=j+6+1) then begin sldata[7]:=twsou('',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[7]); end; if istrue and (i=j+7+1) then begin sldata[8]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[8]); end; if istrue and (i=j+8+1) then begin sldata[9]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[9]); end; if istrue and (i=j+9+1) then begin sldata[10]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[10]); end; if istrue and (i=j+10+1) then begin sldata[11]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[11]); end; if istrue and (i=j+11+1) then begin sldata[12]:=twsou('','',sl[i]); if inmsg then begin { aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关放行信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; } inmsg:=false; end; if trim(sldata[11])<>'' then fxzt:=sldata[11]; { if not aQuery2.Locate('报关单号',trim(sldata[2]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('报关单号').AsString:=sldata[2]; aQuery2.FieldByName('放行时间').AsString:=sldata[3]; aQuery2.FieldByName('放行件数').Asinteger:=strtointdef(sldata[4],0); aQuery2.FieldByName('船名').AsString:=sldata[5]; aQuery2.FieldByName('航次').AsString:=sldata[6]; aQuery2.FieldByName('提单号').AsString:=Copy(sldata[7],2,30); // aQuery2.FieldByName('箱号').AsString:=sldata[8]; aQuery2.FieldByName('净重').Asfloat:=strtofloatdef(sldata[9],0); aQuery2.FieldByName('毛重').Asfloat:=strtofloatdef(sldata[10],0); aQuery2.FieldByName('海关状态').AsString:=sldata[11]; // aQuery2.FieldByName('关区').AsString:=sldata[12]; aQuery2.FieldByName('导入时间').AsString:=FormatDateTime('YYYY-MM-DD',date); aQuery2.FieldByName('类型').AsString:='QQCT'; aQuery2.post; end; } end; end; end; finally freeandnil(aQuery); freeandnil(sl); end; end; procedure Tfrm_op_seae_qiandan_add.getqqctuydfx_1(bsno,mblno,fmblno:string);//qqctu获取运抵报告和报关信息 var aQuery,aQuery2:TAdoQuery; sl:tstringlist; IdHTTP1:TidHTTP; i,j,k,m,n:integer; istrue,QQCT,inmsg:boolean; sldata:Array [1..13] of string[50]; begin sl:=tstringlist.Create; aQuery:=createAdoQuery; aQuery2:=createAdoQuery; IdHTTP1 := TidHTTP.Create(nil); IdHTTP1.HandleRedirects:=true; QQCT:=false; istrue:=false; for i:=1 to 13 do begin sldata[i]:=''; end; n:=0; try istrue:=false; inmsg:=false; sl.text:=idhttp1.get('http://www.qingdaoport.net/ywzx/qqctu/bill_query.jsp?tdh='+mblno); j:=0; for i:=0 to sl.Count-1 do begin if pos('海关放行信息',sl[i])>0 then begin { aQuery.close; aQuery.SQL.Text:='select * from t_op_msg where 消息名称=''海关放行信息'' and 编号='''+bsno+''''; aQuery.open; if aQuery.isempty then inmsg:=true; aQuery2.close; aQuery2.SQL.Text:='select * from t_op_msg_bg where 编号='''+bsno+''''; aQuery2.open; } j:=i; n:=i; end; if (i>=n) and (n<>0) then begin if pos('',sl[i])>0 then begin end; if pos('',sl[i])>0 then begin istrue:=true; j:=i; end; if pos('',sl[i])>0 then begin istrue:=false; Exit; end; // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sl[i]); if istrue and (i=j+1) then begin sldata[1]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[1]); end; if istrue and (i=j+1+1) then begin sldata[2]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[2]); end; if istrue and (i=j+2+1) then begin sldata[3]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[3]); end; if istrue and (i=j+3+1) then begin sldata[4]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[4]); end; if istrue and (i=j+4+1) then begin sldata[5]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[5]); end; if istrue and (i=j+5+1) then begin sldata[6]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[6]); end; if istrue and (i=j+6+1) then begin sldata[7]:=twsou('',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[7]); end; if istrue and (i=j+7+1) then begin sldata[8]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[8]); end; if istrue and (i=j+8+1) then begin sldata[9]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[9]); end; if istrue and (i=j+9+1) then begin sldata[10]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[10]); end; if istrue and (i=j+10+1) then begin sldata[11]:=twsou('','',sl[i]); // Memo1.Lines.Add(IntToStr(i)+'='+IntToStr(j)+' Data '+sldata[11]); end; if istrue and (i=j+11+1) then begin if trim(sldata[11])<>'' then fxzt:=sldata[11]; sldata[12]:=twsou('','',sl[i]); { if inmsg then begin aQuery.close; aQuery.SQL.Text:='insert into t_op_msg (编号,业务类型,消息名称,完成时间) ' +'Values ('''+bsno+''',''海运出口'',''海关放行信息'','''+FormatDateTime('YYYY-MM-DD hh:mm:ss',now)+''')'; aQuery.ExecSQL; inmsg:=false; end; if not aQuery2.Locate('报关单号',trim(sldata[2]),[]) then begin aQuery2.Insert; aQuery2.fieldbyname('编号').AsString:=bsno; aQuery2.FieldByName('报关单号').AsString:=sldata[2]; aQuery2.FieldByName('放行时间').AsString:=sldata[3]; aQuery2.FieldByName('放行件数').Asinteger:=strtointdef(sldata[4],0); aQuery2.FieldByName('船名').AsString:=sldata[5]; aQuery2.FieldByName('航次').AsString:=sldata[6]; aQuery2.FieldByName('提单号').AsString:=Copy(sldata[7],2,30); // aQuery2.FieldByName('箱号').AsString:=sldata[8]; aQuery2.FieldByName('净重').Asfloat:=strtofloatdef(sldata[9],0); aQuery2.FieldByName('毛重').Asfloat:=strtofloatdef(sldata[10],0); aQuery2.FieldByName('海关状态').AsString:=sldata[11]; // aQuery2.FieldByName('关区').AsString:=sldata[12]; aQuery2.FieldByName('导入时间').AsString:=FormatDateTime('YYYY-MM-DD',date); aQuery2.FieldByName('类型').AsString:='QQCTU'; aQuery2.post; end; } end; end; end; finally freeandnil(aQuery); freeandnil(sl); end; end; procedure Tfrm_op_seae_qiandan_add.analyzeData_1(mblno,s:string); var i:Integer; s1:string; aList,aListData:TStringlist; begin aList:=TStringlist.Create; aListData:=TStringlist.Create; aList.Clear; aListData.Clear; try while Length(s)>0 do begin s1:=Copy(s,1,Pos('',s)+4); s:=Copy(s,Pos('',s)+5,Length(s)-1); aList.Add(s1); end; // aList.SaveToFile('c:\1.txt'); // ShowMessage(IntToStr(aList.Count)); for i:=0 to aList.Count-1 do begin aListData.Add(twsou('','',aList[i])); end; if aListData.Count<=4 then Exit; if Trim(aListData[5])<>'' then ctn_1:=ctn_1+1; if Trim(aListData[6])<>'' then ctn_2:=ctn_2+1; // ShowMessage(Trim(aListData[5])+Trim(aListData[6])); finally aList.Free; aListData.Free; end; end; procedure Tfrm_op_seae_qiandan_add.analyzeListData_1(mblno:string;aList:TStringlist); var i,k,c:Integer; begin try k:=0; for i:=0 to aList.Count-1 do begin analyzeData_1(mblno,Trim(aList[k])); k:=k+2; if aList.Count>0 then if k>aList.Count-2 then Exit; end; finally // Updateopctn(mblno); end; end; procedure Tfrm_op_seae_qiandan_add.getczwebmsg_1(mblno:string); var sl,slcz:tstringlist; IdHTTP1:TidHTTP; i,k,m:integer; begin sl:=tstringlist.Create; slcz:=tstringlist.Create; IdHTTP1 := TidHTTP.Create(nil); IdHTTP1.HandleRedirects:=true; try slcz.Clear; sl.Clear; sl.text:=idhttp1.get('http://www.sdsmart.cn/Query/YD_BLQueryGrid.aspx?blno='+mblno); k:=0; for i:=0 to sl.Count-1 do begin sl[i]:=Utf8ToAnsi(sl[i]); if pos('箱货动态 ',sl[i])>0 then begin k:=i; end; if (k>1) and (i>k+5) then begin slcz.Add(sl[i]); end; if (k>1) and (i>k+5) then if pos('',sl[i])>0 then begin if slcz.Count>0 then begin analyzeListData_1(mblno,slcz); end; Exit; end; end; // if slcz.Count>4 then finally freeandnil(sl); freeandnil(slcz); IdHTTP1.HandleRedirects:=False; IdHTTP1.Free; end; end; procedure Tfrm_op_seae_qiandan_add.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_op_seae_qiandan_add.Hide; frm_op_seae_qiandan_add.ManualFloat(frm_op_seae_qiandan_add.BoundsRect ); frm_main.freeTabs('frm_op_seae_qiandan_add'); action:=cafree; frm_op_seae_qiandan_add:=nil; end; procedure Tfrm_op_seae_qiandan_add.bsSkinButton10Click(Sender: TObject); var str:widestring; begin str:='where 业务类型=''普通货'' and 主提单号<>'''''; if Edit2.text<>''then str:=str+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; if wwDBDateTimePicker1.text<>''then str:=str+' and 开船日期>='+''''+wwDBDateTimePicker1.text+''''; if wwDBDateTimePicker2.text<>''then str:=str+' and 开船日期<='+''''+wwDBDateTimePicker2.text+''''; if RxDBLookupCombo2.DisplayValues[1]<>''then str:=str+' and 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; if wwDBLookupCombo49.text<>''then str:=str+' and 船名 like '+''''+'%'+wwDBLookupCombo49.text+'%'+''''; if Edit7.text<>''then str:=str+' and 航次 like '+''''+'%'+Edit7.text+'%'+''''; if trim(str)='' then begin str:='where '+open_data('0001','t_op_seae.录入人', 't_op_seae.操作员','t_op_seae.客服员','t_op_seae.报关操作','t_op_seae.报检操作'); end else begin str:=str+' and '+open_data('0001','t_op_seae.录入人', 't_op_seae.操作员','t_op_seae.客服员','t_op_seae.报关操作','t_op_seae.报检操作'); end; t_op_seae.close; t_op_seae.sql.clear; t_op_seae.sql.add('select * from t_op_seae '+str+default_sort(53,'t_op_seae','','desc')); t_op_seae_ctn.close; t_op_seae_ctn.sql.clear; t_op_seae_ctn.sql.add('select sum(数量) c from t_op_ctn where 编号=:编号'); kbmcl.EmptyTable; kbmcl.Open; kbmcl.DisableControls; t_op_seae.Open; if not ASSIGNED(frm_sys_progress) then frm_sys_progress:=tfrm_sys_progress.Create(application); frm_sys_progress.bsSkinGauge1.ProgressText:='正在处理数据请等候。。。'; frm_sys_progress.Show; frm_sys_progress.bsSkinGauge1.MaxValue:=t_op_seae.RecordCount; frm_sys_progress.bsSkinGauge1.MinValue:=0; frm_sys_progress.bsSkinGauge1.Value:=0; try with t_op_seae do begin First; while not eof do begin kbmcl.Insert; kbmcl.FieldByName('委托人').Value:=FieldByName('委托单位').Value; kbmcl.FieldByName('船名').Value:=FieldByName('船名').Value; kbmcl.FieldByName('航次').Value:=FieldByName('航次').Value; kbmcl.FieldByName('开船日期').Value:=FieldByName('开船日期').Value; kbmcl.FieldByName('主提单号').Value:=FieldByName('主提单号').Value; frm_sys_progress.bsSkinGauge1.ProgressText:='提单号:'+FieldByName('主提单号').AsString; frm_sys_progress.bsSkinGauge1.Value:=frm_sys_progress.bsSkinGauge1.Value+1; // frm_op_seae_qiandan_add.Caption:='业务进度表:'+FieldByName('主提单号').Value; ctn_sum:=0; ctn_1:=0; ctn_2:=0; ydzt:='否'; fxzt:='否'; getczwebmsg_1(Trim(fieldbyname('主提单号').AsString)); t_op_seae_ctn.Close; t_op_seae_ctn.Parameters.ParamByName('编号').Value:=FieldByName('编号').Value; t_op_seae_ctn.Open; kbmcl.FieldByName('箱量').Value:=t_op_seae_ctn.FieldByName('c').AsInteger; kbmcl.FieldByName('提箱数量').Value:=ctn_1; kbmcl.FieldByName('返场数量').Value:=ctn_2; getwebmsg('',fieldbyname('主提单号').AsString,''); getwebmsg_new('',fieldbyname('主提单号').AsString,''); getqqctuydfx('',fieldbyname('主提单号').AsString,''); if not FieldByName('截单日期').IsNull then kbmcl.FieldByName('截单时间').Value:=FormatDateTime('YYYY-MM-DD hh:mm',FieldByName('截单日期').Value); if not FieldByName('截港日期').IsNull then kbmcl.FieldByName('截港时间').Value:=FormatDateTime('YYYY-MM-DD hh:mm',FieldByName('截港日期').Value); kbmcl.FieldByName('运抵报告').Value:=ydzt; kbmcl.FieldByName('通关状态').Value:=fxzt; kbmcl.post; Next; end; end; kbmcl.EnableControls; finally frm_sys_progress.Close; frm_sys_progress.Free; frm_sys_progress:=nil; end; end; procedure Tfrm_op_seae_qiandan_add.bsSkinButton6Click(Sender: TObject); begin { Edit2.text:=''; wwDBDateTimePicker1.text:=''; wwDBDateTimePicker2.text:=''; RxDBLookupCombo2.ClearValue; wwDBLookupCombo49.text:=''; Edit7.text:=''; RxDBLookupCombo6.ClearValue; } Close; end; procedure Tfrm_op_seae_qiandan_add.MenuItem2Click(Sender: TObject); begin grid_save_xls(dxDBGrid1); end; end.