/** * @param torder * @param order * @param limit * @return * @throws Exception */ public List getDepots(TransportOrderValue torder, OrderValue order, int limit) throws Exception { WaypointValue customerAddress = null; Address seaTerminalAddress = null; long carrierId; long container; boolean pickup; pickup = !order.getIsImportOrder(); container = order.getContainerType().longValue(); carrierId = order.getCarrierId(); // get the needed customer address List waypoints = null; if (pickup) { waypoints = torder.getExportWaypoints(); } else { waypoints = torder.getImportWaypoints(); } log.debug("the length of waypoints: " + waypoints.size()); if (order.getIsImportOrder()) { // last customer for import for (int i = waypoints.size() - 1; i >= 0; i--) { WaypointValue point = (WaypointValue) waypoints.get(i); if (point.getType().equalsIgnoreCase("Customer")) { customerAddress = point; } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) { seaTerminalAddress = point; } } } else { // fist customer for export for (int i = 0; i < waypoints.size(); i++) { WaypointValue point = (WaypointValue) waypoints.get(i); if (point.getType().equalsIgnoreCase("Customer")) { customerAddress = point; } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) { seaTerminalAddress = point; } } } Date fixedDate = customerAddress.getFixedDate(); boolean isExtended = false; // VERSION_TOGGLE FRR.ExtendedDepots Start ---------- if (ResourceUtil.getBoolean("FRR.ExtendedDepots")) { isExtended = true; } // VERSION_TOGGLE FRR.ExtendedDepots End ---------- log.debug( "customer:" + customerAddress + " carrierId: " + carrierId + " container " + container + " pickup " + pickup); return getFacilityManager() .getDepots( customerAddress, seaTerminalAddress, carrierId, container, pickup, fixedDate, limit, isExtended); }
/** * @ejb.interface-method * @ejb.transaction type="Supports" */ public List findSpecialRateLinesByInfo( Boolean isImport, Boolean isExport, Date validFrom, Date validTo, Long[] vendorIds, Long[] seaTerminalIds, String countryName, String zipCodeFrom, String zipCodeTo) throws LocalException { // // check parameters // if (isImport == null && isExport == null) { throw new LocalException("isImport AND isExport must not be null"); } if ((validFrom == null && validTo != null) || (validFrom != null && validTo == null)) { throw new LocalException( "durationFrom AND durationTo must both be null, or both be filled! durationFrom: " + validFrom + " | durationTo: " + validTo); } // if( !(countryName == null && zipCodeFrom == null && zipCodeTo == null) // && !(countryName != null && zipCodeFrom != null && zipCodeTo != null) ) // throw new LocalException("countryName AND zipCodeFrom AND zipCodeTo must all be null, or all // be filled! // countryId: "+countryName+" | zipCodeFrom: "+zipCodeFrom+" | zipCodeTo: "+zipCodeTo); // Reduce ZIP codes to make search result Rate Retrieval queries if (countryName != null) { String countryCode = WaypointValue.getPrefix(countryName); String p = getCache().getParameterAsStringOrDefault("", ""); SuffixZipCodeReduction zcr = new SuffixZipCodeReduction(p); if (zipCodeFrom != null) { zipCodeFrom = zcr.reduce(zipCodeFrom, countryCode, "Customer"); } if (zipCodeTo != null) { zipCodeTo = zcr.reduce(zipCodeTo, countryCode, "Customer"); } } // // build query // SQLQuery query = new SQLQuery( "line.id as id,firstarea.countryid, firstarea.fromzipcode, firstarea.tozipcode, tariff.vendorid as vendorid, vendor.name as vendorname, tariff.isimport as isimport, tariff.facilityid as seaterminal", "specialrate tariff, specialrateline line, rateservicearea area, country, vendor, firstarea", true); query.addWhereClause("and", "tariff.id = line.specialRateId(+)"); query.addWhereClause("and", "line.id = area.specialRateLineId(+)"); query.addWhereClause("and", "area.countryid = country.id"); query.addWhereClause("and", "tariff.vendorid = vendor.id"); query.addWhereClause("and", "line.id = firstarea.specialratelineid(+)"); // if import and export are specified, we don't care, because the field is marked as not null // so if we don't specify it in the where clause, true and false will be found. if (isImport != null && (isExport == null || !isExport.booleanValue())) { query.addWhereClause("and", "tariff.isImport", "=", isImport); } if ((isImport == null || !isImport.booleanValue()) && isExport != null) { query.addWhereClause( "and", "tariff.isImport", "=", isExport.booleanValue() ? Boolean.FALSE : Boolean.TRUE); } query.addWhereClause("and", "tariff.durationFrom", "<=", validTo); query.addWhereClause("and", "tariff.durationTo", ">=", validFrom); if (countryName != null) { query.addWhereClause("and", "country.name", "=", countryName); } if (zipCodeFrom != null && zipCodeTo != null && !zipCodeFrom.equals(zipCodeTo)) { query.addWhereClause("and", "area.fromzipcode", "<=", zipCodeTo); query.addWhereClause("and", "concat(area.tozipcode,'zzzzzz')", ">=", zipCodeFrom); } // bugfix 8982 if ((zipCodeFrom != null && zipCodeTo != null && zipCodeFrom.equals(zipCodeTo)) || (zipCodeFrom != null && zipCodeTo == null)) { query.addWhereClause("and", "area.fromzipcode", "=", zipCodeFrom); } // // build nested vendor query // if (vendorIds != null && vendorIds.length > 0) { SQLQuery nestedVendorQuery = new SQLQuery(true); nestedVendorQuery.addWhereClause("or", "tariff.vendorid", "=", vendorIds); query.addWhereClause("and", nestedVendorQuery); } // // build nested seaterminal query // if (seaTerminalIds != null && seaTerminalIds.length > 0) { SQLQuery nestedSeaterminalQuery = new SQLQuery(true); nestedSeaterminalQuery.addWhereClause("or", "tariff.facilityid", "=", seaTerminalIds); query.addWhereClause("and", nestedSeaterminalQuery); } if (log.isInfoEnabled()) log.info(query.getSQLDebugString()); // // execute query // ResultSet result = null; PreparedStatement stmt = null; Connection con = null; List truckTariffLines = new CompressedSerializedList(); try { con = getConnection(); stmt = query.getPreparedStatement(con); result = stmt.executeQuery(); SpecialRateLineManagerLocal srlm = (SpecialRateLineManagerLocal) SpecialRateLineManagerUtil.getLocalHome().create(); while (result.next()) { long tariffLineId = result.getLong("id"); SpecialRateLineValue ttlv = (SpecialRateLineValue) srlm.findByPrimaryKey(new SpecialRateLinePK(new Long(tariffLineId))); // fill vendor name ttlv.vendorName = result.getString("vendorname"); ttlv.seaterminalID = result.getLong("seaterminal"); ttlv.importTariff = result.getBoolean("isimport") ? Boolean.TRUE : Boolean.FALSE; ttlv.firstCountryId = new Long(result.getLong("countryid")); ttlv.firstzipFrom = result.getString("fromzipcode"); ttlv.firstzipTo = result.getString("tozipcode"); truckTariffLines.add(ttlv); } } catch (Exception ex) { log.warn(StackTraceUtil.getStackTrace(ex)); throw new LocalException(ex); } finally { closeQuietly(result, stmt, con); } return truckTariffLines; }
/** * @param order * @param limit * @return * @throws Exception */ public List getDepots(OrderValue order, int limit) throws Exception { log.debug("getDepots, order: " + order); WaypointValue customerAddress = null; WaypointValue seaTerminalAddress = null; long carrierId; long container; // long containerType; boolean pickup; pickup = !order.getIsImportOrder(); container = order.getContainerType().longValue(); carrierId = order.getCarrierId(); // containerType = order.getContainerType().longValue(); // get the needed customer address List waypoints = order.getWaypoints(); log.info("Waypointcount: " + waypoints.size() + " limit: " + limit); // boolean isSpecial = false; // CarrierValue carrier = // (CarrierValue)CarrierService.getInstance().findByPrimaryKey(new // CarrierPK(new // Long(carrierId))); // long special = carrier.getHinterlandEquipmentChange(); // isSpecial = (special&containerType)!=0; // if (!isSpecial){ if (order.getIsImportOrder()) { // last customer for import for (int i = waypoints.size() - 1; i >= 0; i--) { WaypointValue point = (WaypointValue) waypoints.get(i); if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_CUSTOMER)) { customerAddress = point; } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) { seaTerminalAddress = point; } } } else { // fist customer for export for (int i = 0; i < waypoints.size(); i++) { WaypointValue point = (WaypointValue) waypoints.get(i); if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_CUSTOMER)) { customerAddress = point; } else if (point.getType().equalsIgnoreCase(Constants.WAYPOINT_TYPE_SEATERMINAL)) { seaTerminalAddress = point; } } } Date fixedDate = customerAddress.getFixedDate(); boolean isExtended = false; // VERSION_TOGGLE FRR.ExtendedDepots Start ---------- if (ResourceUtil.getBoolean("FRR.ExtendedDepots")) { isExtended = true; } // VERSION_TOGGLE FRR.ExtendedDepots End ---------- return getFacilityManager() .getDepots( customerAddress, seaTerminalAddress, carrierId, container, pickup, fixedDate, limit, isExtended); }