IDEMPIERE-308 Performance: Replace with StringBuilder / Thanks to Richard Morales and David Peñuela

This commit is contained in:
Carlos Ruiz 2012-09-25 12:54:09 -05:00
parent f41c5cf94b
commit bda4e5736d
7 changed files with 155 additions and 126 deletions

View File

@ -112,7 +112,8 @@ public class CopyOrder extends SvrProcess
//
// Env.setSOTrx(getCtx(), newOrder.isSOTrx());
// return "@C_Order_ID@ " + newOrder.getDocumentNo();
return dt.getName() + ": " + newOrder.getDocumentNo();
StringBuilder msgreturn = new StringBuilder(dt.getName()).append(": ").append(newOrder.getDocumentNo());
return msgreturn.toString();
} // doIt
} // CopyOrder

View File

@ -88,8 +88,8 @@ public class CopyRole extends SvrProcess
String table = tables[i];
String keycolumn = keycolumns[i];
String sql = "DELETE FROM " + table + " WHERE AD_Role_ID = " + m_AD_Role_ID_To;
int no = DB.executeUpdateEx(sql, get_TrxName());
StringBuilder sql = new StringBuilder("DELETE FROM ").append(table).append(" WHERE AD_Role_ID = ").append(m_AD_Role_ID_To);
int no = DB.executeUpdateEx(sql.toString(), get_TrxName());
addLog(action++, null, BigDecimal.valueOf(no), "Old records deleted from " + table );
final boolean column_IsReadWrite =
@ -97,29 +97,29 @@ public class CopyRole extends SvrProcess
&& !table.equals(I_AD_Role_Included.Table_Name);
final boolean column_SeqNo = table.equals(I_AD_Role_Included.Table_Name);
sql = "INSERT INTO " + table
+ " (AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, "
+ "AD_Role_ID, " + keycolumn +", isActive";
sql = new StringBuilder("INSERT INTO ").append(table)
.append(" (AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, ")
.append( "AD_Role_ID, ").append(keycolumn).append(", isActive");
if (column_SeqNo)
sql += ", SeqNo ";
sql.append(", SeqNo ");
if (column_IsReadWrite)
sql += ", isReadWrite) ";
sql.append(", isReadWrite) ");
else
sql += ") ";
sql += "SELECT " + m_AD_Client_ID
+ ", "+ m_AD_Org_ID
+ ", getdate(), "+ Env.getAD_User_ID(Env.getCtx())
+ ", getdate(), "+ Env.getAD_User_ID(Env.getCtx())
+ ", " + m_AD_Role_ID_To
+ ", " + keycolumn
+ ", IsActive ";
sql.append(") ");
sql.append("SELECT ").append(m_AD_Client_ID)
.append(", ").append(m_AD_Org_ID)
.append(", getdate(), ").append(Env.getAD_User_ID(Env.getCtx()))
.append(", getdate(), ").append(Env.getAD_User_ID(Env.getCtx()))
.append(", ").append(m_AD_Role_ID_To)
.append(", ").append(keycolumn)
.append(", IsActive ");
if (column_SeqNo)
sql += ", SeqNo ";
sql.append(", SeqNo ");
if (column_IsReadWrite)
sql += ", isReadWrite ";
sql += "FROM " + table + " WHERE AD_Role_ID = " + m_AD_Role_ID_From;
sql.append(", isReadWrite ");
sql.append("FROM ").append(table).append(" WHERE AD_Role_ID = ").append(m_AD_Role_ID_From);
no = DB.executeUpdateEx (sql, get_TrxName());
no = DB.executeUpdateEx (sql.toString(), get_TrxName());
addLog(action++, null, new BigDecimal(no), "New records inserted into " + table );
}

View File

