libero: refactor MPPOrder* classes

This commit is contained in:
teo_sarca 2008-08-27 19:45:15 +00:00
parent fb72fa6816
commit 0c5b13e196
13 changed files with 827 additions and 1690 deletions

View File

@ -628,4 +628,20 @@ public class MWFNode extends X_AD_WF_Node
return success;
} // afterDelete
/**
* Check if the workflow node is valid for given date
* @param date
* @return true if valid
*/
public boolean isValidFromTo(Timestamp date)
{
Timestamp validFrom = getValidFrom();
Timestamp validTo = getValidTo();
if (validFrom != null && date.before(validFrom))
return false;
if (validTo != null && date.after(validTo))
return false;
return true;
}
} // M_WFNext

View File

@ -19,6 +19,7 @@ package org.compiere.wf;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Properties;
@ -934,4 +935,20 @@ public class MWorkflow extends X_AD_Workflow
return DB.getSQLValue(null, sql, product.getValue(), AD_Client_ID);
}
/**
* Check if the workflow is valid for given date
* @param date
* @return true if valid
*/
public boolean isValidFromTo(Timestamp date)
{
Timestamp validFrom = getValidFrom();
Timestamp validTo = getValidTo();
if (validFrom != null && date.before(validFrom))
return false;
if (validTo != null && date.after(validTo))
return false;
return true;
}
} // MWorkflow_ID

View File

@ -28,9 +28,9 @@ import org.compiere.model.MRequisition;
import org.compiere.model.MRequisitionLine;
import org.compiere.model.MResource;
import org.compiere.model.MResourceType;
import org.compiere.model.MSequence;
import org.compiere.model.MTable;
import org.compiere.model.MWarehouse;
import org.compiere.model.Query;
import org.compiere.model.X_C_DocType;
import org.compiere.model.X_M_Forecast;
import org.compiere.model.X_M_ForecastLine;
@ -45,9 +45,13 @@ import org.compiere.wf.MWorkflow;
*
* @author Victor Perez www.e-evolution.com
* @version $Id: MPPMRP.java,v 1.4 2004/05/13 06:05:22 vpj-cd Exp $
*
* @author Teo Sarca, www.arhipac.ro
*/
public class MPPMRP extends X_PP_MRP
{
private static final long serialVersionUID = 1L;
/**************************************************************************
* Default Constructor
* @param ctx context
@ -86,7 +90,7 @@ public class MPPMRP extends X_PP_MRP
* @param X_M_ForecastLine Forecast Line
* @param delete Indicate if this record is delete
*/
public static void M_ForecastLine(X_M_ForecastLine fl,boolean delete)
public static void M_ForecastLine(X_M_ForecastLine fl, boolean delete)
{
String sql = null;
String trxName = fl.get_TrxName();
@ -94,13 +98,12 @@ public class MPPMRP extends X_PP_MRP
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE M_ForecastLine_ID = "+ fl.getM_ForecastLine_ID() +" AND AD_Client_ID = " + fl.getAD_Client_ID();
DB.executeUpdate(sql, trxName);
DB.executeUpdateEx(sql, trxName);
return;
}
MWarehouse[] w = MWarehouse.getForOrg(m_ctx,fl.getAD_Org_ID());
X_M_Forecast f = new X_M_Forecast(m_ctx,fl.getM_Forecast_ID(), trxName);
MWarehouse[] w = MWarehouse.getForOrg(m_ctx, fl.getAD_Org_ID());
X_M_Forecast f = new X_M_Forecast(m_ctx, fl.getM_Forecast_ID(), trxName);
String WhereClause = "M_ForecastLine_ID=?";
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID).getPO(WhereClause, new Object[]{fl.getM_ForecastLine_ID()}, trxName);
if(mrp!=null)
@ -169,58 +172,31 @@ public class MPPMRP extends X_PP_MRP
*/
public static void C_OrderLine(MOrderLine ol, boolean delete)
{
Properties m_ctx = ol.getCtx();
String sql = null;
String trxName = ol.getParent().get_TrxName();
Properties ctx = ol.getCtx();
String trxName = ol.get_TrxName();
final String whereClause = "AD_Client_ID = ? AND C_OrderLine_ID = ?";
Object[] params = new Object[]{ol.getAD_Client_ID(),ol.getC_OrderLine_ID()};
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE C_OrderLine_ID = "+ ol.getC_OrderLine_ID() +" AND AD_Client_ID = " + ol.getAD_Client_ID();
DB.executeUpdate(sql ,trxName);
int PP_Order_ID = DB.getSQLValue(trxName,"SELECT PP_Order_ID FROM PP_Order o WHERE o.AD_Client_ID = ? AND o.C_OrderLine_ID = ? ", ol.getAD_Client_ID(),ol.getC_OrderLine_ID());
if (PP_Order_ID != -1 )
DB.executeUpdateEx("DELETE FROM PP_MRP WHERE "+whereClause, params, trxName);
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
.setParameters(params)
.first();
if (order != null && !order.isProcessed())
{
MPPOrder order = new MPPOrder(m_ctx, PP_Order_ID,trxName);
if (!MPPOrder.DOCSTATUS_Completed.equals(order.getDocStatus())
&& !MPPOrder.DOCSTATUS_Closed.equals(order.getDocStatus())
)
{
order.deleteEx(true, trxName);
}
order.deleteEx(true, trxName);
}
return;
}
String WhereClause = "AD_Client_ID = ? AND C_OrderLine_ID = ?";
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID)
.getPO(WhereClause, new Object[]{ol.getAD_Client_ID(),ol.getC_OrderLine_ID()}, trxName);
if(mrp != null)
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
.setParameters(params)
.first();
if(mrp == null)
{
mrp.setDescription(ol.getDescription());
mrp.setName("MRP");
mrp.setQty(ol.getQtyOrdered().subtract(ol.getQtyDelivered()));
mrp.setDatePromised(ol.getDatePromised());
mrp.setDateStartSchedule(ol.getDatePromised());
mrp.setDateFinishSchedule(ol.getDatePromised());
mrp.setDateOrdered(ol.getDateOrdered());
mrp.setM_Product_ID(ol.getM_Product_ID());
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
mrp.setDocStatus(ol.getParent().getDocStatus());
mrp.saveEx();
}
else
{
mrp = new MPPMRP(m_ctx, 0,trxName);
mrp.setC_OrderLine_ID(ol.getC_OrderLine_ID());
mrp.setName("MRP");
mrp.setDescription(ol.getDescription());
mrp = new MPPMRP(ctx, 0,trxName);
mrp.setC_Order_ID(ol.getC_Order_ID());
mrp.setQty(ol.getQtyOrdered().subtract(ol.getQtyDelivered()));
mrp.setDatePromised(ol.getDatePromised());
mrp.setDateStartSchedule(ol.getDatePromised());
mrp.setDateFinishSchedule(ol.getDatePromised());
mrp.setDateOrdered(ol.getDateOrdered());
mrp.setM_Product_ID(ol.getM_Product_ID());
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
mrp.setDocStatus(ol.getParent().getDocStatus());
mrp.setC_OrderLine_ID(ol.getC_OrderLine_ID());
if (ol.getParent().isSOTrx())
{
mrp.setOrderType(MPPMRP.ORDERTYPE_SalesOrder);
@ -231,36 +207,46 @@ public class MPPMRP extends X_PP_MRP
mrp.setOrderType(MPPMRP.ORDERTYPE_PurchaseOrder);
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
}
mrp.saveEx();
}
mrp.setDescription(ol.getDescription());
mrp.setName("MRP");
mrp.setQty(ol.getQtyOrdered().subtract(ol.getQtyDelivered()));
mrp.setDatePromised(ol.getDatePromised());
mrp.setDateStartSchedule(ol.getDatePromised());
mrp.setDateFinishSchedule(ol.getDatePromised());
mrp.setDateOrdered(ol.getDateOrdered());
mrp.setM_Product_ID(ol.getM_Product_ID());
mrp.setM_Warehouse_ID(ol.getM_Warehouse_ID());
mrp.setDocStatus(ol.getParent().getDocStatus());
mrp.saveEx();
MPPOrder order = (MPPOrder) MTable.get(m_ctx, MPPOrder.Table_ID).getPO("AD_Client_ID = ? AND C_OrderLine_ID = ? ", new Object[]{ol.getAD_Client_ID(),ol.getC_OrderLine_ID()},trxName);
if (order == null )
MPPOrder order = new Query(ctx, MPPOrder.Table_Name, whereClause, trxName)
.setParameters(params)
.first();
if (order == null)
{
MProduct product = MProduct.get(m_ctx,ol.getM_Product_ID());
WhereClause = "AD_Client_ID = ? AND Value = ?";
MPPProductBOM bom = (MPPProductBOM) MTable.get(m_ctx, MPPProductBOM.Table_ID).getPO(WhereClause,new Object[]{ ol.getAD_Client_ID(),product.getValue()}, trxName);
MProduct product = MProduct.get(ctx,ol.getM_Product_ID());
MPPProductBOM bom = MPPProductBOM.getDefault(product, trxName);
if (bom != null)
{
if (bom.getBOMType().equals(MPPProductBOM.BOMTYPE_Make_To_Order))
{
WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?";
MResource m_resource = (MResource)MTable.get(m_ctx,MResource.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),ol.getM_Warehouse_ID()}, trxName);
WhereClause = "AD_Client_ID = ? AND Value = ?";
MWorkflow m_workflow = (MWorkflow)MTable.get(m_ctx,MWorkflow.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),product.getValue()}, trxName);
String WhereClause = "ManufacturingResourceType = 'PT' AND IsManufacturingResource = 'Y' AND AD_Client_ID = ? AND M_Warehouse_ID = ?";
MResource m_resource = (MResource)MTable.get(ctx,MResource.Table_ID).getPO(WhereClause, new Object[]{ ol.getAD_Client_ID(),ol.getM_Warehouse_ID()}, trxName);
MWorkflow m_workflow = MWorkflow.get(ctx, MWorkflow.getWorkflowSearchKey(ctx, product));
if (m_resource != null && m_workflow != null)
{
MDocType[] doc = MDocType.getOfDocBaseType(m_ctx,X_C_DocType.DOCBASETYPE_ManufacturingOrder);
int C_DocType_ID = doc[0].getC_DocType_ID();
order = new MPPOrder(m_ctx, 0 , trxName);
MDocType[] doc = MDocType.getOfDocBaseType(ctx, X_C_DocType.DOCBASETYPE_ManufacturingOrder);
int C_DocType_ID = doc[0].getC_DocType_ID();
order = new MPPOrder(ctx, 0 , trxName);
order.setC_OrderLine_ID(ol.getC_OrderLine_ID());
order.setDocumentNo(MSequence.getDocumentNo(C_DocType_ID,trxName,true));
order.setS_Resource_ID(m_resource.getS_Resource_ID());
order.setS_Resource_ID(m_resource.get_ID());
order.setM_Warehouse_ID(ol.getM_Warehouse_ID());
order.setM_Product_ID(ol.getM_Product_ID());
order.setM_AttributeSetInstance_ID(ol.getM_AttributeSetInstance_ID());
order.setPP_Product_BOM_ID(bom.getPP_Product_BOM_ID());
order.setAD_Workflow_ID(m_workflow.getAD_Workflow_ID());
order.setPP_Product_BOM_ID(bom.get_ID());
order.setAD_Workflow_ID(m_workflow.get_ID());
//order.setPlanner_ID(SupplyPlanner_ID);
order.setLine(10);
order.setQtyDelivered(Env.ZERO);
@ -268,7 +254,7 @@ public class MPPMRP extends X_PP_MRP
order.setQtyScrap(Env.ZERO);
order.setDateOrdered(ol.getDateOrdered());
order.setDatePromised(ol.getDatePromised());
order.setDateStartSchedule(TimeUtil.addDays(ol.getDatePromised(), (MPPMRP.getDays(m_ctx,m_resource.getS_Resource_ID(),m_workflow.getAD_Workflow_ID(), ol.getQtyOrdered(),ol.get_TrxName())).negate().intValue()));
order.setDateStartSchedule(TimeUtil.addDays(ol.getDatePromised(), (MPPMRP.getDays(ctx,m_resource.getS_Resource_ID(),m_workflow.getAD_Workflow_ID(), ol.getQtyOrdered(),ol.get_TrxName())).negate().intValue()));
order.setDateFinishSchedule(ol.getDatePromised());
order.setQtyEntered(ol.getQtyEntered());
order.setQtyOrdered(ol.getQtyOrdered());
@ -278,18 +264,17 @@ public class MPPMRP extends X_PP_MRP
order.setC_DocTypeTarget_ID(C_DocType_ID);
order.setC_DocType_ID(C_DocType_ID);
order.setPriorityRule(MPPOrder.PRIORITYRULE_High);
order.save(trxName);
order.saveEx();
order.prepareIt();
order.setDocAction(MPPOrder.DOCSTATUS_Completed);
order.saveEx();
}
}
}
}
}
else
{
if (MPPOrder.DOCSTATUS_Completed != order.getDocStatus() || MPPOrder.DOCSTATUS_Closed != order.getDocStatus())
if (!order.isProcessed())
{
order.setQtyEntered(ol.getQtyEntered());
order.setDatePromised(ol.getDatePromised());
@ -314,47 +299,32 @@ public class MPPMRP extends X_PP_MRP
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE PP_Order_ID = "+ o.getPP_Order_ID() +" AND AD_Client_ID = " + o.getAD_Client_ID();
DB.executeUpdate(sql ,trxName);
DB.executeUpdateEx(sql ,trxName);
return;
}
String WhereClause = "TypeMRP = 'S' AND OrderType='MOP' AND AD_Client_ID=? AND PP_Order_ID = ?";
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx,MPPMRP.Table_ID).getPO(WhereClause, new Object[]{o.getAD_Client_ID() , o.getPP_Order_ID()}, trxName);
if(mrp != null)
String whereClause = "TypeMRP=? AND OrderType=? AND AD_Client_ID=? AND PP_Order_ID=?";
MPPMRP mrp = new Query(m_ctx, MPPMRP.Table_Name, whereClause, trxName)
.setParameters(new Object[]{MPPMRP.TYPEMRP_Supply, MPPMRP.ORDERTYPE_ManufacturingOrder, o.getAD_Client_ID() , o.getPP_Order_ID()})
.first();
if(mrp == null)
{
mrp.setDescription(o.getDescription());
mrp.setName(o.getDocumentNo());
mrp.setQty(o.getQtyOrdered().subtract(o.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateFinishSchedule());
mrp.setM_Product_ID(o.getM_Product_ID());
mrp.setM_Warehouse_ID(o.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setDocStatus(o.getDocStatus());
mrp.saveEx();
}
else
{
mrp = new MPPMRP(m_ctx, 0, trxName);
mrp.setPP_Order_ID(o.getPP_Order_ID());
mrp.setDescription(o.getDescription());
mrp.setName(o.getDocumentNo());
mrp.setQty(o.getQtyOrdered().subtract(o.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateStartSchedule());
mrp.setM_Product_ID(o.getM_Product_ID());
mrp.setM_Warehouse_ID(o.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setOrderType(MPPMRP.ORDERTYPE_ManufacturingOrder);
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
mrp.setDocStatus(o.getDocStatus());
mrp.saveEx();
}
return ;
mrp.setOrderType(MPPMRP.ORDERTYPE_ManufacturingOrder);
}
mrp.setDescription(o.getDescription());
mrp.setName(o.getDocumentNo());
mrp.setQty(o.getQtyOrdered().subtract(o.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateStartSchedule());
mrp.setM_Product_ID(o.getM_Product_ID());
mrp.setM_Warehouse_ID(o.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setDocStatus(o.getDocStatus());
mrp.saveEx();
}
/**
@ -364,56 +334,40 @@ public class MPPMRP extends X_PP_MRP
*/
public static void PP_Order_BOMLine(MPPOrderBOMLine obl,boolean delete)
{
String sql = null;
String trxName = obl.getParent().get_TrxName();
Properties m_ctx = obl.getCtx();
String trxName = obl.get_TrxName();
Properties ctx = obl.getCtx();
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE PP_Order_BOMLine_ID = "+ obl.getPP_Order_BOMLine_ID() +" AND AD_Client_ID = " + obl.getAD_Client_ID();
DB.executeUpdate(sql ,trxName);
final String sql = "DELETE FROM PP_MRP WHERE PP_Order_BOMLine_ID=? AND AD_Client_ID=?";
DB.executeUpdateEx(sql, new Object[]{obl.get_ID(), obl.getAD_Client_ID()}, trxName);
return;
}
String WhereClause = "TypeMRP = 'D' AND OrderType='MOP' AND AD_Client_ID=? AND PP_Order_BOMLine_ID = ? ";
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID).getPO(WhereClause, new Object[]{obl.getAD_Client_ID(),obl.getPP_Order_BOMLine_ID()}, trxName);
final String whereClause = "TypeMRP=? AND OrderType=? AND PP_Order_BOMLine_ID=? AND AD_Client_ID=?";
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
.setParameters(new Object[]{TYPEMRP_Demand, ORDERTYPE_ManufacturingOrder, obl.get_ID(), obl.getAD_Client_ID()})
.first();
MPPOrder o = obl.getParent();
if(mrp!=null)
if(mrp == null)
{
mrp.setName(o.getDocumentNo());
mrp.setDescription(o.getDescription());
mrp.setQty(obl.getQtyRequiered().subtract(obl.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateFinishSchedule());
mrp.setM_Product_ID(obl.getM_Product_ID());
mrp.setM_Warehouse_ID(obl.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setDocStatus(o.getDocStatus());
mrp.saveEx();
}
else
{
mrp = new MPPMRP(m_ctx , 0,trxName);
mrp = new MPPMRP(ctx, 0, trxName);
mrp.setPP_Order_BOMLine_ID(obl.getPP_Order_BOMLine_ID());
mrp.setName(o.getDocumentNo());
mrp.setDescription(o.getDescription());
mrp.setPP_Order_ID(o.getPP_Order_ID());
mrp.setQty(obl.getQtyRequiered().subtract(obl.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateFinishSchedule());
mrp.setM_Product_ID(obl.getM_Product_ID());
mrp.setM_Warehouse_ID(obl.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setDocStatus(o.getDocStatus());
mrp.setOrderType(MPPMRP.ORDERTYPE_ManufacturingOrder);
mrp.setTypeMRP(MPPMRP.TYPEMRP_Demand);
mrp.saveEx();
}
return;
mrp.setName(o.getDocumentNo());
mrp.setDescription(o.getDescription());
mrp.setQty(obl.getQtyRequiered().subtract(obl.getQtyDelivered()));
mrp.setDatePromised(o.getDatePromised());
mrp.setDateOrdered(o.getDateOrdered());
mrp.setDateStartSchedule(o.getDateStartSchedule());
mrp.setDateFinishSchedule(o.getDateFinishSchedule());
mrp.setM_Product_ID(obl.getM_Product_ID());
mrp.setM_Warehouse_ID(obl.getM_Warehouse_ID());
mrp.setS_Resource_ID(o.getS_Resource_ID());
mrp.setDocStatus(o.getDocStatus());
mrp.saveEx();
}
/**
@ -428,7 +382,7 @@ public class MPPMRP extends X_PP_MRP
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE DD_Order_ID = "+ o.getDD_Order_ID() +" AND AD_Client_ID = " + o.getAD_Client_ID();
DB.executeUpdate(sql ,trxName);
DB.executeUpdateEx(sql, trxName);
return;
}
}
@ -446,7 +400,7 @@ public class MPPMRP extends X_PP_MRP
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE DD_OrderLine_ID = "+ ol.getDD_OrderLine_ID() +" AND AD_Client_ID = " + ol.getAD_Client_ID();
DB.executeUpdate(sql ,trxName);
DB.executeUpdateEx(sql ,trxName);
return;
}
String whereClause = "TypeMRP = 'D' AND OrderType='DOO' AND AD_Client_ID=? AND DD_OrderLine_ID = ?";
@ -529,54 +483,41 @@ public class MPPMRP extends X_PP_MRP
*/
public static void M_RequisitionLine( MRequisitionLine rl , boolean delete)
{
String sql = null;
String trxName = rl.get_TrxName();
Properties m_ctx = rl.getCtx();
Properties ctx = rl.getCtx();
final String whereClause = "M_RequisitionLine_ID=? AND AD_Client_ID=?";
Object[] params = new Object[]{rl.getM_RequisitionLine_ID(), rl.getAD_Client_ID()};
if (delete)
{
sql = "DELETE FROM PP_MRP WHERE M_RequisitionLine_ID = "+ rl.getM_RequisitionLine_ID() +" AND AD_Client_ID = " + rl.getAD_Client_ID();
DB.executeUpdate(sql,trxName); //reorder by hamed
DB.executeUpdateEx("DELETE FROM PP_MRP WHERE "+whereClause, params, trxName);
return;
}
String whereClause = new String("AD_Client_ID=? AND M_RequisitionLine_ID = ? ");
MPPMRP mrp = (MPPMRP)MTable.get(m_ctx, MPPMRP.Table_ID).getPO(whereClause, new Object[]{rl.getAD_Client_ID(),rl.getM_RequisitionLine_ID()}, trxName);
MRequisition r = new MRequisition(m_ctx, rl.getM_Requisition_ID(),trxName);
if(mrp!=null)
{
mrp.setName("MRP");
mrp.setDescription(rl.getDescription());
mrp.setQty(rl.getQty());
mrp.setDatePromised(r.getDateRequired());
mrp.setDateStartSchedule(r.getDateRequired());
mrp.setDateFinishSchedule(r.getDateRequired());
mrp.setDateOrdered(r.getDateRequired());
mrp.setM_Product_ID(rl.getM_Product_ID());
mrp.setM_Warehouse_ID(r.getM_Warehouse_ID());
mrp.setDocStatus(r.getDocStatus());
mrp.saveEx();
}
else
{
mrp = new MPPMRP(m_ctx, 0,trxName);
MPPMRP mrp = new Query(ctx, MPPMRP.Table_Name, whereClause, trxName)
.setParameters(params)
.first();
MRequisition r = rl.getParent();
if (mrp == null)
{
mrp = new MPPMRP(ctx, 0, trxName);
mrp.setM_Requisition_ID(rl.getM_Requisition_ID());
mrp.setM_RequisitionLine_ID(rl.getM_RequisitionLine_ID());
mrp.setName("MRP");
mrp.setDescription(rl.getDescription());
mrp.setQty(rl.getQty());
mrp.setDatePromised(r.getDateRequired());
mrp.setDateOrdered(r.getDateRequired());
mrp.setDateStartSchedule(r.getDateRequired());
mrp.setDateFinishSchedule(r.getDateRequired());
mrp.setM_Product_ID(rl.getM_Product_ID());
mrp.setM_Warehouse_ID(r.getM_Warehouse_ID());
mrp.setDocStatus(r.getDocStatus());
mrp.setOrderType(MPPMRP.ORDERTYPE_MaterialRequisition);
mrp.setTypeMRP(MPPMRP.TYPEMRP_Supply);
mrp.setIsAvailable(true);
mrp.saveEx();
}
return;
mrp.setName("MRP");
mrp.setDescription(rl.getDescription());
mrp.setQty(rl.getQty());
mrp.setDatePromised(r.getDateRequired());
mrp.setDateStartSchedule(r.getDateRequired());
mrp.setDateFinishSchedule(r.getDateRequired());
mrp.setDateOrdered(r.getDateRequired());
mrp.setM_Product_ID(rl.getM_Product_ID());
mrp.setM_Warehouse_ID(r.getM_Warehouse_ID());
mrp.setDocStatus(r.getDocStatus());
mrp.saveEx();
}
/**
@ -586,17 +527,15 @@ public class MPPMRP extends X_PP_MRP
*/
public static void M_Requisition(MRequisition r)
{
String trxName = r.get_TrxName();
String WhereClause = "AD_Client_ID=? AND M_Requisition_ID=?";
MPPMRP mrp = (MPPMRP)MTable.get(r.getCtx(),MRequisition.Table_ID).getPO(WhereClause, new Object[]{r.getAD_Client_ID(), r.getM_Requisition_ID()},trxName);
if(mrp!=null)
final String whereClause = "M_Requisition_ID=? AND AD_Client_ID=?";
MPPMRP mrp = new Query(r.getCtx(), MPPMRP.Table_Name, whereClause, r.get_TrxName())
.setParameters(new Object[]{r.getM_Requisition_ID(), r.getAD_Client_ID()})
.first();
if(mrp != null)
{
mrp.setDocStatus(r.getDocStatus());
mrp.saveEx();
mrp.setDocStatus(r.getDocStatus());
mrp.saveEx();
}
return;
}
@ -609,8 +548,9 @@ public class MPPMRP extends X_PP_MRP
*/
public static BigDecimal getQtyOnHand(int AD_Client_ID, int M_Warehouse_ID ,int M_Product_ID,String trxName)
{
String sql = "SELECT SUM(bomQtyOnHand (M_Product_ID ,"+M_Warehouse_ID+",0)) AS OnHand FROM M_Product WHERE AD_Client_ID=? AND M_Product_ID=?";
BigDecimal QtyOnHand = DB.getSQLValueBD(trxName, sql, new Object[]{AD_Client_ID,M_Product_ID});
final String sql = "SELECT SUM(bomQtyOnHand (M_Product_ID,?,0)) AS OnHand FROM M_Product"
+" WHERE AD_Client_ID=? AND M_Product_ID=?";
BigDecimal QtyOnHand = DB.getSQLValueBD(trxName, sql, new Object[]{M_Warehouse_ID,AD_Client_ID,M_Product_ID});
if (QtyOnHand == null)
QtyOnHand = Env.ZERO;
return QtyOnHand;
@ -624,12 +564,11 @@ public class MPPMRP extends X_PP_MRP
*/
public static int getMaxLowLevel(Properties ctx, String trxName)
{
int LowLevel = 0;
int AD_Client_ID = Env.getAD_Client_ID(ctx);
//
String sql = "SELECT MAX("+MProduct.COLUMNNAME_LowLevel+") FROM M_Product"
+" WHERE AD_Client_ID=? AND "+MProduct.COLUMNNAME_LowLevel+" IS NOT NULL";
LowLevel = DB.getSQLValue(trxName, sql, AD_Client_ID);
final String sql = "SELECT MAX("+MProduct.COLUMNNAME_LowLevel+") FROM M_Product"
+" WHERE AD_Client_ID=? AND "+MProduct.COLUMNNAME_LowLevel+" IS NOT NULL";
int LowLevel = DB.getSQLValue(trxName, sql, AD_Client_ID);
return LowLevel + 1;
}

File diff suppressed because it is too large Load Diff

View File

@ -24,9 +24,13 @@ import java.util.Properties;
*
* @author Victor Perez www.e-evolution.com
* @version $Id: MOrder.java,v 1.40 2004/04/13 04:19:30 vpj-cd Exp $
*
* @author Teo Sarca, www.arhipac.ro
*/
public class MPPOrderBOM extends X_PP_Order_BOM
{
private static final long serialVersionUID = 1L;
/**
* Default Constructor
* @param ctx context
@ -51,6 +55,37 @@ public class MPPOrderBOM extends X_PP_Order_BOM
{
super (ctx, rs, trxName);
} // MOrder
/**
* Peer constructor
* @param bom
* @param PP_Order_ID
* @param trxName
*/
public MPPOrderBOM(MPPProductBOM bom, int PP_Order_ID, String trxName)
{
this(bom.getCtx(), 0, trxName);
//
setBOMType(bom.getBOMType());
setBOMUse(bom.getBOMUse());
setM_ChangeNotice_ID(bom.getM_ChangeNotice_ID());
setHelp(bom.getHelp());
//setCopyFrom(bom.getCopyFrom());
setProcessing(bom.isProcessing());
setHelp(bom.getHelp());
setDescription(bom.getDescription());
setM_AttributeSetInstance_ID(bom.getM_AttributeSetInstance_ID());
setM_Product_ID(bom.getM_Product_ID());
setName(bom.getName());
setRevision(bom.getRevision());
setValidFrom(bom.getValidFrom());
setValidTo(bom.getValidTo());
setValue(bom.getValue());
setDocumentNo(bom.getDocumentNo());
setC_UOM_ID(bom.getC_UOM_ID());
//
setPP_Order_ID(PP_Order_ID);
}
/**
* String Representation

View File

@ -28,6 +28,8 @@ import org.compiere.util.Env;
*
* @author Victor Perez www.e-evolution.com
* @version $Id: MOrderLine.java,v 1.22 2004/03/22 07:15:03 vpj-cd Exp $
*
* @author Teo Sarca, www.arhipac.ro
*/
public class MPPOrderBOMLine extends X_PP_Order_BOMLine
{
@ -63,9 +65,50 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
{
super (ctx, rs,trxName);
} // MOrderLine
/**
* Peer constructor
* @param bomLine
* @param PP_Order_ID
* @param PP_Order_BOM_ID
* @param M_Warehouse_ID
* @param trxName
*/
public MPPOrderBOMLine(MPPProductBOMLine bomLine,
int PP_Order_ID, int PP_Order_BOM_ID, int M_Warehouse_ID,
String trxName)
{
this(bomLine.getCtx(), 0, trxName);
this.setPP_Order_BOM_ID(PP_Order_BOM_ID);
this.setPP_Order_ID(PP_Order_ID);
this.setM_Warehouse_ID(M_Warehouse_ID);
//
this.setM_ChangeNotice_ID(bomLine.getM_ChangeNotice_ID());
this.setDescription(bomLine.getDescription());
this.setHelp(bomLine.getHelp());
this.setAssay(bomLine.getAssay());
this.setQtyBatch(bomLine.getQtyBatch());
this.setQtyBOM(bomLine.getQtyBOM());
this.setIsQtyPercentage(bomLine.isQtyPercentage());
this.setComponentType(bomLine.getComponentType());
this.setC_UOM_ID(bomLine.getC_UOM_ID());
this.setForecast(bomLine.getForecast());
this.setIsCritical(bomLine.isCritical());
this.setIssueMethod(bomLine.getIssueMethod());
this.setLeadTimeOffset(bomLine.getLeadTimeOffset());
this.setM_AttributeSetInstance_ID(bomLine.getM_AttributeSetInstance_ID());
this.setM_Product_ID(bomLine.getM_Product_ID());
this.setScrap(bomLine.getScrap());
this.setValidFrom(bomLine.getValidFrom());
this.setValidTo(bomLine.getValidTo());
this.setBackflushGroup(bomLine.getBackflushGroup());
}
private MPPOrder m_parent = null;
private MProduct m_product = null;
private MProduct m_product = null;
/** Qty used for exploding this BOM Line */
private BigDecimal m_qtyToExplode = null;
@Override
@ -78,26 +121,26 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
int ii = DB.getSQLValue (get_TrxName(), sql, getPP_Order_ID());
setLine (ii);
}
// If Phantom, we need to explode this line (see afterSave):
if(newRecord && COMPONENTTYPE_Phantom.equals(getComponentType()))
{
m_qtyToExplode = getQtyRequiered();
setQtyRequiered(Env.ZERO);
}
return true;
}
/**************************************************************************
* after Save
* @param newRecord new
* @return save
*/
@Override
protected boolean afterSave(boolean newRecord, boolean success) {
if (!newRecord)
return success;
//Qty Ordered to Phantom
BigDecimal QtyOrdered = getQtyRequiered();
protected boolean afterSave(boolean newRecord, boolean success)
{
if (!success)
return false;
log.fine(" Parent Product" + getM_Product_ID() + " getQtyBatch" + getQtyBatch() + " getQtyRequiered" + getQtyRequiered() + " QtyScrap" + getQtyScrap());
//Phantom
if(getComponentType().equals(MPPProductBOMLine.COMPONENTTYPE_Phantom))
//
if(m_qtyToExplode != null)
{
MProduct parent = MProduct.get(getCtx(), getM_Product_ID());
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getCtx(), parent);
@ -110,67 +153,16 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
MPPProductBOMLine[] PP_Product_BOMline = bom.getLines();
for(int i = 0 ; i < PP_Product_BOMline.length ; i++ )
{
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(getCtx(), 0, get_TrxName());
MProduct component = MProduct.get(getCtx(),PP_Product_BOMline[i].getM_Product_ID());
PP_Order_BOMLine.setDescription(PP_Product_BOMline[i].getDescription());
PP_Order_BOMLine.setHelp(PP_Product_BOMline[i].getHelp());
PP_Order_BOMLine.setM_ChangeNotice_ID(PP_Product_BOMline[i].getM_ChangeNotice_ID());
PP_Order_BOMLine.setAssay(PP_Product_BOMline[i].getAssay());
PP_Order_BOMLine.setQtyBatch(PP_Product_BOMline[i].getQtyBatch());
PP_Order_BOMLine.setQtyBOM(PP_Product_BOMline[i].getQtyBOM());
PP_Order_BOMLine.setIsQtyPercentage(PP_Product_BOMline[i].isQtyPercentage());
PP_Order_BOMLine.setComponentType(PP_Product_BOMline[i].getComponentType());
PP_Order_BOMLine.setC_UOM_ID(PP_Product_BOMline[i].getC_UOM_ID());
PP_Order_BOMLine.setForecast(PP_Product_BOMline[i].getForecast());
PP_Order_BOMLine.setIsCritical(PP_Product_BOMline[i].isCritical());
PP_Order_BOMLine.setIssueMethod(PP_Product_BOMline[i].getIssueMethod());
PP_Order_BOMLine.setLeadTimeOffset(PP_Product_BOMline[i].getLeadTimeOffset());
PP_Order_BOMLine.setM_AttributeSetInstance_ID(PP_Product_BOMline[i].getM_AttributeSetInstance_ID());
PP_Order_BOMLine.setPP_Order_BOM_ID(getPP_Order_BOM_ID());
PP_Order_BOMLine.setPP_Order_ID(getPP_Order_ID());
PP_Order_BOMLine.setM_Product_ID(PP_Product_BOMline[i].getM_Product_ID());
PP_Order_BOMLine.setScrap(PP_Product_BOMline[i].getScrap());
PP_Order_BOMLine.setValidFrom(PP_Product_BOMline[i].getValidFrom());
PP_Order_BOMLine.setValidTo(PP_Product_BOMline[i].getValidTo());
PP_Order_BOMLine.setM_Warehouse_ID(getM_Warehouse_ID());
if (PP_Order_BOMLine.isQtyPercentage())
{
BigDecimal qty = PP_Order_BOMLine.getQtyBatch().multiply(QtyOrdered);
log.fine("product:"+component.getName() +" Qty:"+qty + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBatch():" + PP_Order_BOMLine.getQtyBatch());
if(PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Packing))
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP));
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Phantom))
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP));
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Tools))
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
//System.out.println("PP_Order_BOMLinegetQtyRequiered" + PP_Order_BOMLine.getQtyRequiered());
}
else
{
//System.out.println("product: "+product.getName() + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBOM():" + PP_Order_BOMLine.getQtyBOM());
if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Phantom))
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Packing))
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Tools))
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
}
// Set Scrap of Component
BigDecimal Scrap = PP_Order_BOMLine.getScrap();
if (!Scrap.equals(Env.ZERO))
{
Scrap = Scrap.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP);
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyRequiered().divide( Env.ONE.subtract(Scrap) , 8 ,BigDecimal.ROUND_HALF_UP ));
}
System.out.println("Cantidad Requerida" + PP_Order_BOMLine.getQtyRequiered());
PP_Order_BOMLine.saveEx();
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(PP_Product_BOMline[i],
getPP_Order_ID(), getPP_Order_BOM_ID(),
getM_Warehouse_ID(),
get_TrxName());
PP_Order_BOMLine.setQtyOrdered(m_qtyToExplode);
PP_Order_BOMLine.saveEx();
}
}
}// end Phantom
m_qtyToExplode = null;
}
return true;
}
@ -197,4 +189,48 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
return m_parent;
} // getParent
public void setQtyOrdered(BigDecimal QtyOrdered)
{
// Set Qty Required
if (this.isQtyPercentage())
{
BigDecimal qty = this.getQtyBatch().multiply(QtyOrdered);
if (this.getComponentType().equals(COMPONENTTYPE_Component)
|| this.getComponentType().equals(COMPONENTTYPE_Phantom))
{
this.setQtyRequiered(qty.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP));
}
else if (this.getComponentType().equals(COMPONENTTYPE_Packing))
{
this.setQtyRequiered(qty.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP));
}
else if (this.getComponentType().equals(COMPONENTTYPE_Tools))
{
this.setQtyRequiered(this.getQtyBOM());
}
}
else
{
if (this.getComponentType().equals(COMPONENTTYPE_Component)
|| this.getComponentType().equals(COMPONENTTYPE_Phantom))
{
this.setQtyRequiered(this.getQtyBOM().multiply(QtyOrdered));
}
else if (this.getComponentType().equals(COMPONENTTYPE_Packing))
{
this.setQtyRequiered(this.getQtyBOM().multiply(QtyOrdered));
}
else if (this.getComponentType().equals(COMPONENTTYPE_Tools))
{
this.setQtyRequiered(this.getQtyBOM());
}
}
// Set Scrap of Component
BigDecimal Scrap = this.getScrap();
if (Scrap.signum() != 0) {
Scrap = Scrap.divide(Env.ONEHUNDRED, 8, BigDecimal.ROUND_UP);
this.setQtyRequiered(this.getQtyRequiered().divide(Env.ONE.subtract(Scrap), 8, BigDecimal.ROUND_HALF_UP));
}
}
}

View File

@ -16,12 +16,10 @@
package org.eevolution.model;
import java.util.*;
import java.sql.*;
import java.math.*;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.util.*;
import org.compiere.model.*;
import org.compiere.model.MCost;
/**
* Order Model.
@ -31,9 +29,13 @@ import org.compiere.model.*;
*
* @author Victor Perez www.e-evolution.com
* @version $Id: MOrder.java,v 1.40 2004/04/13 04:19:30 vpj-cd Exp $
*
* @author Teo Sarca, www.arhipac.ro
*/
public class MPPOrderCost extends X_PP_Order_Cost
{
private static final long serialVersionUID = 1L;
/**
* Default Constructor
* @param ctx context
@ -41,63 +43,36 @@ public class MPPOrderCost extends X_PP_Order_Cost
*/
public MPPOrderCost(Properties ctx, int PP_Order_Cost_ID,String trxName)
{
super (ctx, PP_Order_Cost_ID,trxName);
// New
if ( PP_Order_Cost_ID == 0)
{
}
super (ctx, PP_Order_Cost_ID, trxName);
} // MOrder
/**
* Load Constructor
* @param ctx context
* @param rs result set record
/**
* Peer constructor
* @param cost
* @param PP_Order_ID
*/
public MPPOrderCost(Properties ctx, MCost m_cost, int PP_Order_ID, String trxName)
public MPPOrderCost(MCost cost, int PP_Order_ID, String trxName)
{
super (ctx, 0,trxName);
setC_AcctSchema_ID(m_cost.getC_AcctSchema_ID());
setCumulatedAmt(m_cost.getCumulatedAmt());
setCumulatedQty(m_cost.getCumulatedQty());
setCurrentCostPrice(m_cost.getCurrentCostPrice());
setCurrentCostPriceLL(m_cost.getCurrentCostPriceLL());
setM_Product_ID(m_cost.getM_Product_ID());
setM_CostElement_ID(m_cost.getM_CostElement_ID());
setM_AttributeSetInstance_ID(m_cost.getM_AttributeSetInstance_ID());
save(get_TrxName());
} // MOrder
this(cost.getCtx(), 0, trxName);
setPP_Order_ID(PP_Order_ID);
setC_AcctSchema_ID(cost.getC_AcctSchema_ID());
setCumulatedAmt(cost.getCumulatedAmt());
setCumulatedQty(cost.getCumulatedQty());
setCurrentCostPriceLL(cost.getCurrentCostPriceLL());
setCurrentCostPrice(cost.getCurrentCostPrice());
setM_Product_ID(cost.getM_Product_ID());
setM_AttributeSetInstance_ID(cost.getM_AttributeSetInstance_ID());
setM_CostElement_ID(cost.getM_CostElement_ID());
}
/**
* Load Constructor
* @param ctx context
* @param rs result set record
*/
public MPPOrderCost(Properties ctx, ResultSet rs,String trxName)
public MPPOrderCost(Properties ctx, ResultSet rs, String trxName)
{
super (ctx, rs,"PP_Order_Cost");
super (ctx, rs, trxName);
} // MOrder
/**
* Overwrite Client/Org if required
* @param AD_Client_ID client
* @param AD_Org_ID org
*/
public void setClientOrg (int AD_Client_ID, int AD_Org_ID)
{
super.setClientOrg(AD_Client_ID, AD_Org_ID);
} // setClientOrg
// save
} // MOrder
}

View File

@ -17,6 +17,7 @@
package org.eevolution.model;
import java.awt.Point;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
@ -27,18 +28,21 @@ import org.compiere.model.Query;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.wf.MWFNode;
/**
* Workflow Node Model
* PP Order Workflow Node Model
*
* @author Jorg Janke
* @version $Id: MWFNode.java,v 1.2 2006/07/30 00:51:05 jjanke Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* <li>BF [ 2041799 ] Can't delete PP_Order_Node (Not found=PP_Order_Node_Trl)
* @author Teo Sarca, http://www.arhipac.ro
*/
public class MPPOrderNode extends X_PP_Order_Node
{
private static final long serialVersionUID = 1L;
/**
* Get WF Node from Cache
* @param ctx context
@ -108,6 +112,62 @@ public class MPPOrderNode extends X_PP_Order_Node
m_durationBaseMS = wf.getDurationBaseSec() * 1000;
} // MPPOrderNode
/**
* Peer constructor
* @param wfNode
* @param PP_Order_Workflow
* @param qtyOrdered
* @param trxName
*/
public MPPOrderNode (MWFNode wfNode, MPPOrderWorkflow PP_Order_Workflow,
BigDecimal qtyOrdered,
String trxName)
{
this(wfNode.getCtx(), 0, trxName);
setPP_Order_ID(PP_Order_Workflow.getPP_Order_ID());
setPP_Order_Workflow_ID(PP_Order_Workflow.getPP_Order_Workflow_ID());
//
setAction(wfNode.getAction());
setAD_WF_Node_ID(wfNode.getAD_WF_Node_ID());
setAD_WF_Responsible_ID(wfNode.getAD_WF_Responsible_ID());
setAD_Workflow_ID(wfNode.getAD_Workflow_ID());
setCost(wfNode.getCost());
setDuration(wfNode.getDuration());
setEntityType(wfNode.getEntityType());
setIsCentrallyMaintained(wfNode.isCentrallyMaintained());
setJoinElement(wfNode.getJoinElement()); // X
setLimit(wfNode.getLimit());
setName(wfNode.getName());
setPriority(wfNode.getPriority());
setSplitElement(wfNode.getSplitElement()); // X
setSubflowExecution(wfNode.getSubflowExecution());
setValue(wfNode.getValue());
setS_Resource_ID(wfNode.getS_Resource_ID());
setSetupTime(wfNode.getSetupTime());
setSetupTimeRequiered(wfNode.getSetupTime());
BigDecimal time = new BigDecimal(wfNode.getDuration()).multiply(qtyOrdered);
setDurationRequiered(time.intValue());
setMovingTime(wfNode.getMovingTime());
setWaitingTime(wfNode.getWaitingTime());
setWorkingTime(wfNode.getWorkingTime());
setQueuingTime(wfNode.getQueuingTime());
setXPosition(wfNode.getXPosition());
setYPosition(wfNode.getYPosition());
setDocAction(wfNode.getDocAction());
setAD_Column_ID(wfNode.getAD_Column_ID());
setAD_Form_ID(wfNode.getAD_Form_ID());
setAD_Image_ID(wfNode.getAD_Image_ID());
setAD_Window_ID(wfNode.getAD_Window_ID());
setAD_Process_ID(wfNode.getAD_Process_ID());
setAttributeName(wfNode.getAttributeName());
setAttributeValue(wfNode.getAttributeValue());
setC_BPartner_ID(wfNode.getC_BPartner_ID());
setStartMode(wfNode.getStartMode());
setFinishMode(wfNode.getFinishMode());
setValidFrom(wfNode.getValidFrom());
setValidTo(wfNode.getValidTo());
}
/**
* Load Constructor - save to cache
* @param ctx context

View File

@ -16,22 +16,24 @@
*****************************************************************************/
package org.eevolution.model;
import java.sql.*;
import java.util.*;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.*;
import org.compiere.process.*;
import java.util.logging.*;
import org.compiere.util.*;
import org.compiere.util.DB;
import org.compiere.wf.MWFNodeNext;
/**
* Workflow Node Next - Transition
* PP Order Workflow Node Next - Transition
*
* @author Jorg Janke
* @version $Id: MPPOrdeNodeNext.java,v 1.3 2006/10/06 00:42:24 jjanke Exp $
*
* @author Teo Sarca, http://www.arhipac.ro
*/
public class MPPOrderNodeNext extends X_PP_Order_NodeNext
{
private static final long serialVersionUID = 1L;
/**
* Standard Costructor
* @param ctx context
@ -75,8 +77,28 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
setPP_Order_Next_ID(PP_Order_Next_ID);
} // MPPOrderNodeNext
/** Transition Conditions */
//private MWFNextCondition[] m_conditions = null;
/**
* Peer constructor
* @param wfNodeNext
* @param PP_Order_Node
* @param trxName
*/
public MPPOrderNodeNext (MWFNodeNext wfNodeNext, MPPOrderNode PP_Order_Node, String trxName)
{
this(wfNodeNext.getCtx(), 0, trxName);
setPP_Order_Node_ID(PP_Order_Node.get_ID());
setPP_Order_ID(PP_Order_Node.getPP_Order_ID());
setPP_Order_Next_ID(0);
//
setAD_WF_Node_ID(wfNodeNext.getAD_WF_Node_ID());
setAD_WF_Next_ID(wfNodeNext.getAD_WF_Next_ID());
setDescription(wfNodeNext.getDescription());
setEntityType(wfNodeNext.getEntityType());
setIsStdUserWorkflow(wfNodeNext.isStdUserWorkflow());
setSeqNo(wfNodeNext.getSeqNo());
setTransitionCode(wfNodeNext.getTransitionCode());
}
/** From (Split Eleemnt) is AND */
public Boolean m_fromSplitAnd = null;
/** To (Join Element) is AND */
@ -109,11 +131,6 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
return sb.toString ();
} // toString
/**
* Split Element is AND
* @return Returns the from Split And.
@ -160,4 +177,12 @@ public class MPPOrderNodeNext extends X_PP_Order_NodeNext
m_toJoinAnd = new Boolean(toJoinAnd);
} // setToJoinAnd
public void setPP_Order_Next_ID()
{
final String sql = "SELECT PP_Order_Node_ID FROM PP_Order_Node "
+ " WHERE PP_Order_ID=? AND AD_WF_Node_ID=? AND AD_Client_ID=?";
int id = DB.getSQLValue(get_TrxName(), sql, getPP_Order_ID(), getAD_WF_Next_ID(), getAD_Client_ID());
if (id > 0)
setPP_Order_Next_ID(id);
}
} // MPPOrderNodeNext

View File

@ -26,16 +26,20 @@ import java.util.logging.Level;
import org.compiere.model.MClient;
import org.compiere.model.Query;
import org.compiere.util.CCache;
import org.compiere.util.Env;
import org.compiere.wf.MWorkflow;
/**
* WorkFlow Model
* PP Order WorkFlow Model
*
* @author Jorg Janke
* @version $Id: MPPOrderWorkflow.java,v 1.4 2006/07/30 00:51:05 jjanke Exp $
*
* @author Teo Sarca, http://www.arhipac.ro
*/
public class MPPOrderWorkflow extends X_PP_Order_Workflow
{
private static final long serialVersionUID = 1L;
/**
* Get Workflow from Cache
* @param ctx context
@ -97,6 +101,50 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
super(ctx, rs, trxName);
loadNodes();
} // Workflow
/**
* Peer constructor
* @param workflow
* @param PP_Order_ID
* @param trxName
*/
public MPPOrderWorkflow (MWorkflow workflow, int PP_Order_ID, String trxName)
{
this(workflow.getCtx(), 0, trxName);
setPP_Order_ID(PP_Order_ID);
//
setValue(workflow.getValue());
setWorkflowType(workflow.getWorkflowType());
setQtyBatchSize(workflow.getQtyBatchSize());
setName(workflow.getName());
setAccessLevel(workflow.getAccessLevel());
setAuthor(workflow.getAuthor());
setDurationUnit(workflow.getDurationUnit());
setDuration(workflow.getDuration());
setEntityType(workflow.getEntityType());
setIsDefault(workflow.isDefault());
setPublishStatus(workflow.getPublishStatus());
setVersion(workflow.getVersion());
setCost(workflow.getCost());
setWaitingTime(workflow.getWaitingTime());
setWorkingTime(workflow.getWorkingTime());
setAD_WF_Responsible_ID(workflow.getAD_WF_Responsible_ID());
setAD_Workflow_ID(workflow.getAD_Workflow_ID());
setLimit(workflow.getLimit());
setPriority(workflow.getPriority());
setValidateWorkflow(workflow.getValidateWorkflow());
setS_Resource_ID(workflow.getS_Resource_ID());
setQueuingTime(workflow.getQueuingTime());
setSetupTime(workflow.getSetupTime());
setMovingTime(workflow.getMovingTime());
setProcessType(workflow.getProcessType());
setAD_Table_ID(workflow.getAD_Table_ID());
setAD_WF_Node_ID(workflow.getAD_WF_Node_ID());
setAD_WorkflowProcessor_ID(workflow.getAD_WorkflowProcessor_ID());
setDescription(workflow.getDescription());
setValidFrom(workflow.getValidFrom());
setValidTo(workflow.getValidTo());
}
/** WF Nodes */
private List<MPPOrderNode> m_nodes = null;
@ -104,17 +152,16 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
/**
* Load All Nodes
*/
private void loadNodes()
protected void loadNodes()
{
final String whereClause = MPPOrderNode.COLUMNNAME_PP_Order_Workflow_ID+"=? AND IsActive=?";
m_nodes = new Query(getCtx(), MPPOrderNode.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{get_ID(), "Y"})
.list();
.setParameters(new Object[]{get_ID(), "Y"})
.list();
log.fine("#" + m_nodes.size());
} // loadNodes
/**************************************************************************
/**
* Get Number of Nodes
* @return number of nodes
*/
@ -401,23 +448,7 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
return sb.toString ();
} // toString
/**************************************************************************
* Before Save
* @param newRecord new
* @return true
*/
protected boolean beforeSave (boolean newRecord)
{
//validate();
return true;
} // beforeSave
/**
* After Save.
* @param newRecord new record
* @param success success
* @return true if save complete (if not overwritten true)
*/
@Override
protected boolean afterSave (boolean newRecord, boolean success)
{
log.fine("Success=" + success);
@ -432,9 +463,6 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
return success;
} // afterSave
/**
* Get Duration Base in Seconds
* @return duration unit in seconds
@ -480,95 +508,4 @@ public class MPPOrderWorkflow extends X_PP_Order_Workflow
return Calendar.YEAR;
return Calendar.MINUTE;
} // getDurationCalendarField
/**************************************************************************
* main
* @param args
*/
public static void main (String[] args)
{
org.compiere.Adempiere.startup(true);
// Create Standard Document Process
MPPOrderWorkflow wf = new MPPOrderWorkflow(Env.getCtx(), 0, null);
wf.setValue ("Process_xx");
wf.setName (wf.getValue());
wf.setDescription("(Standard " + wf.getValue());
wf.setEntityType (ENTITYTYPE_Dictionary);
wf.save();
//
MPPOrderNode node10 = new MPPOrderNode (wf, "10", "(Start)");
node10.setDescription("(Standard Node)");
node10.setEntityType (ENTITYTYPE_Dictionary);
node10.setAction(MPPOrderNode.ACTION_WaitSleep);
//node10.setWaitTime(0);
node10.setPosition(5, 5);
node10.save();
wf.setPP_Order_Node_ID(node10.getPP_Order_Node_ID());
wf.save();
MPPOrderNode node20 = new MPPOrderNode (wf, "20", "(DocAuto)");
node20.setDescription("(Standard Node)");
node20.setEntityType (ENTITYTYPE_Dictionary);
node20.setAction(MPPOrderNode.ACTION_DocumentAction);
node20.setDocAction(MPPOrderNode.DOCACTION_None);
node20.setPosition(5, 120);
node20.save();
MPPOrderNodeNext tr10_20 = new MPPOrderNodeNext(node10, node20.getPP_Order_Node_ID());
tr10_20.setEntityType (ENTITYTYPE_Dictionary);
tr10_20.setDescription("(Standard Transition)");
tr10_20.setSeqNo(100);
tr10_20.save();
MPPOrderNode node100 = new MPPOrderNode (wf, "100", "(DocPrepare)");
node100.setDescription("(Standard Node)");
node100.setEntityType (ENTITYTYPE_Dictionary);
node100.setAction(MPPOrderNode.ACTION_DocumentAction);
node100.setDocAction(MPPOrderNode.DOCACTION_Prepare);
node100.setPosition(170, 5);
node100.save();
MPPOrderNodeNext tr10_100 = new MPPOrderNodeNext(node10, node100.getPP_Order_Node_ID());
tr10_100.setEntityType (ENTITYTYPE_Dictionary);
tr10_100.setDescription("(Standard Approval)");
tr10_100.setIsStdUserWorkflow(true);
tr10_100.setSeqNo(10);
tr10_100.save();
MPPOrderNode node200 = new MPPOrderNode (wf, "200", "(DocComplete)");
node200.setDescription("(Standard Node)");
node200.setEntityType (ENTITYTYPE_Dictionary);
node200.setAction(MPPOrderNode.ACTION_DocumentAction);
node200.setDocAction(MPPOrderNode.DOCACTION_Complete);
node200.setPosition(170, 120);
node200.save();
MPPOrderNodeNext tr100_200 = new MPPOrderNodeNext(node100, node200.getPP_Order_Node_ID());
tr100_200.setEntityType (ENTITYTYPE_Dictionary);
tr100_200.setDescription("(Standard Transition)");
tr100_200.setSeqNo(100);
tr100_200.save();
/**
Env.setContext(Env.getCtx(), "#AD_Client_ID ", "11");
Env.setContext(Env.getCtx(), "#AD_Org_ID ", "11");
Env.setContext(Env.getCtx(), "#AD_User_ID ", "100");
//
int PP_Order_Workflow_ID = 115; // Requisition WF
int M_Requsition_ID = 100;
MRequisition req = new MRequisition (Env.getCtx(), M_Requsition_ID);
req.setDocStatus(DocAction.DOCSTATUS_Drafted);
req.save();
Log.setTraceLevel(8);
System.out.println("---------------------------------------------------");
MPPOrderWorkflow wf = MPPOrderWorkflow.get (Env.getCtx(), PP_Order_Workflow_ID);
**/
// wf.start(M_Requsition_ID);
} // main
} // MPPOrderWorkflow_ID

