Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StatInfo_1
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
chenyuling
StatInfo_1
Commits
75dcf957
Commit
75dcf957
authored
Jan 26, 2024
by
chenyuling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"解决第二天保留第一天数据的问题,优化放松更新数据的条件"
parent
86253c4b
Pipeline
#2287
canceled with stages
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
9 deletions
+42
-9
DeviceCallback.java
.../java/com/srthinker/statinfo/listener/DeviceCallback.java
+1
-1
ApiManager.java
...ain/java/com/srthinker/statinfo/presenter/ApiManager.java
+5
-3
ApiQuest.java
.../main/java/com/srthinker/statinfo/presenter/ApiQuest.java
+36
-5
No files found.
app/src/main/java/com/srthinker/statinfo/listener/DeviceCallback.java
View file @
75dcf957
...
@@ -5,6 +5,6 @@ import com.srthinker.statinfo.database.entity.PersonEntity;
...
@@ -5,6 +5,6 @@ import com.srthinker.statinfo.database.entity.PersonEntity;
import
java.util.List
;
import
java.util.List
;
public
interface
DeviceCallback
{
public
interface
DeviceCallback
{
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
);
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
,
String
nowDate
);
void
onConnectStatus
(
boolean
isConnect
,
int
type
);
void
onConnectStatus
(
boolean
isConnect
,
int
type
);
}
}
app/src/main/java/com/srthinker/statinfo/presenter/ApiManager.java
View file @
75dcf957
...
@@ -50,6 +50,7 @@ public class ApiManager {
...
@@ -50,6 +50,7 @@ public class ApiManager {
private
boolean
lastConnect
=
false
;
private
boolean
lastConnect
=
false
;
private
QueryPersonCallback
queryPersonsCallback
;
private
QueryPersonCallback
queryPersonsCallback
;
private
DevicePortCallback
devicePortCallback
;
private
DevicePortCallback
devicePortCallback
;
private
String
begin_time
;
public
ApiManager
(
String
username
,
String
password
,
String
serverIp
,
int
type
){
public
ApiManager
(
String
username
,
String
password
,
String
serverIp
,
int
type
){
...
@@ -184,9 +185,10 @@ public class ApiManager {
...
@@ -184,9 +185,10 @@ public class ApiManager {
queryPass
();
queryPass
();
//Log.i(TAG, "run: totalPassLists.size()="+totalPassLists.size());
//Log.i(TAG, "run: totalPassLists.size()="+totalPassLists.size());
//Log.i(TAG, "run: lastPassTotal="+lastPassTotal);
//Log.i(TAG, "run: lastPassTotal="+lastPassTotal);
if
(
totalPassLists
.
size
()!=
0
&&
totalPassLists
.
size
()!=
lastPassTotal
){
//&&totalPassLists.size()!= lastPassTotal
if
(
totalPassLists
.
size
()!=
0
){
if
(
callback
!=
null
)
{
if
(
callback
!=
null
)
{
callback
.
getPassInfo
(
totalPassLists
,
type
);
callback
.
getPassInfo
(
totalPassLists
,
type
,
begin_time
);
}
}
}
}
lastPassTotal
=
totalPassLists
.
size
();
lastPassTotal
=
totalPassLists
.
size
();
...
@@ -215,7 +217,7 @@ public class ApiManager {
...
@@ -215,7 +217,7 @@ public class ApiManager {
private
void
queryPass
(){
private
void
queryPass
(){
//获取历史通行记录
//获取历史通行记录
// Log.i(TAG, "start: passApi="+passApi);
// Log.i(TAG, "start: passApi="+passApi);
String
begin_time
=
DateUtil
.
getDateFormattedZone
(
new
Date
(),
"yyyy-MM-dd"
);
begin_time
=
DateUtil
.
getDateFormattedZone
(
new
Date
(),
"yyyy-MM-dd"
);
String
end_time
=
DateUtil
.
getDateFormattedZone
(
DateUtil
.
getNextDate
(),
"yyyy-MM-dd"
);
String
end_time
=
DateUtil
.
getDateFormattedZone
(
DateUtil
.
getNextDate
(),
"yyyy-MM-dd"
);
if
(
TextUtils
.
isEmpty
(
sessionId
)){
if
(
TextUtils
.
isEmpty
(
sessionId
)){
//handler.post(this);
//handler.post(this);
...
...
app/src/main/java/com/srthinker/statinfo/presenter/ApiQuest.java
View file @
75dcf957
...
@@ -15,6 +15,8 @@ import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
...
@@ -15,6 +15,8 @@ import com.srthinker.statinfo.listener.upper.UpperDevicesCallback;
import
com.srthinker.statinfo.listener.upper.UpperDevicesPortCallback
;
import
com.srthinker.statinfo.listener.upper.UpperDevicesPortCallback
;
import
com.srthinker.statinfo.util.common.ThreadPool
;
import
com.srthinker.statinfo.util.common.ThreadPool
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
...
@@ -35,6 +37,8 @@ public class ApiQuest {
...
@@ -35,6 +37,8 @@ public class ApiQuest {
private
UpperDevicesCallback
upperDevicesCallback
;
private
UpperDevicesCallback
upperDevicesCallback
;
private
static
LinkedHashMap
<
String
,
ApiManager
>
enterMgrHashMap
=
new
LinkedHashMap
<>();
private
static
LinkedHashMap
<
String
,
ApiManager
>
enterMgrHashMap
=
new
LinkedHashMap
<>();
private
static
LinkedHashMap
<
String
,
ApiManager
>
leaveMgrHashMap
=
new
LinkedHashMap
<>();
private
static
LinkedHashMap
<
String
,
ApiManager
>
leaveMgrHashMap
=
new
LinkedHashMap
<>();
private
static
LinkedHashMap
<
String
,
List
<
PersonEntity
>>
allEnterPassMap
=
new
LinkedHashMap
<>();
private
static
LinkedHashMap
<
String
,
List
<
PersonEntity
>>
allLeavePassMap
=
new
LinkedHashMap
<>();
private
String
oneEnterIp
;
private
String
oneEnterIp
;
private
UpperDevicesPortCallback
upperDevicesPortCallback
;
private
UpperDevicesPortCallback
upperDevicesPortCallback
;
...
@@ -59,9 +63,11 @@ public class ApiQuest {
...
@@ -59,9 +63,11 @@ public class ApiQuest {
if
(
type
==
ENTER_TYPE
){
if
(
type
==
ENTER_TYPE
){
isEnterAllConnect
=
false
;
isEnterAllConnect
=
false
;
allEnterPass
=
new
ArrayList
<>();
allEnterPass
=
new
ArrayList
<>();
allEnterPassMap
=
new
LinkedHashMap
<>();
}
else
if
(
type
==
LEAVE_TYPE
){
}
else
if
(
type
==
LEAVE_TYPE
){
isLeaveAllConnect
=
false
;
isLeaveAllConnect
=
false
;
allLeavePass
=
new
ArrayList
<>();
allLeavePass
=
new
ArrayList
<>();
allLeavePassMap
=
new
LinkedHashMap
<>();
}
}
}
}
...
@@ -89,7 +95,7 @@ public class ApiQuest {
...
@@ -89,7 +95,7 @@ public class ApiQuest {
}
}
}
}
}
}
private
String
lastEnterDate
=
""
;
private
void
startEnterIp
(
String
username
,
String
password
,
String
ip
)
{
private
void
startEnterIp
(
String
username
,
String
password
,
String
ip
)
{
Log
.
i
(
TAG
,
"startEnterIp: 访问接口的ip="
+
ip
);
Log
.
i
(
TAG
,
"startEnterIp: 访问接口的ip="
+
ip
);
/*//如果之前有过则停掉
/*//如果之前有过则停掉
...
@@ -111,9 +117,21 @@ public class ApiQuest {
...
@@ -111,9 +117,21 @@ public class ApiQuest {
});
});
enterMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
enterMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
@Override
@Override
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
,
String
nowDate
)
{
synchronized
(
allEnterPass
){
synchronized
(
allEnterPass
){
allEnterPass
.
addAll
(
passEntities
);
if
(!
StringUtils
.
equals
(
lastEnterDate
,
nowDate
)){
//allEnterPass.clear(); //清空数据
allEnterPassMap
.
clear
();
lastEnterDate
=
nowDate
;
//更新lastDate
}
allEnterPass
.
clear
();
//清空数据
allEnterPassMap
.
put
(
ip
,
passEntities
);
for
(
Map
.
Entry
<
String
,
List
<
PersonEntity
>>
entry
:
allEnterPassMap
.
entrySet
())
{
if
(
entry
!=
null
)
{
allEnterPass
.
addAll
(
entry
.
getValue
());
}
}
//allEnterPass.addAll(passEntities);
/*for (PersonEntity enterPass : allEnterPass) {
/*for (PersonEntity enterPass : allEnterPass) {
Log.i(TAG, "去重前getPassInfo: enterPass.time="+enterPass.getTimestamp()+",name="+enterPass.getPerson_name());
Log.i(TAG, "去重前getPassInfo: enterPass.time="+enterPass.getTimestamp()+",name="+enterPass.getPerson_name());
}*/
}*/
...
@@ -167,6 +185,7 @@ public class ApiQuest {
...
@@ -167,6 +185,7 @@ public class ApiQuest {
});
});
}
}
private
String
lastLeaveDate
=
""
;
private
void
startLeaveIp
(
String
username
,
String
password
,
String
ip
)
{
private
void
startLeaveIp
(
String
username
,
String
password
,
String
ip
)
{
//如果之前有过则停掉
//如果之前有过则停掉
/*if (leaveMgrHashMap.get(ip)!=null){
/*if (leaveMgrHashMap.get(ip)!=null){
...
@@ -187,9 +206,21 @@ public class ApiQuest {
...
@@ -187,9 +206,21 @@ public class ApiQuest {
});
});
leaveMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
leaveMgr
.
setOnDeviceCallback
(
new
DeviceCallback
()
{
@Override
@Override
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
)
{
public
void
getPassInfo
(
List
<
PersonEntity
>
passEntities
,
int
type
,
String
nowDate
)
{
synchronized
(
allLeavePass
){
synchronized
(
allLeavePass
){
allLeavePass
.
addAll
(
passEntities
);
if
(!
StringUtils
.
equals
(
lastLeaveDate
,
nowDate
)){
//allLeavePass.clear(); //清空数据
allLeavePassMap
.
clear
();
lastLeaveDate
=
nowDate
;
//更新lastDate
}
allLeavePass
.
clear
();
//清空数据
allLeavePassMap
.
put
(
ip
,
passEntities
);
for
(
Map
.
Entry
<
String
,
List
<
PersonEntity
>>
entry
:
allLeavePassMap
.
entrySet
())
{
if
(
entry
!=
null
)
{
allLeavePass
.
addAll
(
entry
.
getValue
());
}
}
//allLeavePass.addAll(passEntities);
PersonEntityComparator
comparator
=
new
PersonEntityComparator
();
PersonEntityComparator
comparator
=
new
PersonEntityComparator
();
Collections
.
sort
(
allLeavePass
,
comparator
);
Collections
.
sort
(
allLeavePass
,
comparator
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allLeavePass
);
LinkedHashSet
<
PersonEntity
>
mergeList
=
new
LinkedHashSet
<>(
allLeavePass
);
...
...
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