Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
谢明辉
/
fanxing3-integration
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 91cb74e7
authored
Jun 14, 2022
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<fix>:优化推送数据,增加设备卡口关系缓存
1 parent
e19283fe
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
1 deletions
fanxing-docking-gb1400/src/main/java/com/viontech/handler/TrafficDataConvertHandler.java
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/DataCacheScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/handler/TrafficDataConvertHandler.java
View file @
91cb74e
...
@@ -2,6 +2,7 @@ package com.viontech.handler;
...
@@ -2,6 +2,7 @@ package com.viontech.handler;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.viontech.constant.RedisConstants
;
import
com.viontech.constant.RedisConstants
;
import
com.viontech.scheduled.DataCacheScheduled
;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.Gb1400GenerateIDUtil
;
import
com.viontech.utils.Gb1400GenerateIDUtil
;
import
com.viontech.vo.gb1400.*
;
import
com.viontech.vo.gb1400.*
;
...
@@ -309,7 +310,7 @@ public class TrafficDataConvertHandler {
...
@@ -309,7 +310,7 @@ public class TrafficDataConvertHandler {
//车辆信息
//车辆信息
Map
bodyMap
=
(
Map
)
vehicleMap
.
get
(
"body"
);
Map
bodyMap
=
(
Map
)
vehicleMap
.
get
(
"body"
);
if
(
bodyMap
!=
null
)
{
if
(
bodyMap
!=
null
)
{
csys
=
getCsysByVehicleBody
(
bodyMap
,
""
);
csys
=
getCsysByVehicleBody
(
bodyMap
,
"
Z
"
);
cllx
=
getCllxByVehicleBody
(
bodyMap
,
""
);
cllx
=
getCllxByVehicleBody
(
bodyMap
,
""
);
clpp
=
getClppByVehicleBody
(
bodyMap
,
""
);
clpp
=
getClppByVehicleBody
(
bodyMap
,
""
);
}
}
...
@@ -325,6 +326,11 @@ public class TrafficDataConvertHandler {
...
@@ -325,6 +326,11 @@ public class TrafficDataConvertHandler {
vehicle
.
setPassTime
(
passTime
);
vehicle
.
setPassTime
(
passTime
);
vehicle
.
setSourceID
(
gb1400GenerateIDUtil
.
generateSourceID
(
vehicle
.
getDeviceID
(),
"02"
,
vehicle
.
getPassTime
()));
vehicle
.
setSourceID
(
gb1400GenerateIDUtil
.
generateSourceID
(
vehicle
.
getDeviceID
(),
"02"
,
vehicle
.
getPassTime
()));
vehicle
.
setMotorVehicleID
(
gb1400GenerateIDUtil
.
generateMotorVehicleID
(
vehicle
.
getSourceID
(),
"02"
));
vehicle
.
setMotorVehicleID
(
gb1400GenerateIDUtil
.
generateMotorVehicleID
(
vehicle
.
getSourceID
(),
"02"
));
String
tollgateID
=
""
;
if
(
DataCacheScheduled
.
deviceTollgateMap
.
containsKey
(
deviceID
))
{
tollgateID
=
DataCacheScheduled
.
deviceTollgateMap
.
get
(
deviceID
);
}
vehicle
.
setTollgateID
(
tollgateID
);
vehicle
.
setBreakRuleMode
(
wflxProperties
.
getProperty
(
illCode
,
illCode
));
vehicle
.
setBreakRuleMode
(
wflxProperties
.
getProperty
(
illCode
,
illCode
));
vehicle
.
setStorageUrl1
(
picUrl
);
vehicle
.
setStorageUrl1
(
picUrl
);
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/DataCacheScheduled.java
0 → 100644
View file @
91cb74e
package
com
.
viontech
.
scheduled
;
import
com.viontech.service.TrafficEventService
;
import
com.viontech.vo.traffic.LaneModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
@Slf4j
@Component
public
class
DataCacheScheduled
implements
CommandLineRunner
{
//key:apeid,value:TollgateId
public
static
Map
<
String
,
String
>
deviceTollgateMap
=
new
ConcurrentHashMap
<>();
@Resource
private
TrafficEventService
trafficEventService
;
@Scheduled
(
cron
=
"0 0 2 * * ?"
)
public
void
flushCache
()
{
updateDeviceTollgateCache
();
}
@Override
public
void
run
(
String
...
args
)
throws
Exception
{
updateDeviceTollgateCache
();
}
private
void
updateDeviceTollgateCache
()
{
log
.
info
(
"开始更新设备与卡口关系缓存数据"
);
//查询
int
offset
=
0
;
int
limit
=
50
;
int
selectSize
=
0
;
int
num
=
0
;
do
{
LaneModel
laneQry
=
new
LaneModel
();
laneQry
.
setOffset
(
offset
);
laneQry
.
setLimit
(
limit
);
List
<
LaneModel
>
laneModels
=
trafficEventService
.
selectLaneDatas
(
laneQry
);
selectSize
=
laneModels
.
size
();
num
=
num
+
1
;
offset
=
limit
*
num
;
if
(!
CollectionUtils
.
isEmpty
(
laneModels
))
{
for
(
LaneModel
laneModel
:
laneModels
)
{
try
{
deviceTollgateMap
.
put
(
laneModel
.
getApeID
(),
laneModel
.
getTollgateID
());
}
catch
(
Exception
e
)
{
log
.
error
(
"deviceTollgateMap.put Exception"
,
e
);
}
}
}
}
while
(
selectSize
>=
limit
);
log
.
info
(
"结束更新设备与卡口关系缓存,共更新{}条"
,
deviceTollgateMap
.
size
());
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment