libero: minor improvements:

* fix identation
* use getSQLValue*Ex instead of getSQLValue - better exception handling
* refactor debugging messages
This commit is contained in:
teo_sarca 2008-12-08 16:17:37 +00:00
parent 34f8c8ba7c
commit e0558c54a6
4 changed files with 54 additions and 46 deletions

View File

@ -180,7 +180,9 @@ public class MPPMRP extends X_PP_MRP
if(MDocType.DOCSUBTYPESO_StandardOrder.equals(DocSubTypeSO) || !o.isSOTrx())
{
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress) || o.getDocStatus().equals(MOrder.DOCSTATUS_Completed)) || !o.isSOTrx())
if((o.getDocStatus().equals(MOrder.DOCSTATUS_InProgress)
|| o.getDocStatus().equals(MOrder.DOCSTATUS_Completed))
|| !o.isSOTrx())
{
for(MOrderLine line : o.getLines())
{
@ -580,7 +582,7 @@ public class MPPMRP extends X_PP_MRP
{
final String sql = "SELECT SUM(bomQtyOnHand (M_Product_ID,?,0)) AS OnHand FROM M_Product"
+" WHERE AD_Client_ID=? AND M_Product_ID=?";
BigDecimal QtyOnHand = DB.getSQLValueBD(trxName, sql, new Object[]{M_Warehouse_ID,Env.getAD_Client_ID(ctx),M_Product_ID});
BigDecimal QtyOnHand = DB.getSQLValueBDEx(trxName, sql, new Object[]{M_Warehouse_ID,Env.getAD_Client_ID(ctx),M_Product_ID});
if (QtyOnHand == null)
QtyOnHand = Env.ZERO;
return QtyOnHand;
@ -599,7 +601,7 @@ public class MPPMRP extends X_PP_MRP
{
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP=? AND DocStatus IN ('IN','CO')");
sql.append(" AND OrderType IN ('SOO','MOP','DOO') AND AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{MPPMRP.TYPEMRP_Demand,Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
BigDecimal qty = DB.getSQLValueBDEx(trxName, sql.toString(), new Object[]{MPPMRP.TYPEMRP_Demand,Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
// SQL may return no rows or null
if (qty == null)
return Env.ZERO;
@ -633,7 +635,7 @@ public class MPPMRP extends X_PP_MRP
{
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP='S' AND DocStatus IN ('IN','CO')");
sql.append(" AND OrderType IN ('POO','MOP','DOO') AND AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
BigDecimal qty = DB.getSQLValueBDEx(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
// SQL may return no rows or null
if (qty == null)
return Env.ZERO;
@ -667,7 +669,7 @@ public class MPPMRP extends X_PP_MRP
//
final String sql = "SELECT MAX("+MProduct.COLUMNNAME_LowLevel+") FROM M_Product"
+" WHERE AD_Client_ID=? AND "+MProduct.COLUMNNAME_LowLevel+" IS NOT NULL";
int LowLevel = DB.getSQLValue(trxName, sql, AD_Client_ID);
int LowLevel = DB.getSQLValueEx(trxName, sql, AD_Client_ID);
return LowLevel + 1;
}

View File

@ -176,13 +176,14 @@ public class MPPProductPlanning extends X_PP_Product_Planning
if (!CLogMgt.isLevelInfo())
return;
log.info("------------ Planning Data --------------");
log.info(" Create Plan: " + isCreatePlan());
log.info(" Resource: " + getS_Resource_ID());
log.info(" M_Product_ID: " + getM_Product_ID());
log.info(" BOM: " + getPP_Product_BOM_ID());
log.info(" Network Distribution: " + getDD_NetworkDistribution_ID());
log.info(" Workflow: " + getAD_Workflow_ID());
log.info(" Network Distribution: " + getDD_NetworkDistribution_ID());
log.info("Delivery Time Promised: " + getDeliveryTime_Promised());
log.info(" TransfertTime: " + getTransfertTime ());
log.info(" Create Plan: " + isCreatePlan());
log.info(" Max Order: " + getOrder_Max());
log.info(" Min Order: " + getOrder_Min());
log.info(" Pack Order: " + getOrder_Pack());
@ -191,7 +192,6 @@ public class MPPProductPlanning extends X_PP_Product_Planning
log.info(" Order Policy: " + getOrder_Policy());
log.info(" Warehouse: " + getM_Warehouse_ID());
log.info(" Planner: " + getPlanner_ID());
log.info(" PP_Product_BOM_ID: " + getPP_Product_BOM_ID());
}
} // Product Data Planning

View File

@ -583,7 +583,7 @@ public class MRP extends SvrProcess
AD_Client_ID, AD_Org_ID,
m_product_planning.getM_Warehouse_ID()
};
QtyScheduledReceipts = DB.getSQLValueBD(null, "SELECT COALESCE(SUM(Qty),0) FROM PP_MRP WHERE "+whereClause, params);
QtyScheduledReceipts = DB.getSQLValueBDEx(null, "SELECT COALESCE(SUM(Qty),0) FROM PP_MRP WHERE "+whereClause, params);
DB.executeUpdateEx("UPDATE PP_MRP SET IsAvailable = 'N' WHERE "+whereClause, params, get_TrxName());
log.info("QtyScheduledReceipts :" + QtyScheduledReceipts);
@ -615,10 +615,11 @@ public class MRP extends SvrProcess
QtyNetReqs = ((QtyScheduledReceipts).add(QtyProjectOnHand)).subtract(QtyGrossReqs);
log.info(" Planning Data :" + product.getName() + " Create Plan:" + m_product_planning.isCreatePlan() + " OrderPlan:" + QtyPlanned);
m_product_planning.dump();
log.info(" Product:" + product.getName());
log.info(" Demand Date Start Schedule:" + DemandDateStartSchedule);
log.info(" Delivery Time Promised:" + m_product_planning.getDeliveryTime_Promised());
log.info(" DatePromisedFrom:" + DatePromisedFrom + " DatePromisedTo:" + DatePromisedTo);
log.info(" Qty Planned:" + QtyPlanned);
log.info(" Qty Scheduled Receipts:" + QtyScheduledReceipts);
log.info(" QtyProjectOnHand:" + QtyProjectOnHand);
log.info(" QtyGrossReqs:" + QtyGrossReqs);
@ -697,6 +698,10 @@ public class MRP extends SvrProcess
{
createPPOrder(AD_Org_ID,PP_MPR_ID, product, DemandDateStartSchedule);
}
else
{
// TODO: throw error ?
}
} // end for oqf
}
else
@ -971,13 +976,14 @@ public class MRP extends SvrProcess
Integer order_id = dd_order_id_cache.get(key.toString());
if ( order_id == null)
{
order_id = DB.getSQLValue(get_TrxName(), "SELECT DD_Order_ID FROM DD_Order WHERE AD_Org_ID=? AND M_Warehouse_ID=? AND M_Shipper_ID = ? AND C_BPartner_ID=? AND DatePromised=? AND DocStatus=?",
String sql = "SELECT DD_Order_ID FROM DD_Order WHERE AD_Org_ID=? AND M_Warehouse_ID=? AND M_Shipper_ID = ? AND C_BPartner_ID=? AND DatePromised=? AND DocStatus=?";
order_id = DB.getSQLValueEx(get_TrxName(), sql,
new Object[]{ AD_Org_ID,
M_Warehouse_ID,
M_Shipper_ID,
C_BPartner_ID,
DatePromised,
"DR"});
MDDOrder.DOCSTATUS_Drafted });
if(order_id > 0)
dd_order_id_cache.put(key,order_id);
}