Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public static void createOrUpdateMrpEvent(Map<String, Object> mrpEventKeyMap, Bi
if (isLate) {
mrpEvent.put("isLate", "Y");
}
if (UtilValidate.isEmpty(mrpEvent.getString("facilityId")) && UtilValidate.isNotEmpty(facilityId)) {
mrpEvent.put("facilityId", facilityId);
}
mrpEvent.store();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,
}
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", requiredByDate, "mrpEventTypeId", "SALES_ORDER_SHIP");
try {
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null,
String salesOrderFacilityId = genericResult.getString("facilityId");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, salesOrderFacilityId,
genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
Expand Down Expand Up @@ -231,8 +232,9 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,

parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId", "PROD_REQ_RECP");
try {
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("requirementId"),
false, delegator);
String requirementFacilityId = genericResult.getString("facilityId");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, requirementFacilityId,
genericResult.getString("requirementId"), false, delegator);
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
"mrpEventTypeId", "PROD_REQ_RECP"), locale));
Expand Down Expand Up @@ -309,7 +311,8 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,

parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId",
"PUR_ORDER_RECP");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, shipGroupQuantity, null,
String purchaseOrderFacilityId = UtilValidate.isNotEmpty(facilityId) ? facilityId : null;
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, shipGroupQuantity, purchaseOrderFacilityId,
genericResult.getString("orderId") + "-" + genericResult.getString("orderItemSeqId"), false, delegator);
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
Expand Down Expand Up @@ -351,7 +354,9 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,
"MANUF_ORDER_REQ");
String eventName = (UtilValidate.isEmpty(genericResult.getString("workEffortParentId")) ? genericResult.getString("workEffortId")
: genericResult.getString("workEffortParentId") + "-" + genericResult.getString("workEffortId"));
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, eventName, false, delegator);
String productionFacilityId = genericResult.getString("facilityId");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, productionFacilityId, eventName, false,
delegator);
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
Expand Down Expand Up @@ -395,8 +400,9 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,

parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", estimatedShipDate, "mrpEventTypeId",
"MANUF_ORDER_RECP");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, null, genericResult.getString("workEffortId"),
false, delegator);
String productionFacilityId = genericResult.getString("facilityId");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, eventQuantityTmp, productionFacilityId,
genericResult.getString("workEffortId"), false, delegator);
}
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
Expand Down Expand Up @@ -437,7 +443,8 @@ public static Map<String, Object> initMrpEvents(DispatchContext ctx, Map<String,
}
parameters = UtilMisc.toMap("mrpId", mrpId, "productId", productId, "eventDate", now, "mrpEventTypeId", "REQUIRED_MRP");
try {
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, BigDecimal.ZERO, null, null, false, delegator);
String productFacilityId = genericResult.getString("facilityId");
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, BigDecimal.ZERO, productFacilityId, null, false, delegator);
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpEventProblemInitializing", UtilMisc.toMap(
"mrpEventTypeId", "REQUIRED_MRP"), locale));
Expand Down Expand Up @@ -537,7 +544,7 @@ public static BigDecimal findProductMrpQoh(String mrpId, String productId, Strin
}
} catch (GenericServiceException e) {
Debug.logError(e, "Error calling getProductInventoryAvailableByFacility service", MODULE);
logMrpError(mrpId, productId, "Unable to count inventory", delegator);
logMrpError(mrpId, productId, facilityId, "Unable to count inventory", delegator);
return BigDecimal.ZERO;
}
return ((BigDecimal) resultMap.get("quantityOnHandTotal"));
Expand Down Expand Up @@ -579,16 +586,26 @@ private static int getSupplierProductLeadTimeDays(Delegator delegator, String pr
}

public static void logMrpError(String mrpId, String productId, String errorMessage, Delegator delegator) {
logMrpError(mrpId, productId, UtilDateTime.nowTimestamp(), errorMessage, delegator);
logMrpError(mrpId, productId, null, UtilDateTime.nowTimestamp(), errorMessage, delegator);
}

public static void logMrpError(String mrpId, String productId, String facilityId, String errorMessage, Delegator delegator) {
logMrpError(mrpId, productId, facilityId, UtilDateTime.nowTimestamp(), errorMessage, delegator);
}

