Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-standard-interfaces
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
1
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7feb8ef6
authored
May 17, 2022
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
优化激活信息保存方式
1 parent
3487b5c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
8 deletions
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleDeviceMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/multithread/AsyncTasks.java
src/main/resources/mapper/VehicleDeviceMapper.xml
src/test/java/cn/com/glsx/stdinterface/modules/service/DeviceActiveServiceTest.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleDeviceMapper.java
View file @
7feb8ef
...
@@ -36,4 +36,6 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
...
@@ -36,4 +36,6 @@ public interface VehicleDeviceMapper extends CommonBaseMapper<VehicleDevice> {
List
<
String
>
getUnActiveInfoSnList
(
@Param
(
"dayTimeFormat"
)
String
dayTimeFormat
);
List
<
String
>
getUnActiveInfoSnList
(
@Param
(
"dayTimeFormat"
)
String
dayTimeFormat
);
List
<
String
>
getAllUnActiveInfoSnList
();
List
<
String
>
getAllUnActiveInfoSnList
();
Integer
updateVehicleDeviceBysn
(
VehicleDevice
vehicleDevice
);
}
}
src/main/java/cn/com/glsx/stdinterface/modules/multithread/AsyncTasks.java
View file @
7feb8ef
...
@@ -44,7 +44,8 @@ public class AsyncTasks {
...
@@ -44,7 +44,8 @@ public class AsyncTasks {
return
;
return
;
}
}
lastGpsBsList
.
forEach
(
gpsBsData
->
{
lastGpsBsList
.
forEach
(
gpsBsData
->
{
VehicleDevice
vehicleDevice
=
vehicleDeviceMapper
.
selectBindingDeviceBySn
(
gpsBsData
.
getSn
());
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
vehicleDevice
.
setSn
(
gpsBsData
.
getSn
());
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
// 默认保存GPS定位数据 没有GPS定位数据 保存BS定位数据
// 默认保存GPS定位数据 没有GPS定位数据 保存BS定位数据
if
(
Objects
.
nonNull
(
gpsLocation
))
{
if
(
Objects
.
nonNull
(
gpsLocation
))
{
...
@@ -53,6 +54,9 @@ public class AsyncTasks {
...
@@ -53,6 +54,9 @@ public class AsyncTasks {
vehicleDevice
.
setActiveLocationLng
(
gpsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLng
(
gpsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLat
(
gpsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationLat
(
gpsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationAddress
(
gpsLocation
.
getAddress
());
vehicleDevice
.
setActiveLocationAddress
(
gpsLocation
.
getAddress
());
// 保存激活信息
log
.
info
(
"active device info gps:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateVehicleDeviceBysn
(
vehicleDevice
);
}
else
{
}
else
{
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
if
(
Objects
.
nonNull
(
bsLocation
))
{
if
(
Objects
.
nonNull
(
bsLocation
))
{
...
@@ -61,11 +65,11 @@ public class AsyncTasks {
...
@@ -61,11 +65,11 @@ public class AsyncTasks {
vehicleDevice
.
setActiveLocationLng
(
bsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLng
(
bsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLat
(
bsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationLat
(
bsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationAddress
(
bsLocation
.
getAddress
());
vehicleDevice
.
setActiveLocationAddress
(
bsLocation
.
getAddress
());
// 保存激活信息
log
.
info
(
"active device info bs:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateVehicleDeviceBysn
(
vehicleDevice
);
}
}
}
}
// 保存激活信息
log
.
info
(
"active device info:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateByPrimaryKeySelective
(
vehicleDevice
);
});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"saveActiveInfo异常信息==="
+
e
.
getMessage
());
log
.
info
(
"saveActiveInfo异常信息==="
+
e
.
getMessage
());
...
@@ -97,7 +101,8 @@ public class AsyncTasks {
...
@@ -97,7 +101,8 @@ public class AsyncTasks {
return
;
return
;
}
}
lastGpsBsList
.
forEach
(
gpsBsData
->
{
lastGpsBsList
.
forEach
(
gpsBsData
->
{
VehicleDevice
vehicleDevice
=
vehicleDeviceMapper
.
selectBindingDeviceBySn
(
gpsBsData
.
getSn
());
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
vehicleDevice
.
setSn
(
gpsBsData
.
getSn
());
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
// 默认保存GPS定位数据 没有GPS定位数据 保存BS定位数据
// 默认保存GPS定位数据 没有GPS定位数据 保存BS定位数据
if
(
Objects
.
nonNull
(
gpsLocation
))
{
if
(
Objects
.
nonNull
(
gpsLocation
))
{
...
@@ -106,6 +111,9 @@ public class AsyncTasks {
...
@@ -106,6 +111,9 @@ public class AsyncTasks {
vehicleDevice
.
setActiveLocationLng
(
gpsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLng
(
gpsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLat
(
gpsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationLat
(
gpsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationAddress
(
gpsLocation
.
getAddress
());
vehicleDevice
.
setActiveLocationAddress
(
gpsLocation
.
getAddress
());
// 保存激活信息
log
.
info
(
"active device info by task gps:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateVehicleDeviceBysn
(
vehicleDevice
);
}
else
{
}
else
{
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
if
(
Objects
.
nonNull
(
bsLocation
))
{
if
(
Objects
.
nonNull
(
bsLocation
))
{
...
@@ -114,11 +122,11 @@ public class AsyncTasks {
...
@@ -114,11 +122,11 @@ public class AsyncTasks {
vehicleDevice
.
setActiveLocationLng
(
bsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLng
(
bsLocation
.
getLng
());
vehicleDevice
.
setActiveLocationLat
(
bsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationLat
(
bsLocation
.
getLat
());
vehicleDevice
.
setActiveLocationAddress
(
bsLocation
.
getAddress
());
vehicleDevice
.
setActiveLocationAddress
(
bsLocation
.
getAddress
());
// 保存激活信息
log
.
info
(
"active device info by task bs:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateVehicleDeviceBysn
(
vehicleDevice
);
}
}
}
}
// 保存激活信息
log
.
info
(
"active device info by task:"
+
JSONUtil
.
toJsonStr
(
vehicleDevice
));
vehicleDeviceMapper
.
updateByPrimaryKeySelective
(
vehicleDevice
);
});
});
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"saveActiveInfoByTask异常信息==="
+
e
.
getMessage
());
log
.
info
(
"saveActiveInfoByTask异常信息==="
+
e
.
getMessage
());
...
...
src/main/resources/mapper/VehicleDeviceMapper.xml
View file @
7feb8ef
...
@@ -100,4 +100,15 @@
...
@@ -100,4 +100,15 @@
and bind_status = 1
and bind_status = 1
and active_location_date is null
and active_location_date is null
</select>
</select>
<update
id=
"updateVehicleDeviceBysn"
>
update t_vehicle_device
set
active_location_date = #{activeLocationDate},
active_location_type = #{activeLocationType},
active_location_lat = #{activeLocationLat},
active_location_lng = #{activeLocationLng},
active_location_address = #{activeLocationAddress}
where sn = #{sn}
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
src/test/java/cn/com/glsx/stdinterface/modules/service/DeviceActiveServiceTest.java
View file @
7feb8ef
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
service
;
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
service
;
import
java.util.Date
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDevice
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -16,10 +20,27 @@ public class DeviceActiveServiceTest {
...
@@ -16,10 +20,27 @@ public class DeviceActiveServiceTest {
@Autowired
@Autowired
private
DeviceActiveService
deviceActiveService
;
private
DeviceActiveService
deviceActiveService
;
@Autowired
VehicleDeviceMapper
vehicleDeviceMapper
;
@Test
@Test
public
void
saveActiveInfoFlushAll
()
{
public
void
saveActiveInfoFlushAll
()
{
System
.
out
.
println
(
"start==="
);
System
.
out
.
println
(
"start==="
);
deviceActiveService
.
saveActiveInfoFlushAll
();
deviceActiveService
.
saveActiveInfoFlushAll
();
System
.
out
.
println
(
"end==="
);
System
.
out
.
println
(
"end==="
);
}
}
@Test
public
void
test01
()
{
System
.
out
.
println
(
"start==="
);
VehicleDevice
vehicleDevice
=
new
VehicleDevice
();
vehicleDevice
.
setSn
(
"1511213547"
);
vehicleDevice
.
setActiveLocationDate
(
new
Date
());
// vehicleDevice.setActiveLocationLng("114.025984");
// vehicleDevice.setActiveLocationLat("22.546064");
vehicleDevice
.
setActiveLocationType
(
0
);
vehicleDevice
.
setActiveLocationAddress
(
"广东省深圳市福田区展鹏足球俱乐部"
);
vehicleDeviceMapper
.
updateVehicleDeviceBysn
(
vehicleDevice
);
System
.
out
.
println
(
"end==="
);
}
}
}
\ No newline at end of file
\ No newline at end of file
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