You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1946 lines
75 KiB
Plaintext
1946 lines
75 KiB
Plaintext
unit u_op_seae_edi_cosco;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB;
|
|
|
|
type
|
|
Tfrm_op_seae_edi_cosco = class(TForm)
|
|
bsBusinessSkinForm1: TbsBusinessSkinForm;
|
|
Label2: TLabel;
|
|
Edit2: TEdit;
|
|
Edit1: TEdit;
|
|
Label1: TLabel;
|
|
SaveDialog1: TSaveDialog;
|
|
bsSkinButton1: TbsSkinButton;
|
|
bsSkinButton2: TbsSkinButton;
|
|
Label3: TLabel;
|
|
Label4: TLabel;
|
|
Edit3: TEdit;
|
|
Edit4: TEdit;
|
|
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
|
|
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
|
|
bsSkinCheckRadioBox3: TbsSkinCheckRadioBox;
|
|
bsSkinCheckRadioBox4: TbsSkinCheckRadioBox;
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
private
|
|
function FormatListString(Old:TStrings;mCount,Strlength:integer):String;
|
|
function FormatEdiString(str:String;Strlength:integer=0):String;
|
|
function GetLengthword(var s: String; l: Integer;str:String): String;
|
|
procedure GetLengthTString(var sl:TStringList;l:integer);
|
|
function GetCntrEdi(cntrsize: String):String;
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
function GetpkgsEdi(pkgs: String): String;
|
|
procedure Edi_ZY;
|
|
procedure Edi_Jap;
|
|
procedure Edi_fs;
|
|
function GetShipEdiNO(Ship:String): String;
|
|
end;
|
|
|
|
var
|
|
frm_op_seae_edi_cosco: Tfrm_op_seae_edi_cosco;
|
|
|
|
implementation
|
|
|
|
uses u_op_seae, u_main, my_sys_function, u_data_share;
|
|
|
|
{$R *.dfm}
|
|
|
|
function Tfrm_op_seae_edi_cosco.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_cosco.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_cosco.GetLengthword(var s: String; l: Integer;str:String): String;
|
|
var
|
|
i:Integer;
|
|
b:Boolean;
|
|
begin
|
|
s:='';
|
|
if Length(str)<=l then begin
|
|
result:=str;
|
|
end else begin
|
|
b:=true;
|
|
s:=Copy(str,l+1,Length(str)-l);
|
|
str:=Copy(str,1,l);
|
|
result:='';
|
|
for i:=Length(str) downto 1 do begin
|
|
if ( not (str[i] in [' ',';',',','.',':','/','(',')','?','+','-'])) and b then
|
|
s:=str[i]+s
|
|
else begin
|
|
b:=false;
|
|
result:=str[i]+Result;
|
|
end;
|
|
end;
|
|
s:=s+' ';
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure Tfrm_op_seae_edi_cosco.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_cosco.FormatEdiString(str:String;Strlength:integer=0):String;
|
|
var
|
|
i:integer;
|
|
strC:widestring;
|
|
begin
|
|
strC:='';
|
|
for i:=1 to length(str) do
|
|
begin
|
|
if ((str[i]=#39) or (str[i]=':') or (str[i]='+') or (str[i]='?') or (str[i]=';')) then
|
|
begin
|
|
strC:=strC+'?'+str[i];
|
|
end
|
|
else
|
|
begin
|
|
strC:=strC+str[i];
|
|
end;
|
|
end;
|
|
result:=strC;
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_cosco.FormatListString(Old:TStrings;mCount,Strlength:integer):String;
|
|
var
|
|
i:integer;
|
|
NewStrs:TStrings;
|
|
mStr:String;
|
|
begin
|
|
Result:='';
|
|
NewStrs:=TStringList.Create;
|
|
for i:=0 to old.Count-1 do begin
|
|
if Length(old.Strings[i])<=Strlength then begin
|
|
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 i<NewStrs.Count then begin
|
|
Result:=Result+NewStrs.Strings[i];
|
|
end;
|
|
if i<mCount-1 then
|
|
Result:=Result+':';
|
|
end;
|
|
finally
|
|
FreeAndNil(NewStrs);
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_cosco.bsSkinButton2Click(Sender: TObject);
|
|
begin
|
|
close;
|
|
end;
|
|
|
|
procedure Tfrm_op_seae_edi_cosco.FormShow(Sender: TObject);
|
|
var
|
|
inifile1:Tinifile;
|
|
begin
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
edit1.text:=inifile1.ReadString('EDI','COSCOSEND','');
|
|
edit2.text:=inifile1.ReadString('EDI','COSCORECIEVE','COSCO');
|
|
edit4.text:=inifile1.ReadString('EDI','COSCOPORTLOAD','CNTAO');
|
|
edit3.text:=inifile1.ReadString('EDI','COSCOPORTDISCHARG','');
|
|
bsSkinCheckRadioBox1.Checked:=inifile1.ReadBool('EDI','COSCONOCTN',true);
|
|
inifile1.free;
|
|
end;
|
|
function Tfrm_op_seae_edi_cosco.GetCntrEdi(cntrsize: String):String;
|
|
var
|
|
aQuery:TADOQuery;
|
|
begin
|
|
aQuery:=CreateAdoQuery;
|
|
try
|
|
with aQuery do begin
|
|
Close;SQL.Clear;
|
|
SQL.Add('Select Edi代码 from t_code_ctn where 代码='''+cntrsize+'''');
|
|
Open;
|
|
if IsEmpty then
|
|
Result:=''
|
|
else
|
|
Result:=FieldByName('Edi代码').AsString;
|
|
end;
|
|
finally
|
|
FreeAndNil(aQuery);
|
|
end;
|
|
|
|
end;
|
|
procedure Tfrm_op_seae_edi_cosco.Edi_ZY;
|
|
var
|
|
str,sl,sl1:Tstringlist;
|
|
i,j,Count,L,M:integer;
|
|
strsql,strRmain,strtemp,S:string;
|
|
rs:Tadoquery;
|
|
aQuery2:Tadoquery;
|
|
wide_str:widestring;
|
|
k:integer;
|
|
inifile1:Tinifile;
|
|
strType:string;
|
|
strDatetime:string;
|
|
SenderCode,ReciverCode:string;
|
|
function GetShipperString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('发货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='16:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetConsigneString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('收货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='17:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetNOTIFYString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('通知人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='18:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
function GetMARKSString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('唛头').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='44:';
|
|
Result:=Result+FormatListString(TempStr,10,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
SenderCode:=trim(edit1.Text) ;
|
|
ReciverCode:=trim(edit2.Text) ;
|
|
strType:='9';
|
|
sl:=Tstringlist.Create;
|
|
sl1:=Tstringlist.Create;
|
|
|
|
|
|
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
|
|
begin
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
aQuery2:=CreateAdoQuery;
|
|
with aQuery2 do begin
|
|
Close;
|
|
SQL.Clear;
|
|
SQL.Add('select * from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+'''');
|
|
open;
|
|
end;
|
|
end;
|
|
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:IFCSUM:MANIFEST:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+FormatDateTime('YYMMDDHHMM', Now)+#39);
|
|
Count:=0;
|
|
|
|
str.Add('10::'
|
|
+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':'
|
|
+ trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)
|
|
+ '::::'
|
|
+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+':'
|
|
+trim(edit4.text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)
|
|
+#39); //船舶经营人
|
|
|
|
|
|
str.Add('11:'
|
|
+'SOF'+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)
|
|
+#39); //船舶经营人
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
if frm_data_share.t_code_free.locate('代码',aQuery2.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end else begin
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end;
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
str.Add ('12:'+trim(aQuery2.fieldbyname('主提单号').asstring)+':'
|
|
+':::::' // 收货地
|
|
+trim(edit4.text)+':'
|
|
+trim(aQuery2.fieldbyname('装货港').asstring)+':'
|
|
+'CY-CY'+':'
|
|
+strtemp+':'
|
|
+FormatDateTime('YYYYMMDD',aQuery2.fieldbyname('开船日期').asdatetime)+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text)+':'
|
|
+trim(aQuery2.fieldbyname('卸货港').asstring)+':'
|
|
+trim(edit3.Text)+':'
|
|
+trim(aQuery2.fieldbyname('交货地点').asstring)
|
|
+#39);
|
|
end else begin
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'
|
|
+':::::' // 收货地
|
|
+trim(edit4.text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':'
|
|
+'CY-CY'+':'
|
|
+strtemp+':'
|
|
+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':'
|
|
+trim(edit3.Text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring)
|
|
+#39);
|
|
end;
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001:'+strtemp+':' // 货物标识 S/R/D/O
|
|
+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);
|
|
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) +':'
|
|
+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;
|
|
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
sl1.Text:=FormatEdiString(aQuery2.fieldbyname('货物描述').AsString)
|
|
else
|
|
sl1.Text:=FormatEdiString(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);
|
|
|
|
Count:=Count+11;
|
|
if not bsSkinCheckRadioBox1.Checked then begin
|
|
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end else begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end
|
|
else
|
|
begin
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:IFCSUM:MANIFEST:'+trim(strType)+':'+ SenderCode+':'+ ReciverCode +':'+FormatDateTime('YYMMDDHHMM', Now)+#39);
|
|
str.Add('10::'
|
|
+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)
|
|
+ '::::'
|
|
+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+':'
|
|
+trim(edit4.Text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)
|
|
+#39); //船舶经营人
|
|
str.Add('11:'
|
|
+'SOF'+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring)
|
|
+#39); //船舶经营人
|
|
|
|
Count:=0;
|
|
for k:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
|
|
begin
|
|
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[k]));
|
|
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
aQuery2:=CreateAdoQuery;
|
|
with aQuery2 do begin
|
|
Close;
|
|
SQL.Clear;
|
|
SQL.Add('select * from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+'''');
|
|
open;
|
|
end;
|
|
end;
|
|
|
|
{
|
|
str.Add('11::'
|
|
+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':'
|
|
+ 'V.'+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)
|
|
+ '::::::::::' +#39); //船舶经营人
|
|
}
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
if frm_data_share.t_code_free.locate('代码',aQuery2.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end else begin
|
|
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end;
|
|
if bsSkinCheckRadioBox2.Checked then begin
|
|
str.Add ('12:'+trim(aQuery2.fieldbyname('主提单号').asstring)+':'
|
|
+':::::' // 收货地
|
|
+trim(edit4.text)+':'
|
|
+trim(aQuery2.fieldbyname('装货港').asstring)+':'
|
|
+'CY-CY'+':'
|
|
+strtemp+':'
|
|
+FormatDateTime('YYYYMMDD',aQuery2.fieldbyname('开船日期').asdatetime)+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text)+':'
|
|
+trim(aQuery2.fieldbyname('卸货港').asstring)+':'
|
|
+trim(edit3.Text)+':'
|
|
+trim(aQuery2.fieldbyname('交货地点').asstring)
|
|
+#39);
|
|
end else begin
|
|
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring)+':'
|
|
+':::::' // 收货地
|
|
+trim(edit4.Text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring)+':'
|
|
+'CY-CY'+':'
|
|
+strtemp+':'
|
|
+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)+':'
|
|
+trim(edit3.Text)+':'
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring)
|
|
+#39);
|
|
end;
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001:'+strtemp+':' // 货物标识 S/R/D/O
|
|
+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);
|
|
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) +':'
|
|
+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;
|
|
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
sl1.Text:=FormatEdiString(aQuery2.fieldbyname('货物描述').AsString)
|
|
else
|
|
sl1.Text:=FormatEdiString(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);
|
|
|
|
Count:=Count+11;
|
|
|
|
if not bsSkinCheckRadioBox1.Checked then begin
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end else begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end;
|
|
freeandnil(sl);
|
|
freeandnil(sl1);
|
|
|
|
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('船名').asstring+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;
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
inifile1.WriteString('EDI','COSCOSEND',edit1.text);
|
|
inifile1.WriteString('EDI','COSCORECIEVE',edit2.text);
|
|
inifile1.WriteString('EDI','COSCOPORTLOAD',edit4.text);
|
|
inifile1.WriteString('EDI','COSCOPORTDISCHARG',edit3.text);
|
|
inifile1.WriteBool('EDI','COSCONOCTN',bsSkinCheckRadioBox1.checked);
|
|
inifile1.free;
|
|
|
|
close;
|
|
end;
|
|
|
|
|
|
/// \日本货
|
|
procedure Tfrm_op_seae_edi_cosco.Edi_Jap;
|
|
var
|
|
str,sl,sl1:Tstringlist;
|
|
i,j,Count,L,M:integer;
|
|
strsql,strRmain,strtemp,S:string;
|
|
rs:Tadoquery;
|
|
aQuery2:Tadoquery;
|
|
wide_str:widestring;
|
|
k:integer;
|
|
inifile1:Tinifile;
|
|
strType:string;
|
|
strDatetime,str_LoadPort:string;
|
|
SenderCode,ReciverCode:string;
|
|
|
|
|
|
function GetShipperString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('发货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='16:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetConsigneString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('收货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='17:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetNOTIFYString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('通知人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='18:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
function GetMARKSString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('唛头').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='44:001:';
|
|
Result:=Result+FormatListString(TempStr,10,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
SenderCode:=trim(edit1.Text) ;
|
|
ReciverCode:=trim(edit2.Text) ;
|
|
strType:='9';
|
|
sl:=Tstringlist.Create;
|
|
sl1:=Tstringlist.Create;
|
|
|
|
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
|
|
begin
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
aQuery2:=CreateAdoQuery;
|
|
with aQuery2 do
|
|
begin
|
|
Close;
|
|
SQL.Clear;
|
|
SQL.Add('select * from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+'''');
|
|
open;
|
|
end;
|
|
end;
|
|
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:IFCSUM:MANIFEST:'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+FormatDateTime('YYYYMMDDHHMM', Now)+#39);
|
|
Count:=0;
|
|
|
|
if Pos(',',trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring))>0 then
|
|
str_LoadPort:=Copy(trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring),1,Pos(',',trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring))-1)
|
|
else str_LoadPort:=trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring);
|
|
|
|
str.Add('10:' //1记录类型标识 2船名代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) //3船名
|
|
+ ':' //4舶国籍代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) //5航次
|
|
+ ':' //6航线代码
|
|
+ ':' //7航线
|
|
+ ':'
|
|
+ ':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+'2000' //9离港日期
|
|
+':'+trim(edit4.text) // 10离港地点代码
|
|
+':'+str_LoadPort //11离港地点
|
|
+ ':' //8到港日期 //12下一挂港代码
|
|
+ ':' //13下一挂港
|
|
+ ':' //14集装箱箱数
|
|
+#39); //船舶经营人
|
|
|
|
|
|
str.Add('11:'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring) //1 记录类型标识 2 船公司(承运人)代码
|
|
+':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('预抵日期').asdatetime)+'2000' //3 船公司(承运人)
|
|
+#39); //船舶经营人
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
if frm_data_share.t_code_free.locate('代码',aQuery2.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end;
|
|
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
str.Add ('12:'+trim(aQuery2.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':' // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(aQuery2.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(aQuery2.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式
|
|
+':'+FormatDateTime('YYYYMMDD',aQuery2.fieldbyname('开船日期').asdatetime)+'2000' //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(aQuery2.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(aQuery2.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+#39);
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('分提单号').asstring) // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式
|
|
+':'+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+'2000' //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+#39);
|
|
end;
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001' // 1 记录类型标识 2货物序号
|
|
+':'+strtemp // 3 货物标识 S/R/D/O
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 4 件数
|
|
+':' // 5 包装类型代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 6 包装类型
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 7 货毛重
|
|
+'::' // 8 货净重
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 9 货尺码
|
|
+#39);
|
|
|
|
|
|
|
|
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) +':'
|
|
+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;
|
|
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
sl1.Text:=FormatEdiString(aQuery2.fieldbyname('货物描述').AsString)
|
|
else
|
|
sl1.Text:=FormatEdiString(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:001:'+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:001:'+FormatEdiString(sl.Strings[L],0)+':';
|
|
end;
|
|
M:=M+1;
|
|
end;
|
|
S:=S+'''';
|
|
Str.Add(S);
|
|
|
|
Count:=Count+11;
|
|
if not bsSkinCheckRadioBox1.Checked then
|
|
begin
|
|
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do
|
|
begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end
|
|
else
|
|
begin
|
|
|
|
if Pos(',',trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring))>0 then
|
|
str_LoadPort:=Copy(trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring),1,Pos(',',trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring))-1)
|
|
else str_LoadPort:=trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring);
|
|
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:IFCSUM:MANIFEST:'+trim(strType)+':'+ SenderCode+':'+ ReciverCode +':'+FormatDateTime('YYMMDDHHMM', Now)+#39);
|
|
str.Add('10:' //1记录类型标识 2船名代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) //3船名
|
|
+ ':' //4舶国籍代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) //5航次
|
|
+ ':' //6航线代码
|
|
+ ':' //7航线
|
|
+ ':'
|
|
+ ':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+'2000' //9离港日期
|
|
+':'+trim(edit4.text) // 10离港地点代码
|
|
+':'+str_LoadPort //11离港地点
|
|
+ ':' //8到港日期 //12下一挂港代码
|
|
+ ':' //13下一挂港
|
|
+ ':' //14集装箱箱数
|
|
+#39); //船舶经营人
|
|
|
|
|
|
str.Add('11:'+GetShipEdiNO(frm_op_seae.t_op_seae.fieldbyname('船公司').asstring) //1 记录类型标识 2 船公司(承运人)代码
|
|
+':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('预抵日期').asdatetime)+'2000' //3 船公司(承运人)
|
|
+#39); //船舶经营人
|
|
|
|
Count:=0;
|
|
for k:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
|
|
begin
|
|
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[k]));
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
aQuery2:=CreateAdoQuery;
|
|
with aQuery2 do
|
|
begin
|
|
Close;
|
|
SQL.Clear;
|
|
SQL.Add('select * from t_op_seae_assistant where 编号='''+frm_op_seae.t_op_seae.fieldbyname('编号').AsString+'''');
|
|
open;
|
|
end;
|
|
end;
|
|
|
|
{
|
|
str.Add('11::'
|
|
+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) +':'
|
|
+ 'V.'+trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring)
|
|
+ '::::::::::' +#39); //船舶经营人
|
|
}
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
if frm_data_share.t_code_free.locate('代码',aQuery2.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
end;
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
begin
|
|
str.Add ('12:'+trim(aQuery2.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':' // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(aQuery2.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(aQuery2.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式
|
|
+':'+FormatDateTime('YYYYMMDDHH',aQuery2.fieldbyname('开船日期').asdatetime) //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(aQuery2.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(aQuery2.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+':' // 10 中转标志
|
|
+#39);
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('分提单号').asstring) // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式
|
|
+':'+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime)+'2000' //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+':' // 10 中转标志
|
|
+#39);
|
|
end;
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001' // 1 记录类型标识 2货物序号
|
|
+':'+strtemp // 3 货物标识 S/R/D/O
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 4 件数
|
|
+':' // 5 包装类型代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 6 包装类型
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 7 货毛重
|
|
+'::' // 8 货净重
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 9 货尺码
|
|
+#39);
|
|
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) +':'
|
|
+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;
|
|
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
sl1.Text:=FormatEdiString(aQuery2.fieldbyname('货物描述').AsString)
|
|
else
|
|
sl1.Text:=FormatEdiString(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:001:'+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:001:'+FormatEdiString(sl.Strings[L],0)+':';
|
|
end;
|
|
M:=M+1;
|
|
end;
|
|
S:=S+'''';
|
|
Str.Add(S);
|
|
|
|
Count:=Count+11;
|
|
|
|
if not bsSkinCheckRadioBox1.Checked then begin
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do
|
|
begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end;
|
|
freeandnil(sl);
|
|
freeandnil(sl1);
|
|
|
|
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('船名').asstring+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;
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
inifile1.WriteString('EDI','COSCOSEND',edit1.text);
|
|
inifile1.WriteString('EDI','COSCORECIEVE',edit2.text);
|
|
inifile1.WriteString('EDI','COSCOPORTLOAD',edit4.text);
|
|
inifile1.WriteString('EDI','COSCOPORTDISCHARG',edit3.text);
|
|
inifile1.WriteBool('EDI','COSCONOCTN',bsSkinCheckRadioBox1.checked);
|
|
inifile1.free;
|
|
|
|
close;
|
|
end;
|
|
|
|
|
|
/// 釜山
|
|
procedure Tfrm_op_seae_edi_cosco.Edi_FS;
|
|
var
|
|
str,sl,sl1:Tstringlist;
|
|
i,j,Count,L,M:integer;
|
|
strsql,strRmain,strtemp,S:string;
|
|
rs:Tadoquery;
|
|
aQuery2:Tadoquery;
|
|
wide_str:widestring;
|
|
k:integer;
|
|
inifile1:Tinifile;
|
|
strType:string;
|
|
strDatetime:string;
|
|
SenderCode,ReciverCode:string;
|
|
function GetShipperString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('发货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='16:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetConsigneString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('收货人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='17:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
function GetNOTIFYString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aquery2.fieldbyname('通知人代码').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='18:';
|
|
Result:=Result+':';
|
|
Result:=Result+FormatListString(TempStr,6,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
function GetMARKSString:String;
|
|
var
|
|
TempStr:TStringList;
|
|
begin
|
|
TempStr:=TStringList.Create;
|
|
try
|
|
if bsSkinCheckRadioBox2.Checked then
|
|
TempStr.Text:=FormatEdiString(aQuery2.fieldbyname('唛头').AsString)
|
|
else
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('唛头').AsString);
|
|
GetLengthTString(TempStr,35);
|
|
Result:='44:001:';
|
|
Result:=Result+FormatListString(TempStr,10,35)+'''';
|
|
finally
|
|
FreeAndNil(TempStr);
|
|
end;
|
|
end;
|
|
|
|
|
|
begin
|
|
SenderCode:=trim(edit1.Text) ;
|
|
ReciverCode:=trim(edit2.Text) ;
|
|
strType:='9';
|
|
sl:=Tstringlist.Create;
|
|
sl1:=Tstringlist.Create;
|
|
|
|
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
|
|
begin
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:CN1101::'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+FormatDateTime('YYYYMMDDHHMMSSS', Now)+':1.0'+#39);
|
|
Count:=0;
|
|
|
|
str.Add('10:a' //1记录类型标识 2船名代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) //3船名
|
|
+ ':' //4舶国籍代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) //5航次
|
|
+ ':' //6航线代码
|
|
+ ':' //7航线
|
|
+ ':' //8预计到达日期
|
|
+ ':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime) //9离港日期
|
|
+':'+trim(edit4.text) // 10离港地点代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) //11离港地点
|
|
+ ':' //12下一挂港代码
|
|
+ ':' //13下一挂港
|
|
+ ':' //14集装箱箱数
|
|
+ ':1' //15运输方式代码
|
|
+#39); //船舶经营人
|
|
|
|
|
|
str.Add('11:'+'00036' //1 记录类型标识 2 船公司(承运人)代码
|
|
+':' //3 船公司(承运人)
|
|
+#39); //船舶经营人
|
|
|
|
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
|
|
|
|
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':' // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式 ???
|
|
+':'+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime) //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+':' // 17 分提运单号
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 18 件数
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 19 包装种类代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 20 货物总毛重
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 21 货物总毛重
|
|
+':' // 22 托运货物价值
|
|
+':' // 23 码头作业指令代码
|
|
+':' // 24 拆箱人代码
|
|
+':' // 25 前一海关单证号
|
|
+':' // 26 前一海关单证类型代码
|
|
+':' // 26 货物海关处理状态代码(1~99)
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+':' // 10 提单签发地
|
|
+':' // 11 提单签发地
|
|
+':' // 12 提单签发地
|
|
+':' // 13 提单签发地
|
|
+#39);
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001' // 1 记录类型标识 2货物序号
|
|
+':'+strtemp // 3 货物标识 S/R/D/O
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 4 件数
|
|
+':' // 5 包装类型代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 6 包装类型
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 7 货毛重
|
|
+'::' // 8 货净重
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 9 货尺码
|
|
+#39);
|
|
|
|
|
|
|
|
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) +':'
|
|
+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;
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
sl1.Text:=FormatEdiString(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:001:'+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:001:'+FormatEdiString(sl.Strings[L],0)+':';
|
|
end;
|
|
M:=M+1;
|
|
end;
|
|
S:=S+'''';
|
|
Str.Add(S);
|
|
|
|
Count:=Count+11;
|
|
if not bsSkinCheckRadioBox1.Checked then
|
|
begin
|
|
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do
|
|
begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end
|
|
else
|
|
begin
|
|
str:=Tstringlist.Create;
|
|
str.Clear;
|
|
str.Add('00:CN1101::'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+FormatDateTime('YYYYMMDDHHMMSSS', Now)+':1.0'+#39);
|
|
str.Add('10:a' //1记录类型标识 2船名代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('船名').asstring) //3船名
|
|
+ ':' //4舶国籍代码
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('航次').asstring) //5航次
|
|
+ ':' //6航线代码
|
|
+ ':' //7航线
|
|
+ ':' //8预计到达日期
|
|
+ ':'+ FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime) //9离港日期
|
|
+':'+trim(edit4.text) // 10离港地点代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) //11离港地点
|
|
+ ':' //12下一挂港代码
|
|
+ ':' //13下一挂港
|
|
+ ':' //14集装箱箱数
|
|
+ ':1' //15运输方式代码
|
|
+#39); //船舶经营人
|
|
|
|
|
|
str.Add('11:'+'00036' //1 记录类型标识 2 船公司(承运人)代码
|
|
+':' //3 船公司(承运人)
|
|
+#39); //船舶经营人
|
|
|
|
Count:=0;
|
|
for k:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
|
|
begin
|
|
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[k]));
|
|
|
|
if frm_data_share.t_code_free.locate('代码',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
begin
|
|
strtemp:=copy(frm_data_share.t_code_free.fieldbyname('代码').asstring,1,1);
|
|
end
|
|
else
|
|
begin
|
|
strtemp:='P';
|
|
end;
|
|
|
|
|
|
|
|
str.Add ('12:'+trim(frm_op_seae.t_op_seae.fieldbyname('主提单号').asstring) //1 记录类型标识 2 提单号
|
|
+':' // 3前程运输船名代码
|
|
+':' // 4 前程运输船名
|
|
+':' // 5 前程运输航次
|
|
+':'+trim(edit4.text) // 6 收货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 7 收货地
|
|
+':'+trim(edit4.text) // 8 装货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('装货港').asstring) // 9 装货港
|
|
+':'+'CY-CY' //10 运输条款
|
|
+':'+strtemp // 11 付款方式 ???
|
|
+':'+FormatDateTime('YYYYMMDD',frm_op_seae.t_op_seae.fieldbyname('开船日期').asdatetime) //12 装货日期
|
|
+':' // 13检疫代码
|
|
+':' // 14 签发日期
|
|
+':' // 15 币种
|
|
+':' // 16 汇率
|
|
+':' // 17 分提运单号
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 18 件数
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 19 包装种类代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 20 货物总毛重
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 21 货物总毛重
|
|
+':' // 22 托运货物价值
|
|
+':' // 23 码头作业指令代码
|
|
+':' // 24 拆箱人代码
|
|
+':' // 25 前一海关单证号
|
|
+':' // 26 前一海关单证类型代码
|
|
+':' // 26 货物海关处理状态代码(1~99)
|
|
+#39);
|
|
|
|
str.Add ('13:'+trim(edit3.text) // 1 记录类型标识 2 卸货港代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring) // 3 卸货港
|
|
+':'+trim(edit3.Text) // 4 交货地代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring) // 5 交货地
|
|
+':' // 6 中转港代码
|
|
+':' // 7 中转港
|
|
+':' // 8 提单签发地代码
|
|
+':' // 9 提单签发地
|
|
+':' // 10 提单签发地
|
|
+':' // 11 提单签发地
|
|
+':' // 12 提单签发地
|
|
+':' // 13 提单签发地
|
|
+#39);
|
|
Str.Add(GetShipperString);
|
|
Str.Add(GetConsigneString);
|
|
Str.Add(GetNOTIFYString);
|
|
|
|
IF trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' THEN
|
|
strtemp:='S'
|
|
else
|
|
strtemp:=trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring);
|
|
|
|
str.Add ('41:001' // 1 记录类型标识 2货物序号
|
|
+':'+strtemp // 3 货物标识 S/R/D/O
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('件数').asstring) // 4 件数
|
|
+':' // 5 包装类型代码
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring) // 6 包装类型
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('重量').asstring) // 7 货毛重
|
|
+'::' // 8 货净重
|
|
+trim(frm_op_seae.t_op_seae.fieldbyname('尺码').asstring) // 9 货尺码
|
|
+#39);
|
|
|
|
|
|
|
|
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) +':'
|
|
+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;
|
|
Str.Add(GetMARKSString);
|
|
// Str.Add(GetCARGODESCRIPTIONString);
|
|
|
|
sl1.Text:=FormatEdiString(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:001:'+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:001:'+FormatEdiString(sl.Strings[L],0)+':';
|
|
end;
|
|
M:=M+1;
|
|
end;
|
|
S:=S+'''';
|
|
Str.Add(S);
|
|
|
|
Count:=Count+11;
|
|
if not bsSkinCheckRadioBox1.Checked then
|
|
begin
|
|
|
|
strRmain:='';
|
|
try
|
|
rs:=Tadoquery.Create(application);
|
|
rs.Connection := frm_main.db;
|
|
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
|
|
rs.First;
|
|
while not rs.Eof do
|
|
begin
|
|
if rs.fieldbyname('备注').asstring='' then
|
|
strtemp:='F'
|
|
else
|
|
strtemp:=copy(rs.fieldbyname('备注').asstring,1,1);
|
|
str.Add ('51:001:'+trim(rs.fieldbyname('箱号').asstring)+':'+trim(rs.fieldbyname('封号').asstring)+':'+Trim(rs.fieldbyname('尺寸').asstring+rs.fieldbyname('箱型').asstring)+':'+strtemp+':'
|
|
+trim(IntToStr(rs.fieldbyname('件数').AsInteger))+':'+trim(FloatToStr(rs.fieldbyname('重量').AsFloat))+':'+''''
|
|
);
|
|
rs.Next;
|
|
end;
|
|
end;
|
|
rs.Close;
|
|
rs.Destroy;
|
|
except
|
|
on e:exception do
|
|
begin
|
|
rs.Close;
|
|
rs.Destroy;
|
|
exit;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
str.Add ('51:::::::::::::::'+'''');
|
|
end;
|
|
|
|
end;
|
|
count:=str.count;
|
|
str.Add ('99:'+ inttostr(count+1)+#39);
|
|
end;
|
|
freeandnil(sl);
|
|
freeandnil(sl1);
|
|
|
|
SaveDialog1.FileName:=frm_op_seae.t_op_seae.fieldbyname('船名').asstring+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;
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
inifile1.WriteString('EDI','COSCOSEND',edit1.text);
|
|
inifile1.WriteString('EDI','COSCORECIEVE',edit2.text);
|
|
inifile1.WriteString('EDI','COSCOPORTLOAD',edit4.text);
|
|
inifile1.WriteString('EDI','COSCOPORTDISCHARG',edit3.text);
|
|
inifile1.WriteBool('EDI','COSCONOCTN',bsSkinCheckRadioBox1.checked);
|
|
inifile1.free;
|
|
|
|
close;
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_cosco.bsSkinButton1Click(Sender: TObject);
|
|
begin
|
|
if bsSkinCheckRadioBox3.Checked then
|
|
Edi_Jap
|
|
else
|
|
if bsSkinCheckRadioBox4.Checked then
|
|
Edi_fs
|
|
else Edi_zy;
|
|
end;
|
|
|
|
end.
|