AX2009 批处理作业中使用多线程---顶级采摘
顶级采摘
是前两种模式的一种混合,使用使用实体表存储单任务模式那样的每个工单,任务每次都取顶行做操作。单任务数不想单任务模式,一个工单一个任务。而是类似批量捆绑那样设置任务数。
表:demoTopPickProcessTrackTable
字段 | 类型 | |
SalesId | String | SalesId |
processedStatus | Enum | NoYes |
Class:
/*
顶级采摘
*/
class DemoBatchTopPicking extends RunBaseBatch
{
str 20 fromSalesOrder, toSalesOrder;
#define.CurrentVersion(1)
#localmacro.CurrentList
fromSalesOrder, toSalesOrder
#endmacro
} public void new()
{
super();
} void run()
{
SalesTable salesTable;
SalesFormLetter formletter;
DemoTopPickProcessTrackTable demoTopPickProcessTrackTable;
Map SalesMap;
; DemoTopPickProcessTrackTable.readPast(true); do
{
ttsBegin;
// when it finds no more work item to process do-while loop will exit select pessimisticlock firstOnly * from demoTopPickProcessTrackTable
where demoTopPickProcessTrackTable.ProcessedStatus == NoYes::No; select * from salesTable
where salesTable.salesId == demoTopPickProcessTrackTable.SalesID &&
salesTable.documentStatus == DocumentStatus::none; if (salesTable)
{
formletter = SalesFormLetter::construct(DocumentStatus::Invoice);
formletter.getLast();
formletter.resetParmListCommonCS();
formletter.allowEmptyTable(formletter.initAllowEmptyTable(true));
SalesMap = new Map(Types::Int64,Types::Record);
SalesMap.insert(salesTable.recid,salesTable);
// formletter.parmDataSourceRecordsPacked(SalesMap.pack());
// formletter.createParmUpdateFromParmUpdateRecord(SalesFormletterParmData::initSalesParmUpdateFormletter(DocumentStatus::Invoice, FormLetter.pack()));
formletter.showQueryForm(false);
formletter.initLinesQuery();
formletter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, false, false);
} if(demoTopPickProcessTrackTable)
{
demoTopPickProcessTrackTable.ProcessedStatus = NoYes::Yes;
demoTopPickProcessTrackTable.update();
}
ttsCommit;
} while ( demoTopPickProcessTrackTable);
} public static DemoBatchTopPicking construct()
{
DemoBatchTopPicking c;
;
c = new DemoBatchTopPicking();
return c;
} public container pack()
{
return [#CurrentVersion, #CurrentList]; } public boolean unpack(container packedClass)
{
Version version = RunBase::getVersion(packedClass);
switch(version)
{
case #CurrentVersion:
[version,#CurrentList] = packedClass;
break;
default:
return false;
}
return true;
}
Job Test
static void scheduleDemoBatchTopPickingJob(Args _args)
{
BatchHeader batchHeader;
DemoBatchTopPicking demoBatchTopPicking;
DemoTopPickProcessTrackTable demoTopPickProcessTrackTable;
SalesTable salesTable; int totalNumberOfTasksNeeded = 10; int counter;
SalesId _SalesIdFrom,_SalesIdTo;
BatchInfo batchInfo;
; _SalesIdFrom = "SSO000001";
_SalesIdTo = "SSO001000"; ttsBegin;
select count(RecId) from salesTable
where salesTable.salesId >= _SalesIdFrom &&
salesTable.salesId <= _SalesIdTo
&& salesTable.documentStatus == DocumentStatus::none; info(Strfmt("%1",salesTable.recid));
delete_from demoTopPickProcessTrackTable; if (salesTable.recid > 0)
{
//Populating the staging table with the work items insert_recordset demoTopPickProcessTrackTable (SalesId)
select SalesId from salesTable
where salesTable.SalesId >= _SalesIdFrom &&
salesTable.SalesId <= _SalesIdTo &&
salesTable.DocumentStatus == DocumentStatus::None; update_recordSet demoTopPickProcessTrackTable
setting processedStatus = NoYes::No; batchHeader = BatchHeader::construct();
batchHeader.parmCaption(strFmt('Batch job for demoBatchTopPicking')); //Creating predefined number of tasks
for(counter = 1; counter <= totalNumberOfTasksNeeded; counter++)
{
info(strfmt("-->%1",counter)); demoBatchTopPicking = DemoBatchTopPicking::construct(); batchInfo = demoBatchTopPicking.batchInfo();
BatchInfo.parmCaption(strfmt('Invoicing :%1 ',counter));
batchInfo.parmGroupId("COUNTING"); batchHeader.addTask(demoBatchTopPicking);
}
batchHeader.save(); }
ttsCommit;
info('Done');
}
/*
顶级采摘: 假设,我们处理10万条记录 #创建的任务 #批处理线程(在我的测试服务器) #可并行执行的并行任务
10 10 10 批处理整个时段,10个任务同时运行,直到队列中没有更多的项目(暂存表中没有要处理的项目)
*/
AX2009 批处理作业中使用多线程---顶级采摘的更多相关文章
- AX2009 批处理作业中使用多线程---批量捆绑
批量捆绑 由于Ax服务器中批处理线程是可以多个的,而实际批处理作业中线程往往只使用了一个 Class: /* 批量捆绑 */ /*class Code*/ public class DemoBat ...
- AX2009 批处理作业中使用多线程---独立任务模式
每个工单独立一个任务. Class /* 独立任务模式 */ class DemoBatchIndividualTasks extends RunBaseBatch { str 20 SalesOrd ...
- C#中的多线程 - 同步基础 z
原文:http://www.albahari.com/threading/part2.aspx 专题:C#中的多线程 1同步概要Permalink 在第 1 部分:基础知识中,我们描述了如何在线程上启 ...
- 细说.NET 中的多线程 (一 概念)
为什么使用多线程 使用户界面能够随时相应用户输入 当某个应用程序在进行大量运算时候,为了保证应用程序能够随时相应客户的输入,这个时候我们往往需要让大量运算和相应用户输入这两个行为在不同的线程中进行. ...
- 细说.NET中的多线程 (二 线程池)
上一章我们了解到,由于线程的创建,销毁都是需要耗费大量资源和时间的,开发者应该非常节约的使用线程资源.最好的办法是使用线程池,线程池能够避免当前进行中大量的线程导致操作系统不停的进行线程切换,当线程数 ...
- kettle作业中的js如何写日志文件
在kettle作业中JavaScript脚本有时候也扮演非常重要的角色,此时我们希望有一些日志记录.下面是job中JavaScript记录日志的方式. job的js写日志的方法. 得到日志输出实例 o ...
- [转载]ArcGIS Engine 中的多线程使用
ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/ 一直都想写 ...
- python中的多线程【转】
转载自: http://c4fun.cn/blog/2014/05/06/python-threading/ python中关于多线程的操作可以使用thread和threading模块来实现,其中th ...
- 拒绝卡顿——在WPF中使用多线程更新UI
原文:拒绝卡顿--在WPF中使用多线程更新UI 有经验的程序员们都知道:不能在UI线程上进行耗时操作,那样会造成界面卡顿,如下就是一个简单的示例: public partial class MainW ...
随机推荐
- HTTP 请求头中的 Remote_Addr,X-Forwarded-For,X-Real-IP
REMOTE_ADDR 表示发出请求的远程主机的 IP 地址,remote_addr代表客户端的IP,但它的值不是由客户端提供的,而是服务端根据客户端的ip指定的,当你的浏览器访问某个网站时,假设中间 ...
- (python基础 函数)
关键字参数:关键字参数和函数调用关系紧密,函数调用使用关键字参数来确定传入的参数值.使用关键字参数允许函数调用时参数的顺序与声明时不一致,因为 Python 解释器能够用参数名匹配参数值 必需参数:必 ...
- ubuntu远程windows桌面
最近把系统装成了ubuntu,需要远程windows ,就用到了ubuntu的 rdesktop工具 1.先打开终端输入 rdesktop 看系统是否安装了 rdesktop 如果没有安装需要 ...
- ajax的4个字母分别是什么意思
Asynchronous JavaScript and XML 的缩写,异步的JavaScript和XML.在不重新加载整个页面的情况下 ,AJAX 与服务器交换数据并更新部分网页.
- mysql for循环存储过程
DROP PROCEDURE IF EXISTS test_insert; DELIMITER ;; CREATE PROCEDURE test_insert () BEGIN DECLARE i i ...
- Java使用BigDecimal计算保留位数不对问题定位
在项目中使用BigDecimal计算将单位从B换成TB时,算出来的结果总是整数,而没有保留设置的2位小数: 计算代码如下: db.divide(oneTB, ROUND_HALF_UP).setSca ...
- JAVA_maven 配置
前人种树: https://www.cnblogs.com/supiaopiao/p/7276805.html?utm_source=itdadao&utm_medium=referral
- CodeForces - 864C-Bus-(模拟加油站问题)
https://vjudge.net/problem/CodeForces-864C 题意:两地之间有个加油站,往返走k个单程,最少加油多少次. 大佬几十行代码就解决,我却要用一百多行的if语句模拟解 ...
- [ts] Property 'aaa' does not exist on type 'Window' 解决办法
第一种: (window as any).aaa 第二种: declare global { interface Window { aaa: any; } } window.aaa = window. ...
- react 环境安装
React 使用了ES6标准的JSX(script标签type为text/babel),但目前很多浏览器只支持ES5,所以我们就需要将JSX转成普通JS.在生产环节中,通常直接将JSX编译为JS,但简 ...