2017-08-01 48 views
2

編輯:我已經編輯了實際的數字,並用pseudoswears替換了它們,因爲我被告知共享性能數據是針對Netsuite的TOS。NetSuite restlet寫入性能差

我正在使用restlets將我們的會計系統與NetSuite集成在一起,總的來說,它的表現非常出色。我從性能的角度認識到nlapiLoadRecord是撒旦自己的孩子,所以我儘可能地避免使用搜索api,現在我的閱讀restlets非常活潑。然而,每當我要求一個restlet寫任何東西,它就像一隻烏龜卡在冷焦油中一樣慢。我通常會在SLOW之間分析nlapiSubmitRecord本身的真實時間,其結果爲秒。這對我來說似乎很瘋狂。沒有人會使用NetSuite,如果表現總是這麼差寫作。我將在下面包含幾個代碼示例。任何關於加速NetSuite restlet寫入性能的提示都將不勝感激。

在這第一個receivedInvoice是傳入的數據,並且findCurrencyCode和findCustomerByCustomerNumber是執行這些事情的功能良好的函數。我只是在幾乎難以置信的時間點鐘,這幾乎令人難以置信聖母徒步旅行時間很短秒用於一個簡單的發票與一個行項目,幾乎所有的時間通過,而我等待nlapiSubmitRecord完成。

var createdInvoice = nlapiCreateRecord('invoice'); 

createdInvoice.setFieldValue('customform', Number(receivedInvoice.transactionType)); 
createdInvoice.setFieldValue('memo', receivedInvoice.message); 
createdInvoice.setFieldValue('duedate', receivedInvoice.dateDue); 

createdInvoice.setFieldValue('currency', findCurrencyCode(receivedInvoice.currencyUnit)); 
createdInvoice.setFieldValue('location', Number(receivedInvoice.location)); 
createdInvoice.setFieldValue('postingperiod', findPostingPeriod(receivedInvoice.datePosted)); 
var customer = findCustomerByCustomerNumber(receivedInvoice.customerNumber); 

createdInvoice.setFieldValue('entity', customer.customerId); 
createdInvoice.setFieldValue('custbody_end_user', customer.customerId); 
createdInvoice.setFieldValue('department', customer.departmentId); 

var itemCount = receivedInvoice.items.length; 
for(var i = 0; i < itemCount; i++) 
{ 
    createdInvoice.selectNewLineItem('item'); 
    createdInvoice.setCurrentLineItemValue('item', 'item',receivedInvoice.items[i].item); 
    createdInvoice.setCurrentLineItemValue('item', 'quantity', receivedInvoice.items[i].quantity); 
    createdInvoice.setCurrentLineItemValue('item', 'rate',receivedInvoice.items[i].price); 
    createdInvoice.setCurrentLineItemValue('item', 'custcol_list_rate',receivedInvoice.items[i].price); 
    createdInvoice.setCurrentLineItemValue('item', 'amount',receivedInvoice.items[i].totalAmount); 
    createdInvoice.setCurrentLineItemValue('item', 'description',receivedInvoice.items[i].description); 
    createdInvoice.commitLineItem('item'); 
} 

var recordNumber = nlapiSubmitRecord(createdInvoice,false,true); 

在這其中我覺得我在動態模式下打開記錄犯了性能異端,但我不知道怎麼回事,得到的可能行項目。只需在動態模式下開啓新紀錄約SLOW秒。再次,提交是大多數時間被吃掉的地方(通常在之間OH親愛的甜心可愛秒),雖然這個人吃了很多時間,因爲我弄亂了訂單項,再次推測可能是因爲我打開了記錄在動態模式下。

var customerPayment = nlapiCreateRecord('customerpayment',{recordmode: 'dynamic'}); 

customerPayment.setFieldValue('customer', parseInt(customerId)); 
customerPayment.setFieldValue('payment', paymentAmount); 
customerPayment.setFieldValue('paymentmethod', paymentMethod); 
customerPayment.setFieldValue('checknum', transactionId); 
customerPayment.setFieldValue('currency', currency); 
customerPayment.setFieldValue('account', account); 

var applyCount = customerPayment.getLineItemCount('apply'); 

