Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-devicemonitor
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 916085ac
authored
Oct 20, 2021
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修复obd设备类型错误bug
1 parent
0f8046a3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
74 deletions
src/main/java/cn/com/glsx/devicemonitor/modules/api/GpsBsApiController.java
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackInfoBo.java → src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackInfoDTO.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/DeviceService.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/RemoteDeviceService.java
src/main/resources/mapper/DeviceMapper.xml
src/main/java/cn/com/glsx/devicemonitor/modules/api/GpsBsApiController.java
View file @
916085a
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
api
;
import
cn.com.glsx.devicemonitor.api.dto.request.DeviceLocationRequest
;
import
cn.com.glsx.devicemonitor.api.dto.request.GpsBsLastBatchRequest
;
import
cn.com.glsx.devicemonitor.api.dto.request.LocationHistoryRequest
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceLocationBo
;
...
...
@@ -10,6 +9,8 @@ import cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum;
import
cn.com.glsx.devicemonitor.api.feign.GpsBsService
;
import
cn.com.glsx.devicemonitor.common.BussinessExceptionEnum
;
import
cn.com.glsx.devicemonitor.common.ConstantsDevice
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
cn.com.glsx.devicemonitor.modules.service.DeviceService
;
import
cn.com.glsx.devicemonitor.modules.service.GpsBsLocationService
;
import
cn.com.glsx.devicemonitor.modules.service.MonitorService
;
import
com.glsx.plat.core.web.R
;
...
...
@@ -17,11 +18,9 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotBlank
;
import
java.util.List
;
/**
...
...
@@ -42,10 +41,14 @@ public class GpsBsApiController implements GpsBsService {
private
GpsBsLocationService
gpsBsLocationService
;
@Autowired
private
DeviceService
deviceService
;
@Autowired
private
MonitorService
monitorService
;
/**
* 通过设备号批量查询 设备位置信息
*
* @param gpsBsLastBatchRequest
* @return
*/
...
...
@@ -61,6 +64,7 @@ public class GpsBsApiController implements GpsBsService {
/**
* 获取单个设备的最新位置和基站数据
*
* @param sn
* @param deviceCode
* @return
...
...
@@ -77,6 +81,7 @@ public class GpsBsApiController implements GpsBsService {
/**
* 获取设备的历史轨迹
*
* @param request
* @return
*/
...
...
@@ -93,6 +98,7 @@ public class GpsBsApiController implements GpsBsService {
/**
* 设备监控信息
*
* @param sns
* @return
*/
...
...
@@ -100,12 +106,26 @@ public class GpsBsApiController implements GpsBsService {
@ApiOperation
(
value
=
"车辆监控信息"
)
@GetMapping
(
value
=
"/devicemonitorinfo"
)
public
R
listDeviceMonitorInfo
(
@RequestParam
(
value
=
"sns"
)
String
sns
,
@RequestParam
(
value
=
"deviceCode"
)
String
deviceCode
)
{
if
(!
DeviceTypeRelationEnum
.
findByDeviceCode
(
deviceCode
).
equals
(
DeviceTypeRelationEnum
.
GPS
))
{
return
R
.
error
(
BussinessExceptionEnum
.
UNSUPORT_DEVICE
.
getCode
(),
BussinessExceptionEnum
.
UNSUPORT_DEVICE
.
getMessage
());
DeviceTypeRelationEnum
deviceTypeRelationEnum
=
DeviceTypeRelationEnum
.
findByDeviceCode
(
deviceCode
);
Device
device
=
deviceService
.
getBySn
(
sns
);
if
(
device
!=
null
)
{
//查询数据库设备类型,
deviceTypeRelationEnum
=
DeviceTypeRelationEnum
.
findByBizDeviceType
(
device
.
getDeviceType
());
}
if
(
deviceTypeRelationEnum
==
null
)
{
//都拿不到设备类型,默认设备类型为gps
deviceTypeRelationEnum
=
DeviceTypeRelationEnum
.
GPS
;
}
//离线时间
Long
offlineTime
=
ConstantsDevice
.
OFFLINE_TIME_OTHER
;
List
<
DeviceLocationBo
>
deviceLocaBoList
=
monitorService
.
getDeviceMonitorInfo
(
sns
,
offlineTime
,
DeviceTypeRelationEnum
.
findByDeviceCode
(
deviceCode
));
List
<
DeviceLocationBo
>
deviceLocaBoList
=
monitorService
.
getDeviceMonitorInfo
(
sns
,
offlineTime
,
deviceTypeRelationEnum
);
return
R
.
ok
().
data
(
deviceLocaBoList
);
}
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackInfo
Bo
.java
→
src/main/java/cn/com/glsx/devicemonitor/modules/model/TrackInfo
DTO
.java
View file @
916085a
...
...
@@ -5,7 +5,7 @@ import lombok.Data;
import
java.util.Date
;
@Data
public
class
TrackInfo
Bo
{
public
class
TrackInfo
DTO
{
private
Integer
deviceType
;
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/service/DeviceService.java
View file @
916085a
...
...
@@ -3,25 +3,28 @@ package cn.com.glsx.devicemonitor.modules.service;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceStatusModel
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
Bo
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
DTO
;
import
java.util.Collection
;
import
java.util.List
;
/**
* @desc 提供设备相关的服务
* @author huangxc
* @desc 提供设备相关的服务
**/
public
interface
DeviceService
{
/**
* 基本信息
*
* @param sn
* @return
*/
Device
getDeviceBySn
(
String
sn
);
Device
getBySn
(
String
sn
);
/**
* 根据设备号查询设备信息
*
* @param sn
* @return
*/
...
...
@@ -29,6 +32,7 @@ public interface DeviceService {
/**
* 获取设备的在线状态
*
* @param sn
* @param offlineTime
* @return
...
...
@@ -37,17 +41,19 @@ public interface DeviceService {
/**
* 远程获取e盾的设备信息
*
* @param sn
* @return
*/
TrackInfo
Bo
getTrackInfoB
o
(
String
sn
);
TrackInfo
DTO
getTrackInf
o
(
String
sn
);
/**
* 查询设备(本地库没有,查询旧E盾)
*
* @param sn
* @return
*/
Device
getDeviceOrRemote
(
String
sn
)
;
Device
getDeviceOrRemote
(
String
sn
);
/**
...
...
@@ -60,9 +66,11 @@ public interface DeviceService {
/**
* 批量获取设备状态
*
* @param sns
* @param offlineTime
* @return
*/
List
<
DeviceStatusModel
>
listDeviceStatusBySns
(
Collection
<
String
>
sns
,
Long
offlineTime
);
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
View file @
916085a
...
...
@@ -8,7 +8,7 @@ import cn.com.glsx.devicemonitor.iceprotocol.hdao.DevicesTotalCountGetRequest;
import
cn.com.glsx.devicemonitor.iceprotocol.hdao.DevicesTotalCountResHolder
;
import
cn.com.glsx.devicemonitor.modules.entity.Device
;
import
cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
Bo
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
DTO
;
import
cn.com.glsx.devicemonitor.modules.service.DeviceService
;
import
cn.com.glsx.devicemonitor.modules.utils.DeviceUtils
;
import
com.alibaba.excel.util.CollectionUtils
;
...
...
@@ -37,7 +37,7 @@ public class DeviceServiceImpl implements DeviceService {
private
DaoGpsServicePrx
gpsPrxInstance
;
@Override
public
Device
get
Device
BySn
(
String
sn
)
{
public
Device
getBySn
(
String
sn
)
{
return
deviceMapper
.
selectBySn
(
sn
);
}
...
...
@@ -95,7 +95,7 @@ public class DeviceServiceImpl implements DeviceService {
}
@Override
public
TrackInfo
Bo
getTrackInfoB
o
(
String
sn
)
{
public
TrackInfo
DTO
getTrackInf
o
(
String
sn
)
{
return
remoteDeviceService
.
getDeviceBySn
(
sn
);
}
...
...
@@ -110,12 +110,12 @@ public class DeviceServiceImpl implements DeviceService {
}
public
Device
getRemoteDevice
(
String
sn
)
{
TrackInfo
Bo
trackInfoBo
=
remoteDeviceService
.
getDeviceBySn
(
sn
);
if
(
trackInfo
Bo
==
null
)
{
TrackInfo
DTO
trackInfoDTO
=
remoteDeviceService
.
getDeviceBySn
(
sn
);
if
(
trackInfo
DTO
==
null
)
{
return
null
;
}
Device
device
=
new
Device
();
BeanUtils
.
copyProperties
(
trackInfo
Bo
,
device
);
BeanUtils
.
copyProperties
(
trackInfo
DTO
,
device
);
return
device
;
}
...
...
@@ -125,7 +125,7 @@ public class DeviceServiceImpl implements DeviceService {
* @param trackInfo
* @param createId
*/
public
int
saveTrackInfoBo
(
TrackInfo
Bo
trackInfo
,
Long
createId
)
{
public
int
saveTrackInfoBo
(
TrackInfo
DTO
trackInfo
,
Long
createId
)
{
if
(
trackInfo
==
null
)
{
return
0
;
}
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/RemoteDeviceService.java
View file @
916085a
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
service
.
impl
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
Bo
;
import
cn.com.glsx.devicemonitor.modules.model.TrackInfo
DTO
;
import
cn.com.glsx.devicemonitor.modules.utils.GopUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.HttpUtils
;
...
...
@@ -20,7 +20,7 @@ public class RemoteDeviceService {
* 调用e盾标准接口获取设备信息
* @param sn
*/
public
TrackInfo
Bo
getDeviceBySn
(
String
sn
)
{
public
TrackInfo
DTO
getDeviceBySn
(
String
sn
)
{
String
url
=
PropertiesUtils
.
getProperty
(
"edun.otsi.url"
)
+
"/api/device/getInfoBySn"
;
String
appKet
=
PropertiesUtils
.
getProperty
(
"edun.otsi.appKet"
);
String
appSecret
=
PropertiesUtils
.
getProperty
(
"edun.otsi.appSecret"
);
...
...
@@ -47,8 +47,8 @@ public class RemoteDeviceService {
if
(
StringUtils
.
isBlank
(
data
))
{
return
null
;
}
TrackInfo
Bo
trackInfoBo
=
JSONObject
.
parseObject
(
data
,
TrackInfoBo
.
class
);
return
trackInfo
Bo
;
TrackInfo
DTO
trackInfoDTO
=
JSONObject
.
parseObject
(
data
,
TrackInfoDTO
.
class
);
return
trackInfo
DTO
;
}
catch
(
Exception
e
)
{
log
.
info
(
"调用虎哥E盾标准接口查询设备信息异常:{}"
,
e
.
getMessage
());
}
...
...
src/main/resources/mapper/DeviceMapper.xml
View file @
916085a
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.devicemonitor.modules.mapper.DeviceMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.devicemonitor.modules.entity.Device"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"imsi"
jdbcType=
"VARCHAR"
property=
"imsi"
/>
<result
column=
"iccid"
jdbcType=
"VARCHAR"
property=
"iccid"
/>
<result
column=
"imei"
jdbcType=
"VARCHAR"
property=
"imei"
/>
<result
column=
"sim"
jdbcType=
"VARCHAR"
property=
"sim"
/>
<result
column=
"check_code"
jdbcType=
"VARCHAR"
property=
"checkCode"
/>
<result
column=
"device_type"
jdbcType=
"INTEGER"
property=
"deviceType"
/>
<result
column=
"manufacturer"
jdbcType=
"VARCHAR"
property=
"manufacturer"
/>
<result
column=
"model_id"
jdbcType=
"INTEGER"
property=
"modelId"
/>
<result
column=
"model_name"
jdbcType=
"VARCHAR"
property=
"modelName"
/>
<result
column=
"soft_version"
jdbcType=
"VARCHAR"
property=
"softVersion"
/>
<result
column=
"source"
jdbcType=
"TINYINT"
property=
"source"
/>
<result
column=
"activate_status"
jdbcType=
"TINYINT"
property=
"activateStatus"
/>
<result
column=
"activate_time"
jdbcType=
"TIMESTAMP"
property=
"activateTime"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, `name`, sn, imsi, iccid, imei, sim, check_code, device_type, manufacturer, model_id,
model_name, soft_version, `source`, activate_status, activate_time, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.devicemonitor.modules.entity.Device"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"name"
jdbcType=
"VARCHAR"
property=
"name"
/>
<result
column=
"sn"
jdbcType=
"VARCHAR"
property=
"sn"
/>
<result
column=
"imsi"
jdbcType=
"VARCHAR"
property=
"imsi"
/>
<result
column=
"iccid"
jdbcType=
"VARCHAR"
property=
"iccid"
/>
<result
column=
"imei"
jdbcType=
"VARCHAR"
property=
"imei"
/>
<result
column=
"sim"
jdbcType=
"VARCHAR"
property=
"sim"
/>
<result
column=
"check_code"
jdbcType=
"VARCHAR"
property=
"checkCode"
/>
<result
column=
"device_type"
jdbcType=
"INTEGER"
property=
"deviceType"
/>
<result
column=
"manufacturer"
jdbcType=
"VARCHAR"
property=
"manufacturer"
/>
<result
column=
"model_id"
jdbcType=
"INTEGER"
property=
"modelId"
/>
<result
column=
"model_name"
jdbcType=
"VARCHAR"
property=
"modelName"
/>
<result
column=
"soft_version"
jdbcType=
"VARCHAR"
property=
"softVersion"
/>
<result
column=
"source"
jdbcType=
"TINYINT"
property=
"source"
/>
<result
column=
"activate_status"
jdbcType=
"TINYINT"
property=
"activateStatus"
/>
<result
column=
"activate_time"
jdbcType=
"TIMESTAMP"
property=
"activateTime"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_date"
jdbcType=
"TIMESTAMP"
property=
"createdDate"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"updated_date"
jdbcType=
"TIMESTAMP"
property=
"updatedDate"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, `name`, sn, imsi, iccid, imei, sim, check_code, device_type, manufacturer, model_id,
model_name, soft_version, `source`, activate_status, activate_time, del_flag, created_date,
created_by, updated_date, updated_by
</sql>
<select
id=
"selectBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device
where del_flag = 0
and sn = #{sn}
</select>
<select
id=
"selectBySn"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device
where del_flag = 0
and sn = #{sn}
</select>
<select
id=
"selectBySns"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device
where del_flag = 0 and sn in
<foreach
collection=
"sns"
item=
"item"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</select>
<select
id=
"selectBySns"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from t_device
where del_flag = 0 and sn in
<foreach
collection=
"sns"
item=
"item"
separator=
","
open=
"("
close=
")"
>
#{item}
</foreach>
</select>
</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