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 17796168
authored
Dec 18, 2021
by
levphon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
设备位置点验证接口
1 parent
38a96341
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
39 deletions
src/main/java/cn/com/glsx/devicemonitor/modules/api/FeignDeviceController.java
src/main/java/cn/com/glsx/devicemonitor/modules/components/HdaoGpsComponent.java
src/main/java/cn/com/glsx/devicemonitor/modules/convert/DataLocationConvert.java → src/main/java/cn/com/glsx/devicemonitor/modules/converter/DataLocationConvert.java
src/main/java/cn/com/glsx/devicemonitor/modules/converter/GpsLocationConverter.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/GpsBsLocationServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
src/main/java/cn/com/glsx/devicemonitor/modules/api/FeignDeviceController.java
View file @
1779616
...
...
@@ -42,6 +42,12 @@ public class FeignDeviceController implements DeviceFeignService {
return
R
.
ok
().
data
(
deviceDTO
);
}
@Override
@GetMapping
({
"/getOrStoreDeviceBySn"
})
public
R
<
DeviceDTO
>
getOrStoreDeviceBySn
(
String
sn
,
boolean
storeIfNotExists
)
{
DeviceDTO
deviceDTO
=
deviceService
.
getDeviceDTOBySn
(
sn
,
storeIfNotExists
);
return
R
.
ok
().
data
(
deviceDTO
);
}
/**
* 获取设备的状态
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/components/HdaoGpsComponent.java
View file @
1779616
...
...
@@ -12,7 +12,7 @@ import cn.com.glsx.devicemonitor.iceprotocol.bs.BsDataRespHolder;
import
cn.com.glsx.devicemonitor.iceprotocol.hdao.*
;
import
cn.com.glsx.devicemonitor.iceprotocol.poisearch.IPOISearchNearPrx
;
import
cn.com.glsx.devicemonitor.iceprotocol.poisearch.geopoint
;
import
cn.com.glsx.devicemonitor.modules.convert.DataLocationConvert
;
import
cn.com.glsx.devicemonitor.modules.convert
er
.DataLocationConvert
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataBsLocation
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataGpsLocation
;
import
cn.com.glsx.devicemonitor.modules.model.*
;
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/convert/DataLocationConvert.java
→
src/main/java/cn/com/glsx/devicemonitor/modules/convert
er
/DataLocationConvert.java
View file @
1779616
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
convert
;
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
convert
er
;
import
cn.com.glsx.devicemonitor.api.dto.response.GpsLocation
;
import
cn.com.glsx.devicemonitor.api.enums.GeoLocationEnum
;
...
...
@@ -23,11 +23,12 @@ public class DataLocationConvert {
/**
* 「single」将DataGps转为GpsLocation DTO对象
*
* @param dataGpsLocation
* @return
*/
public
static
GpsLocation
convertDataToGpsLocation
(
DataGpsLocation
dataGpsLocation
)
{
if
(
dataGpsLocation
==
null
)
{
if
(
dataGpsLocation
==
null
)
{
return
null
;
}
GpsLocation
gpsLocation
=
new
GpsLocation
();
...
...
@@ -50,6 +51,7 @@ public class DataLocationConvert {
/**
* 将dataList 位置数据转换为DTO对象
*
* @param trackModels
* @return
*/
...
...
@@ -60,7 +62,7 @@ public class DataLocationConvert {
List
<
DataGpsLocation
>
dataGpsLocationList
=
new
ArrayList
<>(
trackModels
.
size
());
for
(
GpsDevInfo
gpsDevInfo
:
trackModels
)
{
if
(
gpsDevInfo
.
record
==
null
)
{
if
(
gpsDevInfo
.
record
==
null
)
{
continue
;
}
DataGpsLocation
dataGpsLocation
=
new
DataGpsLocation
();
...
...
@@ -85,6 +87,7 @@ public class DataLocationConvert {
/**
* 「batch」将DataGps转为GpsLocation DTO对象
*
* @param dataGpsLocationList
* @return
*/
...
...
@@ -92,9 +95,7 @@ public class DataLocationConvert {
if
(
CollectionUtils
.
isEmpty
(
dataGpsLocationList
))
{
return
null
;
}
List
<
GpsLocation
>
gpsLocationList
=
dataGpsLocationList
.
stream
().
map
(
dataGpsLocation
->
{
return
convertDataToGpsLocation
(
dataGpsLocation
);
}).
collect
(
Collectors
.
toList
());
List
<
GpsLocation
>
gpsLocationList
=
dataGpsLocationList
.
stream
().
map
(
DataLocationConvert:
:
convertDataToGpsLocation
).
collect
(
Collectors
.
toList
());
return
gpsLocationList
;
}
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/converter/GpsLocationConverter.java
0 → 100644
View file @
1779616
package
cn
.
com
.
glsx
.
devicemonitor
.
modules
.
converter
;
import
cn.com.glsx.devicemonitor.api.dto.response.GpsLocation
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataGpsLocation
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
@Mapper
public
interface
GpsLocationConverter
{
GpsLocationConverter
INSTANCE
=
Mappers
.
getMapper
(
GpsLocationConverter
.
class
);
GpsLocation
trans2dto
(
DataGpsLocation
item
);
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/DeviceService.java
View file @
1779616
...
...
@@ -3,7 +3,6 @@ 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.TrackInfoDTO
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -31,21 +30,22 @@ public interface DeviceService {
DeviceDTO
getDeviceDTOBySn
(
String
sn
);
/**
*
获取设备的在线状态
*
根据设备号查询设备信息,不存在就同步
*
* @param sn
* @param
offlineTime
* @param
storeIfNotExists
* @return
*/
Device
StatusModel
getDeviceStatusBySn
(
String
sn
,
Long
offlineTime
);
Device
DTO
getDeviceDTOBySn
(
String
sn
,
Boolean
storeIfNotExists
);
/**
*
远程获取e盾的设备信息
*
获取设备的在线状态
*
* @param sn
* @param offlineTime
* @return
*/
TrackInfoDTO
getTrackInfo
(
String
sn
);
DeviceStatusModel
getDeviceStatusBySn
(
String
sn
,
Long
offlineTime
);
/**
* 查询设备(本地库没有,查询旧E盾)
...
...
@@ -53,7 +53,7 @@ public interface DeviceService {
* @param sn
* @return
*/
Device
getDeviceOrRemote
(
String
sn
);
Device
getDeviceOrRemote
(
String
sn
,
Boolean
storeIfNotExists
);
/**
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/DeviceServiceImpl.java
View file @
1779616
...
...
@@ -43,7 +43,18 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public
DeviceDTO
getDeviceDTOBySn
(
String
sn
)
{
Device
device
=
getDeviceOrRemote
(
sn
);
Device
device
=
getDeviceOrRemote
(
sn
,
false
);
if
(
device
==
null
)
{
return
null
;
}
DeviceDTO
deviceDTO
=
new
DeviceDTO
();
BeanUtils
.
copyProperties
(
device
,
deviceDTO
);
return
deviceDTO
;
}
@Override
public
DeviceDTO
getDeviceDTOBySn
(
String
sn
,
Boolean
storeIfNotExists
)
{
Device
device
=
getDeviceOrRemote
(
sn
,
storeIfNotExists
);
if
(
device
==
null
)
{
return
null
;
}
...
...
@@ -54,7 +65,7 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public
DeviceStatusModel
getDeviceStatusBySn
(
String
sn
,
Long
offlineTime
)
{
Device
device
=
getDeviceOrRemote
(
sn
);
Device
device
=
getDeviceOrRemote
(
sn
,
false
);
if
(
device
==
null
)
{
return
null
;
}
...
...
@@ -65,6 +76,7 @@ public class DeviceServiceImpl implements DeviceService {
DeviceStatusModel
statusModel
=
DeviceUtils
.
parseDeviceStatus
(
deviceLogin
,
device
.
getSource
(),
offlineTime
);
return
statusModel
;
}
@Override
public
List
<
DeviceStatusModel
>
listDeviceStatusBySns
(
Collection
<
String
>
sns
,
Long
offlineTime
)
{
List
<
DeviceStatusModel
>
statusModels
=
new
LinkedList
<>();
...
...
@@ -95,28 +107,21 @@ public class DeviceServiceImpl implements DeviceService {
}
@Override
public
TrackInfoDTO
getTrackInfo
(
String
sn
)
{
return
remoteDeviceService
.
getDeviceBySn
(
sn
);
}
@Override
public
Device
getDeviceOrRemote
(
String
sn
)
{
public
Device
getDeviceOrRemote
(
String
sn
,
Boolean
storeIfNotExists
)
{
Device
device
=
deviceMapper
.
selectBySn
(
sn
);
if
(
device
!=
null
)
{
return
device
;
}
device
=
getRemoteDevice
(
sn
);
if
(
storeIfNotExists
&&
device
!=
null
)
{
deviceMapper
.
insert
(
device
);
}
return
device
;
}
public
Device
getRemoteDevice
(
String
sn
)
{
TrackInfoDTO
trackInfoDTO
=
remoteDeviceService
.
getDeviceBySn
(
sn
);
if
(
trackInfoDTO
==
null
)
{
return
null
;
}
Device
device
=
new
Device
();
BeanUtils
.
copyProperties
(
trackInfoDTO
,
device
);
return
device
;
return
convertDevice
(
trackInfoDTO
,
0L
);
}
/**
...
...
@@ -125,25 +130,20 @@ public class DeviceServiceImpl implements DeviceService {
* @param trackInfo
* @param createId
*/
public
int
saveTrackInfoBo
(
TrackInfoDTO
trackInfo
,
Long
createId
)
{
public
Device
convertDevice
(
TrackInfoDTO
trackInfo
,
Long
createId
)
{
if
(
trackInfo
==
null
)
{
return
0
;
return
null
;
}
Device
device
=
new
Device
();
BeanUtils
.
copyProperties
(
trackInfo
,
device
);
// device.setName("");
device
.
setSim
(
trackInfo
.
getSimPhone
());
device
.
setManufacturer
(
trackInfo
.
getPartner
());
device
.
setSource
(
trackInfo
.
getSource
());
device
.
setActivateStatus
(
trackInfo
.
getIsActive
());
device
.
setActivateTime
(
trackInfo
.
getActiveDate
());
device
.
setCreatedBy
(
createId
);
device
.
setCreatedDate
(
new
Date
());
return
insertDevice
(
device
);
}
public
int
insertDevice
(
Device
device
)
{
return
deviceMapper
.
insert
(
device
);
return
device
;
}
@Override
...
...
@@ -152,4 +152,5 @@ public class DeviceServiceImpl implements DeviceService {
gpsPrxInstance
.
getDevicesTotalCount
(
new
DevicesTotalCountGetRequest
(
Long
.
parseLong
(
sn
)),
res
);
return
res
.
value
.
deviceCount
;
}
}
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/GpsBsLocationServiceImpl.java
View file @
1779616
...
...
@@ -8,7 +8,7 @@ import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import
cn.com.glsx.devicemonitor.api.enums.DeviceTypeRelationEnum
;
import
cn.com.glsx.devicemonitor.api.enums.GeoLocationEnum
;
import
cn.com.glsx.devicemonitor.modules.components.HdaoGpsComponent
;
import
cn.com.glsx.devicemonitor.modules.convert.DataLocationConvert
;
import
cn.com.glsx.devicemonitor.modules.convert
er
.DataLocationConvert
;
import
cn.com.glsx.devicemonitor.modules.entity.inner.DataGpsLocation
;
import
cn.com.glsx.devicemonitor.modules.model.BaseStationModel
;
import
cn.com.glsx.devicemonitor.modules.model.BsInfoModel
;
...
...
src/main/java/cn/com/glsx/devicemonitor/modules/service/impl/MonitorServiceImpl.java
View file @
1779616
...
...
@@ -63,7 +63,7 @@ public class MonitorServiceImpl implements MonitorService {
throw
BusinessException
.
create
(
"所选设备数量太多"
);
}
for
(
String
sn
:
snArr
)
{
Device
device
=
deviceService
.
getDeviceOrRemote
(
sn
);
Device
device
=
deviceService
.
getDeviceOrRemote
(
sn
,
false
);
if
(
device
==
null
)
{
log
.
info
(
sn
+
"设备未入库"
);
continue
;
...
...
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