public static void logMrpError(String mrpId, String productId, Timestamp eventDate, String errorMessage, Delegator delegator) {
logMrpError(mrpId, productId, null, eventDate, errorMessage, delegator);
}

public static void logMrpError(String mrpId, String productId, String facilityId, Timestamp eventDate, String errorMessage,
Delegator delegator) {
try {
if (UtilValidate.isNotEmpty(productId) && UtilValidate.isNotEmpty(errorMessage)) {
GenericValue inventoryEventError = delegator.makeValue("MrpEvent", UtilMisc.toMap("productId", productId,
"mrpId", mrpId,
"eventDate", eventDate,
"mrpEventTypeId", "ERROR",
"facilityId", facilityId,
"eventName", errorMessage));
delegator.createOrStore(inventoryEventError);
}
Expand All @@ -609,7 +626,7 @@ public static void logMrpError(String mrpId, String productId, Timestamp eventDa
*/

public static void processBomComponent(String mrpId, GenericValue product, BigDecimal eventQuantity, Timestamp startDate,
Map<String, Object> routingTaskStartDate, List<BOMNode> listComponent) {
Map<String, Object> routingTaskStartDate, List<BOMNode> listComponent, String facilityId) {
// TODO : change the return type to boolean to be able to test if all is ok or if it have had a exception
Delegator delegator = product.getDelegator();

Expand All @@ -628,11 +645,12 @@ public static void processBomComponent(String mrpId, GenericValue product, BigDe
parameters.put("mrpEventTypeId", "MRP_REQUIREMENT");
BigDecimal componentEventQuantity = node.getQuantity();
try {
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), null, product.get(
InventoryEventPlannedServices.createOrUpdateMrpEvent(parameters, componentEventQuantity.negate(), facilityId, product.get(
"productId") + ": " + eventDate, false, delegator);
} catch (GenericEntityException e) {
Debug.logError("Error : findOne(\"MrpEvent\", parameters) =" + parameters + "--" + e.getMessage(), MODULE);
logMrpError(mrpId, node.getProduct().getString("productId"), "Unable to create event (processBomComponent)", delegator);
logMrpError(mrpId, node.getProduct().getString("productId"), facilityId,
"Unable to create event (processBomComponent)", delegator);
}
}
}
Expand Down Expand Up @@ -897,16 +915,16 @@ public static Map<String, Object> executeMrp(DispatchContext ctx, Map<String, ?
if (isBuilt) {
// process the product components
processBomComponent(mrpId, product, proposedOrder.getQuantity(), proposedOrder.getRequirementStartDate(),
routingTaskStartDate, components);
routingTaskStartDate, components, manufacturingFacilityId);
}
// create the ProposedOrder (only if the product is warehouse managed), and the MrpEvent associated
String requirementId = null;
if (productFacility != null) {
requirementId = proposedOrder.create(ctx, userLogin);
}
if (UtilValidate.isEmpty(productFacility) && !isBuilt) {
logMrpError(mrpId, productId, now, "No ProductFacility record for [" + facilityId + "]; no requirement created.",
delegator);
logMrpError(mrpId, productId, facilityId, now, "No ProductFacility record for [" + facilityId
+ "]; no requirement created.", delegator);
}
String eventName = null;
if (UtilValidate.isNotEmpty(requirementId)) {
Expand All @@ -916,8 +934,9 @@ public static Map<String, Object> executeMrp(DispatchContext ctx, Map<String, ?
"mrpId", mrpId,
"eventDate", eventDate,
"mrpEventTypeId", (isBuilt ? "PROP_MANUF_O_RECP" : "PROP_PUR_O_RECP"));
String eventFacilityId = isBuilt ? manufacturingFacilityId : facilityId;
try {
InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, proposedOrder.getQuantity(), null,
InventoryEventPlannedServices.createOrUpdateMrpEvent(eventMap, proposedOrder.getQuantity(), eventFacilityId,
eventName, (proposedOrder.getRequirementStartDate().compareTo(now) < 0), delegator);
} catch (GenericEntityException e) {
return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "ManufacturingMrpCreateOrUpdateEvent",
Expand Down
Loading