@ -151,11 +151,13 @@ public class DistributionCreate extends SvrProcess
// Update Qty
if (m_singleOrder != null)
{
m_singleOrder.setDescription("# " + counter + " - " + m_totalQty);
StringBuilder msg = new StringBuilder("# ").append(counter).append(" - ").append(m_totalQty);
m_singleOrder.setDescription(msg.toString());
m_singleOrder.saveEx();
}
return "@Created@ #" + counter + " - @Qty@=" + m_totalQty;
StringBuilder msgreturn = new StringBuilder("@Created@ #").append(counter).append(" - @Qty@=").append(m_totalQty);
return msgreturn.toString();
} // doIt
/**

View File

@ -320,10 +320,12 @@ public class DistributionRun extends SvrProcess
for (int j = 0; j < m_runLines.length; j++)
{
MDistributionRunLine runLine = m_runLines[j];
if (runLine.isActualMinGtTotal())
throw new Exception ("Line " + runLine.getLine()
+ " Sum of Min Qty=" + runLine.getActualMin()
+ " is greater than Total Qty=" + runLine.getTotalQty());
if (runLine.isActualMinGtTotal()){
StringBuilder msg = new StringBuilder("Line ").append(runLine.getLine())
.append(" Sum of Min Qty=").append(runLine.getActualMin())
.append(" is greater than Total Qty=").append(runLine.getTotalQty());
throw new Exception (msg.toString());
}
if (allocationEqTotal && !runLine.isActualAllocationEqTotal())
allocationEqTotal = false;
} // for all run lines
@ -378,8 +380,9 @@ public class DistributionRun extends SvrProcess
}
}
} // for all detail lines
throw new Exception ("Cannot adjust Difference = " + difference
+ " - You need to change Total Qty or Min Qty");
StringBuilder msgexc = new StringBuilder("Cannot adjust Difference = ").append(difference)
.append(" - You need to change Total Qty or Min Qty");
throw new Exception (msgexc.toString());
}
else // Distibute
{
@ -394,9 +397,11 @@ public class DistributionRun extends SvrProcess
ratioTotal = ratioTotal.add(detail.getRatio());
}
}
if (ratioTotal.compareTo(Env.ZERO) == 0)
throw new Exception ("Cannot distribute Difference = " + difference
+ " - You need to change Total Qty or Min Qty");
if (ratioTotal.compareTo(Env.ZERO) == 0){
StringBuilder msgexc = new StringBuilder("Cannot distribute Difference = ").append(difference)
.append(" - You need to change Total Qty or Min Qty");
throw new Exception (msgexc.toString());
}
// Distribute
for (int i = 0; i < m_details.length; i++)
{
@ -542,8 +547,8 @@ public class DistributionRun extends SvrProcess
product = MProduct.get (getCtx(), detail.getM_Product_ID());
if (p_IsTest)
{
addLog(0,null, detail.getActualAllocation(),
bp.getName() + " - " + product.getName());
StringBuilder msglog = new StringBuilder(bp.getName()).append(" - ").append(product.getName());
addLog(0,null, detail.getActualAllocation(), msglog.toString());
continue;
}
@ -566,8 +571,8 @@ public class DistributionRun extends SvrProcess
log.log(Level.SEVERE, "OrderLine not saved");
return false;
}
addLog(0,null, detail.getActualAllocation(), order.getDocumentNo()
+ ": " + bp.getName() + " - " + product.getName());
StringBuilder msglog = new StringBuilder(order.getDocumentNo()).append(": ").append(bp.getName()).append(" - ").append(product.getName());
addLog(0,null, detail.getActualAllocation(), msglog.toString());
}
// finish order
order = null;
@ -584,40 +589,40 @@ public class DistributionRun extends SvrProcess
private int insertDetailsDistributionDemand()
{
// Handle NULL
String sql = "UPDATE M_DistributionRunLine SET MinQty = 0 WHERE MinQty IS NULL";
int no = DB.executeUpdate(sql, get_TrxName());
StringBuilder sql = new StringBuilder("UPDATE M_DistributionRunLine SET MinQty = 0 WHERE MinQty IS NULL");
int no = DB.executeUpdate(sql.toString(), get_TrxName());
sql = "UPDATE M_DistributionListLine SET MinQty = 0 WHERE MinQty IS NULL";
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE M_DistributionListLine SET MinQty = 0 WHERE MinQty IS NULL");
no = DB.executeUpdate(sql.toString(), get_TrxName());
// Delete Old
sql = "DELETE FROM T_DistributionRunDetail WHERE M_DistributionRun_ID="
+ p_M_DistributionRun_ID;
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("DELETE FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=")
.append(p_M_DistributionRun_ID);
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("insertDetails - deleted #" + no);
// Insert New
sql = "INSERT INTO T_DistributionRunDetail "
+ "(M_DistributionRun_ID, M_DistributionRunLine_ID, M_DistributionList_ID, M_DistributionListLine_ID,"
+ "AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,"
+ "C_BPartner_ID, C_BPartner_Location_ID, M_Product_ID,"
+ "Ratio, MinQty, Qty) "
+"SELECT MAX(rl.M_DistributionRun_ID), MAX(rl.M_DistributionRunLine_ID),MAX(ll.M_DistributionList_ID), MAX(ll.M_DistributionListLine_ID), "
+"MAX(rl.AD_Client_ID),MAX(rl.AD_Org_ID), MAX(rl.IsActive), MAX(rl.Created),MAX(rl.CreatedBy), MAX(rl.Updated),MAX(rl.UpdatedBy), "
+"MAX(ll.C_BPartner_ID), MAX(ll.C_BPartner_Location_ID), MAX(rl.M_Product_ID),"
sql = new StringBuilder("INSERT INTO T_DistributionRunDetail ")
.append("(M_DistributionRun_ID, M_DistributionRunLine_ID, M_DistributionList_ID, M_DistributionListLine_ID,")
.append("AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
.append("C_BPartner_ID, C_BPartner_Location_ID, M_Product_ID,")
.append("Ratio, MinQty, Qty) " )
.append("SELECT MAX(rl.M_DistributionRun_ID), MAX(rl.M_DistributionRunLine_ID),MAX(ll.M_DistributionList_ID), MAX(ll.M_DistributionListLine_ID), ")
.append("MAX(rl.AD_Client_ID),MAX(rl.AD_Org_ID), MAX(rl.IsActive), MAX(rl.Created),MAX(rl.CreatedBy), MAX(rl.Updated),MAX(rl.UpdatedBy), ")
.append("MAX(ll.C_BPartner_ID), MAX(ll.C_BPartner_Location_ID), MAX(rl.M_Product_ID),")
// Ration for this process is equal QtyToDeliver
+"COALESCE (SUM(ol.QtyOrdered-ol.QtyDelivered-TargetQty), 0) , "
.append("COALESCE (SUM(ol.QtyOrdered-ol.QtyDelivered-TargetQty), 0) , ")
// Min Qty for this process is equal to TargetQty
+" 0 , 0 FROM M_DistributionRunLine rl "
+"INNER JOIN M_DistributionList l ON (rl.M_DistributionList_ID=l.M_DistributionList_ID) "
+"INNER JOIN M_DistributionListLine ll ON (rl.M_DistributionList_ID=ll.M_DistributionList_ID) "
+"INNER JOIN DD_Order o ON (o.C_BPartner_ID=ll.C_BPartner_ID AND o.DocStatus IN ('DR','IN')) "
+"INNER JOIN DD_OrderLine ol ON (ol.DD_Order_ID=o.DD_Order_ID AND ol.M_Product_ID=rl.M_Product_ID) "
+"INNER JOIN M_Locator loc ON (loc.M_Locator_ID=ol.M_Locator_ID AND loc.M_Warehouse_ID="+p_M_Warehouse_ID+") "
+"WHERE rl.M_DistributionRun_ID="+p_M_DistributionRun_ID+" AND rl.IsActive='Y' AND ll.IsActive='Y' AND ol.DatePromised <= "+DB.TO_DATE(p_DatePromised)
+" GROUP BY o.M_Shipper_ID , ll.C_BPartner_ID, ol.M_Product_ID";
.append(" 0 , 0 FROM M_DistributionRunLine rl ")
.append("INNER JOIN M_DistributionList l ON (rl.M_DistributionList_ID=l.M_DistributionList_ID) ")
.append("INNER JOIN M_DistributionListLine ll ON (rl.M_DistributionList_ID=ll.M_DistributionList_ID) ")
.append("INNER JOIN DD_Order o ON (o.C_BPartner_ID=ll.C_BPartner_ID AND o.DocStatus IN ('DR','IN')) ")
.append("INNER JOIN DD_OrderLine ol ON (ol.DD_Order_ID=o.DD_Order_ID AND ol.M_Product_ID=rl.M_Product_ID) ")
.append("INNER JOIN M_Locator loc ON (loc.M_Locator_ID=ol.M_Locator_ID AND loc.M_Warehouse_ID=").append(p_M_Warehouse_ID).append(") ")
.append("WHERE rl.M_DistributionRun_ID=").append(p_M_DistributionRun_ID).append(" AND rl.IsActive='Y' AND ll.IsActive='Y' AND ol.DatePromised <= ").append(DB.TO_DATE(p_DatePromised))
.append(" GROUP BY o.M_Shipper_ID , ll.C_BPartner_ID, ol.M_Product_ID");
//+ " BETWEEN "+ DB.TO_DATE(p_DatePromised) +" AND "+ DB.TO_DATE(p_DatePromised_To)
no = DB.executeUpdate(sql, get_TrxName());
no = DB.executeUpdate(sql.toString(), get_TrxName());
List<MDistributionRunDetail> records = new Query(getCtx(),
MDistributionRunDetail.Table_Name,
@ -647,16 +652,20 @@ public class DistributionRun extends SvrProcess
private BigDecimal getQtyDemand(int M_Product_ID)
{
StringBuffer sql = new StringBuffer("SELECT SUM (QtyOrdered-QtyDelivered-TargetQty) FROM DD_OrderLine ol INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) ");
//sql.append(" WHERE o.DocStatus IN ('DR','IN') AND ol.DatePromised BETWEEN ? AND ? AND l.M_Warehouse_ID=? AND ol.M_Product_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID");
sql.append(" WHERE o.DocStatus IN ('DR','IN') AND ol.DatePromised <= ? AND l.M_Warehouse_ID=? AND ol.M_Product_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID");
String sql = "SELECT SUM (QtyOrdered-QtyDelivered-TargetQty) " +
"FROM DD_OrderLine ol " +
"INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) " +
"INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) " +
" WHERE o.DocStatus IN ('DR','IN') " +
"AND ol.DatePromised <= ? " +
"AND l.M_Warehouse_ID=? " +
"AND ol.M_Product_ID=? " +
"GROUP BY M_Product_ID, l.M_Warehouse_ID";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
pstmt = DB.prepareStatement (sql, get_TrxName());
pstmt.setTimestamp(1, p_DatePromised);
//pstmt.setTimestamp(2, p_DatePromised_To);
pstmt.setInt(2, p_M_Warehouse_ID);
@ -692,37 +701,37 @@ public class DistributionRun extends SvrProcess
private int insertDetailsDistribution()
{
// Handle NULL
String sql = "UPDATE M_DistributionRunLine SET MinQty = 0 WHERE MinQty IS NULL";
int no = DB.executeUpdate(sql, get_TrxName());
StringBuilder sql = new StringBuilder("UPDATE M_DistributionRunLine SET MinQty = 0 WHERE MinQty IS NULL");
int no = DB.executeUpdate(sql.toString(), get_TrxName());
sql = "UPDATE M_DistributionListLine SET MinQty = 0 WHERE MinQty IS NULL";
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("UPDATE M_DistributionListLine SET MinQty = 0 WHERE MinQty IS NULL");
no = DB.executeUpdate(sql.toString(), get_TrxName());
// Delete Old
sql = "DELETE FROM T_DistributionRunDetail WHERE M_DistributionRun_ID="
+ p_M_DistributionRun_ID;
no = DB.executeUpdate(sql, get_TrxName());
sql = new StringBuilder("DELETE FROM T_DistributionRunDetail WHERE M_DistributionRun_ID=")
.append(p_M_DistributionRun_ID);
no = DB.executeUpdate(sql.toString(), get_TrxName());
log.fine("insertDetails - deleted #" + no);
// Insert New
sql = "INSERT INTO T_DistributionRunDetail "
+ "(M_DistributionRun_ID, M_DistributionRunLine_ID, M_DistributionList_ID, M_DistributionListLine_ID,"
+ "AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,"
+ "C_BPartner_ID, C_BPartner_Location_ID, M_Product_ID,"
+ "Ratio, MinQty, Qty) "
+"SELECT rl.M_DistributionRun_ID, rl.M_DistributionRunLine_ID,ll.M_DistributionList_ID, ll.M_DistributionListLine_ID, "
+"rl.AD_Client_ID,rl.AD_Org_ID, rl.IsActive, rl.Created,rl.CreatedBy, rl.Updated,rl.UpdatedBy, "
+"ll.C_BPartner_ID, ll.C_BPartner_Location_ID, rl.M_Product_ID, 0 , "
+"ol.TargetQty AS MinQty , 0 FROM M_DistributionRunLine rl "
+"INNER JOIN M_DistributionList l ON (rl.M_DistributionList_ID=l.M_DistributionList_ID) "
+"INNER JOIN M_DistributionListLine ll ON (rl.M_DistributionList_ID=ll.M_DistributionList_ID) "
+"INNER JOIN DD_Order o ON (o.C_BPartner_ID=ll.C_BPartner_ID) "
+"INNER JOIN DD_OrderLine ol ON (ol.DD_Order_ID=o.DD_Order_ID AND ol.M_Product_ID=rl.M_Product_ID) AND ol.DatePromised"
sql = new StringBuilder("INSERT INTO T_DistributionRunDetail ")
.append("(M_DistributionRun_ID, M_DistributionRunLine_ID, M_DistributionList_ID, M_DistributionListLine_ID,")
.append("AD_Client_ID,AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy,")
.append("C_BPartner_ID, C_BPartner_Location_ID, M_Product_ID,")
.append("Ratio, MinQty, Qty) ")
.append("SELECT rl.M_DistributionRun_ID, rl.M_DistributionRunLine_ID,ll.M_DistributionList_ID, ll.M_DistributionListLine_ID, ")
.append("rl.AD_Client_ID,rl.AD_Org_ID, rl.IsActive, rl.Created,rl.CreatedBy, rl.Updated,rl.UpdatedBy, ")
.append("ll.C_BPartner_ID, ll.C_BPartner_Location_ID, rl.M_Product_ID, 0 , ")
.append("ol.TargetQty AS MinQty , 0 FROM M_DistributionRunLine rl ")
.append("INNER JOIN M_DistributionList l ON (rl.M_DistributionList_ID=l.M_DistributionList_ID) ")
.append("INNER JOIN M_DistributionListLine ll ON (rl.M_DistributionList_ID=ll.M_DistributionList_ID) ")
.append("INNER JOIN DD_Order o ON (o.C_BPartner_ID=ll.C_BPartner_ID) ")
.append("INNER JOIN DD_OrderLine ol ON (ol.DD_Order_ID=o.DD_Order_ID AND ol.M_Product_ID=rl.M_Product_ID) AND ol.DatePromised")
//+ " BETWEEN " + DB.TO_DATE(p_DatePromised) +" AND "+ DB.TO_DATE(p_DatePromised_To)
+ "<="+DB.TO_DATE(p_DatePromised)
+" INNER JOIN M_Locator loc ON (loc.M_Locator_ID=ol.M_Locator_ID AND loc.M_Warehouse_ID="+p_M_Warehouse_ID+") "
+" WHERE rl.M_DistributionRun_ID="+p_M_DistributionRun_ID+" AND l.RatioTotal<>0 AND rl.IsActive='Y' AND ll.IsActive='Y'";
no = DB.executeUpdate(sql, get_TrxName());
.append( "<=").append(DB.TO_DATE(p_DatePromised))
.append(" INNER JOIN M_Locator loc ON (loc.M_Locator_ID=ol.M_Locator_ID AND loc.M_Warehouse_ID=").append(p_M_Warehouse_ID).append(") ")
.append(" WHERE rl.M_DistributionRun_ID=").append(p_M_DistributionRun_ID).append(" AND l.RatioTotal<>0 AND rl.IsActive='Y' AND ll.IsActive='Y'");
no = DB.executeUpdate(sql.toString(), get_TrxName());
Query query = MTable.get(getCtx(), I_T_DistributionRunDetail.Table_ID).
createQuery(MDistributionRunDetail.COLUMNNAME_M_DistributionRun_ID + "=?", get_TrxName());
@ -772,9 +781,9 @@ public class DistributionRun extends SvrProcess
{
MDistributionRunDetail detail = m_details[i];
StringBuffer sql = new StringBuffer("SELECT * FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) ");
String sql = "SELECT * FROM DD_OrderLine ol INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) ";
//sql.append(" WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised BETWEEN ? AND ? ");
sql.append(" WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised <=?");
sql = sql + " WHERE o.DocStatus IN ('DR','IN') AND o.C_BPartner_ID = ? AND M_Product_ID=? AND l.M_Warehouse_ID=? AND ol.DatePromised <=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -930,12 +939,12 @@ public class DistributionRun extends SvrProcess
if(p_ConsolidateDocument)
{
String whereClause = "DocStatus IN ('DR','IN') AND AD_Org_ID=" + bp.getAD_OrgBP_ID_Int() + " AND " +
MDDOrder.COLUMNNAME_C_BPartner_ID +"=? AND " +
MDDOrder.COLUMNNAME_M_Warehouse_ID +"=? AND " +
MDDOrder.COLUMNNAME_DatePromised +"<=? ";
StringBuilder whereClause = new StringBuilder("DocStatus IN ('DR','IN') AND AD_Org_ID=").append(bp.getAD_OrgBP_ID_Int()).append(" AND ")
.append(MDDOrder.COLUMNNAME_C_BPartner_ID).append("=? AND ")
.append(MDDOrder.COLUMNNAME_M_Warehouse_ID).append("=? AND ")
.append(MDDOrder.COLUMNNAME_DatePromised).append("<=? ");
order = new Query(getCtx(), MDDOrder.Table_Name, whereClause, get_TrxName())
order = new Query(getCtx(), MDDOrder.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(new Object[]{lastC_BPartner_ID, ws[0].getM_Warehouse_ID(), p_DatePromised})
.setOrderBy(MDDOrder.COLUMNNAME_DatePromised +" DESC")
.first();
@ -988,8 +997,8 @@ public class DistributionRun extends SvrProcess
product = MProduct.get (getCtx(), detail.getM_Product_ID());
if (p_IsTest)
{
addLog(0,null, detail.getActualAllocation(),
bp.getName() + " - " + product.getName());
StringBuilder msglog = new StringBuilder(bp.getName()).append(" - ").append(product.getName());
addLog(0,null, detail.getActualAllocation(), msglog.toString());
continue;
}
@ -1017,7 +1026,9 @@ public class DistributionRun extends SvrProcess
String Description ="";
if (m_run.getName() != null)
Description =Description.concat(m_run.getName());
line.setDescription(Description + " " +Msg.translate(getCtx(), "Qty")+ " = " +QtyAllocation+" ");
StringBuilder msgline = new StringBuilder(Description).append(" ").append(Msg.translate(getCtx(), "Qty"))
.append(" = ").append(QtyAllocation).append(" ");
line.setDescription(msgline.toString());
//line.setConfirmedQty(QtyAllocation);
line.saveEx();
}
@ -1032,7 +1043,8 @@ public class DistributionRun extends SvrProcess
Description ="";
if (m_run.getName() != null)
Description =Description.concat(m_run.getName());
line.setDescription(Description + " " +Msg.translate(getCtx(), "Qty")+ " = " +QtyAllocation+" ");
StringBuilder msgline = new StringBuilder(Description).append(" ").append(Msg.translate(getCtx(), "Qty")).append(" = ").append(QtyAllocation).append(" ");
line.setDescription(msgline.toString());
line.setQty(line.getQtyEntered().add(QtyAllocation));
//line.setConfirmedQty(line.getConfirmedQty().add( QtyAllocation));
line.saveEx();
@ -1064,12 +1076,15 @@ public class DistributionRun extends SvrProcess
String Description ="";
if (m_run.getName() != null)
Description =Description.concat(m_run.getName());
line.setDescription(Description + " " +Msg.translate(getCtx(), "Qty")+ " = " +detail.getActualAllocation()+" ");
StringBuilder msgline = new StringBuilder(Description).append(" ").append(Msg.translate(getCtx(), "Qty")).append(" = ")
.append(detail.getActualAllocation()).append(" ");
line.setDescription(msgline.toString());
line.saveEx();
}
addLog(0,null, detail.getActualAllocation(), order.getDocumentNo()
+ ": " + bp.getName() + " - " + product.getName());
StringBuilder msglog = new StringBuilder(order.getDocumentNo())
.append(": ").append(bp.getName()).append(" - ").append(product.getName());
addLog(0,null, detail.getActualAllocation(), msglog.toString());
}
// finish order
order = null;

View File

@ -132,7 +132,8 @@ public class DunningPrint extends SvrProcess
MBPartner bp = new MBPartner (getCtx(), entry.getC_BPartner_ID(), get_TrxName());
if (bp.get_ID() == 0)
{
addLog (entry.get_ID(), null, null, "@NotFound@: @C_BPartner_ID@ " + entry.getC_BPartner_ID());
StringBuilder msglog = new StringBuilder("@NotFound@: @C_BPartner_ID@ ").append(entry.getC_BPartner_ID());
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
continue;
}
@ -142,13 +143,15 @@ public class DunningPrint extends SvrProcess
{
if (to.get_ID() == 0)
{
addLog (entry.get_ID(), null, null, "@NotFound@: @AD_User_ID@ - " + bp.getName());
StringBuilder msglog = new StringBuilder("@NotFound@: @AD_User_ID@ - ").append(bp.getName());
addLog (entry.get_ID(), null, null,msglog.toString());
errors++;
continue;
}
else if (to.getEMail() == null || to.getEMail().length() == 0)
{
addLog (entry.get_ID(), null, null, "@NotFound@: @EMail@ - " + to.getName());
StringBuilder msglog = new StringBuilder("@NotFound@: @EMail@ - ").append(to.getName());
addLog (entry.get_ID(), null, null, msglog.toString());
errors++;
continue;
}
@ -164,7 +167,8 @@ public class DunningPrint extends SvrProcess
MDunningRunEntry.Table_ID,
entry.getC_DunningRunEntry_ID(),
entry.getC_BPartner_ID());
info.setDescription(bp.getName() + ", Amt=" + entry.getAmt());
StringBuilder msginfo = new StringBuilder(bp.getName()).append(", Amt=").append(entry.getAmt());
info.setDescription(msginfo.toString());
ReportEngine re = null;
if (format != null)
re = new ReportEngine(getCtx(), format, query, info);
@ -174,8 +178,9 @@ public class DunningPrint extends SvrProcess
EMail email = client.createEMail(to.getEMail(), null, null);
if (!email.isValid())
{
addLog (entry.get_ID(), null, null,
"@RequestActionEMailError@ Invalid EMail: " + to);
StringBuilder msglog = new StringBuilder(
"@RequestActionEMailError@ Invalid EMail: ").append(to);
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
continue;
}
@ -193,7 +198,8 @@ public class DunningPrint extends SvrProcess
//
if (re != null) {
File attachment = re.getPDF(File.createTempFile("Dunning", ".pdf"));
log.fine(to + " - " + attachment);
StringBuilder msglog = new StringBuilder(to.toString()).append(" - ").append(attachment);
log.fine(msglog.toString());
email.addAttachment(attachment);
}
//
@ -202,15 +208,16 @@ public class DunningPrint extends SvrProcess
um.saveEx();
if (msg.equals(EMail.SENT_OK))
{
addLog (entry.get_ID(), null, null,
bp.getName() + " @RequestActionEMailOK@");
StringBuilder msglog = new StringBuilder(
bp.getName()).append(" @RequestActionEMailOK@");
addLog (entry.get_ID(), null, null,msglog.toString());
count++;
printed = true;
}
else
{
addLog (entry.get_ID(), null, null,
bp.getName() + " @RequestActionEMailError@ " + msg);
StringBuilder msglog = new StringBuilder(bp.getName()).append(" @RequestActionEMailError@ ").append(msg);
addLog (entry.get_ID(), null, null,msglog.toString() );
errors++;
}
}
@ -233,8 +240,10 @@ public class DunningPrint extends SvrProcess
run.setProcessed(true);
run.saveEx();
}
if (p_EMailPDF)
return "@Sent@=" + count + " - @Errors@=" + errors;
if (p_EMailPDF){
StringBuilder msgreturn = new StringBuilder("@Sent@=").append(count).append(" - @Errors@=").append(errors);
return msgreturn.toString();
}
return "@Printed@=" + count;
} // doIt

View File

@ -169,7 +169,7 @@ public class DunningRunCreate extends SvrProcess
sql.append(" AND i.AD_Org_ID=").append(p_AD_Org_ID);
// log.info(sql);
StringBuilder sql2= new StringBuilder();
String sql2= "";
// if sequentially we must check for other levels with smaller days for
// which this invoice is not yet included!
@ -190,11 +190,11 @@ public class DunningRunCreate extends SvrProcess
}
}
// ensure that we do only dunn what's not yet dunned, so we lookup the max of last Dunn Date which was processed
sql2.append("SELECT COUNT(*), COALESCE(DAYSBETWEEN(MAX(dr2.DunningDate), MAX(dr.DunningDate)),0)");
sql2.append("FROM C_DunningRun dr2, C_DunningRun dr");
sql2.append(" INNER JOIN C_DunningRunEntry dre ON (dr.C_DunningRun_ID=dre.C_DunningRun_ID)");
sql2.append(" INNER JOIN C_DunningRunLine drl ON (dre.C_DunningRunEntry_ID=drl.C_DunningRunEntry_ID) ");
sql2.append("WHERE dr2.C_DunningRun_ID=? AND drl.C_Invoice_ID=?"); // ##1 ##2
sql2 = "SELECT COUNT(*), COALESCE(DAYSBETWEEN(MAX(dr2.DunningDate), MAX(dr.DunningDate)),0)"
+ "FROM C_DunningRun dr2, C_DunningRun dr"
+ " INNER JOIN C_DunningRunEntry dre ON (dr.C_DunningRun_ID=dre.C_DunningRun_ID)"
+ " INNER JOIN C_DunningRunLine drl ON (dre.C_DunningRunEntry_ID=drl.C_DunningRunEntry_ID) "
+ "WHERE dr2.C_DunningRun_ID=? AND drl.C_Invoice_ID=?"; // ##1 ##2
BigDecimal DaysAfterDue = level.getDaysAfterDue();
int DaysBetweenDunning = level.getDaysBetweenDunning();

View File

@ -55,7 +55,8 @@ public class EMailTest extends SvrProcess
// Test Client Mail
String clientTest = client.testEMail();
addLog(0, null, null, client.getName() + ": " + clientTest);
StringBuilder msglog = new StringBuilder(client.getName()).append(": ").append(clientTest);
addLog(0, null, null, msglog.toString());
// Test Client DocumentDir
if (!Ini.isClient())
@ -75,7 +76,8 @@ public class EMailTest extends SvrProcess
{
MStore store = wstores[i];
String test = store.testEMail();
addLog(0, null, null, store.getName() + ": " + test);
msglog = new StringBuilder(store.getName()).append(": ").append(test);
addLog(0, null, null, msglog.toString());
}
return clientTest;