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 1d58e920
authored
May 10, 2022
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加同步数据
1 parent
e092c22e
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
417 additions
and
45 deletions
fanxing-docking-gb1400/src/main/java/com/viontech/constant/RedisConstants.java
fanxing-docking-gb1400/src/main/java/com/viontech/handler/TrafficDataConvertHandler.java
fanxing-docking-gb1400/src/main/java/com/viontech/mapper/TrafficEventMapper.java
fanxing-docking-gb1400/src/main/java/com/viontech/mapping/TrafficEventMapper.xml
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/DeviceSyncScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/LaneSyncScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TollgateSyncScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/service/TrafficEventService.java
fanxing-docking-gb1400/src/main/java/com/viontech/service/impl/TrafficEventServiceImpl.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/APEList.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/LaneList.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/TollgateList.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/DeviceModel.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/LaneModel.java
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/TollgateModel.java
fanxing-docking-gb1400/src/main/java/com/viontech/constant/RedisConstants.java
View file @
1d58e92
...
...
@@ -11,6 +11,14 @@ public class RedisConstants {
*/
public
static
final
String
FANXING_TO_GB1400_LASTTIME
=
"fanxing:to:gb1400:lasttime"
;
/**
* 设备数据上次同步到的时间点
*/
public
static
final
String
FANXING_TO_GB1400_DEVICE_LASTTIME
=
"fanxing:to:gb1400:device:lasttime"
;
/**
* 卡口数据上次同步到的时间点
*/
public
static
final
String
FANXING_TO_GB1400_KAKOU_LASTTIME
=
"fanxing:to:gb1400:kakou:lasttime"
;
/**
* 车道数据上次同步到的时间点
*/
public
static
final
String
FANXING_TO_GB1400_LANE_LASTTIME
=
"fanxing:to:gb1400:lane:lasttime"
;
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/handler/TrafficDataConvertHandler.java
View file @
1d58e92
...
...
@@ -5,9 +5,13 @@ import com.viontech.constant.RedisConstants;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.Gb1400GenerateIDUtil
;
import
com.viontech.vo.gb1400.*
;
import
com.viontech.vo.traffic.DeviceModel
;
import
com.viontech.vo.traffic.LaneModel
;
import
com.viontech.vo.traffic.TollgateModel
;
import
com.viontech.vo.traffic.TrafficMongoModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
@@ -87,9 +91,9 @@ public class TrafficDataConvertHandler {
return
result
;
}
public
SubscribeNotificationsObj
deviceToSubscribeNotifications
(
List
<
TrafficMongoModel
>
trafficMongo
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
trafficMongo
Models
))
{
log
.
warn
(
"
trafficMongo
Models isEmpty"
);
public
SubscribeNotificationsObj
deviceToSubscribeNotifications
(
List
<
DeviceModel
>
device
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
device
Models
))
{
log
.
warn
(
"
device
Models isEmpty"
);
return
null
;
}
SubscribeNotificationsObj
result
=
new
SubscribeNotificationsObj
();
...
...
@@ -111,8 +115,9 @@ public class TrafficDataConvertHandler {
List
<
APEList
.
APE
>
apeList
=
new
ArrayList
<>();
StringBuilder
infoIds
=
new
StringBuilder
();
//设置设备数据
for
(
TrafficMongoModel
trafficMongoModel
:
trafficMongoModels
)
{
APEList
.
APE
ape
=
null
;
for
(
DeviceModel
deviceModel
:
deviceModels
)
{
APEList
.
APE
ape
=
new
APEList
.
APE
();
BeanUtils
.
copyProperties
(
deviceModel
,
ape
);
apeList
.
add
(
ape
);
if
(
""
.
equals
(
infoIds
.
toString
()))
{
...
...
@@ -132,9 +137,9 @@ public class TrafficDataConvertHandler {
return
result
;
}
public
SubscribeNotificationsObj
tollgateToSubscribeNotifications
(
List
<
T
rafficMongoModel
>
trafficMongo
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
t
rafficMongo
Models
))
{
log
.
warn
(
"t
rafficMongo
Models isEmpty"
);
public
SubscribeNotificationsObj
tollgateToSubscribeNotifications
(
List
<
T
ollgateModel
>
tollgate
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
t
ollgate
Models
))
{
log
.
warn
(
"t
ollgate
Models isEmpty"
);
return
null
;
}
SubscribeNotificationsObj
result
=
new
SubscribeNotificationsObj
();
...
...
@@ -156,8 +161,9 @@ public class TrafficDataConvertHandler {
List
<
TollgateList
.
Tollgate
>
tollgateList
=
new
ArrayList
<>();
StringBuilder
infoIds
=
new
StringBuilder
();
//设置卡口数据
for
(
TrafficMongoModel
trafficMongoModel
:
trafficMongoModels
)
{
TollgateList
.
Tollgate
tollgate
=
null
;
for
(
TollgateModel
tollgateModel
:
tollgateModels
)
{
TollgateList
.
Tollgate
tollgate
=
new
TollgateList
.
Tollgate
();
BeanUtils
.
copyProperties
(
tollgateModel
,
tollgate
);
tollgateList
.
add
(
tollgate
);
if
(
""
.
equals
(
infoIds
.
toString
()))
{
...
...
@@ -177,9 +183,9 @@ public class TrafficDataConvertHandler {
return
result
;
}
public
SubscribeNotificationsObj
laneToSubscribeNotifications
(
List
<
TrafficMongoModel
>
trafficMongo
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
trafficMongo
Models
))
{
log
.
warn
(
"
trafficMongo
Models isEmpty"
);
public
SubscribeNotificationsObj
laneToSubscribeNotifications
(
List
<
LaneModel
>
lane
Models
)
{
if
(
CollectionUtils
.
isEmpty
(
lane
Models
))
{
log
.
warn
(
"
lane
Models isEmpty"
);
return
null
;
}
SubscribeNotificationsObj
result
=
new
SubscribeNotificationsObj
();
...
...
@@ -201,8 +207,9 @@ public class TrafficDataConvertHandler {
List
<
LaneList
.
Lane
>
laneList
=
new
ArrayList
<>();
StringBuilder
infoIds
=
new
StringBuilder
();
//设置车道数据
for
(
TrafficMongoModel
trafficMongoModel
:
trafficMongoModels
)
{
LaneList
.
Lane
lane
=
null
;
for
(
LaneModel
laneModel
:
laneModels
)
{
LaneList
.
Lane
lane
=
new
LaneList
.
Lane
();
BeanUtils
.
copyProperties
(
laneModel
,
lane
);
laneList
.
add
(
lane
);
StringBuilder
laneSb
=
new
StringBuilder
();
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/mapper/TrafficEventMapper.java
View file @
1d58e92
package
com
.
viontech
.
mapper
;
import
com.viontech.vo.traffic.DeviceModel
;
import
com.viontech.vo.traffic.LaneModel
;
import
com.viontech.vo.traffic.TollgateModel
;
import
com.viontech.vo.traffic.TrafficModel
;
import
java.util.List
;
public
interface
TrafficEventMapper
{
List
<
Object
>
selectJsonDatas
(
TrafficModel
trafficModel
);
List
<
DeviceModel
>
selectDeviceDatas
(
DeviceModel
deviceModel
);
List
<
TollgateModel
>
selectTollgateDatas
(
TollgateModel
tollgateModel
);
List
<
LaneModel
>
selectLaneDatas
(
LaneModel
laneModel
);
}
fanxing-docking-gb1400/src/main/java/com/viontech/mapping/TrafficEventMapper.xml
View file @
1d58e92
...
...
@@ -11,6 +11,31 @@
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"modify_time"
jdbcType=
"TIMESTAMP"
property=
"modifyTime"
/>
</resultMap>
<resultMap
id=
"DeviceResultMap"
type=
"com.viontech.vo.traffic.DeviceModel"
>
<result
column=
"ape_id"
jdbcType=
"VARCHAR"
property=
"apeID"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"model"
jdbcType=
"VARCHAR"
property=
"model"
/>
<result
column=
"ip_addr"
jdbcType=
"VARCHAR"
property=
"ipAddr"
/>
<result
column=
"port"
jdbcType=
"INTEGER"
property=
"port"
/>
<result
column=
"longitude"
jdbcType=
"DECIMAL"
property=
"longitude"
/>
<result
column=
"latitude"
jdbcType=
"DECIMAL"
property=
"latitude"
/>
<result
column=
"place_code"
jdbcType=
"VARCHAR"
property=
"placeCode"
/>
<result
column=
"is_online"
jdbcType=
"VARCHAR"
property=
"isOnline"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"modify_time"
jdbcType=
"TIMESTAMP"
property=
"modifyTime"
/>
</resultMap>
<resultMap
id=
"TollgateResultMap"
type=
"com.viontech.vo.traffic.TollgateModel"
>
<result
column=
"tollgate_id"
jdbcType=
"VARCHAR"
property=
"tollgateID"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"longitude"
jdbcType=
"DECIMAL"
property=
"longitude"
/>
<result
column=
"latitude"
jdbcType=
"DECIMAL"
property=
"latitude"
/>
<result
column=
"place_code"
jdbcType=
"VARCHAR"
property=
"placeCode"
/>
<result
column=
"status"
jdbcType=
"VARCHAR"
property=
"status"
/>
<result
column=
"tollgate_cat"
jdbcType=
"VARCHAR"
property=
"tollgateCat"
/>
<result
column=
"tollgate_usage"
jdbcType=
"INTEGER"
property=
"tollgateUsage"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"modify_time"
jdbcType=
"TIMESTAMP"
property=
"modifyTime"
/>
</resultMap>
<!-- fetchSize="5000" -->
<select
id=
"selectJsonDatas"
parameterType=
"com.viontech.vo.traffic.TrafficModel"
resultType=
"java.lang.String"
fetchSize=
"5000"
>
...
...
@@ -173,6 +198,46 @@
</if>
</select>
<select
id=
"selectDeviceDatas"
parameterType=
"com.viontech.vo.traffic.DeviceModel"
resultMap=
"DeviceResultMap"
fetchSize=
"5000"
>
select ape_id,name,model,ip_addr,port,longitude,latitude,place_code,is_online,create_time,modify_time
from tb_device
<where>
<if
test=
"modifyTime_gte != null and modifyTime_gte != ''"
>
and modify_time > #{modifyTime_gte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime >= #{modifyTime_gte}-->
</if>
<if
test=
"modifyTime_lte != null and modifyTime_lte != ''"
>
and modify_time
<![CDATA[<=]]>
#{modifyTime_lte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime <![CDATA[<]]> #{modifyTime_lte}-->
</if>
</where>
order by modify_time asc
<if
test=
"limit != null and offset != null"
>
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
<select
id=
"selectTollgateDatas"
parameterType=
"com.viontech.vo.traffic.TollgateModel"
resultMap=
"TollgateResultMap"
fetchSize=
"5000"
>
select tollgate_id,name,longitude,latitude,place_code,status,tollgate_cat,tollgate_usage,create_time,modify_time
from tb_tollgate
<where>
<if
test=
"modifyTime_gte != null and modifyTime_gte != ''"
>
and modify_time > #{modifyTime_gte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime >= #{modifyTime_gte}-->
</if>
<if
test=
"modifyTime_lte != null and modifyTime_lte != ''"
>
and modify_time
<![CDATA[<=]]>
#{modifyTime_lte,typeHandler=com.viontech.handler.MilliDateTypeHandler}
<!-- and shoot_dtime <![CDATA[<]]> #{modifyTime_lte}-->
</if>
</where>
order by modify_time asc
<if
test=
"limit != null and offset != null"
>
LIMIT #{limit} OFFSET #{offset}
</if>
</select>
<select
id=
"selectLaneDatas"
parameterType=
"com.viontech.vo.traffic.LaneModel"
resultMap=
"LaneResultMap"
fetchSize=
"5000"
>
select tollgate_id,lane_id,lane_no,name,direction,ape_id,create_time,modify_time
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/DeviceSyncScheduled.java
0 → 100644
View file @
1d58e92
package
com
.
viontech
.
scheduled
;
import
com.viontech.constant.Gb1400Constants
;
import
com.viontech.constant.RedisConstants
;
import
com.viontech.constant.SystemConstants
;
import
com.viontech.handler.TrafficDataConvertHandler
;
import
com.viontech.service.Gb1400Service
;
import
com.viontech.service.TrafficEventService
;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.JsonMessage
;
import
com.viontech.vo.gb1400.SubscribeNotificationsObj
;
import
com.viontech.vo.traffic.DeviceModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author msl
* @date 2022/5/7
*/
@Slf4j
@Component
public
class
DeviceSyncScheduled
{
@Resource
private
TrafficEventService
trafficEventService
;
@Resource
private
Gb1400Service
gb1400Service
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
TrafficDataConvertHandler
trafficDataConvertHandler
;
@Scheduled
(
cron
=
"0 */2 * * * ?"
)
public
void
handleIllegal
()
{
log
.
info
(
"开始处理设备数据"
);
if
(!
Gb1400Constants
.
LinkStatus
)
{
return
;
}
Object
o
=
redisTemplate
.
opsForValue
().
get
(
RedisConstants
.
FANXING_TO_GB1400_DEVICE_LASTTIME
);
//上次对接到的设备记录时间
String
lastTimeUtc
=
""
;
if
(
o
==
null
)
{
//初次查询一小时前的数据,-12,-8:转UTC时间,总-20
lastTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
20
),
DateUtil
.
TIMESTAMP_FORMAT
);
}
else
{
lastTimeUtc
=
(
String
)
o
;
}
String
currentTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
8
),
DateUtil
.
TIMESTAMP_FORMAT
);
if
(
StringUtils
.
isBlank
(
lastTimeUtc
)
||
StringUtils
.
isBlank
(
currentTimeUtc
))
{
log
.
warn
(
"lastTimeUtc or currentTimeUtc isBlank"
);
return
;
}
//查询
DeviceModel
deviceQry
=
new
DeviceModel
();
deviceQry
.
setModifyTime_gte
(
lastTimeUtc
);
deviceQry
.
setModifyTime_lte
(
currentTimeUtc
);
deviceQry
.
setOffset
(
0
);
deviceQry
.
setLimit
(
10
);
List
<
DeviceModel
>
deviceModels
=
trafficEventService
.
selectDeviceDatas
(
deviceQry
);
log
.
info
(
"查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次设备待同步数据总{}条。"
,
lastTimeUtc
,
currentTimeUtc
,
deviceModels
.
size
());
if
(!
CollectionUtils
.
isEmpty
(
deviceModels
))
{
//List<DeviceModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj
subscribeNotificationsObj
=
trafficDataConvertHandler
.
deviceToSubscribeNotifications
(
deviceModels
);
//将设备数据同步gb1400
if
(
subscribeNotificationsObj
!=
null
)
{
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_DEVICE_LASTTIME
,
DateUtil
.
formatDate
(
deviceModels
.
get
(
deviceModels
.
size
()
-
1
).
getModifyTime
(),
DateUtil
.
TIMESTAMP_FORMAT
));
}
}
else
{
log
.
error
(
"trafficDataConvertHandler.deviceToSubscribeNotifications is null"
);
}
}
log
.
info
(
"结束处理设备数据"
);
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/LaneSyncScheduled.java
View file @
1d58e92
...
...
@@ -2,12 +2,17 @@ package com.viontech.scheduled;
import
com.viontech.constant.Gb1400Constants
;
import
com.viontech.constant.RedisConstants
;
import
com.viontech.constant.SystemConstants
;
import
com.viontech.handler.TrafficDataConvertHandler
;
import
com.viontech.service.Gb1400Service
;
import
com.viontech.service.TrafficEventService
;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.JsonMessage
;
import
com.viontech.vo.gb1400.SubscribeNotificationsObj
;
import
com.viontech.vo.traffic.LaneModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
...
@@ -43,16 +48,37 @@ public class LaneSyncScheduled {
//上次对接到的车道记录时间
String
lastTimeUtc
=
""
;
if
(
o
==
null
)
{
//初次查询
12小时前的数据
lastTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
12
),
DateUtil
.
TIMESTAMP_FORMAT
);
//初次查询
一小时前的数据,-12,-8:转UTC时间,总-20
lastTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
20
),
DateUtil
.
TIMESTAMP_FORMAT
);
}
else
{
lastTimeUtc
=
(
String
)
o
;
}
String
currentTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
8
),
DateUtil
.
TIMESTAMP_FORMAT
);
if
(
StringUtils
.
isBlank
(
lastTimeUtc
)
||
StringUtils
.
isBlank
(
currentTimeUtc
))
{
log
.
warn
(
"lastTimeUtc or currentTimeUtc isBlank"
);
return
;
}
//查询
LaneModel
laneQry
=
new
LaneModel
();
laneQry
.
setModifyTime_gte
(
lastTimeUtc
);
laneQry
.
setModifyTime_lte
(
currentTimeUtc
);
laneQry
.
setOffset
(
0
);
laneQry
.
setLimit
(
10
);
List
<
LaneModel
>
laneModels
=
trafficEventService
.
selectLaneDatas
(
laneQry
);
log
.
info
(
"查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次车道待同步数据总{}条。"
,
lastTimeUtc
,
currentTimeUtc
,
laneModels
.
size
());
if
(!
CollectionUtils
.
isEmpty
(
laneModels
))
{
//List<LaneModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj
subscribeNotificationsObj
=
trafficDataConvertHandler
.
laneToSubscribeNotifications
(
laneModels
);
//将车道数据同步gb1400
if
(
subscribeNotificationsObj
!=
null
)
{
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LANE_LASTTIME
,
DateUtil
.
formatDate
(
laneModels
.
get
(
laneModels
.
size
()
-
1
).
getModifyTime
(),
DateUtil
.
TIMESTAMP_FORMAT
));
}
}
else
{
log
.
error
(
"trafficDataConvertHandler.laneToSubscribeNotifications is null"
);
}
}
log
.
info
(
"结束处理车道数据"
);
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TollgateSyncScheduled.java
0 → 100644
View file @
1d58e92
package
com
.
viontech
.
scheduled
;
import
com.viontech.constant.Gb1400Constants
;
import
com.viontech.constant.RedisConstants
;
import
com.viontech.constant.SystemConstants
;
import
com.viontech.handler.TrafficDataConvertHandler
;
import
com.viontech.service.Gb1400Service
;
import
com.viontech.service.TrafficEventService
;
import
com.viontech.utils.DateUtil
;
import
com.viontech.utils.JsonMessage
;
import
com.viontech.vo.gb1400.SubscribeNotificationsObj
;
import
com.viontech.vo.traffic.LaneModel
;
import
com.viontech.vo.traffic.TollgateModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
import
java.util.List
;
/**
* @author msl
* @date 2022/5/7
*/
@Slf4j
@Component
public
class
TollgateSyncScheduled
{
@Resource
private
TrafficEventService
trafficEventService
;
@Resource
private
Gb1400Service
gb1400Service
;
@Autowired
private
RedisTemplate
redisTemplate
;
@Autowired
private
TrafficDataConvertHandler
trafficDataConvertHandler
;
@Scheduled
(
cron
=
"0 */2 * * * ?"
)
public
void
handleIllegal
()
{
log
.
info
(
"开始处理卡口数据"
);
if
(!
Gb1400Constants
.
LinkStatus
)
{
return
;
}
Object
o
=
redisTemplate
.
opsForValue
().
get
(
RedisConstants
.
FANXING_TO_GB1400_KAKOU_LASTTIME
);
//上次对接到的卡口记录时间
String
lastTimeUtc
=
""
;
if
(
o
==
null
)
{
//初次查询一小时前的数据,-12,-8:转UTC时间,总-20
lastTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
20
),
DateUtil
.
TIMESTAMP_FORMAT
);
}
else
{
lastTimeUtc
=
(
String
)
o
;
}
String
currentTimeUtc
=
DateUtil
.
formatDate
(
DateUtil
.
addHours
(
new
Date
(),
-
8
),
DateUtil
.
TIMESTAMP_FORMAT
);
if
(
StringUtils
.
isBlank
(
lastTimeUtc
)
||
StringUtils
.
isBlank
(
currentTimeUtc
))
{
log
.
warn
(
"lastTimeUtc or currentTimeUtc isBlank"
);
return
;
}
//查询
TollgateModel
tollgateQry
=
new
TollgateModel
();
tollgateQry
.
setModifyTime_gte
(
lastTimeUtc
);
tollgateQry
.
setModifyTime_lte
(
currentTimeUtc
);
tollgateQry
.
setOffset
(
0
);
tollgateQry
.
setLimit
(
10
);
List
<
TollgateModel
>
tollgateModels
=
trafficEventService
.
selectTollgateDatas
(
tollgateQry
);
log
.
info
(
"查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次卡口待同步数据总{}条。"
,
lastTimeUtc
,
currentTimeUtc
,
tollgateModels
.
size
());
if
(!
CollectionUtils
.
isEmpty
(
tollgateModels
))
{
//List<TollgateModel> 转 SubscribeNotificationsObj
SubscribeNotificationsObj
subscribeNotificationsObj
=
trafficDataConvertHandler
.
tollgateToSubscribeNotifications
(
tollgateModels
);
//将卡口数据同步gb1400
if
(
subscribeNotificationsObj
!=
null
)
{
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_KAKOU_LASTTIME
,
DateUtil
.
formatDate
(
tollgateModels
.
get
(
tollgateModels
.
size
()
-
1
).
getModifyTime
(),
DateUtil
.
TIMESTAMP_FORMAT
));
}
}
else
{
log
.
error
(
"trafficDataConvertHandler.tollgateToSubscribeNotifications is null"
);
}
}
log
.
info
(
"结束处理卡口数据"
);
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/service/TrafficEventService.java
View file @
1d58e92
package
com
.
viontech
.
service
;
import
com.viontech.vo.traffic.DeviceModel
;
import
com.viontech.vo.traffic.LaneModel
;
import
com.viontech.vo.traffic.TollgateModel
;
import
com.viontech.vo.traffic.TrafficModel
;
import
java.util.List
;
public
interface
TrafficEventService
{
List
<
Object
>
selectJsonDatas
(
TrafficModel
trafficModel
);
List
<
DeviceModel
>
selectDeviceDatas
(
DeviceModel
deviceModel
);
List
<
TollgateModel
>
selectTollgateDatas
(
TollgateModel
tollgateModel
);
List
<
LaneModel
>
selectLaneDatas
(
LaneModel
laneModel
);
}
fanxing-docking-gb1400/src/main/java/com/viontech/service/impl/TrafficEventServiceImpl.java
View file @
1d58e92
...
...
@@ -2,7 +2,9 @@ package com.viontech.service.impl;
import
com.viontech.mapper.TrafficEventMapper
;
import
com.viontech.service.TrafficEventService
;
import
com.viontech.vo.traffic.DeviceModel
;
import
com.viontech.vo.traffic.LaneModel
;
import
com.viontech.vo.traffic.TollgateModel
;
import
com.viontech.vo.traffic.TrafficModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -21,6 +23,16 @@ public class TrafficEventServiceImpl implements TrafficEventService {
}
@Override
public
List
<
DeviceModel
>
selectDeviceDatas
(
DeviceModel
deviceModel
)
{
return
trafficEventMapper
.
selectDeviceDatas
(
deviceModel
);
}
@Override
public
List
<
TollgateModel
>
selectTollgateDatas
(
TollgateModel
tollgateModel
)
{
return
trafficEventMapper
.
selectTollgateDatas
(
tollgateModel
);
}
@Override
public
List
<
LaneModel
>
selectLaneDatas
(
LaneModel
laneModel
)
{
return
trafficEventMapper
.
selectLaneDatas
(
laneModel
);
}
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/APEList.java
View file @
1d58e92
...
...
@@ -3,6 +3,7 @@ package com.viontech.vo.gb1400;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
...
...
@@ -16,22 +17,22 @@ public class APEList {
@Data
public
static
class
APE
{
@JSONField
(
name
=
"ApeID"
)
private
String
A
peID
;
private
String
a
peID
;
@JSONField
(
name
=
"Name"
)
private
String
N
ame
;
private
String
n
ame
;
@JSONField
(
name
=
"Model"
)
private
String
M
odel
;
private
String
m
odel
;
@JSONField
(
name
=
"IPAddr"
)
private
String
IP
Addr
;
private
String
ip
Addr
;
@JSONField
(
name
=
"Port"
)
private
Integer
P
ort
;
@JSONField
(
name
=
"Long
t
itude"
)
private
Double
Longt
itude
;
private
Integer
p
ort
;
@JSONField
(
name
=
"Longitude"
)
private
BigDecimal
long
itude
;
@JSONField
(
name
=
"Latitude"
)
private
Double
L
atitude
;
private
BigDecimal
l
atitude
;
@JSONField
(
name
=
"PlaceCode"
)
private
String
P
laceCode
;
private
String
p
laceCode
;
@JSONField
(
name
=
"IsOnline"
)
private
String
I
sOnline
;
private
String
i
sOnline
;
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/LaneList.java
View file @
1d58e92
...
...
@@ -16,16 +16,16 @@ public class LaneList {
@Data
public
static
class
Lane
{
@JSONField
(
name
=
"TollgateID"
)
private
String
T
ollgateID
;
private
String
t
ollgateID
;
@JSONField
(
name
=
"LaneId"
)
private
Integer
L
aneId
;
private
Integer
l
aneId
;
@JSONField
(
name
=
"LaneNo"
)
private
Integer
L
aneNo
;
private
Integer
l
aneNo
;
@JSONField
(
name
=
"Name"
)
private
String
N
ame
;
private
String
n
ame
;
@JSONField
(
name
=
"Direction"
)
private
String
D
irection
;
private
String
d
irection
;
@JSONField
(
name
=
"ApeID"
)
private
String
A
peID
;
private
String
a
peID
;
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/vo/gb1400/TollgateList.java
View file @
1d58e92
...
...
@@ -3,6 +3,7 @@ package com.viontech.vo.gb1400;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
...
...
@@ -16,20 +17,20 @@ public class TollgateList {
@Data
public
static
class
Tollgate
{
@JSONField
(
name
=
"TollgateID"
)
private
String
T
ollgateID
;
private
String
t
ollgateID
;
@JSONField
(
name
=
"Name"
)
private
String
N
ame
;
@JSONField
(
name
=
"Long
t
itude"
)
private
Double
Longt
itude
;
@JSONField
(
name
=
"Latitue"
)
private
Double
Latitu
e
;
private
String
n
ame
;
@JSONField
(
name
=
"Longitude"
)
private
BigDecimal
long
itude
;
@JSONField
(
name
=
"Latitu
d
e"
)
private
BigDecimal
latitud
e
;
@JSONField
(
name
=
"PlaceCode"
)
private
String
P
laceCode
;
private
String
p
laceCode
;
@JSONField
(
name
=
"Status"
)
private
String
S
tatus
;
private
String
s
tatus
;
@JSONField
(
name
=
"TollgateCat"
)
private
String
T
ollgateCat
;
private
String
t
ollgateCat
;
@JSONField
(
name
=
"TollgateUsage"
)
private
Integer
T
ollgateUsage
;
private
Integer
t
ollgateUsage
;
}
}
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/DeviceModel.java
0 → 100644
View file @
1d58e92
package
com
.
viontech
.
vo
.
traffic
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @author msl
* @date 2022/5/7
*/
@Data
@JsonInclude
(
value
=
JsonInclude
.
Include
.
NON_NULL
)
public
class
DeviceModel
{
private
String
apeID
;
private
String
name
;
private
String
model
;
private
String
ipAddr
;
private
Integer
port
;
private
BigDecimal
longitude
;
private
BigDecimal
latitude
;
private
String
placeCode
;
private
String
isOnline
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 修改时间
*/
private
Date
modifyTime
;
//
private
String
modifyTime_gte
;
private
String
modifyTime_lte
;
private
Integer
offset
;
private
Integer
limit
;
}
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/LaneModel.java
View file @
1d58e92
...
...
@@ -22,12 +22,10 @@ public class LaneModel {
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Date
createTime
;
/**
* 修改时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Date
modifyTime
;
//
private
String
modifyTime_gte
;
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/vo/traffic/TollgateModel.java
0 → 100644
View file @
1d58e92
package
com
.
viontech
.
vo
.
traffic
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @author msl
* @date 2022/5/7
*/
@Data
@JsonInclude
(
value
=
JsonInclude
.
Include
.
NON_NULL
)
public
class
TollgateModel
{
private
String
tollgateID
;
private
String
name
;
private
BigDecimal
longitude
;
private
BigDecimal
latitude
;
private
String
placeCode
;
private
String
status
;
private
String
tollgateCat
;
private
Integer
tollgateUsage
;
/**
* 创建时间
*/
private
Date
createTime
;
/**
* 修改时间
*/
private
Date
modifyTime
;
//
private
String
modifyTime_gte
;
private
String
modifyTime_lte
;
private
Integer
offset
;
private
Integer
limit
;
}
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