Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunDeclaration.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunDeclaration.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunDeclaration.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunDeclaration.groovy Wed Nov 2 19:09:13 2016 @@ -20,125 +20,125 @@ // The only required parameter is "productionRunId". // The "actionForm" parameter triggers actions (see "ProductionRunSimpleEvents.xml"). -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.entity.GenericValue; -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.entity.GenericValue +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun -productionRunId = parameters.productionRunId ?: parameters.workEffortId; +productionRunId = parameters.productionRunId ?: parameters.workEffortId if (productionRunId) { - ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher) if (productionRun.exist()) { - productionRunId = productionRun.getGenericValue().workEffortId; - context.productionRunId = productionRunId; - context.productionRun = productionRun.getGenericValue(); + productionRunId = productionRun.getGenericValue().workEffortId + context.productionRunId = productionRunId + context.productionRun = productionRun.getGenericValue() // Find all the order items to which this production run is linked. - orderItems = from("WorkOrderItemFulfillment").where("workEffortId", productionRunId).queryList(); + orderItems = from("WorkOrderItemFulfillment").where("workEffortId", productionRunId).queryList() if (orderItems) { - context.orderItems = orderItems; + context.orderItems = orderItems } - quantityToProduce = productionRun.getGenericValue().get("quantityToProduce") ?: 0.0; + quantityToProduce = productionRun.getGenericValue().get("quantityToProduce") ?: 0.0 // Find the inventory items produced - inventoryItems = from("WorkEffortInventoryProduced").where("workEffortId", productionRunId).queryList(); - context.inventoryItems = inventoryItems; + inventoryItems = from("WorkEffortInventoryProduced").where("workEffortId", productionRunId).queryList() + context.inventoryItems = inventoryItems if (inventoryItems) { - lastWorkEffortInventoryProduced = (GenericValue)inventoryItems.get(inventoryItems.size() - 1); - lastInventoryItem = lastWorkEffortInventoryProduced.getRelatedOne("InventoryItem", false); - context.lastLotId = lastInventoryItem.lotId; + lastWorkEffortInventoryProduced = (GenericValue)inventoryItems.get(inventoryItems.size() - 1) + lastInventoryItem = lastWorkEffortInventoryProduced.getRelatedOne("InventoryItem", false) + context.lastLotId = lastInventoryItem.lotId } // Find if the production run can produce inventory. - quantityProduced = productionRun.getGenericValue().quantityProduced ?: 0.0; - quantityRejected = productionRun.getGenericValue().quantityRejected ?: 0.0; + quantityProduced = productionRun.getGenericValue().quantityProduced ?: 0.0 + quantityRejected = productionRun.getGenericValue().quantityRejected ?: 0.0 - lastTask = productionRun.getLastProductionRunRoutingTask(); - quantityDeclared = lastTask ? (lastTask.quantityProduced ?: 0.0) : 0.0 ; + lastTask = productionRun.getLastProductionRunRoutingTask() + quantityDeclared = lastTask ? (lastTask.quantityProduced ?: 0.0) : 0.0 - context.canDeclareAndProduce = "N"; + context.canDeclareAndProduce = "N" if (lastTask && ("PRUN_RUNNING".equals(lastTask.currentStatusId) || "PRUN_COMPLETED".equals(lastTask.currentStatusId))) { - context.canDeclareAndProduce = "Y"; + context.canDeclareAndProduce = "Y" } - maxQuantity = quantityDeclared - quantityProduced; + maxQuantity = quantityDeclared - quantityProduced - productionRunData = [:]; - productionRunData.workEffortId = productionRunId; - productionRunData.productId = productionRun.getProductProduced().productId; - productionRunData.product = productionRun.getProductProduced(); + productionRunData = [:] + productionRunData.workEffortId = productionRunId + productionRunData.productId = productionRun.getProductProduced().productId + productionRunData.product = productionRun.getProductProduced() if (maxQuantity > 0 && !"WIP".equals(productionRun.getProductProduced().productTypeId)) { - productionRunData.quantity = maxQuantity; - context.canProduce = "Y"; + productionRunData.quantity = maxQuantity + context.canProduce = "Y" } - productionRunData.quantityToProduce = quantityToProduce; - productionRunData.quantityProduced = quantityProduced; - productionRunData.quantityRejected = quantityRejected; - productionRunData.quantityRemaining = quantityToProduce - quantityProduced; - productionRunData.estimatedCompletionDate = productionRun.getEstimatedCompletionDate(); - productionRunData.productionRunName = productionRun.getProductionRunName(); - productionRunData.description = productionRun.getDescription(); - productionRunData.estimatedStartDate = productionRun.getEstimatedStartDate(); - productionRunData.actualStartDate = productionRun.getGenericValue().getTimestamp("actualStartDate"); - productionRunData.actualCompletionDate = productionRun.getGenericValue().getTimestamp("actualCompletionDate"); - productionRunData.currentStatusId = productionRun.getGenericValue().currentStatusId; - productionRunData.facilityId = productionRun.getGenericValue().facilityId; + productionRunData.quantityToProduce = quantityToProduce + productionRunData.quantityProduced = quantityProduced + productionRunData.quantityRejected = quantityRejected + productionRunData.quantityRemaining = quantityToProduce - quantityProduced + productionRunData.estimatedCompletionDate = productionRun.getEstimatedCompletionDate() + productionRunData.productionRunName = productionRun.getProductionRunName() + productionRunData.description = productionRun.getDescription() + productionRunData.estimatedStartDate = productionRun.getEstimatedStartDate() + productionRunData.actualStartDate = productionRun.getGenericValue().getTimestamp("actualStartDate") + productionRunData.actualCompletionDate = productionRun.getGenericValue().getTimestamp("actualCompletionDate") + productionRunData.currentStatusId = productionRun.getGenericValue().currentStatusId + productionRunData.facilityId = productionRun.getGenericValue().facilityId - manufacturer = from("WorkEffortPartyAssignment").where("workEffortId", productionRunId, "roleTypeId", "MANUFACTURER").filterByDate().queryFirst(); + manufacturer = from("WorkEffortPartyAssignment").where("workEffortId", productionRunId, "roleTypeId", "MANUFACTURER").filterByDate().queryFirst() if (manufacturer){ - productionRunData.manufacturerId = manufacturer.partyId; + productionRunData.manufacturerId = manufacturer.partyId } - context.productionRunData = productionRunData; + context.productionRunData = productionRunData - actionForm = parameters.actionForm ?: "beforeActionProductionRun"; - context.actionForm = actionForm; + actionForm = parameters.actionForm ?: "beforeActionProductionRun" + context.actionForm = actionForm //--------------- // Routing tasks //--------------- // routingTask update sub-screen - routingTaskId = parameters.routingTaskId; + routingTaskId = parameters.routingTaskId if (routingTaskId && (actionForm.equals("UpdateRoutingTask") || actionForm.equals("EditRoutingTask"))) { - routingTask = from("WorkEffort").where("workEffortId", routingTaskId).queryOne(); - Map routingTaskData = routingTask.getAllFields(); - routingTaskData.estimatedSetupMillis = routingTask.getDouble("estimatedSetupMillis"); - routingTaskData.estimatedMilliSeconds = routingTask.getDouble("estimatedMilliSeconds"); - context.routingTaskData = routingTaskData; - routingTaskData.partyId = userLogin.partyId; - context.routingTaskId = routingTaskId; + routingTask = from("WorkEffort").where("workEffortId", routingTaskId).queryOne() + Map routingTaskData = routingTask.getAllFields() + routingTaskData.estimatedSetupMillis = routingTask.getDouble("estimatedSetupMillis") + routingTaskData.estimatedMilliSeconds = routingTask.getDouble("estimatedMilliSeconds") + context.routingTaskData = routingTaskData + routingTaskData.partyId = userLogin.partyId + context.routingTaskId = routingTaskId // Get the list of deliverable products, i.e. the WorkEffortGoodStandard entries // with workEffortGoodStdTypeId = "PRUNT_PROD_DELIV": // first of all we get the template task (the routing task) - templateTaskAssoc = from("WorkEffortAssoc").where("workEffortIdTo", routingTask.workEffortId, "workEffortAssocTypeId", "WORK_EFF_TEMPLATE").filterByDate().queryFirst(); - templateTask = [:]; + templateTaskAssoc = from("WorkEffortAssoc").where("workEffortIdTo", routingTask.workEffortId, "workEffortAssocTypeId", "WORK_EFF_TEMPLATE").filterByDate().queryFirst() + templateTask = [:] if (templateTaskAssoc) { - templateTask = templateTaskAssoc.getRelatedOne("FromWorkEffort", false); + templateTask = templateTaskAssoc.getRelatedOne("FromWorkEffort", false) } - delivProducts = []; + delivProducts = [] if (templateTask) { - delivProducts = EntityUtil.filterByDate(templateTask.getRelated("WorkEffortGoodStandard", [workEffortGoodStdTypeId : "PRUNT_PROD_DELIV"], null, false)); + delivProducts = EntityUtil.filterByDate(templateTask.getRelated("WorkEffortGoodStandard", [workEffortGoodStdTypeId : "PRUNT_PROD_DELIV"], null, false)) } - context.delivProducts = delivProducts; + context.delivProducts = delivProducts // Get the list of delivered products, i.e. inventory items - prunInventoryProduced = from("WorkEffortAndInventoryProduced").where("workEffortId", routingTaskId).queryList(); - context.prunInventoryProduced = prunInventoryProduced; + prunInventoryProduced = from("WorkEffortAndInventoryProduced").where("workEffortId", routingTaskId).queryList() + context.prunInventoryProduced = prunInventoryProduced } // RoutingTasks list - List productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks(); - String startTaskId = null; // which production run task is ready to start and has the [Start] buton next to it - String issueTaskId = null; // which production run task is ready to have products issued with [Issue Components] button - String completeTaskId = null; // which task has the [Complete] button next to it + List productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks() + String startTaskId = null // which production run task is ready to start and has the [Start] buton next to it + String issueTaskId = null // which production run task is ready to have products issued with [Issue Components] button + String completeTaskId = null // which task has the [Complete] button next to it productionRunRoutingTasks.each { task -> // only PRUN_RUNNING tasks can have items issued or production run completed if ("PRUN_RUNNING".equals(task.currentStatusId)) { // Use WorkEffortGoodStandard to figure out if there are products which are needed for this task (PRUNT_PRODNEEDED) and which have not been issued (ie, WEGS_CREATED). // If so this task should have products issued - components = from("WorkEffortGoodStandard").where("workEffortId", task.workEffortId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED", "statusId", "WEGS_CREATED").queryList(); + components = from("WorkEffortGoodStandard").where("workEffortId", task.workEffortId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED", "statusId", "WEGS_CREATED").queryList() if (components) { - issueTaskId = task.workEffortId; + issueTaskId = task.workEffortId } if (!issueTaskId) { - completeTaskId = task.workEffortId; + completeTaskId = task.workEffortId } } @@ -149,70 +149,70 @@ if (productionRunId) { ("PRUN_CREATED".equals(task.currentStatusId) || "PRUN_SCHEDULED".equals(task.currentStatusId) || "PRUN_DOC_PRINTED".equals(task.currentStatusId))) { - startTaskId = task.workEffortId; + startTaskId = task.workEffortId } } - context.productionRunRoutingTasks = productionRunRoutingTasks; - context.startTaskId = (startTaskId ? startTaskId: "null"); - context.issueTaskId = (issueTaskId? issueTaskId: "null"); - context.completeTaskId = (completeTaskId != null? completeTaskId: "null"); + context.productionRunRoutingTasks = productionRunRoutingTasks + context.startTaskId = (startTaskId ? startTaskId: "null") + context.issueTaskId = (issueTaskId? issueTaskId: "null") + context.completeTaskId = (completeTaskId != null? completeTaskId: "null") // Product components list - productionRunComponents = productionRun.getProductionRunComponents(); - productionRunComponentsData = []; - productionRunComponentsDataReadyForIssuance = []; - productionRunComponentsAlreadyIssued = []; + productionRunComponents = productionRun.getProductionRunComponents() + productionRunComponentsData = [] + productionRunComponentsDataReadyForIssuance = [] + productionRunComponentsAlreadyIssued = [] if (productionRunComponents) { productionRunComponents.each { component -> - product = component.getRelatedOne("Product", false); - componentName = product.getString("internalName"); - productionRunTask = component.getRelatedOne("WorkEffort", false); - workEffortName = productionRunTask.getString("workEffortName"); - Map componentData = component.getAllFields(); - componentData.internalName = componentName; - componentData.workEffortName = workEffortName; - componentData.facilityId = productionRunTask.facilityId; - issuances = from("WorkEffortAndInventoryAssign").where("workEffortId", component.workEffortId, "productId", product.productId).queryList(); - totalIssued = 0.0; + product = component.getRelatedOne("Product", false) + componentName = product.getString("internalName") + productionRunTask = component.getRelatedOne("WorkEffort", false) + workEffortName = productionRunTask.getString("workEffortName") + Map componentData = component.getAllFields() + componentData.internalName = componentName + componentData.workEffortName = workEffortName + componentData.facilityId = productionRunTask.facilityId + issuances = from("WorkEffortAndInventoryAssign").where("workEffortId", component.workEffortId, "productId", product.productId).queryList() + totalIssued = 0.0 issuances.each { issuance -> - issued = issuance.quantity; + issued = issuance.quantity if (issued) { - totalIssued += issued; + totalIssued += issued } } - returns = from("WorkEffortAndInventoryProduced").where("workEffortId", component.workEffortId , "productId", product.productId).queryList(); - totalReturned = 0.0; + returns = from("WorkEffortAndInventoryProduced").where("workEffortId", component.workEffortId , "productId", product.productId).queryList() + totalReturned = 0.0 returns.each { returned -> - returnDetail = from("InventoryItemDetail").where("inventoryItemId", returned.inventoryItemId).orderBy("inventoryItemDetailSeqId").queryFirst(); + returnDetail = from("InventoryItemDetail").where("inventoryItemId", returned.inventoryItemId).orderBy("inventoryItemDetailSeqId").queryFirst() if (returnDetail) { - qtyReturned = returnDetail.quantityOnHandDiff; + qtyReturned = returnDetail.quantityOnHandDiff if (qtyReturned) { - totalReturned += qtyReturned; + totalReturned += qtyReturned } } } - componentData.issuedQuantity = totalIssued; - componentData.returnedQuantity = totalReturned; - componentData.currentStatusId = productionRunTask.currentStatusId; + componentData.issuedQuantity = totalIssued + componentData.returnedQuantity = totalReturned + componentData.currentStatusId = productionRunTask.currentStatusId if ("PRUN_RUNNING".equals(productionRunTask.currentStatusId)) { - componentData.isRunning = "Y"; + componentData.isRunning = "Y" } else { - componentData.isRunning = "null"; + componentData.isRunning = "null" } - productionRunComponentsData.add(componentData); + productionRunComponentsData.add(componentData) if ("PRUN_RUNNING".equals(productionRunTask.currentStatusId) && "WEGS_CREATED".equals(component.getString("statusId"))) { - productionRunComponentsDataReadyForIssuance.add(componentData); + productionRunComponentsDataReadyForIssuance.add(componentData) } else if (totalIssued > 0.0) { - productionRunComponentsAlreadyIssued.add(componentData); + productionRunComponentsAlreadyIssued.add(componentData) } } } // Content - productionRunContents = from("WorkEffortContentAndInfo").where("workEffortId", productionRunId).orderBy("-fromDate").filterByDate().queryList(); - context.productionRunContents = productionRunContents; - context.productionRunComponents = productionRunComponents; - context.productionRunComponentsData = productionRunComponentsData; - context.productionRunComponentsDataReadyForIssuance = productionRunComponentsDataReadyForIssuance; - context.productionRunComponentsAlreadyIssued = productionRunComponentsAlreadyIssued; + productionRunContents = from("WorkEffortContentAndInfo").where("workEffortId", productionRunId).orderBy("-fromDate").filterByDate().queryList() + context.productionRunContents = productionRunContents + context.productionRunComponents = productionRunComponents + context.productionRunComponentsData = productionRunComponentsData + context.productionRunComponentsDataReadyForIssuance = productionRunComponentsDataReadyForIssuance + context.productionRunComponentsAlreadyIssued = productionRunComponentsAlreadyIssued } } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunFixedAssets.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunFixedAssets.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunFixedAssets.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunFixedAssets.groovy Wed Nov 2 19:09:13 2016 @@ -17,12 +17,12 @@ * under the License. */ -productionRunId = parameters.productionRunId ?: parameters.workEffortId; +productionRunId = parameters.productionRunId ?: parameters.workEffortId -taskInfos = []; -tasks = from("WorkEffort").where("workEffortParentId", productionRunId, "workEffortTypeId", "PROD_ORDER_TASK").orderBy("workEffortId").queryList(); +taskInfos = [] +tasks = from("WorkEffort").where("workEffortParentId", productionRunId, "workEffortTypeId", "PROD_ORDER_TASK").orderBy("workEffortId").queryList() tasks.each { task -> - records = task.getRelated("WorkEffortFixedAssetAssign", null, null, false); - taskInfos.add([task : task, records : records]); + records = task.getRelated("WorkEffortFixedAssetAssign", null, null, false) + taskInfos.add([task : task, records : records]) } -context.taskInfos = taskInfos; +context.taskInfos = taskInfos Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTaskParties.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTaskParties.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTaskParties.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTaskParties.groovy Wed Nov 2 19:09:13 2016 @@ -17,21 +17,21 @@ * under the License. */ -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; -taskPartyAssocList = []; -productionRunId = parameters.productionRunId ?: parameters.workEffortId; +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun +taskPartyAssocList = [] +productionRunId = parameters.productionRunId ?: parameters.workEffortId if (productionRunId) { - ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher) if (productionRun.exist()) { - productionRunTasks = productionRun.getProductionRunRoutingTasks(); + productionRunTasks = productionRun.getProductionRunRoutingTasks() if (productionRunTasks) { productionRunTasks.each { prodRunTask -> - prodRunTaskId = prodRunTask.workEffortId; - taskPartyAssocs = from("WorkEffortPartyAssignment").where("workEffortId", prodRunTaskId).queryList(); + prodRunTaskId = prodRunTask.workEffortId + taskPartyAssocs = from("WorkEffortPartyAssignment").where("workEffortId", prodRunTaskId).queryList() if (taskPartyAssocs) { taskPartyAssocs.each { taskPartyAssoc -> - taskPartyAssocList.add(taskPartyAssoc); + taskPartyAssocList.add(taskPartyAssoc) } } } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTasks.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTasks.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTasks.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ProductionRunTasks.groovy Wed Nov 2 19:09:13 2016 @@ -17,14 +17,14 @@ * under the License. */ -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun -productionRunId = parameters.productionRunId ?: parameters.workEffortId; +productionRunId = parameters.productionRunId ?: parameters.workEffortId if (productionRunId) { - ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher) if (productionRun.exist()) { - productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks(); - context.productionRunRoutingTasks = productionRunRoutingTasks; - context.quantity = productionRun.getQuantity(); // this is useful to compute the total estimates runtime in the form + productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks() + context.productionRunRoutingTasks = productionRunRoutingTasks + context.quantity = productionRun.getQuantity() // this is useful to compute the total estimates runtime in the form } } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ShowProductionRun.groovy Wed Nov 2 19:09:13 2016 @@ -19,40 +19,40 @@ // The only required parameter is "productionRunId". -import java.util.*; -import org.apache.ofbiz.entity.*; -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.base.util.*; -import org.apache.ofbiz.base.util.Debug; -import org.apache.ofbiz.base.util.UtilValidate; -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; +import java.util.* +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.base.util.* +import org.apache.ofbiz.base.util.Debug +import org.apache.ofbiz.base.util.UtilValidate +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun -delegator = request.getAttribute("delegator"); +delegator = request.getAttribute("delegator") -productionRunId = request.getParameter("productionRunId"); +productionRunId = request.getParameter("productionRunId") if (UtilValidate.isEmpty(productionRunId)) { - productionRunId = request.getParameter("workEffortId"); + productionRunId = request.getParameter("workEffortId") } if (UtilValidate.isNotEmpty(productionRunId)) { - GenericValue productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId), false); + GenericValue productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRunId), false) if (UtilValidate.isNotEmpty(productionRun)) { // If this is a task, get the parent production run if (productionRun.getString("workEffortTypeId") != null && "PROD_ORDER_TASK".equals(productionRun.getString("workEffortTypeId"))) { - productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRun.getString("workEffortParentId")), false); + productionRun = delegator.findOne("WorkEffort", UtilMisc.toMap("workEffortId", productionRun.getString("workEffortParentId")), false) } } if (UtilValidate.isEmpty(productionRun)) { - return "error"; + return "error" } if ("PRUN_CREATED".equals(productionRun.getString("currentStatusId")) || "PRUN_SCHEDULED".equals(productionRun.getString("currentStatusId")) || "PRUN_CANCELLED".equals(productionRun.getString("currentStatusId"))) { - return "docs_not_printed"; + return "docs_not_printed" } else { - return "docs_printed"; + return "docs_printed" } } -return "error"; +return "error" Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ViewProductionRun.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ViewProductionRun.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ViewProductionRun.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/ViewProductionRun.groovy Wed Nov 2 19:09:13 2016 @@ -20,49 +20,49 @@ // The only required parameter is "productionRunId". // The "actionForm" parameter triggers actions (see "ProductionRunSimpleEvents.xml"). -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun -productionRunId = parameters.productionRunId; +productionRunId = parameters.productionRunId if (productionRunId) { - ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher); + ProductionRun productionRun = new ProductionRun(productionRunId, delegator, dispatcher) if (productionRun.exist()) { - productionRunId = productionRun.getGenericValue().workEffortId; - context.productionRunId = productionRunId; - context.productionRun = productionRun.getGenericValue(); + productionRunId = productionRun.getGenericValue().workEffortId + context.productionRunId = productionRunId + context.productionRun = productionRun.getGenericValue() // Prepare production run header data - productionRunData = [:]; - productionRunData.productionRunId = productionRunId; - productionRunData.productId = productionRun.getProductProduced().productId; - productionRunData.currentStatusId = productionRun.getGenericValue().currentStatusId; - productionRunData.facilityId = productionRun.getGenericValue().facilityId; - productionRunData.workEffortName = productionRun.getProductionRunName(); - productionRunData.description = productionRun.getDescription(); - productionRunData.quantity = productionRun.getQuantity(); - productionRunData.estimatedStartDate = productionRun.getEstimatedStartDate(); - productionRunData.estimatedCompletionDate = productionRun.getEstimatedCompletionDate(); + productionRunData = [:] + productionRunData.productionRunId = productionRunId + productionRunData.productId = productionRun.getProductProduced().productId + productionRunData.currentStatusId = productionRun.getGenericValue().currentStatusId + productionRunData.facilityId = productionRun.getGenericValue().facilityId + productionRunData.workEffortName = productionRun.getProductionRunName() + productionRunData.description = productionRun.getDescription() + productionRunData.quantity = productionRun.getQuantity() + productionRunData.estimatedStartDate = productionRun.getEstimatedStartDate() + productionRunData.estimatedCompletionDate = productionRun.getEstimatedCompletionDate() - manufacturer = from("WorkEffortPartyAssignment").where("workEffortId", productionRunId, "roleTypeId", "MANUFACTURER").filterByDate().queryFirst(); + manufacturer = from("WorkEffortPartyAssignment").where("workEffortId", productionRunId, "roleTypeId", "MANUFACTURER").filterByDate().queryFirst() if (manufacturer){ - productionRunData.manufacturerId = manufacturer.partyId; + productionRunData.manufacturerId = manufacturer.partyId } - context.productionRunData = productionRunData; + context.productionRunData = productionRunData // Find all the order items to which this production run is linked. - orderItems = from("WorkOrderItemFulfillment").where("workEffortId", productionRunId).queryList(); + orderItems = from("WorkOrderItemFulfillment").where("workEffortId", productionRunId).queryList() if (orderItems) { - context.orderItems = orderItems; + context.orderItems = orderItems } // RoutingTasks list - context.productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks(); - context.quantity = productionRun.getQuantity(); // this is useful to compute the total estimates runtime in the form + context.productionRunRoutingTasks = productionRun.getProductionRunRoutingTasks() + context.quantity = productionRun.getQuantity() // this is useful to compute the total estimates runtime in the form // Product component/parts list - context.productionRunComponents = productionRun.getProductionRunComponents();; + context.productionRunComponents = productionRun.getProductionRunComponents() // Find all the notes linked to this production run. - productionRunNoteData = from("WorkEffortNoteAndData").where("workEffortId", productionRunId).queryList(); + productionRunNoteData = from("WorkEffortNoteAndData").where("workEffortId", productionRunId).queryList() if (productionRunNoteData) { - context.productionRunNoteData = productionRunNoteData; + context.productionRunNoteData = productionRunNoteData } } } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/WorkWithShipmentPlans.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/WorkWithShipmentPlans.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/WorkWithShipmentPlans.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/jobshopmgt/WorkWithShipmentPlans.groovy Wed Nov 2 19:09:13 2016 @@ -17,112 +17,112 @@ * under the License. */ -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun; +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRun // ************************************** // ShipmentPlan list form // ************************************** -shipmentPlans = []; -rows = []; +shipmentPlans = [] +rows = [] if (shipment && shipment.shipmentId) { - shipmentPlans = from("OrderShipment").where("shipmentId", shipment.shipmentId).queryList(); + shipmentPlans = from("OrderShipment").where("shipmentId", shipment.shipmentId).queryList() } if (shipmentPlans) { - workInProgress = "false"; + workInProgress = "false" shipmentPlans.each { shipmentPlan -> - oneRow = new HashMap(shipmentPlan); - orderItem = shipmentPlan.getRelatedOne("OrderItem", false); - oneRow.productId = orderItem.productId; - orderedQuantity = orderItem.quantity; - canceledQuantity = orderItem.cancelQuantity; + oneRow = new HashMap(shipmentPlan) + orderItem = shipmentPlan.getRelatedOne("OrderItem", false) + oneRow.productId = orderItem.productId + orderedQuantity = orderItem.quantity + canceledQuantity = orderItem.cancelQuantity if (canceledQuantity) { - orderedQuantity = orderedQuantity - canceledQuantity; + orderedQuantity = orderedQuantity - canceledQuantity } - oneRow.totOrderedQuantity = orderedQuantity.intValue(); + oneRow.totOrderedQuantity = orderedQuantity.intValue() // Total quantity issued - issuedQuantity = 0.0; - qtyIssuedInShipment = [:]; - issuances = orderItem.getRelated("ItemIssuance", null, null, false); + issuedQuantity = 0.0 + qtyIssuedInShipment = [:] + issuances = orderItem.getRelated("ItemIssuance", null, null, false) issuances.each { issuance -> if (issuance.quantity) { - issuedQuantity += issuance.quantity; + issuedQuantity += issuance.quantity if (issuance.cancelQuantity) { - issuedQuantity -= issuance.cancelQuantity; + issuedQuantity -= issuance.cancelQuantity } if (qtyIssuedInShipment.containsKey(issuance.shipmentId)) { - qtyInShipment = qtyIssuedInShipment[issuance.shipmentId]; - qtyInShipment += issuance.quantity; - qtyIssuedInShipment.issuance.shipmentId = qtyInShipment; + qtyInShipment = qtyIssuedInShipment[issuance.shipmentId] + qtyInShipment += issuance.quantity + qtyIssuedInShipment.issuance.shipmentId = qtyInShipment } else { - qtyInShipment = issuance.quantity; + qtyInShipment = issuance.quantity if (issuance.cancelQuantity) { - qtyInShipment -= issuance.cancelQuantity; + qtyInShipment -= issuance.cancelQuantity } - qtyIssuedInShipment.issuance.shipmentId = qtyInShipment; + qtyIssuedInShipment.issuance.shipmentId = qtyInShipment } } } - oneRow.totIssuedQuantity = issuedQuantity; + oneRow.totIssuedQuantity = issuedQuantity // Total quantity planned not issued - plannedQuantity = 0.0; - qtyPlannedInShipment = [:]; - plans = from("OrderShipment").where("orderId", orderItem.orderId ,"orderItemSeqId", orderItem.orderItemSeqId).queryList(); + plannedQuantity = 0.0 + qtyPlannedInShipment = [:] + plans = from("OrderShipment").where("orderId", orderItem.orderId ,"orderItemSeqId", orderItem.orderItemSeqId).queryList() plans.each { plan -> if (plan.quantity) { - netPlanQty = plan.quantity; + netPlanQty = plan.quantity if (qtyIssuedInShipment.containsKey(plan.shipmentId)) { - qtyInShipment = qtyIssuedInShipment[plan.shipmentId]; + qtyInShipment = qtyIssuedInShipment[plan.shipmentId] if (netPlanQty > qtyInShipment) { - netPlanQty -= qtyInShipment; + netPlanQty -= qtyInShipment } else { - netPlanQty = 0.0; + netPlanQty = 0.0 } } - plannedQuantity += netPlanQty; + plannedQuantity += netPlanQty if (qtyPlannedInShipment.containsKey(plan.shipmentId)) { - qtyInShipment = qtyPlannedInShipment[plan.shipmentId]; - qtyInShipment += netPlanQty; - qtyPlannedInShipment[plan.shipmentId] = qtyInShipment; + qtyInShipment = qtyPlannedInShipment[plan.shipmentId] + qtyInShipment += netPlanQty + qtyPlannedInShipment[plan.shipmentId] = qtyInShipment } else { - qtyPlannedInShipment[plan.shipmentId] = netPlanQty; + qtyPlannedInShipment[plan.shipmentId] = netPlanQty } } } - oneRow.totPlannedQuantity = plannedQuantity; + oneRow.totPlannedQuantity = plannedQuantity if (qtyIssuedInShipment.containsKey(shipmentPlan.shipmentId)) { - oneRow.issuedQuantity = qtyIssuedInShipment.get(shipmentPlan.shipmentId); + oneRow.issuedQuantity = qtyIssuedInShipment.get(shipmentPlan.shipmentId) } else { - oneRow.issuedQuantity = ""; + oneRow.issuedQuantity = "" } // Reserved and Not Available quantity - reservedQuantity = 0.0; - reservedNotAvailable = 0.0; - reservations = orderItem.getRelated("OrderItemShipGrpInvRes", null, null, false); + reservedQuantity = 0.0 + reservedNotAvailable = 0.0 + reservations = orderItem.getRelated("OrderItemShipGrpInvRes", null, null, false) reservations.each { reservation -> if (reservation.quantity) { - reservedQuantity += reservation.quantity; + reservedQuantity += reservation.quantity } if (reservation.quantityNotAvailable) { - reservedNotAvailable += reservation.quantityNotAvailable; + reservedNotAvailable += reservation.quantityNotAvailable } } - oneRow.notAvailableQuantity = reservedNotAvailable; + oneRow.notAvailableQuantity = reservedNotAvailable // Planned Weight and Volume - product = orderItem.getRelatedOne("Product", false); - weight = 0.0; - quantity = 0.0; + product = orderItem.getRelatedOne("Product", false) + weight = 0.0 + quantity = 0.0 if (shipmentPlan.quantity) { - quantity = shipmentPlan.quantity; + quantity = shipmentPlan.quantity } if (product.productWeight) { - weight = product.productWeight * quantity; + weight = product.productWeight * quantity } - oneRow.weight = weight; + oneRow.weight = weight if (product.weightUomId) { - weightUom = from("Uom").where("uomId", product.weightUomId).cache(true).queryOne(); - oneRow.weightUom = weightUom.abbreviation; + weightUom = from("Uom").where("uomId", product.weightUomId).cache(true).queryOne() + oneRow.weightUom = weightUom.abbreviation } - volume = 0.0; + volume = 0.0 if (product.productHeight && product.productWidth && product.productDepth) { @@ -130,37 +130,37 @@ if (shipmentPlans) { volume = product.productHeight * product.productWidth * product.productDepth * - quantity; + quantity } - oneRow.volume = volume; + oneRow.volume = volume if (product.heightUomId && product.widthUomId && product.depthUomId) { - heightUom = from("Uom").where("uomId", product.heightUomId).cache(true).queryOne(); - widthUom = from("Uom").where("uomId", product.widthUomId).cache(true).queryOne(); - depthUom = from("Uom").where("uomId", product.depthUomId).cache(true).queryOne(); + heightUom = from("Uom").where("uomId", product.heightUomId).cache(true).queryOne() + widthUom = from("Uom").where("uomId", product.widthUomId).cache(true).queryOne() + depthUom = from("Uom").where("uomId", product.depthUomId).cache(true).queryOne() oneRow.volumeUom = heightUom.abbreviation + "x" + widthUom.abbreviation + "x" + - depthUom.abbreviation; + depthUom.abbreviation } - rows.add(oneRow); + rows.add(oneRow) // Select the production runs, if available - productionRuns = from("WorkOrderItemFulfillment").where("orderId", shipmentPlan.orderId, "orderItemSeqId", shipmentPlan.orderItemSeqId, "shipGroupSeqId", shipmentPlan.shipGroupSeqId).orderBy("workEffortId").queryList(); + productionRuns = from("WorkOrderItemFulfillment").where("orderId", shipmentPlan.orderId, "orderItemSeqId", shipmentPlan.orderItemSeqId, "shipGroupSeqId", shipmentPlan.shipGroupSeqId).orderBy("workEffortId").queryList() if (productionRuns) { - workInProgress = "true"; - productionRunsId = ""; + workInProgress = "true" + productionRunsId = "" productionRuns.each { productionRun -> - productionRunRow = new HashMap(); - productionRunRow.put("productionRunId", productionRun.workEffortId); - ProductionRun productionRunWrapper = new ProductionRun(productionRun.workEffortId, delegator, dispatcher); - productionRunRow.put("productionRunEstimatedCompletionDate", productionRunWrapper.getEstimatedCompletionDate()); - productionRunRow.put("productionRunStatusId", productionRunWrapper.getGenericValue().currentStatusId); - productionRunRow.put("productionRunQuantityProduced", productionRunWrapper.getGenericValue().quantityProduced); - rows.add(productionRunRow); + productionRunRow = new HashMap() + productionRunRow.put("productionRunId", productionRun.workEffortId) + ProductionRun productionRunWrapper = new ProductionRun(productionRun.workEffortId, delegator, dispatcher) + productionRunRow.put("productionRunEstimatedCompletionDate", productionRunWrapper.getEstimatedCompletionDate()) + productionRunRow.put("productionRunStatusId", productionRunWrapper.getGenericValue().currentStatusId) + productionRunRow.put("productionRunQuantityProduced", productionRunWrapper.getGenericValue().quantityProduced) + rows.add(productionRunRow) } } } - context.workInProgress = workInProgress; - context.shipmentPlan = rows; + context.workInProgress = workInProgress + context.shipmentPlan = rows } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/mrp/FindInventoryEventPlan.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/mrp/FindInventoryEventPlan.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/mrp/FindInventoryEventPlan.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/mrp/FindInventoryEventPlan.groovy Wed Nov 2 19:09:13 2016 @@ -17,72 +17,72 @@ * under the License. */ -import org.apache.ofbiz.base.util.ObjectType; -import org.apache.ofbiz.entity.condition.EntityOperator; -import org.apache.ofbiz.entity.condition.EntityCondition; -import org.apache.ofbiz.entity.util.EntityUtilProperties; +import org.apache.ofbiz.base.util.ObjectType +import org.apache.ofbiz.entity.condition.EntityOperator +import org.apache.ofbiz.entity.condition.EntityCondition +import org.apache.ofbiz.entity.util.EntityUtilProperties -productId = parameters.productId; +productId = parameters.productId // get the lookup flag -lookupFlag = parameters.lookupFlag; +lookupFlag = parameters.lookupFlag // blank param list -paramList = ""; -inventoryList = []; +paramList = "" +inventoryList = [] if (lookupFlag) { - paramList = paramList + "&lookupFlag=" + lookupFlag; - andExprs = []; + paramList = paramList + "&lookupFlag=" + lookupFlag + andExprs = [] //define main condition - mainCond = null; + mainCond = null // now do the filtering - eventDate = parameters.eventDate; + eventDate = parameters.eventDate if (eventDate?.length() > 8) { - eventDate = eventDate.trim(); - if (eventDate.length() < 14) eventDate = eventDate + " " + "00:00:00.000"; - paramList = paramList + "&eventDate=" + eventDate; - andExprs.add(EntityCondition.makeCondition("eventDate", EntityOperator.GREATER_THAN, ObjectType.simpleTypeConvert(eventDate, "Timestamp", null, null))); + eventDate = eventDate.trim() + if (eventDate.length() < 14) eventDate = eventDate + " " + "00:00:00.000" + paramList = paramList + "&eventDate=" + eventDate + andExprs.add(EntityCondition.makeCondition("eventDate", EntityOperator.GREATER_THAN, ObjectType.simpleTypeConvert(eventDate, "Timestamp", null, null))) } if (productId) { - paramList = paramList + "&productId=" + productId; - andExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId)); + paramList = paramList + "&productId=" + productId + andExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, productId)) } - andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "INITIAL_QOH")); - andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "ERROR")); - andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "REQUIRED_MRP")); + andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "INITIAL_QOH")) + andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "ERROR")) + andExprs.add(EntityCondition.makeCondition("mrpEventTypeId", EntityOperator.NOT_EQUAL, "REQUIRED_MRP")) - mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND); + mainCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND) if ( mainCond) { // do the lookup - inventoryList = from("MrpEvent").where(mainCond).orderBy("productId", "eventDate").queryList(); + inventoryList = from("MrpEvent").where(mainCond).orderBy("productId", "eventDate").queryList() } - context.inventoryList = inventoryList; + context.inventoryList = inventoryList } -context.paramList = paramList; +context.paramList = paramList // set the page parameters -viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 0); -viewSize = parameters.VIEW_SIZE ?: EntityUtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20); -listSize = 0; +viewIndex = Integer.valueOf(parameters.VIEW_INDEX ?: 0) +viewSize = parameters.VIEW_SIZE ?: EntityUtilProperties.getPropertyAsInteger("widget", "widget.form.defaultViewSize", 20) +listSize = 0 if (inventoryList) - listSize = inventoryList.size(); + listSize = inventoryList.size() -lowIndex = viewIndex * viewSize; -highIndex = (viewIndex + 1) * viewSize; +lowIndex = viewIndex * viewSize +highIndex = (viewIndex + 1) * viewSize if (listSize < highIndex) - highIndex = listSize; + highIndex = listSize if ( highIndex < 1 ) - highIndex = 0; -context.viewIndex = viewIndex; -context.listSize = listSize; -context.highIndex = highIndex; -context.lowIndex = lowIndex; -context.viewSize = viewSize; + highIndex = 0 +context.viewIndex = viewIndex +context.listSize = listSize +context.highIndex = highIndex +context.lowIndex = lowIndex +context.viewSize = viewSize Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/CuttingListReport.groovy Wed Nov 2 19:09:13 2016 @@ -23,22 +23,22 @@ import org.apache.ofbiz.manufacturing.jo import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunHelper if (security.hasEntityPermission("MANUFACTURING", "_VIEW", session)) { - context.hasPermission = Boolean.TRUE; + context.hasPermission = Boolean.TRUE } else { - context.hasPermission = Boolean.FALSE; + context.hasPermission = Boolean.FALSE } // ----------------------------- // Report's parameters -selectWorkEffortNameParameter = "O-PREL_A"; // sezionatura -selectPrimaryCategoryIdParameter = "CABINETS"; // struttura +selectWorkEffortNameParameter = "O-PREL_A" // sezionatura +selectPrimaryCategoryIdParameter = "CABINETS" // struttura // ----------------------------- -shipmentId = request.getParameter("shipmentId"); -context.shipmentId = shipmentId; +shipmentId = request.getParameter("shipmentId") +context.shipmentId = shipmentId -shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false); -context.shipment = shipment; +shipment = delegator.findOne("Shipment", [shipmentId : shipmentId], false) +context.shipment = shipment // dimensionsByFeatureMap [key=feature; value=productsByShapeMap] // productsByShapeMap [key=dimension; value=quantityByProductsMap] @@ -46,85 +46,85 @@ context.shipment = shipment; // dimension={width*, height*, qty} // product={productId*,...} -productIdToQuantity = [:]; // key=productId, value=quantity -productIdToProduct = [:]; // key=productId, value=product -dimensionToProducts = [:]; // key=Dimension, value=list of products -dimensionToQuantity = [:]; // key=Dimension, value=tot qty (of products) +productIdToQuantity = [:] // key=productId, value=quantity +productIdToProduct = [:] // key=productId, value=product +dimensionToProducts = [:] // key=Dimension, value=list of products +dimensionToQuantity = [:] // key=Dimension, value=tot qty (of products) shipmentPlans = from("OrderShipment").where("shipmentId", shipmentId).queryList() if (shipmentPlans) { shipmentPlans.each { shipmentPlan -> // Select the production run, if available - weIds = from("WorkOrderItemFulfillment").where("orderId", shipmentPlan.orderId, "orderItemSeqId", shipmentPlan.orderItemSeqId).orderBy("workEffortId").queryList(); // TODO: add shipmentId - weId = EntityUtil.getFirst(weIds); - productionRunTree = [] as ArrayList; + weIds = from("WorkOrderItemFulfillment").where("orderId", shipmentPlan.orderId, "orderItemSeqId", shipmentPlan.orderItemSeqId).orderBy("workEffortId").queryList() // TODO: add shipmentId + weId = EntityUtil.getFirst(weIds) + productionRunTree = [] as ArrayList // TODO if (weId) { - ProductionRunHelper.getLinkedProductionRuns(delegator, dispatcher, weId.workEffortId, productionRunTree); + ProductionRunHelper.getLinkedProductionRuns(delegator, dispatcher, weId.workEffortId, productionRunTree) for (int i = 0; i < productionRunTree.size(); i++) { - oneProductionRun = (ProductionRun)productionRunTree.get(i); + oneProductionRun = (ProductionRun)productionRunTree.get(i) if (ProductionRunHelper.hasTask(delegator, selectWorkEffortNameParameter, oneProductionRun.getGenericValue().workEffortId)) { - product = oneProductionRun.getProductProduced(); - primaryCategory = product.primaryProductCategoryId; + product = oneProductionRun.getProductProduced() + primaryCategory = product.primaryProductCategoryId if (primaryCategory && selectPrimaryCategoryIdParameter.equals(primaryCategory)) { - productId = product.productId; - productIdToProduct.put(productId, product); + productId = product.productId + productIdToProduct.put(productId, product) if (!productIdToQuantity.containsKey(productId)) { - productIdToQuantity.put(productId, 0.0); + productIdToQuantity.put(productId, 0.0) } - qty = productIdToQuantity.get(productId); - productIdToQuantity.put(productId, oneProductionRun.getGenericValue().quantityToProduce + qty); + qty = productIdToQuantity.get(productId) + productIdToQuantity.put(productId, oneProductionRun.getGenericValue().quantityToProduce + qty) } } } } } productIdToProduct.values().each { product -> - heightD = product.productHeight; - height = 0; + heightD = product.productHeight + height = 0 if (heightD) { - height = (heightD * 1000) as int; + height = (heightD * 1000) as int } - widthD = product.productWidth; - width = 0; + widthD = product.productWidth + width = 0 if (widthD) { - width = (widthD * 1000) as int; + width = (widthD * 1000) as int } - Dimension dim = new Dimension(width, height); + Dimension dim = new Dimension(width, height) if (!dimensionToProducts.containsKey(dim)) { - dimensionToProducts.put(dim, new ArrayList()); + dimensionToProducts.put(dim, new ArrayList()) } - prodList = (List)dimensionToProducts.get(dim); - prodList.add(product); + prodList = (List)dimensionToProducts.get(dim) + prodList.add(product) // tot qty per dimension if (!dimensionToQuantity.containsKey(dim)) { - dimensionToQuantity.put(dim, 0.0); + dimensionToQuantity.put(dim, 0.0) } - qty = dimensionToQuantity[dim]; - dimensionToQuantity.put(dim, productIdToQuantity[product.productId] + qty); + qty = dimensionToQuantity[dim] + dimensionToQuantity.put(dim, productIdToQuantity[product.productId] + qty) } // // // - list1 = [] as ArrayList; + list1 = [] as ArrayList dimensionToProducts.keySet().each { dim -> - map1 = [:]; - list1.add(map1); - map1.width = (dim.getWidth() / 1000); - map1.height = (dim.getHeight() / 1000); - map1.quantity = dimensionToQuantity.get(dim); - list2 = [] as ArrayList; - map1.products = list2; - products = (List)dimensionToProducts.get(dim); + map1 = [:] + list1.add(map1) + map1.width = (dim.getWidth() / 1000) + map1.height = (dim.getHeight() / 1000) + map1.quantity = dimensionToQuantity.get(dim) + list2 = [] as ArrayList + map1.products = list2 + products = (List)dimensionToProducts.get(dim) for (int i = 0; i < products.size(); i++) { - product = products.get(i); - Map map2 = [:]; - list2.add(map2); - map2.product = product; - map2.quantity = productIdToQuantity.get(product.productId); + product = products.get(i) + Map map2 = [:] + list2.add(map2) + map2.product = product + map2.quantity = productIdToQuantity.get(product.productId) } } - context.cuttingList = list1; + context.cuttingList = list1 } \ No newline at end of file Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsComponentsByFeature.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsComponentsByFeature.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsComponentsByFeature.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsComponentsByFeature.groovy Wed Nov 2 19:09:13 2016 @@ -20,100 +20,100 @@ // PRunsComponentsByFeature // ReportF -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.product.category.CategoryWorker; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.product.category.CategoryWorker if (productCategoryIdPar) { - category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne(); - context.category = category; + category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne() + context.category = category } if (productFeatureTypeIdPar) { - featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne(); - context.featureType = featureType; + featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne() + context.featureType = featureType } -allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList(); -productionRuns = []; -features = [:]; // each entry is a productFeatureId|{productFeature,products} -products = [:]; // each entry is a productId|{product,quantity} +allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList() +productionRuns = [] +features = [:] // each entry is a productFeatureId|{productFeature,products} +products = [:] // each entry is a productId|{product,quantity} if (!productFeatureTypeIdPar) { - features.put(null, UtilMisc.toMap("productFeature", null, "products", products)); + features.put(null, UtilMisc.toMap("productFeature", null, "products", products)) } if (allProductionRuns) { allProductionRuns.each { productionRun -> // select the production run's task of a given name (i.e. type) if any (based on the report's parameter) - productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst(); + productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst() if (!productionRunTask) { // the production run doesn't include the given task, skip it - return; + return } // select the task's components, if any - allProductionRunComponents = from("WorkEffortGoodStandard").where("workEffortId", productionRunTask.workEffortId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED").queryList(); + allProductionRunComponents = from("WorkEffortGoodStandard").where("workEffortId", productionRunTask.workEffortId, "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED").queryList() allProductionRunComponents.each { productionRunComponent -> // verify if the product is a member of the given category (based on the report's parameter) if (productCategoryIdPar) { if (!isProductInCategory(delegator, productionRunComponent.productId, productCategoryIdPar)) { // the production run's product is not a member of the given category, skip it - return; + return } } - productionRunProduct = from("Product").where("productId", productionRunComponent.productId).queryOne(); + productionRunProduct = from("Product").where("productId", productionRunComponent.productId).queryOne() - location = null; + location = null if (productionRunProduct) { - location = from("ProductFacilityLocation").where("facilityId", productionRun.facilityId, "productId", productionRunProduct.productId).queryFirst(); + location = from("ProductFacilityLocation").where("facilityId", productionRun.facilityId, "productId", productionRunProduct.productId).queryFirst() } // group by standard feature of type productFeatureTypeIdPar if (productFeatureTypeIdPar) { - standardFeature = from("ProductFeatureAndAppl").where("productFeatureTypeId", productFeatureTypeIdPar, "productId", productionRunComponent.productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryFirst(); - standardFeatureId = null; + standardFeature = from("ProductFeatureAndAppl").where("productFeatureTypeId", productFeatureTypeIdPar, "productId", productionRunComponent.productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryFirst() + standardFeatureId = null if (standardFeature) { - standardFeatureId = standardFeature.productFeatureId; + standardFeatureId = standardFeature.productFeatureId } if (!features.containsKey(standardFeatureId)) { - features.put(standardFeatureId, [productFeature : standardFeature, products : [:]]); + features.put(standardFeatureId, [productFeature : standardFeature, products : [:]]) } - feature = (Map)features.get(standardFeatureId); - products = (Map)feature.products; + feature = (Map)features.get(standardFeatureId) + products = (Map)feature.products } // // populate the products map and sum the quantities // if (!products.containsKey(productionRunComponent.getString("productId"))) { - products.put(productionRunComponent.productId, [product : productionRunProduct, quantity : new Double(0), location : location]); + products.put(productionRunComponent.productId, [product : productionRunProduct, quantity : new Double(0), location : location]) } - Map productMap = (Map)products.get(productionRunComponent.productId); - productMapQty = productMap.quantity; - currentProductQty = productionRunComponent.estimatedQuantity; - productMap.quantity = productMapQty + currentProductQty; + Map productMap = (Map)products.get(productionRunComponent.productId) + productMapQty = productMap.quantity + currentProductQty = productionRunComponent.estimatedQuantity + productMap.quantity = productMapQty + currentProductQty } } // now create lists of products for each feature group - featuresIt = features.values().iterator(); + featuresIt = features.values().iterator() while (featuresIt) { - feature = featuresIt.next(); - productsMap = feature.products; - productsMapIt = productsMap.values().iterator(); + feature = featuresIt.next() + productsMap = feature.products + productsMapIt = productsMap.values().iterator() while (productsMapIt.hasNext()) { - productMap = productsMapIt.next(); + productMap = productsMapIt.next() if (productMap.product.productWidth && productMap.product.productHeight) { - productMapQty = productMap.quantity; - productHeight = productMap.product.productHeight; - productWidth = productMap.product.productWidth; - productArea = (productHeight * productWidth) / (1000 * 1000); - panelQty = 0.0; - int panelQtyInt = 0; - if (productArea > 0) panelQty = productMapQty / productArea; - panelQtyInt = panelQty; - if (panelQtyInt < panelQty) panelQtyInt++; - productMap.panelQuantity = panelQtyInt; + productMapQty = productMap.quantity + productHeight = productMap.product.productHeight + productWidth = productMap.product.productWidth + productArea = (productHeight * productWidth) / (1000 * 1000) + panelQty = 0.0 + int panelQtyInt = 0 + if (productArea > 0) panelQty = productMapQty / productArea + panelQtyInt = panelQty + if (panelQtyInt < panelQty) panelQtyInt++ + productMap.panelQuantity = panelQtyInt } } - feature.productList = productsMap.values(); + feature.productList = productsMap.values() } - context.features = features.values(); + context.features = features.values() } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsInfoAndOrder.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsInfoAndOrder.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsInfoAndOrder.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsInfoAndOrder.groovy Wed Nov 2 19:09:13 2016 @@ -20,17 +20,17 @@ // PRunsInfoAndOrder // ReportG -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunHelper; -import org.apache.ofbiz.order.order.OrderReadHelper; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunHelper +import org.apache.ofbiz.order.order.OrderReadHelper if (productCategoryIdPar) { - category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne(); - context.category = category; + category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne() + context.category = category } -allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUN_PROD_DELIV").orderBy("productId").queryList(); -productionRuns = []; +allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUN_PROD_DELIV").orderBy("productId").queryList() +productionRuns = [] if (allProductionRuns) { allProductionRuns.each { productionRun -> @@ -38,20 +38,20 @@ if (allProductionRuns) { if (productCategoryIdPar) { if (!isProductInCategory(delegator, productionRun.productId, productCategoryIdPar)) { // the production run's product is not a member of the given category, skip it - return; + return } } - productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne(); - String rootProductionRunId = ProductionRunHelper.getRootProductionRun(delegator, productionRun.workEffortId); + productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne() + String rootProductionRunId = ProductionRunHelper.getRootProductionRun(delegator, productionRun.workEffortId) - productionRunOrder = from("WorkOrderItemFulfillment").where("workEffortId", rootProductionRunId).queryFirst(); - OrderReadHelper orh = new OrderReadHelper(delegator, productionRunOrder.orderId); + productionRunOrder = from("WorkOrderItemFulfillment").where("workEffortId", rootProductionRunId).queryFirst() + OrderReadHelper orh = new OrderReadHelper(delegator, productionRunOrder.orderId) // select the production run's task of a given name (i.e. type) if any (based on the report's parameter) - productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst(); + productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst() if (!productionRunTask) { // the production run doesn't include the given task, skip it - return; + return } productionRunMap = [productionRun : productionRun, @@ -59,20 +59,20 @@ if (allProductionRuns) { productionRunTask : productionRunTask, productionRunOrder : productionRunOrder, customer : orh.getPlacingParty(), - address : orh.getShippingAddress()]; - allProductionComponents = from("WorkEffortAndGoods").where("workEffortId", productionRunTask.workEffortId, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED").orderBy("productId").queryList(); + address : orh.getShippingAddress()] + allProductionComponents = from("WorkEffortAndGoods").where("workEffortId", productionRunTask.workEffortId, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUNT_PROD_NEEDED").orderBy("productId").queryList() - componentList = []; + componentList = [] if (allProductionComponents) { allProductionComponents.each { productionComponent -> - productionRunProductComp = from("Product").where("productId", productionComponent.productId).queryOne(); - productionRunProductMap = [component : productionComponent,componentProduct : productionRunProductComp]; - componentList.add(productionRunProductMap); + productionRunProductComp = from("Product").where("productId", productionComponent.productId).queryOne() + productionRunProductMap = [component : productionComponent,componentProduct : productionRunProductComp] + componentList.add(productionRunProductMap) } } - productionRunMap.componentList = componentList; - productionRuns.add(productionRunMap); + productionRunMap.componentList = componentList + productionRuns.add(productionRunMap) } } -context.productionRuns = productionRuns; +context.productionRuns = productionRuns Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsAndOrder.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsAndOrder.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsAndOrder.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsAndOrder.groovy Wed Nov 2 19:09:13 2016 @@ -20,17 +20,17 @@ // PRunsProductsAndOrder // ReportD -import org.apache.ofbiz.entity.util.EntityUtil; -import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunHelper; -import org.apache.ofbiz.order.order.OrderReadHelper; +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.manufacturing.jobshopmgt.ProductionRunHelper +import org.apache.ofbiz.order.order.OrderReadHelper if (productCategoryIdPar) { - category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne(); - context.category = category; + category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne() + context.category = category } -allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUN_PROD_DELIV").orderBy("productId").queryList(); -productionRuns = []; +allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName, "statusId", "WEGS_CREATED", "workEffortGoodStdTypeId", "PRUN_PROD_DELIV").orderBy("productId").queryList() +productionRuns = [] if (allProductionRuns) { allProductionRuns.each { productionRun -> @@ -38,28 +38,28 @@ if (allProductionRuns) { if (productCategoryIdPar) { if (!isProductInCategory(delegator, productionRun.productId, productCategoryIdPar)) { // the production run's product is not a member of the given category, skip it - return; + return } } - productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne(); - String rootProductionRunId = ProductionRunHelper.getRootProductionRun(delegator, productionRun.workEffortId); + productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne() + String rootProductionRunId = ProductionRunHelper.getRootProductionRun(delegator, productionRun.workEffortId) - productionRunOrder = from("WorkOrderItemFulfillment").where("workEffortId", rootProductionRunId).queryFirst(); - OrderReadHelper orh = new OrderReadHelper(delegator, productionRunOrder.orderId); - location = from("ProductFacilityLocation").where("productId", productionRun.productId, "facilityId", productionRun.facilityId).queryFirst(); + productionRunOrder = from("WorkOrderItemFulfillment").where("workEffortId", rootProductionRunId).queryFirst() + OrderReadHelper orh = new OrderReadHelper(delegator, productionRunOrder.orderId) + location = from("ProductFacilityLocation").where("productId", productionRun.productId, "facilityId", productionRun.facilityId).queryFirst() productionRunMap = [productionRun : productionRun, product : productionRunProduct, productionRunOrder : productionRunOrder, customer : orh.getPlacingParty(), address : orh.getShippingAddress(), - location : location]; + location : location] - productionRunMap.plan = planName; - quantity = productionRun.estimatedQuantity; + productionRunMap.plan = planName + quantity = productionRun.estimatedQuantity for (int i = 0; i < quantity; i++) { - productionRuns.add(productionRunMap); + productionRuns.add(productionRunMap) } } } -context.productionRuns = productionRuns; +context.productionRuns = productionRuns Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsByFeature.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsByFeature.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsByFeature.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsByFeature.groovy Wed Nov 2 19:09:13 2016 @@ -20,22 +20,22 @@ // PRunsProductsByFeature // ReportE -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil if (productCategoryIdPar) { - category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne(); - context.category = category; + category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne() + context.category = category } if (productFeatureTypeIdPar) { - featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne(); - context.featureType = featureType; + featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne() + context.featureType = featureType } -allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList(); -productionRuns = [:]; -features = []; +allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList() +productionRuns = [:] +features = [] if (!productFeatureTypeIdPar) { - features.put(null, UtilMisc.toMap("productFeature", null, "productionRuns", productionRuns)); + features.put(null, UtilMisc.toMap("productFeature", null, "productionRuns", productionRuns)) } if (allProductionRuns) { @@ -44,36 +44,36 @@ if (allProductionRuns) { if (productCategoryIdPar) { if (!isProductInCategory(delegator, productionRun.productId, productCategoryIdPar)) { // the production run's product is not a member of the given category, skip it - return; + return } } - productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne(); + productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne() // group by standard feature of type productFeatureTypeIdPar if (productFeatureTypeIdPar) { - standardFeature = from("ProductFeatureAndAppl").where("productFeatureTypeId", productFeatureTypeIdPar, "productId", productionRun.productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryFirst(); - standardFeatureId = null; + standardFeature = from("ProductFeatureAndAppl").where("productFeatureTypeId", productFeatureTypeIdPar, "productId", productionRun.productId, "productFeatureApplTypeId", "STANDARD_FEATURE").filterByDate().queryFirst() + standardFeatureId = null if (standardFeature) { - standardFeatureId = standardFeature.productFeatureId; + standardFeatureId = standardFeature.productFeatureId } if (!features.containsKey(standardFeatureId)) { - features.put(standardFeatureId, [productFeature : standardFeature, productionRuns : []]); + features.put(standardFeatureId, [productFeature : standardFeature, productionRuns : []]) } - feature = (Map)features.standardFeatureId; - productionRuns = (List)feature.productionRuns; + feature = (Map)features.standardFeatureId + productionRuns = (List)feature.productionRuns } // select the production run's task of a given name (i.e. type) if any (based on the report's parameter) - productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst(); + productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId, "workEffortName", taskNamePar).queryFirst() if (!productionRunTask) { // the production run doesn't include the given task, skip it - return; + return } productionRunMap = [productionRun : productionRun, product : productionRunProduct, - productionRunTask : productionRunTask]; - productionRuns.add(productionRunMap); + productionRunTask : productionRunTask] + productionRuns.add(productionRunMap) } - context.features = features.values(); + context.features = features.values() } Modified: ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsStacks.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsStacks.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff ============================================================================== --- ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsStacks.groovy (original) +++ ofbiz/trunk/applications/manufacturing/groovyScripts/reports/PRunsProductsStacks.groovy Wed Nov 2 19:09:13 2016 @@ -20,21 +20,21 @@ // PRunsProductsStacks // ReportC -import org.apache.ofbiz.entity.util.EntityUtil; +import org.apache.ofbiz.entity.util.EntityUtil if (productCategoryIdPar) { - category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne(); - context.category = category; + category = from("ProductCategory").where("productCategoryId", productCategoryIdPar).queryOne() + context.category = category } if (productFeatureTypeIdPar) { - featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne(); - context.featureType = featureType; + featureType = from("ProductFeatureType").where("productFeatureTypeId", productFeatureTypeIdPar).queryOne() + context.featureType = featureType } -allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList(); -productionRuns = []; -features = [:]; -products = [:]; +allProductionRuns = from("WorkEffortAndGoods").where("workEffortName", planName).orderBy("productId").queryList() +productionRuns = [] +features = [:] +products = [:] if (allProductionRuns) { allProductionRuns.each { productionRun -> @@ -42,44 +42,44 @@ if (allProductionRuns) { if (productCategoryIdPar) { if (!isProductInCategory(delegator, productionRun.productId, productCategoryIdPar)) { // the production run's product is not a member of the given category, skip it - return; + return } } - productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne(); - location = [:]; + productionRunProduct = from("Product").where("productId", productionRun.productId).queryOne() + location = [:] if (productionRunProduct) { - location = form("ProductFacilityLocation").where(facilityId : productionRun.facilityId, productId : productionRun.productId).queryFirst(); + location = form("ProductFacilityLocation").where(facilityId : productionRun.facilityId, productId : productionRun.productId).queryFirst() } if (taskNamePar) { // select the production run's task of a given name (i.e. type) if any (based on the report's parameter) - productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId , "workEffortName", taskNamePar).queryFirst(); + productionRunTask = from("WorkEffort").where("workEffortParentId", productionRun.workEffortId , "workEffortName", taskNamePar).queryFirst() if (!productionRunTask) { // the production run doesn't include the given task, skip it - return; + return } } // Stack information - stackInfos = []; - productionRunQty = productionRun.quantityToProduce; - numOfStacks = productionRunQty / stackQty; // number of stacks - numOfStacks = numOfStacks.intValue(); - qtyInLastStack = productionRunQty % stackQty; // qty in the last stack + stackInfos = [] + productionRunQty = productionRun.quantityToProduce + numOfStacks = productionRunQty / stackQty // number of stacks + numOfStacks = numOfStacks.intValue() + qtyInLastStack = productionRunQty % stackQty // qty in the last stack if (qtyInLastStack > 0) { - numOfStacks++; + numOfStacks++ } else { - qtyInLastStack = stackQty; + qtyInLastStack = stackQty } for (int i = 1; i < numOfStacks; i++) { - stackInfos.add([stackNum : "" + i, numOfStacks : "" + numOfStacks, qty : stackQty]); + stackInfos.add([stackNum : "" + i, numOfStacks : "" + numOfStacks, qty : stackQty]) } - stackInfos.add([stackNum : "" + numOfStacks, numOfStacks : "" + numOfStacks, qty : qtyInLastStack]); + stackInfos.add([stackNum : "" + numOfStacks, numOfStacks : "" + numOfStacks, qty : qtyInLastStack]) productionRunMap = [productionRun : productionRun, product : productionRunProduct, location : location, - stackInfos : stackInfos]; - productionRuns.add(productionRunMap); + stackInfos : stackInfos] + productionRuns.add(productionRunMap) } - context.productionRuns = productionRuns; + context.productionRuns = productionRuns } |
Free forum by Nabble | Edit this page |