First version of the methods to compute the start date of requirements created by the MRP for products with WIP in their BOM. More tests still need to be done.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@530461 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -38,6 +38,8 @@ import org.ofbiz.entity.util.EntityUtil;
|
||||
import org.ofbiz.service.GenericServiceException;
|
||||
import org.ofbiz.service.LocalDispatcher;
|
||||
|
||||
import org.ofbiz.manufacturing.mrp.ProposedOrder;
|
||||
|
||||
/** An ItemCoinfigurationNode represents a component in a bill of materials.
|
||||
*/
|
||||
|
||||
@@ -563,6 +565,26 @@ public class BOMNode {
|
||||
return productionRunId;
|
||||
}
|
||||
|
||||
public Timestamp getStartDate(String facilityId, Timestamp requiredBydate) {
|
||||
Timestamp minStartDate = requiredBydate;
|
||||
if ("WIP".equals(getProduct().getString("productTypeId"))) {
|
||||
ProposedOrder proposedOrder = new ProposedOrder(getProduct(), facilityId, facilityId, true, requiredBydate, getQuantity());
|
||||
proposedOrder.calculateStartDate(0, null, delegator, dispatcher, userLogin);
|
||||
Timestamp startDate = proposedOrder.getRequirementStartDate();
|
||||
minStartDate = startDate;
|
||||
for (int i = 0; i < childrenNodes.size(); i++) {
|
||||
BOMNode oneChildNode = (BOMNode)childrenNodes.get(i);
|
||||
if (oneChildNode != null) {
|
||||
Timestamp childStartDate = oneChildNode.getStartDate(facilityId, startDate);
|
||||
if (childStartDate.compareTo(minStartDate) < 0) {
|
||||
minStartDate = childStartDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return minStartDate;
|
||||
}
|
||||
|
||||
public boolean isWarehouseManaged() {
|
||||
boolean isWarehouseManaged = false;
|
||||
try {
|
||||
|
||||
+1
-7
@@ -1834,13 +1834,7 @@ public class ProductionRunServices {
|
||||
}
|
||||
String productionRunId = (String)resultService.get("productionRunId");
|
||||
result.put("productionRunId", productionRunId);
|
||||
|
||||
// try {
|
||||
// requirement.remove();
|
||||
// } catch (GenericEntityException e) {
|
||||
// return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingRequirementNotDeleted", locale));
|
||||
// }
|
||||
|
||||
|
||||
result.put(ModelService.SUCCESS_MESSAGE, UtilProperties.getMessage(resource, "ManufacturingProductionRunCreated",UtilMisc.toMap("productionRunId", productionRunId), locale));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -600,9 +600,7 @@ public class MrpServices {
|
||||
Debug.logError("Error : parameters = "+parameters,module);
|
||||
return ServiceUtil.returnError("Problem, can not initialise the table InventoryEventPlanned, for more detail look at the log");
|
||||
}
|
||||
// TODO : modifier le jeux d'essai de TGR pour mettre 0 au niveau pf
|
||||
long bomLevel = 0;
|
||||
// iteration for the bomLevel for which there are some events
|
||||
do {
|
||||
//get the products from the InventoryEventPlanned table for the current billOfMaterialLevel (ie. BOM)
|
||||
parameters = UtilMisc.toMap("billOfMaterialLevel", new Long(bomLevel), "userLogin", userLogin);
|
||||
@@ -677,7 +675,7 @@ public class MrpServices {
|
||||
eventDate = inventoryEventForMRP.getTimestamp("eventDate");
|
||||
// to be just before the requirement
|
||||
eventDate.setTime(eventDate.getTime()-1);
|
||||
ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock, now);
|
||||
ProposedOrder proposedOrder = new ProposedOrder(product, facilityId, manufacturingFacilityId, isBuilt, eventDate, qtyToStock);
|
||||
proposedOrder.setMrpName(mrpName);
|
||||
// calculate the ProposedOrder quantity and update the quantity object property.
|
||||
proposedOrder.calculateQuantityToSupply(reorderQuantity, minimumStock, iteratorListInventoryEventForMRP);
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.ofbiz.entity.GenericDelegator;
|
||||
import org.ofbiz.entity.GenericEntityException;
|
||||
import org.ofbiz.entity.GenericValue;
|
||||
import org.ofbiz.entity.util.EntityUtil;
|
||||
import org.ofbiz.manufacturing.bom.BOMTree;
|
||||
import org.ofbiz.manufacturing.jobshopmgt.ProductionRun;
|
||||
import org.ofbiz.manufacturing.techdata.TechDataServices;
|
||||
import org.ofbiz.service.DispatchContext;
|
||||
@@ -57,11 +58,10 @@ public class ProposedOrder {
|
||||
protected String mrpName;
|
||||
protected Timestamp requiredByDate;
|
||||
protected Timestamp requirementStartDate;
|
||||
protected Timestamp now;
|
||||
protected double quantity;
|
||||
|
||||
|
||||
public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, double quantity, Timestamp now) {
|
||||
public ProposedOrder(GenericValue product, String facilityId, String manufacturingFacilityId, boolean isBuilt, Timestamp requiredByDate, double quantity) {
|
||||
this.product = product;
|
||||
this.productId = product.getString("productId");
|
||||
this.facilityId = facilityId;
|
||||
@@ -227,7 +227,14 @@ public class ProposedOrder {
|
||||
LocalDispatcher dispatcher = ctx.getDispatcher();
|
||||
GenericDelegator delegator = ctx.getDelegator();
|
||||
Map parameters = UtilMisc.toMap("userLogin", userLogin);
|
||||
|
||||
if (isBuilt) {
|
||||
try {
|
||||
BOMTree tree = new BOMTree(productId, "MANUF_COMPONENT", null, BOMTree.EXPLOSION_MANUFACTURING, delegator, dispatcher, userLogin);
|
||||
requirementStartDate = tree.getRoot().getStartDate(manufacturingFacilityId, requiredByDate);
|
||||
} catch (Exception e) {
|
||||
Debug.logError(e,"Error : computing the requirement start date. " + e.getMessage(), module);
|
||||
}
|
||||
}
|
||||
parameters.put("productId", productId);
|
||||
parameters.put("statusId", "REQ_PROPOSED");
|
||||
parameters.put("facilityId", (isBuilt? manufacturingFacilityId: facilityId));
|
||||
|
||||
Reference in New Issue
Block a user