Bring in Manufacturing Light code from Adaxa / Paul Bowden
Refs #44. Improve exception handling on production create lines. Prevent production lines for same locator/asi being split changeset 6170 1b6c87d57f92
This commit is contained in:
parent
d00cfa2ad5
commit
0785915c7b
|
@ -8,6 +8,7 @@ import java.util.ArrayList;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.compiere.model.MAttributeSetInstance;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MProduct;
|
||||
|
@ -52,11 +53,12 @@ public class MProduction extends X_M_Production {
|
|||
+ "WHERE pl.M_Production_ID = ?";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
pstmt.setInt(1, get_ID());
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
list.add( new MProductionLine( getCtx(), rs.getInt(1), get_TrxName() ) );
|
||||
rs.close();
|
||||
|
@ -65,17 +67,12 @@ public class MProduction extends X_M_Production {
|
|||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
m_log.log(Level.SEVERE, sql, ex);
|
||||
throw new AdempiereException("Unable to load production lines", ex);
|
||||
}
|
||||
try
|
||||
finally
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close();
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
catch (SQLException ex1)
|
||||
{
|
||||
}
|
||||
pstmt = null;
|
||||
|
||||
MProductionLine[] retValue = new MProductionLine[list.size()];
|
||||
list.toArray(retValue);
|
||||
|
@ -120,11 +117,12 @@ public class MProduction extends X_M_Production {
|
|||
+ " WHERE M_Product_ID=" + getM_Product_ID() + " ORDER BY Line";
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, get_TrxName());
|
||||
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
|
||||
lineno = lineno + 10;
|
||||
|
@ -244,6 +242,19 @@ public class MProduction extends X_M_Production {
|
|||
if (BOMMovementQty.signum() != 0 ) {
|
||||
if (!mustBeStocked)
|
||||
{
|
||||
|
||||
// roll up costing attributes if in the same locator
|
||||
if ( previousAttribSet == 0
|
||||
&& prevLoc == defaultLocator) {
|
||||
BOMLine.setQtyUsed(BOMLine.getQtyUsed()
|
||||
.add(BOMMovementQty));
|
||||
BOMLine.setPlannedQty(BOMLine.getQtyUsed());
|
||||
BOMLine.save(get_TrxName());
|
||||
|
||||
}
|
||||
// otherwise create new line
|
||||
else {
|
||||
|
||||
BOMLine = new MProductionLine( this );
|
||||
BOMLine.setLine( lineno );
|
||||
BOMLine.setM_Product_ID( BOMProduct_ID );
|
||||
|
@ -255,6 +266,8 @@ public class MProduction extends X_M_Production {
|
|||
lineno = lineno + 10;
|
||||
count++;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AdempiereUserError("Not enough stock of " + BOMProduct_ID);
|
||||
|
@ -263,7 +276,10 @@ public class MProduction extends X_M_Production {
|
|||
}
|
||||
} // for all bom products
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "createLines", e);
|
||||
throw new AdempiereException("Failed to create production lines", e);
|
||||
}
|
||||
finally {
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
|
||||
return count;
|
||||
|
|
|
@ -325,6 +325,4 @@ public class MProductionLine extends X_M_ProductionLine {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue