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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations