use of org.compiere.model.MResource in project adempiere by adempiere.
the class MRPUpdate method doIt.
// prepare
/**
* doIT - run process
*/
protected String doIt() throws Exception {
String result = null;
ArrayList<Object> parameters = new ArrayList<Object>();
StringBuffer whereClause = new StringBuffer(MResource.COLUMNNAME_ManufacturingResourceType + "=? AND AD_Client_ID=?");
parameters.add(MResource.MANUFACTURINGRESOURCETYPE_Plant);
parameters.add(m_AD_Client_ID);
if (p_S_Resource_ID > 0) {
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();
if (plants.size() == 0) {
// TODO: translate
throw new AdempiereException("No plants found");
}
for (MResource plant : plants) {
log.info("Run MRP to Plant: " + plant.getName());
parameters = new ArrayList<Object>();
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());
deleteRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), w.getM_Warehouse_ID());
createRecords(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 {
log.info("Run MRP to Wharehouse: " + p_M_Warehouse_ID);
deleteRecords(m_AD_Client_ID, organization.getAD_Org_ID(), plant.getS_Resource_ID(), p_M_Warehouse_ID);
createRecords(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();
}
if (Util.isEmpty(result, true)) {
// TODO: translate
return "No records found";
}
return Msg.getMsg(getCtx(), "ProcessOK");
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class MRP method doIt.
protected String doIt() throws Exception {
parameters = new ArrayList<Object>();
dd_order_id_cache.clear();
partner_cache.clear();
StringBuffer whereClause = new StringBuffer(MResource.COLUMNNAME_ManufacturingResourceType + "=? AND AD_Client_ID=?");
parameters.add(MResource.MANUFACTURINGRESOURCETYPE_Plant);
parameters.add(getAD_Client_ID());
if (getPlant_ID() > 0) {
whereClause.append(" AND " + MResource.COLUMNNAME_S_Resource_ID + "=?");
parameters.add(getPlant_ID());
}
List<MResource> plants = new Query(getCtx(), MResource.Table_Name, whereClause.toString(), get_TrxName()).setParameters(parameters).list();
if (plants == null || plants.size() <= 0)
return MRefList.getListName(getCtx(), MResource.MANUFACTURINGRESOURCETYPE_AD_Reference_ID, "PT") + " @S_Resource_ID@ @NotFound@";
for (MResource plant : plants) {
log.info("Run MRP to Plant: " + plant.getName());
this.Planning_Horizon = TimeUtil.addDays(getToday(), plant.getPlanningHorizon());
parameters = new ArrayList<Object>();
whereClause = new StringBuffer("AD_Client_ID=?");
parameters.add(getAD_Client_ID());
if (getAD_Org_ID() > 0) {
whereClause.append(" AND AD_Org_ID=?");
parameters.add(getAD_Org_ID());
}
List<MOrg> orgList = new Query(getCtx(), MOrg.Table_Name, whereClause.toString(), get_TrxName()).setParameters(parameters).list();
for (MOrg org : orgList) {
// Set Default Document Type To Requisition
int AD_User_ID = Env.getAD_User_ID(getCtx());
docTypeReq_ID = MPPMRP.getDocType(getCtx(), MDocType.DOCBASETYPE_PurchaseRequisition, org.getAD_Org_ID(), AD_User_ID, get_TrxName());
docTypeMO_ID = MPPMRP.getDocType(getCtx(), MDocType.DOCBASETYPE_ManufacturingOrder, org.getAD_Org_ID(), AD_User_ID, get_TrxName());
docTypeMF_ID = MPPMRP.getDocType(getCtx(), MDocType.DOCBASETYPE_MaintenanceOrder, org.getAD_Org_ID(), AD_User_ID, get_TrxName());
docTypeDO_ID = MPPMRP.getDocType(getCtx(), MDocType.DOCBASETYPE_DistributionOrder, org.getAD_Org_ID(), AD_User_ID, get_TrxName());
log.info("Run MRP to Organization: " + org.getName());
MWarehouse[] ws;
if (getM_Warehouse_ID() <= 0) {
ws = MWarehouse.getForOrg(getCtx(), org.getAD_Org_ID());
} else {
ws = new MWarehouse[] { MWarehouse.get(getCtx(), getM_Warehouse_ID()) };
}
//
for (MWarehouse w : ws) {
// remove using DRP should be executed
//if(plant.getM_Warehouse_ID() == w.getM_Warehouse_ID() && isRequiredDRP())
// continue;
log.info("Run MRP to Wharehouse: " + w.getName());
runMRP(getAD_Client_ID(), org.getAD_Org_ID(), plant.getS_Resource_ID(), w.getM_Warehouse_ID());
StringBuffer resultMsg = new StringBuffer();
resultMsg.append("<br> <b> @AD_Org_ID@: </b>" + org.getName());
resultMsg.append("<b>, @M_Warehouse_ID@: </b>" + w.getName());
resultMsg.append("<b>, @S_Resource_ID@: </b>" + plant.getName());
resultMsg.append("<hr>");
resultMsg.append("<br><b>@PP_Order_ID@:</b> " + count_MO);
resultMsg.append("<br><b>@DD_Order_ID@:</b> " + count_DO);
resultMsg.append("<br><b>@M_Requisition_ID@:</b> " + count_MR);
resultMsg.append("<br><b>@AD_Note_ID@:</b> " + count_Msg);
count_MO = 0;
count_MR = 0;
count_DO = 0;
count_Msg = 0;
addLog("");
addLog(resultMsg.toString());
}
//resultMsg.append("<br>finish MRP to Organization " +org.getName());
}
}
//
return "";
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class WCRP method onEvent.
@Override
public void onEvent(Event event) throws Exception {
String cmd = event.getTarget().getId();
if (cmd.equals(ConfirmPanel.A_OK)) {
Timestamp date = null;
if (dateFrom.getValue() != null)
date = (Timestamp) dateFrom.getValue();
int S_Resource_ID = 0;
if (resource.getValue() != null)
S_Resource_ID = ((Integer) resource.getValue()).intValue();
if (date != null && S_Resource_ID != 0) {
MResource r = MResource.get(Env.getCtx(), S_Resource_ID);
int uom_id = r.getResourceType().getC_UOM_ID();
MUOM uom = MUOM.get(Env.getCtx(), uom_id);
CategoryDataset dataset = null;
if (uom.isHour()) {
dataset = createDataset(date, r);
} else {
dataset = createWeightDataset(date, r);
}
String title = r.getName() != null ? r.getName() : "";
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
JFreeChart jfreechart = createChart(dataset, title, uom);
renderChart(jfreechart);
}
}
if (cmd.equals(ConfirmPanel.A_CANCEL)) {
dispose();
}
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class WCRPDetail method getChartTitle.
private String getChartTitle() {
MResource r = getResource(resource.getValue());
String title = r.getName() != null ? r.getName() : "";
title = title + " " + r.getDescription() != null ? r.getDescription() : "";
return title;
}
use of org.compiere.model.MResource in project adempiere by adempiere.
the class CreateRfQAction method createRfQ.
private void createRfQ(DefaultMutableTreeNode node) {
BOMWrapper bom = (BOMWrapper) node.getUserObject();
MPPOrder mo = new MPPOrder(Env.getCtx(), bom.getPP_Order_ID(), null);
MResource r = MResource.get(Env.getCtx(), mo.getS_Resource_ID());
Calendar cal = Calendar.getInstance();
MRfQ rfq = new MRfQ(Env.getCtx(), 0, null);
rfq.setName(Msg.translate(Env.getCtx(), "C_RFQ_ID") + ": " + mo.getDocumentNo() + "_" + r.getName() + " (" + bom.getName() + ")");
rfq.setC_Currency_ID(Env.getContextAsInt(Env.getCtx(), "$C_Currency_ID"));
rfq.setQuoteType(MRfQ.QUOTETYPE_QuoteSelectedLines);
rfq.setDateWorkStart(mo.getDateStartSchedule());
rfq.setDateWorkComplete(mo.getDateFinishSchedule());
// process parameters
rfq.setC_RfQ_Topic_ID(((BigDecimal) getParameterValue("C_RFQ_Topic_ID")).intValue());
rfq.setSalesRep_ID(((BigDecimal) getParameterValue("SalesRep_ID")).intValue());
savePO(rfq);
if (successful()) {
createRfQLines(rfq.get_ID(), node);
}
}
Aggregations