View File

@ -37,7 +37,7 @@ import org.compiere.util.Env;
* @author Victor Perez www.e-evolution.com
* @version $Id: MOrder.java,v 1.40 2004/04/13 04:19:30 vpj-cd Exp $
*
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
* @author Teo Sarca, http://www.arhipac.ro
*/
public class MPPProductBOM extends X_PP_Product_BOM
{
@ -46,7 +46,7 @@ public class MPPProductBOM extends X_PP_Product_BOM
/** Static Logger */
private static CLogger log = CLogger.getCLogger(MPPProductBOM.class);
/** Cache */
private static CCache<Integer,MPPProductBOM> s_cache = new CCache<Integer,MPPProductBOM>(Table_Name, 40, 5); // 5 minutes
private static CCache<Integer,MPPProductBOM> s_cache = new CCache<Integer,MPPProductBOM>(Table_Name, 40, 5);
/**
* Load/Get Product BOM by ID (cached)
@ -78,49 +78,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
*/
public MPPProductBOM(Properties ctx, int PP_Product_BOM_ID,String trxName)
{
super (ctx, PP_Product_BOM_ID,trxName);
// New
if ( PP_Product_BOM_ID == 0)
{
//setDocStatus(DOCSTATUS_Drafted);
//setDocAction (DOCACTION_Prepare);
//
//setDeliveryRule (DELIVERYRULE_Availability);
//setFreightCostRule (FREIGHTCOSTRULE_FreightIncluded);
//setInvoiceRule (INVOICERULE_Immediate);
//setPaymentRule(PAYMENTRULE_OnCredit);
//setPriorityRule (PRIORITYRULE_Medium);
//setDeliveryViaRule (DELIVERYVIARULE_Pickup);
//
//setIsDiscountPrinted (false);
//setIsSelected (false);
//setIsTaxIncluded (false);
//setIsSOTrx (true);
///setIsDropShip(false);
//setSendEMail (false);
//
//setIsApproved(false);
//setIsPrinted(false);
//setIsCreditApproved(false);
//setIsDelivered(false);
//setIsInvoiced(false);
//setIsTransferred(false);
//setIsSelfService(false);
//
//setProcessed(false);
//setProcessing(false);
//setPosted(false);
//setDateAcct (new Timestamp(System.currentTimeMillis()));
//setDatePromised (new Timestamp(System.currentTimeMillis()));
//setDateOrdered (new Timestamp(System.currentTimeMillis()));
//setFreightAmt (Env.ZERO);
//setChargeAmt (Env.ZERO);
//setTotalLines (Env.ZERO);
//setGrandTotal (Env.ZERO);
}
} // MOrder
super (ctx, PP_Product_BOM_ID, trxName);
} // MPPProductBOM
/**
@ -133,21 +92,6 @@ public class MPPProductBOM extends X_PP_Product_BOM
super (ctx, rs,trxName);
} // MOrder
/**
* Overwrite Client/Org if required
* @param AD_Client_ID client
* @param AD_Org_ID org
*/
public void setClientOrg (int AD_Client_ID, int AD_Org_ID)
{
super.setClientOrg(AD_Client_ID, AD_Org_ID);
} // setClientOrg
/**
* Copy Lines From other BOM
* @param order order
@ -164,15 +108,6 @@ public class MPPProductBOM extends X_PP_Product_BOM
MPPProductBOMLine line = new MPPProductBOMLine (this);
PO.copyValues(fromLines[i], line, getAD_Client_ID(), getAD_Org_ID());
line.setPP_Product_BOM_ID(getPP_Product_BOM_ID());
//line.setOrder(bom);
line.setPP_Product_BOMLine_ID(0);
//
//line.setQtyDelivered(Env.ZERO);
//line.setQtyInvoiced(Env.ZERO);
//line.setDateDelivered(null);
//line.setDateInvoiced(null);
//line.setRef_OrderLine_ID(0);
//line.setTax();
if (line.save(get_TrxName()))
count++;
}
@ -187,7 +122,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
* BUG #104
* @param lines
*/
private void setLines(List<MPPProductBOMLine> lines) {
private void setLines(List<MPPProductBOMLine> lines)
{
this.lines = lines;
}
@ -272,28 +208,10 @@ public class MPPProductBOM extends X_PP_Product_BOM
public static MPPProductBOM get(MProduct product, int ad_org_id, Timestamp valid, String trxName)
{
MPPProductBOM bom = get(product, ad_org_id, trxName);
//
// Validate date
if (bom != null)
if (bom != null && bom.isValidFromTo(valid))
{
boolean ValidFromBOM = true;
boolean ValidToBOM = true;
if (bom.getValidFrom() != null)
{
ValidFromBOM = valid.compareTo(bom.getValidFrom()) >= 0 ? true : false;
}
if (bom.getValidTo() != null )
{
ValidToBOM = valid.compareTo(bom.getValidTo()) <= 0 ? true : false;
}
if(ValidFromBOM && ValidToBOM)
{
return bom;
}
else
return null;
return bom;
}
return null;
} // getBOM
@ -308,20 +226,9 @@ public class MPPProductBOM extends X_PP_Product_BOM
MPPProductBOMLine[] bomlines = getLines(); // All BOM Lines
List<MPPProductBOMLine> list = new ArrayList<MPPProductBOMLine>(); // Selected BOM Lines Only
for (MPPProductBOMLine bl : bomlines) {
boolean ValidFromBOMLine = true;
boolean ValidToBOMLine = true;
if (bl.getValidFrom() != null)
{
ValidFromBOMLine = valid.compareTo(bl.getValidFrom()) >= 0 ? true : false;
}
if (bl.getValidTo() != null )
{
ValidToBOMLine = valid.compareTo(bl.getValidTo()) <= 0 ? true : false;
}
if(ValidFromBOMLine && ValidToBOMLine)
{
if (bl.isValidFromTo(valid)) {
list.add(bl);
}
}
}
//
return list.toArray(new MPPProductBOMLine[list.size()]);
@ -333,12 +240,14 @@ public class MPPProductBOM extends X_PP_Product_BOM
*/
public MPPProductBOMLine[] getLines()
{
// TODO: add caching support
String whereClause = MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID+"=?";
List<MPPProductBOMLine> list = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause, get_TrxName())
if (this.lines == null)
{
final String whereClause = MPPProductBOMLine.COLUMNNAME_PP_Product_BOM_ID+"=?";
this.lines = new Query(getCtx(), MPPProductBOMLine.Table_Name, whereClause, get_TrxName())
.setParameters(new Object[]{getPP_Product_BOM_ID()})
.list();
return list.toArray(new MPPProductBOMLine[list.size()]);
}
return this.lines.toArray(new MPPProductBOMLine[this.lines.size()]);
} // getLines
/**
@ -350,8 +259,8 @@ public class MPPProductBOM extends X_PP_Product_BOM
{
int AD_Client_ID = Env.getAD_Client_ID(ctx);
String sql = "SELECT pb.PP_Product_BOM_ID FROM PP_Product_BOM pb"
+" WHERE pb.Value = ? AND pb.AD_Client_ID = ?";
return DB.getSQLValue(null, sql, product.getValue(), AD_Client_ID);
+" WHERE pb.Value = ? AND pb.M_Product_ID=? AND pb.AD_Client_ID = ?";
return DB.getSQLValue(null, sql, product.getValue(), product.get_ID(), AD_Client_ID);
}
/**
@ -364,7 +273,17 @@ public class MPPProductBOM extends X_PP_Product_BOM
return new Query(product.getCtx(), Table_Name, "M_Product_ID=? AND Value=?", trxName)
.setParameters(new Object[]{product.getM_Product_ID(), product.getValue()})
.first();
}
public boolean isValidFromTo(Timestamp date)
{
Timestamp validFrom = getValidFrom();
Timestamp validTo = getValidTo();
if (validFrom != null && date.before(validFrom))
return false;
if (validTo != null && date.after(validTo))
return false;
return true;
}
} // MPPProductBOM

View File

@ -18,6 +18,7 @@ package org.eevolution.model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Hashtable;
import java.util.Properties;
@ -115,6 +116,18 @@ public class MPPProductBOMLine extends X_PP_Product_BOMLine
}
return true;
}
public boolean isValidFromTo(Timestamp date)
{
Timestamp validFrom = getValidFrom();
Timestamp validTo = getValidTo();
if (validFrom != null && date.before(validFrom))
return false;
if (validTo != null && date.after(validTo))
return false;
return true;
}
}
class ProductLowLevelCalculator {

View File

@ -18,92 +18,73 @@ package org.eevolution.tools;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.*;
/**
* @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany
* @version 1.0, October 14th 2005
*/
* @author Gunther Hoppe, tranSIT GmbH Ilmenau/Germany
* @version 1.0, October 14th 2005
*/
public class DateTimeUtil {
public static long getTimeDifference(Timestamp time1 , Timestamp time2) {
/**
* @param time1
* @param time2
* @return time difference (time2 - time1) in millis
*/
public static long getTimeDifference(Timestamp time1 , Timestamp time2)
{
return time2.getTime() - time1.getTime();
}
GregorianCalendar gc1 = new GregorianCalendar();
gc1.setTimeInMillis(time1.getTime());
GregorianCalendar gc2 = new GregorianCalendar();
gc2.setTimeInMillis(time2.getTime());
long l1 = gc1.getTime().getTime();
long l2 = gc2.getTime().getTime();
return l2 - l1;
}
public static Timestamp[] getDayBorders(Timestamp dateTime, Timestamp timeSlotStart, Timestamp timeSlotFinish) {
return new Timestamp[] {
getDayBorder(dateTime, timeSlotStart, false),
getDayBorder(dateTime, timeSlotFinish, true),
};
}
public static Timestamp getDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end) {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(dateTime.getTime());
dateTime.setNanos(0);
if(timeSlot != null) {
timeSlot.setNanos(0);
GregorianCalendar gcTS = new GregorianCalendar();
gcTS.setTimeInMillis(timeSlot.getTime());
gc.set(Calendar.HOUR_OF_DAY, gcTS.get(Calendar.HOUR_OF_DAY));
gc.set(Calendar.MINUTE, gcTS.get(Calendar.MINUTE));
gc.set(Calendar.SECOND, gcTS.get(Calendar.SECOND));
gc.set(Calendar.MILLISECOND, gcTS.get(Calendar.MILLISECOND));
}
else if(end) {
gc.set(Calendar.HOUR_OF_DAY, 23);
gc.set(Calendar.MINUTE, 59);
gc.set(Calendar.SECOND, 59);
gc.set(Calendar.MILLISECOND, 999);
}
else {
gc.set(Calendar.MILLISECOND, 0);
gc.set(Calendar.SECOND, 0);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.HOUR_OF_DAY, 0);
}
return new Timestamp(gc.getTimeInMillis());
}
public static Timestamp[] getDayBorders(Timestamp dateTime) {
return getDayBorders(dateTime, null, null);
}
/*public static Timestamp incrementDay(Timestamp dateTime) {
/**
* Returns the day border by combining the date part from dateTime and time part form timeSlot.
* If timeSlot is null, then first milli of the day will be used (if end == false) or last milli of the day (if end == true).
*
* @param dateTime
* @param timeSlot
* @param end
* @return
*/
public static Timestamp getDayBorder(Timestamp dateTime, Timestamp timeSlot, boolean end)
{
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(dateTime.getTime());
gc.add(Calendar.DAY_OF_MONTH, 1);
dateTime.setNanos(0);
if(timeSlot != null) {
timeSlot.setNanos(0);
GregorianCalendar gcTS = new GregorianCalendar();
gcTS.setTimeInMillis(timeSlot.getTime());
gc.set(Calendar.HOUR_OF_DAY, gcTS.get(Calendar.HOUR_OF_DAY));
gc.set(Calendar.MINUTE, gcTS.get(Calendar.MINUTE));
gc.set(Calendar.SECOND, gcTS.get(Calendar.SECOND));
gc.set(Calendar.MILLISECOND, gcTS.get(Calendar.MILLISECOND));
}
else if(end) {
gc.set(Calendar.HOUR_OF_DAY, 23);
gc.set(Calendar.MINUTE, 59);
gc.set(Calendar.SECOND, 59);
gc.set(Calendar.MILLISECOND, 999);
}
else {
gc.set(Calendar.MILLISECOND, 0);
gc.set(Calendar.SECOND, 0);
gc.set(Calendar.MINUTE, 0);
gc.set(Calendar.HOUR_OF_DAY, 0);
}
return new Timestamp(gc.getTimeInMillis());
}
public static Timestamp decrementDay(Timestamp dateTime) {
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(dateTime.getTime());
gc.add(Calendar.DAY_OF_MONTH, -1);
return new Timestamp(gc.getTimeInMillis());
}*/
}