2

我试图让它尽可能简单。我是春季批次的新手,我有一个小问题,了解如何将弹簧项目联系在一起,特别是在涉及多步骤作业时,但这是我的逻辑而不是代码(简化),我不知道在春季批次中实施它所以我认为这可能是正确的结构

  • reader_money
  • 读者详细信息
  • 小任务
  • 读者利润
  • tasklet_calculation
  • 作家

但是,如果我错了,请纠正我并尽可能提供一些代码。非常感谢您

逻辑:

sql = "select * from MONEY where id= user input"; //the user will input the condition

while (records are available) { 

    int currency= resultset(currency column);
    sql= "select * from DETAILS where D_currency = currency";


    while (records are available) {

        int amount= resultset(amount column);
        string money_flag= resultset(money_type column);
        sql= "select * from PROFIT where Mtypes = money_type";

        while (records are available) {

            int revenue= resultset(revenue);

            if (money_type== 1) {
                int net_profit= revenue * 3.75;
                sql = "update PROFIT set Nprofit = net_profit";
            }

            else (money_type== 2) {
                int net_profit = (revenue - 5 ) * 3.7 ;
                sql = "update PROFIT set Nprofit = net_profit";
            }
        }
    sql="update DETAILS set detail_falg = 001 ";
    }
sql = "update MONEY set currency_flag = 009";

}
4

2 回答 2

1

检查 ItemReaderAdapter 的使用,您可以将所有 SQL 放在某种 DAO 中,该 DAO 可以返回包含计算所需的所有信息的聚合对象列表。

或者

您可以使用 CompositeItemReader 模式。您基本上将多个 ItemReader 定义为一个主 ItemReader。read() 方法将在进入处理器/编写器阶段之前调用所有内部 ItemReader。

我可以给你发一些例子..但我必须离开:-(..

如果您需要一些示例,请发表评论

于 2013-04-24T20:04:38.490 回答
1

要将其放入“常规”弹簧批处理配置中,您需要尽可能将三个循环扁平化为一个。

也许是一个 sql 语句,它会在一个类似于的循环中返回它;

select p.revenue, d.amount from PROFIT p, DETAILS d, MONEY m where p.MTypes = d.money_type and d.D_currency = m.currency and m.id = :?

一旦你“扁平化”了它,你就会陷入更“传统”的块模式的读/处理/写,其中读取器从结果集中检索记录,处理器执行money_type逻辑,然后写入器执行“更新”声明。

于 2013-04-24T19:00:41.113 回答