[ 2037983 ] CreateProductPlanning
http://sourceforge.net/tracker/index.php?func=detail&aid=2037983&group_id=176962&atid=879332
This commit is contained in:
parent
0099f9febd
commit
8a84aabf10
|
@ -216,7 +216,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
// find Default BOM in Product Data Planning
|
||||
if (ad_org_id > 0 )
|
||||
{
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(ctx, ad_org_id, product.getM_Product_ID(), trxName);
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(ctx, product.getAD_Client_ID(),ad_org_id, product.getM_Product_ID(), trxName);
|
||||
|
||||
if(pp!= null && pp.getPP_Product_BOM_ID() > 0 )
|
||||
{
|
||||
|
@ -254,7 +254,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
|
|||
// find Default BOM in Product Data Planning
|
||||
if (ad_org_id > 0 )
|
||||
{
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(ctx, ad_org_id, product.getM_Product_ID(), trxName);
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(ctx, product.getAD_Client_ID() ,ad_org_id, product.getM_Product_ID(), trxName);
|
||||
|
||||
if(pp!= null && pp.getPP_Product_BOM_ID() > 0 )
|
||||
{
|
||||
|
|
|
@ -82,23 +82,24 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
|||
* @param trxName Transaction Name
|
||||
* @return MPPProductPlanning
|
||||
*/
|
||||
public static MPPProductPlanning get(Properties ctx, int ad_org_id , int m_product_id, String trxname)
|
||||
public static MPPProductPlanning get(Properties ctx,int ad_client_id, int ad_org_id , int m_product_id, String trxname)
|
||||
{
|
||||
int m_M_Warehouse_ID = MOrgInfo.get(ctx, ad_org_id).getM_Warehouse_ID();
|
||||
if(m_M_Warehouse_ID <= 0)
|
||||
return null;
|
||||
|
||||
int m_S_Resource_ID = DB.getSQLValue(trxname, "SELECT MAX(S_Resource_ID) FROM S_Resource WHERE IsManufacturingResource='Y' AND ManufacturingResourceType ='" + MResource.MANUFACTURINGRESOURCETYPE_Plant +"' AND M_Warehouse_ID= ?", m_M_Warehouse_ID);
|
||||
int m_S_Resource_ID = DB.getSQLValue(trxname, "SELECT MAX(S_Resource_ID) FROM S_Resource WHERE IsManufacturingResource='Y' AND ManufacturingResourceType ='" + MResource.MANUFACTURINGRESOURCETYPE_Plant +"' AND AD_Client_ID=? AND M_Warehouse_ID= ?", ad_client_id, m_M_Warehouse_ID);
|
||||
|
||||
if (m_S_Resource_ID <=0 )
|
||||
return null;
|
||||
|
||||
return get(ctx,ad_org_id, m_M_Warehouse_ID, m_S_Resource_ID, m_product_id, trxname);
|
||||
return get(ctx, ad_client_id,ad_org_id, m_M_Warehouse_ID, m_S_Resource_ID, m_product_id, trxname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Data Product Planning
|
||||
* @param ctx Context
|
||||
* @param AD_Client_ID ID Organization
|
||||
* @param AD_Org_ID ID Organization
|
||||
* @param M_Warehouse_ID Warehouse
|
||||
* @param S_Resource_ID Resource type Plant
|
||||
|
@ -106,20 +107,26 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
|||
* @param trxname Trx Name
|
||||
* @return MPPProductPlanning
|
||||
*/
|
||||
public static MPPProductPlanning get(Properties ctx, int ad_org_id , int m_warehouse_id, int s_resource_id, int m_product_id, String trxname)
|
||||
public static MPPProductPlanning get(Properties ctx,int ad_client_id, int ad_org_id , int m_warehouse_id, int s_resource_id, int m_product_id, String trxname)
|
||||
{
|
||||
|
||||
log.info("Ad_Org_ID" + ad_org_id + "M_Product_ID" + m_product_id + "M_Warehouse_ID" + m_warehouse_id + "S_Resource_ID" + s_resource_id );
|
||||
String sql = "SELECT * FROM PP_Product_Planning pp WHERE pp.AD_Org_ID = ? AND pp.M_Product_ID = ? AND pp.M_Warehouse_ID = ? AND pp.S_Resource_ID = ? ";
|
||||
log.info("AD_Client_ID=" + ad_client_id + " AD_Org_ID=" + ad_org_id + " M_Product_ID=" + m_product_id + " M_Warehouse_ID=" + m_warehouse_id + " S_Resource_ID=" + s_resource_id );
|
||||
String sql_warehouse = "pp.M_Warehouse_ID = ? ";
|
||||
if(m_warehouse_id == 0)
|
||||
sql_warehouse += "OR pp.M_Warehouse_ID IS NULL ";
|
||||
|
||||
|
||||
String sql = "SELECT * FROM PP_Product_Planning pp WHERE pp.AD_Client_ID = ? AND pp.AD_Org_ID = ? AND pp.M_Product_ID = ? AND "+sql_warehouse+" AND pp.S_Resource_ID = ? ";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, trxname);
|
||||
pstmt.setInt(1, ad_org_id);
|
||||
pstmt.setInt(2, m_product_id);
|
||||
pstmt.setInt(3, m_warehouse_id);
|
||||
pstmt.setInt(4, s_resource_id);
|
||||
pstmt.setInt(1, ad_client_id);
|
||||
pstmt.setInt(2, ad_org_id);
|
||||
pstmt.setInt(3, m_product_id);
|
||||
pstmt.setInt(4, m_warehouse_id);
|
||||
pstmt.setInt(5, s_resource_id);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
return new MPPProductPlanning(ctx, rs, trxname);
|
||||
|
@ -155,7 +162,7 @@ public class MPPProductPlanning extends X_PP_Product_Planning
|
|||
* @param trxName Transaction Name
|
||||
* @return MPPProductPlanning Planning Data
|
||||
*/
|
||||
public static MPPProductPlanning getMPPProductPlanning(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 getFisrt(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;
|
||||
PreparedStatement pstmt = null;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package org.eevolution.process;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.logging.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
|
@ -208,11 +209,12 @@ public class CreateProductPlanning extends SvrProcess
|
|||
{
|
||||
|
||||
int M_Product_ID = rs.getInt(1);
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), m_AD_Org_ID , p_M_Warehouse_ID, p_S_Resource_ID,M_Product_ID, get_TrxName());
|
||||
if (pp==null && ( p_S_Resource_ID == 0 || p_M_Warehouse_ID == 0 ))
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(),m_AD_Client_ID , m_AD_Org_ID , p_M_Warehouse_ID, p_S_Resource_ID,M_Product_ID, get_TrxName());
|
||||
//Create Product Data Planning
|
||||
if (pp==null)
|
||||
{
|
||||
pp = new MPPProductPlanning(getCtx(),0,get_TrxName());
|
||||
pp.setAD_Org_ID(0);
|
||||
pp.setAD_Org_ID(m_AD_Org_ID);
|
||||
pp.setM_Product_ID(rs.getInt(1));
|
||||
pp.setDD_NetworkDistribution_ID (p_DD_NetworkDistribution_ID);
|
||||
pp.setAD_Workflow_ID(p_AD_Workflow_ID);
|
||||
|
@ -236,11 +238,10 @@ public class CreateProductPlanning extends SvrProcess
|
|||
pp.setTimeFence(p_TimeFence);
|
||||
pp.setWorkingTime(p_WorkingTime);
|
||||
pp.setYield(p_Yield);
|
||||
pp.save(get_TrxName());
|
||||
pp.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
pp.setDD_NetworkDistribution_ID (p_DD_NetworkDistribution_ID);
|
||||
pp.setAD_Workflow_ID(p_AD_Workflow_ID);
|
||||
pp.setIsCreatePlan(p_CreatePlan);
|
||||
|
|
|
@ -483,7 +483,7 @@ public class MRP extends SvrProcess
|
|||
{
|
||||
|
||||
//find data product planning demand
|
||||
MPPProductPlanning pp = MPPProductPlanning.getMPPProductPlanning(getCtx(), AD_Client_ID ,AD_Org_ID , M_Warehouse_ID, S_Resource_ID , product.getM_Product_ID(), get_TrxName());
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), AD_Client_ID ,AD_Org_ID , M_Warehouse_ID, S_Resource_ID , product.getM_Product_ID(), get_TrxName());
|
||||
DatePromisedTo = null;
|
||||
DatePromisedFrom = null;
|
||||
if (pp != null)
|
||||
|
|
|
@ -118,7 +118,7 @@ public class RollupWorkflow extends SvrProcess
|
|||
// check if element cost is of type Labor
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_Resource))
|
||||
{
|
||||
BigDecimal Labor = getCost(element.COSTELEMENTTYPE_Resource , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
BigDecimal Labor = getCost(element.COSTELEMENTTYPE_Resource , getAD_Client_ID(), p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Labor : " + Labor);
|
||||
cost.setCurrentCostPrice(Labor);
|
||||
cost.save();
|
||||
|
@ -126,7 +126,7 @@ public class RollupWorkflow extends SvrProcess
|
|||
}
|
||||
if (element.getCostElementType().equals(element.COSTELEMENTTYPE_BurdenMOverhead))
|
||||
{
|
||||
BigDecimal Burden = getCost(element.COSTELEMENTTYPE_BurdenMOverhead, p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
BigDecimal Burden = getCost(element.COSTELEMENTTYPE_BurdenMOverhead, getAD_Client_ID() , p_AD_Org_ID , M_Product_ID , p_M_CostType_ID , p_C_AcctSchema_ID);
|
||||
log.info("Burden : " + Burden);
|
||||
cost.setCurrentCostPrice(Burden);
|
||||
cost.save(get_TrxName());
|
||||
|
@ -160,11 +160,11 @@ public class RollupWorkflow extends SvrProcess
|
|||
* @return Cost for this Element
|
||||
* @throws Exception if not successful
|
||||
*/
|
||||
private BigDecimal getCost(String CostElementType , int AD_Org_ID , int M_Product_ID , int M_CostType_ID , int C_AcctSchema_ID)
|
||||
private BigDecimal getCost(String CostElementType ,int AD_Client_ID , int AD_Org_ID , int M_Product_ID , int M_CostType_ID , int C_AcctSchema_ID)
|
||||
{
|
||||
BigDecimal cost = Env.ZERO;
|
||||
|
||||
int AD_Workflow_ID = getAD_Workflow_ID(AD_Org_ID , M_Product_ID);
|
||||
int AD_Workflow_ID = getAD_Workflow_ID(AD_Client_ID , AD_Org_ID , M_Product_ID);
|
||||
if (AD_Workflow_ID != 0)
|
||||
{
|
||||
MWorkflow Workflow = new MWorkflow(getCtx(),AD_Workflow_ID,get_TrxName());
|
||||
|
@ -256,10 +256,10 @@ public class RollupWorkflow extends SvrProcess
|
|||
* @param M_Product_ID Product ID
|
||||
* @return Workflow ID
|
||||
**/
|
||||
private int getAD_Workflow_ID(int AD_Org_ID , int M_Product_ID)
|
||||
private int getAD_Workflow_ID(int AD_Client_ID ,int AD_Org_ID , int M_Product_ID)
|
||||
{
|
||||
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), AD_Org_ID , M_Product_ID, get_TrxName());
|
||||
MPPProductPlanning pp = MPPProductPlanning.get(getCtx(), AD_Client_ID, AD_Org_ID , M_Product_ID, get_TrxName());
|
||||
MProduct M_Product = new MProduct(getCtx(), M_Product_ID,null);
|
||||
|
||||
int AD_Workflow_ID = 0;
|
||||
|
|
Loading…
Reference in New Issue