protected void _saveByPriceInfo(Context ctx, List list, IObjectValue model)
throws BOSException, EASBizException
{
PriceInfo priceInfo = null;
if(list != null && list.size() > 0)
{
TransferOrderBillInfo billInfo = (TransferOrderBillInfo)model;
TransferOrderBillEntryInfo entryInfo = null;
PreparedStatement addStmt = null;
Connection conn = null;
Statement stmt = null;
try
{
conn = EJBFactory.getConnection(ctx);
stmt = conn.createStatement();
stmt.execute("delete from T_IM_MultiSidesTransferPrices where FTransferBillId = '" + billInfo.getId() + "'");
StringBuffer sql = new StringBuffer("insert into T_IM_MultiSidesTransferPrices");
sql.append("(FID,FTransferBillID,FTransferBillEntryID,FSupplyRelationID,FBizRole,FTaxRate");
sql.append(",FDiscountType,FDiscountRate,FPrice,FActualPrcie,FTaxPrice,FActualTaxPrice)");
sql.append("values (?,?,?,?,?,?,?,?,?,?,?,?)");
addStmt = conn.prepareStatement(sql.toString());
int i = 0;
int stmtSize = 0;
for(int size = list.size(); i < size;)
{
priceInfo = (PriceInfo)list.get(i);
if(priceInfo != null)
{
entryInfo = billInfo.getEntry().get(i % billInfo.getEntry().size());
if(!entryInfo.isIsPresent() && entryInfo.getSupplyRelation() != null && priceInfo.getBizRoleType() != null)
{
addStmt.setString(1, BOSUuid.create("31C6DAB6").toString());
addStmt.setString(2, billInfo.getId().toString());
addStmt.setString(3, entryInfo.getId().toString());
addStmt.setString(4, entryInfo.getSupplyRelation().getId().toString());
addStmt.setInt(5, priceInfo.getBizRoleType().getValue());
addStmt.setBigDecimal(6, entryInfo.getTaxRate());
if(priceInfo.getPrice() == null || priceInfo.getPrice().compareTo(zero) <= 0)
{
addStmt.setInt(7, entryInfo.getDiscountType().getValue());
addStmt.setBigDecimal(8, entryInfo.getDiscountRate());
addStmt.setBigDecimal(9, entryInfo.getPrice());
addStmt.setBigDecimal(10, entryInfo.getActualPrice());
addStmt.setBigDecimal(11, entryInfo.getTaxPrice());
addStmt.setBigDecimal(12, entryInfo.getActualTaxPrice());
} else
{
addStmt.setInt(7, priceInfo.getDiscountType().getValue());
addStmt.setBigDecimal(8, priceInfo.getDiscountRate());
addStmt.setBigDecimal(9, priceInfo.getPrice());
addStmt.setBigDecimal(10, priceInfo.getActualPrice());
addStmt.setBigDecimal(11, priceInfo.getTaxPrice());
addStmt.setBigDecimal(12, priceInfo.getActualTaxPrice());
}
addStmt.addBatch();
}
}
if(stmtSize > 500)
{
stmtSize = 0;
addStmt.executeBatch();
addStmt.clearBatch();
}
i++;
stmtSize++;
}
addStmt.executeBatch();
}
catch(SQLException e)
{
e.printStackTrace();
throw new BOSException(e.getCause());
}
finally
{
try
{
SQLUtils.cleanup(stmt);
SQLUtils.cleanup(addStmt);
SQLUtils.cleanup(conn);
}
catch(Exception e)
{
throw new BOSException(e.getCause());
}
}
}
}
批量执行sql语句
最新推荐文章于 2024-07-30 23:01:04 发布