Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
huangzhicong
/
SmartCanteen
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
bf50cf74
authored
May 09, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、增加离线订单分批上传机制(避免一次性上传大量订单被服务拒绝)
2、增加数据库版本从1升级到2的迁移机制
parent
d4b74d34
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletions
+22
-1
app/src/main/java/com/bgycc/smartcanteen/data/_1To_2Migration.java
+19
-0
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
+3
-1
No files found.
app/src/main/java/com/bgycc/smartcanteen/data/_1To_2Migration.java
0 → 100644
View file @
bf50cf74
package
com
.
bgycc
.
smartcanteen
.
data
;
import
androidx.annotation.NonNull
;
import
androidx.room.migration.Migration
;
import
androidx.sqlite.db.SupportSQLiteDatabase
;
import
com.bgycc.smartcanteen.entity.PayData
;
public
class
_1To_2Migration
extends
Migration
{
public
_1To_2Migration
()
{
super
(
1
,
2
);
}
@Override
public
void
migrate
(
@NonNull
SupportSQLiteDatabase
database
)
{
database
.
execSQL
(
"ALTER TABLE "
+
PayData
.
TABLE_NAME
+
" ADD COLUMN uploadTime INTEGER NOT NULL DEFAULT 0"
);
}
}
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
View file @
bf50cf74
...
@@ -143,9 +143,11 @@ public class PayOfflineViewModel extends ViewModel {
...
@@ -143,9 +143,11 @@ public class PayOfflineViewModel extends ViewModel {
}
}
private
class
RequestRunnable
implements
Runnable
{
private
class
RequestRunnable
implements
Runnable
{
private
static
final
int
PAY_OFFLINE_PER_LIMIT
=
10
;
@Override
@Override
public
void
run
()
{
public
void
run
()
{
List
<
PayData
>
payData
=
payDataRepository
.
queryPayOfflineData
();
long
currentTime
=
System
.
currentTimeMillis
();
List
<
PayData
>
payData
=
payDataRepository
.
queryPayOfflineData
(
currentTime
,
PAY_OFFLINE_PER_LIMIT
);
if
(
payData
==
null
||
payData
.
isEmpty
())
{
if
(
payData
==
null
||
payData
.
isEmpty
())
{
cancelTimeout
();
cancelTimeout
();
payRequest
=
null
;
payRequest
=
null
;
...
...
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