" + "insert into zx_tendaysreport t\n" + " (REPORTID,PLACEPOINTID,USEDAY,GATHERTYPE,REALMONEY,BANCIMONEY,FINANCEMONEY,uploadflag,docno,STATUS)\n" + "selec_foreach u">
赞
踩
insert的foreach
@DslDataSource(MASTER) @Insert("<script>" + "insert into zx_tendaysreport t\n" + " (REPORTID,PLACEPOINTID,USEDAY,GATHERTYPE,REALMONEY,BANCIMONEY,FINANCEMONEY,uploadflag,docno,STATUS)\n" + "select zx_tendaysreport_seq.nextval REPORTID,a.* from (\n" + " <foreach collection=\"inReportMapList\" item=\"item\" index=\"index\" separator=\"union all\">\n" + "(select " + "#{item.placepointid} PLACEPOINTID," + "to_date(#{item.useday},'yyyy-MM-dd') USEDAY," + " #{item.gathertype} GATHERTYPE," + "'0' REALMONEY," + "'0' BANCIMONEY," + "#{item.financemoney} FINANCEMONEY," + "'N' uploadflag," + "#{item.docno} docno," + "'1' STATUS\n" + "from dual)\n" + " </foreach>"+ ") a\n" + "</script>") public int insTenDaysReport(@Param("inReportMapList")List<ReportItem> inReportMapList);
update的foreach
@DslDataSource(MASTER)
@Update("<script>" +
"<foreach collection='upReportMapList' item='item' index='index' open='begin' close=';end;' separator=';'>\n" +
"update zx_tendaysreport set financemoney = #{item.financemoney} where placepointid = #{item.placepointid} and gathertype = #{item.gathertype} and useday = to_date(#{item.useday},'yyyy-MM-dd')" +
"</foreach>" +
"</script>")
public int upTenDaysReport(@Param("upReportMapList")List<ReportItem> upReportMapList);
分批调用mybatis的接口方法
int inPointDataLimit = 50;//每一批的数量 List<ReportItem> inNewList = new ArrayList<ReportItem>(); for (int i = 0; i < inReportMapList.size(); i++) { //分批次处理 inNewList.add(inReportMapList.get(i)); if(inPointDataLimit == inNewList.size() || i == inReportMapList.size() - 1){ tenDaysToHubMapper.insTenDaysReport(inNewList); inNewList.clear(); } } int upPointDataLimit = 50;//每一批的数量 List<ReportItem> upNewList = new ArrayList<ReportItem>(); for (int i = 0; i < upReportMapList.size(); i++) { //分批次处理 upNewList.add(upReportMapList.get(i)); if(upPointDataLimit == upNewList.size() || i == upReportMapList.size() - 1){ tenDaysToHubMapper.upTenDaysReport(upNewList); upNewList.clear(); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。