Search in sources :

Example 31 with MPPProductBOMLine

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

the class VProductConfigurationBOM method getTotalBOMLevels.

private int getTotalBOMLevels(HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
    log.fine("In getTotalBOMLevels");
    int maxBOMLevel = 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>>();
        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() > maxBOMLevel)
                maxBOMLevel = ((Integer) me2.getKey()).intValue();
        }
    }
    log.fine("maxBOMLevel found: " + maxBOMLevel);
    return maxBOMLevel;
}
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 32 with MPPProductBOMLine

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

the class VProductConfigurationBOM method printConfigBOMIDToBOMLinesMapForProduct.

private void printConfigBOMIDToBOMLinesMapForProduct(MProduct m_product, HashMap<Integer, HashMap<Integer, ArrayList<MPPProductBOMLine>>> m_ConfigBOMInstIDToBOMLinesMap) {
    log.fine("In printConfigBOMIDToBOMLinesMapForProduct");
    log.fine("Analyzing product bom id's and corresponding bomlines and levels for those product bom id's for a particular product");
    log.fine("Product: " + m_product.getName() + " has:");
    log.fine("Total BOM's: " + m_ConfigBOMInstIDToBOMLinesMap.size());
    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();
            ArrayList<MPPProductBOMLine> bomLines = (ArrayList<MPPProductBOMLine>) me2.getValue();
            log.fine("Total bom lines: " + bomLines.size());
            for (int count = 0; count < bomLines.size(); count++) {
                MPPProductBOMLine m_MPPProductBOMLine = (MPPProductBOMLine) bomLines.get(count);
                log.fine("bom line #: " + count + " product: " + m_MPPProductBOMLine.getDescription());
            }
        }
    }
}
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 33 with MPPProductBOMLine

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

the class MProduction method createBOM.

/**
	 * Create Lines from finished product
	 * @param mustBeStocked
	 * @param finishedProduct
	 * @param requiredQty
	 * @return
	 */
private String createBOM(boolean mustBeStocked, MProduct finishedProduct, BigDecimal requiredQty) {
    int defaultLocator = 0;
    MPPProductBOM bom = MPPProductBOM.getDefault(finishedProduct, get_TrxName());
    for (MPPProductBOMLine bLine : bom.getLines()) {
        lineno = lineno + 10;
        BigDecimal BOMMovementQty = getQty(bLine, true).multiply(requiredQty);
        int precision = bLine.getPrecision();
        if (BOMMovementQty.scale() > precision) {
            BOMMovementQty = BOMMovementQty.setScale(precision, RoundingMode.HALF_UP);
        }
        MProduct bomproduct = bLine.getProduct();
        if (bomproduct.isBOM() && bomproduct.isPhantom()) {
            createBOM(mustBeStocked, bomproduct, BOMMovementQty);
        } else {
            defaultLocator = bomproduct.getM_Locator_ID();
            if (defaultLocator == 0)
                defaultLocator = getM_Locator_ID();
            if (!bomproduct.isStocked()) {
                MProductionLine BOMLine = null;
                BOMLine = new MProductionLine(this);
                BOMLine.setLine(lineno);
                BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
                BOMLine.setM_Locator_ID(defaultLocator);
                BOMLine.setQtyUsed(BOMMovementQty);
                BOMLine.setPlannedQty(BOMMovementQty);
                BOMLine.setMovementQty(BOMMovementQty.negate());
                BOMLine.saveEx(get_TrxName());
                lineno = lineno + 10;
            } else if (BOMMovementQty.signum() == 0) {
                MProductionLine BOMLine = null;
                BOMLine = new MProductionLine(this);
                BOMLine.setLine(lineno);
                BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
                BOMLine.setM_Locator_ID(defaultLocator);
                BOMLine.setQtyUsed(BOMMovementQty);
                BOMLine.setPlannedQty(BOMMovementQty);
                BOMLine.saveEx(get_TrxName());
                lineno = lineno + 10;
            } else {
                MProductionLine BOMLine = null;
                BOMLine = new MProductionLine(this);
                BOMLine.setLine(lineno);
                BOMLine.setM_Product_ID(bomproduct.getM_Product_ID());
                BOMLine.setM_Locator_ID(defaultLocator);
                BOMLine.setPlannedQty(BOMMovementQty);
                BOMLine.setQtyReserved(BOMMovementQty);
                BOMLine.setMovementQty(BOMMovementQty.negate());
                BOMLine.saveEx(get_TrxName());
                lineno = lineno + 10;
            }
        // for available storages
        }
    }
    return "";
}
Also used : MPPProductBOM(org.eevolution.model.MPPProductBOM) MPPProductBOMLine(org.eevolution.model.MPPProductBOMLine) BigDecimal(java.math.BigDecimal)

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