You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1057 lines
44 KiB
JavaScript

Ext.namespace('DsTruckRpt');
DsTruckRpt.MsRptPcStatQryIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruckRpt.MsRptPcStatQryIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruckRpt.MsRptPcStatQryIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
fields: [
{ name: 'TRUCKNO', type: 'string' },
{ name: 'IMP40QTY', type: 'number' },
{ name: 'IMP20QTY', type: 'number' },
{ name: 'EXP40QTY', type: 'number' },
{ name: 'EXP20QTY', type: 'number' },
{ name: 'E40QTY', type: 'number' },
{ name: 'E20QTY', type: 'number' },
{ name: 'OT40QTY', type: 'number' },
{ name: 'OT20QTY', type: 'number' },
{ name: 'TOTALMIL', type: 'number' },
{ name: 'NOLOADMIL', type: 'number' },
{ name: 'OVERLOADMIL', type: 'number' },
{ name: 'TON', type: 'number' },
{ name: 'AROUNDTON', type: 'number' },
{ name: 'RATEDFUEL', type: 'number' },
{ name: 'REALFUEL', type: 'number' },
{ name: 'SAVEFUEL', type: 'number' },
{ name: 'YS_DF', type: 'number' },
{ name: 'YS_LY', type: 'number' },
{ name: 'YS_Total', type: 'number' },
{ name: 'YF_LQ', type: 'number' },
{ name: 'YF_XDCFY', type: 'number' },
{ name: 'YF_Total', type: 'number' },
{ name: 'REMARK', type: 'string' }
],
remoteSort: false,
proxy: {
type: 'ajax',
url: '/RptMng/MsRptPcStatQry/QryData',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeList_day = Ext.create('Ext.data.Store', {
fields: [
{ name: 'TRUCKNO', type: 'string' },
{ name: 'EXPDATE', type: 'string' },
{ name: 'PCCOUNT', type: 'number' },
{ name: 'IMP40QTY', type: 'number' },
{ name: 'IMP20QTY', type: 'number' },
{ name: 'EXP40QTY', type: 'number' },
{ name: 'EXP20QTY', type: 'number' },
{ name: 'E40QTY', type: 'number' },
{ name: 'E20QTY', type: 'number' },
{ name: 'OT40QTY', type: 'number' },
{ name: 'OT20QTY', type: 'number' },
{ name: 'TOTALMIL', type: 'number' },
{ name: 'NOLOADMIL', type: 'number' },
{ name: 'OVERLOADMIL', type: 'number' },
{ name: 'TON', type: 'number' },
{ name: 'AROUNDTON', type: 'number' },
{ name: 'RATEDFUEL', type: 'number' },
{ name: 'REALFUEL', type: 'number' },
{ name: 'SAVEFUEL', type: 'number' },
{ name: 'YS_DF', type: 'number' },
{ name: 'YS_LY', type: 'number' },
{ name: 'YS_Total', type: 'number' },
{ name: 'YF_LQ', type: 'number' },
{ name: 'YF_XDCFY', type: 'number' },
{ name: 'YF_Total', type: 'number' },
{ name: 'REMARK', type: 'string' },
{ name: 'detination', type: 'string' }
],
remoteSort: false,
groupField: 'TRUCKNO',
proxy: {
type: 'ajax',
url: '/RptMng/MsRptPcStatQry/QryData_Day',
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
columns: [{
sortable: true,
dataIndex: 'TRUCKNO',
header: '车牌号',
summaryType: 'count',
width: 70
}, {
sortable: true,
dataIndex: 'IMP40QTY',
header: '进口箱40',
summaryType: 'sum',
width: 70,
field: {
xtype: 'numberfield'
}
}, {
sortable: true,
dataIndex: 'IMP20QTY',
header: '进口箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'EXP40QTY',
summaryType: 'sum',
header: '出口箱40',
width: 70
}, {
sortable: true,
dataIndex: 'EXP20QTY',
header: '出口箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'E40QTY',
header: '空箱40',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'E20QTY',
header: '空箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OT40QTY',
header: '其他箱40',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OT20QTY',
header: '其他箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'TOTALMIL',
header: '总里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'NOLOADMIL',
header: '空驶里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OVERLOADMIL',
header: '重驶里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'TON',
header: '运量(吨)',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'AROUNDTON',
header: '周转量',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'RATEDFUEL',
header: '额定油耗',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'REALFUEL',
header: '实际油耗',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'SAVEFUEL',
header: '节油',
summaryType: 'sum',
width: 70
},{
sortable: true,
dataIndex: 'YS_LY',
header: '应收_陆运费',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YS_DF',
header: '应收_垫付',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YS_Total',
header: '应收_合计',
width: 60,
summaryType: 'sum'
}
, {
sortable: true,
dataIndex: 'YF_LQ',
header: '应付_路桥费',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YF_XDCFY',
header: '应付_下单车费用',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YF_Total',
header: '应付_合计',
width: 60,
summaryType: 'sum'
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
id:"bbar1",
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.gridList_day = new Ext.grid.GridPanel({
store: this.storeList_day,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
features: [{
id: 'group',
ftype: 'groupingsummary',
groupHeaderTpl: '{name}',
hideGroupedHeader: false,
enableGroupingMenu: true
}],
columns: [{
sortable: true,
dataIndex: 'TRUCKNO',
header: '车牌号',
summaryType: 'count',
width: 70
}, {
sortable: true,
dataIndex: 'EXPDATE',
header: '派车日期',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
width: 80
}, {
sortable: true,
dataIndex: 'PCCOUNT',
header: '派车次数',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'detination',
header: '目的地',
width: 200
}, {
sortable: true,
dataIndex: 'IMP40QTY',
header: '进口箱40',
summaryType: 'sum',
width: 70,
field: {
xtype: 'numberfield'
}
}, {
sortable: true,
dataIndex: 'IMP20QTY',
header: '进口箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'EXP40QTY',
summaryType: 'sum',
header: '出口箱40',
width: 70
}, {
sortable: true,
dataIndex: 'EXP20QTY',
header: '出口箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'E40QTY',
header: '空箱40',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'E20QTY',
header: '空箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OT40QTY',
header: '其他箱40',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OT20QTY',
header: '其他箱20',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'TOTALMIL',
header: '总里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'NOLOADMIL',
header: '空驶里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'OVERLOADMIL',
header: '重驶里程',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'TON',
header: '运量(吨)',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'AROUNDTON',
header: '周转量',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'RATEDFUEL',
header: '额定油耗',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'REALFUEL',
header: '实际油耗',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'SAVEFUEL',
header: '节油',
summaryType: 'sum',
width: 70
}, {
sortable: true,
dataIndex: 'YS_DF',
header: '应收_陆运费',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YS_LY',
header: '应收_垫付',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YS_Total',
header: '应收_应收合计',
width: 60,
summaryType: 'sum'
},{
sortable: true,
dataIndex: 'YF_LQ',
header: '应付_路桥费',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YF_XDCFY',
header: '应付_下单车费用',
width: 60,
summaryType: 'sum'
},
{
sortable: true,
dataIndex: 'YF_Total',
header: '应付_应付合计',
width: 60,
summaryType: 'sum'
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 200
}
],
// paging bar on the bottom
bbar: Ext.create('Ext.PagingToolbar', {
id: "bbar2",
store: this.storeList_day,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#region menu1
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: '单车单月 日明细统计',
handler: clickHandler
}, {
text: '自营车辆运营状况、核算月报表',
handler: clickHandler_2
}, {
text: '交运物流公司经营情况月报表(附表2)',
tooltip: "注意,对此报表,查询条件最好仅选择派车日的起止日期",
handler: clickHandler_3
}]
});
//#region 打印格式定义
var _this = this;
function clickHandler() {
_this.Print();
};
function clickHandler_2() {
_this.Print_2();
};
function clickHandler_3() {
_this.Print_3();
};
//#endregion
//#endregion
//#region formSearch
//#region formSearch枚举参照相关
var _this = this;
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CompanyModel',
proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: "" }
, callback: function (options, success, response) {
if (success) {
var record = Ext.create('DsTruckMng.ux.CompanyModel', {
'gid': '',
'code': '',
'name': ''
});
_this.storeCompany.add(record);
Ext.getCmp("PS_ORGCODE").setValue("");
}
}
});
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '分公司',
store: this.storeCompany,
forceSelection: true,
id: "PS_ORGCODE",
name: 'PS_ORGCODE',
valueField: 'code',
displayField: 'name'
});
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [/*{
fieldLabel: '分公司',
name: 'PS_ORGCODE'
}*/this.comboxCompany
, {
fieldLabel: '从派车日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_EXPDATEBGN',
id: "PS_EXPDATEBGN"
}, {
fieldLabel: '到派车日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_EXPDATEEND',
id: "PS_EXPDATEEND"
}, {
fieldLabel: '从返回日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_RETURNDATEBEGIN',
id: "PS_RETURNDATEBEGIN"
}, {
fieldLabel: '到返回日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'PS_RETURNDATEEND',
id: "PS_RETURNDATEEND"
}, {
fieldLabel: '车号',
name: 'PS_TRUCKNO',
id: "PS_TRUCKNO"
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-',
{ text: "打印报表", menu: menu1, scope: this }
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 80,
items: [this.formSearch, this.panelBtn]
});
this.page_1 = new Ext.Panel({
id: "page_1",
layout: "border",
region: "center",
title: "单车合计",
items: [this.gridList
]
});
this.page_2 = new Ext.Panel({
id: "page_2",
layout: "border",
region: "center",
title: "单车按日明细",
items: [this.gridList_day
]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [this.page_1, this.page_2]
})
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
var _p = this.MainTab.getActiveTab().id;
if (_p == "page_1") {
this.storeList.load({
params: { start: 0, limit: 500, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
} else {
this.storeList_day.load({
params: { start: 0, limit: 500, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
}
},
getCondition: function () {
var form = this.formSearch.getForm();
var sql = '';
var sqldata = form.getValues();
sql = Ext.JSON.encode(sqldata);
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
,
onExportClick: function (button, event) {
var _p = this.MainTab.getActiveTab().id;
if (_p == "page_1") {
GridExportExcelPage(this.gridList);
//GridExportExcelPage(this.gridList, "合同信息(每商品)");
}
if (_p == "page_2") {
GridExportExcelPage(this.gridList_day);
}
},
Print: function () {
var MainList = "";
var printType = 'RPT_TRUCK_DCDYRMX'; //单车单月日明细
var PS_ORGCODE = Ext.getCmp("PS_ORGCODE").getValue();
var PS_EXPDATEBGN = Ext.getCmp("PS_EXPDATEBGN").getRawValue();
var PS_EXPDATEEND = Ext.getCmp("PS_EXPDATEEND").getRawValue();
var PS_RETURNDATEBEGIN = Ext.getCmp("PS_RETURNDATEBEGIN").getRawValue();
var PS_RETURNDATEEND = Ext.getCmp("PS_RETURNDATEEND").getRawValue();
var PS_TRUCKNO = Ext.getCmp("PS_TRUCKNO").getValue();
if (PS_EXPDATEBGN == "" || PS_EXPDATEBGN == null || PS_EXPDATEEND == "" || PS_EXPDATEEND == null) {
alert("必须确定 派车日期 时间段");
return;
}
var sql1 = " create table #t ([date] date) ";
sql1 = sql1 + " insert into #t exec GetBetweenDays '" + PS_EXPDATEBGN + "','" + PS_EXPDATEEND + "' ";
sql1 = sql1 + " create table #tmpRptPcStat_RPT( ";
sql1 = sql1 + " [TruckNo] [varchar](100), ";
sql1 = sql1 + " [EXPDATE] datetime, ";
sql1 = sql1 + " [PCCOUNT] int, ";
sql1 = sql1 + " [Imp40Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [Imp20Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [Exp40Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [Exp20Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [E40Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [E20Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [OT40Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [OT20Qty] [numeric](10,0) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [TotalMil] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [NoLoadMil] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [OverLoadMil] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [Ton] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [AroundTon] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [RatedFuel] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [RealFuel] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " [SaveFuel] [numeric](19,2) NOT NULL DEFAULT (0), ";
sql1 = sql1 + " YS_DF [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " YS_LY [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " YF_LQ [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " YF_XDCFY [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " YS_Total [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " YF_Total [numeric](19,2) NULL DEFAULT (0), ";
sql1 = sql1 + " [Remark] [varchar](500) ";
sql1 = sql1 + " ) ";
sql1 = sql1 + " declare @p7 int ";
sql1 = sql1 + " set @p7=1 ";
sql1 = sql1 + " declare @p8 nvarchar(2000) ";
sql1 = sql1 + " set @p8=NULL ";
sql1 = sql1 + " insert into #tmpRptPcStat_RPT ";
sql1 = sql1 + " exec sMsRptPcStatQry_Day @PS_ORGCODE=N'" + PS_ORGCODE + "',@PS_EXPDATEBGN=N'" + PS_EXPDATEBGN + "',@PS_EXPDATEEND=N'" + PS_EXPDATEEND + "',@PS_RETURNDATEBGN=N'" + PS_RETURNDATEBEGIN + "',@PS_RETURNDATEEND=N'" + PS_RETURNDATEEND + "',@PS_TRUCKNO=N'" + PS_TRUCKNO + "',@pi_result=@p7 output,@ps_Message=@p8 output ";
sql1 = sql1 + " alter table #tmpRptPcStat_RPT add GID varchar(50) ";
sql1 = sql1 + " update #tmpRptPcStat_RPT set GID=newid() ";
sql1 = sql1 + " insert into #tmpRptPcStat_RPT ([TruckNo],[EXPDATE],[PCCOUNT],[Imp40Qty],[Imp20Qty],[Exp40Qty],[Exp20Qty] ";
sql1 = sql1 + " ,[E40Qty],[E20Qty],[OT40Qty],[OT20Qty],[TotalMil],[NoLoadMil],[OverLoadMil] ";
sql1 = sql1 + " ,[Ton],[AroundTon],[RatedFuel],[RealFuel],[SaveFuel],[YS_DF],[YS_LY],[YS_Total],[YF_LQ],[YF_XDCFY],[YF_Total],[Remark],GID) ";
sql1 = sql1 + " select truckno,date,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'',newid() from #t,tMsWlTruck where truckno like '%" + PS_TRUCKNO + "%' ";
sql1 = sql1 + " delete from #tmpRptPcStat_RPT ";
sql1 = sql1 + " where GID in ( ";
sql1 = sql1 + " select gid from #tmpRptPcStat_RPT a ";
sql1 = sql1 + " where exists (select 1 ";
sql1 = sql1 + " from (select TRUCKNO, EXPDATE ";
sql1 = sql1 + " from #tmpRptPcStat_RPT ";
sql1 = sql1 + " group by TRUCKNO, EXPDATE ";
sql1 = sql1 + " having count(*) > 1) s ";
sql1 = sql1 + " where s.TRUCKNO = a.TRUCKNO ";
sql1 = sql1 + " and s.EXPDATE = a.EXPDATE) ";
sql1 = sql1 + " ) and pccount=0 ";
sql1 = sql1 + " select * from #tmpRptPcStat_RPT order by truckno,EXPDATE ";
sql1 = sql1 + " drop table #tmpRptPcStat_RPT ";
sql1 = sql1 + " drop table #t ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,
Print_2: function () {//交运物流公司经营情况月报表
var MainList = "";
var printType = 'RPT_TRUCK_JYQK_FJ3';
var _T = this.getCondition_2();
if (_T != "") { _T = " where " + _T; }
var sql1 = " select truckno,(select name from company where codename=orgcode) 分公司,sum(isnull(单车运营收入,0)) 单车运营收入,sum(isnull(路桥费,0)) 路桥费 ";
sql1 = sql1 + " ,(select LoadCount from tmswltruck where truckno=_t.truckno) 核载重量 ";
sql1 = sql1 + " ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99019 and EnumValueID=(select trucktype from tmswltruck where truckno=_t.truckno)) 车型 ";
sql1 = sql1 + " ,sum(isnull(轮胎费,0)) 轮胎费,sum(isnull(TotalMil,0)) 总里程 ";
sql1 = sql1 + " ,sum(isnull(OVERLOADMIL,0)) 重驶里程,sum(isnull(NOLOADMIL,0)) 空驶里程 ";
sql1 = sql1 + " ,sum(isnull(TEU,0)) TEU,sum(isnull(Ton,0)) Ton ";
sql1 = sql1 + " ,sum(AmountInCome)/(case sum(isnull(OVERLOADMIL,0)) when 0 then 1 else sum(isnull(OVERLOADMIL,0)) end) 平均费率 ";
sql1 = sql1 + " ,sum(RatedFuel) 额定油耗,sum(RealFuel) 实际油耗,sum(RealFuel-RatedFuel) 节约超额 ";
sql1 = sql1 + " from ";
sql1 = sql1 + " ( ";
sql1 = sql1 + " select orgcode,billno,pc.gid,truckno,expdate "; //TEAMGID,
sql1 = sql1 + " ,(select sum(isnull((case when feetype='1' then Amount else -Amount end),0)) from ch_fee where bsno=pc.gid)as 单车运营收入 ";
sql1 = sql1 + " ,dbo.F_GetFee(pc.gid,1,'路桥费') as 路桥费 ";
sql1 = sql1 + " ,dbo.F_GetFee(pc.gid,1,'轮胎费') as 轮胎费 ";
sql1 = sql1 + " ,pc.TotalMil ,OVERLOADMIL ,NOLOADMIL ";
sql1 = sql1 + " ,pc.ContainerType ";
sql1 = sql1 + " ,(SELECT CtnName FROM VMSTRUCKCTN WHERE CTNCODE=pc.CONTAINERTYPE) AS ContainerType_Ref ";
sql1 = sql1 + " ,isnull((select teu from code_ctn where ctnid=pc.ContainerType),0) TEU ";
sql1 = sql1 + " ,pc.Ton ";
sql1 = sql1 + " ,(select sum(isnull((case when feetype='1' then Amount else 0 end),0)) from ch_fee where bsno=pc.gid) AmountInCome ";
sql1 = sql1 + " ,pc.RatedFuel ,pc.RealFuel ";
sql1 = sql1 + " from tMsWlPcHead pc ";
sql1 = sql1 + _T;
sql1 = sql1 + " ) _t ";
sql1 = sql1 + " group by _t.TruckNo,_t.orgcode order by truckno ";
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
,
Print_3: function () {//交运物流公司经营情况月报表
var MainList = "";
var printType = 'RPT_TRUCK_JYQK_FJ2';
var _T1 = this.getCondition_2();
if (_T1 != "") { _T1 = " and " + _T1; }
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = "";
var PS_EXPDATEBGN = form.findField('PS_EXPDATEBGN').getRawValue();
sql = sql + getAndConSql(sql, PS_EXPDATEBGN, "pc.EXPDATE >= '" + PS_EXPDATEBGN + "'");
var PS_EXPDATEEND = form.findField('PS_EXPDATEEND').getRawValue();
sql = sql + getAndConSql(sql, PS_EXPDATEEND, "pc.EXPDATE <= '" + PS_EXPDATEEND + " 23:59:59'");
if (sql != "") { sql = " where " + sql; }
var PS_EXPDATEBGN_2 = "";
var PS_EXPDATEEND_2 = "";
var PS_EXPDATEBGN_3 = "";
var PS_EXPDATEEND_3 = "";
if (PS_EXPDATEBGN == null || PS_EXPDATEEND == null) {
alert("请选择 派车日期 区间");
return;
} else {
//计算去年同期和今年以来两个时间区间
var _s = Ext.util.Format.date(form.findField('PS_EXPDATEBGN').getValue(), 'Y-m-d');
var arr = _s.split("-");
if (arr[1] == 2 && arr[2] == 29) {
var PS_EXPDATEBGN_2 = new Date(Number(arr[0]) - 1, Number(arr[1])-1, Number(arr[2]) - 1);
}
else {
var PS_EXPDATEBGN_2 = new Date(Number(arr[0]) - 1, Number(arr[1])-1, Number(arr[2]));
}
PS_EXPDATEBGN_2 = Ext.util.Format.date(PS_EXPDATEBGN_2, 'Y-m-d');
var _s = Ext.util.Format.date(form.findField('PS_EXPDATEEND').getValue(), 'Y-m-d');
var arr = _s.split("-");
if (arr[1] == 2 && arr[2] == 29) {
var PS_EXPDATEEND_2 = new Date(Number(arr[0]) - 1, Number(arr[1])-1, Number(arr[2]) - 1);
}
else {
var PS_EXPDATEEND_2 = new Date(Number(arr[0]) - 1, Number(arr[1])-1, Number(arr[2]));
}
PS_EXPDATEEND_2 = Ext.util.Format.date(PS_EXPDATEEND_2, 'Y-m-d');
var _s = Ext.util.Format.date(form.findField('PS_EXPDATEBGN').getValue(), 'Y-m-d');
var arr = _s.split("-");
var PS_EXPDATEBGN_3 = new Date(Number(arr[0]), 0, 1);
PS_EXPDATEBGN_3 = Ext.util.Format.date(PS_EXPDATEBGN_3, 'Y-m-d');
PS_EXPDATEEND_3 = PS_EXPDATEEND;
}
//
var sql1 = " select FGS,(select count(*) from tmswltruck where OrgCode=(select codename from company where name=fgs)) 车辆数 ";
sql1 = sql1 + " ,sum(income) income,sum(t.TotalMil) TotalMil,sum(t.OverLoadMil) OverLoadMil,sum(TEU) TEU,sum(TON) ton,sum(t.JZX_PT) JZX_PT ";
sql1 = sql1 + " ,sum(t.JZX_PZ) JZX_PZ,sum(t.DJYS) DJYS,sum(t.PHYS_ALL) PHYS_ALL,sum(t.PHYS_ZXF) PHYS_ZXF,sum(t.JZC_CC) JZC_CC,sum(jzc) jzc ";
sql1 = sql1 + " ,0 码头TEU,0 码头income ";
sql1 = sql1 + " from( ";
sql1 = sql1 + " select truckno,isnull((select name from company where codename =(select orgcode from tmswltruck where pc.TruckNo=TruckNo)),'其他') FGS ";
sql1 = sql1 + " ,dbo.f_getincome(pc.gid) income,pc.TotalMil,pc.OverLoadMil ";
sql1 = sql1 + " ,isnull((select teu from code_ctn where ctnid=pc.ContainerType),0) TEU ";
sql1 = sql1 + " ,pc.Ton ";
sql1 = sql1 + " ,case when pcbilltype=0 and bstype not in (5,6) then isnull(dbo.f_getincome(pc.gid),0) else 0 end JZX_PT ";
sql1 = sql1 + " ,case when pcbilltype=0 and bstype =6 then dbo.f_getincome(pc.gid) else 0 end JZX_PZ ";
sql1 = sql1 + " ,case when pcbilltype=2 then dbo.f_getincome(pc.gid) else 0 end DJYS ";
sql1 = sql1 + " ,case when pcbilltype=1 then dbo.f_getincome(pc.gid) else 0 end PHYS_ALL ";
sql1 = sql1 + " ,case when pcbilltype=1 then dbo.F_GetFee(pc.gid,1,'装卸费')+dbo.F_GetFee(pc.gid,1,'吊装费') ";
sql1 = sql1 + " -dbo.F_GetFee(pc.gid,2,'装卸费')-dbo.F_GetFee(pc.gid,2,'吊装费') else 0 end PHYS_ZXF ";
sql1 = sql1 + " ,case when pcbilltype=0 and bstype =5 then 1 else 0 end JZC_CC ";
sql1 = sql1 + " ,case when pcbilltype=0 and bstype =5 then dbo.f_getincome(pc.gid) else 0 end JZC ";
sql1 = sql1 + " from tmswlpchead pc where pc.TruckNo<>'' " + _T1 + " ) t where FGS<>'其他' ";
sql1 = sql1 + " group by fgs ";
sql1 = sql1 + " union all ";
sql1 = sql1 + " select '中海公司(码头)',(select count(*) from tmswltruck where TruckNo like '%港%'),sum(amount),0,0,0,0,0,0,0,0,0,0,0,sum(teu),sum(amount) from ";
sql1 = sql1 + " ( select expdate,(amount_1-amount_2) amount,(select sum(teu) from tMsWl_Port_Ctn where LINKID=pc.gid) teu from tMsWl_Port pc " + sql + " )t2 ";
//去年同期
var _T2 = " ";
_T2 = _T2 + getAndConSql(sql, PS_EXPDATEBGN_2, "pc.EXPDATE >= '" + PS_EXPDATEBGN_2 + "'");
_T2 = _T2 + getAndConSql(sql, PS_EXPDATEEND_2, "pc.EXPDATE <= '" + PS_EXPDATEEND_2 + " 23:59:59'");
//if (_T2 != "") { _T2 = " and " + _T2; }
var sql2 = " select FGS,(select count(*) from tmswltruck where OrgCode=(select codename from company where name=fgs)) 车辆数 ";
sql2 = sql2 + " ,sum(income) income,sum(t.TotalMil) TotalMil,sum(t.OverLoadMil) OverLoadMil,sum(TEU) TEU,sum(TON) ton,sum(t.JZX_PT) JZX_PT ";
sql2 = sql2 + " ,sum(t.JZX_PZ) JZX_PZ,sum(t.DJYS) DJYS,sum(t.PHYS_ALL) PHYS_ALL,sum(t.PHYS_ZXF) PHYS_ZXF,sum(t.JZC_CC) JZC_CC,sum(jzc) jzc ";
sql2 = sql2 + " ,0 码头TEU,0 码头income ";
sql2 = sql2 + " from( ";
sql2 = sql2 + " select truckno,isnull((select name from company where codename =(select orgcode from tmswltruck where pc.TruckNo=TruckNo)),'其他') FGS ";
sql2 = sql2 + " ,dbo.f_getincome(pc.gid) income,pc.TotalMil,pc.OverLoadMil ";
sql2 = sql2 + " ,isnull((select teu from code_ctn where ctnid=pc.ContainerType),0) TEU ";
sql2 = sql2 + " ,pc.Ton ";
sql2 = sql2 + " ,case when pcbilltype=0 and bstype not in (5,6) then isnull(dbo.f_getincome(pc.gid),0) else 0 end JZX_PT ";
sql2 = sql2 + " ,case when pcbilltype=0 and bstype =6 then dbo.f_getincome(pc.gid) else 0 end JZX_PZ ";
sql2 = sql2 + " ,case when pcbilltype=2 then dbo.f_getincome(pc.gid) else 0 end DJYS ";
sql2 = sql2 + " ,case when pcbilltype=1 then dbo.f_getincome(pc.gid) else 0 end PHYS_ALL ";
sql2 = sql2 + " ,case when pcbilltype=1 then dbo.F_GetFee(pc.gid,1,'装卸费')+dbo.F_GetFee(pc.gid,1,'吊装费') ";
sql2 = sql2 + " -dbo.F_GetFee(pc.gid,2,'装卸费')-dbo.F_GetFee(pc.gid,2,'吊装费') else 0 end PHYS_ZXF ";
sql2 = sql2 + " ,case when pcbilltype=0 and bstype =5 then 1 else 0 end JZC_CC ";
sql2 = sql2 + " ,case when pcbilltype=0 and bstype =5 then dbo.f_getincome(pc.gid) else 0 end JZC ";
sql2 = sql2 + " from tmswlpchead pc where pc.TruckNo<>'' " + _T2 + " ) t where FGS<>'其他' ";
sql2 = sql2 + " group by fgs ";
sql2 = sql2 + " union all ";
sql2 = sql2 + " select '中海公司(码头)',(select count(*) from tmswltruck where TruckNo like '%港%'),sum(amount),0,0,0,0,0,0,0,0,0,0,0,sum(teu),sum(amount) from ";
sql2 = sql2 + " ( select expdate,(amount_1-amount_2) amount,(select sum(teu) from tMsWl_Port_Ctn where LINKID=pc.gid) teu from tMsWl_Port pc where 1=1 " + _T2 + " )t2 ";
//今年以来
var _T3 = " ";
_T3 = _T3 + getAndConSql(sql, PS_EXPDATEBGN_3, "pc.EXPDATE >= '" + PS_EXPDATEBGN_3 + "'");
_T3 = _T3 + getAndConSql(sql, PS_EXPDATEEND_3, "pc.EXPDATE <= '" + PS_EXPDATEEND_3 + " 23:59:59'");
//if (_T3 != "") { _T3 = " where " + _T3; }
var sql3 = " select FGS,(select count(*) from tmswltruck where OrgCode=(select codename from company where name=fgs)) 车辆数 ";
sql3 = sql3 + " ,sum(income) income,sum(t.TotalMil) TotalMil,sum(t.OverLoadMil) OverLoadMil,sum(TEU) TEU,sum(TON) ton,sum(t.JZX_PT) JZX_PT ";
sql3 = sql3 + " ,sum(t.JZX_PZ) JZX_PZ,sum(t.DJYS) DJYS,sum(t.PHYS_ALL) PHYS_ALL,sum(t.PHYS_ZXF) PHYS_ZXF,sum(t.JZC_CC) JZC_CC,sum(jzc) jzc ";
sql3 = sql3 + " ,0 码头TEU,0 码头income ";
sql3 = sql3 + " from( ";
sql3 = sql3 + " select truckno,isnull((select name from company where codename =(select orgcode from tmswltruck where pc.TruckNo=TruckNo)),'其他') FGS ";
sql3 = sql3 + " ,dbo.f_getincome(pc.gid) income,pc.TotalMil,pc.OverLoadMil ";
sql3 = sql3 + " ,isnull((select teu from code_ctn where ctnid=pc.ContainerType),0) TEU ";
sql3 = sql3 + " ,pc.Ton ";
sql3 = sql3 + " ,case when pcbilltype=0 and bstype not in (5,6) then isnull(dbo.f_getincome(pc.gid),0) else 0 end JZX_PT ";
sql3 = sql3 + " ,case when pcbilltype=0 and bstype =6 then dbo.f_getincome(pc.gid) else 0 end JZX_PZ ";
sql3 = sql3 + " ,case when pcbilltype=2 then dbo.f_getincome(pc.gid) else 0 end DJYS ";
sql3 = sql3 + " ,case when pcbilltype=1 then dbo.f_getincome(pc.gid) else 0 end PHYS_ALL ";
sql3 = sql3 + " ,case when pcbilltype=1 then dbo.F_GetFee(pc.gid,1,'装卸费')+dbo.F_GetFee(pc.gid,1,'吊装费') ";
sql3 = sql3 + " -dbo.F_GetFee(pc.gid,2,'装卸费')-dbo.F_GetFee(pc.gid,2,'吊装费') else 0 end PHYS_ZXF ";
sql3 = sql3 + " ,case when pcbilltype=0 and bstype =5 then 1 else 0 end JZC_CC ";
sql3 = sql3 + " ,case when pcbilltype=0 and bstype =5 then dbo.f_getincome(pc.gid) else 0 end JZC ";
sql3 = sql3 + " from tmswlpchead pc where pc.TruckNo<>'' " + _T3 + " ) t where FGS<>'其他' ";
sql3 = sql3 + " group by fgs ";
sql3 = sql3 + " union all ";
sql3 = sql3 + " select '中海公司(码头)',(select count(*) from tmswltruck where TruckNo like '%港%'),sum(amount),0,0,0,0,0,0,0,0,0,0,0,sum(teu),sum(amount) from ";
sql3 = sql3 + " ( select expdate,(amount_1-amount_2) amount,(select sum(teu) from tMsWl_Port_Ctn where LINKID=pc.gid) teu from tMsWl_Port pc where 1=1 " + _T3 + " )t2 ";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
}
, getCondition_2: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = "";
/*
var PS_ORGCODE = Ext.getCmp("PS_ORGCODE").getValue();
var PS_EXPDATEBGN = Ext.getCmp("PS_EXPDATEBGN").getRawValue();
var PS_EXPDATEEND = Ext.getCmp("PS_EXPDATEEND").getRawValue();
var PS_RETURNDATEBEGIN = Ext.getCmp("PS_RETURNDATEBEGIN").getRawValue();
var PS_RETURNDATEEND = Ext.getCmp("PS_RETURNDATEEND").getRawValue();
var PS_TRUCKNO = Ext.getCmp("PS_TRUCKNO").getValue();*/
var PS_ORGCODE = form.findField('PS_ORGCODE').getValue();
sql = sql + getAndConSql(sql, PS_ORGCODE, " PC.ORGCODE ='" + PS_ORGCODE + "' ");
var PS_EXPDATEBGN = form.findField('PS_EXPDATEBGN').getRawValue();
sql = sql + getAndConSql(sql, PS_EXPDATEBGN, "pc.EXPDATE >= '" + PS_EXPDATEBGN + "'");
var PS_EXPDATEEND = form.findField('PS_EXPDATEEND').getRawValue();
sql = sql + getAndConSql(sql, PS_EXPDATEEND, "pc.EXPDATE <= '" + PS_EXPDATEEND + " 23:59:59'");
var PS_TRUCKNO = form.findField('PS_TRUCKNO').getValue();
sql = sql + getAndConSql(sql, PS_TRUCKNO, " PC.TRUCKNO like '%" + PS_TRUCKNO + "%' ");
return sql;
}
});