/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2237 by torben, Tue Dec 9 15:49:43 2014 UTC revision 2238 by torben, Tue Dec 9 20:39:45 2014 UTC
# Line 58  public class Database { Line 58  public class Database {
58                  conn.createStatement().executeUpdate(sql);                                conn.createStatement().executeUpdate(sql);              
59          }                }      
60    
61          public BoundingBox getBoundingbox(int postnr) throws SQLException {          public BoundingBox getBoundingbox(String postnr) throws SQLException {
62                    String minPostnr = postnr.replace("x", "0");
63                    String maxPostnr = postnr.replace("x", "9");
64    
65                  String sql =                  String sql =
66                                  "SELECT max(latitude) latmax, min(latitude) latmin, max(longitude) lngmax,min(longitude) lngmin  " +                                  "SELECT max(latitude) latmax, min(latitude) latmin, max(longitude) lngmax,min(longitude) lngmin  " +
67                                  "FROM fulddaekning.adressetabel WHERE postnr=? and rute is null;";                                  "FROM fulddaekning.adressetabel WHERE postnr BETWEEN ? and ? and rute is null;";
68    
69                  PreparedStatement stmt = conn.prepareStatement(sql);                  PreparedStatement stmt = conn.prepareStatement(sql);
70                  stmt.setInt(1, postnr);                  stmt.setString(1, minPostnr);
71                    stmt.setString(2, maxPostnr);
72    
73                  ResultSet res = stmt.executeQuery();                  ResultSet res = stmt.executeQuery();
74                  res.next(); //query returnerer altid 1 række                  res.next(); //query returnerer altid 1 række
# Line 82  public class Database { Line 85  public class Database {
85                  return bbox;                  return bbox;
86          }          }
87    
88          public Queue<Adresse> hentIkkedaekkedeAdresser(int postnr)  throws SQLException {          public Queue<Adresse> hentIkkedaekkedeAdresser(String postnr)  throws SQLException {
89                    
90                    String minPostnr = postnr.replace("x", "0");
91                    String maxPostnr = postnr.replace("x", "9");
92                    
93                  ConcurrentLinkedQueue<Adresse> queue = new ConcurrentLinkedQueue<Adresse>();                  ConcurrentLinkedQueue<Adresse> queue = new ConcurrentLinkedQueue<Adresse>();
94    
95                  String sql = "SELECT id,a.postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,p.distributor as ho " +                  String sql = "SELECT id,a.postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,p.distributor as ho " +
96                                  "FROM fulddaekning.adressetabel a " +                                  "FROM fulddaekning.adressetabel a " +
97                                  "LEFT JOIN bogleveringer.postnummerdistributor p on (a.postnr=p.postnr) " +                                  "LEFT JOIN bogleveringer.postnummerdistributor p on (a.postnr=p.postnr) " +
98                                  "WHERE rute IS NULL " +  //Ingen dækning                                  "WHERE rute IS NULL " +  //Ingen dækning
99                                  "AND a.postnr=?  " +                                  "AND a.postnr BETWEEN ? AND ? " +
100                                  "AND latitude IS NOT NULL " +                                  "AND latitude IS NOT NULL " +
101                                  "AND longitude IS NOT NULL " +                                  "AND longitude IS NOT NULL " +
102                                  "AND gadeid IS NOT NULL " +                                  "AND gadeid IS NOT NULL " +
103                                  "AND (a.distributor IS NULL OR a.distributor<>'LUKKET') ";                                                "AND (a.distributor IS NULL OR a.distributor<>'LUKKET') ";              
104                  PreparedStatement stmt = conn.prepareStatement(sql);                  PreparedStatement stmt = conn.prepareStatement(sql);
105                  stmt.setInt(1, postnr);                  stmt.setString(1, minPostnr);
106                    stmt.setString(2, maxPostnr);
107    
108                  queue.addAll( hentAdresseListe( stmt ) );                  queue.addAll( hentAdresseListe( stmt ) );
109                  return queue;                  return queue;
110          }          }
111    
112          public List<Integer> hentPostnumre() throws SQLException {          public List<String> hentPostnumre() throws SQLException {
113                  ArrayList<Integer> list = new ArrayList<Integer>();                  ArrayList<String> list = new ArrayList<String>();
114                                    
115                  Constants consts = Constants.getInstance();                  Constants consts = Constants.getInstance();
116    
117                    /*
118                  String sql = "SELECT postnr " +                  String sql = "SELECT postnr " +
119                                           "FROM fulddaekning.adressetabel " +                                           "FROM fulddaekning.adressetabel " +
120                                           "WHERE postnr BETWEEN ? AND ? " +                                           "WHERE postnr BETWEEN ? AND ? " +
121                                           "AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser                                           "AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser
122                                           "GROUP BY postnr " +                                           "GROUP BY postnr " +
123                                           "ORDER by postnr";                                           "ORDER by postnr";
124                    */
125                    
126                    
127                    String sql = "SELECT concat(left(postnr,3),'x') as postnr2 " +
128                                             "FROM fulddaekning.adressetabel " +
129                                             "WHERE postnr BETWEEN ? AND ? " +
130                                             "AND rute is null " + // Træk kun liste på postnumre hvor der er ikke-dækkede adresser
131                                             "GROUP BY postnr2 " +
132                                             "ORDER by postnr2 ";
133                    
134                                            
135                                            
136                  PreparedStatement stmt = conn.prepareStatement(sql);                  PreparedStatement stmt = conn.prepareStatement(sql);
137                  //stmt.setString(1, Lookup.distributor );                  //stmt.setString(1, Lookup.distributor );
138                  stmt.setInt(1, consts.getMinPostnr());                  stmt.setInt(1, consts.getMinPostnr());
# Line 120  public class Database { Line 140  public class Database {
140                  ResultSet res = stmt.executeQuery();                  ResultSet res = stmt.executeQuery();
141    
142                  while (res.next()) {                  while (res.next()) {
143                          int postnr = res.getInt("postnr");                          String postnr = res.getString("postnr2");
144                          list.add(postnr);                          list.add(postnr);
145                  }                  }
146                  res.close();                  res.close();

Legend:
Removed from v.2237  
changed lines
  Added in v.2238

  ViewVC Help
Powered by ViewVC 1.1.20