Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
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 fe373d0c
authored
Mar 15, 2022
by
王欣伟
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
离线规则修改完成
1 parent
08186e96
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
86 deletions
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
src/main/resources/mapper/VehicleMapper.xml
src/main/java/cn/com/glsx/admin/modules/service/VehicleService.java
View file @
fe373d0
...
...
@@ -66,6 +66,7 @@ import org.springframework.util.StopWatch;
import
java.io.FileNotFoundException
;
import
java.io.InputStream
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -1059,47 +1060,7 @@ public class VehicleService {
}
// 设置设备状态
List
<
String
>
sns
=
vehicleInfoList
.
stream
().
map
(
VehicleInfoPageDTO:
:
getSn
).
collect
(
Collectors
.
toList
());
DeviceSearchDTO
deviceSearchDTO
=
new
DeviceSearchDTO
();
deviceSearchDTO
.
setSns
(
sns
);
deviceSearchDTO
.
setOfflineTime
(
0L
);
log
.
info
(
"批量调用设备状态查询接口==="
+
JSON
.
toJSONString
(
deviceSearchDTO
));
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusR
=
deviceFeignService
.
listDeviceStatusBySns
(
deviceSearchDTO
);
log
.
info
(
"批量调用设备状态返回结果==="
+
JSON
.
toJSONString
(
listDeviceStatusR
));
if
(
listDeviceStatusR
!=
null
)
{
// 状态(0 行驶中 1 静止 2离线 3 在线)
List
<
DeviceStatusModel
>
deviceStatusModelList
=
listDeviceStatusR
.
getDataList
(
new
TypeToken
<
List
<
DeviceStatusModel
>>()
{
}.
getType
());
if
(
CollectionUtils
.
isNotEmpty
(
deviceStatusModelList
))
{
for
(
DeviceStatusModel
deviceStatusModel
:
deviceStatusModelList
)
{
Integer
deviceStatus
=
deviceStatusModel
.
getStatus
();
if
(
deviceStatus
!=
null
)
{
for
(
VehicleInfoPageDTO
vehicleInfoPageDTO
:
vehicleInfoList
)
{
if
(
vehicleInfoPageDTO
.
getSn
().
equals
(
deviceStatusModel
.
getSn
()))
{
vehicleInfoPageDTO
.
setDeviceState
(
deviceStatus
);
switch
(
deviceStatus
)
{
case
0
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"行驶中"
);
break
;
case
1
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"静止"
);
break
;
case
2
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"离线"
);
break
;
case
3
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"在线"
);
break
;
default
:
log
.
info
(
"不存在设备状态"
);
}
}
}
}
}
}
}
buildDeviceStatusCommon
(
vehicleInfoList
);
// 暂时删除设备状态的筛选条件
// if (search.getDeviceState() != null) {
...
...
@@ -1117,6 +1078,63 @@ public class VehicleService {
}
/**
* 给设备添加设备状态
* @param vehicleInfoList
*/
private
void
buildDeviceStatusCommon
(
List
<
VehicleInfoPageDTO
>
vehicleInfoList
)
{
if
(
CollectionUtil
.
isEmpty
(
vehicleInfoList
))
{
return
;
}
List
<
String
>
sns
=
vehicleInfoList
.
stream
().
map
(
VehicleInfoPageDTO:
:
getSn
).
collect
(
Collectors
.
toList
());
DeviceSearchDTO
deviceSearchDTO
=
new
DeviceSearchDTO
();
deviceSearchDTO
.
setSns
(
sns
);
deviceSearchDTO
.
setOfflineTime
(
0L
);
log
.
info
(
"批量调用设备状态查询接口==="
+
sns
.
size
());
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusR
=
deviceFeignService
.
listDeviceStatusBySns
(
deviceSearchDTO
);
log
.
info
(
"批量调用设备状态返回结果==="
+
((
listDeviceStatusR
!=
null
)?
listDeviceStatusR
.
getCode
():
"error"
));
if
(
listDeviceStatusR
==
null
)
{
return
;
}
// 状态(0 行驶中 1 静止 2离线 3 在线)
List
<
DeviceStatusModel
>
deviceStatusModelList
=
listDeviceStatusR
.
getDataList
(
new
TypeToken
<
List
<
DeviceStatusModel
>>()
{
}.
getType
());
if
(
CollectionUtil
.
isEmpty
(
deviceStatusModelList
))
{
return
;
}
Map
<
String
,
DeviceStatusModel
>
deviceStatusModelMap
=
deviceStatusModelList
.
stream
().
collect
(
Collectors
.
toMap
(
DeviceStatusModel:
:
getSn
,
Function
.
identity
(),(
v1
,
v2
)->
v1
));
for
(
VehicleInfoPageDTO
vehicleInfoPageDTO
:
vehicleInfoList
)
{
DeviceStatusModel
deviceStatusModel
=
deviceStatusModelMap
.
get
(
vehicleInfoPageDTO
.
getSn
());
Integer
deviceStatus
=
deviceStatusModel
.
getStatus
();
if
(
deviceStatus
==
null
)
{
continue
;
}
if
(
vehicleInfoPageDTO
.
getSn
().
equals
(
deviceStatusModel
.
getSn
()))
{
vehicleInfoPageDTO
.
setDeviceState
(
deviceStatus
);
switch
(
deviceStatus
)
{
case
0
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"行驶中"
);
break
;
case
1
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"静止"
);
break
;
case
2
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"离线"
);
break
;
case
3
:
vehicleInfoPageDTO
.
setDeviceStateStr
(
"在线"
);
break
;
default
:
log
.
info
(
"不存在设备状态"
);
}
}
}
}
/**
* 判断是否支持高阶调频
*
* @param vehicleInfoPageDTO 实体类
...
...
@@ -1215,45 +1233,7 @@ public class VehicleService {
}
// 设置设备状态
List
<
String
>
sns
=
vehicleInfoReportExportList
.
stream
().
map
(
VehicleInfoReportExport:
:
getSn
).
collect
(
Collectors
.
toList
());
DeviceSearchDTO
deviceSearchDTO
=
new
DeviceSearchDTO
();
deviceSearchDTO
.
setSns
(
sns
);
deviceSearchDTO
.
setOfflineTime
(
0L
);
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusR
=
deviceFeignService
.
listDeviceStatusBySns
(
deviceSearchDTO
);
if
(
listDeviceStatusR
!=
null
)
{
// 状态(0 行驶中 1 静止 2离线 3 在线)
List
<
DeviceStatusModel
>
deviceStatusModelList
=
listDeviceStatusR
.
getDataList
(
new
TypeToken
<
List
<
DeviceStatusModel
>>()
{
}.
getType
());
if
(
CollectionUtils
.
isNotEmpty
(
deviceStatusModelList
))
{
for
(
DeviceStatusModel
deviceStatusModel
:
deviceStatusModelList
)
{
Integer
deviceStatus
=
deviceStatusModel
.
getStatus
();
if
(
deviceStatus
!=
null
)
{
for
(
VehicleInfoReportExport
vehicleInfoReportExport
:
vehicleInfoReportExportList
)
{
if
(
vehicleInfoReportExport
.
getSn
().
equals
(
deviceStatusModel
.
getSn
()))
{
vehicleInfoReportExport
.
setDeviceState
(
deviceStatus
);
switch
(
deviceStatus
)
{
case
0
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"行驶中"
);
break
;
case
1
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"静止"
);
break
;
case
2
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"离线"
);
break
;
case
3
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"在线"
);
break
;
default
:
log
.
info
(
"不存在设备状态"
);
}
}
}
}
}
}
}
buildDeviceStatusExpert
(
vehicleInfoReportExportList
);
// 暂时删除设备状态的筛选条件
// if (search.getDeviceState() != null) {
...
...
@@ -1270,6 +1250,58 @@ public class VehicleService {
return
vehicleInfoReportExportList
;
}
/**
* 给导出数据增加设备状态
* @param vehicleInfoReportExportList
*/
private
void
buildDeviceStatusExpert
(
List
<
VehicleInfoReportExport
>
vehicleInfoReportExportList
)
{
if
(
CollectionUtil
.
isEmpty
(
vehicleInfoReportExportList
))
{
return
;
}
List
<
String
>
sns
=
vehicleInfoReportExportList
.
stream
().
map
(
VehicleInfoReportExport:
:
getSn
).
collect
(
Collectors
.
toList
());
DeviceSearchDTO
deviceSearchDTO
=
new
DeviceSearchDTO
();
deviceSearchDTO
.
setSns
(
sns
);
deviceSearchDTO
.
setOfflineTime
(
0L
);
R
<
List
<
DeviceStatusModel
>>
listDeviceStatusR
=
deviceFeignService
.
listDeviceStatusBySns
(
deviceSearchDTO
);
if
(
listDeviceStatusR
==
null
)
{
return
;
}
// 状态(0 行驶中 1 静止 2离线 3 在线)
List
<
DeviceStatusModel
>
deviceStatusModelList
=
listDeviceStatusR
.
getDataList
(
new
TypeToken
<
List
<
DeviceStatusModel
>>()
{
}.
getType
());
if
(
CollectionUtil
.
isEmpty
(
deviceStatusModelList
))
{
return
;
}
Map
<
String
,
DeviceStatusModel
>
deviceStatusModelMap
=
deviceStatusModelList
.
stream
().
collect
(
Collectors
.
toMap
(
DeviceStatusModel:
:
getSn
,
Function
.
identity
(),(
v1
,
v2
)->
v1
));
for
(
VehicleInfoReportExport
vehicleInfoReportExport
:
vehicleInfoReportExportList
)
{
DeviceStatusModel
deviceStatusModel
=
deviceStatusModelMap
.
get
(
vehicleInfoReportExport
.
getSn
());
Integer
deviceStatus
=
deviceStatusModel
.
getStatus
();
if
(
deviceStatus
==
null
)
{
continue
;
}
vehicleInfoReportExport
.
setDeviceState
(
deviceStatus
);
switch
(
deviceStatus
)
{
case
0
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"行驶中"
);
break
;
case
1
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"静止"
);
break
;
case
2
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"离线"
);
break
;
case
3
:
vehicleInfoReportExport
.
setDeviceStateStr
(
"在线"
);
break
;
default
:
log
.
info
(
"不存在设备状态"
);
}
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
addVehicleInfo
(
VehicleInfoVo
vehicleInfoVo
)
{
Vehicle
vehicle
=
new
Vehicle
();
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
fe373d0
...
...
@@ -740,9 +740,11 @@
and tvd.bind_status = 1
and tvd.del_flag = 0
<if
test=
"offlineStartTime != null and offlineStartTime != ''"
>
and ((tdl.last_gps_time
<
#{offlineStartTime} and tdl.last_bs_time
<
#{offlineStartTime}
and td.source = 1)
or (tdl.last_bs_time
<
#{offlineStartTime} and td.source = 0))
and ((tdl.last_gps_time
<
#{offlineStartTime} and tdl.last_bs_time
<
#{offlineStartTime})
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and tdl.last_bs_time
<
#{offlineStartTime})
or (tdl.last_gps_time
<
#{offlineStartTime} and tdl.last_bs_time is null)
)
</if>
<if
test=
"activeStartTime != null and activeStartTime != ''"
>
and tvd.created_date
>
= #{activeStartTime}
...
...
@@ -878,8 +880,11 @@
left join t_device td on td.sn = tvd.sn
left join t_device_location tdl on tdl.sn = td.sn
WHERE tvd.del_flag = 0 and tv.del_flag = 0 and tvd.bind_status = 1
and timestampdiff(SECOND, tdl.last_gps_time, now())
>
#{offlineTime}
and timestampdiff(SECOND, tdl.last_bs_time, now())
>
#{offlineTime}
and ((timestampdiff(SECOND, tdl.last_gps_time, now())
>
#{offlineTime} and timestampdiff(SECOND, tdl.last_bs_time, now())
>
#{offlineTime})
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and timestampdiff(SECOND, tdl.last_bs_time, now())
>
#{offlineTime})
or (timestampdiff(SECOND, tdl.last_gps_time, now())
>
#{offlineTime} and tdl.last_bs_time is null)
)
<if
test=
"offlineSnStr != null and offlineSnStr != ''"
>
and tvd.sn not in (${offlineSnStr})
</if>
...
...
@@ -924,7 +929,11 @@
and tvd.created_date > '2013-01-01 00:00:00.0'
<!--离线时间-->
<if
test=
"lostBegin != null"
>
and tdl.last_gps_time
<
#{lostBegin} and tdl.last_bs_time
<
#{lostBegin}
and ((tdl.last_gps_time
<
#{lostBegin} and tdl.last_bs_time
<
#{lostBegin})
or (tdl.last_gps_time is null and tdl.last_bs_time is null)
or (tdl.last_gps_time is null and tdl.last_bs_time
<
#{lostBegin})
or (tdl.last_gps_time
<
#{lostBegin} and tdl.last_bs_time is null)
)
</if>
</select>
...
...
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