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 4c24df07
authored
Apr 04, 2023
by
杨林龙
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加襄本插叙设备位置接口
1 parent
2c9151a3
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
380 additions
and
107 deletions
src/main/java/cn/com/glsx/stdinterface/modules/api/CommonController.java
src/main/java/cn/com/glsx/stdinterface/modules/api/DeviceLocationApiController.java
src/main/java/cn/com/glsx/stdinterface/modules/api/WorkOrderApiController.java
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
src/main/java/cn/com/glsx/stdinterface/modules/model/XBAddrVerifyDTO.java
src/main/java/cn/com/glsx/stdinterface/modules/model/XBDeviceAddressItem.java
src/main/java/cn/com/glsx/stdinterface/modules/remote/RemoteGpsBsService.java
src/main/java/cn/com/glsx/stdinterface/modules/service/VehicleService.java
src/main/java/cn/com/glsx/stdinterface/modules/service/WorkOrderService.java
src/main/java/cn/com/glsx/stdinterface/modules/util/DeviceLocationUtil.java
src/main/resources/mapper/VehicleMapper.xml
src/test/java/cn/com/glsx/stdinterface/modules/MainTest03.java
src/test/java/cn/com/glsx/stdinterface/modules/service/VehicleServiceTest.java
src/test/java/cn/com/glsx/stdinterface/modules/service/WorkOrderServiceTest.java
src/main/java/cn/com/glsx/stdinterface/modules/api/CommonController.java
0 → 100644
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
api
;
import
cn.com.glsx.stdinterface.common.enums.ResultEnum
;
import
cn.com.glsx.stdinterface.common.exception.StdInterfaceException
;
import
cn.com.glsx.stdinterface.modules.util.Sm4DecryptUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.context.utils.PropertiesUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
/**
* @author Yanglinlong
* @date 2023/4/4 14:34
*/
@Slf4j
@Component
public
class
CommonController
{
/**
* 解密请求体参数
*
* @param org 组织名称
* @param encryptData 加密体
* @return
*/
public
String
decryptRequestData
(
String
org
,
String
encryptData
)
{
if
(
StringUtils
.
isNullOrEmpty
(
org
))
{
throw
new
StdInterfaceException
(
ResultEnum
.
PARAM_ERROR
);
}
String
orgKey
=
PropertiesUtils
.
getProperty
(
"sm4.hexKey."
+
org
);
String
decryptData
=
null
;
try
{
// TODO: 2021/12/2 根据组织org动态获取hexKey,分配给不同组织的key不同
//解密用我们的密钥
decryptData
=
Sm4DecryptUtils
.
decryptCbc
(
"E76F7D9A27F63E6BA5F4282D81BA9E50"
,
encryptData
);
log
.
info
(
"解密参数:{}"
,
decryptData
);
}
catch
(
Exception
e
)
{
throw
new
StdInterfaceException
(
ResultEnum
.
DECRYPT_ENCRYPT_ERROR
);
}
return
decryptData
;
}
}
src/main/java/cn/com/glsx/stdinterface/modules/api/DeviceLocationApiController.java
0 → 100644
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
api
;
import
cn.com.glsx.stdinterface.modules.model.CommonApiRequest
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO
;
import
cn.com.glsx.stdinterface.modules.service.VehicleService
;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* 对外公用设备定位查询接口
*
* @author Yanglinlong
* @date 2023/4/4 14:31
*/
@Slf4j
@RestController
@RequestMapping
(
value
=
"/api/device/location"
)
public
class
DeviceLocationApiController
extends
CommonController
{
@Autowired
private
VehicleService
vehicleService
;
/**
* 襄本验证定位接口
*
* @param request 请求参数
* @return
*/
@PostMapping
(
value
=
"/checkLocationByXB"
)
@SysLog
(
module
=
"工单API"
,
value
=
"压缩图片"
,
action
=
OperateType
.
QUERY
)
public
R
checkLocationByXB
(
@RequestBody
CommonApiRequest
request
)
{
String
decryptData
=
decryptRequestData
(
request
.
getOrganization
(),
request
.
getData
());
XBAddrVerifyBo
verifyBO
=
JSON
.
parseObject
(
decryptData
,
XBAddrVerifyBo
.
class
);
verifyBO
.
setOrderSource
(
request
.
getOrganization
());
XBAddrVerifyDTO
verifyDTO
=
vehicleService
.
addrVerifyByXB
(
verifyBO
);
return
R
.
ok
().
data
(
verifyDTO
);
}
}
src/main/java/cn/com/glsx/stdinterface/modules/api/WorkOrderApiController.java
View file @
4c24df0
...
@@ -312,20 +312,4 @@ public class WorkOrderApiController {
...
@@ -312,20 +312,4 @@ public class WorkOrderApiController {
}
}
return
R
.
ok
();
return
R
.
ok
();
}
}
/**
* 襄本验证定位接口
*
* @param request
* @return
*/
@PostMapping
(
value
=
"/checkLocationByXB"
)
@SysLog
(
module
=
"工单API"
,
value
=
"压缩图片"
,
action
=
OperateType
.
QUERY
)
public
R
checkLocationByXB
(
@RequestBody
CommonApiRequest
request
)
{
String
decryptData
=
decryptRequestData
(
request
.
getOrganization
(),
request
.
getData
());
XBAddrVerifyBo
verifyBO
=
JSON
.
parseObject
(
decryptData
,
XBAddrVerifyBo
.
class
);
verifyBO
.
setOrderSource
(
request
.
getOrganization
());
WorkOrderAddrVerifyDTO
verifyDTO
=
workOrderService
.
addrVerifyByXB
(
verifyBO
);
return
R
.
ok
().
data
(
verifyDTO
);
}
}
}
src/main/java/cn/com/glsx/stdinterface/modules/mapper/VehicleMapper.java
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
mapper
;
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
mapper
;
import
cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyDTO
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator
;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
...
@@ -56,5 +56,5 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
...
@@ -56,5 +56,5 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
* @param orderSource 组织名称
* @param orderSource 组织名称
* @return
* @return
*/
*/
WorkOrder
AddrVerifyDTO
getVehicleBySnAndTenantName
(
@Param
(
"sn"
)
String
sn
,
@Param
(
"orderSource"
)
String
orderSource
);
XB
AddrVerifyDTO
getVehicleBySnAndTenantName
(
@Param
(
"sn"
)
String
sn
,
@Param
(
"orderSource"
)
String
orderSource
);
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/stdinterface/modules/model/XBAddrVerifyDTO.java
0 → 100644
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
model
;
import
lombok.Data
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
XBAddrVerifyDTO
{
/**
* 承租人姓名
*/
private
String
lesseeName
;
/**
* 承租人车架号
*/
private
String
vin
;
/**
* 安装店面名
*/
private
String
shopName
;
/**
* 店面联系人手机号
*/
private
String
shopTelephone
;
/**
* 服务日期
*/
private
Date
serviceTime
;
/**
* 服务地址
*/
private
String
serviceAddress
;
/**
* 位置点详情
*/
private
List
<
XBDeviceAddressItem
>
list
;
}
src/main/java/cn/com/glsx/stdinterface/modules/model/XBDeviceAddressItem.java
0 → 100644
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
model
;
import
lombok.Data
;
@Data
public
class
XBDeviceAddressItem
{
/**
* 设备号
*/
private
String
sn
;
/**
* 设备对应手机卡号
*/
private
String
sim
;
/**
* 设备类型
*/
private
String
deviceType
;
/**
* gps经度
*/
private
String
gpsLat
;
/**
* gps纬度
*/
private
String
gpsLng
;
/**
* GPS定位位置
*/
private
String
gpsPosition
;
/**
* GPS定位时间
*/
private
String
gpsTime
;
/**
* 基站经度
*/
private
String
bsLat
;
/**
* 基站纬度
*/
private
String
bsLng
;
/**
* 基站定位位置
*/
private
String
bsPosition
;
/**
* 基站定位时间
*/
private
String
bsTime
;
/**
* 0 有效位置
* 1 无效位置
*/
private
Integer
type
;
/**
* 状态(0 行驶中 1 静止 2离线 3 在线)
*/
private
Integer
status
;
}
src/main/java/cn/com/glsx/stdinterface/modules/remote/RemoteGpsBsService.java
View file @
4c24df0
...
@@ -121,4 +121,22 @@ public class RemoteGpsBsService {
...
@@ -121,4 +121,22 @@ public class RemoteGpsBsService {
}.
getType
());
}.
getType
());
return
firstGpsBsDataList
;
return
firstGpsBsDataList
;
}
}
/**
* 将定位集合list 转换成map
*
* @param snList 设备集合
* @return
*/
public
Map
<
String
,
GpsBsData
>
getLastGpsBsBatchBySns
(
List
<
String
>
snList
)
{
R
<
List
<
GpsBsData
>>
lastGpsBsBatch
=
gpsBsFeignService
.
getLastGpsBsBatch
(
snList
);
List
<
GpsBsData
>
gpsBsDataList
=
lastGpsBsBatch
.
getDataList
(
new
TypeToken
<
List
<
GpsBsData
>>()
{
}.
getType
());
Map
<
String
,
GpsBsData
>
gpsBsDataMap
=
Maps
.
newHashMap
();
if
(
CollectionUtils
.
isNotEmpty
(
gpsBsDataList
))
{
gpsBsDataMap
=
gpsBsDataList
.
stream
().
collect
(
Collectors
.
toMap
(
GpsBsData:
:
getSn
,
Function
.
identity
(),
(
o
,
n
)
->
n
));
}
return
gpsBsDataMap
;
}
}
}
src/main/java/cn/com/glsx/stdinterface/modules/service/VehicleService.java
View file @
4c24df0
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
service
;
package
cn
.
com
.
glsx
.
stdinterface
.
modules
.
service
;
import
cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO
;
import
cn.com.glsx.devicemonitor.api.dto.response.GpsBsData
;
import
cn.com.glsx.devicemonitor.api.dto.response.GpsLocation
;
import
cn.com.glsx.devicemonitor.api.feign.DeviceFeignService
;
import
cn.com.glsx.stdinterface.common.constants.Constants
;
import
cn.com.glsx.stdinterface.common.enums.ResultEnum
;
import
cn.com.glsx.stdinterface.common.exception.StdInterfaceException
;
import
cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO
;
import
cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.modules.converter.VehicleConverter
;
import
cn.com.glsx.stdinterface.modules.converter.VehicleConverter
;
...
@@ -8,6 +15,14 @@ import cn.com.glsx.stdinterface.modules.entity.VehicleDevice;
...
@@ -8,6 +15,14 @@ import cn.com.glsx.stdinterface.modules.entity.VehicleDevice;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator
;
import
cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleMapper
;
import
cn.com.glsx.stdinterface.modules.mapper.VehicleMapper
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO
;
import
cn.com.glsx.stdinterface.modules.model.XBDeviceAddressItem
;
import
cn.com.glsx.stdinterface.modules.remote.RemoteGpsBsService
;
import
cn.com.glsx.stdinterface.modules.util.DeviceLocationUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.glsx.plat.core.web.R
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
...
@@ -35,6 +50,12 @@ public class VehicleService {
...
@@ -35,6 +50,12 @@ public class VehicleService {
@Autowired
@Autowired
private
WorkOrderService
workOrderService
;
private
WorkOrderService
workOrderService
;
@Autowired
private
RemoteGpsBsService
remoteGpsBsService
;
@Autowired
private
DeviceFeignService
deviceFeignService
;
public
Vehicle
getVehicleInfoBySn
(
String
sn
)
{
public
Vehicle
getVehicleInfoBySn
(
String
sn
)
{
Vehicle
vehicle
=
vehicleMapper
.
getVehicleBySn
(
sn
);
Vehicle
vehicle
=
vehicleMapper
.
getVehicleBySn
(
sn
);
return
vehicle
;
return
vehicle
;
...
@@ -108,4 +129,70 @@ public class VehicleService {
...
@@ -108,4 +129,70 @@ public class VehicleService {
List
<
Vehicle
>
vehicleList
=
vehicleMapper
.
getVehicleByVinAndName
(
vin
,
name
);
List
<
Vehicle
>
vehicleList
=
vehicleMapper
.
getVehicleByVinAndName
(
vin
,
name
);
return
VehicleConverter
.
INSTANCE
.
syncEntity2DtoList
(
vehicleList
);
return
VehicleConverter
.
INSTANCE
.
syncEntity2DtoList
(
vehicleList
);
}
}
/**
* 查询襄本设备定位信息
*
* @param verifyBO 襄本请求体
* @return
*/
public
XBAddrVerifyDTO
addrVerifyByXB
(
XBAddrVerifyBo
verifyBO
)
{
if
(
StringUtils
.
isEmpty
(
verifyBO
.
getSn
()))
{
throw
new
StdInterfaceException
(
ResultEnum
.
PARAM_ERROR
);
}
XBAddrVerifyDTO
verifyDTO
=
vehicleMapper
.
getVehicleBySnAndTenantName
(
verifyBO
.
getSn
(),
verifyBO
.
getOrderSource
());
if
(
Objects
.
isNull
(
verifyDTO
))
{
log
.
warn
(
"没有查询到该设备相关信息=="
+
JSONUtil
.
toJsonStr
(
verifyBO
));
throw
new
StdInterfaceException
(
ResultEnum
.
DEVICE_NOT_EXIST
);
}
List
<
XBDeviceAddressItem
>
list
=
Lists
.
newArrayList
();
//查位置点
Map
<
String
,
GpsBsData
>
gpsBsDataMap
=
remoteGpsBsService
.
getLastGpsBsBatchBySns
(
Lists
.
newArrayList
(
verifyBO
.
getSn
()));
XBDeviceAddressItem
addressItem
=
new
XBDeviceAddressItem
();
R
<
DeviceDTO
>
deviceDTOR
=
deviceFeignService
.
getDeviceBySn
(
verifyBO
.
getSn
());
DeviceDTO
deviceDTO
=
deviceDTOR
.
getData
(
DeviceDTO
.
class
);
addressItem
.
setSn
(
verifyBO
.
getSn
());
addressItem
.
setSim
(
deviceDTO
.
getSim
());
addressItem
.
setDeviceType
((
deviceDTO
.
getSource
()
!=
null
&&
deviceDTO
.
getSource
()
==
Constants
.
DeviceSource
.
WIRED
)
?
"有线设备"
:
"无线设备"
);
GpsBsData
gpsBsData
=
gpsBsDataMap
.
get
(
verifyBO
.
getSn
());
if
(
gpsBsData
!=
null
)
{
String
speedValue
=
""
;
// 获取 Gps 定位数据
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
if
(
gpsLocation
!=
null
)
{
addressItem
.
setGpsLat
(
gpsLocation
.
getLat
());
addressItem
.
setGpsLng
(
gpsLocation
.
getLng
());
addressItem
.
setGpsPosition
(
gpsLocation
.
getAddress
());
addressItem
.
setGpsTime
(
gpsLocation
.
getDateTime
());
speedValue
=
gpsLocation
.
getSpeed
();
}
// 获取基站定位数据
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
if
(
bsLocation
!=
null
)
{
addressItem
.
setBsLat
(
bsLocation
.
getBlat
());
addressItem
.
setBsLng
(
bsLocation
.
getBlng
());
addressItem
.
setBsPosition
(
bsLocation
.
getAddress
());
addressItem
.
setBsTime
(
bsLocation
.
getDateTime
());
}
// 如果基站时间为空,则将GPS时间填充到基站时间中
if
(
StringUtils
.
isBlank
(
addressItem
.
getBsTime
()))
{
addressItem
.
setBsTime
(
addressItem
.
getGpsTime
());
}
// 设置设备位置有效状态
addressItem
.
setType
(
DeviceLocationUtil
.
resolutionGpsType
(
addressItem
.
getGpsTime
(),
addressItem
.
getBsTime
(),
deviceDTO
.
getSource
()));
// 设置设备位置行驶状态
addressItem
.
setStatus
(
DeviceLocationUtil
.
resolutionDeviceOnlineStatus
(
addressItem
,
deviceDTO
.
getSource
(),
speedValue
));
list
.
add
(
addressItem
);
verifyDTO
.
setList
(
list
);
}
return
verifyDTO
;
}
}
}
src/main/java/cn/com/glsx/stdinterface/modules/service/WorkOrderService.java
View file @
4c24df0
...
@@ -1744,71 +1744,4 @@ public class WorkOrderService {
...
@@ -1744,71 +1744,4 @@ public class WorkOrderService {
DeviceLocation
location
=
DeviceLocationConverter
.
INSTANCE
.
bo2do
(
locationBO
);
DeviceLocation
location
=
DeviceLocationConverter
.
INSTANCE
.
bo2do
(
locationBO
);
return
deviceLocationMapper
.
insertOrUpdate
(
location
);
return
deviceLocationMapper
.
insertOrUpdate
(
location
);
}
}
/**
* 通过设备号和襄本标识获取设备定位数据
*
* @param verifyBO
* @return
*/
public
WorkOrderAddrVerifyDTO
addrVerifyByXB
(
XBAddrVerifyBo
verifyBO
)
{
if
(
StringUtils
.
isNullOrEmpty
(
verifyBO
.
getSn
()))
{
throw
new
StdInterfaceException
(
ResultEnum
.
PARAM_ERROR
);
}
WorkOrderAddrVerifyDTO
verifyDTO
=
vehicleMapper
.
getVehicleBySnAndTenantName
(
verifyBO
.
getSn
(),
verifyBO
.
getOrderSource
());
if
(
Objects
.
isNull
(
verifyDTO
))
{
log
.
warn
(
"没有查询到该设备相关信息=="
+
JSONUtil
.
toJsonStr
(
verifyBO
));
throw
new
StdInterfaceException
(
ResultEnum
.
DEVICE_NOT_EXIST
);
}
List
<
WorkOrderDeviceAddressItem
>
list
=
Lists
.
newArrayList
();
//查位置点
Map
<
String
,
GpsBsData
>
gpsBsDataMap
=
getLastGpsBsBatchBySns
(
Lists
.
newArrayList
(
verifyBO
.
getSn
()));
WorkOrderDeviceAddressItem
addressItem
=
new
WorkOrderDeviceAddressItem
();
R
<
DeviceDTO
>
deviceDTOR
=
deviceFeignService
.
getDeviceBySn
(
verifyBO
.
getSn
());
DeviceDTO
deviceDTO
=
deviceDTOR
.
getData
(
DeviceDTO
.
class
);
addressItem
.
setSn
(
verifyBO
.
getSn
());
addressItem
.
setSim
(
deviceDTO
.
getSim
());
addressItem
.
setDeviceType
((
deviceDTO
.
getSource
()
!=
null
&&
deviceDTO
.
getSource
()
==
Constants
.
DeviceSource
.
WIRED
)
?
"有线设备"
:
"无线设备"
);
GpsBsData
gpsBsData
=
gpsBsDataMap
.
get
(
verifyBO
.
getSn
());
if
(
gpsBsData
!=
null
)
{
String
speedValue
=
""
;
// 获取 Gps 定位数据
GpsLocation
gpsLocation
=
gpsBsData
.
getGpsLocation
();
if
(
gpsLocation
!=
null
)
{
addressItem
.
setGpsLat
(
gpsLocation
.
getLat
());
addressItem
.
setGpsLng
(
gpsLocation
.
getLng
());
addressItem
.
setGpsPosition
(
gpsLocation
.
getAddress
());
addressItem
.
setGpsTime
(
gpsLocation
.
getDateTime
());
speedValue
=
gpsLocation
.
getSpeed
();
}
// 获取基站定位数据
GpsLocation
bsLocation
=
gpsBsData
.
getBsLocation
();
if
(
bsLocation
!=
null
)
{
addressItem
.
setBsPosition
(
bsLocation
.
getAddress
());
addressItem
.
setBsTime
(
bsLocation
.
getDateTime
());
}
// 如果基站时间为空,则将GPS时间填充到基站时间中
if
(
StringUtils
.
isBlank
(
addressItem
.
getBsTime
()))
{
addressItem
.
setBsTime
(
addressItem
.
getGpsTime
());
}
// 设置设备位置有效状态
addressItem
.
setType
(
DeviceLocationUtil
.
resolutionGpsType
(
addressItem
.
getGpsTime
(),
addressItem
.
getBsTime
(),
deviceDTO
.
getSource
()));
// 设置设备位置行驶状态
addressItem
.
setStatus
(
DeviceLocationUtil
.
resolutionDeviceOnlineStatus
(
addressItem
,
deviceDTO
.
getSource
(),
speedValue
));
list
.
add
(
addressItem
);
verifyDTO
.
setList
(
list
);
}
return
verifyDTO
;
}
}
}
src/main/java/cn/com/glsx/stdinterface/modules/util/DeviceLocationUtil.java
View file @
4c24df0
...
@@ -2,6 +2,7 @@ package cn.com.glsx.stdinterface.modules.util;
...
@@ -2,6 +2,7 @@ package cn.com.glsx.stdinterface.modules.util;
import
cn.com.glsx.stdinterface.common.constants.Constants
;
import
cn.com.glsx.stdinterface.common.constants.Constants
;
import
cn.com.glsx.stdinterface.dto.WorkOrderDeviceAddressItem
;
import
cn.com.glsx.stdinterface.dto.WorkOrderDeviceAddressItem
;
import
cn.com.glsx.stdinterface.modules.model.XBDeviceAddressItem
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -13,6 +14,7 @@ public class DeviceLocationUtil {
...
@@ -13,6 +14,7 @@ public class DeviceLocationUtil {
/**
/**
* 解析设备位置状态:有效,无效
* 解析设备位置状态:有效,无效
*
* @param gpsTime
* @param gpsTime
* @param bsTime
* @param bsTime
* @param source
* @param source
...
@@ -24,24 +26,25 @@ public class DeviceLocationUtil {
...
@@ -24,24 +26,25 @@ public class DeviceLocationUtil {
}
}
// 初始化设备有源无源状态:默认无源
// 初始化设备有源无源状态:默认无源
int
currentSource
=
(
source
==
null
)?
Constants
.
DeviceSource
.
WIRELESS
:
source
;
int
currentSource
=
(
source
==
null
)
?
Constants
.
DeviceSource
.
WIRELESS
:
source
;
long
differBase
=
(
currentSource
==
Constants
.
DeviceSource
.
WIRED
)?
Constants
.
Verification
.
WIRED_TIME
:
Constants
.
Verification
.
WIRELESS_TIME
;
long
differBase
=
(
currentSource
==
Constants
.
DeviceSource
.
WIRED
)
?
Constants
.
Verification
.
WIRED_TIME
:
Constants
.
Verification
.
WIRELESS_TIME
;
if
(
StringUtils
.
isBlank
(
gpsTime
))
{
if
(
StringUtils
.
isBlank
(
gpsTime
))
{
return
Constants
.
Verification
.
SN_INVALID
;
return
Constants
.
Verification
.
SN_INVALID
;
}
}
long
timeDiff
=
DateUtils
.
getTimeDifference
(
gpsTime
);
long
timeDiff
=
DateUtils
.
getTimeDifference
(
gpsTime
);
if
(
currentSource
==
Constants
.
DeviceSource
.
WIRELESS
)
{
if
(
currentSource
==
Constants
.
DeviceSource
.
WIRELESS
)
{
long
gpsDiffer
=
DateUtils
.
getTimeDifference
(
gpsTime
);
long
gpsDiffer
=
DateUtils
.
getTimeDifference
(
gpsTime
);
long
bsDiffer
=
DateUtils
.
getTimeDifference
(
bsTime
);
long
bsDiffer
=
DateUtils
.
getTimeDifference
(
bsTime
);
timeDiff
=
(
gpsDiffer
>
bsDiffer
)?
bsDiffer:
gpsDiffer
;
timeDiff
=
(
gpsDiffer
>
bsDiffer
)
?
bsDiffer
:
gpsDiffer
;
}
}
return
timeDiff
>
differBase
?
Constants
.
Verification
.
SN_INVALID
:
Constants
.
Verification
.
SN_VALID
;
return
timeDiff
>
differBase
?
Constants
.
Verification
.
SN_INVALID
:
Constants
.
Verification
.
SN_VALID
;
}
}
/**
/**
* 解析设备在线状态
* 解析设备在线状态
*
* @param addressItem
* @param addressItem
* @param source
* @param source
* @param speedValue
* @param speedValue
...
@@ -51,13 +54,50 @@ public class DeviceLocationUtil {
...
@@ -51,13 +54,50 @@ public class DeviceLocationUtil {
if
(
StringUtils
.
isBlank
(
addressItem
.
getGpsTime
()))
{
if
(
StringUtils
.
isBlank
(
addressItem
.
getGpsTime
()))
{
return
Constants
.
DeviceOnline
.
OFFLINE
;
return
Constants
.
DeviceOnline
.
OFFLINE
;
}
}
int
currentSource
=
(
source
==
null
)?
Constants
.
DeviceSource
.
WIRELESS
:
source
;
int
currentSource
=
(
source
==
null
)
?
Constants
.
DeviceSource
.
WIRELESS
:
source
;
int
speed
=
StringUtils
.
isEmpty
(
speedValue
)
?
0
:
Integer
.
parseInt
(
speedValue
);
int
speed
=
StringUtils
.
isEmpty
(
speedValue
)
?
0
:
Integer
.
parseInt
(
speedValue
);
Date
gpsDate
=
DateUtils
.
toDate
(
addressItem
.
getGpsTime
(),
DateUtils
.
pattern19
);
Date
gpsDate
=
DateUtils
.
toDate
(
addressItem
.
getGpsTime
(),
DateUtils
.
pattern19
);
Date
bsDate
=
DateUtils
.
toDate
(
addressItem
.
getBsTime
(),
DateUtils
.
pattern19
);
Date
bsDate
=
DateUtils
.
toDate
(
addressItem
.
getBsTime
(),
DateUtils
.
pattern19
);
long
rtTrckTime
=
(
gpsDate
!=
null
)?
gpsDate
.
getTime
():
0
l
;
long
rtTrckTime
=
(
gpsDate
!=
null
)
?
gpsDate
.
getTime
()
:
0
l
;
long
gprsTime
=
(
bsDate
!=
null
)?
bsDate
.
getTime
():
0
l
;
long
gprsTime
=
(
bsDate
!=
null
)
?
bsDate
.
getTime
()
:
0
l
;
int
status
=
0
;
long
now
=
System
.
currentTimeMillis
();
if
(
gprsTime
==
0
&&
rtTrckTime
==
0
)
{
//离线
status
=
Constants
.
DeviceOnline
.
OFFLINE
;
}
else
if
(
gprsTime
==
0
&&
rtTrckTime
!=
0
)
{
status
=
commonResolutionOnline
(
now
,
rtTrckTime
,
speed
,
currentSource
);
}
else
if
(
gprsTime
!=
0
&&
rtTrckTime
==
0
)
{
status
=
commonResolutionOnline
(
now
,
gprsTime
,
speed
,
currentSource
);
}
else
{
long
time
=
0
;
time
=
gprsTime
>=
rtTrckTime
?
gprsTime
:
rtTrckTime
;
status
=
commonResolutionOnline
(
now
,
time
,
speed
,
currentSource
);
}
return
status
;
}
/**
* 解析设备在线状态(襄本)
*
* @param addressItem
* @param source
* @param speedValue
* @return
*/
public
static
Integer
resolutionDeviceOnlineStatus
(
XBDeviceAddressItem
addressItem
,
Integer
source
,
String
speedValue
)
{
if
(
StringUtils
.
isBlank
(
addressItem
.
getGpsTime
()))
{
return
Constants
.
DeviceOnline
.
OFFLINE
;
}
int
currentSource
=
(
source
==
null
)
?
Constants
.
DeviceSource
.
WIRELESS
:
source
;
int
speed
=
StringUtils
.
isEmpty
(
speedValue
)
?
0
:
Integer
.
parseInt
(
speedValue
);
Date
gpsDate
=
DateUtils
.
toDate
(
addressItem
.
getGpsTime
(),
DateUtils
.
pattern19
);
Date
bsDate
=
DateUtils
.
toDate
(
addressItem
.
getBsTime
(),
DateUtils
.
pattern19
);
long
rtTrckTime
=
(
gpsDate
!=
null
)
?
gpsDate
.
getTime
()
:
0
l
;
long
gprsTime
=
(
bsDate
!=
null
)
?
bsDate
.
getTime
()
:
0
l
;
int
status
=
0
;
int
status
=
0
;
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
...
@@ -78,6 +118,7 @@ public class DeviceLocationUtil {
...
@@ -78,6 +118,7 @@ public class DeviceLocationUtil {
/**
/**
* 根据当前时间判断设备的行驶状态
* 根据当前时间判断设备的行驶状态
*
* @param now
* @param now
* @param rtTrckTime
* @param rtTrckTime
* @param speed
* @param speed
...
@@ -89,7 +130,7 @@ public class DeviceLocationUtil {
...
@@ -89,7 +130,7 @@ public class DeviceLocationUtil {
if
(
now
-
rtTrckTime
>
Constants
.
DeviceOnline
.
TIME_TWENTY_HOURS
)
{
if
(
now
-
rtTrckTime
>
Constants
.
DeviceOnline
.
TIME_TWENTY_HOURS
)
{
status
=
Constants
.
DeviceOnline
.
OFFLINE
;
status
=
Constants
.
DeviceOnline
.
OFFLINE
;
}
else
{
}
else
{
if
(
currentSource
==
Constants
.
DeviceSource
.
WIRELESS
)
{
if
(
currentSource
==
Constants
.
DeviceSource
.
WIRELESS
)
{
status
=
Constants
.
DeviceOnline
.
ONLINE
;
status
=
Constants
.
DeviceOnline
.
ONLINE
;
}
else
{
}
else
{
if
(
now
-
rtTrckTime
>
Constants
.
DeviceOnline
.
TIME_SIX_MINITES
)
{
if
(
now
-
rtTrckTime
>
Constants
.
DeviceOnline
.
TIME_SIX_MINITES
)
{
...
...
src/main/resources/mapper/VehicleMapper.xml
View file @
4c24df0
...
@@ -186,7 +186,7 @@
...
@@ -186,7 +186,7 @@
where owner_name = #{name} and vin = #{vin} and del_flag = 0
where owner_name = #{name} and vin = #{vin} and del_flag = 0
</select>
</select>
<select
id=
"getVehicleBySnAndTenantName"
resultType=
"cn.com.glsx.stdinterface.
dto.WorkOrder
AddrVerifyDTO"
>
<select
id=
"getVehicleBySnAndTenantName"
resultType=
"cn.com.glsx.stdinterface.
modules.model.XB
AddrVerifyDTO"
>
SELECT tw.shop_name AS shopName,
SELECT tw.shop_name AS shopName,
tw.shop_telephone AS shopTelephone,
tw.shop_telephone AS shopTelephone,
tw.service_time AS serviceTime,
tw.service_time AS serviceTime,
...
...
src/test/java/cn/com/glsx/stdinterface/modules/MainTest03.java
View file @
4c24df0
...
@@ -14,7 +14,7 @@ public class MainTest03 {
...
@@ -14,7 +14,7 @@ public class MainTest03 {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
XBAddrVerifyBo
infoBO
=
new
XBAddrVerifyBo
();
XBAddrVerifyBo
infoBO
=
new
XBAddrVerifyBo
();
infoBO
.
setOrderSource
(
"湖北襄本网络"
);
infoBO
.
setOrderSource
(
"湖北襄本网络"
);
infoBO
.
setSn
(
"1700112234
6
"
);
infoBO
.
setSn
(
"1700112234"
);
System
.
out
.
println
(
"infoBO = "
+
JSONUtil
.
toJsonPrettyStr
(
infoBO
));
System
.
out
.
println
(
"infoBO = "
+
JSONUtil
.
toJsonPrettyStr
(
infoBO
));
CommonApiRequest
request
=
new
CommonApiRequest
();
CommonApiRequest
request
=
new
CommonApiRequest
();
request
.
setOrganization
(
"湖北襄本网络"
);
request
.
setOrganization
(
"湖北襄本网络"
);
...
...
src/test/java/cn/com/glsx/stdinterface/modules/service/VehicleServiceTest.java
View file @
4c24df0
...
@@ -2,8 +2,12 @@ package cn.com.glsx.stdinterface.modules.service;
...
@@ -2,8 +2,12 @@ package cn.com.glsx.stdinterface.modules.service;
import
cn.com.glsx.Application
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.dto.VehicleDto
;
import
cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyDTO
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.entity.Vehicle
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo
;
import
cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -42,4 +46,12 @@ public class VehicleServiceTest {
...
@@ -42,4 +46,12 @@ public class VehicleServiceTest {
}
}
@Test
public
void
test
(){
XBAddrVerifyBo
verifyBO
=
new
XBAddrVerifyBo
();
verifyBO
.
setSn
(
"93107720006"
);
verifyBO
.
setOrderSource
(
"仲利国际"
);
XBAddrVerifyDTO
verifyDTO
=
vehicleService
.
addrVerifyByXB
(
verifyBO
);
System
.
out
.
println
(
"verifyDTO = "
+
JSONUtil
.
toJsonStr
(
verifyDTO
));
}
}
}
src/test/java/cn/com/glsx/stdinterface/modules/service/WorkOrderServiceTest.java
View file @
4c24df0
...
@@ -196,14 +196,4 @@ public class WorkOrderServiceTest {
...
@@ -196,14 +196,4 @@ public class WorkOrderServiceTest {
applicationEventPublisher
.
publishEvent
(
new
DeviceActiveSync
(
snList
));
applicationEventPublisher
.
publishEvent
(
new
DeviceActiveSync
(
snList
));
System
.
out
.
println
(
"success"
);
System
.
out
.
println
(
"success"
);
}
}
@Test
public
void
testAddrVerifyByXB
()
{
XBAddrVerifyBo
verifyBO
=
new
XBAddrVerifyBo
();
verifyBO
.
setSn
(
"93107720006"
);
verifyBO
.
setOrderSource
(
"仲利国际"
);
WorkOrderAddrVerifyDTO
verifyDTO
=
workOrderService
.
addrVerifyByXB
(
verifyBO
);
System
.
out
.
println
(
"verifyDTO = "
+
JSONUtil
.
toJsonStr
(
verifyDTO
));
}
}
}
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