if(applyCount>0) 
{ 
    for(var i=1;i<=applyCount;i++) 
    { 
     var thisInvoice = customerPayment.getLineItemValue('apply','refnum',i); 

     if(thisInvoice == invoiceToPay) 
     { 
      customerPayment.selectLineItem('apply', i); 
      customerPayment.setCurrentLineItemValue('apply','apply','T'); 
      customerPayment.setCurrentLineItemValue('apply', 'amount',paymentAmount); 
      customerPayment.commitLineItem('apply'); 
     } 
    } 

} 
nlapiSubmitRecord(customerPayment,false,true); 
+0

謝謝你的pseudoswears - 他們讓我笑。另外:分享表現違反了他們的TOS ...? NetSuite是否默認他們的表現是悲慘的? – Krypton

+0

看來公司不幸的是不幸的是:https://stackoverflow.com/questions/12115397/is-it-against-license-to-publish-oracle-and-sql-server-performance-test – gabrielf

+0

Powercow,你是否曾經能夠解決你的性能問題?你在Netsuite的沙箱或生產環境中執行過測試嗎?生產環境中的性能是否更好? – gabrielf

回答

0

您提交速度慢的原因之一可能是附加到記錄的很多用戶事件腳本。由於它是保存記錄的Restlet,它將觸發用戶事件腳本。

+0

雖然我的發票確實附加了很多用戶事件,但看起來並不像關閉它們可以節省大量提交時間。爲了測試的目的,我將其全部更改爲取消部署,雖然很難確定,但由於即使系統不忙,保存發票的差異範圍也很大,因此並未發現時間差異巨大(提交時間在沙盒系統中一整天保存相同的數據時,變化爲100%)。 – Powercow

1

的一點想法:

  1. (只是把它從我的胸部)與NetSuite的集成財務系統只是聽起來很奇怪。 Netsuite是一個會計系統,通常是使用它的組織的記錄會計系統。如果您沒有使用Netsuite進行會計覈算,您可能需要考慮它對價格有什麼實用性,然後才能實現。
  2. 當我將外部系統與Netsuite集成時,我通常會嘗試將其設置爲異步。我通過將原始信息放入自定義記錄然後啓動預定腳本來處理排隊更新來完成此操作。這讓我的API快速返回。當我處理隊列時,我將錯誤存儲在隊列記錄中,以便如果出現任何問題,我可以修復數據或代碼並重新提交。
  3. 緩慢交易提交的一個顯然主要來源(除了緩慢的UE腳本)是您書籍的狀態。我有一個初創客戶,他的表現非常出色,但他們從未關閉過書籍,他們使用IIRC平均成本計算。每次他們保存了一個帖子交易時,Netsuite正在重新計算整個期間(在一個非常繁忙的站點,事情正在停止的時間大約是兩年)。當他們開始關閉期間時,交易保存時間減少了。當他們轉換爲標準成本計算交易時,保存時間再次下降(我想LIFO會比平均速度更快並且比標準速度慢但是YMMV)

還有關於您的代碼的註釋。

正常的方式創建發票是

nlapiTransformRecord('customer', customer.customerId, 'invoice');nlapiTransformRecord('customer', customer.customerId, 'invoice', {recordmode:'dynamic'});

我從來沒有測試過是否對提交時間,但它可能會幫助,因爲NS將開始從稍微保存的效果更好的地方(抓住吸管,但與NS有時不明顯的變化有速度的好處)

也不知道如何更改動態模式下的自定義形式工作。當你知道了表格,您還可以添加到init默認值:

{recordmode:'dynamic', customform:receivedInvoice.transactionType}

+0

感謝您的想法。通過「與會計系統整合」,我想我有點不清楚 - 我的意思是將它與我​​們的財務團隊用來記錄會計事件的工具整合在一起。 NetSuite是會計記錄系統,但我們有各種會計工具/前端/您提交會計數據的是什麼。我想我應該說'將NetSuite集成到我們的會計生態系統'。感謝您使用轉換創建發票的提示。我會看看這是否會改變性能。 – Powercow

+0

使用轉換確實提高了提交速度,但是創建記錄需要更長時間,因此整體方法執行時間大致相同。 – Powercow