unit u_op_seae_selectbsno; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, BusinessSkinForm, bsSkinCtrls, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, dxDBTLCl, dxGrClms, RxLookup, StdCtrls, wwdbdatetimepicker; type Tfrm_op_seae_selectbsno = class(TForm) bsBusinessSkinForm1: TbsBusinessSkinForm; bsSkinPanel1: TbsSkinPanel; bsSkinButton5: TbsSkinButton; bsSkinNotebook1: TbsSkinNotebook; t_ch_fee: TADOQuery; t_ch_fee1: TDataSource; bsSkinButton10: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton3: TbsSkinButton; t_bill1: TDataSource; t_bill: TADOQuery; bsSkinPanel2: TbsSkinPanel; bsSkinPanel3: TbsSkinPanel; Edit1: TEdit; Edit2: TEdit; Label6: TLabel; Label1: TLabel; Label9: TLabel; RxDBLookupCombo2: TRxDBLookupCombo; Label3: TLabel; Edit4: TEdit; Edit3: TEdit; Label2: TLabel; Label10: TLabel; wwDBDateTimePicker1: TwwDBDateTimePicker; dxDBGrid2: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; dxDBGridMaskColumn4: TdxDBGridMaskColumn; dxDBGridMaskColumn5: TdxDBGridMaskColumn; dxDBGridMaskColumn6: TdxDBGridMaskColumn; dxDBGridMaskColumn7: TdxDBGridMaskColumn; dxDBGrid1Column12: TdxDBGridMaskColumn; dxDBGrid1Column13: TdxDBGridMaskColumn; dxDBGrid1Column14: TdxDBGridMaskColumn; dxDBGrid1Column15: TdxDBGridMaskColumn; dxDBGrid1Column16: TdxDBGridDateColumn; dxDBGrid1Column17: TdxDBGridDateColumn; dxDBGrid1Column18: TdxDBGridDateColumn; dxDBGrid1Column19: TdxDBGridMaskColumn; dxDBGrid1Column20: TdxDBGridMaskColumn; dxDBGrid1Column22: TdxDBGridDateColumn; dxDBGrid1Column63: TdxDBGridMaskColumn; dxDBGrid1Column64: TdxDBGridMaskColumn; dxDBGrid1Column65: TdxDBGridDateColumn; dxDBGrid1Column66: TdxDBGridMaskColumn; dxDBGrid1Column67: TdxDBGridMaskColumn; op_type: TEdit; fee_type: TEdit; t_do_bill: TDataSource; t_op_ctn_insert: TADOQuery; procedure bsSkinButton5Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var frm_op_seae_selectbsno: Tfrm_op_seae_selectbsno; implementation uses u_main, my_sys_function, u_data_share, u_op_seae_order_edit; {$R *.dfm} procedure Tfrm_op_seae_selectbsno.bsSkinButton5Click(Sender: TObject); begin CLOSE; end; procedure Tfrm_op_seae_selectbsno.FormShow(Sender: TObject); begin // bsSkinNotebook1.PageIndex:=strtoint(op_type.text); end; procedure Tfrm_op_seae_selectbsno.bsSkinButton10Click(Sender: TObject); begin Edit1.text:=''; Edit2.text:=''; Edit3.text:=''; Edit4.text:=''; RxDBLookupCombo2.ClearValue; wwDBDateTimePicker1.Text:=''; end; procedure Tfrm_op_seae_selectbsno.bsSkinButton2Click(Sender: TObject); var str:widestring; begin case bsSkinNotebook1.PageIndex of 1: begin if Edit1.text<>''then str:=' where 业务编号 like '+''''+'%'+Edit1.text+'%'+''''; if Edit4.text<>''then begin if str=''then str:=' where 委托编号 like '+''''+'%'+Edit4.text+'%'+'''' else str:=str+' and 委托编号 like '+''''+'%'+Edit4.text+'%'+''''; end; if Edit2.text<>''then begin if str=''then str:=' where 主提单号 like '+''''+'%'+Edit2.text+'%'+'''' else str:=str+' and 主提单号 like '+''''+'%'+Edit2.text+'%'+''''; end; if Edit3.text<>''then begin if str=''then str:=' where 分提单号 like '+''''+'%'+Edit3.text+'%'+'''' else str:=str+' and 分提单号 like '+''''+'%'+Edit3.text+'%'+''''; end; if RxDBLookupCombo2.DisplayValue<>''then begin if str=''then str:=' where 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+'''' else str:=str+' and 委托单位='+''''+RxDBLookupCombo2.DisplayValues[1]+''''; end; if wwDBDateTimePicker1.text<>''then begin if str=''then str:=' where 开船日期='+''''+wwDBDateTimePicker1.text+'''' else str:=str+' and 开船日期='+''''+wwDBDateTimePicker1.text+''''; end; str:='select * from t_op_seae '+str+default_sort(53,'t_op_seae','','desc'); t_bill.close; t_bill.sql.clear; t_bill.sql.add(str); t_bill.open; end; end; end; procedure Tfrm_op_seae_selectbsno.bsSkinButton3Click(Sender: TObject); var i: Integer; bsno,ywno,sql:String; aQuery:TAdoQuery; dsstr,PostUrl:string; begin if t_bill.IsEmpty then exit; { t_do_bill.DataSet.Edit; t_do_bill.DataSet.fieldbyname('收货人').AsString:=t_bill.fieldbyname('收货人').AsString; t_do_bill.DataSet.fieldbyname('通知人').AsString:=t_bill.fieldbyname('通知人').AsString; t_do_bill.DataSet.fieldbyname('发货人').AsString:=t_bill.fieldbyname('发货人').AsString; t_do_bill.DataSet.fieldbyname('收货人代码').AsString:=t_bill.fieldbyname('收货人代码').AsString; t_do_bill.DataSet.fieldbyname('通知人代码').AsString:=t_bill.fieldbyname('通知人代码').AsString; t_do_bill.DataSet.fieldbyname('发货人代码').AsString:=t_bill.fieldbyname('发货人代码').AsString; t_do_bill.DataSet.post; } frm_main.db.BeginTrans; try // if not t_op_seae_insert.Active then t_op_seae_insert.Open; //主表 // if not t_op_ctn_insert.Active then t_op_ctn_insert.Open; // bsno:=t_bill.fieldbyname('编号').asstring; t_bill.Edit; t_bill.FieldByName('货物标识').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CARGOID').AsString; if (t_bill.FieldByName('船公司').AsString<>frm_op_seae_order_edit.t_op_seae.FieldByName('CARRIER').AsString) then begin t_bill.FieldByName('船公司').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CARRIER').AsString; aQuery:=CreateAdoQuery; try With aQuery do begin close;sql.Clear; sql.Add('select 默认场站,默认场站联系人 from t_crm_client where 客户简称='''+frm_op_seae_order_edit.t_op_seae.FieldByName('CARRIER').AsString+''''); Open; if not IsEmpty then begin t_bill.FieldByName('场站').AsString:=aQuery.fieldbyname('默认场站').AsString; t_bill.FieldByName('场站联系人').AsString:=aQuery.fieldbyname('默认场站联系人').AsString; end; end; finally FreeAndNil(aQuery); end; end; t_bill.FieldByName('委托编号').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CUSTNO').AsString; t_bill.FieldByName('装货港').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PORTLOAD').AsString; t_bill.FieldByName('装港代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PORTLOADID').AsString; //////?????? t_bill.FieldByName('提单份数').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('NOBILL').AsString; t_bill.FieldByName('运输条款').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('SERVICE').AsString; t_bill.FieldByName('唛头').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('MARKS').AsString; t_bill.FieldByName('货物描述').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('DESCRIPTION').AsString; t_bill.FieldByName('发货人代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('SHIPPER').AsString; t_bill.FieldByName('收货人代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CONSIGNEE').AsString; t_bill.FieldByName('通知人代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('NOTIFYPARTY').AsString; t_bill.FieldByName('付费方式').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('BLFRT').AsString; t_bill.FieldByName('签单地点').AsString:='QINGDAO,CHINA'; t_bill.FieldByName('货物重量').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('KGS').AsString+'KGS'; t_bill.FieldByName('货物尺码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CBM').AsString+'CBM'; t_bill.FieldByName('件数').AsInteger:=frm_op_seae_order_edit.t_op_seae.FieldByName('PKGS').AsInteger; // t_op_seae_insert.FieldByName('包装').AsString:=getkingpkgs(t_op_seae.FieldByName('KINDPKGS').AsString); t_bill.FieldByName('包装').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('KINDPKGS').AsString; if (t_bill.FieldByName('件数').AsInteger>1) then t_bill.FieldByName('包装').AsString:=t_bill.FieldByName('包装').AsString+'S'; t_bill.FieldByName('件数包装').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PKGS').AsString+t_bill.FieldByName('包装').AsString; t_bill.FieldByName('重量').AsFloat:=frm_op_seae_order_edit.t_op_seae.FieldByName('KGS').AsFloat; t_bill.FieldByName('尺码').AsFloat:=frm_op_seae_order_edit.t_op_seae.FieldByName('CBM').AsFloat; t_bill.FieldByName('件数大写').AsString:='SAY:'+ntoc(frm_op_seae_order_edit.t_op_seae.FieldByName('PKGS').asfloat,true) +frm_op_seae_order_edit.t_op_seae.FieldByName('KINDPKGS').asstring+' ONLY.'; t_bill.FieldByName('危险品分类').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('DCLASS').AsString; t_bill.FieldByName('危险品编号').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('DUNNO').AsString; t_bill.FieldByName('设置温度').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('TEMPSET').AsString; t_bill.FieldByName('冷藏通风量').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('REEFERF').AsString; t_bill.FieldByName('运费协议号').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('SERVICECONTRACTNO').AsString; t_bill.FieldByName('船名').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('VESSEL').AsString; t_bill.FieldByName('航次').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('VOYNO').AsString; t_bill.FieldByName('开船日期').Value:=frm_op_seae_order_edit.t_op_seae.FieldByName('ETD').Value; t_bill.FieldByName('卸货代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PORTDISCHARGEID').AsString; if (frm_data_share.t_code_disport.Locate('EDI代码',frm_op_seae_order_edit.t_op_seae.FieldByName('PORTDISCHARGEID').AsString,[])) then t_bill.FieldByName('卸货港').AsString:=frm_data_share.t_code_disport.fieldbyname('英文名').AsString else t_bill.FieldByName('卸货港').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PORTDISCHARGE').AsString; if (frm_op_seae_order_edit.t_op_seae.FieldByName('CUSTOMERNAME').AsString='海尔') then t_bill.FieldByName('签单编号').AsInteger:=10; t_bill.FieldByName('目的地代码').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('DESTINATIONID').AsString; if (frm_data_share.t_code_disport.Locate('EDI代码',frm_op_seae_order_edit.t_op_seae.FieldByName('DESTINATIONID').AsString,[])) then t_bill.FieldByName('目的地').AsString:=frm_data_share.t_code_disport.fieldbyname('英文名').AsString else t_bill.FieldByName('目的地').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('DESTINATION').AsString; t_bill.FieldByName('集装箱').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('CNTRTOTAL').AsString; t_bill.FieldByName('销售订舱说明').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('REMARK').AsString; t_bill.FieldByName('备注').AsString:='客户联系人:'+frm_op_seae_order_edit.t_op_seae.FieldByName('CUSTATTN').AsString+' '+frm_op_seae_order_edit.t_op_seae.FieldByName('CUSTTEL').AsString; if(frm_op_seae_order_edit.t_op_seae.FieldByName('ISSUETYPE').AsString<>'') then t_bill.FieldByName('签单方式').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('ISSUETYPE').AsString; t_bill.FieldByName('付费方式').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('BLFRT').AsString; if ((frm_op_seae_order_edit.t_op_seae.FieldByName('PREPARDAT').AsString<>'') or (frm_op_seae_order_edit.t_op_seae.FieldByName('PAYABLEAT').AsString<>'')) then begin t_bill.FieldByName('预付地点').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PREPARDAT').AsString; t_bill.FieldByName('到付地点').AsString:=frm_op_seae_order_edit.t_op_seae.FieldByName('PAYABLEAT').AsString; end; t_bill.Post; if (not frm_op_seae_order_edit.t_op_ctn.IsEmpty) then begin try t_op_ctn_insert.Close; t_op_ctn_insert.Open; with frm_op_seae_order_edit.t_op_ctn do begin First; while not Eof do begin t_op_ctn_insert.Insert; t_op_ctn_insert['数量']:=frm_op_seae_order_edit.t_op_ctn['CTNNUM']; if frm_data_share.t_code_ctn.Locate('表现形式',frm_op_seae_order_edit.t_op_ctn['CTNALL'],[]) then begin t_op_ctn_insert['表现形式']:=frm_op_seae_order_edit.t_op_ctn['CTNALL']; t_op_ctn_insert['代码']:=frm_data_share.t_code_ctn['代码']; t_op_ctn_insert['箱型']:=frm_data_share.t_code_ctn['箱型']; t_op_ctn_insert['尺寸']:=frm_data_share.t_code_ctn['尺寸']; if frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='20'then t_op_ctn_insert['TEU']:=1*t_op_ctn_insert.FieldByName('数量').asinteger; if (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='40')OR (frm_data_share.t_code_ctn.FieldByName('尺寸').asstring='45')then t_op_ctn_insert['TEU']:=2*t_op_ctn_insert.FieldByName('数量').asinteger; end else begin t_op_ctn_insert['代码']:=''; t_op_ctn_insert['表现形式']:=''; t_op_ctn_insert['箱型']:=''; t_op_ctn_insert['尺寸']:=''; t_op_ctn_insert['TEU']:=0; end; t_op_ctn_insert['件数']:=frm_op_seae_order_edit.t_op_ctn['PKGS']; t_op_ctn_insert['包装']:=frm_op_seae_order_edit.t_op_ctn['KINDPKGS']; t_op_ctn_insert['重量']:=frm_op_seae_order_edit.t_op_ctn['KGS']; t_op_ctn_insert['尺码']:=frm_op_seae_order_edit.t_op_ctn['CBM']; // t_op_ctn_insert['品名']:=t_op_ctn['GOODSNAME']; t_op_ctn_insert['编号']:=bsno; t_op_ctn_insert.post; Next; end; end; finally end; end; update_ctn(t_op_ctn_insert); frm_op_seae_order_edit.t_op_seae.Edit; frm_op_seae_order_edit.t_op_seae.fieldbyname('ORSTATUS').AsString:='0'; frm_op_seae_order_edit.t_op_seae.fieldbyname('BSCUSTNO').AsString:=bsno; frm_op_seae_order_edit.t_op_seae.Post; frm_op_seae_order_edit.m_qryTask.Edit; frm_op_seae_order_edit.m_qryTask.FieldByName('完成时间').AsDateTime:=Now; frm_op_seae_order_edit.m_qryTask.FieldByName('是否完成').AsInteger:=1; frm_op_seae_order_edit.m_qryTask.FieldByName('任务状态').AsString:='已接收'; frm_op_seae_order_edit.m_qryTask.FieldByName('操作人').AsString:=employee; frm_op_seae_order_edit.m_qryTask.FieldByName('任务相关人员').AsString:=employee; frm_op_seae_order_edit.m_qryTask.Post; sql:='INSERT INTO t_op_task_state ( [任务编号],[任务状态],[操作人])VALUES (''%s'' ,''%s'' ,''%s'')'; sql:=Format(sql,[frm_op_seae_order_edit.m_qryTask.fieldbyname('任务编号').asstring,'已接收',employee] ); frm_op_seae_order_edit.m_qryTask.Connection.Execute(sql); frm_op_seae_order_edit.m_qryTask.Requery(); frm_main.db.CommitTrans; if (t_bill.FieldByName('签单编号').AsInteger=10) then begin dsstr:=dsstr+'{'; dsstr:=dsstr+'"orderNo":"'+frm_op_seae_order_edit.t_op_seae.FieldByName('CUSTNO').AsString+'"'; dsstr:=dsstr+',"status":"N"'; dsstr:=dsstr+',"bookingId":"'+t_bill.FieldByName('业务编号').AsString+'"'; dsstr:=dsstr+',"bookingIdDate":"'+FormatDateTime('YYYY-MM-DD hh:mm:ss',t_bill.FieldByName('录入日期').asdatetime)+'"'; dsstr:=dsstr+'}'; PostUrl:=get_parameters_value(2124,'http://47.104.90.170:6857/api/clp/bookingMsgReceipt'); TDsHaierThread.create(PostUrl,dsstr,'',t_bill.FieldByName('主提单号').AsString); InsertSysLog('上传海尔回执',t_bill.FieldByName('业务编号').asstring); end; finally if frm_main.db.InTransaction then begin frm_main.db.RollbackTrans; end; Application.MessageBox(PChar('操作完成'),'信息提示'); close; end; close; end; end.