Ext.namespace('Shipping'); Shipping.PiLiangTracking = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.PiLiangTracking.superclass.constructor.call(this); }; Ext.extend(Shipping.PiLiangTracking, Ext.Panel, { PageSize: 15, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, isAudit: '', BSNO: '', initUIComponents: function () { this.formname = "formMsOpRailwayTracking"; //页面名称 //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsOpRailwayModel', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpRailway/GetDataList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); Ext.define('MsCodeOpStatusDetail', { extend: 'Ext.data.Model', idProperty: 'GID', fields: [ { name: 'GID', type: 'string' }, { name: 'SerialNo', type: 'number' }, { name: 'OPSTATUS', type: 'string' }, { name: 'REMARKS', type: 'string' }, { name: 'OPTYPE', type: 'string' }, { name: 'OPTYPESTR', type: 'string' } ] }); Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { width: 30 }); this.initgirdcolums = [{ sortable: true, id: '', dataIndex: '', header: '', width: 0 }, { sortable: true, id: '', dataIndex: 'BSNO', header: '业务编号', width: 0 }, { sortable: true, id: '', dataIndex: 'CUSTNO', header: 'SO', width: 120, renderer: function (value, cellmeta) { return "" + value + ""; } }, { sortable: true, id: '', dataIndex: 'CUSTOMERNAME', header: 'Client', width: 120 }, { sortable: true, id: '', dataIndex: 'ORDERNO', header: 'ClientRef', width: 120 }, { sortable: true, id: '', dataIndex: 'TRANSTYPE', header: 'BizKind', width: 120 }, { sortable: true, id: '', dataIndex: 'PlACERECEIPT', header: 'ReceiptPL', width: 120 }, { sortable: true, id: '', dataIndex: 'PLACELOAD', header: 'POL', width: 120 }, { sortable: true, id: '', dataIndex: 'PLACETRANSITENAME', header: 'POT', width: 120 }, { sortable: true, id: '', dataIndex: 'DESTINATIONID', header: 'PODCode', width: 120 }, { sortable: true, id: '', dataIndex: 'DESTINATIONENAME', header: 'POD', width: 120 }, { sortable: true, id: '', dataIndex: 'SALE', header: '揽货人', width: 80 }, { sortable: true, id: '', dataIndex: 'INPUTBY', header: '录入人', width: 80 }, { sortable: true, id: '', dataIndex: 'BSDATE', header: '订舱日期', width: 80 }, { sortable: true, id: '', dataIndex: 'BSSTATUSREF', header: '业务锁定', align: 'center', width: 60, renderer: function (value, cellmeta) { if (value == '锁定') { return ""; } } }, { sortable: true, id: '', dataIndex: 'FEESTATUSREF', header: '费用锁定', align: 'center', width: 60, renderer: function (value, cellmeta) { if (value == '锁定') { return ""; } } } , { sortable: true, id: '', dataIndex: 'OPSTATUS', header: '业务状态', width: 60 }, { sortable: true, id: '', dataIndex: 'TRANSNO', header: '运输单号', width: 120 }, { sortable: true, id: '', dataIndex: 'CTNALL', header: '箱型', width: 80 }, { sortable: true, id: '', dataIndex: 'CTNNUM', header: '箱量', width: 80 }, { sortable: true, id: '', dataIndex: 'GOODSNAME', header: '品名', width: 120 }, { sortable: true, id: '', dataIndex: 'PKGS', header: '件数', width: 80 }, { sortable: true, id: '', dataIndex: 'KGS', header: '毛重', width: 80 }, { sortable: true, id: '', dataIndex: 'CBM', header: '尺码', width: 80 }, { sortable: true, id: '', dataIndex: 'ACCDATE', header: '会计期间', width: 60 }, { sortable: true, id: '', dataIndex: 'BSSOURCE', header: '业务来源', width: 80 }, { sortable: true, id: '', dataIndex: 'BSSOURCEDETAIL', header: '贸易条款', width: 80 }, { sortable: true, id: '', dataIndex: 'CREATETIME', header: '创建时间', width: 120 }]; this.girdcolums = this.initgirdcolums; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, height: 180, region: 'north', split: true, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, selModel: this.GridCheckBoxModel, disableSelection: false, columns: this.girdcolums, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.girdcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.gridList.reconfigure(this.storeList, this.girdcolums); this.gridList.columns[0] = new Ext.grid.RowNumberer(); //////////////////////////////////////////////// //#region formSearch //#region formSearch枚举参照相关 //#endregion //业务来源 //国际港口(进口装货港、出口卸货港) this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeRailwayPort', proxy: { url: '/MvcShipping/MsOpRailway/GetPortList' } }); this.storeCodeDisport.load(); //国内港口(出口装货港、进口卸货港) this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeRailwayPort', proxy: { url: '/MvcShipping/MsOpRailway/GetPortList' } }); this.storeCodeLoadport.load(); this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '发货站', store: this.storeCodeLoadport, forceSelection: true, name: 'PLACELOAD', valueField: 'PORTCNAME', displayField: 'CODEANDNAME', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '到达站', store: this.storeCodeDisport, forceSelection: true, name: 'DESTINATION', valueField: 'PORTENAME', displayField: 'CODEANDNAME', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); //客户加载_委托单位 this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} }); //委托单位 _this = this; this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '委托单位', store: this.storeCustCode, forceSelection: true, name: 'CUSTOMERNAME', valueField: 'CustName', displayField: 'CodeAndName', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }); this.StorePLACETRANSIT = Ext.create('Ext.data.Store', { fields: ['PORT', 'PORTID'] }); this.StorePLACETRANSIT.add({ "PORT": "Dostyk-eks", "PORTID": "ALASHANKOU" }); this.StorePLACETRANSIT.add({ "PORT": "Grodekovo", "PORTID": "SUIFENHE" }); this.StorePLACETRANSIT.add({ "PORT": "Dzamiin-Üüd", "PORTID": "ERLIAN" }); this.StorePLACETRANSIT.add({ "PORT": "Zabaykal'sk", "PORTID": "MANZHOULI" }); this.StorePLACETRANSIT.add({ "PORT": "Xinuiju", "PORTID": "DANDONG" }); this.StorePLACETRANSIT.add({ "PORT": "Brest-Tsentral'nny(V PNR)", "PORTID": "PINGXIANG" }); this.StorePLACETRANSIT.add({ "PORT": "Altynko-eks", "PORTID": "HORGOS" }); this.comboxPLACETRANSIT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '边境口岸', store: this.StorePLACETRANSIT, forceSelection: true, name: 'PLACETRANSIT', valueField: 'PORTID', displayField: 'PORT' }); // this.StoreSTATUS = Ext.create('Ext.data.Store', { // fields: ['STATUS', 'STATUSID'] // }); // this.StoreSTATUS.add({ "STATUS": "订单未装", "STATUSID": "1" }); // this.StoreSTATUS.add({ "STATUS": "已装未发", "STATUSID": "2" }); // this.StoreSTATUS.add({ "STATUS": "已发出在途", "STATUSID": "3" }); // this.StoreSTATUS.add({ "STATUS": "所有未交付", "STATUSID": "4" }); // this.StoreSTATUS.add({ "STATUS": "已交付", "STATUSID": "5" }); // this.comboxSTATUS = Ext.create('DsExt.ux.RefTableCombox', { // fieldLabel: '运踪状态', // store: this.StoreSTATUS, // forceSelection: true, // name: 'TRACKSTATUS', // valueField: 'STATUSID', // displayField: 'STATUS' // }); this.storeOpStatus = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeOpStatusDetail', proxy: { url: '/MvcShipping/MsCodeOpStatus/GetBodyList' } }); this.storeOpStatus.load({ params: { condition: "OPTYPE='铁路运输'"} }); this.comboxSTATUS = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeOpStatus, forceSelection: true, fieldLabel: '运踪状态', name: 'TRACKSTATUS', valueField: 'OPSTATUS', displayField: 'OPSTATUS' }); 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: 'MblNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '箱号', name: 'CtnNo', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '订舱日期', format: 'Y-m-d', xtype: 'datefield', name: 'ETDbgn', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, { fieldLabel: '到', format: 'Y-m-d', xtype: 'datefield', name: 'ETDend', enableKeyEvents: true, listeners: { specialkey: function (field, e) { if (e.getKey() == e.ENTER) { _this.onRefreshClick(); } } } }, this.comboxSTATUS ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxPORTLOAD, this.comboxPORTDISCHARGE, this.comboxPLACETRANSIT, this.comboxCustCode, { xtype: 'hiddenfield' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); this.StoreCTNEF = Ext.create('Ext.data.Store', { fields: ['CTNEF'] }); this.StoreCTNEF.add({ "CTNEF": "Full" }); this.StoreCTNEF.add({ "CTNEF": "Empty" }); this.comboxCTNEF = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCTNEF, forceSelection: true, name: 'EFCNTR', valueField: 'CTNEF', displayField: 'CTNEF', value: 'Full' }); Ext.define('MsCodeRailwayFrPort', { extend: 'Ext.data.Model', idProperty: 'GID', fields: [ { name: 'GID', type: 'string' }, { name: 'PORTID', type: 'string' }, { name: 'PORTENAME', type: 'string' }, { name: 'PORTCNAME', type: 'string' }, { name: 'PORTRNAME', type: 'string' }, { name: 'CODEANDNAME', type: 'string' }, { name: 'COUNTRY', type: 'string' }, { name: 'COUNTRYECODE', type: 'string' }, { name: 'COUNTRYRCODE', type: 'string' }, { name: 'COUNTRYCODE', type: 'string' }, { name: 'COUNTRYENAME', type: 'string' }, { name: 'COUNTRYRNAME', type: 'string' }, { name: 'CITYENAME', type: 'string' }, { name: 'CITYCNAME', type: 'string' }, { name: 'PORTDETAIL', type: 'string' }, { name: 'ADDR', type: 'string' }, { name: 'RAILBUREAU', type: 'string' }, { name: 'DTALSHANKOU', type: 'number' }, { name: 'DTMANZHOULI', type: 'number' }, { name: 'DTERLIAN', type: 'number' }, { name: 'DTSUIFENHE', type: 'number' }, { name: 'DTDANDONG', type: 'number' }, { name: 'DTPINGXIANG', type: 'number' }, { name: 'DTHORGOS', type: 'number' }, { name: 'ISOFTEN', type: 'boolean' }, { name: 'WORKPOWER', type: 'string' }, { name: 'IS20', type: 'boolean' }, { name: 'IS40', type: 'boolean' }, { name: 'IS48', type: 'boolean' }, { name: 'IS50', type: 'boolean' }, { name: 'ISTANK', type: 'boolean' }, { name: 'ISBULK', type: 'boolean' }, { name: 'ISFLAT', type: 'boolean' }, { name: 'ISDSCAR', type: 'boolean' }, { name: 'ISCN', type: 'boolean' }, { name: 'PORTTYPE', type: 'string' }, { name: 'PORTTYPEREF', type: 'string' }, { name: 'BORDERPORTID', type: 'string' }, { name: 'ISBORDERPORT', type: 'boolean' }, { name: 'REMARKS', type: 'string' } ] }); this.storeCodeLocation = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeRailwayFrPort', proxy: { url: '/MvcShipping/MsOpRailway/GetAllPortList' } }); this.storeCodeLocation.load(); this.comboxLOCATION = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCodeLocation, forceSelection: true, name: 'LOCATION', valueField: 'PORTENAME', displayField: 'CODEANDNAME' }); this.storecoderailwaytracking = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeRailwayTracking', proxy: { url: '/MvcShipping/MsOpRailway/GetCodeTrackingList' } }); this.storecoderailwaytracking.load(); this.comboxACTIVITY = Ext.create('DsExt.ux.RefTableCombox', { store: this.storecoderailwaytracking, forceSelection: true, name: 'ACTIVITY', valueField: 'TRACKINGCODE', displayField: 'TRACKINGCODE' }); this.storeBodyListdetail = Ext.create('Ext.data.Store', { model: 'MsOpRailwayTracking', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpRailway/GetBodyTrackingList', reader: { id: 'TK_ID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridListdetail = new Ext.grid.GridPanel({ store: this.storeBodyListdetail, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', tbar: [{ text: '增加明细', tooltip: '增加明细', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event); }, scope: this }, '-', { text: '保存明细', tooltip: '保存明细', iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', id: "btndeldetail", iconCls: "btndeletedetail", handler: function (button, event) { this.onDelDetailClick(button, event); }, scope: this }], columns: [{ sortable: true, dataIndex: 'TK_ID', header: '编号', // headerHeight:80, hidden: true, width: 0 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 0 }, { sortable: true, dataIndex:'SORTNO', text: '序号\r\nNO', width: 30 }, { dataIndex: 'CNTRNO', header: 'CNTR NO', width: 100, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'EFCNTR', header: 'Empty/Full', width: 70, editor: this.comboxCTNEF }, { dataIndex: 'TRAINNO', header: 'CN Wagon#', width: 150, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'FRTRAINNO', header: 'CIS Wagon#', width: 150, editor: { xtype: 'textfield', selectOnFocus: true } }, { dataIndex: 'ACTIVITY', header: 'Activity', width: 150, editor: this.comboxACTIVITY }, { dataIndex: 'LOCATION', header: 'Location', width: 150, editor: this.comboxLOCATION }, { dataIndex: 'LOCATIONID', header: 'Location(RU)', width: 150, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'TRACKDATE', header: 'Date', allowBlank: false, editor: { xtype: 'datefield', format: 'Y-m-d', selectOnFocus: true }, renderer: Ext.util.Format.dateRenderer('Y-m-d'), width: 120 }, { dataIndex: 'DISTANCE', header: 'To Border', width: 80, editor: { xtype: 'numberfield', selectOnFocus: true } }, { dataIndex: 'DISTANCEDEST', header: 'To Destination', width: 80, editor: { xtype: 'numberfield', selectOnFocus: true } }, { dataIndex: 'REMARK', header: 'Remark', width: 250, editor: { xtype: 'textfield', selectOnFocus: true } }] }); this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CodeCtnModel', proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' } }); this.storeCodeCtn.load(); this.comboxCTNALL2 = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '箱型', store: this.storeCodeCtn, forceSelection: true, valueField: 'CTN', displayField: 'CTN' }); this.storeBodyCtnList = Ext.create('Ext.data.Store', { model: 'MsOpSeaeDetail', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsOpSeae/GetBodyList', reader: { id: 'BsNo,CTNCODE,CTN_ID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCtnCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridListCtn = new Ext.grid.GridPanel({ store: this.storeBodyCtnList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCtnCellEditing], selType: 'cellmodel', tbar: [{ text: '增加', tooltip: '增加', id: "btnadddctn", iconCls: "btnadddetail", handler: function (button, event) { this.onAddCtnClick(button, event); }, scope: this }, '-', { text: '保存', tooltip: '保存', iconCls: "btnsave", handler: function (button, event) { this.onPostCtnClick(button, event); }, scope: this }, '-', { text: '删除', tooltip: '删除', id: "btndelctn", iconCls: "btndeletedetail", handler: function (button, event) { this.deleteCtn(button, event); }, scope: this }], columns: [{ sortable: true, dataIndex: 'CTN_ID', header: '编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 0 }, { dataIndex: 'CTNALL', header: '箱型', width: 48, editor: this.comboxCTNALL2 }, { dataIndex: 'CNTRNO', header: '箱号', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }] }); //#endregion this.panelBodyCtn = new Ext.Panel({ title: '集装箱信息', layout: "border", region: "west", width: 220, //margin: '5 10', frame: true, items: [this.gridListCtn] }); //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "重置条件", iconCls: "btnreset", handler: function (button, event) { this.onClearSql(button, event); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", menu: [ { text: "保存", handler: function (button, event) { this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.girdcolums, 1, true); } }, { text: "初始化", handler: function (menu, event) { _this.InitGrid(_this.initgirdcolums); _this.girdcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridList.columns, _this.initgirdcolums, 1, true); } }], scope: this }, '-', { text: "打印", iconCls: 'btnprint', menu: [ { text: "全部", handler: function (menu, event) { _this.Print(); } }, { text: "选择打印", handler: function (menu, event) { _this.PrintSelect(); } }], scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 95, items: [this.formSearch, this.panelBtn] }); this.paneldetail = new Ext.Panel({ title: '运踪明细', layout: "border", region: 'center', items: [ this.gridListdetail ] }); this.panelBody = new Ext.Panel({ layout: "border", region: "center", frame: true, items: [this.panelBodyCtn, this.paneldetail] }); Ext.apply(this, { items: [this.panelTop, this.gridList, this.panelBody] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.onRefreshClick(); this.storeList.on('load', function (store, records) { if (store.getCount() > 0) { this.gridList.getSelectionModel().select(0); } }, this); _this = this; this.gridList.getSelectionModel().on('select', function (model, record, index) { this.BSNO = record.data.BSNO; var sql = ""; sql = " BSNO='" + this.BSNO + "'"; _this.storeBodyListdetail.load({ params: { condition: sql, isfirst: true} }); _this.storeBodyCtnList.load({ params: { condition: sql} }); }, this); this.gridListCtn.getSelectionModel().on('select', function (model, record, index) { var cntrno = record.data.CNTRNO; var sql = ""; sql = " BSNO='" + this.BSNO + "' and CNTRNO='" + cntrno + "'"; _this.storeBodyListdetail.load({ params: { condition: sql,isfirst:false} }); }, this); //绑定事件 this.gridListdetail.on('edit', function (editor, e, eOpts) { this.gridAfterEdit(editor, e, eOpts); }, this); this.InitGrid(this.girdcolums); }, //end initUIComponents //#region 集装箱按钮事件 onAddDetailClick: function (button, event) { this.addDetail(); }, //end onAddDetailClick onDelDetailClick: function (button, event) { this.deleteDetail(); }, //onDelDetailClick onUpDetailClick: function (button, event) { this.UpDetail(); }, //end onAddDetailClick gridAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; if (e.field == 'LOCATION') { var selections = this.gridList.getSelectionModel().getSelection(); var record = selections[0]; var PLACETRANSIT = record.data.PLACETRANSIT; var DESTINATIONENAME = record.data.DESTINATIONENAME; var LOCATION = e.record.data['LOCATION']; var selectrecords = DsStoreQueryBy(this.storeCodeLocation, 'PORTENAME', LOCATION); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; var porttype = selectdata.PORTTYPE; e.record.set('LOCATIONID', selectdata.PORTRNAME); if (porttype == 'T') { e.record.set('DISTANCE', 0); var destrecords = DsStoreQueryBy(this.storeCodeLocation, 'PORTENAME', DESTINATIONENAME); if (PLACETRANSIT == 'ALASHANKOU') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTALSHANKOU) - parseFloat(selectdata.DTALSHANKOU)); } } else if (PLACETRANSIT == 'SUIFENHE') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTSUIFENHE) - parseFloat(selectdata.DTSUIFENHE)); } } else if (PLACETRANSIT == 'ERLIAN') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTERLIAN) - parseFloat(selectdata.DTERLIAN)); } } else if (PLACETRANSIT == 'MANZHOULI') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTMANZHOULI) - parseFloat(selectdata.DTMANZHOULI)); } } else if (PLACETRANSIT == 'DANDONG') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTDANDONG) - parseFloat(selectdata.DTDANDONG)); } } else if (PLACETRANSIT == 'PINGXIANG') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTPINGXIANG) - parseFloat(selectdata.DTPINGXIANG)); } } else if (PLACETRANSIT == 'HORGOS') { if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(destdata.DTHORGOS) - parseFloat(selectdata.DTHORGOS)); } } } else { var destrecords = DsStoreQueryBy(this.storeCodeLocation, 'PORTENAME', DESTINATIONENAME); if (PLACETRANSIT == 'ALASHANKOU') { e.record.set('DISTANCE', selectdata.DTALSHANKOU); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTALSHANKOU) + parseFloat(destdata.DTALSHANKOU)); } } else if (PLACETRANSIT == 'SUIFENHE') { e.record.set('DISTANCE', selectdata.DTSUIFENHE); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTSUIFENHE) + parseFloat(destdata.DTSUIFENHE)); } } else if (PLACETRANSIT == 'ERLIAN') { e.record.set('DISTANCE', selectdata.DTERLIAN); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTERLIAN) + parseFloat(destdata.DTERLIAN)); } } else if (PLACETRANSIT == 'MANZHOULI') { e.record.set('DISTANCE', selectdata.DTMANZHOULI); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTMANZHOULI) + parseFloat(destdata.DTMANZHOULI)); } } else if (PLACETRANSIT == 'DANDONG') { e.record.set('DISTANCE', selectdata.DTDANDONG); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTDANDONG) + parseFloat(destdata.DTDANDONG)); } } else if (PLACETRANSIT == 'PINGXIANG') { e.record.set('DISTANCE', selectdata.DTPINGXIANG); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTPINGXIANG) + parseFloat(destdata.DTPINGXIANG)); } } else if (PLACETRANSIT == 'HORGOS') { e.record.set('DISTANCE', selectdata.DTHORGOS); if (destrecords.getCount() > 0) { var destdata = destrecords.getAt(0).data; e.record.set('DISTANCEDEST', parseFloat(selectdata.DTHORGOS) + parseFloat(destdata.DTHORGOS)); } } } } else { e.record.set('DISTANCE', 0); e.record.set('FRDISTANCE', 0); e.record.set('LOCATIONID', ''); } } }, addDetail: function () { //var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo); var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许添加运踪!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } var newSerialno = this.DsGetNewNo(this.storeBodyListdetail); this.serialNo = newSerialno; var BSNO = record.data.BSNO; var selections = this.gridListCtn.getSelectionModel().getSelection(); var CNTRNO = ''; if (selections.length == 0) { } else { var record = selections[0]; CNTRNO = record.data.CNTRNO; } var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d'); var record = Ext.create('MsOpRailwayTracking', { TK_ID: NewGuid(), BSNO: '*', SORTNO: newSerialno, TRAINNO: '', CNTRNO: CNTRNO, SEALNO: '', ACTIVITY: '', EFCNTR: '', TRACKDATE: mydatestr, LOCATION: '', LOCATIONID: '', DISTANCE: 0, REMARK: '' }); this.storeBodyListdetail.add(record); var n = this.storeBodyListdetail.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 }); }, DsGetNewNo: function (store) { var result = store.getCount(); if (result == 0) { return 1; } // var record = store.getAt(result - 1).data.CTNCODE; result = result + 1; return result; }, onPostDetailClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许保存!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } var BSNO = record.data.BSNO; var bodyDrChFeeDatas = []; var i; for (i = 0; i < this.storeBodyListdetail.getCount(); i += 1) { var memberyf = this.storeBodyListdetail.getAt(i); bodyDrChFeeDatas.push(memberyf); }; var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas); _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpRailway/SaveTrackingDetail', scope: this, params: { bsno: BSNO, body: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < this.storeBodyListdetail.getCount(); i += 1) { var member = this.storeBodyListdetail.getAt(i); member.set("BSNO", BSNO); member.commit(); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save deleteDetail: function () { var selections = this.gridList.getSelectionModel().getSelection(); var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } //this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo); var selectedRecords = this.gridListdetail.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台 { this.storeBodyListdetail.remove(selectedRecords[i]); } else { Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpRailway/DeleteTrackingDetail', params: { body: Ext.JSON.encode(rec.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeBodyListdetail.remove(rec); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, scope: this }); //end Ext.Ajax.request } }, this); } //this.storeBodyList.remove(selectedRecords[i]); } }, onAddCtnClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许添加箱号!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } var CTNALL = record.data.CTNALL; var newSerialno = this.DsGetNewNo(this.storeBodyCtnList); this.serialNo = newSerialno; var record = Ext.create('MsOpSeaeDetail', { CTN_ID: NewGuid(), BSNO: '*', CTNCODE: newSerialno, CTNALL: CTNALL, CTNNUM: 1, CNTRNO: '', SEALNO: '', PKGS: 0, KINDPKGS: '', KGS: 0, TAREWEIGHT: 0, CBM: 0, REMARK: '' }); this.storeBodyCtnList.add(record); var n = this.storeBodyCtnList.getCount(); this.gridListCtnCellEditing.startEditByPosition({ row: n - 1, column: 3 }); }, deleteCtn: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } //this.serialNo = DsGetCurSerialNo(this.storeBodyList, this.serialNo); var selectedRecords = this.gridListCtn.selModel.getSelection(); for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BSNO == "" || rec.data.BSNO == "*")//如果是新增但没有保存的数据,没有必要提交到后台 { this.storeBodyCtnList.remove(selectedRecords[i]); } else { Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpSeae/DeleteDetail', params: { data: Ext.JSON.encode(rec.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeBodyCtnList.remove(rec); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, scope: this }); //end Ext.Ajax.request } }, this); } //this.storeBodyList.remove(selectedRecords[i]); } }, onPostCtnClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); var record = selections[0]; if (record.data.BSSTATUS == 'true') { Ext.Msg.show({ title: '警告', msg: '业务已锁定,不允许保存!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } var BSNO = record.data.BSNO; var bodyDrChFeeDatas = []; var i; for (i = 0; i < this.storeBodyCtnList.getCount(); i += 1) { var memberyf = this.storeBodyCtnList.getAt(i); bodyDrChFeeDatas.push(memberyf); }; var jsonChFeeBody = ConvertRecordsToJsonAll(bodyDrChFeeDatas); _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpRailway/SaveCtnDetail', scope: this, params: { bsno: BSNO, body: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < this.storeBodyCtnList.getCount(); i += 1) { var member = this.storeBodyCtnList.getAt(i); member.set("BSNO", BSNO); member.commit(); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save //#endregion InitGrid: function (grid) { var agirdcolums = grid; this.gridList.reconfigure(this.storeList, agirdcolums); }, onClearSql: function () { var form = this.formSearch.getForm(); form.reset(); }, //onDeleteClick onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: sql }, waitMsg: "正在查询数据...", callback: function (r, options, success) { if (success) { if (r.length == 0) { var sql = " BSNO='11111111' "; this.storeBodyListdetail.load({ params: { condition: sql, isfirst: false} }); this.storeBodyCtnList.load({ params: { condition: sql} }); } } }, scope: this }); }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; //#region formSearch 查询面板 //编号包括(主提单号) var MblNo = form.findField('MblNo').getValue(); sql = sql + getAndConSql(sql, MblNo, "(B.MblNo like '%" + MblNo + "%' or B.TRANSNO like '%" + MblNo + "%' or B.CUSTNO like '%" + MblNo + "%' or B.HBLNO like '%" + MblNo + "%' or B.ORDERNO like '%" + MblNo + "%')"); var CtnNo = form.findField('CtnNo').getValue(); sql = sql + getAndConSql(sql, CtnNo, " EXISTS (SELECT 1 FROM OP_CTN D WHERE D.BSNO=B.BSNO AND D.CntrNo like '%" + CtnNo + "%' )"); //客户名称 var CUSTOMERNAME = form.findField('CUSTOMERNAME').getValue(); sql = sql + getAndConSql(sql, CUSTOMERNAME, "B.CUSTOMERNAME='" + CUSTOMERNAME + "'"); //发车日期 var ETDbgn = form.findField('ETDbgn').getRawValue(); sql = sql + getAndConSql(sql, ETDbgn, "B.BSDATE >='" + ETDbgn + "'"); var ETDend = form.findField('ETDend').getRawValue(); sql = sql + getAndConSql(sql, ETDend, "B.BSDATE <='" + ETDend + "'"); //装货港 var PORTLOAD = form.findField('PLACELOAD').getValue(); sql = sql + getAndConSql(sql, PORTLOAD, "B.PLACELOAD like '%" + PORTLOAD + "%'"); //卸货港 var PORTDISCHARGE = form.findField('DESTINATION').getValue(); sql = sql + getAndConSql(sql, PORTDISCHARGE, "B.DESTINATION like '%" + PORTDISCHARGE + "%'"); //卸货港 var PLACETRANSIT = form.findField('PLACETRANSIT').getValue(); sql = sql + getAndConSql(sql, PLACETRANSIT, "B.PLACETRANSIT like '%" + PLACETRANSIT + "%'"); var TRACKSTATUS = form.findField('TRACKSTATUS').getValue(); // sql = sql + getAndConSql(sql, TRACKSTATUS, "B.OPSTATUS like '%" + TRACKSTATUS + "%'"); if (TRACKSTATUS == '' || TRACKSTATUS == null || TRACKSTATUS == undefined) { } else { if (TRACKSTATUS == "订单未装") { sql = sql + getAndConSql(sql, TRACKSTATUS, " NOT EXISTS (SELECT 1 FROM op_railway_tracking D WHERE D.BSNO=B.BSNO and TRAINNO!='')"); } else if (TRACKSTATUS == "已装未发") { sql = sql + getAndConSql(sql, TRACKSTATUS, " EXISTS (SELECT 1 FROM v_top_track D WHERE D.BSNO=B.BSNO AND (D.ACTIVITY='Purchase-In' " + " or D.ACTIVITY='Truck-In' or D.ACTIVITY='Truck-Out/Loaded' or D.ACTIVITY='Customs Declaration' or D.ACTIVITY='Customs Release' ))"); } else if (TRACKSTATUS == "已发出在途") { sql = sql + getAndConSql(sql, TRACKSTATUS, " EXISTS (SELECT 1 FROM v_top_track D WHERE D.BSNO=B.BSNO AND (D.ACTIVITY='Departure' " + " or D.ACTIVITY='On-Board' or D.ACTIVITY='Update' or D.ACTIVITY='Arrival' or D.ACTIVITY='Exchange Railcar' ))"); } else if (TRACKSTATUS == "所有未交付") { sql = sql + getAndConSql(sql, TRACKSTATUS, " NOT EXISTS (SELECT 1 FROM op_railway_tracking D WHERE D.BSNO=B.BSNO AND D.ACTIVITY='Delivery' )"); } else if (TRACKSTATUS == "已交付") { sql = sql + getAndConSql(sql, TRACKSTATUS, " EXISTS (SELECT 1 FROM op_railway_tracking D WHERE D.BSNO=B.BSNO AND D.ACTIVITY='Delivery' )"); } } // this.StoreSTATUS.add({ "STATUS": "订单未装", "STATUSID": "1" }); // this.StoreSTATUS.add({ "STATUS": "已装未发", "STATUSID": "2" }); // this.StoreSTATUS.add({ "STATUS": "已发出在途", "STATUSID": "3" }); // this.StoreSTATUS.add({ "STATUS": "所有未交付", "STATUSID": "4" }); // this.StoreSTATUS.add({ "STATUS": "已交付", "STATUSID": "5" }); //#endregion formSearch return sql; }, Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var bsno = '11111'; var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length != 0) { var record = selections[0]; bsno = record.data.BSNO; } var sql = this.getCondition(); var sortstr = 'BSDATE,MBLNO '; if (this.sortfield != '' && this.sortdire != '') { sortstr = this.sortfield + ' ' + this.sortdire; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsOpRailway/GetDataListStr', scope: this, params: { condition: sql, sort: sortstr }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MSOPRAILWAYTRACKLIST'; var sql1 = returnstr; var sql2 = "select * from op_railway where BSNO='" + bsno + "'"; var sql3 = "select * from op_ctn where BSNO='" + bsno + "'"; var sql4 = "select * from op_railway_tracking where BSNO='" + bsno + "' order by SORTNO desc"; var sql5 = "SELECT TK_ID,BSNO,SORTNO,TRAINNO,FRTRAINNO,INPUTBY,INPUTDATE,TRACKDATE,CNTRNO,SEALNO,EFCNTR,ACTIVITY,LOCATION,LOCATIONID,DISTANCE,[REMARK] from (" + "SELECT TK_ID,BSNO,SORTNO,TRAINNO,FRTRAINNO,INPUTBY,INPUTDATE,TRACKDATE,CNTRNO,SEALNO,EFCNTR,ACTIVITY,LOCATION,LOCATIONID,DISTANCE,[REMARK]" + ",row_number() over (partition by CNTRNO order by SORTNO desc) as rowno from op_railway_tracking where BSNO='" + bsno + "'" + ") x where x.rowno=1 "; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, PrintSelect: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var selectedRecords = []; var storeadd = null; selectedRecords = this.gridList.getSelectionModel().getSelection(); if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要打印的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var sortstr = 'BSDATE,CUSTNO'; var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('BSNO') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var bsno = '11111'; var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length != 0) { var record = selections[0]; bsno = record.data.BSNO; } var printType = 'MSOPRAILWAYTRACKLISTSELECT'; var sql1 = "select * from op_railway WHERE BSNO IN (" + feeGidSql + ") order by " + sortstr; var sql2 = "select * from op_railway where BSNO='" + bsno + "'"; var sql3 = "select * from op_ctn where BSNO='" + bsno + "'"; var sql4 = "select * from op_railway_tracking where BSNO='" + bsno + "' order by SORTNO desc"; var sql5 = "SELECT TK_ID,BSNO,SORTNO,TRAINNO,FRTRAINNO,INPUTBY,INPUTDATE,TRACKDATE,CNTRNO,SEALNO,EFCNTR,ACTIVITY,LOCATION,LOCATIONID,DISTANCE,[REMARK] from (" + "SELECT TK_ID,BSNO,SORTNO,TRAINNO,FRTRAINNO,INPUTBY,INPUTDATE,TRACKDATE,CNTRNO,SEALNO,EFCNTR,ACTIVITY,LOCATION,LOCATIONID,DISTANCE,[REMARK]" + ",row_number() over (partition by CNTRNO order by SORTNO desc) as rowno from op_railway_tracking where BSNO='" + bsno + "'" + ") x where x.rowno=1 "; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } });