18 |
|
|
19 |
public class DatabaseLayer { |
public class DatabaseLayer { |
20 |
|
|
21 |
|
static boolean DEBUG = false; |
22 |
|
|
23 |
public static List<Address> getAllAdresses() throws SQLException { |
public static List<Address> getAllAdresses() throws SQLException { |
24 |
|
String debugFilter = DatabaseLayer.DEBUG ? " AND postnr = 8700 " : ""; |
25 |
|
|
26 |
String sql = "SELECT id,vejnavn,husnr,husnrbogstav,kommunekode,vejkode,postnr,gadeid,upper(distributor) AS distributor,dbkbane,koreliste,rute " |
String sql = "SELECT id,vejnavn,husnr,husnrbogstav,kommunekode,vejkode,postnr,gadeid,upper(distributor) AS distributor,dbkbane,koreliste,rute " |
27 |
+ "FROM fulddaekning.adressetabel " |
+ "FROM fulddaekning.adressetabel " |
28 |
+ "WHERE gadeid IS NOT NULL " |
+ "WHERE gadeid IS NOT NULL " |
29 |
//+ "AND postnr = 8700" //DEBUG only |
+ debugFilter |
30 |
; |
; |
31 |
|
|
32 |
Connection conn = DBConnection.getConnection(); |
Connection conn = DBConnection.getConnection(); |
79 |
} |
} |
80 |
|
|
81 |
public static List<ExtendedBean> getExtendedAdresslist() throws SQLException { |
public static List<ExtendedBean> getExtendedAdresslist() throws SQLException { |
82 |
|
String debugFilter1 = DatabaseLayer.DEBUG ? " WHERE orgPostnr = 8700 " : ""; |
83 |
|
String debugFilter2 = DatabaseLayer.DEBUG ? " AND orgPostnr = 8700 " : ""; |
84 |
|
|
85 |
|
|
86 |
String sql = "select orgid, a.id as targetid, afstand, LOWER(type) as type from fulddaekning.afstand_anden_rute a " + |
String sql = "select orgid, a.id as targetid, afstand, LOWER(type) as type from fulddaekning.afstand_anden_rute a " + |
87 |
"join odbc.transporttype t " + |
"join odbc.transporttype t " + |
88 |
"on t.Art = 'Transpost' " + |
"on t.Art = 'Transpost' " + |
89 |
"and ( (t.Type = 'Cykel' and a.Afstand < 1.001) or (t.Type = 'Scooter' and a.Afstand < 1.201) or (t.Type = 'Bil' and a.Afstand < 2.601) ) " + |
"and ( (t.Type = 'Cykel' and a.Afstand < 1.001) or (t.Type = 'Scooter' and a.Afstand < 1.201) or (t.Type = 'Bil' and a.Afstand < 2.601) ) " + |
90 |
"and t.Rute = a.Rute " + |
"and t.Rute = a.Rute " + |
91 |
|
debugFilter1 + |
92 |
|
|
93 |
"UNION ALL " + |
"UNION ALL " + |
94 |
|
|
95 |
"SELECT orgid, a.id as targetid, afstand,'' as type FROM fulddaekning.afstand_anden_rute_bk a " + |
"SELECT orgid, a.id as targetid, afstand,'' as type FROM fulddaekning.afstand_anden_rute_bk a " + |
96 |
"left join bogleveringer.postnummerdistributor d on d.PostNr = a.orgPostnr " + |
"left join bogleveringer.postnummerdistributor d on d.PostNr = a.orgPostnr " + |
97 |
"WHERE d.Distributor <> 10057" |
"WHERE d.Distributor <> 10057 " + |
98 |
|
debugFilter2 |
99 |
; |
; |
100 |
|
|
101 |
Connection conn = DBConnection.getConnection(); |
Connection conn = DBConnection.getConnection(); |