From 41accaed7b2260f9033701f048b5b65b01a6369d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 21 十一月 2023 15:42:19 +0800 Subject: [PATCH] 2023-11-21 --- src/utils/utils-datamanage.js | 103 +++++++++++++++++++++++++++++---------------------- 1 files changed, 59 insertions(+), 44 deletions(-) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index 0d4babb..a06bc3f 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -11,7 +11,6 @@ * @param {Number} pageIndex 椤电爜 * @param {Number} pageSize 姣忛〉鏁伴噺 * @param {String} BID 涓婄骇ID - * @return {Object} param */ static getQueryDataParams (setting, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, id, year) { let param = null @@ -54,36 +53,31 @@ if (setting.interType === 'inner') { param.func = setting.innerFunc + + if (setting.recordUser === 'true') { + param.username = sessionStorage.getItem('User_Name') || '' + param.fullname = sessionStorage.getItem('Full_Name') || '' + } } else { - if (window.GLOB.mkHS) { - if (setting.sysInterface === 'true' && window.GLOB.cloudServiceApi) { - param.rduri = window.GLOB.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' - } else if (setting.sysInterface !== 'true') { - param.rduri = setting.interface + if (setting.sysInterface === 'true') { + if (window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi + } + } else if (setting.sysInterface === 'external') { + if (window.GLOB.systemType === 'production') { + param.$token = setting.exProInterface || '' + } else { + param.$token = setting.exInterface || '' } } else { - if (setting.sysInterface === 'true') { - if (window.GLOB.mainSystemApi) { - param.rduri = window.GLOB.mainSystemApi - } - } else if (setting.sysInterface === 'external') { - if (window.GLOB.systemType === 'production') { - param.$token = setting.exProInterface || '' - } else { - param.$token = setting.exInterface || '' - } + if (window.GLOB.systemType === 'production' && setting.proInterface) { + param.rduri = setting.proInterface } else { - if (window.GLOB.systemType === 'production' && setting.proInterface) { - param.rduri = setting.proInterface - } else { - param.rduri = setting.interface - } - let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') - if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { - param.$login = true - } + param.rduri = setting.interface + } + let host = window.GLOB.baseurl.replace(/http(s):\/\//, '') + if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) { + param.$login = true } } @@ -210,15 +204,28 @@ } else { DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}` } + } else if (setting.$top) { + if (orderBy) { + LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} order by ${orderBy} ` + } else { + LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} ` + } } else if (orderBy) { - LText = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows ` + LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} order by ${orderBy} ` } else { LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} ` } } if (_customScript) { - if (LText) { + if (DateCount) { + DateCount = `${DateCount} + ${_tailScript} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' + ` + } else if (LText) { LText = `${LText} ${_tailScript} aaa: @@ -233,6 +240,17 @@ insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' ` } + } else if (_tailScript && DateCount) { + LText = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) + Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' + ${LText} + ` + DateCount = `${DateCount} + ${_tailScript} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' + ` } else if (_tailScript) { LText = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' @@ -253,6 +271,7 @@ if (window.GLOB.debugger === true) { _customScript && console.info(`${setting.$name ? `/*${setting.$name} 鑷畾涔夎剼鏈�*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) LText && console.info(`${setting.$name ? `/*${setting.$name} 鏁版嵁婧�*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) + DateCount && console.info(`${setting.$name ? `/*${setting.$name} 鎬绘暟鏌ヨ*/\n` : ''}` + DateCount.replace(/\n\s{8}/ig, '\n')) } if (setting.$name) { @@ -286,10 +305,8 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // special HS鑷畾涔夊嚱鏁版煡璇� - if (setting.tableName === 's_custom_script' && window.GLOB.cloudServiceApi) { - param.rduri = window.GLOB.cloudServiceApi - param.userid = sessionStorage.getItem('CloudUserID') || '' - param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' + if (setting.tableName === 's_custom_script' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi } } @@ -441,21 +458,20 @@ _customScript = _customScript.replace(item.reg, item.value) }) - // _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') - // _customScript = _customScript.replace(/@select\$|\$select@/ig, '') - // _dataresource = _dataresource.replace(/\$sum@/ig, '/*') - // _dataresource = _dataresource.replace(/@sum\$/ig, '*/') - // _customScript = _customScript.replace(/\$sum@/ig, '/*') - // _customScript = _customScript.replace(/@sum\$/ig, '*/') - let _search = '' if (setting.queryType !== 'statistics' && _dataresource) { _search = Utils.joinMainSearchkey(searchlist) _search = _search ? 'where ' + _search : '' } - if (setting.order && _dataresource) { - _dataresource = `select top 1000 ${setting.arr_field} from (select ${setting.arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows ` + if (setting.$top) { + if (setting.order && _dataresource) { + _dataresource = `select top 1 ${setting.arr_field} from ${_dataresource} ${_search} order by ${setting.order} ` + } else if (_dataresource) { + _dataresource = `select top 1 ${setting.arr_field} from ${_dataresource} ${_search} ` + } + } else if (setting.order && _dataresource) { + _dataresource = `select top 1000 ${setting.arr_field} from ${_dataresource} ${_search} order by ${setting.order} ` } else if (_dataresource) { _dataresource = `select top 1000 ${setting.arr_field} from ${_dataresource} ${_search} ` } @@ -490,8 +506,7 @@ primaryKey: setting.primaryKey || '', foreign_key: '', sql: _dataresource, - script: _customScript, - // transaction: setting.transaction === 'true' + script: _customScript } } -- Gitblit v1.8.0