--- dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java 2015/07/13 10:16:41 2597 +++ dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java 2015/08/10 08:59:14 2641 @@ -102,6 +102,8 @@ "LEFT JOIN bogleveringer.postnummerdistributor p on (a.postnr=p.postnr) " + "WHERE rute IS NULL " + //Ingen dækning "AND a.postnr BETWEEN ? AND ? " + + "AND a.postnr NOT BETWEEN 3900 and 3999 " + //Skip greenland + "AND a.postnr NOT BETWEEN 9000 AND 9499 " + // Skip nordjylland (DAO) "AND latitude IS NOT NULL " + "AND longitude IS NOT NULL " + "AND gadeid IS NOT NULL " + @@ -297,163 +299,5 @@ return conn; } - - // ////////////////////////////////////////////////////////////////// - - /* - public Queue hentIkkedaekkedeAdresserCache(short postnr) { - List postListe = ikkeDaekkedePrPost.get(postnr); - - return new ConcurrentLinkedQueue(postListe); - } - - public Adresse[] hentDaekkedeAdresserCache( BoundingBox bbox, Adresse adresseListe[] ) { - long start = System.currentTimeMillis(); - ArrayList list = new ArrayList(); - for (Adresse a : adresseListe) { - if ( a.latitude > bbox.latitudeMin && a.latitude< bbox.latitudeMax && a.longitude> bbox.longitudeMin && a.longitude < bbox.longitudeMax) { - list.add(a); - } - } - long stop = System.currentTimeMillis(); - logger.info("Elapsed cache: " + (stop - start)); - return list.toArray( new Adresse[ list.size() ] ); - } - - - /*public Adresse[] hentDaekkedeAdresserCache( BoundingBox bbox) { - return hentDaekkedeAdresserCache(bbox, alleAdresser); - }*/ - - /* - @Deprecated - private BoundingBox getBoundingboxFromDb_old(String postnr) throws SQLException { - String minPostnr = postnr.replace('x', '0'); - String maxPostnr = postnr.replace('x', '9'); - - String sql = - "SELECT max(latitude) latmax, min(latitude) latmin, max(longitude) lngmax,min(longitude) lngmin " + - "FROM fulddaekning.adressetabel WHERE postnr BETWEEN ? and ? and rute is null;"; - - PreparedStatement stmt = conn.prepareStatement(sql); - stmt.setString(1, minPostnr); - stmt.setString(2, maxPostnr); - - ResultSet res = stmt.executeQuery(); - res.next(); //query returnerer altid 1 række - - BoundingBox bbox = new BoundingBox(); - bbox.latitudeMax = res.getDouble("latmax"); - bbox.latitudeMin = res.getDouble("latmin"); - bbox.longitudeMax = res.getDouble("lngmax"); - bbox.longitudeMin = res.getDouble("lngmin"); - - res.close(); - stmt.close(); - - return bbox; - } - - @Deprecated - public Adresse[] hentDaekkedeAdresser_old( BoundingBox bbox) throws SQLException { - long start = System.currentTimeMillis(); - String sql = "SELECT id,a.postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,p.distributor as ho " + - "FROM fulddaekning.adressetabel a " + - "LEFT JOIN bogleveringer.postnummerdistributor p on (a.postnr=p.postnr) " + - "WHERE rute IS NOT NULL " + - "AND latitude BETWEEN ? AND ? " + - "AND longitude BETWEEN ? AND ? " + - "AND a.distributor = ? "; - - // Forward only + concur_read_only + fetchsize tvinger driver til at hente en række af gangen (bedre performance ved store result sets) - // Se http://dev.mysql.com/doc/connector-j/en/connector-j-reference-implementation-notes.html - //PreparedStatement stmt = conn.prepareStatement(sql); - PreparedStatement stmt = conn.prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); - stmt.setFetchSize(Integer.MIN_VALUE); - - stmt.setDouble(1, bbox.latitudeMin); - stmt.setDouble(2, bbox.latitudeMax); - stmt.setDouble(3, bbox.longitudeMin); - stmt.setDouble(4, bbox.longitudeMax); - stmt.setString(5, LookupMain.distributor); - - List list = hentAdresseListe( stmt ); - long stop = System.currentTimeMillis(); - logger.info("Elapsed DB: " + (stop - start)); - return list.toArray( new Adresse[ list.size() ] ); - } - - @Deprecated - public Queue hentIkkedaekkedeAdresser_old(String postnr) throws SQLException { - String minPostnr = postnr.replace('x', '0'); - String maxPostnr = postnr.replace('x', '9'); - - ConcurrentLinkedQueue queue = new ConcurrentLinkedQueue(); - - String sql = "SELECT id,a.postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,p.distributor as ho " + - "FROM fulddaekning.adressetabel a " + - "LEFT JOIN bogleveringer.postnummerdistributor p on (a.postnr=p.postnr) " + - "WHERE rute IS NULL " + //Ingen dækning - "AND a.postnr BETWEEN ? AND ? " + - "AND latitude IS NOT NULL " + - "AND longitude IS NOT NULL " + - "AND gadeid IS NOT NULL " + - "AND (a.distributor IS NULL OR a.distributor<>'LUKKET') "; - PreparedStatement stmt = conn.prepareStatement(sql); - stmt.setString(1, minPostnr); - stmt.setString(2, maxPostnr); - - queue.addAll( hentAdresseListe( stmt ) ); - return queue; - } - - @Deprecated - public List hentPostnumre_old() throws SQLException { - ArrayList list = new ArrayList(); - - Constants consts = Constants.getInstance(); - - /* - String sql = "SELECT postnr " + - "FROM fulddaekning.adressetabel " + - "WHERE postnr BETWEEN ? AND ? " + - "AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser - "GROUP BY postnr " + - "ORDER by postnr"; - * / - - - String sql = "SELECT rpad(left(postnr,?),'4', 'x') as postnr2 " + - "FROM fulddaekning.adressetabel " + - "WHERE postnr BETWEEN ? AND ? " + - "AND rute is null " + // Trae kun liste paa postnumre hvor der er ikke-daekede adresser - "AND (postnr NOT BETWEEN 3900 and 3999) " + //Skip alle groenlandske postnumre - "GROUP BY postnr2 " + - "ORDER by postnr2 "; - - - - PreparedStatement stmt = conn.prepareStatement(sql); - //stmt.setString(1, Lookup.distributor ); - - stmt.setInt(1, consts.getPostnrGroup() ); - - stmt.setInt(2, consts.getMinPostnr()); - stmt.setInt(3, consts.getMaxPostnr()); - ResultSet res = stmt.executeQuery(); - - while (res.next()) { - String postnr = res.getString("postnr2"); - list.add(postnr); - } - res.close(); - stmt.close(); - - //list.add(8700); - - return list; - }*/ - - }