Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
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
项目统一框架
amos-boot-biz
Commits
7831941b
Commit
7831941b
authored
Jun 18, 2025
by
wujiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交
parent
34102153
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
110 additions
and
91 deletions
+110
-91
JxiopCarIotListerServiceImpl.java
...quipmanage/service/impl/JxiopCarIotListerServiceImpl.java
+10
-7
WlCarMileageServiceImpl.java
...oin/equipmanage/service/impl/WlCarMileageServiceImpl.java
+100
-84
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/JxiopCarIotListerServiceImpl.java
View file @
7831941b
...
@@ -34,9 +34,7 @@ import java.net.HttpURLConnection;
...
@@ -34,9 +34,7 @@ import java.net.HttpURLConnection;
import
java.net.URL
;
import
java.net.URL
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -62,6 +60,8 @@ public class JxiopCarIotListerServiceImpl {
...
@@ -62,6 +60,8 @@ public class JxiopCarIotListerServiceImpl {
private
EmqKeeper
emqkeeper
;
private
EmqKeeper
emqkeeper
;
@Autowired
@Autowired
private
RedisTemplate
redisTemplate
;
private
RedisTemplate
redisTemplate
;
@Autowired
private
static
Map
<
String
,
Object
>
cache
=
new
HashMap
<>();
// @Async("equipAsyncExecutor")
// @Async("equipAsyncExecutor")
...
@@ -72,9 +72,11 @@ public class JxiopCarIotListerServiceImpl {
...
@@ -72,9 +72,11 @@ public class JxiopCarIotListerServiceImpl {
String
iotCode
=
measurement
+
deviceName
;
String
iotCode
=
measurement
+
deviceName
;
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
message
.
toString
());
//判断是否有效坐标
//判断是否有效坐标
if
(!
ObjectUtils
.
isEmpty
(
jsonObject
.
get
(
"FireCar_Longitude"
))
&&
!
ObjectUtils
.
isEmpty
(
jsonObject
.
get
(
"FireCar_Latitude"
)))
{
if
(!
ObjectUtils
.
isEmpty
(
jsonObject
.
get
(
"FireCar_Longitude"
))
&&
!
ObjectUtils
.
isEmpty
(
jsonObject
.
get
(
"FireCar_Latitude"
))
&&
cache
.
get
(
iotCode
)==
null
)
{
//判断是否存在未结束进程,如果不存在,则进入判断插入开始节点
//判断是否存在未结束进程,如果不存在,则进入判断插入开始节点
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
))
{
if
(
iWlCarMileageService
.
getUncompleteMileagByIotCode
(
iotCode
)&&
cache
.
get
(
iotCode
)==
null
)
{
cache
.
put
(
iotCode
,
iotCode
);
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
WlCarMileage
wlCarMileage
=
new
WlCarMileage
();
wlCarMileage
.
setIotCode
(
iotCode
);
wlCarMileage
.
setIotCode
(
iotCode
);
wlCarMileage
.
setDate
(
new
Date
());
wlCarMileage
.
setDate
(
new
Date
());
...
@@ -97,15 +99,16 @@ public class JxiopCarIotListerServiceImpl {
...
@@ -97,15 +99,16 @@ public class JxiopCarIotListerServiceImpl {
e
.
printStackTrace
();
e
.
printStackTrace
();
iWlCarMileageService
.
save
(
wlCarMileage
);
iWlCarMileageService
.
save
(
wlCarMileage
);
}
}
cache
.
remove
(
iotCode
);
}
}
this
.
updateCarLocation
(
jsonObject
,
iotCode
);
this
.
updateCarLocation
(
jsonObject
,
iotCode
);
String
coordinate
=
jsonObject
.
getString
(
"FireCar_Longitude"
)
+
","
+
jsonObject
.
getString
(
"FireCar_Latitude"
);
String
coordinate
=
jsonObject
.
getString
(
"FireCar_Longitude"
)
+
","
+
jsonObject
.
getString
(
"FireCar_Latitude"
);
if
(
ObjectUtils
.
isEmpty
(
redisTemplate
.
opsForValue
().
get
(
iotCode
)))
{
if
(
ObjectUtils
.
isEmpty
(
redisTemplate
.
opsForValue
().
get
(
iotCode
)))
{
redisTemplate
.
opsForValue
().
set
(
iotCode
,
coordinate
,
5
,
TimeUnit
.
MINUTES
);
redisTemplate
.
opsForValue
().
set
(
iotCode
,
coordinate
,
5
,
TimeUnit
.
MINUTES
);
logger
.
info
(
"首次入库redis:{}"
,
iotCode
);
//
logger.info("首次入库redis:{}", iotCode);
}
else
{
}
else
{
if
(!
String
.
valueOf
(
redisTemplate
.
opsForValue
().
get
(
iotCode
)).
equals
(
coordinate
))
{
if
(!
String
.
valueOf
(
redisTemplate
.
opsForValue
().
get
(
iotCode
)).
equals
(
coordinate
))
{
logger
.
info
(
"更新入库redis:{},旧:{},新:{}"
,
iotCode
,
redisTemplate
.
opsForValue
().
get
(
iotCode
),
coordinate
);
//
logger.info("更新入库redis:{},旧:{},新:{}", iotCode, redisTemplate.opsForValue().get(iotCode), coordinate);
redisTemplate
.
opsForValue
().
set
(
iotCode
,
coordinate
,
5
,
TimeUnit
.
MINUTES
);
redisTemplate
.
opsForValue
().
set
(
iotCode
,
coordinate
,
5
,
TimeUnit
.
MINUTES
);
}
}
}
}
...
...
amos-boot-module/amos-boot-module-biz/amos-boot-module-equip-biz/src/main/java/com/yeejoin/equipmanage/service/impl/WlCarMileageServiceImpl.java
View file @
7831941b
...
@@ -55,6 +55,7 @@ import java.text.DateFormat;
...
@@ -55,6 +55,7 @@ import java.text.DateFormat;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -317,103 +318,116 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
...
@@ -317,103 +318,116 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Scheduled
(
cron
=
"${mileage.segmentation.cron}"
)
@Scheduled
(
cron
=
"${mileage.segmentation.cron}"
)
@Async
@Async
public
void
mileageSegmentation
()
{
public
void
mileageSegmentation
()
{
log
.
info
(
"轨迹切分定时任务开始执行时间.............{}"
,
LocalDateTime
.
now
());
CarIotNewListener
.
pooledExecutor
.
submit
(()->{
Calendar
cal
=
Calendar
.
getInstance
();
log
.
info
(
"轨迹切分定时任务开始执行时间.............{}"
,
LocalDateTime
.
now
());
cal
.
setTime
(
new
Date
());
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
1
);
cal
.
setTime
(
new
Date
());
String
nowDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
cal
.
getTime
());
cal
.
add
(
Calendar
.
DATE
,
-
1
);
log
.
info
(
"轨迹切分定时任务数据过滤时间.............{}"
,
nowDate
);
String
nowDate
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
cal
.
getTime
());
List
<
WlCarMileage
>
list
=
this
.
baseMapper
.
list
(
nowDate
);
log
.
info
(
"轨迹切分定时任务数据过滤时间.............{}"
,
nowDate
);
log
.
info
(
"需要切分数据, {}"
,
list
);
List
<
WlCarMileage
>
list
=
this
.
baseMapper
.
list
(
nowDate
);
log
.
info
(
"销毁所有坐标信息成功"
);
// log.info("需要切分数据, {}", list);
log
.
info
(
"------------------跨天轨迹切分任开始切分里程-------------------------------"
);
// log.info("销毁所有坐标信息成功");
list
.
forEach
(
item
->
{
log
.
info
(
"------------------跨天轨迹切分任开始切分里程-------------------------------"
);
redisTemplate
.
delete
(
item
.
getIotCode
());
list
.
forEach
(
item
->
{
Calendar
calendar
=
Calendar
.
getInstance
();
//redisTemplate.delete(item.getIotCode());
calendar
.
setTime
(
item
.
getDate
());
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
add
(
Calendar
.
DATE
,
1
);
calendar
.
setTime
(
item
.
getDate
());
Date
date
=
calendar
.
getTime
();
calendar
.
add
(
Calendar
.
DATE
,
1
);
//iotcode有效
Date
date
=
calendar
.
getTime
();
if
(!
ObjectUtils
.
isEmpty
(
item
.
getIotCode
())
&&
item
.
getIotCode
().
length
()
>
8
)
{
//iotcode有效
// 查询车辆上报信息
if
(!
ObjectUtils
.
isEmpty
(
item
.
getIotCode
())
&&
item
.
getIotCode
().
length
()
>
8
)
{
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
item
.
getIotCode
().
substring
(
0
,
8
),
item
.
getIotCode
().
substring
(
8
),
// 查询车辆上报信息
item
.
getStartTime
(),
new
Date
(
new
Date
().
getTime
()
+
2000
));
ResponseModel
<
List
<
Object
>>
result
=
iotFeign
.
getLiveData
(
item
.
getIotCode
().
substring
(
0
,
8
),
item
.
getIotCode
().
substring
(
8
),
List
<
Object
>
list1
=
result
.
getResult
();
item
.
getStartTime
(),
new
Date
(
new
Date
().
getTime
()
+
2000
));
// 获取最后一个有坐标的数据
List
<
Object
>
list1
=
result
.
getResult
();
JSONObject
lastObj
=
null
;
// 获取最后一个有坐标的数据
// 过滤空坐标
JSONObject
lastObj
=
null
;
List
<
Object
>
filterList
=
new
ArrayList
<
Object
>();
// 过滤空坐标
for
(
int
i
=
0
;
i
<
list1
.
size
();
i
++)
{
List
<
Object
>
filterList
=
new
ArrayList
<
Object
>();
JSONObject
Obj
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list1
.
get
(
i
)));
for
(
int
i
=
0
;
i
<
list1
.
size
();
i
++)
{
if
(
Obj
.
get
(
"FireCar_Longitude"
)
!=
null
&&
Obj
.
get
(
"FireCar_Latitude"
)
!=
null
JSONObject
Obj
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
list1
.
get
(
i
)));
&&
Obj
.
getDoubleValue
(
"FireCar_Longitude"
)
!=
0
if
(
Obj
.
get
(
"FireCar_Longitude"
)
!=
null
&&
Obj
.
get
(
"FireCar_Latitude"
)
!=
null
&&
Obj
.
getDoubleValue
(
"FireCar_Latitude"
)
!=
0
)
{
&&
Obj
.
getDoubleValue
(
"FireCar_Longitude"
)
!=
0
filterList
.
add
(
list1
.
get
(
i
));
&&
Obj
.
getDoubleValue
(
"FireCar_Latitude"
)
!=
0
)
{
// 获取第一个不为空的坐标
filterList
.
add
(
list1
.
get
(
i
));
if
(
lastObj
==
null
)
{
// 获取第一个不为空的坐标
lastObj
=
Obj
;
if
(
lastObj
==
null
)
{
lastObj
=
Obj
;
}
}
}
}
}
}
if
(
lastObj
==
null
)
{
if
(
lastObj
==
null
)
{
lastObj
=
new
JSONObject
();
lastObj
=
new
JSONObject
();
lastObj
.
put
(
"FireCar_Longitude"
,
0.0
);
lastObj
.
put
(
"FireCar_Longitude"
,
0.0
);
lastObj
.
put
(
"FireCar_Latitude"
,
0.0
);
lastObj
.
put
(
"FireCar_Latitude"
,
0.0
);
lastObj
.
put
(
"time"
,
0
);
lastObj
.
put
(
"time"
,
0
);
lastObj
.
put
(
"FireCar_Speed"
,
0
);
lastObj
.
put
(
"FireCar_Speed"
,
0
);
}
}
// 当前坐标
// 当前坐标
double
startLongitude
=
lastObj
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLongitude
=
lastObj
.
getDoubleValue
(
"FireCar_Longitude"
);
double
startLatitude
=
lastObj
.
getDoubleValue
(
"FireCar_Latitude"
);
double
startLatitude
=
lastObj
.
getDoubleValue
(
"FireCar_Latitude"
);
// 当前速度
// 当前速度
Double
v
=
lastObj
.
getDoubleValue
(
"FireCar_Speed"
);
Double
v
=
lastObj
.
getDoubleValue
(
"FireCar_Speed"
);
item
.
setStartSpeed
(
v
.
intValue
());
item
.
setStartSpeed
(
v
.
intValue
());
double
travel
=
0.0
;
double
travel
=
0.0
;
// 获取里程
// 获取里程
for
(
int
i
=
0
;
i
<
filterList
.
size
()
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
filterList
.
size
()
-
1
;
i
++)
{
JSONObject
start
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
)));
JSONObject
start
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
)));
JSONObject
end
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
+
1
)));
JSONObject
end
=
JSONObject
.
parseObject
(
JSONObject
.
toJSONString
(
filterList
.
get
(
i
+
1
)));
travel
+=
CoordinateUtil
.
distance
(
start
.
getDoubleValue
(
"FireCar_Latitude"
),
travel
+=
CoordinateUtil
.
distance
(
start
.
getDoubleValue
(
"FireCar_Latitude"
),
start
.
getDoubleValue
(
"FireCar_Longitude"
),
end
.
getDoubleValue
(
"FireCar_Latitude"
),
start
.
getDoubleValue
(
"FireCar_Longitude"
),
end
.
getDoubleValue
(
"FireCar_Latitude"
),
end
.
getDoubleValue
(
"FireCar_Longitude"
));
end
.
getDoubleValue
(
"FireCar_Longitude"
));
}
}
// 里程耗时
// 里程耗时
long
takeTime
=
(
date
.
getTime
())
-
(
item
.
getStartTime
().
getTime
());
long
takeTime
=
(
date
.
getTime
())
-
(
item
.
getStartTime
().
getTime
());
// 查询车辆最新位置
// 查询车辆最新位置
// 修改0点未结束里程记录
// 修改0点未结束里程记录
item
.
setEndSpeed
(
v
.
intValue
());
item
.
setEndSpeed
(
v
.
intValue
());
item
.
setEndTime
(
date
);
item
.
setEndTime
(
date
);
item
.
setEndLatitude
(
startLatitude
);
item
.
setEndLatitude
(
startLatitude
);
item
.
setEndLongitude
(
startLongitude
);
item
.
setEndLongitude
(
startLongitude
);
item
.
setEndName
(
"无效坐标"
);
item
.
setEndName
(
"无效坐标"
);
if
(
travel
>
0.5
)
{
if
(
travel
>
0.5
)
{
String
address
=
getAddress
(
startLongitude
,
startLatitude
);
String
address
=
getAddress
(
startLongitude
,
startLatitude
);
item
.
setEndName
(
address
);
item
.
setEndName
(
address
);
}
item
.
setTravel
(
new
BigDecimal
(
travel
/
1000
).
setScale
(
1
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
());
item
.
setTakeTime
(
takeTime
);
this
.
getBaseMapper
().
updateById
(
item
);
log
.
info
(
"-----------跨天轨迹切分任更新车辆坐标成功:::"
+
JSONObject
.
toJSONString
(
item
)
+
"-----------------"
);
}
}
item
.
setTravel
(
new
BigDecimal
(
travel
/
1000
).
setScale
(
1
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
());
});
item
.
setTakeTime
(
takeTime
);
log
.
info
(
"-------------------跨天轨迹切分任务执行完成.............."
);
this
.
getBaseMapper
().
updateById
(
item
);
//删除过期的告警数据
log
.
info
(
"-----------跨天轨迹切分任更新车辆坐标成功:::"
+
JSONObject
.
toJSONString
(
item
)
+
"-----------------"
);
Date
endTime
=
DateUtil
.
offsetDay
(
new
Date
(),-
15
);
}
String
endTimeStr
=
DateUtil
.
format
(
endTime
,
"yyyy-MM-dd HH:mm:00"
);
wlCarSpeedWaringRecordMapper
.
delete
(
new
QueryWrapper
<
CarSpeedWarningRecord
>().
le
(
"waring_date"
,
endTimeStr
));
});
});
log
.
info
(
"-------------------跨天轨迹切分任务执行完成.............."
);
//删除过期的告警数据
Date
endTime
=
DateUtil
.
offsetDay
(
new
Date
(),-
15
);
String
endTimeStr
=
DateUtil
.
format
(
endTime
,
"yyyy-MM-dd HH:mm:00"
);
wlCarSpeedWaringRecordMapper
.
delete
(
new
QueryWrapper
<
CarSpeedWarningRecord
>().
le
(
"waring_date"
,
endTimeStr
));
}
}
@Scheduled
(
cron
=
"${mileage.splitmileage.cron}"
)
@Scheduled
(
cron
=
"${mileage.splitmileage.cron}"
)
@Async
@Async
public
void
endCarMileageTask
()
{
public
void
endCarMileageTask
()
{
log
.
info
(
"========开始轨迹切分任务==========="
);
CarIotNewListener
.
pooledExecutor
.
submit
(()->{
// 获取当前的日期和时间
LocalDateTime
now
=
LocalDateTime
.
now
();
// 定义日期时间格式化器
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
// 格式化当前日期时间并打印
String
formattedDateTime
=
now
.
format
(
formatter
);
log
.
info
(
"========开始轨迹切分任务==========="
+
formattedDateTime
);
log
.
info
(
"========开始轨迹切分任务==========="
+
formattedDateTime
);
log
.
info
(
"========开始轨迹切分任务==========="
+
formattedDateTime
);
log
.
info
(
"========开始轨迹切分任务==========="
+
formattedDateTime
);
log
.
info
(
"========开始轨迹切分任务==========="
+
formattedDateTime
);
List
<
WlCarMileage
>
list
=
wlCarMileageMapper
.
selectList
(
new
QueryWrapper
<
WlCarMileage
>().
isNull
(
"end_time"
).
isNotNull
(
"start_time"
));
List
<
WlCarMileage
>
list
=
wlCarMileageMapper
.
selectList
(
new
QueryWrapper
<
WlCarMileage
>().
isNull
(
"end_time"
).
isNotNull
(
"start_time"
));
list
.
forEach
(
item
->
{
list
.
forEach
(
item
->
{
log
.
info
(
"1获取code:{}"
,
item
.
getIotCode
());
//
log.info("1获取code:{}", item.getIotCode());
log
.
info
(
"2获取结果:{}"
,
ObjectUtils
.
isEmpty
(
redisTemplate
.
opsForValue
().
get
(
item
.
getIotCode
())));
//
log.info("2获取结果:{}", ObjectUtils.isEmpty(redisTemplate.opsForValue().get(item.getIotCode())));
if
(
ObjectUtils
.
isEmpty
(
redisTemplate
.
opsForValue
().
get
(
item
.
getIotCode
())))
{
if
(
ObjectUtils
.
isEmpty
(
redisTemplate
.
opsForValue
().
get
(
item
.
getIotCode
())))
{
if
(!
ObjectUtils
.
isEmpty
(
item
.
getIotCode
())
&&
item
.
getIotCode
().
length
()
>
8
)
{
if
(!
ObjectUtils
.
isEmpty
(
item
.
getIotCode
())
&&
item
.
getIotCode
().
length
()
>
8
)
{
log
.
info
(
"3处理结束坐标轨迹iocCode:{}"
,
item
.
getIotCode
());
log
.
info
(
"3处理结束坐标轨迹iocCode:{}"
,
item
.
getIotCode
());
...
@@ -485,12 +499,14 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
...
@@ -485,12 +499,14 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
}
}
}
}
});
});
log
.
info
(
"轨迹切分任务执行完成.............."
);
log
.
info
(
"轨迹切分任务执行完成.............."
);
log
.
info
(
"轨迹切分任务执行完成.............."
);
log
.
info
(
"轨迹切分任务执行完成.............."
);
//删除无效的告警数据
//删除无效的告警数据
Date
endTime
=
DateUtil
.
offsetMinute
(
new
Date
(),-
10
);
Date
endTime
=
DateUtil
.
offsetMinute
(
new
Date
(),-
10
);
String
endTimeStr
=
DateUtil
.
format
(
endTime
,
"yyyy-MM-dd HH:mm:00"
);
String
endTimeStr
=
DateUtil
.
format
(
endTime
,
"yyyy-MM-dd HH:mm:00"
);
wlCarSpeedWaringRecordMapper
.
delete
(
new
QueryWrapper
<
CarSpeedWarningRecord
>().
le
(
"waring_date"
,
endTimeStr
).
lt
(
"over_speed_count"
,
5
));
wlCarSpeedWaringRecordMapper
.
delete
(
new
QueryWrapper
<
CarSpeedWarningRecord
>().
le
(
"waring_date"
,
endTimeStr
).
lt
(
"over_speed_count"
,
5
));
});
}
}
@Override
@Override
...
...
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