|
|
unit u_op_seae_edi_wh;
|
|
|
|
|
|
interface
|
|
|
|
|
|
uses
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,IdFTP,IdFTPCommon,
|
|
|
Dialogs, BusinessSkinForm, StdCtrls, bsSkinCtrls,inifiles, DB, ADODB;
|
|
|
|
|
|
type
|
|
|
Tfrm_op_seae_edi_wh = 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;
|
|
|
bsSkinRadioGroup2: TbsSkinRadioGroup;
|
|
|
bsSkinButton4: TbsSkinButton;
|
|
|
bsSkinGroupBox1: TbsSkinGroupBox;
|
|
|
Label4: TLabel;
|
|
|
Label5: TLabel;
|
|
|
Label6: TLabel;
|
|
|
Label7: TLabel;
|
|
|
Edit4: TEdit;
|
|
|
Edit5: TEdit;
|
|
|
Edit6: TEdit;
|
|
|
Edit7: TEdit;
|
|
|
t_op_ams: TADOQuery;
|
|
|
t_op_ams1: TDataSource;
|
|
|
t_op_seae_assistant: TADOQuery;
|
|
|
Label8: TLabel;
|
|
|
Edit8: TEdit;
|
|
|
procedure bsSkinButton2Click(Sender: TObject);
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
procedure bsSkinButton1Click(Sender: TObject);
|
|
|
procedure bsSkinButton3Click(Sender: TObject);
|
|
|
procedure bsSkinButton4Click(Sender: TObject);
|
|
|
private
|
|
|
function isEditrue(DataSet:TDataSet): boolean; //判断必填项
|
|
|
function GetStrNum(str:String):integer;//判断数字位数
|
|
|
function FormatListString(Old:TStrings;mCount,Strlength:integer):String;//根据长度要求格式化字符串
|
|
|
function FormatEdiString(str:String;Strlength:integer=0):String;//特殊字符加 :
|
|
|
function CreateEdiFile:TStrings;//订舱报文
|
|
|
function GetLengthword(var s: String; l: Integer;str:String): String;//根据长度要求截取字符串
|
|
|
procedure GetLengthTString(var sl:TStringList;l:integer);//根据长度格式化 tstringlist
|
|
|
function IsZhongwen(Str:String):Boolean;//是否包含中文或双字节字符
|
|
|
|
|
|
|
|
|
{ Private declarations }
|
|
|
public
|
|
|
{ Public declarations }
|
|
|
|
|
|
function GetPortEdiID(Port:String): String;
|
|
|
|
|
|
function GetMlbCount(aDataset:TDataset;fldName:string): String;
|
|
|
|
|
|
function GetvesselEdi(avessel: String): String;
|
|
|
|
|
|
|
|
|
function GetPkgCode(Pkg:String):String;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function GetCorpsString(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
|
|
|
|
|
|
|
|
|
function Record00(strType,SenderCode,ReciverCode:string):String;
|
|
|
|
|
|
function Record02(aDataset:TDataset):String;
|
|
|
|
|
|
function Record03(aDataset:TDataset):String;
|
|
|
|
|
|
function Record11(aDataset:TDataset):String;
|
|
|
function Record12(aDataset:TDataset):String;
|
|
|
function Record14(aDataset:TDataset):String;
|
|
|
function Record15(aDataset:TDataset):String;
|
|
|
function Record17(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
function Record20_21_22(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
function Record41(aDataset:TDataset):String;
|
|
|
function Record43(aDataset:TDataset):String;
|
|
|
function Record44_47(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
function Record48(aDataset:TDataset):TStringlist;
|
|
|
function ControlLines:String;
|
|
|
|
|
|
end;
|
|
|
|
|
|
var
|
|
|
frm_op_seae_edi_wh: Tfrm_op_seae_edi_wh;
|
|
|
|
|
|
implementation
|
|
|
|
|
|
uses u_op_seae, u_main, my_sys_function, u_data_share;
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.ControlLines:String;
|
|
|
var
|
|
|
TempStr:TStringList;
|
|
|
s,fldname:string;
|
|
|
i:integer;
|
|
|
begin
|
|
|
result:='';
|
|
|
TempStr:=TStringList.Create;
|
|
|
try
|
|
|
s:='';
|
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('发货人代码').AsString);
|
|
|
for i:=0 to TempStr.Count-1 do
|
|
|
begin
|
|
|
s:=s+TempStr[i]
|
|
|
end;
|
|
|
if Length(s)>144 then
|
|
|
begin
|
|
|
result:='发货人代码'+'详细信息超过144字符,超出部分请在基本信息货描中填写格式为:*加多出部分'+#13#10
|
|
|
end;
|
|
|
|
|
|
s:='';
|
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('收货人代码').AsString);
|
|
|
for i:=0 to TempStr.Count-1 do
|
|
|
begin
|
|
|
s:=s+TempStr[i]
|
|
|
end;
|
|
|
if Length(s)>144 then
|
|
|
begin
|
|
|
result:=result+'收货人代码'+'详细信息超过144字符,超出部分请在基本信息货描中填写格式为:**加多出部分'+#13#10
|
|
|
end;
|
|
|
|
|
|
s:='';
|
|
|
TempStr.Text:=FormatEdiString(frm_op_seae.t_op_seae.fieldbyname('通知人代码').AsString);
|
|
|
for i:=0 to TempStr.Count-1 do
|
|
|
begin
|
|
|
s:=s+TempStr[i]
|
|
|
end;
|
|
|
if Length(s)>144 then
|
|
|
begin
|
|
|
result:=result+'通知人代码'+'详细信息超过144字符,超出部分请在基本信息货描中填写格式为:***加多出部分'+#13#10
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(TempStr);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.GetPortEdiID(Port:String): String;
|
|
|
var
|
|
|
aQuery:TADOQuery;
|
|
|
begin
|
|
|
aQuery:=CreateAdoQuery;
|
|
|
try
|
|
|
with aQuery do begin
|
|
|
Close;SQL.Clear;
|
|
|
SQL.Add('Select EDI代码 from t_code_disport where 英文名='''+Port+'''');
|
|
|
Open;
|
|
|
if not IsEmpty then
|
|
|
Result:=Trim(FieldByName('EDI代码').asstring)
|
|
|
else
|
|
|
Result:='';
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.GetPkgCode(Pkg: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 代码='''+pkg+'''');
|
|
|
Open;
|
|
|
if not IsEmpty then
|
|
|
Result:=Trim(FieldByName('EDI代码').asstring)
|
|
|
else
|
|
|
Result:='';
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.GetMlbCount(aDataset:TDataset;fldName:string): String;
|
|
|
begin
|
|
|
Result:='3';
|
|
|
if aDataset.fieldbyname(fldName).asstring='ONE' then
|
|
|
Result:='1'
|
|
|
else if aDataset.fieldbyname(fldName).asstring='TWO' then
|
|
|
Result:='2'
|
|
|
else if aDataset.fieldbyname(fldName).asstring='THREE' then
|
|
|
Result:='3'
|
|
|
else if aDataset.fieldbyname(fldName).asstring='FOUR' then
|
|
|
Result:='4'
|
|
|
else Result:='3';
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.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:=''
|
|
|
else
|
|
|
Result:=FieldByName('船舶呼号').AsString;
|
|
|
end;
|
|
|
finally
|
|
|
FreeAndNil(aQuery);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.GetCorpsString(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
var
|
|
|
TempStr:TStringList;
|
|
|
s:string;
|
|
|
i:integer;
|
|
|
begin
|
|
|
TempStr:=TStringList.Create;
|
|
|
try
|
|
|
TempStr.Text:=FormatEdiString(aDataset.fieldbyname(fldName).AsString);
|
|
|
for i:=0 to TempStr.Count-1 do
|
|
|
begin
|
|
|
s:=s+TempStr[i]
|
|
|
end;
|
|
|
Result:=recordno+':'; // 3 SHIPPER 发货人 X(144) M
|
|
|
Result:=Result+':'+s;
|
|
|
finally
|
|
|
FreeAndNil(TempStr);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record00(strType,SenderCode,ReciverCode:string):String;
|
|
|
begin
|
|
|
result:='00:IFTMBF:BOOKING'+':'+trim(strType)+':'+ SenderCode+':'+ReciverCode+':'+GetDatetime(datetimetostr(now),1)+#39;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record02(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='02:'+':'+trim(aDataset.fieldbyname('订舱单号').asstring) // 2BOOKING NO. ID 运编号
|
|
|
+':'+trim(aDataset.fieldbyname('主提单号').asstring) // 3B\L NO. 提单号
|
|
|
+':'+ trim(aDataset.fieldbyname('运输条款').asstring) // 4DELIVERY TERM 交货条款
|
|
|
+':' // 5BOOKING PARTY CODE 订舱人代码
|
|
|
+':10001133' // 6ISSUE PARTY CODE 签单人代码 ?
|
|
|
+':WAN HAI LINES CO.,LTD' // 7ISSUE PARTY 签单人说明 ?
|
|
|
+':' // 8APPLICANT 询价单位 ?
|
|
|
+':' // 9 FOB BK PARTY 国外订舱单位
|
|
|
+':' // 10 B/L TRANSHIP ID 转船标识
|
|
|
+':' // 11 BATCH ID 分批
|
|
|
+':'+formatdatetime('YYYYMMDD',aDataset.fieldbyname('开船日期').value) //12 SHIPMENT DATE 装期 // 12 SHIPMENT DATE 装期
|
|
|
+':' // 13 EXPIRY DATE 效期 9(8) CCYYMMDD C
|
|
|
+':'+ trim(aDataset.fieldbyname('运费协议号').asstring) //14 QUOTATION NO. 运费协议号
|
|
|
+':' //15 CHARGE TYPE 费率本代码
|
|
|
+':' //16 S/C NO. 服务合同号 X(15)
|
|
|
+':' // 17 BOND NO. X(15) C
|
|
|
+':' //18 SLOT CHARTER ID 舱位互用标识 X(1) C
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record03(aDataset:TDataset):String;
|
|
|
var str_pay:string;
|
|
|
begin
|
|
|
|
|
|
if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then
|
|
|
str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('预付地点').asstring);
|
|
|
|
|
|
if Pos('COLLECT',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then
|
|
|
str_pay:=trim(frm_op_seae.t_op_seae.fieldbyname('到付地点').asstring);
|
|
|
|
|
|
result:='03:'+':02' // 2TYPE OF B/L FORM 提单类型
|
|
|
+':'+GetPortEdiID(trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring)) // 3PLACE OF B/L ISSUE CODE 提单签发地代码
|
|
|
+':'+ trim(frm_op_seae.t_op_seae.fieldbyname('签单地点').asstring) // 4 PLACE OF B/L ISSUE 提单签发地 X(35) C/M
|
|
|
+':'+ formatdatetime('YYYYMMDD',aDataset.fieldbyname('签单日期').AsDatetime) // 5 DATE OF ISSUE 签发日期
|
|
|
+':' +GetMlbCount(aDataset,'提单份数'); //6 NUMBERS OF ORIGINAL B/L 正本提单份数
|
|
|
|
|
|
|
|
|
if Pos('PREPAID',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring)>0 then
|
|
|
begin
|
|
|
result:=result+':'+str_pay //7预付地
|
|
|
+':' //8到付地点
|
|
|
+#39;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
result:=result+':' //7预付地
|
|
|
+':'+str_pay //8到付地点
|
|
|
+#39;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record11(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='11:'+':'+trim(Edit8.text)// 2 VESSEL CODE 船舶呼号
|
|
|
+':'+trim(aDataset.fieldbyname('船名').asstring) // 3 VESSEL 船名 X(35) '要求装运日期'为空时,该项必选 M
|
|
|
+':'+ trim(aDataset.fieldbyname('航次').asstring) // 4 VOYAGE 航次
|
|
|
+':10001133' //5 SHIPPING LINE CODE船舶经营人代码
|
|
|
+':WAN HAI LINES CO.,LTD' //6 SHIPPING LINE 船舶经营人 //
|
|
|
+':10001133' //7 B/L CARRY CODE 提单承运人代码 C
|
|
|
+':WAN HAI LINES CO.,LTD' //8 B/L CARRY 提单承运人
|
|
|
+':' // 9 REQUESTED SHIPMENT DATE 要求装运日期 9(8) O
|
|
|
+':' // 10 TRADE CODE 航线代码
|
|
|
+':' // 11 TRADE 航线 X(35) C
|
|
|
+':' // 12 PRE. VESSEL CODE 前程运输船名代码
|
|
|
+':' // 13 PRE. VESSEL 前程运输船名
|
|
|
+':' // 14 PRE. VOYAGE 前程运输航次
|
|
|
+#39;
|
|
|
{
|
|
|
result:='11:'+':'+GetvesselEdi(trim(aDataset.fieldbyname('船名').asstring))// 2 VESSEL CODE 船舶呼号
|
|
|
+':'+trim(aDataset.fieldbyname('船名').asstring) // 3 VESSEL 船名 X(35) '要求装运日期'为空时,该项必选 M
|
|
|
+':'+ trim(aDataset.fieldbyname('航次').asstring) // 4 VOYAGE 航次
|
|
|
+':10001133' //5 SHIPPING LINE CODE船舶经营人代码
|
|
|
+':WAN HAI LINES CO.,LTD' //6 SHIPPING LINE 船舶经营人 //
|
|
|
+':10001133' //7 B/L CARRY CODE 提单承运人代码 C
|
|
|
+':WAN HAI LINES CO.,LTD' //8 B/L CARRY 提单承运人
|
|
|
+':' // 9 REQUESTED SHIPMENT DATE 要求装运日期 9(8) O
|
|
|
+':' // 10 TRADE CODE 航线代码
|
|
|
+':' // 11 TRADE 航线 X(35) C
|
|
|
+':' // 12 PRE. VESSEL CODE 前程运输船名代码
|
|
|
+':' // 13 PRE. VESSEL 前程运输船名
|
|
|
+':' // 14 PRE. VOYAGE 前程运输航次
|
|
|
+#39;
|
|
|
}
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record12(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='12'+':'+ trim(aDataset.fieldbyname('装港代码').asstring) // 2 PLACE CODE OF RECEIPT 收货地代码
|
|
|
+':'+trim(aDataset.fieldbyname('装货港').asstring) // 3 PLACE OF RECEIPT 收货地
|
|
|
+':'+ trim(aDataset.fieldbyname('装港代码').asstring) // 4 LOAD PORT CODE 装货港代码
|
|
|
+':'+ trim(aDataset.fieldbyname('装货港').asstring) // 5 LOAD PORT 装货港
|
|
|
+':'+ trim(aDataset.fieldbyname('卸货代码').asstring) // 6 DISCHARGE PORT CODE 卸货港代码
|
|
|
+':'+ trim(aDataset.fieldbyname('卸货港').asstring) // 7 DISCHARGE PORT 卸货港
|
|
|
+':' // 8 TRANSFER PORT CODE 中转港代码
|
|
|
+':' // 9 TRANSFER PORT 中转港
|
|
|
+':'+trim(aDataset.fieldbyname('交货代码').asstring) // 10 PLACE OF DELIVERY CODE 交货地代码
|
|
|
+':'+trim(aDataset.fieldbyname('交货地点').asstring) // 11 PLACE OF DELIVERY 交货地
|
|
|
+':'+trim(aDataset.fieldbyname('目的地代码').asstring) // 12 FINAL DESTINATION CODE 目的地代码
|
|
|
+':'+trim(aDataset.fieldbyname('目的地').asstring) // 13 FINAL DESTINATION CODE 目的地
|
|
|
+#39;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record14(aDataset:TDataset):String;
|
|
|
var strPAY:string;
|
|
|
begin
|
|
|
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strPAY:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
result:='14'+':'+strPAY // 2 FR. CLAUSE. CODE 运费条款代码 X(3) C
|
|
|
+':'+frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring // 3 FREIGHT CLAUSE-I运费条款
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record15(aDataset:TDataset):String;
|
|
|
var strPAY:string;
|
|
|
begin
|
|
|
|
|
|
if frm_data_share.t_code_free.locate('付费方式',frm_op_seae.t_op_seae.fieldbyname('付费方式').asstring,[]) then
|
|
|
begin
|
|
|
strPAY:=frm_data_share.t_code_free.fieldbyname('代码').asstring;
|
|
|
end;
|
|
|
result:='15'+':' // 2 FR. CH. CODE 运费及费用代码
|
|
|
+':' // 3 FR. CH. REMARK 运费及费用说明
|
|
|
+':'+strPAY // 4 PREPAID OR COLLECT 付款方式
|
|
|
+':' // 5 PAYABLE AT (E) 第三地付款地点代码
|
|
|
+':' // 6 PAYEE CODE 收款人代码
|
|
|
+':' // 7 QUANTITY 数量
|
|
|
+':' // 8 CURRENCY 币种
|
|
|
+':' // 9 RATE OF FR. CH. 费率
|
|
|
+':' // 10 UNIT OF QUANTITY 数量单位
|
|
|
+':' // 11 AMOUNT 金额
|
|
|
+#39;
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record17(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
var sl,sl1:Tstringlist;
|
|
|
m,l:integer;
|
|
|
s:string;
|
|
|
begin
|
|
|
result:=Tstringlist.Create;
|
|
|
sl:=Tstringlist.Create;
|
|
|
sl1:=Tstringlist.Create;
|
|
|
try
|
|
|
sl1.Text:=FormatEdiString(aDataset.fieldbyname(FldName).AsString);
|
|
|
GetLengthTString(sl1,strLen);
|
|
|
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<=LoopCount then begin
|
|
|
if M=1 then begin
|
|
|
s:=RecordNo+':'+sl.Strings[L]+'$';
|
|
|
end else begin
|
|
|
if M=LoopCount then
|
|
|
s:=s+sl.Strings[L]
|
|
|
else
|
|
|
s:=s+sl.Strings[L]+'$';
|
|
|
end;
|
|
|
end else begin
|
|
|
S:=S+'''';
|
|
|
result.Add(S);
|
|
|
M:=1;
|
|
|
s:=RecordNo+':'+sl.Strings[L]+'$';
|
|
|
end;
|
|
|
M:=M+1;
|
|
|
end; //2 REMARKS 备注
|
|
|
S:=S+':::'+'''';
|
|
|
// CURRENCY 币种 CARGO AMOUNT 货物金额 MODE OF STUFFING 装箱方式
|
|
|
|
|
|
result.Add(S);
|
|
|
finally
|
|
|
sl.Free;
|
|
|
sl1.Free;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record20_21_22(recordno,fldName:string;aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:=GetCorpsString(recordno,fldName,aDataset);
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record41(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='41'
|
|
|
+':1' // 2 CARGO SEQUENCE NO. 货物序号 9(3) M
|
|
|
+':' // 3 CARGO CODE 货类代码 X(8) 海关HS码 C
|
|
|
+':'+trim(frm_op_seae.t_op_seae.FieldByName('货物标识').asstring) // 4 CARGO ID 货物标识 X(1) S/R/D/O M
|
|
|
+':'+ trim(aDataset.fieldbyname('件数').asstring) // 5 NUMBERS OF PKGS-1 第一层包装件数 9(6) INSIDE PACKAGE M
|
|
|
+':'+ GetPkgCode(trim(aDataset.fieldbyname('包装').asstring)) // 6 CODE OF PKGS-1 第一层包装类型 X(2) M
|
|
|
+':'+ trim(aDataset.fieldbyname('包装').asstring) // 7 PACKAGES DES-1 第一层包装说明 X(35) M
|
|
|
+':'+ trim(aDataset.fieldbyname('重量').asstring) // 8 CARGO GROSS WT-1 第一层包装皮重 9(9). 9 单位:千克 M
|
|
|
+':'+ trim(aDataset.fieldbyname('尺码').asstring) // 9 CARGO MEASUREMENT-1 第一层包装尺码 9(5). 999 单位:立方米 M
|
|
|
+':' // 10 NUMBERS OF PACKAGES-2 第二层包装件数 9(6) INSIDE INSIDE PACKAGE C
|
|
|
+':' // 11 CODE OF PKGS-2 第二层包装类型 X(2) C
|
|
|
+':' // 12 PACKAGES DES.-2 第二层包装说明 X(35) C
|
|
|
+':' // 13 CARGO GROSS WT-2 第二层包装皮重 9(9). 9 单位:千克 C
|
|
|
+':' // 14 CARGO MEASUREMENT-2 第二层包装尺码 9(5). 999 单位:立方米 C
|
|
|
+':'+trim(aDataset.fieldbyname('重量').asstring) // 15 CARGO GROSS WEIGHT 货毛重 9(10).99 单位:千克 M
|
|
|
+':' // 16 CARGO NET WEIGHT 货净重 9(10).99 单位:千克 C
|
|
|
+':' //17 QUARANTINE CODING 检疫代码 X(1) C
|
|
|
+#39; //
|
|
|
// 18 QUARANTINE CODING 检疫名称 X(35) C
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record43(aDataset:TDataset):String;
|
|
|
begin
|
|
|
result:='43';
|
|
|
if trim(aDataset.fieldbyname('货物标识').asstring)='D' THEN
|
|
|
begin
|
|
|
result:=result+':'+trim(aDataset.fieldbyname('危险品分类').asstring) // 2 CLASS 危险品分类 X(3) 由5碼改為3碼 M
|
|
|
+':' // 3 PAGE 危险品页号 X(7) C
|
|
|
+':'+trim(aDataset.fieldbyname('危险品编号').asstring) // 4 UNDG NO. 联合国危险品编号 9(4) M
|
|
|
+':' // 5 LABEL 危险品标签 X(32) C
|
|
|
+':' // 6 FLASH POINT 危险货物闪点 X(5) 摄氏 C
|
|
|
+':' // 7 EMS NO. 船运危险品应急措施号 X(6) C
|
|
|
+':' // 8 MFAG NO. 医疗急救指南号 X(4) C
|
|
|
+':' // 9 MPT(MARINE POLLUTANT) 海运污染 X(1) Y=有污染 N=无污染 C
|
|
|
// 10 EMERGENCY CONTACT 应急联系 X(35) C
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
result:=result+':::::::::'
|
|
|
end;
|
|
|
|
|
|
if trim(aDataset.fieldbyname('货物标识').asstring)='R' then
|
|
|
begin
|
|
|
result:=result+':'+frm_op_seae.t_op_seae.fieldbyname('冷藏通风量').asstring //11 REEFER VENTILATION FLUX 冷藏通风量 X(3) 注释:仅当冷藏箱存在时该项为必选,否则为可选 O
|
|
|
+':C' // 12 TEMPERATURE ID 温度计量单位 X(1) C=摄氏 F=华氏 C
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('设置温度').asstring) //13 TEMPERATURE SETTING 设置温度 X(5) 见注 C
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring) // 14 MIN. TEMPERATURE 冷藏最低温度 X(5) 见注 C
|
|
|
+':'+trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring) //15 MAX. TEMPERATURE 冷藏最高温度 X(5) 见注 C
|
|
|
+':' // 16 OVER LENGTH FRONT 前超 9(4) 厘米 C
|
|
|
+':' // 17 OVER LENGTH BACK 后超 9(4) 厘米 C
|
|
|
+':' // 18 OVER WIDTH LEFT 左超 9(4) 厘米 C
|
|
|
+':' // 19 OVER WIDTH RIGHT 右超 9(4) 厘米 C
|
|
|
+#39; // 20 OVER HEIGHT 超高 9(4) 厘米 C
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
result:=result+':::::::::'+#39;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record44_47(strLen,LoopCount:integer;RecordNo,FldName:string;aDataset:TDataset):TStringlist;
|
|
|
var sl,sl1:Tstringlist;
|
|
|
m,l:integer;
|
|
|
s:string;
|
|
|
begin
|
|
|
result:=Tstringlist.Create;
|
|
|
sl:=Tstringlist.Create;
|
|
|
sl1:=Tstringlist.Create;
|
|
|
try
|
|
|
sl1.Text:=FormatEdiString(aDataset.fieldbyname(FldName).AsString);
|
|
|
GetLengthTString(sl1,strLen);
|
|
|
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<=LoopCount then begin
|
|
|
if M=1 then begin
|
|
|
s:=RecordNo+':'+sl.Strings[L]+':';
|
|
|
end else begin
|
|
|
if M=LoopCount then
|
|
|
s:=s+sl.Strings[L]
|
|
|
else
|
|
|
s:=s+sl.Strings[L]+':';
|
|
|
end;
|
|
|
end else begin
|
|
|
S:=S+'''';
|
|
|
result.Add(S);
|
|
|
M:=1;
|
|
|
s:=RecordNo+':'+sl.Strings[L]+':';
|
|
|
end;
|
|
|
M:=M+1;
|
|
|
end;
|
|
|
S:=S+'''';
|
|
|
result.Add(S);
|
|
|
finally
|
|
|
sl.Free;
|
|
|
sl1.Free; //2 MARKS 唛头 X(70) M 2 CARGO DESCRIPTION货物描述
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.Record48(aDataset:TDataset):TStringlist;
|
|
|
var strsql:string;
|
|
|
rs:TADOQuery;
|
|
|
begin
|
|
|
result:=TStringlist.Create;
|
|
|
strsql:='select 编号,尺寸,箱型,sum(数量) as 数量 from t_op_ctn group by 编号,尺寸,箱型 having 编号='
|
|
|
+#39+aDataset.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
|
|
|
result.Add ('48:'+Trim(rs.fieldbyname('尺寸').asstring)+trim(rs.fieldbyname('箱型').asstring) // 2 CTN. SIZE & TYPE 集装箱尺寸类型 X(4)
|
|
|
+':'+trim(rs.fieldbyname('数量').asstring) // 3 CTN. NUMBERS 集装箱箱数 9(6) M
|
|
|
+':F' // 4 CTN. STATUS 集装箱状态 X(1) F=整箱 L=拼箱 M
|
|
|
+':' // 5 MASTER LCL NO. 主拼号 X(20) O
|
|
|
+':' // 6 MODE OF STUFFING 装箱方式 X(35) 自选/内装/自派车队等 C
|
|
|
+':' // 7 VANNING DEPOT 装箱地点代码 X(13) C
|
|
|
+':' // 8 VANNING DEPOT 装箱地点说明 X(35) C
|
|
|
+':N' // 9 CONTAINER SOC. 货主箱标志 X(1) Y=货主箱N=非货主箱 M
|
|
|
+#39);
|
|
|
rs.Next;
|
|
|
end;
|
|
|
finally
|
|
|
rs.Close;
|
|
|
rs.Destroy;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.IsZhongwen(Str: String): Boolean;
|
|
|
var
|
|
|
i:Integer;
|
|
|
begin
|
|
|
Result:=false;
|
|
|
if Str='' then Exit;
|
|
|
for i:=1 to Length(Str) do begin
|
|
|
if Str[i]>Chr(127) then begin
|
|
|
Result:=True;
|
|
|
Exit;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.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_wh.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_wh.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_wh.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;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.GetStrNum(str:String):integer;
|
|
|
var
|
|
|
i:integer;
|
|
|
begin
|
|
|
result:=0;
|
|
|
if str='' then exit;
|
|
|
for i:=1 to length(Str) do begin
|
|
|
if str[i] in ['0','1','2','3','4','5','6','7','8','9'] then
|
|
|
result:=result+1;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_wh.bsSkinButton2Click(Sender: TObject);
|
|
|
begin
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_wh.FormShow(Sender: TObject);
|
|
|
var
|
|
|
inifile1:Tinifile;
|
|
|
begin
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
edit1.text:=inifile1.ReadString('EDI','WHSEND','');
|
|
|
edit2.text:=inifile1.ReadString('EDI','WHRECIEVE','');
|
|
|
edit3.text:=inifile1.ReadString('EDI','WHSENDNAME','');
|
|
|
edit4.text:=inifile1.ReadString('EDI','WHFTPSERVER','');
|
|
|
edit5.text:=inifile1.ReadString('EDI','WHFTPPATH','');
|
|
|
edit6.text:=inifile1.ReadString('EDI','WHFTPNAME','');
|
|
|
edit7.text:=inifile1.ReadString('EDI','WHFTPPASS','');
|
|
|
inifile1.free;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_wh.bsSkinButton1Click(Sender: TObject);
|
|
|
var
|
|
|
Str:TStrings;
|
|
|
inifile1:Tinifile;
|
|
|
i:integer;
|
|
|
begin
|
|
|
|
|
|
|
|
|
str:=Tstringlist.Create;
|
|
|
try
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
Str:=CreateEdiFile
|
|
|
else
|
|
|
Str:=CreateEdiFile
|
|
|
else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then
|
|
|
else
|
|
|
begin
|
|
|
Exit;
|
|
|
end;
|
|
|
|
|
|
for i:=0 to Str.Count-1 do begin
|
|
|
if IsZhongwen(Str[i]) then begin
|
|
|
if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!',mtWarning,[mbYes,mbNo],0)=mrNo then
|
|
|
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;
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
inifile1.WriteString('EDI','WHSEND',edit1.text);
|
|
|
inifile1.WriteString('EDI','WHRECIEVE',edit2.text);
|
|
|
inifile1.WriteString('EDI','WHSENDNAME',edit3.text);
|
|
|
inifile1.WriteString('EDI','WHFTPSERVER',edit4.text);
|
|
|
inifile1.WriteString('EDI','WHFTPPATH',edit5.text);
|
|
|
inifile1.WriteString('EDI','WHFTPNAME',edit6.text);
|
|
|
inifile1.WriteString('EDI','WHFTPPASS',edit7.text);
|
|
|
inifile1.free;
|
|
|
|
|
|
close;
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.isEditrue(DataSet:TDataSet): boolean;
|
|
|
var s:String;
|
|
|
begin
|
|
|
result:=true;
|
|
|
|
|
|
|
|
|
if trim(Edit1.Text)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('发送方代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(Edit3.Text)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('发送方邮箱不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(Edit2.Text)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('接受方代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(Edit8.Text)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('船舶呼号不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
s:=ControlLines;
|
|
|
|
|
|
if trim(s)<>'' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg(s,mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(DataSet.fieldbyname('付费方式').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('付费方式不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if GetvesselEdi(DataSet.fieldbyname('船名').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('船舶呼号不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(DataSet.fieldbyname('船名').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('船名不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if trim(DataSet.fieldbyname('航次').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('航次不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(DataSet.fieldbyname('装港代码').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('装港代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(DataSet.fieldbyname('装货港').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('装货港不能为空',mtWarning,[mbOk],0);
|
|
|
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('目的地代码').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('目的地代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('交货地点').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('交货地点不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('卸货代码').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('卸货代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('卸货港').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('卸货港不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('包装').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('包装不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if GetPkgCode(trim(DataSet.fieldbyname('包装').asstring))='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('包装代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
if trim(DataSet.fieldbyname('开船日期').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('开船日期不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
if trim(DataSet.fieldbyname('交货地点').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('交货地点不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
if trim(DataSet.fieldbyname('目的地').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('目的地不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(DataSet.fieldbyname('目的地代码').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('目的地代码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
if trim(DataSet.fieldbyname('签单地点').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('签单地点不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
|
|
|
if trim(DataSet.fieldbyname('货物描述').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('货物描述不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if trim(DataSet.fieldbyname('唛头').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('唛头不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if DataSet.fieldbyname('件数').asinteger=0 then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('件数不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if DataSet.fieldbyname('重量').asFloat=0 then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('总重量不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if DataSet.fieldbyname('尺码').asFloat=0 then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('总尺码不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
|
|
|
if trim(frm_op_seae.t_op_seae.fieldbyname('货物标识').asstring)='' then
|
|
|
begin
|
|
|
result:=false;
|
|
|
MessageDlg('货物标识不能为空',mtWarning,[mbOk],0);
|
|
|
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);
|
|
|
end;
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('危险品编号不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if GetStrNum(Trim(frm_op_seae.t_op_seae.fieldbyname('危险品编号').asstring))<>4 then begin
|
|
|
result:=false;
|
|
|
MessageDlg('危险品编号必须是4位数字',mtWarning,[mbOk],0);
|
|
|
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);
|
|
|
end;
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('最低温度').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('最低温度不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('最高温度').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('最高温度不能为空',mtWarning,[mbOk],0);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
begin
|
|
|
t_op_ctn.close;
|
|
|
t_op_ctn.Parameters.ParamByName('编号').Value:=frm_op_seae.t_op_seae.fieldbyname('编号').asstring;
|
|
|
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(t_op_ctn.fieldbyname('箱号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('箱号不能为空!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
if Trim(t_op_ctn.fieldbyname('封号').asstring)='' then begin
|
|
|
result:=false;
|
|
|
MessageDlg('封号不能为空!',mtWarning,[mbOk],0);
|
|
|
exit;
|
|
|
end;
|
|
|
t_op_ctn.Next;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
end;
|
|
|
|
|
|
function Tfrm_op_seae_edi_wh.CreateEdiFile:TStrings;
|
|
|
var str,aTempList:TStringlist;
|
|
|
strType,SenderCode,ReciverCode:string;
|
|
|
i,k,LineNo:integer;
|
|
|
begin
|
|
|
try
|
|
|
aTempList:=TStringlist.create;
|
|
|
str:=TStringlist.create;
|
|
|
|
|
|
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';
|
|
|
I:=0;
|
|
|
if frm_op_seae.dxdbgrid1.SelectedCount<=1 then
|
|
|
begin
|
|
|
if not isEditrue(frm_op_seae.t_op_seae) then abort;
|
|
|
I:=0;
|
|
|
str.add(Record00(strType,SenderCode,ReciverCode));
|
|
|
str.add(Record02(frm_op_seae.t_op_seae));
|
|
|
str.add(Record03(frm_op_seae.t_op_seae));
|
|
|
str.add(Record11(frm_op_seae.t_op_seae));
|
|
|
str.add(Record12(frm_op_seae.t_op_seae));
|
|
|
str.add(Record14(frm_op_seae.t_op_seae));
|
|
|
str.add(Record15(frm_op_seae.t_op_seae));
|
|
|
aTempList:=Record17(35,10,'17','EDI备注',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
str.add(Record20_21_22('20','发货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22('21','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22('22','通知人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record41(frm_op_seae.t_op_seae));
|
|
|
str.add(Record43(frm_op_seae.t_op_seae));
|
|
|
aTempList:=Record44_47(70,10,'44','唛头',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
aTempList:=Record44_47(70,5,'47','货物描述',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
aTempList:=Record48(frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
I:=str.Count;
|
|
|
end
|
|
|
else
|
|
|
begin
|
|
|
{
|
|
|
I:=0;
|
|
|
str.add(Record00(strType,SenderCode,ReciverCode));
|
|
|
str.add(Record11(frm_op_seae.t_op_seae));
|
|
|
for k:=0 to frm_op_seae.dxdbgrid1.SelectedCount-1 do
|
|
|
begin
|
|
|
lineno:=0;
|
|
|
frm_op_seae.t_op_seae.GotoBookmark(pointer(frm_op_seae.dxdbgrid1.selectedrows[k]));
|
|
|
if not isEditrue(frm_op_seae.t_op_seae) then abort;
|
|
|
str.add(Record12(frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22('20','发货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22('21','收货人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record20_21_22('22','通知人代码',frm_op_seae.t_op_seae));
|
|
|
str.add(Record21(frm_op_seae.t_op_seae));
|
|
|
str.add(Record41(frm_op_seae.t_op_seae));
|
|
|
str.add(Record43(frm_op_seae.t_op_seae));
|
|
|
lineno:=8;
|
|
|
|
|
|
aTempList:=Record44_47(35,10,'44','唛头',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
lineno:=lineno+aTempList.count;
|
|
|
|
|
|
aTempList:=Record44_47(70,5,'47','货物描述',frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
lineno:=lineno+aTempList.count;
|
|
|
|
|
|
aTempList:=Record48(frm_op_seae.t_op_seae);
|
|
|
str.addstrings(aTempList);
|
|
|
lineno:=lineno+aTempList.count;
|
|
|
|
|
|
I:=I+lineno;
|
|
|
end;
|
|
|
I:=I+3;
|
|
|
}
|
|
|
end;
|
|
|
finally
|
|
|
str.Add('99:'+intToStr(i+1)+'''');
|
|
|
Result:=str;
|
|
|
freeandnil(aTempList);
|
|
|
//freeandnil(str);
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_wh.bsSkinButton3Click(Sender: TObject);
|
|
|
var
|
|
|
IdFTP1:TIdFTP;
|
|
|
str:widestring;
|
|
|
str_file:widestring;
|
|
|
ftpar,ftpname,ftppass,ftppath,ScriptPath:String;
|
|
|
StrL:TStrings;
|
|
|
inifile1:Tinifile;
|
|
|
i:integer;
|
|
|
begin
|
|
|
|
|
|
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
|
|
|
if Trim(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring)='整箱' then
|
|
|
if bsSkinRadioGroup2.ItemIndex=1 then
|
|
|
StrL:=CreateEdiFile
|
|
|
else
|
|
|
StrL:=CreateEdiFile
|
|
|
else if Pos('主票',(frm_op_seae.t_op_seae.fieldbyname('装运方式').asstring))>0 then
|
|
|
else begin
|
|
|
Exit;
|
|
|
end;
|
|
|
|
|
|
for i:=0 to StrL.Count-1 do begin
|
|
|
if IsZhongwen(StrL[i]) then begin
|
|
|
if MessageDlg('此票业务可能含有中文字符或其他不规范字符,确实要继续上传吗!',mtWarning,[mbYes,mbNo],0)=mrNo then
|
|
|
exit;
|
|
|
end;
|
|
|
end;
|
|
|
|
|
|
|
|
|
strL.SaveToFile(str);
|
|
|
finally
|
|
|
FreeAndNil(StrL)
|
|
|
end;
|
|
|
|
|
|
try
|
|
|
|
|
|
IdFTP1:=TIdFTP.Create(application);
|
|
|
with idftp1 do
|
|
|
begin
|
|
|
Username:=ftpname;
|
|
|
Password:=ftppass;
|
|
|
Host:=ftpar;
|
|
|
Connect;
|
|
|
end;
|
|
|
idftp1.ChangeDir(ftppath);
|
|
|
idftp1.TransferType:=ftBinary;
|
|
|
idftp1.Put(str,str_file);
|
|
|
idftp1.Disconnect;
|
|
|
|
|
|
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
|
|
|
inifile1.WriteString('EDI','WHSEND',edit1.text);
|
|
|
inifile1.WriteString('EDI','WHRECIEVE',edit2.text);
|
|
|
inifile1.WriteString('EDI','WHSENDNAME',edit3.text);
|
|
|
inifile1.WriteString('EDI','WHFTPSERVER',edit4.text);
|
|
|
inifile1.WriteString('EDI','WHFTPPATH',edit5.text);
|
|
|
inifile1.WriteString('EDI','WHFTPNAME',edit6.text);
|
|
|
inifile1.WriteString('EDI','WHFTPPASS',edit7.text);
|
|
|
inifile1.free;
|
|
|
|
|
|
showmessage('文件上传成功!');
|
|
|
except
|
|
|
deletefile(str);
|
|
|
showmessage('文件上传错误!');
|
|
|
end;
|
|
|
idftp1.Free;
|
|
|
end;
|
|
|
|
|
|
procedure Tfrm_op_seae_edi_wh.bsSkinButton4Click(Sender: TObject);
|
|
|
begin
|
|
|
if frm_op_seae_edi_WH.Height=349 then
|
|
|
frm_op_seae_edi_WH.Height:=200
|
|
|
else
|
|
|
frm_op_seae_edi_WH.Height:=349;
|
|
|
end;
|
|
|
|
|
|
end.
|