| | |
| | | }) |
| | | } |
| | | |
| | | if (!arr_field) { |
| | | arr_field = '*' |
| | | } |
| | | |
| | | if (setting.interType === 'system' && setting.execute !== 'false') { |
| | | _dataresource = setting.dataresource || '' |
| | | } |
| | |
| | | // error = '系统函数' + _customScript.match(/\$ex@.{1,50}@ex\$/g)[0].replace(/\$ex@|@ex\$/g, '') + '未定义' |
| | | // } |
| | | |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id)@/ig, `'${timestamp}'`) |
| | | _dataresource = _dataresource.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|upid)@/ig, `'${timestamp}'`) |
| | | _customScript = _customScript.replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|upid)@/ig, `'${timestamp}'`) |
| | | |
| | | _dataresource = _dataresource.replace(/@\$|\$@/ig, '') |
| | | _customScript = _customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | |
| | | let _search = defSearch |
| | | |
| | | if (setting.queryType === 'statistics' && _dataresource) { |
| | | if (_dataresource) { |
| | | _regoptions.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, '0') |
| | | }) |
| | |
| | | |
| | | let sumSql = '' |
| | | |
| | | if (arr_field && _dataresource && /\/\*\$sum@/ig.test(_dataresource)) { |
| | | if (_dataresource && /\/\*\$sum@/ig.test(_dataresource)) { |
| | | let _sql = _dataresource.replace(/\/\*\$sum@|@sum\$\*\//ig, '') |
| | | _sql = `${_sql} ${_search}` |
| | | _sql = `/*system_query*/${_sql} ${_search}` |
| | | if (_customScript) { |
| | | sumSql = `/* sql sum验证 */ |
| | | ${_customScript} |
| | | ${_sql} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '${timestamp}',@ErrorCode, @retmsg,'${timestamp}' |
| | | ` |
| | | } else { |
| | | sumSql = `/* sql sum验证 */ |
| | |
| | | } |
| | | |
| | | // 数据源处理, 存在显示列时 |
| | | if (arr_field && _dataresource) { |
| | | if (_dataresource) { |
| | | if (/\s/.test(_dataresource)) { |
| | | _dataresource = '(' + _dataresource + ') tb' |
| | | } |
| | | |
| | | if (setting.order) { |
| | | _dataresource = `select${setting.laypage === 'true' ? ' top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage === 'true' ? 'where rows > 0' : ''} order by tmptable.rows` |
| | | _dataresource = `/*system_query*/select${setting.laypage === 'true' ? ' top 10' : ''} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable ${setting.laypage === 'true' ? 'where rows > 0' : ''} order by tmptable.rows` |
| | | } else { |
| | | _dataresource = `select${setting.laypage === 'true' ? ' top 10' : ''} ${arr_field} from ${_dataresource} ${_search}` |
| | | _dataresource = `/*system_query*/select${setting.laypage === 'true' ? ' top 10' : ''} ${arr_field} from ${_dataresource} ${_search}` |
| | | } |
| | | } |
| | | |
| | |
| | | ${_dataresource} |
| | | aaa: |
| | | if @ErrorCode!='' |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ |
| | | insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '${timestamp}',@ErrorCode, @retmsg,'${timestamp}' |
| | | ` |
| | | } else { |
| | | sql = `/* sql 验证 */ |
| | |
| | | |
| | | console.info(sql) |
| | | |
| | | let errors = [] |
| | | |
| | | if (/@[0-9a-zA-Z_]+@/ig.test(sql)) { |
| | | let arr = sql.match(/@[0-9a-zA-Z_]+@/ig) |
| | | |
| | | arr.forEach(item => { |
| | | let reg = new RegExp(item, 'ig') |
| | | if (reg.test(_dataresource)) { |
| | | errors.push(`数据源中存在未替换值${item}`) |
| | | } |
| | | scripts && scripts.forEach(script => { |
| | | if (reg.test(script.sql)) { |
| | | errors.push(`自定义脚本(${script.$index || ''})存在未替换值${item}`) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (sumSql) { |
| | | sumSql = sumSql.replace(/\n\s{10}/ig, '\n') |
| | | |
| | | console.info(sumSql) |
| | | sumSql = sumSql.replace(/\n/g, ' ') |
| | | } |
| | | |
| | | return { error, sql, sumSql } |
| | | sql = sql.replace(/\n/g, ' ') |
| | | |
| | | return { error, sql, sumSql, errors: errors.join(';') } |
| | | } |
| | | } |