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
8c66dd9b
authored
May 14, 2020
by
pye52
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
恢复到原来发送订单的方案(让后台去处理异常订单)
parent
d8dee860
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
48 deletions
+1
-48
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
+1
-48
No files found.
app/src/main/java/com/bgycc/smartcanteen/viewModel/PayOfflineViewModel.java
View file @
8c66dd9b
...
...
@@ -22,8 +22,6 @@ import com.google.gson.JsonObject;
import
org.java_websocket.handshake.ServerHandshake
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.concurrent.ScheduledFuture
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -205,58 +203,13 @@ public class PayOfflineViewModel extends ViewModel {
LogUtils
.
d
(
TAG
,
"所有离线订单处理完毕"
);
return
;
}
// 由于离线支付订单有可能和设备码不一致,需要兼容该情况
// 保证离线订单的equipmentId与equipmentNo一致
// 去除不一致的订单(留待下次上传)
String
mainEquipmentNo
=
acquireMaxEquipmentNo
(
payOfflineData
);
if
(
TextUtils
.
isEmpty
(
mainEquipmentNo
))
{
mainEquipmentNo
=
deviceSN
;
}
ArrayList
<
PayData
>
theSameEquipmentNoData
=
new
ArrayList
<>();
for
(
PayData
t
:
payOfflineData
)
{
if
(
t
.
getEquipmentNo
().
equals
(
mainEquipmentNo
))
{
theSameEquipmentNoData
.
add
(
t
);
}
}
payRequest
=
new
PayRequest
(
mainEquipmentNo
,
theSameEquipmentNoData
);
payRequest
=
new
PayRequest
(
deviceSN
,
payOfflineData
);
String
requestStr
=
gson
.
toJson
(
payRequest
);
payOfflineState
.
postValue
(
new
PayOfflineState
(
PayOfflineState
.
SEND
,
requestStr
));
SCWebSocketClient
.
getInstance
().
send
(
requestStr
);
LogUtils
.
d
(
TAG
,
"离线支付: "
+
payRequest
.
toString
());
}
private
String
acquireMaxEquipmentNo
(
List
<
PayData
>
list
)
{
HashMap
<
String
,
Integer
>
tMap
=
new
HashMap
<>();
String
mainEquipmentNo
=
""
;
int
size
=
list
.
size
();
int
max
=
0
;
for
(
PayData
t
:
list
)
{
String
key
=
t
.
getEquipmentNo
();
int
value
;
if
(
tMap
.
containsKey
(
key
))
{
Integer
vWrapper
=
tMap
.
get
(
key
);
if
(
vWrapper
==
null
)
{
value
=
1
;
}
else
{
value
=
vWrapper
+
1
;
}
if
(
value
>
(
size
/
2
))
{
return
key
;
}
}
else
{
value
=
1
;
}
if
(
value
>=
max
)
{
max
=
value
;
mainEquipmentNo
=
key
;
}
tMap
.
put
(
key
,
value
);
}
tMap
.
clear
();
return
mainEquipmentNo
;
}
}
private
class
UpdateUploadTimeRunnable
implements
Runnable
{
...
...
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