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 83008498
authored
Dec 30, 2021
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
设备位置点数据落库
1 parent
b548cd96
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
40 deletions
src/main/java/cn/com/glsx/stdinterface/modules/controller/DeviceLocationController.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DeviceLocationMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/model/DeviceLocation.java
src/main/java/cn/com/glsx/stdinterface/modules/service/DeviceLocationService.java
src/main/resources/mapper/DeviceLocationMapper.xml
src/main/java/cn/com/glsx/stdinterface/modules/controller/DeviceLocationController.java
View file @
8300849
...
...
@@ -5,8 +5,6 @@ import cn.com.glsx.stdinterface.dto.DeviceLocationDto;
import
cn.com.glsx.stdinterface.modules.model.LocationCheckBO
;
import
cn.com.glsx.stdinterface.modules.service.DeviceLocationService
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.common.annotation.SysLog
;
import
com.glsx.plat.common.enums.OperateType
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -34,32 +32,30 @@ public class DeviceLocationController implements DeviceLocationClient {
private
DeviceLocationService
deviceLocationService
;
@Override
@PostMapping
(
value
=
"/saveorupdatedevicelocationdata"
)
@SysLog
(
module
=
MODULE
,
value
=
"插入或者更新设备上点数据"
,
action
=
OperateType
.
EDIT
)
@ApiOperation
(
value
=
"插入或者更新设备上点数据"
)
@PostMapping
(
value
=
"/dropLibrary"
)
@ApiOperation
(
value
=
"设备位置点数据落库"
)
@ResponseBody
public
R
saveOrUpdateDeviceLocationData
(
Collection
<
DeviceLocationDto
>
deviceLocationDtos
)
{
public
R
dropLibrary
(
Collection
<
DeviceLocationDto
>
deviceLocationDtos
)
{
log
.
info
(
"插入或者更新设备上点数据大小==="
+
deviceLocationDtos
.
size
());
deviceLocationService
.
saveOrUpdateDeviceLocationData
(
deviceLocationDtos
);
deviceLocationService
.
dropLibrary
(
deviceLocationDtos
);
return
R
.
ok
();
}
@Override
@GetMapping
(
value
=
"/getallsninneweshield"
)
@SysLog
(
module
=
MODULE
,
value
=
"获取E盾中的所有设备号集合"
,
action
=
OperateType
.
QUERY
)
@GetMapping
(
value
=
"/getAllSn"
)
@ApiOperation
(
value
=
"获取E盾中的所有设备号集合"
)
@ResponseBody
public
R
<
List
<
String
>>
getAllSn
InNewEshield
()
{
public
R
<
List
<
String
>>
getAllSn
()
{
List
<
String
>
allSns
=
deviceLocationService
.
getAllSnInNewEshield
();
log
.
info
(
"E盾中的所有设备号==="
+
JSON
.
toJSONString
(
allSns
));
return
R
.
ok
().
data
(
allSns
);
}
@PostMapping
(
value
=
"/check"
)
@SysLog
(
module
=
MODULE
,
value
=
"设备位置点验证"
,
action
=
OperateType
.
AUDIT
)
@ApiOperation
(
value
=
"设备位置点验证"
)
public
R
check
(
@RequestBody
LocationCheckBO
checkBO
)
{
deviceLocationService
.
locationCheck
(
checkBO
);
return
R
.
ok
();
}
}
src/main/java/cn/com/glsx/stdinterface/modules/mapper/DeviceLocationMapper.java
View file @
8300849
...
...
@@ -21,15 +21,16 @@ public interface DeviceLocationMapper extends CommonBaseMapper<DeviceLocation> {
*
* @return 设备集合
*/
List
<
String
>
getAllSnInNewEshield
();
List
<
String
>
selectAllSn
();
DeviceLocation
getDeviceLocation
BySn
(
@Param
(
"sn"
)
String
sn
);
DeviceLocation
select
BySn
(
@Param
(
"sn"
)
String
sn
);
/**
* 保存和更新设备定位报表
*
* @param
deviceLocationDtoL
ist 设备定位集合
* @param
l
ist 设备定位集合
* @return
*/
Integer
saveOrUpdateDeviceLocationData
(
@Param
(
"deviceLocationDtoList"
)
Collection
<
DeviceLocationDto
>
deviceLocationDtoList
);
Integer
batchInsertOrUpdate
(
@Param
(
"list"
)
Collection
<
DeviceLocationDto
>
list
);
}
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/model/DeviceLocation.java
View file @
8300849
...
...
@@ -38,6 +38,21 @@ public class DeviceLocation {
private
Date
lastBsTime
;
/**
* 速度
*/
private
Integer
speed
;
/**
* 对应大数据侧状态 1、静止 3、行驶
*/
private
Integer
stayStatus
;
/**
* 设备状态最新更新时间
*/
private
Date
stayStatusUpdatetime
;
/**
* 创建时间
*/
private
Date
createdTime
;
...
...
src/main/java/cn/com/glsx/stdinterface/modules/service/DeviceLocationService.java
View file @
8300849
...
...
@@ -2,15 +2,12 @@ package cn.com.glsx.stdinterface.modules.service;
import
cn.com.glsx.stdinterface.dto.DeviceLocationDto
;
import
cn.com.glsx.stdinterface.modules.mapper.DeviceLocationMapper
;
import
cn.com.glsx.stdinterface.modules.model.DeviceLocation
;
import
cn.com.glsx.stdinterface.modules.model.LocationCheckBO
;
import
cn.hutool.core.util.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Collection
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -31,9 +28,9 @@ public class DeviceLocationService {
*
* @param deviceLocationDtoList
*/
public
void
saveOrUpdateDeviceLocationData
(
Collection
<
DeviceLocationDto
>
deviceLocationDtoList
)
{
public
void
dropLibrary
(
Collection
<
DeviceLocationDto
>
deviceLocationDtoList
)
{
try
{
Integer
num
=
deviceLocationMapper
.
saveOrUpdateDeviceLocationData
(
deviceLocationDtoList
);
Integer
num
=
deviceLocationMapper
.
batchInsertOrUpdate
(
deviceLocationDtoList
);
log
.
info
(
"saveOrUpdateDeviceLocationData==="
+
num
);
}
catch
(
Exception
e
)
{
log
.
error
(
"saveOrUpdateDeviceLocationData==="
+
e
.
getMessage
());
...
...
@@ -47,7 +44,7 @@ public class DeviceLocationService {
* @return
*/
public
List
<
String
>
getAllSnInNewEshield
()
{
return
deviceLocationMapper
.
getAllSnInNewEshield
();
return
deviceLocationMapper
.
selectAllSn
();
}
/**
...
...
src/main/resources/mapper/DeviceLocationMapper.xml
View file @
8300849
...
...
@@ -5,38 +5,53 @@
<id
column=
"id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"sn"
property=
"sn"
jdbcType=
"VARCHAR"
/>
<result
column=
"last_gps_time"
property=
"lastGpsTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"last_bs_track"
property=
"lastBsTrack"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"last_bs_time"
property=
"lastBsTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"speed"
property=
"speed"
jdbcType=
"INTEGER"
/>
<result
column=
"stay_status"
property=
"stayStatus"
jdbcType=
"INTEGER"
/>
<result
column=
"stay_status_updatetime"
property=
"stayStatusUpdatetime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"created_time"
property=
"createdTime"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"updated_time"
property=
"updatedTime"
jdbcType=
"TIMESTAMP"
/>
</resultMap>
<sql
id=
"BaseColumns"
>
a.id, a.sn, a.last_gps_time, a.last_bs_track, a.created_time, a.updated_time
</sql>
id
, sn, last_gps_time, last_bs_time, speed, stay_status, stay_status_updatetime, created_time, updated_time
</sql>
<select
id=
"getAllSnInNewEshield"
resultType=
"java.lang.String"
>
select distinct sn from t_device where del_flag = 0;
<select
id=
"selectAllSn"
resultType=
"java.lang.String"
>
select distinct sn
from t_device
</select>
<select
id=
"getDeviceLocationBySn"
resultMap=
"BaseMap"
>
select * from t_device_location where sn = #{sn}
</select>
<select
id=
"selectBySn"
resultMap=
"BaseMap"
>
select
<include
refid=
"BaseColumns"
/>
from t_device_location
where sn = #{sn}
limit 1
</select>
<insert
id=
"
saveOrUpdateDeviceLocationData
"
>
INSERT INTO t_device_location (sn,last_gps_time,last_bs_time,
created_time,upd
ated_time)
<insert
id=
"
batchInsertOrUpdate
"
>
INSERT INTO t_device_location (sn,last_gps_time,last_bs_time,
speed,stay_status,stay_status_updatetime,cre
ated_time)
values
<foreach
collection=
"deviceLocationDtoList"
item=
"deviceLocation"
separator=
","
>
(#{deviceLocation.sn},
#{deviceLocation.lastGpsTime},
#{deviceLocation.lastBsTime},
#{deviceLocation.createdTime},
#{deviceLocation.updatedTime})
<foreach
collection=
"list"
item=
"item"
separator=
","
>
(
#{item.sn},
#{item.lastGpsTime},
#{item.lastBsTime},
#{item.speed},
#{item.stayStatus},
#{item.stayStatusUpdatetime},
sysdate()
)
</foreach>
ON DUPLICATE KEY UPDATE
sn
=
values(sn),
sn
=
values(sn),
last_gps_time=values(last_gps_time),
last_bs_time=values(last_bs_time),
created_time=values(created_time),
updated_time=values(updated_time)
speed=values(speed),
stay_status=values(stay_status),
stay_status_updatetime=values(stay_status_updatetime),
updated_time=sysdate()
</insert>
</mapper>
\ 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