11 |
import dk.daoas.daoadresseservice.Address; |
import dk.daoas.daoadresseservice.Address; |
12 |
import dk.daoas.daoadresseservice.AddressUtils; |
import dk.daoas.daoadresseservice.AddressUtils; |
13 |
import dk.daoas.daoadresseservice.DaekningsType; |
import dk.daoas.daoadresseservice.DaekningsType; |
14 |
|
import dk.daoas.daoadresseservice.ExtendedBean; |
15 |
|
|
16 |
public class DatabaseLayer { |
public class DatabaseLayer { |
17 |
|
|
51 |
a.daekningsType = DaekningsType.DAEKNING_IKKEDAEKKET; |
a.daekningsType = DaekningsType.DAEKNING_IKKEDAEKKET; |
52 |
} |
} |
53 |
|
|
54 |
|
if (a.distributor != null) { |
55 |
|
a.distributor = a.distributor.toUpperCase(); |
56 |
|
} |
57 |
|
|
58 |
list.add(a); |
list.add(a); |
59 |
} |
} |
60 |
res.close(); |
res.close(); |
65 |
|
|
66 |
return list; |
return list; |
67 |
} |
} |
68 |
|
|
69 |
|
public static List<ExtendedBean> getExtendedAdresslistDao() throws SQLException { |
70 |
|
String sql = "select orgid, a.id as targetid, afstand,type from fulddaekning.afstand_anden_rute a " + |
71 |
|
"join odbc.transporttype t " + |
72 |
|
"on t.Art = 'Transpost' " + |
73 |
|
"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) ) " + |
74 |
|
"and t.Rute = a.Rute " + |
75 |
|
|
76 |
|
"UNION ALL " + |
77 |
|
|
78 |
|
"SELECT orgid, a.id as targetid, afstand,'' as type FROM fulddaekning.afstand_anden_rute_bk a " + |
79 |
|
"left join bogleveringer.postnummerdistributor d on d.PostNr = a.orgPostnr " + |
80 |
|
"WHERE d.Distributor <> 10057" |
81 |
|
; |
82 |
|
|
83 |
|
Connection conn = DBConnection.getConnection(); |
84 |
|
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); |
85 |
|
ResultSet res = stmt.executeQuery(sql); |
86 |
|
|
87 |
|
List<ExtendedBean> list = new ArrayList<ExtendedBean>(); |
88 |
|
while (res.next()) { |
89 |
|
ExtendedBean eb = new ExtendedBean(); |
90 |
|
eb.orgId = res.getInt(1); |
91 |
|
eb.targetId = res.getInt(2); |
92 |
|
eb.afstand = res.getDouble(3); |
93 |
|
eb.transport = res.getString(4).toLowerCase(); |
94 |
|
|
95 |
|
list.add(eb); |
96 |
|
} |
97 |
|
|
98 |
|
res.close(); |
99 |
|
stmt.close(); |
100 |
|
conn.close(); |
101 |
|
|
102 |
|
System.out.println("Loaded " + list.size() + " extendedbeans"); |
103 |
|
|
104 |
|
return list; |
105 |
|
} |
106 |
|
|
107 |
} |
} |