[ 2083255 ] Let Calculate Material Plant for every Plant, Org, Wh

http://sourceforge.net/tracker/index.php?func=detail&aid=2083255&group_id=176962&atid=879335
This commit is contained in:
vpj-cd 2008-08-30 01:34:55 +00:00
parent e92957b06d
commit ff4df8636d
4 changed files with 148 additions and 32 deletions

View File

@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@ -184,19 +185,60 @@ public class MRP extends SvrProcess
log.info("Type Document to Requisition:"+ DocTypeReq);
log.info("Type Document to Manufacturing Order:" + DocTypeMO);
log.info("Type Document to Distribution Order:" + DocTypeDO);
if(p_M_Warehouse_ID==0)
{
MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), p_AD_Org_ID);
for(MWarehouse w : ws)
{
runMRP(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,w.getM_Warehouse_ID());
result = result + "<br>finish MRP to Warehouse " +w.getName();
}
}
else
ArrayList <Object> parameters = new ArrayList();
StringBuffer whereClause = new StringBuffer(MResource.COLUMNNAME_ManufacturingResourceType+"='"+
MResource.MANUFACTURINGRESOURCETYPE_Plant+ "' AND AD_Client_ID=?");
parameters.add(m_AD_Client_ID);
if (p_S_Resource_ID > 0)
{
runMRP(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,p_M_Warehouse_ID);
whereClause.append(" AND S_Resource_ID=?");
parameters.add(p_S_Resource_ID);
}
List <MResource> plants = new Query(getCtx(), MResource.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(parameters)
.list();
for(MResource plant : plants)
{
log.info("Run MRP to Plant: " + plant.getName());
parameters = new ArrayList();
whereClause = new StringBuffer("AD_Client_ID=?");
parameters.add(m_AD_Client_ID);
if (p_AD_Org_ID > 0)
{
whereClause.append(" AND AD_Org_ID=?");
parameters.add(p_AD_Org_ID);
}
List <MOrg> organizations = new Query(getCtx(),MOrg.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(parameters)
.list();
for (MOrg organization : organizations)
{
log.info("Run MRP to Organization: " + organization.getName());
if(p_M_Warehouse_ID==0)
{
MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), organization.getAD_Org_ID());
for(MWarehouse w : ws)
{
log.info("Run MRP to Wharehouse: " + w.getName());
runMRP(m_AD_Client_ID,organization.getAD_Org_ID(),plant.getS_Resource_ID(),w.getM_Warehouse_ID());
result = result + "<br>finish MRP to Warehouse " +w.getName();
}
}
else
{
runMRP(m_AD_Client_ID,organization.getAD_Org_ID(),plant.getS_Resource_ID(),p_M_Warehouse_ID);
}
result = result + "<br>finish MRP to Organization " +organization.getName();
}
result = result + "<br>finish MRP to Plant " +plant.getName();
}
return result;

View File

@ -17,9 +17,13 @@
package org.eevolution.process;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.compiere.model.MOrg;
import org.compiere.model.MRequisition;
import org.compiere.model.MResource;
import org.compiere.model.MWarehouse;
import org.compiere.model.PO;
import org.compiere.model.POResultSet;
@ -87,23 +91,63 @@ public class MRPUpdate extends SvrProcess
*/
protected String doIt() throws Exception
{
if(p_M_Warehouse_ID==0)
ArrayList <Object> parameters = new ArrayList();
StringBuffer whereClause = new StringBuffer(MResource.COLUMNNAME_ManufacturingResourceType+"='"+
MResource.MANUFACTURINGRESOURCETYPE_Plant+ "' AND AD_Client_ID=?");
parameters.add(m_AD_Client_ID);
if (p_S_Resource_ID > 0)
{
MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), p_AD_Org_ID);
for(MWarehouse w : ws)
{
if(!deleteRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,w.getM_Warehouse_ID()))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
if(!createRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,w.getM_Warehouse_ID()))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
}
whereClause.append(" AND S_Resource_ID=?");
parameters.add(p_S_Resource_ID);
}
else
List <MResource> plants = new Query(getCtx(), MResource.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(parameters)
.list();
for(MResource plant : plants)
{
if(!deleteRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,p_M_Warehouse_ID))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
if(!createRecord(m_AD_Client_ID,p_AD_Org_ID,p_S_Resource_ID,p_M_Warehouse_ID))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
log.info("Create MRP record to Plant: " + plant.getName());
parameters = new ArrayList();
whereClause = new StringBuffer("AD_Client_ID=?");
parameters.add(m_AD_Client_ID);
if (p_AD_Org_ID > 0)
{
whereClause.append(" AND AD_Org_ID=?");
parameters.add(p_AD_Org_ID);
}
List <MOrg> organizations = new Query(getCtx(),MOrg.Table_Name, whereClause.toString(), get_TrxName())
.setParameters(parameters)
.list();
for (MOrg organization : organizations)
{
log.info("Create MRP record to Organization: " + organization.getName());
if(p_M_Warehouse_ID==0)
{
MWarehouse[] ws = MWarehouse.getForOrg(getCtx(), p_AD_Org_ID);
for(MWarehouse w : ws)
{
log.info("Create MRP record to Warehouse: " + organization.getName());
if(!deleteRecord(m_AD_Client_ID,organization.get_ID(),plant.get_ID(),w.get_ID()))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
if(!createRecord(m_AD_Client_ID,organization.get_ID(),plant.get_ID(),w.get_ID()))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
}
}
else
{
if(!deleteRecord(m_AD_Client_ID,p_AD_Org_ID,plant.get_ID(),p_M_Warehouse_ID))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
if(!createRecord(m_AD_Client_ID,p_AD_Org_ID,plant.get_ID(),p_M_Warehouse_ID))
throw new Exception(Msg.getMsg(getCtx(), "ProcessFailed"),CLogger.retrieveException());
}
}
}
return Msg.getMsg(getCtx(), "ProcessOK");
}

View File

@ -0,0 +1,15 @@
-- Aug 29, 2008 7:06:38 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET AD_Val_Rule_ID=148, IsMandatory='N',Updated=TO_DATE('2008-08-29 19:06:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53054
;
-- Aug 29, 2008 7:09:28 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_DATE('2008-08-29 19:09:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53132
;
-- Aug 29, 2008 7:10:33 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_DATE('2008-08-29 19:10:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53207
;

View File

@ -0,0 +1,15 @@
-- Aug 29, 2008 7:06:38 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET AD_Val_Rule_ID=148, IsMandatory='N',Updated=TO_TIMESTAMP('2008-08-29 19:06:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53054
;
-- Aug 29, 2008 7:09:28 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_TIMESTAMP('2008-08-29 19:09:28','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53132
;
-- Aug 29, 2008 7:10:33 PM CDT
-- MRP Run to Multiple Plant
UPDATE AD_Process_Para SET IsMandatory='N',Updated=TO_TIMESTAMP('2008-08-29 19:10:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_Para_ID=53207
;