Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
NewParkAPP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YONG-LIN SU
NewParkAPP
Commits
ca126615
Commit
ca126615
authored
Aug 23, 2022
by
YONG-LIN SU
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修正部分案件查詢帶入當天日期
parent
20f3f571
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
7 deletions
+73
-7
deploymentTargetDropDown.xml
.idea/deploymentTargetDropDown.xml
+1
-1
CaseDao.java
app/src/main/java/ecom/android/newparkapp/dao/CaseDao.java
+9
-0
InfoRepository.java
...va/ecom/android/newparkapp/repository/InfoRepository.java
+40
-0
T02StartActivity.java
...n/java/ecom/android/newparkapp/view/T02StartActivity.java
+3
-1
T03ListFilesActivity.java
...va/ecom/android/newparkapp/view/T03ListFilesActivity.java
+2
-1
T03SearchingParkingSpaceActivity.java
...oid/newparkapp/view/T03SearchingParkingSpaceActivity.java
+10
-1
T04RenewListActivity.java
...va/ecom/android/newparkapp/view/T04RenewListActivity.java
+2
-2
T02StartViewModel.java
.../ecom/android/newparkapp/viewModel/T02StartViewModel.java
+6
-1
No files found.
.idea/deploymentTargetDropDown.xml
View file @
ca126615
...
@@ -12,6 +12,6 @@
...
@@ -12,6 +12,6 @@
</deviceKey>
</deviceKey>
</Target>
</Target>
</runningDeviceTargetSelectedWithDropDown>
</runningDeviceTargetSelectedWithDropDown>
<timeTargetWasSelectedWithDropDown
value=
"2022-08-23T0
5:10:09.6510089
00Z"
/>
<timeTargetWasSelectedWithDropDown
value=
"2022-08-23T0
6:16:20.9716084
00Z"
/>
</component>
</component>
</project>
</project>
\ No newline at end of file
app/src/main/java/ecom/android/newparkapp/dao/CaseDao.java
View file @
ca126615
...
@@ -23,9 +23,15 @@ public interface CaseDao {
...
@@ -23,9 +23,15 @@ public interface CaseDao {
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoByShitAndUserId
(
Shift
shift
,
int
userId
);
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoByShitAndUserId
(
Shift
shift
,
int
userId
);
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId AND case_time>=:startDate AND case_time<=:endDate"
)
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoByShitAndUserIdInDay
(
Shift
shift
,
int
userId
,
Date
startDate
,
Date
endDate
);
@Query
(
"SELECT * FROM `case` WHERE space_id=:spaceId"
)
@Query
(
"SELECT * FROM `case` WHERE space_id=:spaceId"
)
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoBySpace
(
String
spaceId
);
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoBySpace
(
String
spaceId
);
@Query
(
"SELECT * FROM `case` WHERE space_id=:spaceId AND shift=:shift AND user_id=:userId AND case_time>=:startDate AND case_time<=:endDate"
)
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoBySpaceAndShiftAndUserIdInDay
(
String
spaceId
,
Shift
shift
,
int
userId
,
Date
startDate
,
Date
endDate
);
@Query
(
"SELECT * FROM `case`"
)
@Query
(
"SELECT * FROM `case`"
)
List
<
Case
>
getAll
();
List
<
Case
>
getAll
();
...
@@ -47,6 +53,9 @@ public interface CaseDao {
...
@@ -47,6 +53,9 @@ public interface CaseDao {
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
List
<
Case
>
getAllByShiftAndUser
(
Shift
shift
,
int
userId
);
List
<
Case
>
getAllByShiftAndUser
(
Shift
shift
,
int
userId
);
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId AND case_time>=:startDate AND case_time<=:endDate"
)
List
<
Case
>
getAllByShiftAndUserInDay
(
Shift
shift
,
int
userId
,
Date
startDate
,
Date
endDate
);
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
@Query
(
"SELECT * FROM `case` WHERE shift=:shift AND user_id=:userId"
)
LiveData
<
List
<
Case
>>
getAllByShiftAndUserLiveData
(
Shift
shift
,
int
userId
);
LiveData
<
List
<
Case
>>
getAllByShiftAndUserLiveData
(
Shift
shift
,
int
userId
);
...
...
app/src/main/java/ecom/android/newparkapp/repository/InfoRepository.java
View file @
ca126615
...
@@ -2,6 +2,10 @@ package ecom.android.newparkapp.repository;
...
@@ -2,6 +2,10 @@ package ecom.android.newparkapp.repository;
import
android.app.Application
;
import
android.app.Application
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
...
@@ -18,6 +22,9 @@ import ecom.android.newparkapp.dao.VehicleBrandDao;
...
@@ -18,6 +22,9 @@ import ecom.android.newparkapp.dao.VehicleBrandDao;
import
ecom.android.newparkapp.dao.VehicleColorDao
;
import
ecom.android.newparkapp.dao.VehicleColorDao
;
import
ecom.android.newparkapp.dao.VehicleTypeDao
;
import
ecom.android.newparkapp.dao.VehicleTypeDao
;
import
ecom.android.newparkapp.database.InfoDatabase
;
import
ecom.android.newparkapp.database.InfoDatabase
;
import
ecom.android.newparkapp.entity.Case
;
import
ecom.android.newparkapp.entity.CaseAndAllCasePhoto
;
import
ecom.android.newparkapp.entity.Shift
;
public
class
InfoRepository
{
public
class
InfoRepository
{
private
InfoDatabase
infoDatabase
;
private
InfoDatabase
infoDatabase
;
...
@@ -38,6 +45,8 @@ public class InfoRepository {
...
@@ -38,6 +45,8 @@ public class InfoRepository {
public
CaseDao
caseDao
;
public
CaseDao
caseDao
;
public
CasePhotoDao
casePhotoDao
;
public
CasePhotoDao
casePhotoDao
;
private
Date
startDate
,
endDate
=
new
Date
();
public
InfoRepository
(
Application
application
)
{
public
InfoRepository
(
Application
application
)
{
infoDatabase
=
InfoDatabase
.
getInstance
(
application
);
infoDatabase
=
InfoDatabase
.
getInstance
(
application
);
...
@@ -57,4 +66,35 @@ public class InfoRepository {
...
@@ -57,4 +66,35 @@ public class InfoRepository {
executorService
=
Executors
.
newFixedThreadPool
(
application
.
getResources
().
getInteger
(
R
.
integer
.
number_db_thread_pool
));
executorService
=
Executors
.
newFixedThreadPool
(
application
.
getResources
().
getInteger
(
R
.
integer
.
number_db_thread_pool
));
}
}
public
List
<
Case
>
getAllCaseByShiftAndUserToday
(
Shift
shift
,
int
userId
){
getStartEndToday
();
return
caseDao
.
getAllByShiftAndUserInDay
(
shift
,
userId
,
startDate
,
endDate
);
}
public
List
<
CaseAndAllCasePhoto
>
getAllCaseWithCasePhotoByShiftAndUserToday
(
Shift
shift
,
int
userId
){
getStartEndToday
();
return
caseDao
.
getAllWithCasePhotoByShitAndUserIdInDay
(
shift
,
userId
,
startDate
,
endDate
);
}
public
List
<
CaseAndAllCasePhoto
>
getAllWithCasePhotoBySpaceAndShiftAndUserIdToday
(
String
spaceId
,
Shift
shift
,
int
userId
){
getStartEndToday
();
return
caseDao
.
getAllWithCasePhotoBySpaceAndShiftAndUserIdInDay
(
spaceId
,
shift
,
userId
,
startDate
,
endDate
);
}
private
void
getStartEndToday
()
{
Calendar
calendar
=
Calendar
.
getInstance
(
Locale
.
getDefault
());
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
0
);
// HOUR_OF_DAY 才是24小時制
calendar
.
set
(
Calendar
.
MINUTE
,
0
);
calendar
.
set
(
Calendar
.
SECOND
,
0
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
0
);
startDate
=
calendar
.
getTime
();
calendar
.
set
(
Calendar
.
HOUR_OF_DAY
,
23
);
// HOUR_OF_DAY 才是24小時制
calendar
.
set
(
Calendar
.
MINUTE
,
59
);
calendar
.
set
(
Calendar
.
SECOND
,
59
);
calendar
.
set
(
Calendar
.
MILLISECOND
,
999
);
endDate
=
calendar
.
getTime
();
}
}
}
app/src/main/java/ecom/android/newparkapp/view/T02StartActivity.java
View file @
ca126615
...
@@ -705,7 +705,7 @@ public class T02StartActivity extends AppCompatActivity {
...
@@ -705,7 +705,7 @@ public class T02StartActivity extends AppCompatActivity {
private
void
btnSearchingParkingSpaceOnClicked
(){
private
void
btnSearchingParkingSpaceOnClicked
(){
Case
tempCase
=
t02StartViewModel
.
getCurrentCase
().
getValue
();
Case
tempCase
=
t02StartViewModel
.
getCurrentCase
().
getValue
();
if
(
tempCase
==
null
){
if
(
tempCase
==
null
||
tempCase
.
caseStatus
!=
CaseStatus
.
NEW
){
return
;
return
;
}
}
if
(
tempCase
.
space
!=
null
)
if
(
tempCase
.
space
!=
null
)
...
@@ -715,6 +715,8 @@ public class T02StartActivity extends AppCompatActivity {
...
@@ -715,6 +715,8 @@ public class T02StartActivity extends AppCompatActivity {
intent
.
setClass
(
this
,
T03SearchingParkingSpaceActivity
.
class
);
intent
.
setClass
(
this
,
T03SearchingParkingSpaceActivity
.
class
);
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelable
(
"Space"
,
tempCase
.
space
);
bundle
.
putParcelable
(
"Space"
,
tempCase
.
space
);
bundle
.
putInt
(
"UserId"
,
currentUser
.
id
);
bundle
.
putParcelable
(
"Shift"
,
shift
);
intent
.
putExtras
(
bundle
);
intent
.
putExtras
(
bundle
);
searchingParkingSpaceActivityResultLauncher
.
launch
(
intent
);
searchingParkingSpaceActivityResultLauncher
.
launch
(
intent
);
...
...
app/src/main/java/ecom/android/newparkapp/view/T03ListFilesActivity.java
View file @
ca126615
...
@@ -53,7 +53,8 @@ public class T03ListFilesActivity extends AppCompatActivity {
...
@@ -53,7 +53,8 @@ public class T03ListFilesActivity extends AppCompatActivity {
}
}
});
});
infoRepository
=
new
InfoRepository
(
getApplication
());
infoRepository
=
new
InfoRepository
(
getApplication
());
caseAndAllCasePhotos
=
infoRepository
.
caseDao
.
getAllWithCasePhotoByShitAndUserId
(
shift
,
userId
);
// caseAndAllCasePhotos = infoRepository.caseDao.getAllWithCasePhotoByShitAndUserId(shift, userId);
caseAndAllCasePhotos
=
infoRepository
.
getAllCaseWithCasePhotoByShiftAndUserToday
(
shift
,
userId
);
caseListAdapter
.
submitList
(
caseAndAllCasePhotos
);
caseListAdapter
.
submitList
(
caseAndAllCasePhotos
);
...
...
app/src/main/java/ecom/android/newparkapp/view/T03SearchingParkingSpaceActivity.java
View file @
ca126615
...
@@ -16,6 +16,7 @@ import ecom.android.newparkapp.adapter.LargeCaseListAdapter;
...
@@ -16,6 +16,7 @@ import ecom.android.newparkapp.adapter.LargeCaseListAdapter;
import
ecom.android.newparkapp.databinding.ActivityT03SearchingParkingSpaceBinding
;
import
ecom.android.newparkapp.databinding.ActivityT03SearchingParkingSpaceBinding
;
import
ecom.android.newparkapp.entity.Case
;
import
ecom.android.newparkapp.entity.Case
;
import
ecom.android.newparkapp.entity.CaseAndAllCasePhoto
;
import
ecom.android.newparkapp.entity.CaseAndAllCasePhoto
;
import
ecom.android.newparkapp.entity.Shift
;
import
ecom.android.newparkapp.entity.Space
;
import
ecom.android.newparkapp.entity.Space
;
import
ecom.android.newparkapp.repository.InfoRepository
;
import
ecom.android.newparkapp.repository.InfoRepository
;
...
@@ -24,9 +25,16 @@ public class T03SearchingParkingSpaceActivity extends AppCompatActivity {
...
@@ -24,9 +25,16 @@ public class T03SearchingParkingSpaceActivity extends AppCompatActivity {
private
Space
selectedSpace
;
private
Space
selectedSpace
;
private
LargeCaseListAdapter
largeCaseListAdapter
;
private
LargeCaseListAdapter
largeCaseListAdapter
;
private
InfoRepository
infoRepository
;
private
InfoRepository
infoRepository
;
private
int
userId
;
private
Shift
shift
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
Bundle
bundle
=
getIntent
().
getExtras
();
shift
=
bundle
.
getParcelable
(
"Shift"
);
userId
=
bundle
.
getInt
(
"UserId"
);
dataBinding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_t03_searching_parking_space
);
dataBinding
=
DataBindingUtil
.
setContentView
(
this
,
R
.
layout
.
activity_t03_searching_parking_space
);
ActionBar
actionBar
=
getSupportActionBar
();
ActionBar
actionBar
=
getSupportActionBar
();
if
(
actionBar
!=
null
){
if
(
actionBar
!=
null
){
...
@@ -59,7 +67,8 @@ public class T03SearchingParkingSpaceActivity extends AppCompatActivity {
...
@@ -59,7 +67,8 @@ public class T03SearchingParkingSpaceActivity extends AppCompatActivity {
}
}
});
});
List
<
CaseAndAllCasePhoto
>
caseAndAllCasePhotos
=
infoRepository
.
caseDao
.
getAllWithCasePhotoBySpace
(
selectedSpace
.
id
);
//List<CaseAndAllCasePhoto> caseAndAllCasePhotos = infoRepository.caseDao.getAllWithCasePhotoBySpace(selectedSpace.id);
List
<
CaseAndAllCasePhoto
>
caseAndAllCasePhotos
=
infoRepository
.
getAllWithCasePhotoBySpaceAndShiftAndUserIdToday
(
selectedSpace
.
id
,
shift
,
userId
);
if
(
caseAndAllCasePhotos
.
size
()
==
0
){
if
(
caseAndAllCasePhotos
.
size
()
==
0
){
emptyResult
();
emptyResult
();
}
}
...
...
app/src/main/java/ecom/android/newparkapp/view/T04RenewListActivity.java
View file @
ca126615
...
@@ -140,7 +140,7 @@ public class T04RenewListActivity extends AppCompatActivity {
...
@@ -140,7 +140,7 @@ public class T04RenewListActivity extends AppCompatActivity {
}
}
private
void
updateData
(
boolean
isNear
){
private
void
updateData
(
boolean
isNear
){
cases
=
infoRepository
.
caseDao
.
getAllByShiftAndUser
(
shift
,
userId
);
cases
=
infoRepository
.
getAllCaseByShiftAndUserToday
(
shift
,
userId
);
Map
<
String
,
List
<
Case
>>
casesGroupByRoad
=
cases
.
stream
().
collect
(
Collectors
.
groupingBy
(
c
->
c
.
space
.
road
.
getCombineInfo
()));
Map
<
String
,
List
<
Case
>>
casesGroupByRoad
=
cases
.
stream
().
collect
(
Collectors
.
groupingBy
(
c
->
c
.
space
.
road
.
getCombineInfo
()));
Location
location
=
fusedGpsViewModel
.
getLocation
().
getValue
();
Location
location
=
fusedGpsViewModel
.
getLocation
().
getValue
();
...
@@ -196,7 +196,7 @@ public class T04RenewListActivity extends AppCompatActivity {
...
@@ -196,7 +196,7 @@ public class T04RenewListActivity extends AppCompatActivity {
private
class
NotifyNestedReNewTimerTask
extends
TimerTask
{
private
class
NotifyNestedReNewTimerTask
extends
TimerTask
{
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
Case
>
caseList
=
infoRepository
.
caseDao
.
getAllByShiftAndUser
(
shift
,
userId
);
List
<
Case
>
caseList
=
infoRepository
.
getAllCaseByShiftAndUserToday
(
shift
,
userId
);
Location
location
=
fusedGpsViewModel
.
getLocation
().
getValue
();
Location
location
=
fusedGpsViewModel
.
getLocation
().
getValue
();
boolean
isNeedNotify
=
false
;
boolean
isNeedNotify
=
false
;
for
(
Case
c:
caseList
)
{
for
(
Case
c:
caseList
)
{
...
...
app/src/main/java/ecom/android/newparkapp/viewModel/T02StartViewModel.java
View file @
ca126615
...
@@ -116,6 +116,9 @@ public class T02StartViewModel extends AndroidViewModel {
...
@@ -116,6 +116,9 @@ public class T02StartViewModel extends AndroidViewModel {
public
void
setSpace
(
Space
space
){
public
void
setSpace
(
Space
space
){
Case
tempCase
=
currentCase
.
getValue
();
Case
tempCase
=
currentCase
.
getValue
();
if
(
tempCase
.
caseStatus
!=
CaseStatus
.
NEW
){
return
;
}
tempCase
.
space
=
space
;
tempCase
.
space
=
space
;
// 取得車格後,更新費用及時間
// 取得車格後,更新費用及時間
...
@@ -624,7 +627,9 @@ public class T02StartViewModel extends AndroidViewModel {
...
@@ -624,7 +627,9 @@ public class T02StartViewModel extends AndroidViewModel {
if
(
user
==
null
){
if
(
user
==
null
){
return
;
return
;
}
}
cases
=
infoRepository
.
caseDao
.
getAllByShiftAndUser
(
shift
,
user
.
id
);
//cases = infoRepository.caseDao.getAllByShiftAndUser(shift, user.id);
cases
=
infoRepository
.
getAllCaseByShiftAndUserToday
(
shift
,
user
.
id
);
for
(
int
i
=
0
;
i
<
cases
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
cases
.
size
();
i
++){
cases
.
get
(
i
).
caseStatus
=
CaseStatus
.
LIST
;
cases
.
get
(
i
).
caseStatus
=
CaseStatus
.
LIST
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment