顶级采摘

是前两种模式的一种混合,使用使用实体表存储单任务模式那样的每个工单,任务每次都取顶行做操作。单任务数不想单任务模式,一个工单一个任务。而是类似批量捆绑那样设置任务数。
表: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 批处理作业中使用多线程---顶级采摘的更多相关文章

  1. AX2009 批处理作业中使用多线程---批量捆绑

    批量捆绑   由于Ax服务器中批处理线程是可以多个的,而实际批处理作业中线程往往只使用了一个 Class: /* 批量捆绑 */ /*class Code*/ public class DemoBat ...

  2. AX2009 批处理作业中使用多线程---独立任务模式

    每个工单独立一个任务. Class /* 独立任务模式 */ class DemoBatchIndividualTasks extends RunBaseBatch { str 20 SalesOrd ...

  3. C#中的多线程 - 同步基础 z

    原文:http://www.albahari.com/threading/part2.aspx 专题:C#中的多线程 1同步概要Permalink 在第 1 部分:基础知识中,我们描述了如何在线程上启 ...

  4. 细说.NET 中的多线程 (一 概念)

    为什么使用多线程 使用户界面能够随时相应用户输入 当某个应用程序在进行大量运算时候,为了保证应用程序能够随时相应客户的输入,这个时候我们往往需要让大量运算和相应用户输入这两个行为在不同的线程中进行. ...

  5. 细说.NET中的多线程 (二 线程池)

    上一章我们了解到,由于线程的创建,销毁都是需要耗费大量资源和时间的,开发者应该非常节约的使用线程资源.最好的办法是使用线程池,线程池能够避免当前进行中大量的线程导致操作系统不停的进行线程切换,当线程数 ...

  6. kettle作业中的js如何写日志文件

    在kettle作业中JavaScript脚本有时候也扮演非常重要的角色,此时我们希望有一些日志记录.下面是job中JavaScript记录日志的方式. job的js写日志的方法. 得到日志输出实例 o ...

  7. [转载]ArcGIS Engine 中的多线程使用

    ArcGIS Engine 中的多线程使用 原文链接 http://anshien.blog.163.com/blog/static/169966308201082441114173/   一直都想写 ...

  8. python中的多线程【转】

    转载自: http://c4fun.cn/blog/2014/05/06/python-threading/ python中关于多线程的操作可以使用thread和threading模块来实现,其中th ...

  9. 拒绝卡顿——在WPF中使用多线程更新UI

    原文:拒绝卡顿--在WPF中使用多线程更新UI 有经验的程序员们都知道:不能在UI线程上进行耗时操作,那样会造成界面卡顿,如下就是一个简单的示例: public partial class MainW ...

随机推荐

  1. mybaties插件生成代码

    指定插件运行什么xml,关于如何用idea创建一个maven项目,可以看我以前写的博客 <?xml version="1.0" encoding="UTF-8&qu ...

  2. asp.net 实现后台异步处理的方式

    问题描述: 刚刚开发的一个页面,使用的NET的MVC4.5框架,因为页面数据加载慢需要优化,页面上有8个请求,但是请求并没有什么相互依赖的关系.前端使用ajax异步,但是后台并没有按照异步程序处理.解 ...

  3. Java2E中的路径问题

    本节主要介绍: 1.request.getContextPath()-----项目的发布的根路径 2.request.getRealPath('t')----t目录在当前磁盘中的物理位置,包括盘符,文 ...

  4. LeetCode 92. Reverse Linked List II倒置链表2 C++

    Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Exa ...

  5. 利用pyinstaller生成exe之后,运行不能正常产生结果文件问题记录

    https://segmentfault.com/q/1010000011284617/a-1020000011493026 在此链接已解决问题,现在在这里在详细记录一次 问题描述: 利用pychar ...

  6. 分享自己用的php分页类实例源码

    分享一个我自己用着的php分页类实例源码,供大家参考,具体内容如下: <?php /** file: page.class.php 完美分页类 Page */ class Page { priv ...

  7. [JavaScript,Java,C#,C++,Ruby,Perl,PHP,Python][转]流式接口(Fluent interface)

    原文:https://en.m.wikipedia.org/wiki/Fluent_interface(英文,完整) 转载:https://zh.wikipedia.org/wiki/流式接口(中文, ...

  8. 新装 Win7 系统装完驱动精灵,一打开到检测界面就卡死——原因与解决方案

    1.现象: 重装系统后,鼠标反应慢,且不能上网.因此装了个驱动精灵,准备更新下驱动,但驱动精灵一打开到检测界面就卡死(换驱动人生.鲁大师也一样). 2.原因: Win7 系统 iso 中自带的驱动程序 ...

  9. 知识点---animate()动画滞后执行的解决方案

    jQuery动画: animate 容易出现连续触发.滞后反复执行的现象: 针对 jQuery 中 slideUp.slideDown.animate 等动画运用时出现的滞后反复执行等问题的解决方法有 ...

  10. 导弹拦截问题(DP+贪心)

    1. 拦截导弹(Noip1999) 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度. ...