大型Excel文件未在服务器上上传

时间:2019-06-03 09:14:22

标签: mysql node.js

我们在后端使用NODEJS作为API中间件和MySQL服务器。在前端,我们使用Angular及其基于Linux OS的系统。 我们编写了一个代码,将excel文件从本地计算机上传到MySQL数据库。会经历5万行的文件大小,但是当我们加载25万行的文件时,它会继续运行并触发NPM的API服务。 可能是什么原因?

我们的逻辑是将excel文件从本地计算机移动到服务器。然后将excel上载到Temp表中。在临时表中,我们应用验证和转换,然后将其插入到主表中。 大文件陷入无休止的循环,断开NPM服务并停止所有操作。 可能是什么原因?

我们已经使用分块从excel&temp表中获取数据并将其移到主表中,但是对于大文件仍然不起作用。

CREATE DEFINER=`root`@`localhost` PROCEDURE `upload_TansactionTable_procedure`()
BEGIN
DECLARE TransactionCnt INT DEFAULT 0;

        INSERT INTO transaction_table(TransactionDate,SkuID,NodeID,ReciptQty,SalesQty,SalesReturn,ClosingQty,
            InTransit,TradingitemInTransit,WarehouseOpenOrder,QualityUnderHoldQty,BlockedQty,OpenSalesOrder,
            SalesAmount,OpenPO,field2) 
        select tn.TransactionDate,sm.Sku_ID,nm.Node_ID,tn.ReciptQty,tn.SalesQty,tn.SalesReturn,
            tn.ClosingQty,tn.InTransit,tn.TradingitemInTransit,tn.WarehouseOpenOrder,tn.QualityUnderHoldQty,tn.BlockedQty,
            tn.OpenSalesOrder,tn.SalesAmount,tn.OpenPO,tn.field2 from transaction_temp_table tn
            inner join sku_master_table sm on tn.Skucode=sm.Material_Code
            inner join node_master_table nm on tn.Nodecode=nm.NodeCode
           left join transaction_table  TrnTbl on sm.Sku_ID = TrnTbl.SkuID and nm.Node_ID = TrnTbl.NodeID
            where TrnTbl.SkuID is null and TrnTbl.NodeID is null and tn.TransactionDate is not null and tn.Skucode is not null
            and DATE_FORMAT(STR_TO_DATE(tn.TransactionDate, '%Y-%m-%d'), "%d %M %Y")=DATE_FORMAT(CURDATE(), "%d %M %Y");



DELETE FROM transaction_temp_table 
WHERE
    TransactionDate IS NOT NULL
    AND Skucode IS NOT NULL
    AND DATE_FORMAT(STR_TO_DATE(TransactionDate, '%Y-%m-%d'),
        '%d %M %Y') = DATE_FORMAT(CURDATE(), '%d %M %Y');

           INSERT INTO transaction_temp_error_table(TransactionDate,Skucode,Nodecode,ReciptQty,SalesQty,SalesReturn,
ClosingQty,InTransit,TradingitemInTransit,WarehouseOpenOrder,QualityUnderHoldQty,BlockedQty,OpenSalesOrder,SalesAmount,OpenPO,field2,Whenentered)       
        select TransactionDate,Skucode,Nodecode,ReciptQty,SalesQty,SalesReturn,
ClosingQty,InTransit,TradingitemInTransit,WarehouseOpenOrder,QualityUnderHoldQty,BlockedQty,OpenSalesOrder,SalesAmount,OpenPO,field2,Whenentered
 from transaction_temp_table ;# where TransactionDate is null and Skucode is null ;

           #delete from transaction_temp_table where TransactionDate is not null and Skucode is not null ;
           truncate transaction_temp_table;

       set TransactionCnt=(select count(*) from transaction_table where DATE_FORMAT(Whenentered, "%d %M %Y")=DATE_FORMAT(CURDATE(), "%d %M %Y"));

SELECT TransactionCnt AS `TransactionCnt`; 
END

0 个答案:

没有答案