📄 findorders.bsh
字号:
paramList = paramList + "&correspondingPoId=" + correspondingPoId; entityName= "OrderHeaderItemAndRoles"; andExprs.add(new EntityExpr("correspondingPoId", EntityOperator.EQUALS, correspondingPoId)); } productId = request.getParameter("productId"); if (productId != null && productId.length() > 0) { paramList = paramList + "&productId=" + productId; entityName = "OrderHeaderItemAndRoles"; andExprs.add(new EntityExpr("productId", EntityOperator.EQUALS, ProductWorker.findProductId(delegator, productId))); } hasBackOrders = request.getParameter("hasBackOrders"); if (hasBackOrders != null && "Y".equals(hasBackOrders)) { paramList = paramList + "&hasBackOrders=Y"; entityName = "OrderHeaderItemAndInvRoles"; andExprs.add(new EntityExpr("quantityNotAvailable", EntityOperator.NOT_EQUAL, null)); andExprs.add(new EntityExpr("quantityNotAvailable", EntityOperator.GREATER_THAN, new Double(0))); } // define the main condition mainCond = null; // now do the filtering if (lookupErrorMessage == null) { roleType = request.getParameter("roleTypeId"); orderType = request.getParameter("orderTypeId"); orderStatus = request.getParameter("orderStatusId"); productStoreId = request.getParameter("productStoreId"); webSiteId = request.getParameter("webSiteId"); salesChannelEnumId = request.getParameter("salesChannelEnumId"); createdBy = request.getParameter("createdBy"); externalId = request.getParameter("externalId"); internalCode = request.getParameter("internalCode"); billAcct = request.getParameter("billingAccountId"); minDate = request.getParameter("minDate"); maxDate = request.getParameter("maxDate"); if (productStoreId == null) productStoreId = "ANY"; if (webSiteId == null) webSiteId = "ANY"; if (roleType == null) roleType = "ANY"; if (orderType == null) orderType = "ANY"; if (orderStatus == null) orderStatus = "ANY"; if (salesChannelEnumId == null) salesChannelEnumId = "ANY"; paramList = paramList + "&productStoreId=" + productStoreId; if (!"ANY".equals(productStoreId)) { andExprs.add(new EntityExpr("productStoreId", EntityOperator.EQUALS, productStoreId)); } paramList = paramList + "&webSiteId=" + webSiteId; if (!"ANY".equals(webSiteId)) { andExprs.add(new EntityExpr("webSiteId", EntityOperator.EQUALS, webSiteId)); } paramList = paramList + "&roleTypeId=" + roleType; if (!"ANY".equals(roleType)) { entityName = "OrderHeaderAndRoles"; andExprs.add(new EntityExpr("roleTypeId", EntityOperator.EQUALS, roleType)); } paramList = paramList + "&orderTypeId=" + orderType; if (!"ANY".equals(orderType)) { andExprs.add(new EntityExpr("orderTypeId", EntityOperator.EQUALS, orderType)); } paramList = paramList + "&orderStatusId=" + orderStatus; if (!"ANY".equals(orderStatus)) { andExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, orderStatus)); } paramList = paramList + "&salesChannelEnumId=" + salesChannelEnumId; if (!"ANY".equals(salesChannelEnumId)) { andExprs.add(new EntityExpr("salesChannelEnumId", EntityOperator.EQUALS, salesChannelEnumId)); } if (billAcct != null && billAcct.length() > 0) { paramList = paramList + "&billingAccountId=" + billAcct; andExprs.add(new EntityExpr("billingAccountId", EntityOperator.EQUALS, billAcct)); } if (createdBy != null && createdBy.length() > 0) { paramList = paramList + "&createdBy=" + createdBy; andExprs.add(new EntityExpr("createdBy", EntityOperator.EQUALS, createdBy)); } if (externalId != null && externalId.length() > 0) { paramList = paramList + "&externalId=" + externalId; andExprs.add(new EntityExpr("externalId", EntityOperator.EQUALS, externalId)); } if (internalCode != null && internalCode.length() > 0) { paramList = paramList + "&internalCode=" + internalCode; andExprs.add(new EntityExpr("internalCode", EntityOperator.EQUALS, internalCode)); } if (minDate != null && minDate.length() > 8) { minDate = minDate.trim(); if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000"; paramList = paramList + "&minDate=" + minDate; andExprs.add(new EntityExpr("orderDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null))); } if (maxDate != null && maxDate.length() > 8) { maxDate = maxDate.trim(); if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999"; paramList = paramList + "&maxDate=" + maxDate; andExprs.add(new EntityExpr("orderDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null))); } if (andExprs.size() > 0 || showAll.equalsIgnoreCase("Y")) mainCond = new EntityConditionList(andExprs, EntityOperator.AND); } else { Debug.log("Error messages: " + lookupErrorMessage, module); } // do the lookup if (lookupErrorMessage == null && mainCond != null) { // field we need to select; will be used to set distinct List fieldsToSelect = UtilMisc.toList("orderId", "orderTypeId", "orderDate", "currencyUom", "grandTotal", "remainingSubTotal"); fieldsToSelect.add("statusId"); if (!"OrderHeader".equals(entityName)) { if (partyId != null && partyId.length() > 0) { fieldsToSelect.add("partyId"); } if (!"ANY".equals(roleType)) { fieldsToSelect.add("roleTypeId"); } } // sorting by order date newest first List orderBy = UtilMisc.toList("-orderDate", "-orderId"); // set distinct on so we only get one row per order EntityFindOptions findOpts = new EntityFindOptions(true, EntityFindOptions.TYPE_SCROLL_INSENSITIVE, EntityFindOptions.CONCUR_READ_ONLY, true); boolean beganTransaction = false; try { beganTransaction = TransactionUtil.begin(); // using list iterator EntityListIterator ohli = delegator.findListIteratorByCondition(entityName, mainCond, null, fieldsToSelect, orderBy, findOpts); // get the indexes for the partial list lowIndex = (((viewIndex - 1) * viewSize) + 1); highIndex = viewIndex * viewSize; // attempt to get the full size ohli.last(); orderHeaderListSize = ohli.currentIndex(); if (highIndex > orderHeaderListSize) { highIndex = orderHeaderListSize; } // get the partial list for this page ohli.beforeFirst(); if (orderHeaderListSize > viewSize) { orderHeaderList = ohli.getPartialList(lowIndex, viewSize); //Debug.log("Got partial list [" + lowIndex + " / " + viewSize + "] : " + orderHeaderList); } else if (orderHeaderListSize > 0) { orderHeaderList = ohli.getCompleteList(); //Debug.log("Got full list [" + orderHeaderList.size() + "] : " + orderHeaderList); } else { orderHeaderList = new ArrayList(); } // close the iterator ohli.close(); } catch (GenericEntityException e) { String errMsg = "Failure in operation, rolling back transaction"; Debug.logError(e, errMsg, module); try { // only rollback the transaction if we started one... TransactionUtil.rollback(beganTransaction, errMsg, e); } catch (GenericEntityException e2) { Debug.logError(e2, "Could not rollback transaction: " + e2.toString(), module); } // after rolling back, rethrow the exception throw e; } finally { // only commit the transaction if we started one... this will throw an exception if it fails TransactionUtil.commit(beganTransaction); } } else { orderHeaderList = new ArrayList(); orderHeaderListSize = 0; } // viewing of purchase orders requires a special permission. if user doesn't have it, only SALES_ORDER if (!security.hasEntityPermission("ORDERMGR", "_PURCHASE_VIEW", session)) { orderHeaderList = EntityUtil.filterOutByCondition(orderHeaderList, new EntityExpr("orderTypeId", EntityOperator.EQUALS, "PURCHASE_ORDER")); } context.put("orderHeaderList", orderHeaderList); context.put("orderHeaderListSize", orderHeaderListSize); if (lookupErrorMessage != null) { context.put("lookupErrorMessage", lookupErrorMessage); }}context.put("paramList", paramList);context.put("highIndex", highIndex);context.put("lowIndex", lowIndex);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -