BOS账表查询,使用多线程,提升报表查询速度
using Kingdee.BOS; using Kingdee.BOS.Log; using Kingdee.BOS.ServiceHelper; using Kingdee.K3.FIN.App.Core; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace HANS.SupplierSupplyRatio { internal class MutiThreadQry { public static void MTQry(Context context) { var strCountSQL = "/*dialect*/ select count(*) from T_SAL_ORDERENTRY"; long defaultValue = 0L; List<SqlParam> listSqlParam = new List<SqlParam>(); var totalRecord = DBServiceHelper.ExecuteScalar<long>(context, strCountSQL, defaultValue, listSqlParam.ToArray()); /*总记录数:totalRecord:333706 *每页最大记录数:pageSize:10000 *totalPage = (totalRecord + pageSize-1) / pageSize; *其中 pageSize-1 就是 totalRecord / pageSize 的最大的余数 */ long pageSize = 10000L; long totalPage = 0L; if (totalRecord > 0L) { //D:\WorkSpace\SZLS\HANS_CLOUD\K3Cloud\BIN\Kingdee.K3.FIN.App.Core.dll string targetTableName = CommonFunction.GetTempTableName(context); DBServiceHelper.Execute(context, string.Format(@"/*dialect*/ create table {0} as select * from T_SAL_ORDERENTRY where 1=2", targetTableName)); List<Task> mTask = new List<Task>(); totalPage = (totalRecord + pageSize - 1L) / pageSize; for (long i = 1L; i <= totalPage; i++) { long startPageIndex = (i - 1L) * pageSize; long endPageIndex = i * pageSize; var task = Task.Factory.StartNew(() => { Write(context, targetTableName, startPageIndex, endPageIndex); }); mTask.Add(task); } try { Task.WaitAll(mTask.ToArray()); } catch (AggregateException ex) { Logger.Error("HANS.SupplierSupplyRatio.MTQry", "多线程运行产生异常!", ex); } CommonFunction.DropTempTable(context, targetTableName, true); } } static void Write(Context context, string targetTableName, long startPageIndex, long endPageIndex) { var strInsertSQL = string.Format(@"/*dialect*/ INSERT /*+ parallel(4) */ INTO {0} ( {3} ) select tmp.* from ( SELECT {3} FROM ( SELECT t.*, ROWNUM AS rowno FROM ( T_SAL_ORDERENTRY ) t WHERE ROWNUM <= {2} ) t2 WHERE t2.rowno > {1} ) tmp ", targetTableName, startPageIndex, endPageIndex, strFields); DBServiceHelper.Execute(context, strInsertSQL); } const string strFields = @"F_HANS_ORDINARYINVOICEQTY ,F_HANS_REMACHINENUMBER ,F_HANS_INVOICEAMOUNTFOR ,F_HANS_OUTSOURCORDERNUM ,F_HANS_OUTSOURCORDERSEQ ,F_HANS_DECLARPRICE ,F_HANS_DECLARAMOUNT ,F_HANS_CUSTOMSTARIFF ,F_HANS_TRANSFERPRICE ,F_HANS_TRANSFERAMOUNT ,F_HANS_TRANSFERTARIFF ,F_HANS_AMOUNT ,F_HANS_INSTOCKID ,F_HANS_FINSTOCKLOC ,F_HANS_SOFTWAREAMOUNT ,F_HANS_SOFTWAREPRICE ,F_HANS_FENTRYID ,F_HANS_CGSLORGID ,F_HANS_PLACE ,F_HANS_FBSDCGGLQTY1 ,F_HANS_DBSQQTY ,F_HANS_GLDBSQQTY ,F_HANS_DZJLR ,F_HANS_LJDBTLSL ,F_HANS_PRICE ,F_HANS_TAXRATE ,F_HANS_RECEIVEDEPTID ,F_HANS_INVOICETYPE ,F_HANS_RZSQTHSL ,F_HANS_RZZLTH ,F_HANS_SYFBSDRQTY ,F_HANS_SYFBSDCQTY ,F_HANS_APPLICANTID ,F_HANS_NOTAXAMOUNTFOR ,F_HANS_TAXAMOUNTFOR ,F_HANS_ALLAMOUNTFOR ,F_HANS_DECIMAL ,F_HANS_CUSPO ,F_HANS_PRDLINEDATE ,FALLAMOUNTEXCEPTDISCOUNT ,F_UN_JOINPREPICKBASEQTY ,FENTRYID ,FID ,FSEQ ,FMAPNAME ,FMATERIALID ,FAUXPROPID ,FBOMID ,FUNITID ,FQTY ,FBASEUNITID ,FBASEUNITQTY ,FNOTE ,FMRPFREEZESTATUS ,FFREEZEDATE ,FFREEZERID ,FMRPTERMINATESTATUS ,FTERMINATERID ,FTERMINATESTATUS ,FTERMINATEDATE ,FMRPCLOSESTATUS ,FLOT ,FCHANGEFLAG ,FSTOCKORGID ,FSTOCKID ,FLOCKQTY ,FLOCKFLAG ,FOWNERTYPEID ,FOWNERID ,FLOT_TEXT ,FPRODUCEDATE ,FEXPIRYDATE ,FEXPUNIT ,FEXPPERIOD ,FMAPID ,FRETURNTYPE ,FBFLOWID ,FPRIORITY ,FRESERVETYPE ,FMTONO ,FPLANDELIVERYDATE ,FDELIVERYSTATUS ,FOLDQTY ,FPROMOTIONMATCHTYPE ,FSUPPLYORGID ,FNETORDERENTRYID ,FSTOCKUNITID ,FSTOCKQTY ,FSTOCKBASEQTY ,FLEFTQTY ,FINSTOCKPRICE ,FSOSTOCKID ,FSOSTOCKLOCALID ,F_HANS_SRCROW ,F_HANS_SRCQTY ,F_HANS_CONFIG ,F_HANS_CONFIG_TAG ,F_HANS_EXPWHOLE ,F_HANS_EXPCORE ,F_HANS_EXPOTHER ,F_HANS_VOUCHAMT ,F_HANS_ORDERAMT ,F_HANS_DELIVDATE ,F_HANS_REFSALENO ,F_HANS_REFPRODSN ,F_HANS_SIZE ,F_HANS_PIECES ,F_HANS_NONSTAND ,F_HANS_ASPAYED ,F_HANS_OLDREJECT ,F_HANS_EXPWHOLE2 ,F_HANS_EXPCORE2 ,F_HANS_EXPOTHER2 ,F_HANS_VOUCHAMT2 ,F_HANS_ORDERAMT2 ,F_HANS_NONSTAND2 ,F_HANS_ASPAYED2 ,F_HANS_NOTEQTY1 ,F_HANS_OUTQTY1 ,F_HANS_TEXT ,F_HANS_HSAMT ,F_HANS_HSPICE ,F_HANS_SRCMTRL ,F_HANS_SRCQTY2 ,F_HANS_EXPCALC ,F_HANS_SRCMEMO ,F_HANS_SRCMEMO_TAG ,F_HANS_TRANSQTY ,F_HANS_QTY1 ,F_HANS_TSTARTDATE ,F_HANS_TENDDATE ,F_HANS_PRODENME ,F_HANS_PRODMODEL ,FBARCODE ,FBRANCHID ,FRETAILSALEPROM ,F_HANS_CONTRACTID ,F_HANS_SOFTWARE ,F_HANS_TYPE ,F_HANS_SETAMOUNT ,F_HANS_FBQTY ,F_HANS_SPECIALINVOICEQTY"; } }
BOS账表查询,使用多线程,提升报表查询速度
using Kingdee.BOS;using Kingdee.BOS.Log;using Kingdee.BOS.ServiceHelper;using Kingdee.K3.FIN.App.Core;using System;using System.Co...
点击下载文档
本文2024-09-16 18:39:05发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-23515.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章