unit u_op_seae_edi_one; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon, Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,IdGlobal, FtpCli, IdExplicitTLSClientServerBase; type Tfrm_op_seae_edi_one = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; Label2: TLabel; Edit2: TEdit; Edit1: TEdit; Label1: TLabel; SaveDialog1: TSaveDialog; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; t_op_ctn: TADOQuery; t_op_ctn1: TDataSource; bsSkinRadioGroup1: TbsSkinRadioGroup; Label3: TLabel; Edit3: TEdit; bsSkinGroupBox1: TbsSkinGroupBox; bsSkinButton4: TbsSkinButton; Label4: TLabel; Edit4: TEdit; Edit5: TEdit; Label5: TLabel; Label6: TLabel; Edit6: TEdit; Label7: TLabel; Edit7: TEdit; bsSkinCheckRadioBox1: TbsSkinCheckRadioBox; bsSkinCheckRadioBox2: TbsSkinCheckRadioBox; FtpClient1: TFtpClient; bsSkinButton5: TbsSkinButton; IdFTP1: TIdFTP; CheckBox1: TCheckBox; bsSkinButton6: TbsSkinButton; bsSkinButton7: TbsSkinButton; Label8: TLabel; Edit8: TEdit; Edit9: TEdit; Label9: TLabel; Label10: TLabel; Edit10: TEdit; bsSkinButton8: TbsSkinButton; procedure bsSkinButton2Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure bsSkinButton4Click(Sender: TObject); procedure FtpClient1Error(Sender: TObject; var Msg: String); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); private function isEditrue(DataSet:TDataSet): boolean; function GetStrNum(str:String):integer; function FormatListString(Old:TStrings;mCount,Strlength:integer):String; function FormatEdiString(old:String;Strlength:integer=0):String; function CreateEdiFile:TStrings; function CreateZHUEdiFile:TStrings; function GetCntrEdi(cntrsize: String):String; function GetpkgsEdi(pkgs:String):String; function GetlineEdi(aline:String):String; procedure GetLengthTString(var sl: TStringList; l: integer); function GetLengthword(var s: String; l: Integer;str:String): String; function GetcustEdi(cust: String): String; function GetvesselEdi(avessel: String): String; function GetTransPortEdi(port:string):string; function GetCTN(BusinessID:string):TStringList; function IsHasCtn(BusinessID:string):Boolean; function cutpkgs(kindpkg:string):string; function cutmblno(mblno:string):string; { Private declarations } public { Public declarations } function GetShipEdiNO(Ship:String): String; function CreateVgmEdiFile:TStrings; function CreateSIEdiFile_MBL:string; end; var frm_op_seae_edi_one: Tfrm_op_seae_edi_one; implementation uses u_op_seae, u_main, my_sys_function, u_data_share, u_op_seae_assistant; {$R *.dfm} function Tfrm_op_seae_edi_one.IsHasCtn(BusinessID:string):Boolean; var aQuery:TADOQuery; begin Result:=False; aQuery:=CreateAdoQuery; with aQuery do begin Close; SQL.Clear; SQL.Add('select Row_Number()over(order by ctn_id) as 序号,* from t_op_ctn_detail where ctn_id in (' +'select ctn_id from t_op_ctn where 编号='+QuotedStr(BusinessID)+')'); Open; end; if aQuery.RecordCount>0 then Result:=True; FreeAndNil(aQuery); end; function Tfrm_op_seae_edi_one.GetTransPortEdi(port:string):string; var aQuery:TADOQuery; begin Result:=''; aQuery:=CreateAdoQuery; with aQuery do begin Close; SQL.Clear; SQL.Add('select a.二程港口,b.EDI代码 from t_op_seae a left join ' +' (SELECT EDI代码,英文名,国家,省份,中文名,航线,港口全名,港口代码 FROM t_code_disport) b ' +' on a.二程港口=b.英文名 where a.二程港口='+QuotedStr(port) ); Open; end; Result:=aQuery.fieldbyname('EDI代码').AsString; FreeAndNil(aQuery); end; function Tfrm_op_seae_edi_one.GetShipEdiNO(Ship:String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 代码,EDI代码,客户简称,客户全称,揽货人,录入人,录入日期 from t_crm_client'); SQL.Add('where 客户性质<>''目标'' and 船公司=1 and 客户简称='''+Ship+''''); SQL.Add('order by 代码'); Open; if not IsEmpty then Result:=Trim(FieldByName('EDI代码').asstring) else Result:=''; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_one.GetvesselEdi(avessel: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select 船舶呼号 from t_code_vessel where 英文船名='''+avessel+''''); Open; if IsEmpty then Result:='a' else Result:=FieldByName('船舶呼号').AsString; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_one.GetLengthTString(var sl: TStringList; l: integer); var i:integer; str_head,S:String; Stemp:TStrings; begin Stemp:=TStringList.Create; try str_head:=''; S:=''; for i:=0 to sl.Count-1 do begin if sl[i]<>'' then stemp.add(GetLengthword(str_head,l,s+sl[i])); S:=Str_head; end; while S<>'' do begin stemp.add(GetLengthword(str_head,l,s)); S:=Str_head; end; SL.Assign(Stemp); finally FreeAndNil(Stemp); end; end; function Tfrm_op_seae_edi_one.GetLengthword(var s: String; l: Integer;str:String): String; var i:Integer; b:Boolean; begin s:=''; if Length(str)'') and (Trim(old.Strings[i])<>#10) then NewStrs.Add(old.Strings[i]); end else begin mStr:=old.Strings[i]; while length(mStr)>Strlength do begin newStrs.Add(copy(mStr,1,Strlength)); system.Delete(mStr,1,Strlength); end; newStrs.Add(mStr); end; end; try for i:=0 to mCount-1 do begin if i0 then begin aQuery.First; while not aQuery.Eof do begin with bQuery do begin Close; SQL.Clear; SQL.Add('select * from t_op_ctn where ctn_id ='+QuotedStr(aQuery.FieldByName('ctn_id').AsString)); Open; end; Result.Add ('41' +':'+Trim(aQuery.FieldByName('序号').AsString) //2 序号 // 2 +':'+Trim(aQuery.FieldByName('HTS').AsString) // 3 货物标识 S/R/D/O +':'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring) // 4 货物标识 S/R/D/O +':'+Trim(aQuery.FieldByName('件数').AsString) // 5 +':'+trim(GetpkgsEdi(aQuery.FieldByName('包装').AsString)) // 6 +':'+cutpkgs(trim(aQuery.FieldByName('包装').AsString)) // 7 +':'+trim(frm_op_seae.t_op_seae.fieldbyname('总价').asstring) //第一层包装说明 8 +':'+trim(aQuery.FieldByName('尺码').asstring) //第一层包装说明 9 +':' // 10 +':' // 11 +':' // 12 +':' // 13 +':' // 14 +':'+trim(aQuery.FieldByName('重量').asstring) // 15 +':' // 16 +':' // 17 +':' // 第一层包装尺码 // 18 +#39); if bsSkinCheckRadioBox1.Checked then begin Result.Add ('42' +':'+Trim(bQuery.FieldByName('箱号').AsString) //2 序号 // 2 +':'+Trim(Trim(GetCntrEdi(bQuery.fieldbyname('代码').asstring))) // 3 货物标识 S/R/D/O +':'+trim(bQuery.fieldbyname('封号').asstring) // 4 货物标识 S/R/D/O +':'+Trim(aQuery.FieldByName('件数').AsString) // 5 +':'+Trim(aQuery.FieldByName('重量').AsString) // 5 +':' // 7 +':'+trim(aQuery.FieldByName('尺码').asstring) //第一层包装说明 9 +#39); end; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN Result.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN Result.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; if not bsSkinCheckRadioBox2.Checked then begin if (Trim(bQuery.FieldByName('唛头').AsString )='') or (bQuery.RecordCount=0) then Tempstr.Text:=frm_op_seae.t_op_seae.fieldbyname('唛头').AsString else Tempstr.Text:= bQuery.FieldByName('唛头').AsString; GetLengthTString(Tempstr,35); str.text:=''; for L:=0 to Tempstr.Count-1 do begin if Trim(Tempstr.Strings[L])<>'' then str.Add(Tempstr.Strings[L]); end; M:=1; for L:=0 to str.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+FormatEdiString(str.Strings[L],0)+':'; end else begin if M=10 then s:=s+FormatEdiString(str.Strings[L],0) else s:=s+FormatEdiString(str.Strings[L],0)+':'; end; end else begin S:=S+''''; Result.Add(S); M:=1; s:='44:'+FormatEdiString(str.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Result.Add(S); if (Trim(aQuery.FieldByName('货物描述').AsString )='') then Tempstr.Text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString else Tempstr.Text:=aQuery.FieldByName('货物描述').AsString; GetLengthTString(Tempstr,70); str.text:=''; for L:=0 to Tempstr.Count-1 do begin if Trim(Tempstr.Strings[L])<>'' then str.Add(Tempstr.Strings[L]); end; M:=1; for L:=0 to str.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(str.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(str.Strings[L],0) else s:=s+FormatEdiString(str.Strings[L],0)+':'; end; end else begin S:=S+''''; Result.Add(S); M:=1; s:='47:'+FormatEdiString(str.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Result.Add(S); end; aQuery.Next; end; end; FreeAndNil(aQuery); FreeAndNil(bQuery); end; procedure Tfrm_op_seae_edi_one.bsSkinButton1Click(Sender: TObject); var Str:TStrings; inifile1:Tinifile; i:integer; SenderCode,ReciverCode,strType:String; begin if bsSkinCheckRadioBox2.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面选择分单发送分单Edi'); exit; end end; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if not isEditrue(frm_op_seae.t_op_seae) then exit; end; end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; end; str:=Tstringlist.Create; try SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; if bsSkinCheckRadioBox1.Checked then str.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39) else str.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then Str.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then Str.addstrings(CreateZHUEdiFile) else begin Exit; end; end; end else begin if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then Str.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then Str.AddStrings(CreateZHUEdiFile) else begin Exit; end; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); for i:=0 to Str.Count-1 do begin if IsZhongwen(Str[i])<>'' then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str); end; close; end; function Tfrm_op_seae_edi_one.isEditrue(DataSet:TDataSet): boolean; var cntrs:String; begin result:=true; if not bsSkinCheckRadioBox2.Checked then begin if trim(DataSet.fieldbyname('主提单号').asstring)='' then begin result:=false; MessageDlg('提单号不能为空',mtWarning,[mbOk],0); exit; end; end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring)='' then begin result:=false; MessageDlg('提单号不能为空',mtWarning,[mbOk],0); exit; end; end; if trim(DataSet.fieldbyname('付费方式').asstring)='' then begin result:=false; MessageDlg('付费方式不能为空',mtWarning,[mbOk],0); exit; end; { if trim(DataSet.fieldbyname('船名').asstring)='' then begin result:=false; MessageDlg('船名不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('航次').asstring)='' then begin result:=false; MessageDlg('航次不能为空',mtWarning,[mbOk],0); exit; end; } if trim(DataSet.fieldbyname('装港代码').asstring)='' then begin result:=false; MessageDlg('装港代码不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('装货港').asstring)='' then begin result:=false; MessageDlg('装货港不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('总价').asstring)='' then begin result:=false; MessageDlg('第一层包装皮重不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('开船日期').asstring)='' then begin result:=false; MessageDlg('开船日期不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('交货代码').asstring)='' then begin result:=false; MessageDlg('交货代码不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('卸货代码').asstring)='' then begin result:=false; MessageDlg('卸货代码不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('交货地点').asstring)='' then begin result:=false; MessageDlg('交货地点不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('目的地').asstring)='' then begin result:=false; MessageDlg('目的地不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('船名').asstring)<>'' then begin if (GetvesselEdi(trim(DataSet.fieldbyname('船名').asstring)))='' then begin result:=false; MessageDlg('船舶呼号不能为空',mtWarning,[mbOk],0); exit; end; end; {if trim(DataSet.fieldbyname('二程港口').asstring)='' then begin result:=false; MessageDlg('未设定中转港',mtWarning,[mbOk],0); Exit; end; if GetTransPortEdi(trim(DataSet.fieldbyname('二程港口').asstring))='' then begin result:=false; MessageDlg('中转港未设定EDI代码',mtWarning,[mbOk],0); Exit; end; } { if trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)='' then begin result:=false; MessageDlg('运费协议号不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('发货人编号').asstring)='' then begin result:=false; MessageDlg('船舶服务号不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asstring)='' then begin result:=false; MessageDlg('EDI备注不能为空',mtWarning,[mbOk],0); exit; end; } if trim(DataSet.fieldbyname('签单地点').asstring)='' then begin result:=false; MessageDlg('签单地点不能为空',mtWarning,[mbOk],0); exit; end; if not bsSkinCheckRadioBox2.Checked then begin if trim(GetpkgsEdi(DataSet.fieldbyname('包装').asstring))='' then begin result:=false; MessageDlg('包装EDI代码不存在!',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('货物描述').asstring)='' then begin result:=false; MessageDlg('货物描述不能为空',mtWarning,[mbOk],0); exit; end; if trim(DataSet.fieldbyname('唛头').asstring)='' then begin result:=false; MessageDlg('唛头不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('件数').asinteger=0 then begin result:=false; MessageDlg('件数不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('重量').asFloat=0 then begin result:=false; MessageDlg('总重量不能为空',mtWarning,[mbOk],0); exit; end; if DataSet.fieldbyname('尺码').asFloat=0 then begin result:=false; MessageDlg('总尺码不能为空',mtWarning,[mbOk],0); exit; end; end else begin if trim(GetpkgsEdi(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))='' then begin result:=false; MessageDlg('包装EDI代码不存在!',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').asstring)='' then begin result:=false; MessageDlg('货物描述不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').asstring)='' then begin result:=false; MessageDlg('唛头不能为空',mtWarning,[mbOk],0); exit; end; if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asinteger=0 then begin result:=false; MessageDlg('件数不能为空',mtWarning,[mbOk],0); exit; end; if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asFloat=0 then begin result:=false; MessageDlg('总重量不能为空',mtWarning,[mbOk],0); exit; end; if frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asFloat=0 then begin result:=false; MessageDlg('总尺码不能为空',mtWarning,[mbOk],0); exit; end; end; if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' then begin result:=false; MessageDlg('货物标识不能为空',mtWarning,[mbOk],0); exit; end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='D' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring)='' then begin result:=false; MessageDlg('危险品等级不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring)='' then begin result:=false; MessageDlg('危险品编号不能为空',mtWarning,[mbOk],0); exit; end; if GetStrNum(Trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring))<>4 then begin result:=false; MessageDlg('危险品编号必须是4位数字',mtWarning,[mbOk],0); exit; end; end; if trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring)='R' then begin if Trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring)='' then begin result:=false; MessageDlg('设置温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring)='' then begin result:=false; MessageDlg('冷藏通风量不能为空',mtWarning,[mbOk],0); exit; end else begin end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring)='' then begin result:=false; MessageDlg('最低温度不能为空',mtWarning,[mbOk],0); exit; end; if Trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring)='' then begin result:=false; MessageDlg('最高温度不能为空',mtWarning,[mbOk],0); exit; end; end; if not bsSkinCheckRadioBox2.Checked then begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('select * from t_op_ctn'); t_op_ctn.SQL.Add('where 编号=:编号'); t_op_ctn.SQL.Add('order by 代码'); t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; end else begin t_op_ctn.Close;t_op_ctn.SQL.Clear; t_op_ctn.SQL.Add('select * from t_op_ctn_fendan'); t_op_ctn.SQL.Add('where AS_ID=:AS_ID'); t_op_ctn.SQL.Add('order by 代码'); t_op_ctn.Parameters.ParamByName('AS_ID').Value:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsInteger; end; t_op_ctn.open; if t_op_ctn.IsEmpty then begin result:=false; MessageDlg('集装箱不能为空',mtWarning,[mbOk],0); exit; end; t_op_ctn.First; while not t_op_ctn.Eof do begin if Trim(GetCntrEdi(t_op_ctn.fieldbyname('代码').asstring))='' then begin result:=false; MessageDlg('集装箱EDI代码不存在!',mtWarning,[mbOk],0); exit; end; t_op_ctn.Next; end; end; function Tfrm_op_seae_edi_one.CreateEdiFile:TStrings; var str,sl1:Tstringlist; sl:TStrings; i,j,Count,l,M:integer; strsql,strRmain,strtemp,S,strtemp2:string; rs,aQuery2,aQueryCtnDetail,ctnquery:Tadoquery; wide_str:widestring; k:integer; strType,strorderno,strcntrno:string; strDatetime:string; SenderCode,ReciverCode:string; function GetRemarksString:String; var TempStr:TStrings; begin TempStr:=TStringList.Create; try if not bsSkinCheckRadioBox2.Checked then TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('EDI备注').AsString else TempStr.Text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').AsString; Result:='17:'; Result:=Result+FormatListString(TempStr,5,35)+''''; finally FreeAndNil(TempStr); end; end; function GetShipperString:String; var TempStr:TStringlist; aQuery:TADOQuery; M,L:integer; S:String; begin TempStr:=TStringList.Create; aQuery:=CreateAdoQuery; try if bsSkinCheckRadioBox2.Checked then begin with aQuery do begin Close; SQL.Clear; SQL.Add('select 发货人代码 from t_op_seae_assistant where AS_ID='+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString+''); // SQL.Add('select 发货人代码 from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('发货人代码').AsString else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString; end; end else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='20:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='20:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='20:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringlist; aQuery:TADOQuery; M,L:integer; S:String; begin TempStr:=TStringList.Create; aQuery:=CreateAdoQuery; try if bsSkinCheckRadioBox2.Checked then begin with aQuery do begin Close; SQL.Clear; SQL.Add('select 收货人代码 from t_op_seae_assistant where AS_ID='+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString+''); open; if not IsEmpty then TempStr.Text:=fieldbyname('收货人代码').AsString else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString; end; end else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='21:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='21:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='21:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringlist; aQuery:TADOQuery; M,L:integer; S:String; begin TempStr:=TStringList.Create; aQuery:=CreateAdoQuery; try if bsSkinCheckRadioBox2.Checked then begin with aQuery do begin Close; SQL.Clear; SQL.Add('select 通知人代码 from t_op_seae_assistant where AS_ID='+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString+''); // SQL.Add('select 通知人代码 from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('通知人代码').AsString else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString; end; end else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='22:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='22:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='22:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; // function GetNOTIFYTwoString:String; var TempStr:TStringlist; aQuery:TADOQuery; M,L:integer; S:String; begin TempStr:=TStringList.Create; aQuery:=CreateAdoQuery; try if bsSkinCheckRadioBox2.Checked then begin with aQuery do begin Close; SQL.Clear; SQL.Add('select 第二通知人 from t_op_seae_assistant where AS_ID='+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString+''); // SQL.Add('select 通知人代码 from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('第二通知人').AsString else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('第二通知人').AsString; end; end else TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('第二通知人').AsString; if trim(TempStr.Text)='' then Exit; GetLengthTString(TempStr,35); if Tempstr.Count<=6 then begin Result:='22:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=6 then begin if M=1 then begin s:='22:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=6 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='22:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; // function GetAMSShipperString:String; var TempStr:TStringlist; M,L:integer; S:String; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_AMS.fieldbyname('AMS发货人').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='23:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='23:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='23:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; function GetAMSConsigneString:String; var TempStr:TStringlist; M,L:integer; S:String; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_AMS.fieldbyname('AMS收货人').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='24:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='24:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='24:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; function GetAMSNOTIFYString:String; var TempStr:TStringlist; M,L:integer; S:String; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_AMS.fieldbyname('AMS通知人').AsString; GetLengthTString(TempStr,35); if Tempstr.Count<=9 then begin Result:='25:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; end else begin M:=1; for L:=0 to Tempstr.Count-1 do begin if M<=9 then begin if M=1 then begin s:='25:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end else begin if M=9 then s:=s+FormatEdiString(Tempstr.Strings[L],0) else s:=s+FormatEdiString(Tempstr.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='25:'+FormatEdiString(Tempstr.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); result:=''; end; finally FreeAndNil(TempStr); end; end; { function GetMARKSString:String; var TempStr:TStrings; k,j:integer; s:string; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('唛头').AsString; k:=1; for j:=0 to TempStr.Count-1 do begin if k<=10 then begin if k=1 then begin s:='44:'+FormatEdiString(sl.Strings[j],35)+':'; end else begin if K=5 then s:=s+FormatEdiString(sl.Strings[j],35) else s:=s+FormatEdiString(sl.Strings[j],35)+':'; end; end else begin S:=S+''''; EdiStrings.Add(S); k:=1; s:='44:'+FormatEdiString(sl.Strings[j],35)+':'; end; k:=k+1; end; S:=S+''''; Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; } { function GetCARGODESCRIPTIONString:String; var TempStr:TStrings; i:integer; begin TempStr:=TStringList.Create; try TempStr.Text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString; for i:=0 to TempStr.Count-1 do begin if i=0 then Result:='47:'+FormatEdiString(TempStr.Strings[i],70) else Result:=Result+':'+FormatEdiString(TempStr.Strings[i],70); end; Result:=Result+''''; finally FreeAndNil(TempStr); end; end; } begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; aQuery2:=CreateAdoQuery; if bsSkinCheckRadioBox2.Checked then begin with aQuery2 do begin Close; SQL.Clear; SQL.Add('select * from t_op_seae_assistant where AS_ID='''+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString+''''); // SQL.Add('select * from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+''''); open; end; end; if bsSkinCheckRadioBox1.Checked then if not frm_op_seae.t_op_ams.Active then frm_op_seae.t_op_ams.open; str.Clear; Count:=0; if bsSkinCheckRadioBox1.Checked then begin if frm_op_seae.t_op_ams.FieldByName('AMS代码').AsString<>'' then strtemp:=':'+frm_op_seae.t_op_ams.FieldByName('AMS代码').AsString else strtemp:=''; end else begin strtemp:=':'+edit9.Text; end; strorderno:=''; { if frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring<>'' then strorderno:=Trim(frm_op_seae.t_op_seae.fieldbyname('委托编号').asstring) else } strorderno:=Trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring); if bsSkinCheckRadioBox1.Checked then // bsSkinCheckRadioBox1 SI bsSkinCheckRadioBox2 主单 分单 begin if not bsSkinCheckRadioBox2.Checked then //主单 begin str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('订舱单号').asstring)+':' + cutmblno(trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':' + trim(Edit3.Text) +':' + ReciverCode+':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' + ':' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':'+strtemp+#39); end else begin str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('订舱单号').asstring)+':' + cutmblno(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring)) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':' + trim(Edit3.Text) +':' + ReciverCode+':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' + ':' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':'+strtemp+#39); end; end else begin if not bsSkinCheckRadioBox2.Checked then //主单 begin str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':' + trim(Edit3.Text) +':' + ReciverCode+':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+'::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' + ':' +strtemp+#39); end else begin str.Add ('02:'+ trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring)+':' + trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('运输条款').asstring) +':' + trim(Edit3.Text) +':' + ReciverCode+':' + ':::::::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+'::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':'+strtemp+#39); end; end; if (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='正本') OR (trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='电子提单') then strtemp:='ORI' else if trim(frm_op_seae.t_op_seae.fieldbyname('签单方式').asstring)='电放' then strtemp:='TER' else strtemp:='EXP'; str.add('03:'+strtemp+':' +':' + trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(frm_op_seae.t_op_seae.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(trim(frm_op_seae.t_op_seae.fieldbyname('提单份数').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+#39); // + get_fenshu(trim(frm_op_seae.t_op_seae.fieldbyname('副本提单份数').asstring))+#39); str.Add('11:' + trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)+':' +'::' + ReciverCode +':' + '::::::' +#39); //船舶经营人 if bsSkinCheckRadioBox1.Checked then begin str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +Trim(GetTransPortEdi(trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring)+#39); end else begin str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +Trim(GetTransPortEdi(trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +':' +trim(GetcustEdi(frm_op_seae.t_op_seae.fieldbyname('场站').asstring))+#39); end; if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; { if not bsSkinCheckRadioBox1.Checked then begin strtemp:=''; if not bsSkinCheckRadioBox2.Checked then sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('EDI备注').AsString else sl1.Text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').AsString; if (sl1.Text<>'') then begin strtemp:='17:'; strtemp:=strtemp+FormatListString(sl1,5,35); end; if Trim(frm_op_seae.t_op_ams.FieldByName('特殊装载代码').AsString)<>'' then begin if strtemp<>'' then strtemp:=strtemp+'::::'+Trim(frm_op_seae.t_op_ams.FieldByName('特殊装载代码').AsString)+#39 else strtemp:=strtemp+'17:::::::::'+Trim(frm_op_seae.t_op_ams.FieldByName('特殊装载代码').AsString)+#39 end else begin if strtemp<>'' then strtemp:=strtemp+#39; end; if strtemp<>'' then Str.Add(strtemp); end else begin } if not bsSkinCheckRadioBox2.Checked then //主单 begin if trim(frm_op_seae.t_op_seae.fieldbyname('EDI备注').asstring)<>'' then Str.Add(GetRemarksString); end else begin if trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('EDI备注').asstring)<>'' then Str.Add(GetRemarksString); end; // end; if not bsSkinCheckRadioBox1.Checked then begin frm_op_seae.t_op_ams.Close; frm_op_seae.t_op_ams.Open; if Trim(frm_op_seae.t_op_ams.FieldByName('NVONO').AsString)<>'' then begin str.Add ('18:'+'NVO'+':' +Trim(frm_op_seae.t_op_ams.FieldByName('NVONO').AsString)+#39); end; end; strtemp:=GetShipperString; if strtemp<>'' then Str.Add(strtemp); strtemp:=GetConsigneString; if strtemp<>'' then Str.Add(strtemp); strtemp:=GetNOTIFYString; if strtemp<>'' then Str.Add(strtemp); strtemp:=GetNOTIFYTwoString; if strtemp<>'' then Str.Add(strtemp); if bsSkinCheckRadioBox1.Checked then if frm_op_seae.t_op_ams.FieldByName('AMS发货人').AsString<>'' then begin strtemp:=GetAMSShipperString; if strtemp<>'' then Str.Add(strtemp); end; if bsSkinCheckRadioBox1.Checked then if frm_op_seae.t_op_ams.FieldByName('AMS收货人').AsString<>'' then begin strtemp:=GetAMSConsigneString; if strtemp<>'' then Str.Add(strtemp); end; if bsSkinCheckRadioBox1.Checked then if frm_op_seae.t_op_ams.FieldByName('AMS通知人').AsString<>'' then begin strtemp:=GetAMSNOTIFYString; if strtemp<>'' then Str.Add(strtemp); end; { str.Add ('20:'+':' +Changestr(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring) +#39); str.Add ('21:'+':' +Changestr(frm_op_seae.t_op_seae.fieldbyname('收货人代码').asstring) +#39); str.Add ('22:'+':' +Changestr(frm_op_seae.t_op_seae.fieldbyname('通知人代码').asstring) +#39); } if not bsSkinCheckRadioBox2.Checked then begin if IsHasCtn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString) then begin if Getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Count>0 then begin for i:=0 to Getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Count-1 do str.Add(getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Strings[i]); end; end else begin str.Add ('41:1:'+trim(frm_op_seae.t_op_seae.fieldbyname('运输方式').asstring)+':'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae.t_op_seae.fieldbyname('包装').asstring))+':' +cutpkgs(trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)) +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('总价').asstring) +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); end; end else begin str.Add ('41:1:'+trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('HS编码').asstring)+':'+trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring))+':' +cutpkgs(trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('包装').asstring)) +':' //第一层包装说明 +trim(frm_op_seae.t_op_seae.fieldbyname('总价').asstring) +':' //第一层包装说明 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); end; if (bsSkinCheckRadioBox1.Checked) and (not IsHasCtn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString)) then begin ctnquery:=CreateAdoQuery; try with ctnquery do begin Close; SQL.Clear; if bsSkinCheckRadioBox2.Checked then SQL.Add('select * from t_op_ctn_fendan where 编号 ='+QuotedStr(frm_op_seae.t_op_seae.fieldbyname('编号').AsString)) else SQL.Add('select * from t_op_ctn where 编号 ='+QuotedStr(frm_op_seae.t_op_seae.fieldbyname('编号').AsString)); Open; first; while not Eof do begin str.Add ('42' +':'+Trim(ctnquery.FieldByName('箱号').AsString) //2 序号 // 2 +':'+Trim(Trim(GetCntrEdi(ctnquery.fieldbyname('代码').asstring))) // 3 货物标识 S/R/D/O +':'+trim(ctnquery.fieldbyname('封号').asstring) // 4 货物标识 S/R/D/O +':'+Trim(ctnquery.FieldByName('件数').AsString) // 5 +':'+Trim(ctnquery.FieldByName('重量').AsString) // 5 +':' // 7 +':'+trim(ctnquery.FieldByName('尺码').asstring) //第一层包装说明 9 +#39); Next; end; end; finally FreeAndNil(ctnquery); end; end; if not IsHasCtn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString) then begin IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R' THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(frm_op_seae.t_op_seae.fieldbyname('危险品分类').asstring) +':' +':' +trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; end; if (not IsHasCtn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString)) and (not bsSkinCheckRadioBox2.Checked) then begin sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('唛头').AsString; GetLengthTString(sl1,35); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=10 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString; GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); end; if bsSkinCheckRadioBox2.Checked then begin sl1.Text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('唛头').AsString ; GetLengthTString(sl1,35); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=10 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); end; if bsSkinCheckRadioBox2.Checked then begin sl1.Text:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('货物描述').AsString ; // else // sl1.Text:=frm_op_seae.t_op_seae.fieldbyname('货物描述').AsString; GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); end; // Str.Add(GetCARGODESCRIPTIONString); IF frm_op_seae.t_op_seae.fieldbyname('是否自有箱').AsBoolean THEN strtemp2:='Y' else strtemp2:='N'; Count:=Count+11; strRmain:=''; if trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin if not bsSkinCheckRadioBox2.Checked then strRmain:=strRmain+'F:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+strtemp2 else strRmain:=strRmain+'L:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+strtemp2; end else begin if not bsSkinCheckRadioBox2.Checked then strRmain:=strRmain+'F:'+':'+':'+':'+':'+strtemp2 else strRmain:=strRmain+'L:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'+':'+':'+':'+strtemp2; end; if bsSkinCheckRadioBox1.Checked then begin strRmain:=strRmain+#39; end else begin strcntrno:=''; IF frm_op_seae.t_op_seae.fieldbyname('是否自有箱').AsBoolean THEN begin strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; aQueryCtnDetail:=CREATEADOQUERY; try aQueryCtnDetail.close; aQueryCtnDetail.sql.text:=strsql; aQueryCtnDetail.open; if not aQueryCtnDetail.IsEmpty then begin aQueryCtnDetail.First; while not aQueryCtnDetail.Eof do begin if (strcntrno='') then strcntrno:=aQueryCtnDetail.fieldbyname('箱号').AsString else strcntrno:=strcntrno+','+aQueryCtnDetail.fieldbyname('箱号').AsString; aQueryCtnDetail.Next; end; end; finally FreeAndNil(aQueryCtnDetail); end; end; strRmain:=strRmain+':'+strcntrno; strRmain:=strRmain+':'+frm_op_seae.t_op_ams.FieldByName('代箱信息').AsString+':'+frm_op_seae.t_op_ams.FieldByName('超重箱标志').AsString; IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='R' THEN strRmain:=strRmain+':Y' else strRmain:=strRmain+':N'; IF trim(frm_op_seae.t_op_ams.FieldByName('超限箱标志').AsString)<>'' then begin strRmain:=strRmain+'::'+trim(frm_op_seae.t_op_ams.FieldByName('超限箱标志').AsString)+#39; end else strRmain:=strRmain+#39; end; if not bsSkinCheckRadioBox2.Checked then begin strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; end else begin strsql:='select 代码,sum(数量) as 数量 from t_op_ctn_fendan where AS_ID=' +frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString +' group by 代码'; end; try rs:=CreateAdoQuery; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open;rs.First; while not rs.Eof do begin str.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; if bsSkinCheckRadioBox1.Checked then begin if not bsSkinCheckRadioBox2.Checked then begin strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; end else begin strsql:='select * from t_op_ctn_fendan where AS_ID=' +frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('AS_ID').AsString; end; rs.Close;rs.sql.clear; rs.sql.add(strsql); rs.Open; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; aQueryCtnDetail:=CREATEADOQUERY; try while not rs.Eof do begin str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+':'+trim(FloatToStr(rs.fieldbyname('尺码').AsFloat))+'''' ); aQueryCtnDetail.close; aQueryCtnDetail.sql.text:='select * from t_op_ctn_detail WHERE ctn_id='+ rs.fieldbyname('ctn_id').asstring; aQueryCtnDetail.open; if not aQueryCtnDetail.IsEmpty then begin aQueryCtnDetail.First; while not aQueryCtnDetail.Eof do begin str.Add ('53' +':'+trim(aQueryCtnDetail.fieldbyname('HTS').asstring) +':'+trim(IntToStr(aQueryCtnDetail.fieldbyname('件数').AsInteger)) +':'+trim(FloatToStr(aQueryCtnDetail.fieldbyname('重量').AsFloat)) +':'+trim(FloatToStr(aQueryCtnDetail.fieldbyname('尺码').AsFloat)) +':'+trim(GetpkgsEdi(aQueryCtnDetail.fieldbyname('包装').asstring)) +':'+trim(aQueryCtnDetail.fieldbyname('包装').asstring) +':' +':' +''''); sl1.Text:=aQueryCtnDetail.fieldbyname('货物描述').AsString; GetLengthTString(sl1,70); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='54:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='54:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); aQueryCtnDetail.Next; end; end; rs.Next; end; finally freeandnil(aQueryCtnDetail); end; end; end; end; rs.Close; rs.Free; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end else begin if frm_data_share.t_crm_client_changzhan.locate('客户简称',frm_op_seae.t_op_seae.fieldbyname('场站').asstring,[])then begin strRmain:=strRmain+'L:'+':'+':'+frm_data_share.t_crm_client_changzhan.fieldbyname('EDI代码').asstring+':'+':'+'N'+#39; end else begin strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39; end; str.Add('48:'+':'+':'+strRmain); Count:=Count+1; end; Result:=str; end; function Tfrm_op_seae_edi_one.CreateZHUEdiFile:TStrings; var str,sl1:Tstringlist; sl:TStrings; i,j,Count,l,M:integer; first:Boolean; strsql,strRmain,strtemp:string; rs,aQuery:Tadoquery; wide_str:widestring; k:integer; strType,s:string; strDatetime:string; SenderCode,ReciverCode:string; function GetRemarksString:String; var TempStr:TStrings; begin TempStr:=TStringList.Create; try TempStr.Text:=aQuery.fieldbyname('EDI备注').AsString; Result:='17:'; Result:=Result+FormatListString(TempStr,5,35)+''''; finally FreeAndNil(TempStr); end; end; function GetShipperString:String; var TempStr:TStringlist; aQuery2:TAdoQuery; begin aQuery2:=CreateAdoQuery; TempStr:=TStringList.Create; try if bsSkinCheckRadioBox2.Checked then begin with aQuery2 do begin Close; SQL.Clear; SQL.Add('select 发货人代码 from t_op_seae_assistant where 编号='''+aQuery.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('发货人代码').AsString else TempStr.Text:=aQuery.fieldbyname('发货人代码').AsString; end; end else TempStr.Text:=aQuery.fieldbyname('发货人代码').AsString; GetLengthTString(TempStr,35); Result:='20:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetConsigneString:String; var TempStr:TStringlist; aQuery2:TAdoQuery; begin aQuery2:=CreateAdoQuery; TempStr:=TStringList.Create; try if bsSkinCheckRadioBox2.Checked then begin with aQuery2 do begin Close; SQL.Clear; SQL.Add('select 收货人代码 from t_op_seae_assistant where 编号='''+aQuery.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('收货人代码').AsString else TempStr.Text:=aQuery.fieldbyname('收货人代码').AsString; end; end else TempStr.Text:=aQuery.fieldbyname('收货人代码').AsString; GetLengthTString(TempStr,35); Result:='21:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetNOTIFYString:String; var TempStr:TStringlist; aQuery2:TAdoQuery; begin aQuery2:=CreateAdoQuery; TempStr:=TStringList.Create; try if bsSkinCheckRadioBox2.Checked then begin with aQuery2 do begin Close; SQL.Clear; SQL.Add('select 通知人代码 from t_op_seae_assistant where 编号='''+aQuery.fieldbyname('编号').AsString+''''); open; if not IsEmpty then TempStr.Text:=fieldbyname('通知人代码').AsString else TempStr.Text:=aQuery.fieldbyname('通知人代码').AsString; end; end else TempStr.Text:=aQuery.fieldbyname('通知人代码').AsString; GetLengthTString(TempStr,35); Result:='22:'; Result:=Result+':'; Result:=Result+FormatListString(TempStr,9,35)+''''; finally FreeAndNil(TempStr); end; end; function GetMARKSString:String; var TempStr:TStringlist; begin TempStr:=TStringList.Create; try TempStr.Text:=aQuery.fieldbyname('唛头').AsString; GetLengthTString(TempStr,35); Result:='44:'; Result:=Result+FormatListString(TempStr,10,35)+''''; finally FreeAndNil(TempStr); end; end; function GetCARGODESCRIPTIONString:String; var TempStr:TStrings; begin TempStr:=TStringList.Create; try TempStr.Text:=aQuery.fieldbyname('货物描述').AsString; Result:='47:'; Result:=Result+FormatListString(TempStr,5,70)+''''; finally FreeAndNil(TempStr); end; end; begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; Count:=0; aQuery:=CreateAdoQuery; try aQuery.Close;aQuery.sql.Clear; aQuery.SQL.Add('select * from t_op_seae where 主编号=:编号 and 主编号<>编号'); aQuery.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring; aQuery.Open; if not aQuery.IsEmpty then begin if not isEditrue(aQuery) then exit; aQuery.first; first:=true; while not aQuery.eof do begin if first then begin str.Add ('02:'+ trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +'::' + ReciverCode+':' + ':::::::' + '::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':'+ #39); end else begin str.Add ('02:'+ trim(aQuery.fieldbyname('业务编号').asstring)+':' + trim(aQuery.fieldbyname('主提单号').asstring) +':' + trim(aQuery.fieldbyname('运输条款').asstring) +':' + trim(Edit3.Text) +':' + ReciverCode+':' + ':::::::' + '::' + trim(frm_op_seae.t_op_seae.fieldbyname('运费协议号').asstring)+':' +':'+ #39); end; strtemp:='ORI'; str.add('03:'+strtemp+':' +':' + trim(aQuery.fieldbyname('签单地点').asstring) +':' + GetDatetime(trim(aQuery.fieldbyname('签单日期').asstring),0)+':' + get_fenshu(trim(aQuery.fieldbyname('提单份数').asstring))+':' + trim(aQuery.fieldbyname('预付地点').asstring) +':' + trim(aQuery.fieldbyname('预付地点').asstring) +#39); str.Add('11:' + trim(frm_op_seae.t_op_seae.fieldbyname('发货人编号').asstring)+':' + trim(aQuery.fieldbyname('船名').asstring) +':' + trim(aQuery.fieldbyname('航次').asstring)+':' +'::' + ReciverCode +':' + '::::::' +#39); //船舶经营人 if bsSkinCheckRadioBox1.Checked then begin str.Add ('12:'+trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('卸货代码').asstring) +':' +trim(aQuery.fieldbyname('卸货港').asstring)+':' +Trim(GetTransPortEdi(trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)+':' +trim(aQuery.fieldbyname('交货代码').asstring) +':' +trim(aQuery.fieldbyname('交货地点').asstring) +':' +trim(aQuery.fieldbyname('目的地代码').asstring) +':' +trim(aQuery.fieldbyname('目的地').asstring)+#39); end else begin str.Add ('12:'+trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('装港代码').asstring)+':' +trim(aQuery.fieldbyname('装货港').asstring)+':' +trim(aQuery.fieldbyname('卸货代码').asstring) +':' +trim(aQuery.fieldbyname('卸货港').asstring)+':' +Trim(GetTransPortEdi(trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)+':' +trim(aQuery.fieldbyname('交货代码').asstring) +':' +trim(aQuery.fieldbyname('交货地点').asstring) +':' +trim(aQuery.fieldbyname('目的地代码').asstring) +':' +trim(aQuery.fieldbyname('目的地').asstring) +':' +trim(GetcustEdi(aQuery.fieldbyname('场站').asstring))+#39); end; if frm_data_share.t_code_free.locate('付费方式',aQuery.fieldbyname('付费方式').asstring,[]) then begin str.Add ('14:'+frm_data_share.t_code_free.fieldbyname('代码').asstring+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +trim(frm_data_share.t_code_free.fieldbyname('代码').asstring)+':' +'::' + '::::' +#39); //船舶经营人 end else begin str.Add ('14:'+'P'+':' +trim(aQuery.fieldbyname('付费方式').asstring)+#39); str.Add('15:' +'::' +'P:' +'::' + '::::' +#39); //船舶经营人 end; if trim(aQuery.fieldbyname('EDI备注').asstring)<>'' then Str.Add(GetRemarksString); if not bsSkinCheckRadioBox1.Checked then begin frm_op_seae.t_op_ams.Close; frm_op_seae.t_op_ams.Open; if frm_op_seae.t_op_ams.FieldByName('NVONO').AsString<>'' then begin str.Add ('18:'+'NVO'+':' +trim(frm_op_seae.t_op_ams.FieldByName('NVONO').AsString)+#39); end; end; Str.Add(GetShipperString); Str.Add(GetConsigneString); Str.Add(GetNOTIFYString); if IsHasCtn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString) then begin if Getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Count>0 then begin for i:=0 to Getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Count-1 do str.Add(getctn(frm_op_seae.t_op_seae.fieldbyname('编号').AsString).Strings[i]); end; end else begin str.Add ('41:1::'+trim(aQuery.fieldbyname('货物标识').asstring)+':' // 货物标识 S/R/D/O +trim(aQuery.fieldbyname('件数').asstring) +':' +trim(GetpkgsEdi(aQuery.fieldbyname('包装').asstring))+':' +trim(aQuery.fieldbyname('包装').asstring) +':' //第一层包装说明 +trim(aQuery.fieldbyname('总价').asstring) +':' //第一层包装说明 +trim(aQuery.fieldbyname('尺码').asstring) +'::::::' // 第一层包装皮重 +trim(aQuery.fieldbyname('重量').asstring) +':::' // 第一层包装尺码 +#39); end; IF trim(aQuery.fieldbyname('货物标识').asstring)='R'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +':' +':' +':' +':' +':' +':' +':' +'::' +trim(aQuery.fieldbyname('冷藏通风量').asstring) +':' +'C:' +trim(aQuery.fieldbyname('设置温度').asstring) +':' +trim(aQuery.fieldbyname('最低温度').asstring) +':' +trim(aQuery.fieldbyname('最高温度').asstring) +':' +'::::' +#39); END; IF trim(aQuery.fieldbyname('货物标识').asstring)='D'THEN BEGIN str.Add ('43:' // 危险品、冷冻 +trim(aQuery.fieldbyname('危险品分类').asstring) +':' +':' +trim(aQuery.fieldbyname('危险品编号').asstring) +':' +':' +':' +':' +':' +'::' +':' +':' +':' +':' +':::::' +#39); END; sl1.Text:=aQuery.fieldbyname('唛头').AsString; GetLengthTString(sl1,35); sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=10 then begin if M=1 then begin s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=10 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='44:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S);// Str.Add(GetCARGODESCRIPTIONString); sl1.Text:=aQuery.fieldbyname('货物描述').AsString; sl.text:=''; for L:=0 to sl1.Count-1 do begin if Trim(sl1.Strings[L])<>'' then sl.Add(sl1.Strings[L]); end; M:=1; for L:=0 to sl.Count-1 do begin if M<=5 then begin if M=1 then begin s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end else begin if M=5 then s:=s+FormatEdiString(sl.Strings[L],0) else s:=s+FormatEdiString(sl.Strings[L],0)+':'; end; end else begin S:=S+''''; Str.Add(S); M:=1; s:='47:'+FormatEdiString(sl.Strings[L],0)+':'; end; M:=M+1; end; S:=S+''''; Str.Add(S); Count:=Count+11; strRmain:=''; if first then strRmain:=strRmain+'L:'+':'+':'+':'+':'+'N'+#39 else strRmain:=strRmain+'L:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'+':'+':'+':'+'N'+#39; strsql:='select 编号,代码,sum(数量) as 数量 from t_op_ctn group by 编号,代码 having 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; while not rs.Eof do begin str.Add ('48:'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('数量').asstring)+':'+ strRmain); Count:=Count+1; rs.Next; end; if bsSkinCheckRadioBox1.Checked then begin strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; rs.Close; rs.sql.clear; rs.sql.add(strsql); rs.Open; if not rs.IsEmpty then begin if rs.FieldByName('件数').AsInteger>0 then begin rs.First; while not rs.Eof do begin str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring)+':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring))+':'+ trim(rs.fieldbyname('封号').asstring)+':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+':'+trim(FloatToStr(rs.fieldbyname('尺码').AsFloat))+'''' ); rs.Next; end; end; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; aQuery.Next; first:=False; end; end; finally FreeAndNil(aQuery); end; Result:=str; end; function Tfrm_op_seae_edi_one.GetCntrEdi(cntrsize: String):String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select EDI代码MOL Edi代码 from t_code_ctn where 代码='''+cntrsize+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_one.GetpkgsEdi(pkgs: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_package where 代码='''+pkgs+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; function Tfrm_op_seae_edi_one.GetlineEdi(aline: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.Clear; SQL.Add('Select Edi代码 from t_code_trade where 航线='''+aline+''''); Open; if IsEmpty then Result:='' else Result:=FieldByName('Edi代码').AsString; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_one.bsSkinButton3Click(Sender: TObject); var str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; i:integer; SenderCode,ReciverCode,strType:String; begin ftpar:=Trim(edit4.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(edit6.Text); if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(edit7.Text); if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(edit5.Text); FtpClient1.UserName:=ftpname; FtpClient1.PassWord:=ftppass; FtpClient1.HostName:=ftpar; FtpClient1.Passive:=CheckBox1.Checked; FtpClient1.MultiThreaded:=True; FtpClient1.Port:='21'; FtpClient1.DisplayFileFlag:=True; FtpClient1.Timeout:=5; try if (FtpClient1.Open) and (FtpClient1.User) and (FtpClient1.Pass) then begin //连接失败 frm_op_seae_edi_one.Caption:='用户连接成功!'; FtpClient1.HostDirName:=ftppath; if FtpClient1.Cwd then end else begin showmessage('用户连接失败!'); end; except on e:exception do begin FtpClient1.Abort; frm_op_seae_edi_one.Caption:='用户连接失败!'; end; end; { with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Passive:=CheckBox1.Checked; try finally Connect; end; if Connected then begin showmessage('Ftp连接成功!'); ChangeDir(ftppath); TransferType:=ftBinary; end else showmessage('Ftp连接失败,请重新连接!'); end; } end; procedure Tfrm_op_seae_edi_one.FormCloseQuery(Sender: TObject; var CanClose: Boolean); var inifile1:Tinifile; begin inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini'); inifile1.WriteString('ONEEDI','SEND',edit1.text); inifile1.WriteString('ONEEDI','RECIEVE',edit2.text); inifile1.WriteString('ONEEDI','SENDNAME',edit3.text); inifile1.WriteString('ONEEDI','FTPSERVER',edit4.text); inifile1.WriteString('ONEEDI','FTPPATH',edit5.text); inifile1.WriteString('ONEEDI','FTPNAME',edit6.text); inifile1.WriteString('ONEEDI','FTPPASS',edit7.text); inifile1.WriteString('ONEEDI','NVONO',edit8.text); inifile1.WriteString('ONEEDI','SENDEMAIL',edit9.text); inifile1.WriteString('ONEEDI','CONTRACTOR',edit10.text); inifile1.free; end; procedure Tfrm_op_seae_edi_one.bsSkinButton4Click(Sender: TObject); begin if frm_op_seae_edi_one.Height=390 then frm_op_seae_edi_one.Height:=244 else frm_op_seae_edi_one.Height:=390; end; function Tfrm_op_seae_edi_one.GetcustEdi(cust: String): String; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; try with aQuery do begin Close;SQL.CLEAR; SQL.Add('Select EDI代码 from t_crm_client where 客户简称='''+Cust+''''); Open; if not IsEmpty then result:=fieldbyname('EDI代码').AsString; end; finally FreeAndNil(aQuery); end; end; procedure Tfrm_op_seae_edi_one.FtpClient1Error(Sender: TObject; var Msg: String); begin ShowMessage(Msg); end; procedure Tfrm_op_seae_edi_one.bsSkinButton5Click(Sender: TObject); var str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; i,i_soi:integer; SenderCode,ReciverCode,strType:String; dsstr,PostUrl:WideString; begin i_soi:=0; if bsSkinCheckRadioBox2.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if not isEditrue(frm_op_seae.t_op_seae) then exit; end; end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(edit4.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(edit6.Text); if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(edit7.Text); if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(edit5.Text); str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; strL:=Tstringlist.Create; try SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; if bsSkinCheckRadioBox1.Checked then strL.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39) else strL.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then StrL.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then StrL:=CreateZHUEdiFile else begin Exit; end; end; end else begin if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then StrL.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then StrL:=CreateZHUEdiFile else begin Exit; end; end; I:=strL.Count; strL.Add('99:'+intToStr(i+1)+''''); for i:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[i])<>'' then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; strL.SaveToFile(str); finally FreeAndNil(StrL) end; if FtpClient1.Connected then begin try FtpClient1.TransferMode := ftpTransModeStream; FtpClient1.LocalFileName:=str; FtpClient1.HostFileName:= str_file; try if FtpClient1.Put then begin ShowMessage('上传成功'); frm_op_seae_edi_one.Caption:='上传成功!'; end; except FtpClient1.Abort; ShowMessage('上传失败!'); frm_op_seae_edi_one.Caption:='上传失败!'; i_soi:=1; end; finally FtpClient1.Abort; end; end; if i_soi=0 then if bsSkinCheckRadioBox1.Checked then UpdateSOIStatus(1,frm_op_seae.t_op_seae.fieldbyname('编号').asstring) else UpdateSOIStatus(0,frm_op_seae.t_op_seae.fieldbyname('编号').asstring); dsstr:=CreateSIEdiFile_MBL(); PostUrl:=get_parameters_value(2123,'http://www.myshipping.net:8657/Booking/ReceiveBookingData'); if (frm_op_seae.t_op_seae.FieldByName('船公司').asstring<>'东方海外') then begin TDsDjyThread.create(PostUrl,dsstr,''); InsertSysLog('上传大简云',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; if (not bsSkinCheckRadioBox1.Checked) and (frm_op_seae.t_op_seae.FieldByName('签单编号').AsInteger=10) then begin dsstr:='{'; dsstr:=dsstr+'"orderNo":"'+frm_op_seae.t_op_seae.FieldByName('委托编号').AsString+'"'; dsstr:=dsstr+',"status":"N"'; dsstr:=dsstr+',"bookingId":"'+frm_op_seae.t_op_seae.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"bookingIdDate":"'+FormatDateTime('YYYY-MM-DD hh:mm:ss',frm_op_seae.t_op_seae.FieldByName('录入日期').asdatetime)+'"'; dsstr:=dsstr+'}'; PostUrl:=get_parameters_value(2124,'http://47.104.90.170:6857/api/clp/bookingMsgReceipt'); TDsHaierThread.create(PostUrl,dsstr,'',frm_op_seae.t_op_seae.FieldByName('主提单号').AsString); InsertSysLog('上传海尔回执',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; { if not idftp1.Connected then with idftp1 do begin Username:=ftpname; Password:=ftppass; Host:=ftpar; Passive:=CheckBox1.Checked; try finally Connect; end; if Connected then begin showmessage('Ftp重新连接成功!'); ChangeDir(ftppath); TransferType:=ftBinary; end else showmessage('Ftp连接失败,请重新连接!'); end; if MessageDlg('确实要上传EID吗?',mtWarning,[mbyes,mbNo],0)=mryes then begin try if idftp1.Connected then begin idftp1.Put(str,str_file); showmessage('文件上传成功!'); idftp1.Disconnect; end else begin showmessage('Ftp没有连接,请重新连接'); end; except showmessage('文件上传错误!'); end; end; } end; function Tfrm_op_seae_edi_one.CreateVgmEdiFile:TStrings; var str,sl,sl1:Tstringlist; i,j,Count,l,M:integer; strsql,strRmain,strtemp,S,fenshu:string; rs:Tadoquery; wide_str,str_shr,str_con,str_not:widestring; k:integer; strType,SM:string; strDatetime,shipname,shipaddr:string; SenderCode,ReciverCode:string; firstcon:boolean; begin SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; str:=Tstringlist.Create; sl:=Tstringlist.Create; sl1:=Tstringlist.Create; str.Clear; str.Add('00:IFTVGM:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); Count:=0; str.Add ('02:'+ Copy(trim(frm_op_seae.t_op_seae.fieldbyname('业务编号').asstring),3,20)+':' + trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) +#39); str.Add('11:' + trim(GetvesselEdi(frm_op_seae.t_op_seae.fieldbyname('船名').asstring))+':' + trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':' + trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) // +':'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring) +#39); //船舶经营人 str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装港代码').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':' +Trim(GetTransPortEdi(trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)))+':' +trim(frm_op_seae.t_op_seae.fieldbyname('二程港口').asstring)+':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地代码').asstring) +':' +trim(frm_op_seae.t_op_seae.fieldbyname('目的地').asstring) +#39); Count:=Count+4; if 1=1 then begin strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; try rs:=Tadoquery.Create(application); rs.Connection := frm_main.db; rs.sql.clear; rs.sql.add(strsql); rs.Open; rs.First; if not rs.IsEmpty then begin rs.First; while not rs.Eof do begin if (rs.fieldbyname('称重方式').asstring<>'') or (rs.fieldbyname('称重方式').asstring<>'无') then begin if Trim(rs.fieldbyname('称重方式').asstring)='累加' then SM:='SM2' else if Trim(rs.fieldbyname('称重方式').asstring)='总重' then SM:='SM1'; str.Add ('51:'+trim(rs.fieldbyname('箱号').asstring) //2 +':'+Trim(GetCntrEdi(rs.fieldbyname('代码').asstring)) //3 +':'+trim(rs.fieldbyname('封号').asstring) // 4 +':'+trim(IntToStr(rs.fieldbyname('件数').AsInteger)) //5 +':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat)) //6 +'::' +trim(floatToStr(rs.fieldbyname('尺码').Asfloat)) //78 +'::::::' //9-14 +':'+rs.fieldbyname('称重重量').asstring //15 +':'+GetDatetime(datetimetostr(now),1) //16 +':'+SM //17 +''''); sl.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').asstring,0); shipname:=''; if sl.Count>=1 then shipname:=Copy(sl[0],1,20); shipaddr:=''; if sl.Count>=2 then shipaddr:=sl[1]; if sl.Count>=3 then shipaddr:=shipaddr+' '+sl[2]; if sl.Count>=4 then shipaddr:=shipaddr+' '+sl[3]; if sl.Count>=5 then shipaddr:=shipaddr+' '+sl[4]; str.Add ('58:'+shipname //2 +':'+shipaddr //3 +':'+rs.fieldbyname('VGM联系人').asString // 4 +':'+'' //5 +':'+rs.fieldbyname('VGM联系联系方式').asString //6 +':'+rs.fieldbyname('VGM联系人').asString //7 +':' +rs.fieldbyname('VGM签名').asString //8 +':' +'certificate ID' //9 +''''); end; rs.Next; end; end; rs.Close; rs.Destroy; except on e:exception do begin rs.Close; rs.Destroy; exit; end; end; end; I:=str.Count; str.Add('99:'+intToStr(i+1)+''''); Result:=str; end; procedure Tfrm_op_seae_edi_one.bsSkinButton7Click(Sender: TObject); var str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; i,i_soi:integer; SenderCode,ReciverCode,strType:String; SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE:string; edi:WideString; begin i_soi:=0; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(edit4.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(edit6.Text); if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(edit7.Text); if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(edit5.Text); str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; StrL:=Tstringlist.Create; try StrL:=CreateVgmEdiFile; edi:=StrL.Text; strL.SaveToFile(str); finally FreeAndNil(StrL) end; if FtpClient1.Connected then begin try FtpClient1.TransferMode := ftpTransModeStream; FtpClient1.LocalFileName:=str; FtpClient1.HostFileName:= str_file; try if FtpClient1.Put then begin ShowMessage('上传成功'); frm_op_seae_edi_one.Caption:='上传成功!'; end; except FtpClient1.Abort; ShowMessage('上传失败!'); frm_op_seae_edi_one.Caption:='上传失败!'; i_soi:=1; end; finally FtpClient1.Abort; end; end; { if i_soi=0 then if bsSkinCheckRadioBox1.Checked then UpdateSOIStatus(1,frm_op_seae.t_op_seae.fieldbyname('编号').asstring) else UpdateSOIStatus(0,frm_op_seae.t_op_seae.fieldbyname('编号').asstring); } // if bsSkinCheckRadioBox1.Checked then SIO:='SI' else SIO:='SO'; if bsSkinRadioGroup1.ItemIndex=0 then ORG:='ORG' else ORG:='AMEND'; IF bsSkinCheckRadioBox2.Checked then begin MBL:='分单'; MBLNO:=frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring; end else begin MBL:='主单'; MBLNO:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; end; CARR:=frm_op_seae.t_op_seae.fieldbyname('船公司').asstring; CORP:=frm_op_seae.t_op_seae.fieldbyname('委托单位').asstring; EMP:=employee; EMPDAE:=FormatDateTime('YYYY-MM-DD hh:mm:ss',now); ETD:=FormatDateTime('YYYY-MM-DD',frm_op_seae.t_op_seae.fieldbyname('开船日期').value); Insertt_op_Edi_Log(SIO,ORG,MBL,CARR,MBLNO,ETD,CORP,EMP,EMPDAE,str,edi); end; procedure Tfrm_op_seae_edi_one.bsSkinButton6Click(Sender: TObject); var Str:TStrings; i:integer; begin // if not isEditrue(frm_op_seae.t_op_seae) then exit; try Str:=CreateVgmEdiFile; SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring; if SaveDialog1.Execute then begin str.SaveToFile(SaveDialog1.FileName+'.txt'); showmessage('文件生成成功!'); end else begin showmessage('文件生成失败!'); exit; end; finally FreeAndNil(Str) end; end; function Tfrm_op_seae_edi_one.cutpkgs(kindpkg: string): string; var s:string; l:Integer; begin if (kindpkg='') or (Length(kindpkg)=0) then result:=kindpkg; s:=kindpkg; l:=Length(kindpkg); if Copy(kindpkg,l,1)='S' THEN result:=Copy(kindpkg,1,l-1); end; function Tfrm_op_seae_edi_one.cutmblno(mblno: string): string; var s:string; l,j:Integer; begin if (mblno='') or (Length(mblno)=0) then result:=mblno; s:=mblno; l:=Length(mblno); if Copy(mblno,1,4)='ONEY' THEN result:=Copy(mblno,5,l-4) else result:=mblno; end; procedure Tfrm_op_seae_edi_one.bsSkinButton8Click(Sender: TObject); var str:widestring; str_file:widestring; ftpar,ftpname,ftppass,ftppath,ScriptPath:String; StrL:TStrings; i,j,i_soi:integer; SenderCode,ReciverCode,strType:String; dsstr,PostUrl:WideString; begin i_soi:=0; if bsSkinCheckRadioBox2.Checked then begin if frm_op_seae_assistant=nil then begin ShowMessage('请在(委托和提单)界面发送分单Edi'); exit; end end; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); if not isEditrue(frm_op_seae.t_op_seae) then exit; end; end else begin if not isEditrue(frm_op_seae.t_op_seae) then exit; end; ScriptPath:=ExtractFilePath(ParamStr(0))+'EDIFILE\'; if not DirectoryExists(ScriptPath) then CreateDir(ScriptPath); ftpar:=Trim(edit4.Text); if ftpar='' then begin MessageDlg('请设置FTP地址!',mtWarning,[mbOk],0); exit; end; ftpname:=Trim(edit6.Text); if ftpar='' then begin MessageDlg('请设置FTP用户名!',mtWarning,[mbOk],0); exit; end; ftppass:=Trim(edit7.Text); if ftpar='' then begin MessageDlg('请设置FTP密码!',mtWarning,[mbOk],0); exit; end; ftppath:=Trim(edit5.Text); strL:=Tstringlist.Create; try SenderCode:=trim(edit1.Text) ; ReciverCode:=trim(edit2.Text) ; if bsSkinRadioGroup1.ItemIndex=0 then strType:='9' else if bsSkinRadioGroup1.ItemIndex=1 then strType:='2' else if bsSkinRadioGroup1.ItemIndex=2 then strType:='3' else if bsSkinRadioGroup1.ItemIndex=3 then strType:='4' else strType:='9'; if frm_op_seae.dxdbgrid1.SelectedCount>1 then begin for i:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do begin frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[i])); str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; StrL.Clear; if bsSkinCheckRadioBox1.Checked then strL.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39) else strL.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then StrL.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then StrL:=CreateZHUEdiFile else begin Exit; end; j:=strL.Count; strL.Add('99:'+intToStr(j+1)+''''); for j:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[j])<>'' then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; strL.SaveToFile(str); if FtpClient1.Connected then begin try FtpClient1.TransferMode := ftpTransModeStream; FtpClient1.LocalFileName:=str; FtpClient1.HostFileName:= str_file; try if FtpClient1.Put then begin // ShowMessage('上传成功'); frm_op_seae_edi_one.Caption:='上传成功!'; end; except FtpClient1.Abort; // ShowMessage('上传失败!'); frm_op_seae_edi_one.Caption:='上传失败!'; i_soi:=1; end; finally FtpClient1.Abort; end; end; if i_soi=0 then if bsSkinCheckRadioBox1.Checked then UpdateSOIStatus(1,frm_op_seae.t_op_seae.fieldbyname('编号').asstring) else UpdateSOIStatus(0,frm_op_seae.t_op_seae.fieldbyname('编号').asstring); dsstr:=CreateSIEdiFile_MBL(); PostUrl:=get_parameters_value(2123,'http://www.myshipping.net:8657/Booking/ReceiveBookingData'); if (frm_op_seae.t_op_seae.FieldByName('船公司').asstring<>'东方海外') then begin TDsDjyThread.create(PostUrl,dsstr,''); InsertSysLog('上传大简云',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; if (not bsSkinCheckRadioBox1.Checked) and (frm_op_seae.t_op_seae.FieldByName('签单编号').AsInteger=10) then begin dsstr:='{'; dsstr:=dsstr+'"orderNo":"'+frm_op_seae.t_op_seae.FieldByName('委托编号').AsString+'"'; dsstr:=dsstr+',"status":"N"'; dsstr:=dsstr+',"bookingId":"'+frm_op_seae.t_op_seae.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"bookingIdDate":"'+FormatDateTime('YYYY-MM-DD hh:mm:ss',frm_op_seae.t_op_seae.FieldByName('录入日期').asdatetime)+'"'; dsstr:=dsstr+'}'; PostUrl:=get_parameters_value(2124,'http://47.104.90.170:6857/api/clp/bookingMsgReceipt'); TDsHaierThread.create(PostUrl,dsstr,'',frm_op_seae.t_op_seae.FieldByName('主提单号').AsString); InsertSysLog('上传海尔回执',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; end; ShowMessage('上传成功'); end else begin str:=ScriptPath +frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; str_file:=frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring +FormatDateTime('yyyy',now) +FormatDateTime('mm',now) +FormatDateTime('dd',now) +FormatDateTime('hh',now) +FormatDateTime('nn',now)+'.txt'; StrL.Clear; if bsSkinCheckRadioBox1.Checked then strL.Add('00:IFTMIN:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39) else strL.Add('00:IFTMBF:BOOKING:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39); if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then StrL.AddStrings(CreateEdiFile) else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then StrL:=CreateZHUEdiFile else begin Exit; end; I:=strL.Count; strL.Add('99:'+intToStr(i+1)+''''); for j:=0 to StrL.Count-1 do begin if IsZhongwen(StrL[j])<>'' then begin MessageDlg('此票业务有中文字符或TAB等不规范字符,请去除字符后重试!',mtWarning,[mbYes],0); exit; end; end; strL.SaveToFile(str); if FtpClient1.Connected then begin try FtpClient1.TransferMode := ftpTransModeStream; FtpClient1.LocalFileName:=str; FtpClient1.HostFileName:= str_file; try if FtpClient1.Put then begin frm_op_seae_edi_one.Caption:='上传成功!'; end; except FtpClient1.Abort; ShowMessage('上传失败!'); frm_op_seae_edi_one.Caption:='上传失败!'; i_soi:=1; end; finally FtpClient1.Abort; end; end; if i_soi=0 then if bsSkinCheckRadioBox1.Checked then UpdateSOIStatus(1,frm_op_seae.t_op_seae.fieldbyname('编号').asstring) else UpdateSOIStatus(0,frm_op_seae.t_op_seae.fieldbyname('编号').asstring); dsstr:=CreateSIEdiFile_MBL(); PostUrl:=get_parameters_value(2123,'http://www.myshipping.net:8657/Booking/ReceiveBookingData'); if (frm_op_seae.t_op_seae.FieldByName('船公司').asstring<>'东方海外') then begin TDsDjyThread.create(PostUrl,dsstr,''); InsertSysLog('上传大简云',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; if (not bsSkinCheckRadioBox1.Checked) and (frm_op_seae.t_op_seae.FieldByName('签单编号').AsInteger=10) then begin dsstr:='{'; dsstr:=dsstr+'"orderNo":"'+frm_op_seae.t_op_seae.FieldByName('委托编号').AsString+'"'; dsstr:=dsstr+',"status":"N"'; dsstr:=dsstr+',"bookingId":"'+frm_op_seae.t_op_seae.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"bookingIdDate":"'+FormatDateTime('YYYY-MM-DD hh:mm:ss',frm_op_seae.t_op_seae.FieldByName('录入日期').asdatetime)+'"'; dsstr:=dsstr+'}'; PostUrl:=get_parameters_value(2124,'http://47.104.90.170:6857/api/clp/bookingMsgReceipt'); TDsHaierThread.create(PostUrl,dsstr,'',frm_op_seae.t_op_seae.FieldByName('主提单号').AsString); InsertSysLog('上传海尔回执',frm_op_seae.t_op_seae.FieldByName('业务编号').asstring); end; end; finally FreeAndNil(StrL) end; end; function Tfrm_op_seae_edi_one.CreateSIEdiFile_MBL: string; var str,str2,codetype,codestr,strsql,typestr:string; aAdoQuery:TAdoQuery; isfirst:Boolean; TempStr:TStringlist; function getcustedi(cust:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select 海关编码 EDI代码 from t_crm_client where 客户简称='''+cust+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('EDI代码').AsString; if Result='' then result:=cust; finally FreeAndNil(aQuery); end; end; function getempemail(emp:string):string; var aQuery:TADOQuery; begin aQuery:=CreateAdoQuery; result:=''; try aQuery.Close; aQuery.SQL.Text:='select 邮箱 from t_sys_employee where 姓名='''+emp+''''; aQuery.Open; if not aQuery.IsEmpty then result:=aQuery.fieldbyname('邮箱').AsString; finally FreeAndNil(aQuery); end; end; begin str:=str+'{'; str:=str+'"COMPANY_NAME":"'+frm_data_share.t_sys_company.fieldbyname('全称').AsString+'"'; str:=str+',"BOOKINGS":['; str:=str+'{'; aAdoQuery:=CreateAdoQuery; TempStr:=TStringList.Create; try if not bsSkinCheckRadioBox2.checked then begin str:=str+'"BSNO":"'+ frm_op_seae.t_op_seae.FieldByName('业务编号').asstring+'"'; str:=str+',"CUST_NO":"'+ frm_op_seae.t_op_seae.FieldByName('业务编号').asstring+'"'; str:=str+',"MBLNO":"'+ frm_op_seae.t_op_seae.FieldByName('主提单号').asstring+'"'; str:=str+',"HBLNO":"'+ frm_op_seae.t_op_seae.FieldByName('分提单号').asstring+'"'; str:=str+',"CONTRACTNO":"'+ frm_op_seae.t_op_seae.FieldByName('运费协议号').asstring+'"'; str:=str+',"SHIPPER":"'+ StringReplace(frm_op_seae.t_op_seae.FieldByName('发货人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"CONSIGNEE":"'+ StringReplace(frm_op_seae.t_op_seae.FieldByName('收货人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"NOTIFYPARTY":"'+ StringReplace(frm_op_seae.t_op_seae.FieldByName('通知人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"NOTIFYPARTY2":"'+ StringReplace(frm_op_seae.t_op_seae.FieldByName('第二通知人').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"YARD":"'+getcustedi(frm_op_seae.t_op_seae.FieldByName('场站').asstring)+'"'; str:=str+',"VESSEL":"'+ frm_op_seae.t_op_seae.FieldByName('船名').asstring+'"'; str:=str+',"VOYNO":"'+ frm_op_seae.t_op_seae.FieldByName('航次').asstring+'"'; str:=str+',"VoynoInner":"'+ frm_op_seae.t_op_seae.FieldByName('内部航次号').asstring+'"'; str:=str+',"ETD":"'+ frm_op_seae.t_op_seae.FieldByName('开船日期').asstring+'"'; str:=str+',"CLOSINGDATE":"'+ frm_op_seae.t_op_seae.FieldByName('截港日期').asstring+'"'; str:=str+',"CLOSEDOCDATE":"'+ frm_op_seae.t_op_seae.FieldByName('截单日期').asstring+'"'; str:=str+',"ETA":"'+ frm_op_seae.t_op_seae.FieldByName('预抵日期').asstring+'"'; str:=str+',"PLACERECEIPTID":""'; str:=str+',"PLACERECEIPT":""'; str:=str+',"PORTLOADID":"CNTAO"'; str:=str+',"PORTLOAD":"QINGDAO,CHINA"'; str:=str+',"PORTDISCHARGEID":"'+ frm_op_seae.t_op_seae.FieldByName('卸货代码').asstring+'"'; str:=str+',"PORTDISCHARGE":"'+ frm_op_seae.t_op_seae.FieldByName('卸货港').asstring+'"'; str:=str+',"PLACEDELIVERYID":"'+ frm_op_seae.t_op_seae.FieldByName('交货代码').asstring+'"'; str:=str+',"PLACEDELIVERY":"'+ frm_op_seae.t_op_seae.FieldByName('交货地点').asstring+'"'; str:=str+',"DESTINATIONID":"'+ frm_op_seae.t_op_seae.FieldByName('目的地代码').asstring+'"'; str:=str+',"DESTINATION":"'+ frm_op_seae.t_op_seae.FieldByName('目的地').asstring+'"'; str:=str+',"NOBILL":"'+ frm_op_seae.t_op_seae.FieldByName('提单份数').asstring+'"'; str:=str+',"COPYNOBILLL":"'+ frm_op_seae.t_op_seae.FieldByName('副本提单份数').asstring+'"'; str:=str+',"ISSUETYPE":"'+ frm_op_seae.t_op_seae.FieldByName('签单方式').asstring+'"'; str:=str+',"ISSUEDATE":"'+ frm_op_seae.t_op_seae.FieldByName('签单日期').asstring+'"'; // str:=str+',"ISSUEPLACEID":"'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring))+'"'; str:=str+',"ISSUEPLACE":"'+ frm_op_seae.t_op_seae.FieldByName('签单地点').asstring+'"'; str:=str+',"BLFRT":"'+ frm_op_seae.t_op_seae.FieldByName('付费方式').asstring+'"'; str:=str+',"PREPARDAT":"'+ frm_op_seae.t_op_seae.FieldByName('预付地点').asstring+'"'; str:=str+',"PAYABLEAT":"'+ frm_op_seae.t_op_seae.FieldByName('到付地点').asstring+'"'; str:=str+',"SERVICE":"'+ frm_op_seae.t_op_seae.FieldByName('运输条款').asstring+'"'; str:=str+',"MARKS":"'+StringReplace(frm_op_seae.t_op_seae.FieldByName('唛头').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"HSCODE":"'+ frm_op_seae.t_op_seae.FieldByName('运输方式').asstring+'"'; str:=str+',"DESCRIPTION":"'+ StringReplace(frm_op_seae.t_op_seae.FieldByName('货物描述').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"PKGS":'+ frm_op_seae.t_op_seae.FieldByName('件数').asstring; str:=str+',"KINDPKGS":"'+ frm_op_seae.t_op_seae.FieldByName('包装').asstring+'"'; str:=str+',"KGS":'+ frm_op_seae.t_op_seae.FieldByName('重量').asstring; str:=str+',"CBM":'+ frm_op_seae.t_op_seae.FieldByName('尺码').asstring; str:=str+',"CARRIER":"'+frm_op_seae.t_op_seae.FieldByName('船公司').asstring+'"'; str:=str+',"CARGOID":"'+ frm_op_seae.t_op_seae.FieldByName('货物标识').asstring+'"'; str:=str+',"DCLASS":"'+ frm_op_seae.t_op_seae.FieldByName('危险品分类').asstring+'"'; str:=str+',"DUNNO":"'+ frm_op_seae.t_op_seae.FieldByName('危险品编号').asstring+'"'; str:=str+',"DPAGE":""'; str:=str+',"DLABEL":""'; str:=str+',"LINKMAN":""'; if (frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R') then str:=str+',"TEMPID":"C"' else str:=str+',"TEMPID":""'; str:=str+',"TEMPSET":"'+ frm_op_seae.t_op_seae.FieldByName('设置温度').asstring+'"'; str:=str+',"REEFERF":"'+ frm_op_seae.t_op_seae.FieldByName('冷藏通风量').asstring+'"'; str:=str+',"HUMIDITY":"'+ frm_op_seae.t_op_seae.FieldByName('湿度').asstring+'"'; if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then str:=str+',"ISCONTAINERSOC":true' else str:=str+',"ISCONTAINERSOC":false'; strsql:='select * from t_op_ams where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; aAdoQuery.Close; aAdoQuery.SQL.Text:=strsql; aAdoQuery.Open; str:=str+',"REMARK":"'+aAdoQuery.FieldByName('SI备注').asstring+'"'; str:=str+',"EDIREMARK":"'+ frm_op_seae.t_op_seae.FieldByName('EDI备注').asstring+'"'; str:=str+',"YardRemark":"'+ frm_op_seae.t_op_seae.FieldByName('备注').asstring+'"'; str:=str+',"PONO":"'+ frm_op_seae.t_op_seae.FieldByName('委托编号').asstring+'"'; str:=str+',"TOTALNO":"'+ frm_op_seae.t_op_seae.FieldByName('件数大写').asstring+'"'; str:=str+',"TEMPMIN":"'+ frm_op_seae.t_op_seae.FieldByName('最低温度').asstring+'"'; str:=str+',"TEMPMAX":"'+ frm_op_seae.t_op_seae.FieldByName('最高温度').asstring+'"'; str:=str+',"OP":"'+ frm_op_seae.t_op_seae.FieldByName('客服员').asstring+'"'; str:=str+',"DOC":""'; str:=str+',"SALE":""'; str:=str+',"CUSTSERVICE":""'; str:=str+',"VGM_TIME":""'; str:=str+',"CUSTOMERNAME":"'+ frm_op_seae.t_op_seae.FieldByName('委托单位').asstring+'"'; str:=str+',"EMAIL":"'+getempemail(frm_op_seae.t_op_seae.FieldByName('操作员').asstring)+'"'; str:=str+',"FORWARDER":"'+ frm_op_seae.t_op_seae.FieldByName('货代公司').asstring+'"'; str:=str+',"SHIPAGENCY":""'; str:=str+',"CUSTOMSER":""'; str:=str+',"TRUCKER":""'; str:=str+',"AGENTID":""'; str:=str+',"CARRIERID":"'+ getcustedi(frm_op_seae.t_op_seae.FieldByName('船公司').asstring)+'"'; str:=str+',"YARDID":"'+ getcustedi(frm_op_seae.t_op_seae.FieldByName('场站').asstring)+'"'; str:=str+',"YardContract":"'+ frm_op_seae.t_op_seae.FieldByName('场站联系人').asstring+'"'; str:=str+',"CUSTOMERID":""'; str:=str+',"FORWARDERID":""'; str:=str+',"SHIPAGENCYID":"'+frm_op_seae.t_op_seae.FieldByName('船代').asstring+'"'; str:=str+',"CUSTOMSERID":""'; str:=str+',"TRUCKERID":""'; str:=str+',"AGENTNAME":""'; str:=str+',"WEITUO":""'; str:=str+',"EDIATTN":""'; str:=str+',"EDIATTNTEL":""'; str:=str+',"EDIATTNEMAIL":""'; str:=str+',"CONSIGNEEDOORADDR":""'; str:=str+',"SHIPPERDOORADDR":""'; str:=str+',"SCACCODE":""'; str:=str+',"ITNCODE":""'; // str:=str+',"PREPARDAT_ID":"'+GetPortEdiID(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+'"'; str:=str+',"PAYABLEAT_ID":"'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点代码').asstring)+'"'; if (frm_op_seae.t_op_seae.FieldByName('场站').asstring='港捷丰场站(FF)') or (frm_op_seae.t_op_seae.FieldByName('场站').asstring='捷丰场站') then begin if (frm_op_seae.t_op_seae.FieldByName('防伪').AsBoolean) then str:=str+',"FEE_SELF":true' else str:=str+',"FEE_SELF":false'; end else begin str:=str+',"FEE_SELF":true'; end; strsql:='select * from t_op_ctn where 编号=' +#39+frm_op_seae.t_op_seae.fieldbyname('编号').asstring+#39; aAdoQuery.Close; aAdoQuery.SQL.Text:=strsql; aAdoQuery.Open; aAdoQuery.First; str:=str+',"CtrnList":['; isfirst:=true; while not aAdoQuery.Eof do begin if (isfirst) then str:=str+'{' else str:=str+',{'; str:=str+'"CTNALL":"'+StringReplace(aAdoQuery.FieldByName('表现形式').asstring,'''','',[])+'"'; str:=str+',"CTNNUM":'+aAdoQuery.FieldByName('数量').asstring; str:=str+',"CNTRNO":"'+aAdoQuery.FieldByName('箱号').asstring+'"'; str:=str+',"SEALNO":"'+aAdoQuery.FieldByName('封号').asstring+'"'; str:=str+',"PKGS":"'+aAdoQuery.FieldByName('件数').asstring+'"'; str:=str+',"KINDPKGS":"'+aAdoQuery.FieldByName('包装').asstring+'"'; str:=str+',"KGS":"'+aAdoQuery.FieldByName('重量').asstring+'"'; str:=str+',"CBM":"'+aAdoQuery.FieldByName('尺码').asstring+'"'; str:=str+',"TAREWEIGHT":'+aAdoQuery.FieldByName('箱皮重').asstring; str:=str+',"WEIGHTYPE":"累加"'; str:=str+',"WEIGHKGS":'+aAdoQuery.FieldByName('称重重量').asstring; str:=str+',"REMARK":""'; str:=str+'}'; isfirst:=false; aAdoQuery.Next; end; str:=str+']'; end else begin str:=str+'"BSNO":"'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'"'; str:=str+',"CUST_NO":"'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'"'; str:=str+',"MBLNO":"'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('主提单号').asstring+'"'; str:=str+',"HBLNO":"'+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('分提单号').asstring+'"'; str:=str+',"CONTRACTNO":"'+ frm_op_seae.t_op_seae.FieldByName('运费协议号').asstring+'"'; str:=str+',"SHIPPER":"'+ StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('发货人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"CONSIGNEE":"'+ StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('收货人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"NOTIFYPARTY":"'+ StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('通知人代码').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"NOTIFYPARTY2":"'+ StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('第二通知人').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"YARD":"'+getcustedi(frm_op_seae.t_op_seae.FieldByName('场站').asstring)+'"'; str:=str+',"VESSEL":"'+ frm_op_seae.t_op_seae.FieldByName('船名').asstring+'"'; str:=str+',"VOYNO":"'+ frm_op_seae.t_op_seae.FieldByName('航次').asstring+'"'; str:=str+',"VoynoInner":"'+ frm_op_seae.t_op_seae.FieldByName('内部航次号').asstring+'"'; str:=str+',"ETD":"'+ frm_op_seae.t_op_seae.FieldByName('开船日期').asstring+'"'; str:=str+',"CLOSINGDATE":"'+ frm_op_seae.t_op_seae.FieldByName('截港日期').asstring+'"'; str:=str+',"CLOSEDOCDATE":"'+ frm_op_seae.t_op_seae.FieldByName('截单日期').asstring+'"'; str:=str+',"ETA":"'+ frm_op_seae.t_op_seae.FieldByName('预抵日期').asstring+'"'; str:=str+',"PLACERECEIPTID":""'; str:=str+',"PLACERECEIPT":""'; str:=str+',"PORTLOADID":"CNTAO"'; str:=str+',"PORTLOAD":"QINGDAO,CHINA"'; str:=str+',"PORTDISCHARGEID":"'+ frm_op_seae.t_op_seae.FieldByName('卸货代码').asstring+'"'; str:=str+',"PORTDISCHARGE":"'+ frm_op_seae.t_op_seae.FieldByName('卸货港').asstring+'"'; str:=str+',"PLACEDELIVERYID":"'+ frm_op_seae.t_op_seae.FieldByName('交货代码').asstring+'"'; str:=str+',"PLACEDELIVERY":"'+ frm_op_seae.t_op_seae.FieldByName('交货地点').asstring+'"'; str:=str+',"DESTINATIONID":"'+ frm_op_seae.t_op_seae.FieldByName('目的地代码').asstring+'"'; str:=str+',"DESTINATION":"'+ frm_op_seae.t_op_seae.FieldByName('目的地').asstring+'"'; str:=str+',"NOBILL":"'+ frm_op_seae.t_op_seae.FieldByName('提单份数').asstring+'"'; str:=str+',"COPYNOBILLL":"'+ frm_op_seae.t_op_seae.FieldByName('副本提单份数').asstring+'"'; str:=str+',"ISSUETYPE":"'+ frm_op_seae.t_op_seae.FieldByName('签单方式').asstring+'"'; str:=str+',"ISSUEDATE":"'+ frm_op_seae.t_op_seae.FieldByName('签单日期').asstring+'"'; // str:=str+',"ISSUEPLACEID":"'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring))+'"'; str:=str+',"ISSUEPLACE":"'+ frm_op_seae.t_op_seae.FieldByName('签单地点').asstring+'"'; str:=str+',"BLFRT":"'+ frm_op_seae.t_op_seae.FieldByName('付费方式').asstring+'"'; str:=str+',"PREPARDAT":"'+ frm_op_seae.t_op_seae.FieldByName('预付地点').asstring+'"'; str:=str+',"PAYABLEAT":"'+ frm_op_seae.t_op_seae.FieldByName('到付地点').asstring+'"'; str:=str+',"SERVICE":"'+ frm_op_seae.t_op_seae.FieldByName('运输条款').asstring+'"'; str:=str+',"MARKS":"'+StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('唛头').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"HSCODE":"'+ frm_op_seae_assistant.t_op_seae_assistant.FieldByName('HS编码').asstring+'"'; str:=str+',"DESCRIPTION":"'+ StringReplace(frm_op_seae_assistant.t_op_seae_assistant.FieldByName('货物描述').asstring,'"','\"',[rfReplaceAll])+'"'; str:=str+',"PKGS":'+ frm_op_seae_assistant.t_op_seae_assistant.FieldByName('件数').asstring; str:=str+',"KINDPKGS":"'+frm_op_seae_assistant.t_op_seae_assistant.FieldByName('包装').asstring+'"'; str:=str+',"KGS":'+ frm_op_seae_assistant.t_op_seae_assistant.FieldByName('重量').asstring; str:=str+',"CBM":'+ frm_op_seae_assistant.t_op_seae_assistant.FieldByName('尺码').asstring; str:=str+',"CARRIER":"'+frm_op_seae.t_op_seae.FieldByName('船公司').asstring+'"'; str:=str+',"CARGOID":"'+ frm_op_seae.t_op_seae.FieldByName('货物标识').asstring+'"'; str:=str+',"DCLASS":"'+ frm_op_seae.t_op_seae.FieldByName('危险品分类').asstring+'"'; str:=str+',"DUNNO":"'+ frm_op_seae.t_op_seae.FieldByName('危险品编号').asstring+'"'; str:=str+',"DPAGE":""'; str:=str+',"DLABEL":""'; str:=str+',"LINKMAN":""'; if (frm_op_seae.t_op_seae.FieldByName('货物标识').asstring='R') then str:=str+',"TEMPID":"C"' else str:=str+',"TEMPID":""'; str:=str+',"TEMPSET":"'+ frm_op_seae.t_op_seae.FieldByName('设置温度').asstring+'"'; str:=str+',"REEFERF":"'+ frm_op_seae.t_op_seae.FieldByName('冷藏通风量').asstring+'"'; str:=str+',"HUMIDITY":"'+ frm_op_seae.t_op_seae.FieldByName('湿度').asstring+'"'; if frm_op_seae.t_op_seae.fieldbyname('是否自有箱').asboolean then str:=str+',"ISCONTAINERSOC":true' else str:=str+',"ISCONTAINERSOC":false'; str:=str+',"REMARK":""'; str:=str+',"EDIREMARK":"'+frm_op_seae_assistant.t_op_seae_assistant.FieldByName('EDI备注').asstring+'"'; str:=str+',"PONO":"'+ frm_op_seae.t_op_seae.FieldByName('委托编号').asstring+'"'; str:=str+',"TOTALNO":"'+ frm_op_seae.t_op_seae.FieldByName('件数大写').asstring+'"'; str:=str+',"TEMPMIN":"'+ frm_op_seae.t_op_seae.FieldByName('最低温度').asstring+'"'; str:=str+',"TEMPMAX":"'+ frm_op_seae.t_op_seae.FieldByName('最高温度').asstring+'"'; str:=str+',"OP":"'+ frm_op_seae.t_op_seae.FieldByName('客服员').asstring+'"'; str:=str+',"DOC":""'; str:=str+',"SALE":""'; str:=str+',"CUSTSERVICE":""'; str:=str+',"VGM_TIME":""'; str:=str+',"CUSTOMERNAME":"'+ frm_op_seae.t_op_seae.FieldByName('委托单位').asstring+'"'; str:=str+',"EMAIL":"'+getempemail(frm_op_seae.t_op_seae.FieldByName('操作员').asstring)+'"'; str:=str+',"FORWARDER":"'+ frm_op_seae.t_op_seae.FieldByName('货代公司').asstring+'"'; str:=str+',"SHIPAGENCY":""'; str:=str+',"CUSTOMSER":""'; str:=str+',"TRUCKER":""'; str:=str+',"AGENTID":""'; str:=str+',"CARRIERID":"'+ getcustedi(frm_op_seae.t_op_seae.FieldByName('船公司').asstring)+'"'; str:=str+',"YARDID":"'+ getcustedi(frm_op_seae.t_op_seae.FieldByName('场站').asstring)+'"'; str:=str+',"CUSTOMERID":""'; str:=str+',"FORWARDERID":""'; str:=str+',"SHIPAGENCYID":"'+frm_op_seae.t_op_seae.FieldByName('船代').asstring+'"'; str:=str+',"CUSTOMSERID":""'; str:=str+',"TRUCKERID":""'; str:=str+',"AGENTNAME":""'; str:=str+',"WEITUO":""'; str:=str+',"EDIATTN":""'; str:=str+',"EDIATTNTEL":""'; str:=str+',"EDIATTNEMAIL":""'; str:=str+',"CONSIGNEEDOORADDR":""'; str:=str+',"SHIPPERDOORADDR":""'; str:=str+',"SCACCODE":""'; str:=str+',"ITNCODE":""'; // str:=str+',"PREPARDAT_ID":"'+GetPortEdiID(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring)+'"'; str:=str+',"PAYABLEAT_ID":"'+trim(frm_op_seae.t_op_seae.fieldbyname('到付地点代码').asstring)+'"'; if (frm_op_seae.t_op_seae.FieldByName('场站').asstring='港捷丰场站(FF)') or (frm_op_seae.t_op_seae.FieldByName('场站').asstring='捷丰场站') then begin if (frm_op_seae.t_op_seae.FieldByName('防伪').AsBoolean) then str:=str+',"FEE_SELF":true' else str:=str+',"FEE_SELF":false'; end else begin str:=str+',"FEE_SELF":true'; end; strsql:='select * from t_op_ctn_fendan where 编号=' +#39+frm_op_seae_assistant.t_op_seae_assistant.fieldbyname('as_id').asstring+#39; aAdoQuery.Close; aAdoQuery.SQL.Text:=strsql; aAdoQuery.Open; aAdoQuery.First; str:=str+',"CtrnList":['; isfirst:=true; while not aAdoQuery.Eof do begin if (isfirst) then str:=str+'{' else str:=str+',{'; str:=str+'"CTNALL":"'+StringReplace(aAdoQuery.FieldByName('表现形式').asstring,'''','',[])+'"'; str:=str+',"CTNNUM":'+aAdoQuery.FieldByName('数量').asstring; str:=str+',"CNTRNO":"'+aAdoQuery.FieldByName('箱号').asstring+'"'; str:=str+',"SEALNO":"'+aAdoQuery.FieldByName('封号').asstring+'"'; str:=str+',"PKGS":"'+aAdoQuery.FieldByName('件数').asstring+'"'; str:=str+',"KINDPKGS":"'+aAdoQuery.FieldByName('包装').asstring+'"'; str:=str+',"KGS":"'+aAdoQuery.FieldByName('重量').asstring+'"'; str:=str+',"CBM":"'+aAdoQuery.FieldByName('尺码').asstring+'"'; str:=str+',"TAREWEIGHT":0'; str:=str+',"WEIGHTYPE":"累加"'; str:=str+',"WEIGHKGS":0'; str:=str+',"REMARK":""'; str:=str+'}'; isfirst:=false; aAdoQuery.Next; end; str:=str+']'; end; if (frm_data_share.t_crm_client_all.Locate('客户简称',frm_op_seae.t_op_seae.FieldByName('委托单位').asstring,[])) then begin str:=str+',"CUSTOMER_INFO":{'; str:=str+'"CODENAME":"'+frm_data_share.t_crm_client_all.fieldbyname('代码').AsString+'"'; str:=str+',"SHORTNAME":"'+frm_data_share.t_crm_client_all.fieldbyname('客户简称').AsString+'"'; str:=str+',"DESCRIPTION":"'+frm_data_share.t_crm_client_all.fieldbyname('客户全称').AsString+'"'; str:=str+',"CONTRACT_LIST":['; if (frm_op_seae.t_op_seae.FieldByName('客户邮件方案').AsString<>'') then begin aAdoQuery.Close; aAdoQuery.SQL.Clear; aAdoQuery.SQL.Add('select * from t_code_cust_mailproject_detail where 方案代码='''+frm_op_seae.t_op_seae.FieldByName('客户邮件方案').AsString+''' and (单据类型=''入货通知'' or 单据类型=''提单及下货纸'' or 单据类型=''费用确认'' )'); aAdoQuery.Open; aAdoQuery.First; isfirst:=true; typestr:='BC'; while not aAdoQuery.Eof do begin if (isfirst) then str:=str+'{' else str:=str+',{'; str:=str+'"EMAIL":"'+aAdoQuery.FieldByName('收件人').asstring+'"'; if (aAdoQuery.FieldByName('单据类型').asstring='入货通知') then typestr:='BC'; if (aAdoQuery.FieldByName('单据类型').asstring='提单及下货纸') then typestr:='TD'; if (aAdoQuery.FieldByName('单据类型').asstring='费用确认') then typestr:='ZD'; str:=str+',"TYPE":"'+typestr+'"'; str:=str+'}'; isfirst:=false; aAdoQuery.Next; end; end; str:=str+']'; str:=str+'}'; end; str:=str+'}'; str:=str+']'; str:=str+'}'; finally FreeAndNil(aAdoQuery); FreeAndNil(TempStr); end; Result:=str; end; end.