|
|
|
|
unit u_rp_zj_total;
|
|
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
|
|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
|
|
|
Dialogs, dxExEdtr, DB, ADODB, StdCtrls, wwdbdatetimepicker, bsSkinCtrls,
|
|
|
|
|
dxTL, dxDBCtrl, dxDBGrid, dxCntner, ComCtrls, bsSkinTabs, ExtCtrls;
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
|
Tfrm_rp_zj_total = class(TForm)
|
|
|
|
|
Panel1: TPanel;
|
|
|
|
|
bsSkinPageControl1: TbsSkinPageControl;
|
|
|
|
|
bsSkinTabSheet1: TbsSkinTabSheet;
|
|
|
|
|
dxDBGrid1: TdxDBGrid;
|
|
|
|
|
dxDBGrid1Column1: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column2: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column3: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column11: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column8: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column9: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column4: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column5: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column6: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column7: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid1Column10: TdxDBGridColumn;
|
|
|
|
|
bsSkinTabSheet2: TbsSkinTabSheet;
|
|
|
|
|
dxDBGrid2: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn1: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn2: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn3: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column11: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn4: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn5: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn6: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn7: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn8: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn9: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid2Column10: TdxDBGridColumn;
|
|
|
|
|
dxDBGrid3: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn11: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn12: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn13: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn14: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn15: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn16: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn17: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn18: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn19: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn20: TdxDBGridColumn;
|
|
|
|
|
bsSkinPanel2: TbsSkinPanel;
|
|
|
|
|
bsSkinButton10: TbsSkinButton;
|
|
|
|
|
bsSkinButton9: TbsSkinButton;
|
|
|
|
|
bsSkinButton5: TbsSkinButton;
|
|
|
|
|
bsSkinCheckRadioBox2: TbsSkinCheckRadioBox;
|
|
|
|
|
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
|
|
|
|
|
bsSkinPanel1: TbsSkinPanel;
|
|
|
|
|
Label1: TLabel;
|
|
|
|
|
Label2: TLabel;
|
|
|
|
|
wwDBDateTimePicker1: TwwDBDateTimePicker;
|
|
|
|
|
wwDBDateTimePicker2: TwwDBDateTimePicker;
|
|
|
|
|
p_client: TADOStoredProc;
|
|
|
|
|
p_client1: TDataSource;
|
|
|
|
|
p_shen: TADOStoredProc;
|
|
|
|
|
p_shen1: TDataSource;
|
|
|
|
|
p_total: TADOStoredProc;
|
|
|
|
|
p_total1: TDataSource;
|
|
|
|
|
bsSkinTabSheet3: TbsSkinTabSheet;
|
|
|
|
|
dxDBGrid4: TdxDBGrid;
|
|
|
|
|
dxDBGridColumn10: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn21: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn22: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn23: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn24: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn25: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn26: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn27: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn28: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn29: TdxDBGridColumn;
|
|
|
|
|
dxDBGridColumn30: TdxDBGridColumn;
|
|
|
|
|
p_op: TADOStoredProc;
|
|
|
|
|
p_op1: TDataSource;
|
|
|
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
|
|
|
procedure bsSkinButton5Click(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton9Click(Sender: TObject);
|
|
|
|
|
procedure bsSkinPanel2Resize(Sender: TObject);
|
|
|
|
|
procedure bsSkinButton10Click(Sender: TObject);
|
|
|
|
|
procedure dxDBGrid1ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
procedure dxDBGrid2ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
procedure dxDBGrid4ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
private
|
|
|
|
|
{ Private declarations }
|
|
|
|
|
public
|
|
|
|
|
{ Public declarations }
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
var
|
|
|
|
|
frm_rp_zj_total: Tfrm_rp_zj_total;
|
|
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
uses u_main, my_sys_function;
|
|
|
|
|
|
|
|
|
|
{$R *.dfm}
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.FormClose(Sender: TObject;
|
|
|
|
|
var Action: TCloseAction);
|
|
|
|
|
begin
|
|
|
|
|
frm_rp_zj_total.Hide;
|
|
|
|
|
frm_rp_zj_total.ManualFloat(frm_rp_zj_total.BoundsRect );
|
|
|
|
|
frm_main.freeTabs('frm_rp_zj_total');
|
|
|
|
|
action:=cafree;
|
|
|
|
|
frm_rp_zj_total:=nil;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.bsSkinButton5Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
close;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.bsSkinButton9Click(Sender: TObject);
|
|
|
|
|
begin
|
|
|
|
|
sys_print('<27>ʽ<EFBFBD><CABD>ۺϷ<DBBA><CFB7><EFBFBD>',2,nil,nil,nil,nil,p_client1,p_shen1,p_op1,p_total1,nil,nil,nil);
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.bsSkinPanel2Resize(Sender: TObject);
|
|
|
|
|
var
|
|
|
|
|
i:integer;
|
|
|
|
|
begin
|
|
|
|
|
i:=round((bsSkinPanel2.Width-bsSkinPanel1.Width)/5);
|
|
|
|
|
bsSkinCheckRadioBox2.Width:=i;
|
|
|
|
|
bsSkinCheckRadioBox1.Width:=i;
|
|
|
|
|
bsSkinButton10.Width:=i;
|
|
|
|
|
bsSkinButton9.Width:=i;
|
|
|
|
|
bsSkinButton5.Width:=i;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.bsSkinButton10Click(Sender: TObject);
|
|
|
|
|
var
|
|
|
|
|
str,str_date:widestring;
|
|
|
|
|
str_date_tongji:string;
|
|
|
|
|
begin
|
|
|
|
|
if bsSkinCheckRadioBox1.Checked then
|
|
|
|
|
str_date_tongji:='<27><><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>'
|
|
|
|
|
else
|
|
|
|
|
str_date_tongji:='ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>';
|
|
|
|
|
str:='where '+open_data('0036','v_op_no.<2E><><EFBFBD><EFBFBD>Ա','v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','v_op_no.<2E>ͷ<EFBFBD>Ա','no','no');
|
|
|
|
|
if wwDBDateTimePicker1.text<>''then
|
|
|
|
|
begin
|
|
|
|
|
str:=str+' and v_op_no.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
|
|
|
|
|
str_date:=' where v_op_no.'+str_date_tongji+'>='+''''+wwDBDateTimePicker1.text+'''';
|
|
|
|
|
end;
|
|
|
|
|
if wwDBDateTimePicker2.text<>''then
|
|
|
|
|
begin
|
|
|
|
|
str:=str+' and v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
|
|
|
|
|
|
|
|
|
|
if str_date='' then
|
|
|
|
|
str_date:=' where v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+''''
|
|
|
|
|
else
|
|
|
|
|
str_date:=str_date+' and v_op_no.'+str_date_tongji+'<='+''''+wwDBDateTimePicker2.text+'''';
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
p_client.close;
|
|
|
|
|
p_client.Parameters.ParamByName('SQLStr').value:=
|
|
|
|
|
'DECLARE @all_pay numeric '
|
|
|
|
|
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
|
|
|
|
|
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
|
|
|
|
|
+'SELECT v_op_no.ί<>е<EFBFBD>λ,'
|
|
|
|
|
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when @all_pay=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'INTO #bill '
|
|
|
|
|
+'FROM t_op_gain inner join v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' group by v_op_no.ί<>е<EFBFBD>λ '
|
|
|
|
|
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee '
|
|
|
|
|
+'FROM t_ch_fee_do inner JOIN v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance ON '
|
|
|
|
|
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
|
|
|
|
|
+' group by v_op_no.ί<>е<EFBFBD>λ '
|
|
|
|
|
|
|
|
|
|
+'SELECT v_op_no.ί<>е<EFBFBD>λ, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee_truck '
|
|
|
|
|
+'FROM t_ch_fee_do_truck inner JOIN v_op_no on t_ch_fee_do_truck.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance_truck ON '
|
|
|
|
|
+'t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance_truck.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD>='+''''+'1'+''''
|
|
|
|
|
+' group by v_op_no.ί<>е<EFBFBD>λ '
|
|
|
|
|
|
|
|
|
|
+'select #bill.ί<>е<EFBFBD>λ,#bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+'
|
|
|
|
|
+'isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'+
|
|
|
|
|
'/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
|
|
|
|
|
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'from #bill left join #fee on #bill.ί<>е<EFBFBD>λ=#fee.ί<>е<EFBFBD>λ '
|
|
|
|
|
+'left join #fee_truck on #bill.ί<>е<EFBFBD>λ=#fee_truck.ί<>е<EFBFBD>λ '
|
|
|
|
|
+'order by #bill.ί<>е<EFBFBD>λ ';
|
|
|
|
|
p_client.open;
|
|
|
|
|
|
|
|
|
|
p_shen.close;
|
|
|
|
|
p_shen.Parameters.ParamByName('SQLStr').value:=
|
|
|
|
|
'DECLARE @all_pay numeric '
|
|
|
|
|
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
|
|
|
|
|
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
|
|
|
|
|
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when @all_pay=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'INTO #bill '
|
|
|
|
|
+'FROM t_op_gain inner join v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' group by v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee '
|
|
|
|
|
+'FROM t_ch_fee_do inner JOIN v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance ON '
|
|
|
|
|
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
|
|
|
|
|
+' group by v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
|
|
|
|
|
+'SELECT v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee_truck '
|
|
|
|
|
+'FROM t_ch_fee_do_truck inner JOIN v_op_no on t_ch_fee_do_truck.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance_truck ON '
|
|
|
|
|
+'t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance_truck.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD>='+''''+'1'+''''
|
|
|
|
|
+' group by v_op_no.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
|
|
|
|
|
+'select #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+'
|
|
|
|
|
+'isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'+
|
|
|
|
|
'/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
|
|
|
|
|
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'from #bill left join #fee on #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'left join #fee_truck on #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'order by #bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';
|
|
|
|
|
p_shen.open;
|
|
|
|
|
|
|
|
|
|
p_op.close;
|
|
|
|
|
p_op.Parameters.ParamByName('SQLStr').value:=
|
|
|
|
|
'DECLARE @all_pay numeric '
|
|
|
|
|
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
|
|
|
|
|
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
|
|
|
|
|
+'SELECT v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when @all_pay=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'INTO #bill '
|
|
|
|
|
+'FROM t_op_gain inner join v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'SELECT v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee '
|
|
|
|
|
+'FROM t_ch_fee_do inner JOIN v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance ON '
|
|
|
|
|
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
|
|
|
|
|
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
|
|
|
|
|
+'SELECT v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee_truck '
|
|
|
|
|
+'FROM t_ch_fee_do_truck inner JOIN v_op_no on t_ch_fee_do_truck.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance_truck ON '
|
|
|
|
|
+'t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance_truck.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD>='+''''+'1'+''''
|
|
|
|
|
+' group by v_op_no.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
|
|
|
|
|
+'select #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+'
|
|
|
|
|
+'isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'+
|
|
|
|
|
'/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
|
|
|
|
|
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'from #bill left join #fee on #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'left join #fee_truck on #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=#fee_truck.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'order by #bill.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';
|
|
|
|
|
p_op.open;
|
|
|
|
|
|
|
|
|
|
p_total.close;
|
|
|
|
|
p_total.Parameters.ParamByName('SQLStr').value:=
|
|
|
|
|
'DECLARE @all_pay numeric '
|
|
|
|
|
+'select @all_pay=isnull((select sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) from t_op_gain'
|
|
|
|
|
+' where t_op_gain.<2E><><EFBFBD><EFBFBD> in (select v_op_no.<2E><><EFBFBD><EFBFBD> from v_op_no '+str_date+')),0) '
|
|
|
|
|
+'SELECT '
|
|
|
|
|
+'sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>) as ë<><C3AB><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0)=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'ltrim(str(sum(t_op_gain.ë<><C3AB><EFBFBD><EFBFBD>)/sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when @all_pay=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''+' else '
|
|
|
|
|
+'(ltrim(str(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>)/@all_pay*100,10,2))+'+''''+'%'+''''+') end) as <20>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,isnull(sum(t_op_gain.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>),0) as <20>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'INTO #bill '
|
|
|
|
|
+'FROM t_op_gain inner join v_op_no on t_op_gain.<2E><><EFBFBD><EFBFBD> = v_op_no.<2E><><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' SELECT '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> * t_ch_fee.<2E><><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee '
|
|
|
|
|
+'FROM t_ch_fee_do inner JOIN v_op_no on t_ch_fee_do.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance ON '
|
|
|
|
|
+'t_ch_fee_do.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_fee ON t_ch_fee_do.CH_ID = t_ch_fee.CH_ID '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do.<2E><><EFBFBD><EFBFBD>='+''''+'3'+''''
|
|
|
|
|
|
|
|
|
|
+'SELECT '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'<= 30 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 30 and DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=60 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 60 and DATEDIFF([day], v_op_no.'+str_date_tongji+','
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<=90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>, '
|
|
|
|
|
+'SUM(CASE WHEN DATEDIFF([day], v_op_no.'+str_date_tongji+', '
|
|
|
|
|
+'t_ch_balance_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) '
|
|
|
|
|
+'> 90 THEN t_ch_fee_do_truck.ԭʼ<D4AD><CABC><EFBFBD><EFBFBD> ELSE 0 END) AS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+'INTO #fee_truck '
|
|
|
|
|
+'FROM t_ch_fee_do_truck inner JOIN v_op_no on t_ch_fee_do_truck.ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=v_op_no.<2E><><EFBFBD><EFBFBD> inner JOIN '
|
|
|
|
|
+'t_ch_balance_truck ON '
|
|
|
|
|
+'t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> = t_ch_balance_truck.<2E>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD> '
|
|
|
|
|
+str
|
|
|
|
|
+' and t_ch_fee_do_truck.<2E><><EFBFBD><EFBFBD>='+''''+'1'+''''
|
|
|
|
|
|
|
|
|
|
+'select #bill.ë<><C3AB><EFBFBD><EFBFBD>,#bill.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>,#bill.<2E>ʽ<EFBFBD>ռ<EFBFBD><D5BC><EFBFBD><EFBFBD>, '
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD>»<EFBFBD><C2BB><EFBFBD><EFBFBD><EFBFBD>,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0))/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'+''''+'%'+''''+' end) as <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,'
|
|
|
|
|
+'(case when #bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>=0 then '+''''+'<27><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD>'+''''
|
|
|
|
|
+' else ltrim(str((isnull(#fee.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+'
|
|
|
|
|
+'isnull(#fee_truck.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0)+isnull(#fee_truck.<2E><><EFBFBD>»<EFBFBD><C2BB><EFBFBD>,0))'+
|
|
|
|
|
'/#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6>*100,10,2))+'
|
|
|
|
|
+''''+'%'+''''+' end) as <20>ϼƻ<CFBC><C6BB><EFBFBD><EFBFBD><EFBFBD> ,#bill.<2E>ϼ<EFBFBD>Ӧ<EFBFBD><D3A6> '
|
|
|
|
|
+'from #bill CROSS JOIN #fee '
|
|
|
|
|
+'CROSS JOIN #fee_truck ';
|
|
|
|
|
p_total.open;
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.dxDBGrid1ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
begin
|
|
|
|
|
Column_sort_pro(Column,p_client,'ί<>е<EFBFBD>λ');
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.dxDBGrid2ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
begin
|
|
|
|
|
Column_sort_pro(Column,p_shen,'<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure Tfrm_rp_zj_total.dxDBGrid4ColumnSorting(Sender: TObject;
|
|
|
|
|
Column: TdxDBTreeListColumn; var Allow: Boolean);
|
|
|
|
|
begin
|
|
|
|
|
Column_sort_pro(Column,p_op,'ҵ<><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
end.
|