From 283de868bc86e24b1a9b59c268671542681d4c19 Mon Sep 17 00:00:00 2001 From: Hans Bakker Date: Thu, 20 Jul 2006 08:56:18 +0000 Subject: [PATCH] if there are partyassignments to the routingTask, valid date records will be copied over to the productionTask. git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@423836 13f79535-47bb-0310-9956-ffa450edef68 --- .../jobshopmgt/ProductionRunServices.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java index abd136ddf2..28fcbe620d 100644 --- a/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java +++ b/applications/manufacturing/src/org/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java @@ -331,6 +331,35 @@ public class ProductionRunServices { } catch (GenericServiceException e) { Debug.logError(e, "Problem calling the createWorkEffortAssoc service", module); } + // copy date valid WorkEffortPartyAssignments from the routing task to the run task + List workEffortPartyAssignments = null; + try { + workEffortPartyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment", + UtilMisc.toMap("workEffortId", routingTaskAssoc.getString("workEffortIdTo")))); + } catch (GenericEntityException e) { + Debug.logError(e.getMessage(), module); + } + if (workEffortPartyAssignments != null) { + Iterator i = workEffortPartyAssignments.iterator(); + while(i.hasNext()) { + GenericValue workEffortPartyAssignment = (GenericValue) i.next(); + Map partyToWorkEffort = UtilMisc.toMap( + "workEffortId", productionRunTaskId, + "partyId", workEffortPartyAssignment.getString("partyId"), + "roleTypeId", workEffortPartyAssignment.getString("roleTypeId"), + "fromDate", workEffortPartyAssignment.getTimestamp("fromDate"), + "statusId", workEffortPartyAssignment.getString("statusId"), + "userLogin", userLogin + ); + try { + resultService = dispatcher.runSync("assignPartyToWorkEffort", partyToWorkEffort); + } catch (GenericServiceException e) { + Debug.logError(e, "Problem calling the assignPartyToWorkEffort service", module); + } + if (Debug.infoOn()) Debug.logInfo("ProductionRunPartyassigment for party: " + workEffortPartyAssignment.get("partyId") + " created", module); + } + } + // Now we iterate thru the components returned by the getManufacturingComponents service // TODO: if in the BOM a routingWorkEffortId is specified, but the task is not in the routing // the component is not added to the production run. @@ -1162,6 +1191,34 @@ public class ProductionRunServices { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "ManufacturingAddProductionRunRoutingTaskNotCreated", locale)); } + // copy date valid WorkEffortPartyAssignments from the routing task to the run task + List workEffortPartyAssignments = null; + try { + workEffortPartyAssignments = EntityUtil.filterByDate(delegator.findByAnd("WorkEffortPartyAssignment", UtilMisc.toMap("workEffortId", routingTaskId))); + } catch (GenericEntityException e) { + Debug.logError(e.getMessage(), module); + } + if (workEffortPartyAssignments != null) { + Iterator i = workEffortPartyAssignments.iterator(); + while(i.hasNext()) { + GenericValue workEffortPartyAssignment = (GenericValue) i.next(); + Map partyToWorkEffort = UtilMisc.toMap( + "workEffortId", productionRunTaskId, + "partyId", workEffortPartyAssignment.getString("partyId"), + "roleTypeId", workEffortPartyAssignment.getString("roleTypeId"), + "fromDate", workEffortPartyAssignment.getTimestamp("fromDate"), + "statusId", workEffortPartyAssignment.getString("statusId"), + "userLogin", userLogin + ); + try { + resultService = dispatcher.runSync("assignPartyToWorkEffort", partyToWorkEffort); + } catch (GenericServiceException e) { + Debug.logError(e, "Problem calling the assignPartyToWorkEffort service", module); + } + if (Debug.infoOn()) Debug.logInfo("ProductionRunPartyassigment for party: " + workEffortPartyAssignment.get("partyId") + " created", module); + } + } + result.put("routingTaskId", productionRunTaskId); result.put("estimatedStartDate", estimatedStartDate); result.put("estimatedCompletionDate", estimatedCompletionDate);