Commit 3378f58f authored by YONG-LIN SU's avatar YONG-LIN SU

1. 修正路段資料庫規則

2.  新增部分嘉義舊資料轉換表
parent 634cb7f8
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetDropDown">
<runningDeviceTargetSelectedWithDropDown>
<Target>
<type value="RUNNING_DEVICE_TARGET" />
<deviceKey>
<Key>
<type value="SERIAL_NUMBER" />
<value value="577125220043" />
</Key>
</deviceKey>
</Target>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown value="2022-08-30T08:56:53.989060900Z" />
</component>
</project>
\ No newline at end of file
......@@ -35,7 +35,7 @@ public class SelectRoadAdapter extends ListAdapter<Road, SelectRoadAdapter.Selec
public static final DiffUtil.ItemCallback<Road> roadItemCallback = new DiffUtil.ItemCallback<Road>() {
@Override
public boolean areItemsTheSame(@NonNull Road oldItem, @NonNull Road newItem) {
return oldItem.id.equals(newItem.id);
return oldItem.id == newItem.id;
}
@Override
......
......@@ -19,7 +19,7 @@ public interface RoadDao{
LiveData<List<Road>> getAllLiveData();
@Query("SELECT * FROM road WHERE id IN (:Ids)")
List<Road> loadAllByIds(String[] Ids);
List<Road> loadAllByIds(int[] Ids);
@Query("SELECT * FROM road WHERE name LIKE :first LIMIT 1")
Road findByName(String first);
......
......@@ -27,22 +27,22 @@ public interface SpaceDao {
List<Space> getAllByLocation(double latitudeBigger, double latitudeSmaller, double longitudeBigger , double longitudeSmaller);
@Query("SELECT * FROM space WHERE road_id IN (:roadIds) AND id>:spaceId AND id NOT IN (:spaceIds)")
List<Space> getAllByInRoadIdsAndBigThanSpaceIdAndNotInSpaces(String[] roadIds, String spaceId, String[] spaceIds);
List<Space> getAllByInRoadIdsAndBigThanSpaceIdAndNotInSpaces(int[] roadIds, String spaceId, String[] spaceIds);
@Query("SELECT * FROM space WHERE road_id IN (:roadIds) AND id<:spaceId AND id NOT IN (:spaceIds)")
List<Space> getAllByInRoadIdsAndSmallThanSpaceIdAndNotInSpaces(String[] roadIds, String spaceId, String[] spaceIds);
List<Space> getAllByInRoadIdsAndSmallThanSpaceIdAndNotInSpaces(int[] roadIds, String spaceId, String[] spaceIds);
@Query("SELECT * FROM space WHERE road_id IN (:roadIds) AND id NOT IN (:spaceIds)")
List<Space> getAllByInRoadIdsAndNotInSpaceIds(String[] roadIds,String[] spaceIds);
List<Space> getAllByInRoadIdsAndNotInSpaceIds(int[] roadIds,String[] spaceIds);
@Query("SELECT * FROM space WHERE id IN (:Ids)")
List<Space> loadAllByIds(String [] Ids);
@Query("SELECT * FROM space WHERE road_id=:RoadIds")
List<Space> loadAllByRoadId(String RoadIds);
List<Space> loadAllByRoadId(int RoadIds);
@Query("SELECT * FROM space WHERE road_id=:RoadIds")
LiveData<List<Space>> loadAllLiveDataByRoadId(String RoadIds);
LiveData<List<Space>> loadAllLiveDataByRoadId(int RoadIds);
@Insert
void insertAll(Space... spaces);
......
......@@ -14,24 +14,31 @@ import androidx.room.PrimaryKey;
@Entity
public class Road implements Parcelable {
@PrimaryKey
public @NonNull String id;
public @NonNull int id;
@ColumnInfo(name = "code")
public String code; // 路段代號
@ColumnInfo(name = "name")
public String name; // 路段名稱
public Road(String id, String name) {
public Road(int id, String code, String name) {
this.id = id;
this.code = code;
this.name = name;
}
protected Road(Parcel in) {
id = in.readString();
id = in.readInt();
code = in.readString();
name = in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeInt(id);
dest.writeString(code);
dest.writeString(name);
}
......@@ -53,6 +60,7 @@ public class Road implements Parcelable {
};
public String getCombineInfo() {
return String.format("%s %s", id, name);
return String.format("%s %s", code, name);
}
}
......@@ -209,10 +209,16 @@ public class T01ImportDbViewModel extends AndroidViewModel {
infoRepository.roadDao.deleteAll();
for (int i = 0; i < lines.length; i++){
String[] columnString = lines[i].trim().split("[ ]");
if (columnString.length != 2){ break; }
String newId = columnString[0];
String newName = columnString[1];
Road newRoad = new Road(newId, newName);
if (columnString.length != 3){ break; }
int newId;
try {
newId = Integer.parseInt(columnString[0]);
}catch (NumberFormatException exception){
break;
}
String newCode = columnString[1];
String newName = columnString[2];
Road newRoad = new Road(newId,newCode, newName);
infoRepository.roadDao.insertAll(newRoad);
}
});
......@@ -223,9 +229,10 @@ public class T01ImportDbViewModel extends AndroidViewModel {
for (int i = 0; i < lines.length; i++) {
String[] columnString = lines[i].trim().split("[ ]");
if (columnString.length != 7){ break; }
int fee,spaceRateId,spaceTypeId, spaceStatusId;
int spaceRateId,spaceTypeId, spaceStatusId, roadId;
float latitude,longitude;
try {
roadId = Integer.parseInt(columnString[1]);
spaceRateId = Integer.parseInt(columnString[2]);
spaceTypeId = Integer.parseInt(columnString[3]);
latitude = Float.parseFloat(columnString[4]);
......@@ -237,7 +244,7 @@ public class T01ImportDbViewModel extends AndroidViewModel {
String newId = columnString[0];
List<Road> roadList = infoRepository.roadDao.loadAllByIds(new String[]{columnString[1]});
List<Road> roadList = infoRepository.roadDao.loadAllByIds(new int[]{roadId});
if (roadList.size() == 0){break;}
Road newRoad = roadList.get(0);
......
......@@ -14,6 +14,7 @@ import java.lang.invoke.MutableCallSite;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import ecom.android.newparkapp.entity.Case;
......@@ -58,8 +59,13 @@ public class T02SelectSpaceViewModel extends AndroidViewModel {
private void getMoreNearSpace(List<Space> nearSpace){
List<Space> moreNearSpace = new ArrayList<>();
if (nearSpace.size() > 0) {
Map<String, List<Space>> spaceGroupByRoad = nearSpace.stream().collect(Collectors.groupingBy(s -> s.road.id));
String[] roadIds = spaceGroupByRoad.keySet().toArray(new String[0]);
Map<Integer, List<Space>> spaceGroupByRoad = nearSpace.stream().collect(Collectors.groupingBy(s -> s.road.id));
int[] roadIds = new int[spaceGroupByRoad.size()];
int roadIndex = 0;
for (Integer key : spaceGroupByRoad.keySet()){
roadIds[roadIndex] = key.intValue();
roadIndex++;
}
String[] spaceIds = new String[nearSpace.size() - 1];
Space firstSpace = nearSpace.get(0);
// 取得除了第一筆以外的車格id
......@@ -101,8 +107,14 @@ public class T02SelectSpaceViewModel extends AndroidViewModel {
public void nextSpacePage(){
List<Space> currentSpaceList = getCurrentSpace().getValue();
if (currentSpaceList.size() > 0){
Map<String, List<Space>> spaceGroupByRoad = currentSpaceList.stream().collect(Collectors.groupingBy(s -> s.road.id));
String[] roadIds = spaceGroupByRoad.keySet().toArray(new String[0]);
Map<Integer, List<Space>> spaceGroupByRoad = currentSpaceList.stream().collect(Collectors.groupingBy(s -> s.road.id));
int[] roadIds = new int[spaceGroupByRoad.size()];
int roadIndex = 0;
for (Integer key : spaceGroupByRoad.keySet()){
roadIds[roadIndex] = key.intValue();
roadIndex++;
}
String[] spaceIds = new String[currentSpaceList.size()];
for (int i = 0; i < spaceIds.length; i++){
......@@ -124,8 +136,15 @@ public class T02SelectSpaceViewModel extends AndroidViewModel {
public void previousSpacePage(){
List<Space> currentSpaceList = getCurrentSpace().getValue();
if (currentSpaceList.size() > 0){
Map<String, List<Space>> spaceGroupByRoad = currentSpaceList.stream().collect(Collectors.groupingBy(s -> s.road.id));
String[] roadIds = spaceGroupByRoad.keySet().toArray(new String[0]);
Map<Integer, List<Space>> spaceGroupByRoad = currentSpaceList.stream().collect(Collectors.groupingBy(s -> s.road.id));
int[] roadIds = new int[spaceGroupByRoad.size()];
int roadIndex = 0;
for (Integer key : spaceGroupByRoad.keySet()){
roadIds[roadIndex] = key.intValue();
roadIndex++;
}
String[] spaceIds = new String[currentSpaceList.size()];
for (int i = 0; i < spaceIds.length; i++){
......
......@@ -483,7 +483,7 @@ public class T02StartViewModel extends AndroidViewModel {
// 檢查車格
if (tempCase.space == null || tempCase.space.id.isEmpty() || tempCase.space.road == null || tempCase.space.road.id.isEmpty()){
if (tempCase.space == null || tempCase.space.id.isEmpty() || tempCase.space.road == null || tempCase.space.road.id == -1){
return false;
}
......
A 中山路A
B 中山路B
C 垂楊路C
D 新榮路D
E 友愛路E
F 文化路F
G 仁愛路G
H 新民路H
I 忠孝路I
J 民生北路J
JJ 民生南路JJ
K 公明路K
LL 南京路LL
L 興業路L
M 彌陀路M
N 八德路N
P 維新路P
Q 中興路Q
R 上海路R
S 吳鳳北路S
T 大雅路T
U 重慶路U
V 民族路V
W 林森西路W
X 芳安路X
Y 德安路Y
Z 民權路Z
SP 站前停車場SP
MM 立仁路MM
KK 光華路KK
GG 志昇街GG
WA 興達路WA
DD 國華街DD
II 博東路II
CY 勤益大道CY
\ No newline at end of file
1 A 中山路A
2 B 中山路B
3 C 垂楊路C
4 D 新榮路D
5 E 友愛路E
6 F 文化路F
7 J 民生南路J
8 G 仁愛路G
9 H 新民路H
10 I 忠孝路I
11 J 民生北路J
12 K 公明路K
13 LL 南京路LL
14 L 興業路L
15 M 彌陀路M
16 N 八德路N
17 P 維新路P
18 Q 中興路Q
19 R 上海路R
20 S 吳鳳北路S
21 T 大雅路T
22 U 重慶路U
23 V 民族路V
24 W 林森西路W
25 X 芳安路X
26 Y 德安路Y
27 Z 民權路Z
28 SP 站前停車場SP
29 M 立仁路M
30 K 光華路K
31 G 志昇街G
32 WA 興達路WA
33 D 國華街D
34 I 博東路I
35 CY 勤益大道CY
\ No newline at end of file
A209 A 01 01 23.4799691 120.448693 01
A211 A 01 01 23.4799691 120.448693 01
A213 A 01 01 23.4799791 120.4486883 01
A215 A 01 01 23.4799762 120.4486685 01
N066 N 02 02 23.4894827 120.4303129 01
N068 N 02 02 23.4895994 120.4303028 01
N070 N 02 02 23.4900085 120.4301186 01
CY001 CY 02 02 24.143980 120.728605 01
CY002 CY 01 01 24.144095 120.728209 01
CY003 CY 01 01 24.145044 120.730499 01
CY004 CY 01 01 24.146152 120.730624 01
CY101 CY 01 01 24.142922 120.729012 01
CY102 CY 01 01 24.143535 120.728891 01
CY103 CY 01 01 24.143514 120.729429 01
CY104 CY 01 01 24.143509 120.728561 01
CY105 CY 01 01 24.143510 120.728581 01
CY106 CY 01 01 24.143710 120.728481 01
CY107 CY 01 01 24.143296 120.728681 01
A209 1 01 01 23.4799691 120.448693 01
A211 1 01 01 23.4799691 120.448693 01
A213 1 01 01 23.4799791 120.4486883 01
A215 1 01 01 23.4799762 120.4486685 01
N066 16 02 02 23.4894827 120.4303129 01
N068 16 02 02 23.4895994 120.4303028 01
N070 16 02 02 23.4900085 120.4301186 01
CY001 35 02 02 24.143980 120.728605 01
CY002 35 01 01 24.144095 120.728209 01
CY003 35 01 01 24.145044 120.730499 01
CY004 35 01 01 24.146152 120.730624 01
CY101 35 01 01 24.142922 120.729012 01
CY102 35 01 01 24.143535 120.728891 01
CY103 35 01 01 24.143514 120.729429 01
CY104 35 01 01 24.143509 120.728561 01
CY105 35 01 01 24.143510 120.728581 01
CY106 35 01 01 24.143710 120.728481 01
CY107 35 01 01 24.143296 120.728681 01
A 中山路A
B 中山路B
C 垂楊路C
D 新榮路D
E 友愛路E
F 文化路F
G 仁愛路G
H 新民路H
I 忠孝路I
J 民生北路J
JJ 民生南路JJ
K 公明路K
LL 南京路LL
L 興業路L
M 彌陀路M
N 八德路N
P 維新路P
Q 中興路Q
R 上海路R
S 吳鳳北路S
T 大雅路T
U 重慶路U
V 民族路V
W 林森西路W
X 芳安路X
Y 德安路Y
Z 民權路Z
SP 站前停車場SP
MM 立仁路MM
KK 光華路KK
GG 志昇街GG
WA 興達路WA
DD 國華街DD
II 博東路II
CY 勤益大道CY
\ No newline at end of file
A209 A 01 01 23.4799691 120.448693 01
A211 A 01 01 23.4799691 120.448693 01
A213 A 01 01 23.4799791 120.4486883 01
A215 A 01 01 23.4799762 120.4486685 01
N066 N 02 02 23.4894827 120.4303129 01
N068 N 02 02 23.4895994 120.4303028 01
N070 N 02 02 23.4900085 120.4301186 01
CY001 CY 02 02 24.143980 120.728605 01
CY002 CY 01 01 24.144095 120.728209 01
CY003 CY 01 01 24.145044 120.730499 01
CY004 CY 01 01 24.146152 120.730624 01
CY101 CY 01 01 24.142922 120.729012 01
CY102 CY 01 01 24.143535 120.728891 01
CY103 CY 01 01 24.143514 120.729429 01
CY104 CY 01 01 24.143509 120.728561 01
CY105 CY 01 01 24.143510 120.728581 01
CY106 CY 01 01 24.143710 120.728481 01
CY107 CY 01 01 24.143296 120.728681 01
1 2 20
2 2 20
3 2 20
4 2 20
5 2 20
6 2 20
7 2 20
8 2 20
9 2 20
10 2 20
11 2 40
12 2 20
13 2 20
14 2 40
1 1 25
2 1 25
3 1 25
4 1 25
5 1 25
6 1 25
7 1 25
8 1 25
9 1 25
10 1 25
11 1 50
12 1 15
13 1 15
14 1 50
01 0.5
02 1.0
\ No newline at end of file
01 啟用
99 禁用
\ No newline at end of file
01 機車
02 汽車
03 身障車格
04 婦幼車格
\ No newline at end of file
01 Allen allen allen 01
02 Bruce bruce bruce 02
777 Root root toor 99
\ No newline at end of file
01 早班
02 晚班
99 工程師
\ No newline at end of file
01 無限 (INFINITI)
02 裕隆
03 三陽 (Honda)
04 大發 (Daihatsu)
05 喜悅 (Seat)
06 中華
07 福特 (Ford)
08 雷諾 (Renault)
09 寶獅 (Peugeot)
10 賓士 (Benz)
11 寶馬 (BMW)
12 富豪 (Volvo)
13 別克 (Buick)
14 雪鐵龍 (Citroen)
15 飛雅特 (Fiat)
16 其他
17 豐田 (Toyota)
18 歐寶 (Opel)
19 奧斯摩比 (Oldsmobile)
20 龐帝克 (Pontiac)
21 奧斯汀(Austin)
22 雪佛蘭 (Chevrolet)
23 克萊斯勒 (Chrysler)
24 愛快羅密歐 (Alfa Romeo)
25 福斯 (Volkswagon)
26 紳寶 (Saab)
27 蘭吉雅 (Lancia)
28 謀克利 (Mercury)
29 三菱 (Mitsubishi)
30 速霸路 (Subaru)
31 奧迪 (Audi)
32 路寶 (Rover)
33 馬自達 (Mazda)
34 鈴木 (Suzuki)
35 現代 (Hyundai)
36 大慶
37 凱迪拉克 (Cadillac)
38 釷星 (Saturn)
39 日產 (Nissan)
40 五十鈴 (Isuzu)
41 本田 (Honda)
42 拉達 (Lada)
43 保時捷 (Porsche)
44 紳揚
45 大宇 (Dwewoo)
46 勞斯萊斯 (Rolls Royce)
47 起亞 (KIA)
48 吉優 (GEO)
49 捷豹 (Jaguar)
50 道奇 (Dodge)
51 台塑 (Formosa)
52 凌志 (Lexus)
53 蓮花 (Lotus)
54 吉普 (Jeep)
55 納智捷 (Luxgen)
56 MG
57 寶騰 (pontiac)
58 SKODA
\ No newline at end of file
01 咖啡
02 黑
03 白
04 紅
05 橙
06 黃
07 綠
08 藍
09 紫
10 金
11 棕
12 銀
13 灰
14 其他
\ No newline at end of file
01 自小客
02 自小貨
03 小客貨
04 小營客
05 小營貨
06 大自客貨
07 遊覽車
08 大營貨
10 計程車
11 交通車
12 身心障礙(府-2)
13 身心障礙(社-4)
14 其他
31 輕機
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment