MPPProductPlanning.find - improved performance
This commit is contained in:
parent
6af3e09c77
commit
4513b48f50
|
@ -15,10 +15,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.model.MOrgInfo;
|
import org.compiere.model.MOrgInfo;
|
||||||
import org.compiere.model.MResource;
|
import org.compiere.model.MResource;
|
||||||
|
@ -31,6 +29,8 @@ import org.compiere.util.DB;
|
||||||
*
|
*
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MPProductPlannning.java,v 1.4 2004/05/13 06:05:22 vpj-cd Exp $
|
* @version $Id: MPProductPlannning.java,v 1.4 2004/05/13 06:05:22 vpj-cd Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, www.arhipac.ro
|
||||||
*/
|
*/
|
||||||
public class MPPProductPlanning extends X_PP_Product_Planning
|
public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
{
|
{
|
||||||
|
@ -131,73 +131,14 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
||||||
**/
|
**/
|
||||||
public static MPPProductPlanning find(Properties ctx ,int AD_Client_ID, int AD_Org_ID ,int M_Warehouse_ID, int S_Resource_ID, int M_Product_ID, String trxName)
|
public static MPPProductPlanning find(Properties ctx ,int AD_Client_ID, int AD_Org_ID ,int M_Warehouse_ID, int S_Resource_ID, int M_Product_ID, String trxName)
|
||||||
{
|
{
|
||||||
MPPProductPlanning pp = null;
|
final String whereClause = "AD_Client_ID=? AND M_Product_ID=?"
|
||||||
PreparedStatement pstmt = null;
|
+ " AND (AD_Org_ID IN (0,?) OR AD_Org_ID IS NULL)"
|
||||||
try
|
+ " AND (M_Warehouse_ID IN (0,?) OR M_Warehouse_ID IS NULL)"
|
||||||
{
|
+ " AND (S_Resource_ID IN (0,?) OR S_Resource_ID IS NULL)";
|
||||||
// Find specific data planning
|
return new Query(ctx, Table_Name, whereClause, trxName)
|
||||||
String sql = "SELECT * FROM PP_Product_Planning pp WHERE pp.AD_Client_ID = ? AND pp.AD_Org_ID = ? AND pp.M_Warehouse_ID=? AND pp.S_Resource_ID = ? AND pp.M_Product_ID = ? ";
|
.setParameters(new Object[]{AD_Client_ID, M_Product_ID, AD_Org_ID, M_Warehouse_ID, S_Resource_ID})
|
||||||
|
.setOrderBy("AD_Org_ID DESC NULLS LAST, M_Warehouse_ID DESC NULLS LAST, S_Resource_ID DESC NULLS LAST")
|
||||||
pstmt = DB.prepareStatement(sql ,trxName);
|
.first();
|
||||||
pstmt.setInt(1, AD_Client_ID);
|
|
||||||
pstmt.setInt(2, AD_Org_ID);
|
|
||||||
pstmt.setInt(3, M_Warehouse_ID);
|
|
||||||
pstmt.setInt(4, S_Resource_ID);
|
|
||||||
pstmt.setInt(5, M_Product_ID);
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
return new MPPProductPlanning(ctx, rs, trxName);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
|
|
||||||
// Find general data planning Org = * , Wharehouse = *
|
|
||||||
sql = "SELECT * FROM PP_Product_Planning pp WHERE pp.AD_Client_ID = ? AND (pp.AD_Org_ID = 0 OR AD_Org_ID IS NULL) AND (pp.M_Warehouse_ID = 0 OR pp.M_Warehouse_ID IS NULL) AND pp.S_Resource_ID = ? AND pp.M_Product_ID = ? ";
|
|
||||||
pstmt = DB.prepareStatement(sql ,trxName);
|
|
||||||
pstmt.setInt(1, AD_Client_ID);
|
|
||||||
pstmt.setInt(2, S_Resource_ID);
|
|
||||||
pstmt.setInt(3, M_Product_ID);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
return new MPPProductPlanning(ctx, rs, trxName);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
|
|
||||||
// Find general data planning Org = * , Wharehouse = * , Resource = *
|
|
||||||
sql = "SELECT * FROM PP_Product_Planning pp WHERE pp.AD_Client_ID = ? AND (pp.AD_Org_ID = 0 OR AD_Org_ID IS NULL) AND (pp.M_Warehouse_ID = 0 OR pp.M_Warehouse_ID IS NULL) AND (pp.S_Resource_ID =0 OR pp.S_Resource_ID IS NULL ) AND pp.M_Product_ID = ? ";
|
|
||||||
pstmt = DB.prepareStatement(sql ,trxName);
|
|
||||||
pstmt.setInt(1, AD_Client_ID);
|
|
||||||
pstmt.setInt(2, M_Product_ID);
|
|
||||||
rs = pstmt.executeQuery();
|
|
||||||
while (rs.next())
|
|
||||||
{
|
|
||||||
return new MPPProductPlanning(ctx, rs, trxName);
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE,"getProductPlanning", e);
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (pstmt != null)
|
|
||||||
pstmt.close();
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
pstmt = null;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue