Search in sources :

Example 26 with MPPProductBOMLine

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

the class VProductConfigurationBOM method isSameProductsInProductInstance.

private boolean isSameProductsInProductInstance(int bomLevel, ArrayList<MPPProductBOMLine> configBomLines, HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
    log.info("In isSameProductsInProductInstance");
    boolean retVal = true;
    Set set = m_ConfigBOMInstIDToBOMLinesMap.entrySet();
    for (Iterator i = set.iterator(); i.hasNext(); ) {
        Map.Entry me = (Map.Entry) i.next();
        HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
        log.fine("PP_Product_BOM_ID: " + me.getKey().toString() + " has: ");
        m_BOMLevelToLinesMap = (HashMap<Integer, ArrayList<MPPProductBOMLine>>) me.getValue();
        Set setLines = m_BOMLevelToLinesMap.entrySet();
        for (Iterator k = setLines.iterator(); k.hasNext(); ) {
            Map.Entry me2 = (Map.Entry) k.next();
            if (((Integer) me2.getKey()).intValue() == bomLevel) {
                ArrayList<MPPProductBOMLine> configInstanceBomLines = (ArrayList<MPPProductBOMLine>) me2.getValue();
                log.fine("configBomLines.size: " + configBomLines.size());
                log.fine("configInstanceBomLines.size: " + configInstanceBomLines.size());
                for (int l = 0; l < configBomLines.size(); l++) {
                    boolean matchedProduct = false;
                    for (int m = 0; m < configInstanceBomLines.size(); m++) {
                        int chosenProduct_ID = getProductFromMPPProductBOMLine(configBomLines.get(l)).get_ID();
                        int instanceProduct_ID = getProductFromMPPProductBOMLine(configBomLines.get(m)).get_ID();
                        log.fine("bomLevel: " + bomLevel);
                        log.fine("chosenProduct_ID: " + chosenProduct_ID);
                        log.fine("instanceProduct_ID: " + instanceProduct_ID);
                        if (chosenProduct_ID == instanceProduct_ID)
                            matchedProduct = true;
                    }
                    if (!matchedProduct)
                        return false;
                }
            }
        }
    }
    return retVal;
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) ALayoutConstraint(org.compiere.apps.ALayoutConstraint) Iterator(java.util.Iterator) Map(java.util.Map) HashMap(java.util.HashMap)

Example 27 with MPPProductBOMLine

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

the class VProductConfigurationBOM method buildConfigBOMIDToBOMLevelToLinesMapFromSelectionList.

private HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> buildConfigBOMIDToBOMLevelToLinesMapFromSelectionList() {
    log.fine("In buildConfigBOMIDToBOMLevelToLinesMapFromSelectionList");
    KeyNamePair pp = (KeyNamePair) productField.getSelectedItem();
    MProduct m_productConfig = MProduct.get(Env.getCtx(), pp.getKey());
    MPPProductBOMLine[] configBOMLines = getBOMLines(m_productConfig);
    int PP_ConfigProduct_BOM_ID = configBOMLines[0].getPP_Product_BOM_ID();
    HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMIDToBOMLevelToLinesMapFromSelectionList = new HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>>();
    HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
    HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMapFromKey = null;
    //	for all bom lines
    for (int i = 0; i < m_selectionList.size(); i++) {
        if (isSelectionSelected(m_selectionList.get(i))) {
            int PP_Product_BOMLine_ID = ((Integer) m_bomLineIDList.get(i)).intValue();
            log.fine("PP_Product_BOMLine_ID: " + PP_Product_BOMLine_ID);
            MPPProductBOMLine m_MPPProductBOMLine = new MPPProductBOMLine(Env.getCtx(), PP_Product_BOMLine_ID, null);
            m_BOMLevelToLinesMapFromKey = (HashMap<Integer, ArrayList<MPPProductBOMLine>>) m_ConfigBOMIDToBOMLevelToLinesMapFromSelectionList.get(new Integer(m_MPPProductBOMLine.getPP_Product_BOM_ID()));
            if (m_BOMLevelToLinesMapFromKey == null) {
                m_BOMLevelToLinesMapFromKey = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
                m_ConfigBOMIDToBOMLevelToLinesMapFromSelectionList.put(new Integer(m_MPPProductBOMLine.getPP_Product_BOM_ID()), m_BOMLevelToLinesMapFromKey);
                //ArrayList<MPPProductBOMLine> bomLines = (ArrayList<MPPProductBOMLine>)m_BOMLevelToLinesMapFromKey.get(getBomLevelBetweenPPProductBOMIDs(PP_ConfigProduct_BOM_ID, m_MPPProductBOMLine.getPP_Product_BOM_ID()));
                ArrayList<MPPProductBOMLine> bomLines = new ArrayList<MPPProductBOMLine>();
                bomLines.add(m_MPPProductBOMLine);
                m_BOMLevelToLinesMapFromKey.put(getBomLevelBetweenPPProductBOMIDs(PP_ConfigProduct_BOM_ID, m_MPPProductBOMLine.getPP_Product_BOM_ID()), bomLines);
            } else {
                ArrayList<MPPProductBOMLine> bomLines = (ArrayList<MPPProductBOMLine>) m_BOMLevelToLinesMapFromKey.get(getBomLevelBetweenPPProductBOMIDs(PP_ConfigProduct_BOM_ID, m_MPPProductBOMLine.getPP_Product_BOM_ID()));
                bomLines.add(m_MPPProductBOMLine);
            }
        }
    //	line selected
    }
    return m_ConfigBOMIDToBOMLevelToLinesMapFromSelectionList;
}
Also used : MProduct(org.compiere.model.MProduct) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) KeyNamePair(org.compiere.util.KeyNamePair) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 28 with MPPProductBOMLine

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

the class VProductConfigurationBOM method getTotalBOMLines.

private int getTotalBOMLines(HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
    log.fine("In getTotalBOMLines");
    int retVal = 0;
    Set set = m_ConfigBOMInstIDToBOMLinesMap.entrySet();
    for (Iterator i = set.iterator(); i.hasNext(); ) {
        Map.Entry me = (Map.Entry) i.next();
        HashMap<Integer, ArrayList<MPPProductBOMLine>> m_BOMLevelToLinesMap = new HashMap<Integer, ArrayList<MPPProductBOMLine>>();
        m_BOMLevelToLinesMap = (HashMap<Integer, ArrayList<MPPProductBOMLine>>) me.getValue();
        Set set2 = m_BOMLevelToLinesMap.entrySet();
        for (Iterator i2 = set2.iterator(); i2.hasNext(); ) {
            Map.Entry me2 = (Map.Entry) i2.next();
            ArrayList<MPPProductBOMLine> bomLines = (ArrayList<MPPProductBOMLine>) me2.getValue();
            retVal += bomLines.size();
        }
    }
    log.fine("Total bom lines: " + retVal);
    return retVal;
}
Also used : ResultSet(java.sql.ResultSet) Set(java.util.Set) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) Map(java.util.Map) HashMap(java.util.HashMap) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Example 29 with MPPProductBOMLine

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

the class VTreeBOM method parent.

public DefaultMutableTreeNode parent(MPPProductBOM bom) {
    // System.out.println("Parent:" + bom.getName());
    // X_M_Product product = new X_M_Product(getCtx(), bom.getM_Product_ID(),"M_Product");
    //vparent.setValue(m_product_id);
    DefaultMutableTreeNode parent = new DefaultMutableTreeNode(productSummary(bom));
    if (m_level == getLevelNo()) {
        m_level--;
        return parent;
    }
    for (MPPProductBOMLine bomline : bom.getLines()) {
        MProduct component = MProduct.get(getCtx(), bomline.getM_Product_ID());
        //System.out.println("Componente :" + component.getValue() + "[" + component.getName() + "]");
        //component(component);
        Vector<Object> line = new Vector<Object>(17);
        //  0 Select
        line.add(new Boolean(false));
        //  1 IsActive
        line.add(new Boolean(true));
        // 2 Line                
        line.add(new Integer(bomline.getLine()));
        //  3 ValidDrom
        line.add((Timestamp) bomline.getValidFrom());
        //  4 ValidTo
        line.add((Timestamp) bomline.getValidTo());
        KeyNamePair pp = new KeyNamePair(component.getM_Product_ID(), component.getName());
        //  5 M_Product_ID
        line.add(pp);
        KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), bomline.getC_UOM().getUOMSymbol());
        //  6 C_UOM_ID
        line.add(uom);
        //  7 IsQtyPercentage
        line.add(new Boolean(bomline.isQtyPercentage()));
        //  8 BatchPercent
        line.add((BigDecimal) bomline.getQtyBatch());
        //  9 QtyBom
        line.add((BigDecimal) bomline.getQtyBOM());
        //  10 IsCritical       
        line.add(new Boolean(bomline.isCritical()));
        // 11 LTOffSet
        line.add((Integer) bomline.getLeadTimeOffset());
        // 12 Assay
        line.add((BigDecimal) bomline.getAssay());
        // 13 Scrap
        line.add((BigDecimal) (bomline.getScrap()));
        // 14 IssueMethod
        line.add((String) bomline.getIssueMethod());
        // 15 BackflushGroup
        line.add((String) bomline.getBackflushGroup());
        // 16 Forecast
        line.add((BigDecimal) bomline.getForecast());
        dataBOM.add(line);
        parent.add(component(component));
    }
    m_level--;
    return parent;
}
Also used : MProduct(org.compiere.model.MProduct) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) KeyNamePair(org.compiere.util.KeyNamePair) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) Vector(java.util.Vector)

Example 30 with MPPProductBOMLine

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

the class VProductConfigurationBOM method addBOMLines.

/**
	 * 	Add BOM Lines to this.
	 * 	Called recursively
	 * 	@param product product
	 * 	@param qty quantity
	 */
private void addBOMLines(MProduct product, BigDecimal qty) {
    MPPProductBOMLine[] bomLines = getBOMLines(product);
    for (int i = 0; i < bomLines.length; i++) addBOMLine(bomLines[i], qty);
    log.fine("#" + bomLines.length);
}
Also used : MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) ALayoutConstraint(org.compiere.apps.ALayoutConstraint)

Aggregations

MPPProductBOMLine (org.eevolution.model.MPPProductBOMLine)33 ArrayList (java.util.ArrayList)14 MProduct (org.compiere.model.MProduct)13 MPPProductBOM (org.eevolution.model.MPPProductBOM)13 ALayoutConstraint (org.compiere.apps.ALayoutConstraint)10 HashMap (java.util.HashMap)8 ResultSet (java.sql.ResultSet)7 Iterator (java.util.Iterator)6 Map (java.util.Map)6 Set (java.util.Set)6 Query (org.compiere.model.Query)6 BigDecimal (java.math.BigDecimal)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 KeyNamePair (org.compiere.util.KeyNamePair)4 Vector (java.util.Vector)3 AdempiereException (org.adempiere.exceptions.AdempiereException)2 MCost (org.compiere.model.MCost)2 X_T_BOMLine (org.eevolution.model.X_T_BOMLine)2 DefaultTreeNode (org.zkoss.zul.DefaultTreeNode)2 PreparedStatement (java.sql.PreparedStatement)1