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 51ac3ca7
authored
Jun 28, 2022
by
毛树良
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
<fix>:优化查询
1 parent
b78d683d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
19 deletions
fanxing-docking-gb1400/src/main/java/com/viontech/handler/MilliDateTypeHandler.java
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TrafficIllegalScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TrafficVehicleScheduled.java
fanxing-docking-gb1400/src/main/java/com/viontech/utils/CheckUtil.java
fanxing-docking-gb1400/src/main/java/com/viontech/handler/MilliDateTypeHandler.java
View file @
51ac3ca
package
com
.
viontech
.
handler
;
package
com
.
viontech
.
handler
;
import
java.sql.CallableStatement
;
import
java.sql.*
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -21,14 +18,15 @@ public class MilliDateTypeHandler extends BaseTypeHandler<String> {
...
@@ -21,14 +18,15 @@ public class MilliDateTypeHandler extends BaseTypeHandler<String> {
@Override
@Override
public
void
setNonNullParameter
(
PreparedStatement
arg0
,
int
arg1
,
public
void
setNonNullParameter
(
PreparedStatement
arg0
,
int
arg1
,
String
arg2
,
JdbcType
arg3
)
throws
SQLException
{
String
arg2
,
JdbcType
arg3
)
throws
SQLException
{
Date
time
=
new
Date
();
// Date time = new Date();
try
{
// try {
time
=
DateUtil
.
dateFormat
(
arg2
);
// time = DateUtil.dateFormat(arg2);
}
catch
(
ParseException
e
)
{
// } catch (ParseException e) {
// TODO Auto-generated catch block
// // TODO Auto-generated catch block
e
.
printStackTrace
();
// e.printStackTrace();
}
// }
java
.
sql
.
Timestamp
sqlTimestamp
=
new
java
.
sql
.
Timestamp
(
time
.
getTime
());
// java.sql.Timestamp sqlTimestamp = new java.sql.Timestamp(time.getTime());
java
.
sql
.
Timestamp
sqlTimestamp
=
Timestamp
.
valueOf
(
arg2
);
arg0
.
setTimestamp
(
arg1
,
sqlTimestamp
);
arg0
.
setTimestamp
(
arg1
,
sqlTimestamp
);
}
}
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TrafficIllegalScheduled.java
View file @
51ac3ca
...
@@ -83,7 +83,9 @@ public class TrafficIllegalScheduled {
...
@@ -83,7 +83,9 @@ public class TrafficIllegalScheduled {
trafficMongoModels
.
add
(
trafficModel
);
trafficMongoModels
.
add
(
trafficModel
);
}
else
{
}
else
{
log
.
info
(
"ill.update.record:{}-{}"
,
trafficModel
.
getId
(),
trafficModel
.
getEvent_dt
());
log
.
info
(
"ill.update.record:{}-{}"
,
trafficModel
.
getId
(),
trafficModel
.
getEvent_dt
());
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LASTTIME
,
trafficModel
.
getEvent_dt
());
if
(
CheckUtil
.
checkTime
(
trafficModel
,
lastTimeUtc
))
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LASTTIME
,
trafficModel
.
getEvent_dt
());
}
}
}
}
}
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
...
@@ -93,8 +95,16 @@ public class TrafficIllegalScheduled {
...
@@ -93,8 +95,16 @@ public class TrafficIllegalScheduled {
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
TrafficMongoModel
last
=
trafficMongoModels
.
get
(
trafficMongoModels
.
size
()
-
1
);
TrafficMongoModel
last
=
trafficMongoModels
.
get
(
trafficMongoModels
.
size
()
-
1
);
log
.
info
(
"ill.update.record:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
log
.
info
(
"ill.update.record2:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LASTTIME
,
last
.
getEvent_dt
());
if
(
CheckUtil
.
checkTime
(
last
,
lastTimeUtc
))
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LASTTIME
,
last
.
getEvent_dt
());
}
else
{
log
.
info
(
"ill.update.record-false:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
Date
lastRecord
=
DateUtil
.
parse
(
lastTimeUtc
,
DateUtil
.
TIMESTAMP_FORMAT
);
Date
lastRecord1
=
DateUtil
.
addSeconds
(
lastRecord
,
1
);
String
lastRecord1Str
=
DateUtil
.
format
(
lastRecord1
,
DateUtil
.
TIMESTAMP_FORMAT
);
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_LASTTIME
,
lastRecord1Str
);
}
}
}
}
else
{
}
else
{
log
.
error
(
"trafficDataConvertHandler.trafficIllegalToSubscribeNotifications is null"
);
log
.
error
(
"trafficDataConvertHandler.trafficIllegalToSubscribeNotifications is null"
);
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/scheduled/TrafficVehicleScheduled.java
View file @
51ac3ca
...
@@ -72,7 +72,7 @@ public class TrafficVehicleScheduled {
...
@@ -72,7 +72,7 @@ public class TrafficVehicleScheduled {
trafficQry
.
setEvent_dt__lt
(
event_dt__lt
);
trafficQry
.
setEvent_dt__lt
(
event_dt__lt
);
trafficQry
.
setLimit
(
limit
);
trafficQry
.
setLimit
(
limit
);
trafficQry
.
setOffset
(
offset
);
trafficQry
.
setOffset
(
offset
);
log
.
info
(
"过车查询范围(lastTimeUtc,currentTimeUtc]=({},{}]
。
"
,
lastTimeUtc
,
currentTimeUtc
);
log
.
info
(
"过车查询范围(lastTimeUtc,currentTimeUtc]=({},{}]
!
"
,
lastTimeUtc
,
currentTimeUtc
);
List
<
Object
>
trafficModels
=
trafficEventService
.
selectJsonDatas
(
trafficQry
);
List
<
Object
>
trafficModels
=
trafficEventService
.
selectJsonDatas
(
trafficQry
);
log
.
info
(
"过车查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次待同步过车数据总{}条。"
,
lastTimeUtc
,
currentTimeUtc
,
trafficModels
.
size
());
log
.
info
(
"过车查询范围(lastTimeUtc,currentTimeUtc]=({},{}],本批次待同步过车数据总{}条。"
,
lastTimeUtc
,
currentTimeUtc
,
trafficModels
.
size
());
if
(!
CollectionUtils
.
isEmpty
(
trafficModels
))
{
if
(!
CollectionUtils
.
isEmpty
(
trafficModels
))
{
...
@@ -83,7 +83,9 @@ public class TrafficVehicleScheduled {
...
@@ -83,7 +83,9 @@ public class TrafficVehicleScheduled {
trafficMongoModels
.
add
(
trafficModel
);
trafficMongoModels
.
add
(
trafficModel
);
}
else
{
}
else
{
log
.
info
(
"gc.update.record:{}-{}"
,
trafficModel
.
getId
(),
trafficModel
.
getEvent_dt
());
log
.
info
(
"gc.update.record:{}-{}"
,
trafficModel
.
getId
(),
trafficModel
.
getEvent_dt
());
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_VEHICLE_LASTTIME
,
trafficModel
.
getEvent_dt
());
if
(
CheckUtil
.
checkTime
(
trafficModel
,
lastTimeUtc
))
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_VEHICLE_LASTTIME
,
trafficModel
.
getEvent_dt
());
}
}
}
}
}
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
//List<TrafficMongoModel> 转 SubscribeNotificationsObj
...
@@ -93,8 +95,16 @@ public class TrafficVehicleScheduled {
...
@@ -93,8 +95,16 @@ public class TrafficVehicleScheduled {
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
JsonMessage
resultVo
=
gb1400Service
.
subscribeNotifications
(
subscribeNotificationsObj
);
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
if
(
SystemConstants
.
APP_CODE_SUCCESS
==
resultVo
.
getCode
())
{
TrafficMongoModel
last
=
trafficMongoModels
.
get
(
trafficMongoModels
.
size
()
-
1
);
TrafficMongoModel
last
=
trafficMongoModels
.
get
(
trafficMongoModels
.
size
()
-
1
);
log
.
info
(
"gc.update.record:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
log
.
info
(
"gc.update.record2:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_VEHICLE_LASTTIME
,
last
.
getEvent_dt
());
if
(
CheckUtil
.
checkTime
(
last
,
lastTimeUtc
))
{
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_VEHICLE_LASTTIME
,
last
.
getEvent_dt
());
}
else
{
log
.
info
(
"gc.update.record-false:{}-{}"
,
last
.
getId
(),
last
.
getEvent_dt
());
Date
lastRecord
=
DateUtil
.
parse
(
lastTimeUtc
,
DateUtil
.
TIMESTAMP_FORMAT
);
Date
lastRecord1
=
DateUtil
.
addSeconds
(
lastRecord
,
1
);
String
lastRecord1Str
=
DateUtil
.
format
(
lastRecord1
,
DateUtil
.
TIMESTAMP_FORMAT
);
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
FANXING_TO_GB1400_VEHICLE_LASTTIME
,
lastRecord1Str
);
}
}
}
}
else
{
}
else
{
log
.
error
(
"trafficDataConvertHandler.trafficVehicleToSubscribeNotifications is null"
);
log
.
error
(
"trafficDataConvertHandler.trafficVehicleToSubscribeNotifications is null"
);
...
...
fanxing-docking-gb1400/src/main/java/com/viontech/utils/CheckUtil.java
View file @
51ac3ca
...
@@ -2,6 +2,7 @@ package com.viontech.utils;
...
@@ -2,6 +2,7 @@ package com.viontech.utils;
import
com.viontech.vo.traffic.TrafficMongoModel
;
import
com.viontech.vo.traffic.TrafficMongoModel
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -16,4 +17,14 @@ public class CheckUtil {
...
@@ -16,4 +17,14 @@ public class CheckUtil {
}
}
return
false
;
return
false
;
}
}
public
static
boolean
checkTime
(
TrafficMongoModel
last
,
String
lastTimeUtc
)
{
Date
lastDate
=
DateUtil
.
parse
(
lastTimeUtc
,
DateUtil
.
TIMESTAMP_FORMAT
);
Date
lastRecord
=
DateUtil
.
parse
(
last
.
getEvent_dt
(),
DateUtil
.
TIMESTAMP_FORMAT
);
if
(
lastRecord
.
getTime
()
>=
lastDate
.
getTime
())
{
return
true
;
}
else
{
return
false
;
}
}
}
}
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