📄 orderview.bsh
字号:
context.put("statusChange", statusChange); currentStatus = orderHeader.getRelatedOne("StatusItem"); context.put("currentStatus", currentStatus); orderHeaderStatuses = orderReadHelper.getOrderHeaderStatuses(); context.put("orderHeaderStatuses", orderHeaderStatuses); adjustmentTypes = delegator.findAll("OrderAdjustmentType", UtilMisc.toList("description")); context.put("orderAdjustmentTypes", adjustmentTypes); notes = delegator.findByAnd("OrderHeaderNoteView", UtilMisc.toMap("orderId", orderId), UtilMisc.toList("-noteDateTime")); context.put("orderNotes", notes); cmvm = ContactMechWorker.getOrderContactMechValueMaps(delegator, orderId); context.put("orderContactMechValueMaps", cmvm); if ("PURCHASE_ORDER".equals(orderType)) { // for purchase orders, we need also the supplier's postal address GenericValue supplier = orderReadHelper.getBillFromParty(); if (supplier != null) { List supplierContactMechValueMaps = ContactMechWorker.getPartyContactMechValueMaps(delegator, supplier.getString("partyId"), false, "POSTAL_ADDRESS"); context.put("supplierContactMechValueMaps", supplierContactMechValueMaps); Iterator supplierContactMechValueMapsIt = supplierContactMechValueMaps.iterator(); while (supplierContactMechValueMapsIt.hasNext()) { Map supplierContactMechValueMap = (Map)supplierContactMechValueMapsIt.next(); List contactMechPurposes = supplierContactMechValueMap.get("partyContactMechPurposes"); Iterator contactMechPurposesIt = contactMechPurposes.iterator(); while (contactMechPurposesIt.hasNext()) { GenericValue contactMechPurpose = (GenericValue)contactMechPurposesIt.next(); if (contactMechPurpose.getString("contactMechPurposeTypeId").equals("GENERAL_LOCATION")) { context.put("supplierGeneralContactMechValueMap", supplierContactMechValueMap); } else if (contactMechPurpose.getString("contactMechPurposeTypeId").equals("SHIPPING_LOCATION")) { context.put("supplierShippingContactMechValueMap", supplierContactMechValueMap); } else if (contactMechPurpose.getString("contactMechPurposeTypeId").equals("BILLING_LOCATION")) { context.put("supplierBillingContactMechValueMap", supplierContactMechValueMap); } else if (contactMechPurpose.getString("contactMechPurposeTypeId").equals("PAYMENT_LOCATION")) { context.put("supplierPaymentContactMechValueMap", supplierContactMechValueMap); } } } } } // see if an approved order with all items completed exists context.put("setOrderCompleteOption", false); if ("ORDER_APPROVED".equals(orderHeader.getString("statusId"))) { expr = new EntityExpr("statusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED"); notCreatedItems = orderReadHelper.getOrderItemsByCondition(expr); if (notCreatedItems.size() == 0) { context.put("setOrderCompleteOption", true); } } // get inventory summary for each shopping cart product item inventorySummary = dispatcher.runSync("getProductInventorySummaryForItems", UtilMisc.toMap("orderItems", orderItems)); context.put("availableToPromiseMap", inventorySummary.get("availableToPromiseMap")); context.put("quantityOnHandMap", inventorySummary.get("quantityOnHandMap")); // get a list of facilities for purchase orders to receive against. These facilities must be owned by the bill-to party of the purchase order. if ("PURCHASE_ORDER".equals(orderType)) { facilities = delegator.findByAndCache("Facility", UtilMisc.toMap("ownerPartyId", orderReadHelper.getBillToParty().getString("partyId"))); context.put("facilities", facilities); } // set the type of return based on type of order if ("SALES_ORDER".equals(orderType)) { context.put("returnHeaderTypeId", "CUSTOMER_RETURN"); // also set the product store facility Id for sales orders context.put("storeFacilityId", orderHeader.getRelatedOne("ProductStore").getString("inventoryFacilityId")); } else { context.put("returnHeaderTypeId", "VENDOR_RETURN"); } // QUANTITY: get the returned quantity by order item map context.put("returnQuantityMap", orderReadHelper.getOrderItemReturnedQuantities()); // INVENTORY: construct a Set of productIds in the order for use in querying for inventory, otherwise these queries can get expensive productIds = new HashSet(); for (iter = orderItems.iterator(); iter.hasNext(); ) { productIds.add(iter.next().getString("productId")); } // INVENTORY: get the production quantity for each product and store the results in a map of productId -> quantity productionMap = new HashMap(); for (iter = productIds.iterator(); iter.hasNext(); ) { productId = iter.next(); if (productId == null) continue; // avoid order items without productIds, such as bulk order items contextInput = UtilMisc.toMap("productId", productId, "userLogin", userLogin); resultOutput = dispatcher.runSync("getProductManufacturingSummaryByFacility", contextInput); manufacturingInQuantitySummaryByFacility = resultOutput.get("summaryInByFacility"); Double productionQuantity = (Double) manufacturingInQuantitySummaryByFacility.get("estimatedQuantityTotal"); productionMap.put(productId, productionQuantity); } context.put("productionProductQuantityMap", productionMap); // INVENTORY: find the number of products in outstanding sales orders for the same product store fieldsToSelect = UtilMisc.toList("productId", "quantity"); condList = UtilMisc.toList( new EntityExpr("orderTypeId", EntityOperator.EQUALS, "SALES_ORDER"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED") ); if (productIds.size() > 0) { condList.add(new EntityExpr("productId", EntityOperator.IN, productIds)); } condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED")); condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")); condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED")); conditions = new EntityConditionList(condList, EntityOperator.AND); List requiredProducts = delegator.findByCondition("OrderReportGroupByProduct", conditions, fieldsToSelect, null); // store the results in a map of productId -> quantity requiredMap = new HashMap(); for (iter = requiredProducts.iterator(); iter.hasNext(); ) { value = iter.next(); requiredMap.put(value.getString("productId"), value.getDouble("quantity")); } context.put("requiredProductQuantityMap", requiredMap); // INVENTORY: find the quantity of each product in outstanding purchase orders fieldsToSelect = UtilMisc.toList("productId", "quantity"); condList = UtilMisc.toList( new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_COMPLETED"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_REJECTED"), new EntityExpr("orderStatusId", EntityOperator.NOT_EQUAL, "ORDER_CANCELLED") ); if (productIds.size() > 0) { condList.add(new EntityExpr("productId", EntityOperator.IN, productIds)); } condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_COMPLETED")); condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_REJECTED")); condList.add(new EntityExpr("orderItemStatusId", EntityOperator.NOT_EQUAL, "ITEM_CANCELLED")); conditions = new EntityConditionList(condList, EntityOperator.AND); List onOrderProducts = delegator.findByCondition("OrderReportGroupByProduct", conditions, fieldsToSelect, null); // store the results in a map of productId -> quantity onOrderMap = new HashMap(); for (iter = onOrderProducts.iterator(); iter.hasNext(); ) { value = iter.next(); onOrderMap.put(value.getString("productId"), value.getDouble("quantity")); } context.put("onOrderProductQuantityMap", onOrderMap);}paramString = "";if (orderId != null) paramString = paramString + "orderId=" + orderId;if (workEffortId != null) paramString = paramString + "&workEffortId=" + workEffortId;if (assignPartyId != null) paramString = paramString + "&partyId=" + assignPartyId;if (assignRoleTypeId != null) paramString = paramString + "&roleTypeId=" + assignRoleTypeId;if (fromDate != null) paramString = paramString + "&fromDate=" + fromDate;context.put("paramString", paramString);workEffortStatus = null;if (workEffortId != null && assignPartyId != null && assignRoleTypeId != null && fromDate != null) { fields = UtilMisc.toMap("workEffortId", workEffortId, "partyId", assignPartyId, "roleTypeId", assignRoleTypeId, "fromDate", fromDate); wepa = delegator.findByPrimaryKey("WorkEffortPartyAssignment", fields); if (wepa != null && wepa.get("statusId") != null && wepa.getString("statusId").equals("CAL_ACCEPTED")) { workEffort = delegator.findByPrimaryKey("WorkEffort", UtilMisc.toMap("workEffortId", workEffortId)); workEffortStatus = workEffort.getString("currentStatusId"); if (workEffortStatus != null) { context.put("workEffortStatus", workEffortStatus); if (workEffortStatus.equals("WF_RUNNING") || workEffortStatus.equals("WF_SUSPENDED")) context.put("inProcess", new Boolean(true)); } if (workEffort != null) { if ((delegate != null && delegate.equals("true")) || (workEffortStatus != null && workEffortStatus.equals("WF_RUNNING"))) { actFields = UtilMisc.toMap("packageId", workEffort.getString("workflowPackageId"), "packageVersion", workEffort.getString("workflowPackageVersion"), "processId", workEffort.getString("workflowProcessId"), "processVersion", workEffort.getString("workflowProcessVersion"), "activityId", workEffort.getString("workflowActivityId")); activity = delegator.findByPrimaryKey("WorkflowActivity", actFields); if (activity != null) { transitions = activity.getRelated("FromWorkflowTransition", null, UtilMisc.toList("-transitionId")); context.put("wfTransitions", transitions); } } } }}// list to find all the POSTAL_ADDRESS for the shipment party. orderParty = delegator.findByPrimaryKey("Party", UtilMisc.toMap("partyId", partyId));shippingContactMechList = ContactHelper.getContactMech(orderParty, "SHIPPING_LOCATION", "POSTAL_ADDRESS", false);context.put("shippingContactMechList",shippingContactMechList);// list to find all the shipmentMethods from the view named "ProductStoreShipmentMethView".if (orderHeader != null) {productStoreId = orderHeader.getRelatedOne("ProductStore").getString("productStoreId");productStoreShipmentMethList = delegator.findByAndCache("ProductStoreShipmentMethView", UtilMisc.toMap("productStoreId", productStoreId), UtilMisc.toList("sequenceNumber"));context.put("productStoreShipmentMethList",productStoreShipmentMethList);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -