Search in sources :

Example 1 with MPPOrderNode

use of org.eevolution.model.MPPOrderNode in project adempiere by adempiere.

the class DefaultRoutingServiceImpl method estimateWorkingTime.

public BigDecimal estimateWorkingTime(I_PP_Cost_Collector cc) {
    final String trxName = (cc instanceof PO ? ((PO) cc).get_TrxName() : null);
    final BigDecimal qty = cc.getMovementQty();
    MPPOrderNode node = MPPOrderNode.get(Env.getCtx(), cc.getPP_Order_Node_ID(), trxName);
    return estimateWorkingTime(node, qty);
}
Also used : MPPOrderNode(org.eevolution.model.MPPOrderNode) BigDecimal(java.math.BigDecimal) PO(org.compiere.model.PO)

Example 2 with MPPOrderNode

use of org.eevolution.model.MPPOrderNode in project adempiere by adempiere.

the class CRPDatasetFactory method addTreeNodes.

/**
	 * Generates following tree:
	 * <pre>
	 * (dateTime)
	 *     \-------(root)
	 *     \-------(PP Order)
	 *                 \---------(PP Order Node)
	 * </pre>
	 * @param dateTime
	 * @param root
	 * @param r
	 * @return
	 */
private HashMap<DefaultMutableTreeNode, String> addTreeNodes(Timestamp dateTime, DefaultMutableTreeNode root, MResource r) {
    HashMap<DefaultMutableTreeNode, String> names = new HashMap<DefaultMutableTreeNode, String>();
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(dateTime);
    names.put(parent, getTreeNodeRepresentation(null, parent, r));
    root.add(parent);
    for (MPPOrder order : getPPOrders(dateTime, r)) {
        DefaultMutableTreeNode childOrder = new DefaultMutableTreeNode(order);
        parent.add(childOrder);
        names.put(childOrder, getTreeNodeRepresentation(dateTime, childOrder, r));
        for (MPPOrderNode node : getPPOrderNodes(dateTime, r)) {
            DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);
            childOrder.add(childNode);
            names.put(childNode, getTreeNodeRepresentation(dateTime, childNode, r));
        }
    }
    return names;
}
Also used : MPPOrderNode(org.eevolution.model.MPPOrderNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) HashMap(java.util.HashMap) MPPOrder(org.eevolution.model.MPPOrder)

Example 3 with MPPOrderNode

use of org.eevolution.model.MPPOrderNode in project adempiere by adempiere.

the class CRPDatasetFactory method getTreeNodeRepresentation.

private String getTreeNodeRepresentation(Timestamp dateTime, DefaultMutableTreeNode node, MResource r) {
    String name = null;
    if (node.getUserObject() instanceof MResource) {
        MResource res = (MResource) node.getUserObject();
        name = res.getName();
    } else if (node.getUserObject() instanceof Timestamp) {
        Timestamp d = (Timestamp) node.getUserObject();
        SimpleDateFormat df = Env.getLanguage(Env.getCtx()).getDateFormat();
        name = df.format(d);
        if (!isAvailable(r, d)) {
            name = "{" + name + "}";
        }
    } else if (node.getUserObject() instanceof MPPOrder) {
        MPPOrder o = (MPPOrder) node.getUserObject();
        MProduct p = MProduct.get(Env.getCtx(), o.getM_Product_ID());
        name = o.getDocumentNo() + " (" + p.getName() + ")";
    } else if (node.getUserObject() instanceof MPPOrderNode) {
        MPPOrderNode on = (MPPOrderNode) node.getUserObject();
        MPPOrderWorkflow owf = on.getMPPOrderWorkflow();
        MResourceType rt = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
        // no function
        //Env.getLanguage(Env.getCtx()).getTimeFormat();
        SimpleDateFormat df = new SimpleDateFormat("HH:mm");
        Timestamp[] interval = getDayBorders(dateTime, on, rt);
        name = df.format(interval[0]) + " - " + df.format(interval[1]) + " " + on.getName() + " (" + owf.getName() + ")";
    }
    return name;
}
Also used : MResource(org.compiere.model.MResource) MPPOrderNode(org.eevolution.model.MPPOrderNode) MProduct(org.compiere.model.MProduct) MPPOrderWorkflow(org.eevolution.model.MPPOrderWorkflow) Timestamp(java.sql.Timestamp) SimpleDateFormat(java.text.SimpleDateFormat) MPPOrder(org.eevolution.model.MPPOrder) MResourceType(org.compiere.model.MResourceType)

Example 4 with MPPOrderNode

use of org.eevolution.model.MPPOrderNode in project adempiere by adempiere.

the class DiagramTreeCellRenderer method getIcon.

protected ImageIcon getIcon(Object value) {
    ImageIcon icon = null;
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
    if (node.getUserObject() instanceof MResource) {
    } else if (node.getUserObject() instanceof Date) {
        icon = Env.getImageIcon("Calendar10.gif");
    } else if (node.getUserObject() instanceof MPPOrder) {
    } else if (node.getUserObject() instanceof MPPOrderNode) {
    }
    return icon;
}
Also used : MResource(org.compiere.model.MResource) ImageIcon(javax.swing.ImageIcon) MPPOrderNode(org.eevolution.model.MPPOrderNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Date(java.util.Date) MPPOrder(org.eevolution.model.MPPOrder)

Example 5 with MPPOrderNode

use of org.eevolution.model.MPPOrderNode in project adempiere by adempiere.

the class CRPDatasetFactory method calculateLoad.

public BigDecimal calculateLoad(Timestamp dateTime, MResource r, String docStatus) {
    MResourceType t = MResourceType.get(Env.getCtx(), r.getS_ResourceType_ID());
    MUOM uom = MUOM.get(Env.getCtx(), t.getC_UOM_ID());
    BigDecimal qtyOpen;
    long millis = 0l;
    for (MPPOrderNode node : getPPOrderNodes(dateTime, r)) {
        if (docStatus != null) {
            MPPOrder o = new MPPOrder(node.getCtx(), node.getPP_Order_ID(), node.get_TrxName());
            if (!o.getDocStatus().equals(docStatus)) {
                continue;
            }
        }
        millis += calculateMillisForDay(dateTime, node, t);
    }
    // Pre-converts to minutes, because its the lowest time unit of compiere 
    BigDecimal scale = new BigDecimal(1000 * 60);
    BigDecimal minutes = new BigDecimal(millis).divide(scale, 2, BigDecimal.ROUND_HALF_UP);
    return convert(minutes);
}
Also used : MPPOrderNode(org.eevolution.model.MPPOrderNode) MUOM(org.compiere.model.MUOM) MResourceType(org.compiere.model.MResourceType) BigDecimal(java.math.BigDecimal) MPPOrder(org.eevolution.model.MPPOrder)

Aggregations

MPPOrderNode (org.eevolution.model.MPPOrderNode)7 MPPOrder (org.eevolution.model.MPPOrder)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 MResource (org.compiere.model.MResource)3 BigDecimal (java.math.BigDecimal)2 Timestamp (java.sql.Timestamp)2 Date (java.util.Date)2 MResourceType (org.compiere.model.MResourceType)2 MPPOrderWorkflow (org.eevolution.model.MPPOrderWorkflow)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ImageIcon (javax.swing.ImageIcon)1 VDate (org.compiere.grid.ed.VDate)1 MProduct (org.compiere.model.MProduct)1 MUOM (org.compiere.model.MUOM)1 PO (org.compiere.model.PO)1 CRPException (org.eevolution.exceptions.CRPException)1