Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
open-platform-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 882b8856
authored
Dec 29, 2020
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.添加ice的getLatesGpsBsRecords服务接口
2.优化集合处理代码
1 parent
d0b095bc
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
1170 additions
and
276 deletions
src/main/java/com/glsx/base/aop/LogAspect.java
src/main/java/com/glsx/base/aop/SysLog.java
src/main/java/com/glsx/base/controller/BaseService.java
src/main/java/com/glsx/base/controller/JwtService.java
src/main/java/com/glsx/constant/OpenAPIConstant.java
src/main/java/com/glsx/controller/OpenApiController.java
src/main/java/com/glsx/exception/GlobalExceptionHandler.java
src/main/java/com/glsx/ice/HDaoGps/Callback_DaoGpsService_getLatestGpsBsRecord.java
src/main/java/com/glsx/ice/HDaoGps/DaoGpsServicePrx.java
src/main/java/com/glsx/ice/HDaoGps/DaoGpsServicePrxHelper.java
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsRecord.java
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsRecordHolder.java
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsReponse.java
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsReponseHolder.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDel.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDelD.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDelM.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDisp.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceOperations.java
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceOperationsNC.java
src/main/java/com/glsx/ice/iceClient/IceHDaoGpsClient.java
src/main/java/com/glsx/ice/iceClient/IcePoiSearchFTRClient.java
src/main/java/com/glsx/ice/iceClient/IceRtMileStatClient.java
src/main/java/com/glsx/intercepter/AuthIntercepter.java
src/main/java/com/glsx/model/BO/DeviceStatusBo.java
src/main/java/com/glsx/model/BO/GpsBsRecordsBo.java
src/main/java/com/glsx/model/BO/subscribeMessageBo.java
src/main/java/com/glsx/service/CommonParam.java
src/main/java/com/glsx/service/IOpenApiHTTPService.java
src/main/java/com/glsx/service/IOpenApiICEService.java
src/main/java/com/glsx/service/IOpenApiService.java
src/main/java/com/glsx/service/component/OpenApiInvoker.java
src/main/java/com/glsx/service/impl/OpenApiHTTPServiceImpl.java
src/main/java/com/glsx/service/impl/OpenApiICEServiceImpl.java
src/main/java/com/glsx/service/impl/OpenApiServiceImpl.java
src/main/java/com/glsx/utils/MapUtils.java
src/main/java/com/glsx/utils/RSAUtils.java
src/main/resources/config/application.properties
src/main/resources/logback.xml
src/main/java/com/glsx/base/aop/LogAspect.java
View file @
882b885
package
com
.
glsx
.
base
.
aop
;
package
com
.
glsx
.
base
.
aop
;
import
com.glsx.exception.ApiException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.aspectj.lang.reflect.CodeSignature
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.aspectj.lang.reflect.MethodSignature
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Map
;
@Component
@Component
@Aspect
@Aspect
@Slf4j
@Slf4j
...
@@ -34,7 +31,7 @@ public class LogAspect {
...
@@ -34,7 +31,7 @@ public class LogAspect {
* @date 2020年12月22日
* @date 2020年12月22日
*/
*/
@Around
(
"methodAspect()"
)
@Around
(
"methodAspect()"
)
public
Object
doAround
(
ProceedingJoinPoint
point
)
throws
Throwable
{
public
Object
doAround
(
ProceedingJoinPoint
point
)
{
//获取类名
//获取类名
String
className
=
point
.
getTarget
().
getClass
().
getName
();
String
className
=
point
.
getTarget
().
getClass
().
getName
();
...
@@ -42,21 +39,33 @@ public class LogAspect {
...
@@ -42,21 +39,33 @@ public class LogAspect {
MethodSignature
signature
=
(
MethodSignature
)
point
.
getSignature
();
MethodSignature
signature
=
(
MethodSignature
)
point
.
getSignature
();
String
methodName
=
signature
.
getMethod
().
getName
();
String
methodName
=
signature
.
getMethod
().
getName
();
//访问目标方法的参数:
//访问目标方法的参数名和参数值
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Object
[]
paramVals
=
point
.
getArgs
();
Object
[]
paramValues
=
point
.
getArgs
();
String
[]
paramNames
=
((
CodeSignature
)
point
.
getSignature
()).
getParameterNames
();
for
(
int
i
=
0
;
i
<
paramNames
.
length
;
i
++)
{
//todo 打印接口的入参
params
.
put
(
paramNames
[
i
],
paramValues
[
i
]);
/*//stream转为List
}
String[] paramNames = ((CodeSignature) point.getSignature()).getParameterNames();
List<Object> listValues = Arrays.stream(paramVals).collect(Collectors.toList());
List<String> listNames = Arrays.stream(paramNames).collect(Collectors.toList());
//将2个分为为key,value的list转为map,打印参数对象
Map<String, Object> params = MapUtils.listToMap(listNames, listValues);*/
log
.
info
(
className
+
"===调用"
+
methodName
+
"开始==="
+
params
);
log
.
info
(
className
+
"===调用"
+
methodName
+
"开始==="
);
//用改变后的参数执行目标方法
//用改变后的参数执行目标方法
Object
returnValue
=
point
.
proceed
(
paramValues
);
Object
returnValue
=
null
;
try
{
returnValue
=
point
.
proceed
(
paramVals
);
}
catch
(
Throwable
throwable
)
{
throwable
.
printStackTrace
();
throw
new
ApiException
(
className
+
"调用"
+
methodName
+
"失败,message:"
+
throwable
.
getMessage
());
}
log
.
info
(
className
+
"==="
+
methodName
+
"返回==="
+
returnValue
);
log
.
info
(
className
+
"==="
+
methodName
+
"返回==="
+
returnValue
);
return
returnValue
;
return
returnValue
;
}
}
}
}
src/main/java/com/glsx/base/aop/SysLog.java
View file @
882b885
...
@@ -14,4 +14,5 @@ import java.lang.annotation.Target;
...
@@ -14,4 +14,5 @@ import java.lang.annotation.Target;
@Target
(
ElementType
.
METHOD
)
// 方法注解
@Target
(
ElementType
.
METHOD
)
// 方法注解
@Retention
(
RetentionPolicy
.
RUNTIME
)
// 运行时可见
@Retention
(
RetentionPolicy
.
RUNTIME
)
// 运行时可见
public
@interface
SysLog
{
public
@interface
SysLog
{
// String name();
}
}
src/main/java/com/glsx/base/controller/BaseService.java
View file @
882b885
package
com
.
glsx
.
base
.
controller
;
package
com
.
glsx
.
base
.
controller
;
import
com.glsx.model.BO.DeviceStatusBo
;
import
com.glsx.model.BO.DeviceStayBo
;
import
com.glsx.model.BO.GpsBsRecordsBo
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.Basemodel
;
import
com.glsx.service.CommonParam
;
import
com.glsx.utils.JwtUtil
;
import
com.glsx.utils.SystemProperty
;
import
com.glsx.utils.SystemProperty
;
import
io.jsonwebtoken.Claims
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -22,8 +17,6 @@ public class BaseService {
...
@@ -22,8 +17,6 @@ public class BaseService {
@Autowired
@Autowired
private
SystemProperty
systemProperty
;
private
SystemProperty
systemProperty
;
@Autowired
private
JwtUtil
jwtUtil
;
/*
/*
* 获取配置中心属性
* 获取配置中心属性
...
@@ -50,48 +43,17 @@ public class BaseService {
...
@@ -50,48 +43,17 @@ public class BaseService {
/*
/*
* jwt方法
*/
private
Claims
getCustomerFromToken
(
Basemodel
basemodel
){
return
jwtUtil
.
getClaimsFromToken
(
basemodel
.
getToken
());
}
public
String
getCustomerStrProperty
(
Basemodel
basemodel
,
String
propertyName
){
return
(
String
)
getCustomerFromToken
(
basemodel
).
get
(
propertyName
);
}
public
Integer
getCustomerIntProperty
(
Basemodel
basemodel
,
String
propertyName
){
return
(
Integer
)
getCustomerFromToken
(
basemodel
).
get
(
propertyName
);
}
public
Integer
getCustomerID
(
Basemodel
basemodel
){
return
(
getCustomerIntProperty
(
basemodel
,
"appid"
));
}
/*
* 公共参数相关方法
* 公共参数相关方法
*/
*/
public
Long
getSn
(
DeviceStatusBo
deviceStatusBo
){
public
Long
getSn
(
CommonParam
commonParam
){
return
Long
.
parseLong
(
deviceStatusBo
.
getSn
());
return
Long
.
parseLong
(
commonParam
.
getLongSn
());
}
public
Long
getSn
(
GpsBsRecordsBo
gpsBsRecordsBo
){
return
Long
.
parseLong
(
gpsBsRecordsBo
.
getSn
());
}
public
Integer
getDeviceType
(
DeviceStatusBo
deviceStatusBo
){
return
deviceStatusBo
.
getDevice_type
();
}
public
Integer
getDeviceType
(
GpsBsRecordsBo
gpsBsRecordsBo
){
return
gpsBsRecordsBo
.
getDevice_type
();
}
}
public
Integer
getDeviceType
(
DeviceStayBo
deviceStayBo
){
public
Integer
getDeviceType
(
CommonParam
commonParam
){
return
deviceStayBo
.
getDevice_t
ype
();
return
commonParam
.
getIntDeviceT
ype
();
}
}
public
f
loat
getLat
(
BaseMapModel
mapModel
){
public
F
loat
getLat
(
BaseMapModel
mapModel
){
return
mapModel
.
getLat
().
floatValue
();
return
mapModel
.
getLat
().
floatValue
();
}
}
...
...
src/main/java/com/glsx/base/controller/JwtService.java
0 → 100644
View file @
882b885
package
com
.
glsx
.
base
.
controller
;
import
com.glsx.model.Basemodel
;
import
com.glsx.utils.JwtUtil
;
import
io.jsonwebtoken.Claims
;
import
org.springframework.beans.factory.annotation.Autowired
;
public
class
JwtService
extends
BaseService
{
@Autowired
protected
JwtUtil
jwtUtil
;
/*
* jwt方法
*/
private
Claims
getCustomerFromToken
(
Basemodel
basemodel
){
return
jwtUtil
.
getClaimsFromToken
(
basemodel
.
getToken
());
}
public
String
getCustomerStrProperty
(
Basemodel
basemodel
,
String
propertyName
){
return
(
String
)
getCustomerFromToken
(
basemodel
).
get
(
propertyName
);
}
public
Integer
getCustomerIntProperty
(
Basemodel
basemodel
,
String
propertyName
){
return
(
Integer
)
getCustomerFromToken
(
basemodel
).
get
(
propertyName
);
}
public
Integer
getCustomerID
(
Basemodel
basemodel
){
return
(
getCustomerIntProperty
(
basemodel
,
"appid"
));
}
}
src/main/java/com/glsx/constant/OpenAPIConstant.java
View file @
882b885
...
@@ -6,22 +6,38 @@ package com.glsx.constant;
...
@@ -6,22 +6,38 @@ package com.glsx.constant;
* @version V1.0
* @version V1.0
*/
*/
public
class
OpenAPIConstant
{
public
class
OpenAPIConstant
{
public
static
final
String
TEST_PRIVATE_KEY
=
"MIIB
VQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAqx/pXk7cbNk8ZDLs9nYE/6ohPqjefpsTvjJCHyVlUIYH+bhg1hG6SwZ9C5dJBWNplku0jcEZ5lq5SJboVXRYOQIDAQABAkA8S7460KayY8j3tUnxfZw9SYD1RyM+kP3f4m2R8+dC+6IS3qVis3zeowZjhliJOB7tipNSG/TClf2919PLysgBAiEA8Q44UuszieMaIm15MJNBQTQDvZleHXVNA5fPA5OL/MECIQC1u9Jxf/0DX3RkH5hO0Ryc8mI0/BxQUB6Z7s0bqPUheQIgKJTFRKhV99uktbEKWvQfYzO3gX7FSl5KBdXTwv1e7sECIQCENqvolQO+s3Ba8z18gde+OvzFrXDv4QoSVVB1QhtsiQIhAKL54pZ3s1ViBA4lUcRxuRZ4hrvSbwn09ozvIwM3aqFn
"
;
public
static
final
String
TEST_PRIVATE_KEY
=
"MIIB
UwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEAj7MKbIEiAK2wOIrEhvJtYZDi3wLy4qUxMbbTd8L64R7JI/+U+zFo5Pg1VNQpObEnc74fhppSSvrVzHo3sHx5rQIDAQABAkBlCF7l1w0PKQ9jUb3Hm59oH7RDVBFtZPPnnkGkTISTzj2AQmssY0DPlcOVfz/4vRxUMWPWuLSATmqUGi2LxLKBAiEA5KO7GYrdrA5ixkd7VvmkvObCtiO0R9InDsMSdiIyFNECIQCg5TSmvHYcOgHPTguN4XA5ySn9xRmO/ozY5rug2s2+HQIgJq7M6PVlq8aDT6ioZX63MH6aUtaXmc8kbIr0hKgkcQECIDGlR8/DCza+d1x+GnaW/0f1WG2jabWDufYbi/2gRifJAiAmtkTizcgcdvPc8BUZeKlWRnBR0dFATzfw9V91GJFkkQ==
"
;
public
static
final
String
TEST_TOKEN
=
"yRaUk3pOtRxYLH2nNoNBXSEC4zvPicu2d6gAOh+NLXl7TIiR8kDL/aMJQcjN4LDqLAnBosahygnRro6ZCoR7KXoE0bmJ+5Ozhv3Hz+vvzUyGEjGmorIVXIlS/KkZWAwIguFYhXXSDLHwxfZZHMQxTtARAv3hpf7nM++YeGCnNUQ
="
;
//public static final String TEST_TOKEN = "hlnE2oQB3oTG1adSEVzvxk5ZotIQcNV5niSmQbxzNGYhKeVpXS2Sk6VsuSiqE/MJwwBgSH7CJht2ohvvoMOLGQ=
=";
public
static
final
String
TEST_PUBLIC_KEY
=
"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBA
Ksf6V5O3GzZPGQy7PZ2BP+qIT6o3n6bE74yQh8lZVCGB/m4YNYRuksGfQuXSQVjaZZLtI3BGeZauUiW6FV0WDk
CAwEAAQ=="
;
public
static
final
String
TEST_PUBLIC_KEY
=
"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBA
I+zCmyBIgCtsDiKxIbybWGQ4t8C8uKlMTG203fC+uEeySP/lPsxaOT4NVTUKTmxJ3O+H4aaUkr61cx6N7B8ea0
CAwEAAQ=="
;
/**
* 拦截器中,过期时间格式展示
*/
public
static
final
String
TIME_FROMAT_NORMAL
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
TIME_FROMAT_NORMAL
=
"yyyy-MM-dd HH:mm:ss"
;
/**
* 签名参数名
*/
public
static
final
String
PARAM_SIGN
=
"sign"
;
public
static
final
String
PARAM_SIGN
=
"sign"
;
/**
* 配置中心的dubbo服务提供者
*/
public
static
final
String
DUBBO_SERVICE_URL
=
"openapi.dubbo.service.url"
;
public
static
final
String
DUBBO_SERVICE_URL
=
"openapi.dubbo.service.url"
;
/**
/**
*
缺少必填参数
*
围栏,碰撞接口相关
*/
*/
public
final
static
String
PARAM_IS_REQUIRED
=
"4000
"
;
public
static
final
String
HTTP_TIME_OUT
=
"openapi.http.timeout
"
;
public
static
final
String
HTTP_OPENAPI_SERVER
=
"openapi.http.server
"
;
public
static
final
String
HTTP_OPENAPI_SERVER
_1
=
"openapi.http.server1
"
;
public
static
final
String
METHOD_FENCE_RECORD
=
"openapi.fencereecords.name"
;
public
static
final
String
METHOD_FENCE_RECORD
=
"openapi.fencereecords.name"
;
public
static
final
String
METHOD_RESCUE_RECORD
=
"openapi.rescuerecords.name"
;
public
static
final
String
METHOD_RESCUE_RECORD
=
"openapi.rescuerecords.name"
;
public
static
final
String
HTTP_TIME_OUT
=
"openapi.http.timeout"
;
/**
* 设备状态,下发指令接口相关
*/
public
static
final
String
HTTP_OPENAPI_SERVER_2
=
"openapi.http.server2"
;
public
static
final
String
METHOD_DEVICE_STATUS
=
"openapi.devicestatus.name"
;
public
static
final
String
METHOD_POST_COMMANDS
=
"openapi.postcommands.name"
;
}
}
src/main/java/com/glsx/controller/OpenApiController.java
View file @
882b885
...
@@ -4,6 +4,7 @@ import com.glsx.model.BO.*;
...
@@ -4,6 +4,7 @@ import com.glsx.model.BO.*;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.DTO.*
;
import
com.glsx.model.DTO.*
;
import
com.glsx.model.Result
;
import
com.glsx.model.Result
;
import
com.glsx.service.IOpenApiHTTPService
;
import
com.glsx.service.IOpenApiICEService
;
import
com.glsx.service.IOpenApiICEService
;
import
com.glsx.service.IOpenApiService
;
import
com.glsx.service.IOpenApiService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -26,7 +27,7 @@ import java.util.Map;
...
@@ -26,7 +27,7 @@ import java.util.Map;
@Slf4j
@Slf4j
public
class
OpenApiController
{
public
class
OpenApiController
{
/*
/*
* 开放平台接口
* 开放平台接口
(本服务实现)
*/
*/
@Autowired
@Autowired
IOpenApiService
openApiService
;
IOpenApiService
openApiService
;
...
@@ -36,6 +37,12 @@ public class OpenApiController {
...
@@ -36,6 +37,12 @@ public class OpenApiController {
*/
*/
@Autowired
@Autowired
IOpenApiICEService
openApiICEService
;
IOpenApiICEService
openApiICEService
;
/*
* http协议的接口
*/
@Autowired
IOpenApiHTTPService
openApiHTTPService
;
/*
/*
* =================================openApiService=====================================
* =================================openApiService=====================================
*/
*/
...
@@ -82,24 +89,6 @@ public class OpenApiController {
...
@@ -82,24 +89,6 @@ public class OpenApiController {
*/
*/
/*
/*
* 下发指令
*/
@PostMapping
(
"postCommands"
)
public
Result
postCommands
(
@Valid
@RequestBody
CommandsBo
commandsBo
){
openApiICEService
.
postCommands
(
commandsBo
);
return
Result
.
ok
();
}
/*
* 查询设备状态
*/
@PostMapping
(
"deviceStatus"
)
public
Result
getDeviceStatus
(
@Valid
@RequestBody
DeviceStatusBo
deviceStatusBo
){
Map
<
String
,
Integer
>
map
=
openApiICEService
.
getDeviceStatus
(
deviceStatusBo
);
return
Result
.
ok
().
data
(
map
);
}
/*
* 查询最新位置点
* 查询最新位置点
*/
*/
@PostMapping
(
"latestGpsRecord"
)
@PostMapping
(
"latestGpsRecord"
)
...
@@ -270,12 +259,17 @@ public class OpenApiController {
...
@@ -270,12 +259,17 @@ public class OpenApiController {
return
Result
.
ok
().
data
(
map
);
return
Result
.
ok
().
data
(
map
);
}
}
/*
* =================================Http协议接口=====================================
*/
/*
/*
* 根据某段时间围栏触发记录
* 根据某段时间围栏触发记录
*/
*/
@PostMapping
(
"fenceTriggerRecords"
)
@PostMapping
(
"fenceTriggerRecords"
)
public
String
getFenceTriggerRecords
(
@Valid
@RequestBody
DeviceDateBo
deviceDateBo
){
public
String
getFenceTriggerRecords
(
@Valid
@RequestBody
DeviceDateBo
deviceDateBo
){
return
openApi
ICE
Service
.
getFenceTriggerRecords
(
deviceDateBo
);
return
openApi
HTTP
Service
.
getFenceTriggerRecords
(
deviceDateBo
);
}
}
/*
/*
...
@@ -283,7 +277,25 @@ public class OpenApiController {
...
@@ -283,7 +277,25 @@ public class OpenApiController {
*/
*/
@PostMapping
(
"rescueEventRecords"
)
@PostMapping
(
"rescueEventRecords"
)
public
String
getRescueEventRecords
(
@Valid
@RequestBody
DeviceSdeviceDateBo
deviceDateBo
){
public
String
getRescueEventRecords
(
@Valid
@RequestBody
DeviceSdeviceDateBo
deviceDateBo
){
return
openApiICEService
.
getRescueEventRecords
(
deviceDateBo
);
return
openApiHTTPService
.
getRescueEventRecords
(
deviceDateBo
);
}
/*
* 下发指令
*/
@PostMapping
(
"commands"
)
public
Result
postCommands
(
@Valid
@RequestBody
CommandsBo
commandsBo
){
openApiHTTPService
.
postCommands
(
commandsBo
);
return
Result
.
ok
();
}
/*
* 查询设备状态
*/
@PostMapping
(
"deviceStatus"
)
public
Result
getDeviceStatus
(
@Valid
@RequestBody
DeviceStatusBo
deviceStatusBo
){
Map
<
String
,
Integer
>
map
=
openApiHTTPService
.
getDeviceStatus
(
deviceStatusBo
);
return
Result
.
ok
().
data
(
map
);
}
}
}
}
src/main/java/com/glsx/exception/GlobalExceptionHandler.java
View file @
882b885
package
com
.
glsx
.
exception
;
package
com
.
glsx
.
exception
;
import
com.fasterxml.jackson.databind.exc.InvalidFormatException
;
import
com.glsx.model.Result
;
import
com.glsx.model.Result
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.FieldError
;
import
org.springframework.validation.FieldError
;
...
@@ -8,13 +9,13 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
...
@@ -8,13 +9,13 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* @Description: 全局异常处理
* @author fengzhi
* @author fengzhi
* @version V1.0
* @version V1.0
* @Description: 全局异常处理
*/
*/
@Slf4j
@Slf4j
@RestControllerAdvice
@RestControllerAdvice
...
@@ -35,10 +36,28 @@ public class GlobalExceptionHandler {
...
@@ -35,10 +36,28 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
public
Result
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
e
)
{
public
Result
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
e
)
{
List
<
String
>
errs
=
new
ArrayList
<>();
//遍历参数异常的提示信息拼接返回
for
(
FieldError
error
:
e
.
getBindingResult
().
getFieldErrors
())
{
List
<
String
>
errs
=
e
.
getBindingResult
()
errs
.
add
(
error
.
getDefaultMessage
());
.
getFieldErrors
()
}
.
stream
()
.
map
(
FieldError:
:
getDefaultMessage
)
.
collect
(
Collectors
.
toList
());
return
ApiErrorMessage
.
ARGS_NULL
.
exception
(
errs
).
getResultEntity
();
return
ApiErrorMessage
.
ARGS_NULL
.
exception
(
errs
).
getResultEntity
();
}
}
/**
* 业务异常处理
*
* @param req
* @param e
* @return
*/
@ExceptionHandler
(
value
=
InvalidFormatException
.
class
)
public
Result
InvalidFormatHandler
(
HttpServletRequest
req
,
Exception
e
)
{
String
errMsg
=
"jackson反序列化失败:"
+
e
.
getMessage
();
log
.
error
(
errMsg
);
return
new
ApiException
(
errMsg
).
getResultEntity
();
}
}
}
src/main/java/com/glsx/ice/HDaoGps/Callback_DaoGpsService_getLatestGpsBsRecord.java
0 → 100644
View file @
882b885
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `HDao_gps.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package
com
.
glsx
.
ice
.
HDaoGps
;
public
abstract
class
Callback_DaoGpsService_getLatestGpsBsRecord
extends
Ice
.
TwowayCallback
{
public
abstract
void
response
(
boolean
__ret
,
LatestGpsBsReponse
res
);
public
final
void
__completed
(
Ice
.
AsyncResult
__result
)
{
DaoGpsServicePrx
__proxy
=
(
DaoGpsServicePrx
)
__result
.
getProxy
();
boolean
__ret
=
false
;
LatestGpsBsReponseHolder
res
=
new
LatestGpsBsReponseHolder
();
try
{
__ret
=
__proxy
.
end_getLatestGpsBsRecord
(
res
,
__result
);
}
catch
(
Ice
.
LocalException
__ex
)
{
exception
(
__ex
);
return
;
}
response
(
__ret
,
res
.
value
);
}
}
src/main/java/com/glsx/ice/HDaoGps/DaoGpsServicePrx.java
View file @
882b885
...
@@ -22,6 +22,24 @@ package com.glsx.ice.HDaoGps;
...
@@ -22,6 +22,24 @@ package com.glsx.ice.HDaoGps;
public
interface
DaoGpsServicePrx
extends
Ice
.
ObjectPrx
public
interface
DaoGpsServicePrx
extends
Ice
.
ObjectPrx
{
{
public
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
);
public
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
Ice
.
Callback
__cb
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Callback
__cb
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
Callback_DaoGpsService_getLatestGpsBsRecord
__cb
);
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Callback_DaoGpsService_getLatestGpsBsRecord
__cb
);
public
boolean
end_getLatestGpsBsRecord
(
LatestGpsBsReponseHolder
res
,
Ice
.
AsyncResult
__result
);
public
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
);
public
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
);
public
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
);
public
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
);
...
...
src/main/java/com/glsx/ice/HDaoGps/DaoGpsServicePrxHelper.java
View file @
882b885
...
@@ -2334,6 +2334,142 @@ public final class DaoGpsServicePrxHelper extends Ice.ObjectPrxHelperBase implem
...
@@ -2334,6 +2334,142 @@ public final class DaoGpsServicePrxHelper extends Ice.ObjectPrxHelperBase implem
}
}
}
}
private
static
final
String
__getLatestGpsBsRecord_name
=
"getLatestGpsBsRecord"
;
public
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
)
{
return
getLatestGpsBsRecord
(
req
,
res
,
null
,
false
);
}
public
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
)
{
return
getLatestGpsBsRecord
(
req
,
res
,
__ctx
,
true
);
}
private
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
boolean
__explicitCtx
)
{
if
(
__explicitCtx
&&
__ctx
==
null
)
{
__ctx
=
_emptyContext
;
}
final
Ice
.
Instrumentation
.
InvocationObserver
__observer
=
IceInternal
.
ObserverHelper
.
get
(
this
,
"getLatestGpsBsRecord"
,
__ctx
);
int
__cnt
=
0
;
try
{
while
(
true
)
{
Ice
.
_ObjectDel
__delBase
=
null
;
try
{
__checkTwowayOnly
(
"getLatestGpsBsRecord"
);
__delBase
=
__getDelegate
(
false
);
_DaoGpsServiceDel
__del
=
(
_DaoGpsServiceDel
)
__delBase
;
return
__del
.
getLatestGpsBsRecord
(
req
,
res
,
__ctx
,
__observer
);
}
catch
(
IceInternal
.
LocalExceptionWrapper
__ex
)
{
__handleExceptionWrapper
(
__delBase
,
__ex
,
__observer
);
}
catch
(
Ice
.
LocalException
__ex
)
{
__cnt
=
__handleException
(
__delBase
,
__ex
,
null
,
__cnt
,
__observer
);
}
}
}
finally
{
if
(
__observer
!=
null
)
{
__observer
.
detach
();
}
}
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
)
{
return
begin_getLatestGpsBsRecord
(
req
,
null
,
false
,
null
);
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
)
{
return
begin_getLatestGpsBsRecord
(
req
,
__ctx
,
true
,
null
);
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
Ice
.
Callback
__cb
)
{
return
begin_getLatestGpsBsRecord
(
req
,
null
,
false
,
__cb
);
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Callback
__cb
)
{
return
begin_getLatestGpsBsRecord
(
req
,
__ctx
,
true
,
__cb
);
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
Callback_DaoGpsService_getLatestGpsBsRecord
__cb
)
{
return
begin_getLatestGpsBsRecord
(
req
,
null
,
false
,
__cb
);
}
public
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Callback_DaoGpsService_getLatestGpsBsRecord
__cb
)
{
return
begin_getLatestGpsBsRecord
(
req
,
__ctx
,
true
,
__cb
);
}
private
Ice
.
AsyncResult
begin_getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
boolean
__explicitCtx
,
IceInternal
.
CallbackBase
__cb
)
{
__checkAsyncTwowayOnly
(
__getLatestGpsBsRecord_name
);
IceInternal
.
OutgoingAsync
__result
=
new
IceInternal
.
OutgoingAsync
(
this
,
__getLatestGpsBsRecord_name
,
__cb
);
try
{
__result
.
__prepare
(
__getLatestGpsBsRecord_name
,
Ice
.
OperationMode
.
Normal
,
__ctx
,
__explicitCtx
);
IceInternal
.
BasicStream
__os
=
__result
.
__startWriteParams
(
Ice
.
FormatType
.
DefaultFormat
);
req
.
__write
(
__os
);
__result
.
__endWriteParams
();
__result
.
__send
(
true
);
}
catch
(
Ice
.
LocalException
__ex
)
{
__result
.
__exceptionAsync
(
__ex
);
}
return
__result
;
}
public
boolean
end_getLatestGpsBsRecord
(
LatestGpsBsReponseHolder
res
,
Ice
.
AsyncResult
__result
)
{
Ice
.
AsyncResult
.
__check
(
__result
,
this
,
__getLatestGpsBsRecord_name
);
boolean
__ok
=
__result
.
__wait
();
try
{
if
(!
__ok
)
{
try
{
__result
.
__throwUserException
();
}
catch
(
Ice
.
UserException
__ex
)
{
throw
new
Ice
.
UnknownUserException
(
__ex
.
ice_name
(),
__ex
);
}
}
IceInternal
.
BasicStream
__is
=
__result
.
__startReadParams
();
res
.
value
=
new
LatestGpsBsReponse
();
res
.
value
.
__read
(
__is
);
boolean
__ret
;
__ret
=
__is
.
readBool
();
__result
.
__endReadParams
();
return
__ret
;
}
catch
(
Ice
.
LocalException
ex
)
{
Ice
.
Instrumentation
.
InvocationObserver
__obsv
=
__result
.
__getObserver
();
if
(
__obsv
!=
null
)
{
__obsv
.
failed
(
ex
.
ice_name
());
}
throw
ex
;
}
}
private
static
final
String
__getLatestGpsRecord_name
=
"getLatestGpsRecord"
;
private
static
final
String
__getLatestGpsRecord_name
=
"getLatestGpsRecord"
;
public
boolean
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
)
public
boolean
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
)
...
...
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsRecord.java
0 → 100644
View file @
882b885
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `HDao_gps.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package
com
.
glsx
.
ice
.
HDaoGps
;
public
class
LatestGpsBsRecord
implements
Cloneable
,
java
.
io
.
Serializable
{
public
GpsRecord
recordgps
;
public
BsRecord
recordbs
;
public
LatestGpsBsRecord
()
{
}
public
LatestGpsBsRecord
(
GpsRecord
recordgps
,
BsRecord
recordbs
)
{
this
.
recordgps
=
recordgps
;
this
.
recordbs
=
recordbs
;
}
public
boolean
equals
(
Object
rhs
)
{
if
(
this
==
rhs
)
{
return
true
;
}
LatestGpsBsRecord
_r
=
null
;
if
(
rhs
instanceof
LatestGpsBsRecord
)
{
_r
=
(
LatestGpsBsRecord
)
rhs
;
}
if
(
_r
!=
null
)
{
if
(
recordgps
!=
_r
.
recordgps
)
{
if
(
recordgps
==
null
||
_r
.
recordgps
==
null
||
!
recordgps
.
equals
(
_r
.
recordgps
))
{
return
false
;
}
}
if
(
recordbs
!=
_r
.
recordbs
)
{
if
(
recordbs
==
null
||
_r
.
recordbs
==
null
||
!
recordbs
.
equals
(
_r
.
recordbs
))
{
return
false
;
}
}
return
true
;
}
return
false
;
}
public
int
hashCode
()
{
int
__h
=
5381
;
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
"::HDaoGps::LatestGpsBsRecord"
);
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
recordgps
);
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
recordbs
);
return
__h
;
}
public
Object
clone
()
{
Object
o
=
null
;
try
{
o
=
super
.
clone
();
}
catch
(
CloneNotSupportedException
ex
)
{
assert
false
;
// impossible
}
return
o
;
}
public
void
__write
(
IceInternal
.
BasicStream
__os
)
{
recordgps
.
__write
(
__os
);
recordbs
.
__write
(
__os
);
}
public
void
__read
(
IceInternal
.
BasicStream
__is
)
{
recordgps
=
new
GpsRecord
();
recordgps
.
__read
(
__is
);
recordbs
=
new
BsRecord
();
recordbs
.
__read
(
__is
);
}
public
static
final
long
serialVersionUID
=
723492379L
;
}
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsRecordHolder.java
0 → 100644
View file @
882b885
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `HDao_gps.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package
com
.
glsx
.
ice
.
HDaoGps
;
public
final
class
LatestGpsBsRecordHolder
{
public
LatestGpsBsRecordHolder
()
{
}
public
LatestGpsBsRecordHolder
(
LatestGpsBsRecord
value
)
{
this
.
value
=
value
;
}
public
LatestGpsBsRecord
value
;
}
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsReponse.java
0 → 100644
View file @
882b885
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `HDao_gps.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package
com
.
glsx
.
ice
.
HDaoGps
;
public
class
LatestGpsBsReponse
implements
Cloneable
,
java
.
io
.
Serializable
{
public
int
oprGpsResult
;
public
int
oprBsResult
;
public
LatestGpsBsRecord
record
;
public
LatestGpsBsReponse
()
{
}
public
LatestGpsBsReponse
(
int
oprGpsResult
,
int
oprBsResult
,
LatestGpsBsRecord
record
)
{
this
.
oprGpsResult
=
oprGpsResult
;
this
.
oprBsResult
=
oprBsResult
;
this
.
record
=
record
;
}
public
boolean
equals
(
Object
rhs
)
{
if
(
this
==
rhs
)
{
return
true
;
}
LatestGpsBsReponse
_r
=
null
;
if
(
rhs
instanceof
LatestGpsBsReponse
)
{
_r
=
(
LatestGpsBsReponse
)
rhs
;
}
if
(
_r
!=
null
)
{
if
(
oprGpsResult
!=
_r
.
oprGpsResult
)
{
return
false
;
}
if
(
oprBsResult
!=
_r
.
oprBsResult
)
{
return
false
;
}
if
(
record
!=
_r
.
record
)
{
if
(
record
==
null
||
_r
.
record
==
null
||
!
record
.
equals
(
_r
.
record
))
{
return
false
;
}
}
return
true
;
}
return
false
;
}
public
int
hashCode
()
{
int
__h
=
5381
;
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
"::HDaoGps::LatestGpsBsReponse"
);
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
oprGpsResult
);
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
oprBsResult
);
__h
=
IceInternal
.
HashUtil
.
hashAdd
(
__h
,
record
);
return
__h
;
}
public
Object
clone
()
{
Object
o
=
null
;
try
{
o
=
super
.
clone
();
}
catch
(
CloneNotSupportedException
ex
)
{
assert
false
;
// impossible
}
return
o
;
}
public
void
__write
(
IceInternal
.
BasicStream
__os
)
{
__os
.
writeInt
(
oprGpsResult
);
__os
.
writeInt
(
oprBsResult
);
record
.
__write
(
__os
);
}
public
void
__read
(
IceInternal
.
BasicStream
__is
)
{
oprGpsResult
=
__is
.
readInt
();
oprBsResult
=
__is
.
readInt
();
record
=
new
LatestGpsBsRecord
();
record
.
__read
(
__is
);
}
public
static
final
long
serialVersionUID
=
-
2035334900L
;
}
src/main/java/com/glsx/ice/HDaoGps/LatestGpsBsReponseHolder.java
0 → 100644
View file @
882b885
// **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `HDao_gps.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package
com
.
glsx
.
ice
.
HDaoGps
;
public
final
class
LatestGpsBsReponseHolder
{
public
LatestGpsBsReponseHolder
()
{
}
public
LatestGpsBsReponseHolder
(
LatestGpsBsReponse
value
)
{
this
.
value
=
value
;
}
public
LatestGpsBsReponse
value
;
}
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDel.java
View file @
882b885
...
@@ -22,6 +22,9 @@ package com.glsx.ice.HDaoGps;
...
@@ -22,6 +22,9 @@ package com.glsx.ice.HDaoGps;
public
interface
_DaoGpsServiceDel
extends
Ice
.
_ObjectDel
public
interface
_DaoGpsServiceDel
extends
Ice
.
_ObjectDel
{
{
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__obsv
)
throws
IceInternal
.
LocalExceptionWrapper
;
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__obsv
)
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__obsv
)
throws
IceInternal
.
LocalExceptionWrapper
;
throws
IceInternal
.
LocalExceptionWrapper
;
...
...
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDelD.java
View file @
882b885
...
@@ -906,6 +906,58 @@ public final class _DaoGpsServiceDelD extends Ice._ObjectDelD implements _DaoGps
...
@@ -906,6 +906,58 @@ public final class _DaoGpsServiceDelD extends Ice._ObjectDelD implements _DaoGps
return
__result
.
value
;
return
__result
.
value
;
}
}
public
boolean
getLatestGpsBsRecord
(
final
LatestGpsGetRequest
req
,
final
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
throws
IceInternal
.
LocalExceptionWrapper
{
final
Ice
.
Current
__current
=
new
Ice
.
Current
();
__initCurrent
(
__current
,
"getLatestGpsBsRecord"
,
Ice
.
OperationMode
.
Normal
,
__ctx
);
final
Ice
.
BooleanHolder
__result
=
new
Ice
.
BooleanHolder
();
IceInternal
.
Direct
__direct
=
null
;
try
{
__direct
=
new
IceInternal
.
Direct
(
__current
)
{
public
Ice
.
DispatchStatus
run
(
Ice
.
Object
__obj
)
{
DaoGpsService
__servant
=
null
;
if
(
__obj
==
null
||
__obj
instanceof
DaoGpsService
)
{
__servant
=
(
DaoGpsService
)
__obj
;
}
else
{
throw
new
Ice
.
OperationNotExistException
(
__current
.
id
,
__current
.
facet
,
__current
.
operation
);
}
__result
.
value
=
__servant
.
getLatestGpsBsRecord
(
req
,
res
,
__current
);
return
Ice
.
DispatchStatus
.
DispatchOK
;
}
};
try
{
Ice
.
DispatchStatus
__status
=
__direct
.
getServant
().
__collocDispatch
(
__direct
);
if
(
__status
==
Ice
.
DispatchStatus
.
DispatchUserException
)
{
__direct
.
throwUserException
();
}
assert
__status
==
Ice
.
DispatchStatus
.
DispatchOK
;
return
__result
.
value
;
}
finally
{
__direct
.
destroy
();
}
}
catch
(
Ice
.
SystemException
__ex
)
{
throw
__ex
;
}
catch
(
Throwable
__ex
)
{
IceInternal
.
LocalExceptionWrapper
.
throwWrapper
(
__ex
);
}
return
__result
.
value
;
}
public
boolean
getLatestGpsRecord
(
final
LatestGpsGetRequest
req
,
final
LatestGpsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
public
boolean
getLatestGpsRecord
(
final
LatestGpsGetRequest
req
,
final
LatestGpsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
throws
IceInternal
.
LocalExceptionWrapper
throws
IceInternal
.
LocalExceptionWrapper
{
{
...
...
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDelM.java
View file @
882b885
...
@@ -873,6 +873,56 @@ public final class _DaoGpsServiceDelM extends Ice._ObjectDelM implements _DaoGps
...
@@ -873,6 +873,56 @@ public final class _DaoGpsServiceDelM extends Ice._ObjectDelM implements _DaoGps
}
}
public
boolean
public
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
throws
IceInternal
.
LocalExceptionWrapper
{
IceInternal
.
Outgoing
__og
=
__handler
.
getOutgoing
(
"getLatestGpsBsRecord"
,
Ice
.
OperationMode
.
Normal
,
__ctx
,
__observer
);
try
{
try
{
IceInternal
.
BasicStream
__os
=
__og
.
startWriteParams
(
Ice
.
FormatType
.
DefaultFormat
);
req
.
__write
(
__os
);
__og
.
endWriteParams
();
}
catch
(
Ice
.
LocalException
__ex
)
{
__og
.
abort
(
__ex
);
}
boolean
__ok
=
__og
.
invoke
();
try
{
if
(!
__ok
)
{
try
{
__og
.
throwUserException
();
}
catch
(
Ice
.
UserException
__ex
)
{
throw
new
Ice
.
UnknownUserException
(
__ex
.
ice_name
(),
__ex
);
}
}
IceInternal
.
BasicStream
__is
=
__og
.
startReadParams
();
res
.
value
=
new
LatestGpsBsReponse
();
res
.
value
.
__read
(
__is
);
boolean
__ret
;
__ret
=
__is
.
readBool
();
__og
.
endReadParams
();
return
__ret
;
}
catch
(
Ice
.
LocalException
__ex
)
{
throw
new
IceInternal
.
LocalExceptionWrapper
(
__ex
,
false
);
}
}
finally
{
__handler
.
reclaimOutgoing
(
__og
);
}
}
public
boolean
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
,
java
.
util
.
Map
<
String
,
String
>
__ctx
,
Ice
.
Instrumentation
.
InvocationObserver
__observer
)
throws
IceInternal
.
LocalExceptionWrapper
throws
IceInternal
.
LocalExceptionWrapper
{
{
...
...
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceDisp.java
View file @
882b885
...
@@ -155,6 +155,11 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
...
@@ -155,6 +155,11 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
return
getLatestBsRecord
(
req
,
res
,
null
);
return
getLatestBsRecord
(
req
,
res
,
null
);
}
}
public
final
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
)
{
return
getLatestGpsBsRecord
(
req
,
res
,
null
);
}
public
final
boolean
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
)
public
final
boolean
getLatestGpsRecord
(
LatestGpsGetRequest
req
,
LatestGpsGetResponseHolder
res
)
{
{
return
getLatestGpsRecord
(
req
,
res
,
null
);
return
getLatestGpsRecord
(
req
,
res
,
null
);
...
@@ -225,6 +230,23 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
...
@@ -225,6 +230,23 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
return
getVoltageRecords
(
req
,
res
,
null
);
return
getVoltageRecords
(
req
,
res
,
null
);
}
}
public
static
Ice
.
DispatchStatus
___getLatestGpsBsRecord
(
DaoGpsService
__obj
,
IceInternal
.
Incoming
__inS
,
Ice
.
Current
__current
)
{
__checkMode
(
Ice
.
OperationMode
.
Normal
,
__current
.
mode
);
IceInternal
.
BasicStream
__is
=
__inS
.
startReadParams
();
LatestGpsGetRequest
req
;
req
=
new
LatestGpsGetRequest
();
req
.
__read
(
__is
);
__inS
.
endReadParams
();
LatestGpsBsReponseHolder
res
=
new
LatestGpsBsReponseHolder
();
boolean
__ret
=
__obj
.
getLatestGpsBsRecord
(
req
,
res
,
__current
);
IceInternal
.
BasicStream
__os
=
__inS
.
__startWriteParams
(
Ice
.
FormatType
.
DefaultFormat
);
res
.
value
.
__write
(
__os
);
__os
.
writeBool
(
__ret
);
__inS
.
__endWriteParams
(
true
);
return
Ice
.
DispatchStatus
.
DispatchOK
;
}
public
static
Ice
.
DispatchStatus
___getBsRecords
(
DaoGpsService
__obj
,
IceInternal
.
Incoming
__inS
,
Ice
.
Current
__current
)
public
static
Ice
.
DispatchStatus
___getBsRecords
(
DaoGpsService
__obj
,
IceInternal
.
Incoming
__inS
,
Ice
.
Current
__current
)
{
{
__checkMode
(
Ice
.
OperationMode
.
Normal
,
__current
.
mode
);
__checkMode
(
Ice
.
OperationMode
.
Normal
,
__current
.
mode
);
...
@@ -771,6 +793,7 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
...
@@ -771,6 +793,7 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
"getGpsWorkModeRecords"
,
"getGpsWorkModeRecords"
,
"getLatestBatteryRecord"
,
"getLatestBatteryRecord"
,
"getLatestBsRecord"
,
"getLatestBsRecord"
,
"getLatestGpsBsRecord"
,
"getLatestGpsRecord"
,
"getLatestGpsRecord"
,
"getLatestGpsRecordByImei"
,
"getLatestGpsRecordByImei"
,
"getLatestGpsRecordByMapSn"
,
"getLatestGpsRecordByMapSn"
,
...
@@ -871,74 +894,78 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
...
@@ -871,74 +894,78 @@ public abstract class _DaoGpsServiceDisp extends Ice.ObjectImpl implements DaoGp
}
}
case
17
:
case
17
:
{
{
return
___getLatestGpsRecord
(
this
,
in
,
__current
);
return
___getLatestGps
Bs
Record
(
this
,
in
,
__current
);
}
}
case
18
:
case
18
:
{
{
return
___getLatestGpsRecord
ByImei
(
this
,
in
,
__current
);
return
___getLatestGpsRecord
(
this
,
in
,
__current
);
}
}
case
19
:
case
19
:
{
{
return
___getLatestGpsRecordBy
MapSn
(
this
,
in
,
__current
);
return
___getLatestGpsRecordBy
Imei
(
this
,
in
,
__current
);
}
}
case
20
:
case
20
:
{
{
return
___getLatestGps
Time
(
this
,
in
,
__current
);
return
___getLatestGps
RecordByMapSn
(
this
,
in
,
__current
);
}
}
case
21
:
case
21
:
{
{
return
___getLatest
LocationByLbsRecord
(
this
,
in
,
__current
);
return
___getLatest
GpsTime
(
this
,
in
,
__current
);
}
}
case
22
:
case
22
:
{
{
return
___getLatest
Rgp
sRecord
(
this
,
in
,
__current
);
return
___getLatest
LocationByLb
sRecord
(
this
,
in
,
__current
);
}
}
case
23
:
case
23
:
{
{
return
___getLatest
Vol
Record
(
this
,
in
,
__current
);
return
___getLatest
Rgps
Record
(
this
,
in
,
__current
);
}
}
case
24
:
case
24
:
{
{
return
___get
MaxVolDiff
(
this
,
in
,
__current
);
return
___get
LatestVolRecord
(
this
,
in
,
__current
);
}
}
case
25
:
case
25
:
{
{
return
___get
ParadeCarAlarmRecords
(
this
,
in
,
__current
);
return
___get
MaxVolDiff
(
this
,
in
,
__current
);
}
}
case
26
:
case
26
:
{
{
return
___getParadeCar
Gps
Records
(
this
,
in
,
__current
);
return
___getParadeCar
Alarm
Records
(
this
,
in
,
__current
);
}
}
case
27
:
case
27
:
{
{
return
___get
RecentB
sRecords
(
this
,
in
,
__current
);
return
___get
ParadeCarGp
sRecords
(
this
,
in
,
__current
);
}
}
case
28
:
case
28
:
{
{
return
___getRecent
Gp
sRecords
(
this
,
in
,
__current
);
return
___getRecent
B
sRecords
(
this
,
in
,
__current
);
}
}
case
29
:
case
29
:
{
{
return
___get
SnMap
Records
(
this
,
in
,
__current
);
return
___get
RecentGps
Records
(
this
,
in
,
__current
);
}
}
case
30
:
case
30
:
{
{
return
___get
Voltage
Records
(
this
,
in
,
__current
);
return
___get
SnMap
Records
(
this
,
in
,
__current
);
}
}
case
31
:
case
31
:
{
{
return
___
ice_id
(
this
,
in
,
__current
);
return
___
getVoltageRecords
(
this
,
in
,
__current
);
}
}
case
32
:
case
32
:
{
{
return
___ice_id
s
(
this
,
in
,
__current
);
return
___ice_id
(
this
,
in
,
__current
);
}
}
case
33
:
case
33
:
{
{
return
___ice_i
sA
(
this
,
in
,
__current
);
return
___ice_i
ds
(
this
,
in
,
__current
);
}
}
case
34
:
case
34
:
{
{
return
___ice_isA
(
this
,
in
,
__current
);
}
case
35
:
{
return
___ice_ping
(
this
,
in
,
__current
);
return
___ice_ping
(
this
,
in
,
__current
);
}
}
}
}
...
...
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceOperations.java
View file @
882b885
...
@@ -22,6 +22,8 @@ package com.glsx.ice.HDaoGps;
...
@@ -22,6 +22,8 @@ package com.glsx.ice.HDaoGps;
public
interface
_DaoGpsServiceOperations
public
interface
_DaoGpsServiceOperations
{
{
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
,
Ice
.
Current
__current
);
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
Ice
.
Current
__current
);
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
,
Ice
.
Current
__current
);
boolean
getLatestBsRecord
(
LatestBsGetRequest
req
,
LatestBsGetResponseHolder
res
,
Ice
.
Current
__current
);
boolean
getLatestBsRecord
(
LatestBsGetRequest
req
,
LatestBsGetResponseHolder
res
,
Ice
.
Current
__current
);
...
...
src/main/java/com/glsx/ice/HDaoGps/_DaoGpsServiceOperationsNC.java
View file @
882b885
...
@@ -22,6 +22,8 @@ package com.glsx.ice.HDaoGps;
...
@@ -22,6 +22,8 @@ package com.glsx.ice.HDaoGps;
public
interface
_DaoGpsServiceOperationsNC
public
interface
_DaoGpsServiceOperationsNC
{
{
boolean
getLatestGpsBsRecord
(
LatestGpsGetRequest
req
,
LatestGpsBsReponseHolder
res
);
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
);
boolean
getBsRecords
(
BsGetRequest
req
,
BsGetResponseHolder
res
);
boolean
getLatestBsRecord
(
LatestBsGetRequest
req
,
LatestBsGetResponseHolder
res
);
boolean
getLatestBsRecord
(
LatestBsGetRequest
req
,
LatestBsGetResponseHolder
res
);
...
...
src/main/java/com/glsx/ice/iceClient/IceHDaoGpsClient.java
View file @
882b885
...
@@ -5,16 +5,12 @@ import com.glsx.model.DTO.*;
...
@@ -5,16 +5,12 @@ import com.glsx.model.DTO.*;
import
com.glsx.utils.SystemProperty
;
import
com.glsx.utils.SystemProperty
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
public
class
IceHDaoGpsClient
{
public
class
IceHDaoGpsClient
{
static
String
url
=
SystemProperty
.
getProperty
(
"ice.traceUrl"
);
static
String
url
=
SystemProperty
.
getProperty
(
"ice.traceUrl"
);
// static String url = "HDaoGpsSvc:default -h 192.168.3.153 -p 23479";
static
Ice
.
Communicator
ic
=
Ice
.
Util
.
initialize
();
static
Ice
.
Communicator
ic
=
Ice
.
Util
.
initialize
();
static
Ice
.
ObjectPrx
base
=
ic
.
stringToProxy
(
url
).
ice_timeout
(
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
"ice.connectTimeout"
)));
static
Ice
.
ObjectPrx
base
=
ic
.
stringToProxy
(
url
).
ice_timeout
(
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
"ice.connectTimeout"
)));
static
DaoGpsServicePrx
prx
=
DaoGpsServicePrxHelper
.
checkedCast
(
base
);
static
DaoGpsServicePrx
prx
=
DaoGpsServicePrxHelper
.
checkedCast
(
base
);
...
@@ -26,13 +22,11 @@ public class IceHDaoGpsClient {
...
@@ -26,13 +22,11 @@ public class IceHDaoGpsClient {
throw
new
Exception
(
"Invalid proxy"
);
throw
new
Exception
(
"Invalid proxy"
);
}
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestRgpsGetRequest
req
=
new
LatestRgpsGetRequest
(
sn
,
deviceType
,
mapType
);
LatestRgpsGetRequest
req
=
new
LatestRgpsGetRequest
(
sn
,
deviceType
,
mapType
);
LatestRgpsGetResponseHolder
res
=
new
LatestRgpsGetResponseHolder
();
LatestRgpsGetResponseHolder
res
=
new
LatestRgpsGetResponseHolder
();
boolean
ret
=
false
;
boolean
ret
=
false
;
ret
=
prx
.
getLatestRgpsRecord
(
req
,
res
);
ret
=
prx
.
getLatestRgpsRecord
(
req
,
res
);
if
(
ret
)
{
if
(
ret
&&
res
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
log
.
info
(
"===getLatestRGPSRecord:"
+
res
.
value
.
record
);
gpsRecord
=
new
LatestGpsRecordDto
();
gpsRecord
=
new
LatestGpsRecordDto
();
gpsRecord
.
setSn
(
sn
+
""
);
gpsRecord
.
setSn
(
sn
+
""
);
gpsRecord
.
setGlng
(
res
.
value
.
record
.
gLng
/
1000000
D
);
gpsRecord
.
setGlng
(
res
.
value
.
record
.
gLng
/
1000000
D
);
...
@@ -87,36 +81,56 @@ public class IceHDaoGpsClient {
...
@@ -87,36 +81,56 @@ public class IceHDaoGpsClient {
return
bsRecord
;
return
bsRecord
;
}
}
public
static
LatestGpsBsRecordDto
get
DevicesGpsInfo
(
long
[]
userIds
,
int
extraMapReq
,
int
seqNo
)
{
public
static
LatestGpsBsRecordDto
get
LatestGpsBsRecord
(
long
userID
,
int
apType
,
int
extraMapReq
)
{
LatestGpsBsRecordDto
bsRecord
=
null
;
LatestGpsBsRecordDto
gps
bsRecord
=
null
;
try
{
try
{
if
(
prx
==
null
)
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
throw
new
Exception
(
"Invalid proxy"
);
}
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestGpsBsReponseHolder
res
=
new
LatestGpsBsReponseHolder
();
BatchGpsDevInfoResponseHolder
res
=
new
BatchGpsDevInfoResponseHolder
();
boolean
ret
=
false
;
boolean
ret
=
false
;
BatchGpsDevInfoRequest
req
=
new
BatchGpsDevInfoRequest
(
userIds
,
extraMapReq
,
seqNo
);
LatestGpsGetRequest
req
=
new
LatestGpsGetRequest
(
userID
,
apType
,
extraMapReq
);
ret
=
prx
.
get
DevicesGpsInfo
(
req
,
res
);
ret
=
prx
.
get
LatestGpsBsRecord
(
req
,
res
);
if
(
ret
)
{
if
(
ret
)
{
log
.
info
(
"===getDevicesGpsInfo:"
+
res
.
value
.
gpsDevInfos
);
int
gpsCode
=
res
.
value
.
oprGpsResult
;
GpsDevInfo
[]
gpsDevInfos
=
res
.
value
.
gpsDevInfos
;
int
bsCode
=
res
.
value
.
oprBsResult
;
if
(
null
!=
gpsDevInfos
&&
gpsDevInfos
.
length
>
0
)
{
log
.
info
(
"===getLatestGpsBsRecord===gpsCode:"
+
gpsCode
+
"===bsCode:"
+
bsCode
);
GpsDevInfo
gpsDevInfo
=
gpsDevInfos
[
0
];
LatestGpsBsRecord
record
=
res
.
value
.
record
;
bsRecord
=
new
LatestGpsBsRecordDto
();
bsRecord
.
setGpstime
(
gpsDevInfo
.
record
.
gpsTime
);
if
(
gpsCode
!=
0
&&
bsCode
!=
0
)
//bsRecord.setMcc(gpsDevInfo.record.);
return
null
;
//bsRecord.setMnc(gpsDevInfo.record.mnc);
gpsbsRecord
=
new
LatestGpsBsRecordDto
();
gpsbsRecord
.
setSn
(
userID
+
""
);
//List<BsRecordDto> bsInfos = Arrays.stream(res.value.record.bsInfos).map(bsInfo -> {
if
(
gpsCode
==
0
)
{
// BsRecordDto bsRecordDto = new BsRecordDto();
GpsRecord
gr
=
record
.
recordgps
;
// bsRecordDto.setCi(bsInfo.cellId);
gpsbsRecord
.
setGpstime
(
gr
.
gpsTime
);
// bsRecordDto.setLac(bsInfo.lac);
gpsbsRecord
.
setLng
(
gr
.
lng
/
1000000
D
);
// bsRecordDto.setSignal(bsInfo.signal);
gpsbsRecord
.
setLat
(
gr
.
lat
/
1000000
D
);
// return bsRecordDto;
gpsbsRecord
.
setSpeed
(
gr
.
speed
);
//}).collect(Collectors.toList());
gpsbsRecord
.
setAlt
(
gr
.
alt
);
//bsRecord.setBsrecord(bsInfos);
gpsbsRecord
.
setDir
(
gr
.
dir
);
gpsbsRecord
.
setGlng
(
gr
.
gLng
/
1000000
D
);
gpsbsRecord
.
setGlat
(
gr
.
gLat
/
1000000
D
);
gpsbsRecord
.
setBlng
(
gr
.
bLng
/
1000000
D
);
gpsbsRecord
.
setBlat
(
gr
.
bLat
/
1000000
D
);
}
if
(
bsCode
==
0
)
{
BsRecord
br
=
record
.
recordbs
;
//gpsbsRecord.setBsvalid(br.);
gpsbsRecord
.
setMcc
(
br
.
mcc
);
gpsbsRecord
.
setMnc
(
br
.
mnc
);
List
<
BsInfoDto
>
bsrecord
=
Arrays
.
stream
(
br
.
bsInfos
).
map
(
bi
->{
BsInfoDto
bsInfoDto
=
new
BsInfoDto
();
bsInfoDto
.
setCi
(
bi
.
cellId
);
bsInfoDto
.
setLac
(
bi
.
lac
);
bsInfoDto
.
setSignal
(
bi
.
signal
);
return
bsInfoDto
;
}).
collect
(
Collectors
.
toList
());
gpsbsRecord
.
setBsrecord
(
bsrecord
);
}
}
}
}
}
catch
(
Ice
.
LocalException
e
)
{
}
catch
(
Ice
.
LocalException
e
)
{
...
@@ -124,7 +138,7 @@ public class IceHDaoGpsClient {
...
@@ -124,7 +138,7 @@ public class IceHDaoGpsClient {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"===getDevicesGpsInfo_EXCEP:"
+
e
.
getMessage
(),
e
);
log
.
error
(
"===getDevicesGpsInfo_EXCEP:"
+
e
.
getMessage
(),
e
);
}
}
return
bsRecord
;
return
gps
bsRecord
;
}
}
/**
/**
...
@@ -212,11 +226,11 @@ public class IceHDaoGpsClient {
...
@@ -212,11 +226,11 @@ public class IceHDaoGpsClient {
GpsGetResponseHolder
res
=
new
GpsGetResponseHolder
(
new
GpsGetResponse
());
GpsGetResponseHolder
res
=
new
GpsGetResponseHolder
(
new
GpsGetResponse
());
GpsGetRequest
req
=
new
GpsGetRequest
();
GpsGetRequest
req
=
new
GpsGetRequest
();
req
.
apType
=
apType
;
req
.
apType
=
apType
;
req
.
reqCount
=
1
;
req
.
reqCount
=
0
;
req
.
userID
=
sn
;
req
.
userID
=
sn
;
req
.
extraMapReq
=
mapType
;
req
.
extraMapReq
=
mapType
;
prx
.
getFirstGpsRecord
(
req
,
res
);
prx
.
getFirstGpsRecord
(
req
,
res
);
log
.
info
(
"getFirstGpsRecord====="
+
res
.
value
.
oprResult
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
GpsRecord
[]
r
=
res
.
value
.
records
;
GpsRecord
[]
r
=
res
.
value
.
records
;
int
len
=
r
.
length
;
int
len
=
r
.
length
;
...
@@ -307,16 +321,20 @@ public class IceHDaoGpsClient {
...
@@ -307,16 +321,20 @@ public class IceHDaoGpsClient {
req
.
type
=
ConvType
.
valueOf
(
maptype
);
req
.
type
=
ConvType
.
valueOf
(
maptype
);
prx
.
convGeoGps
(
req
,
res
);
prx
.
convGeoGps
(
req
,
res
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
)
{
log
.
info
(
"convGeoGps====="
+
res
.
value
.
oprResult
);
if
(
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
){
map
=
new
HashMap
<>();
ConvResponse
r
=
res
.
value
.
gps
;
ConvResponse
r
=
res
.
value
.
gps
;
map
.
put
(
"lng"
,
r
.
lng
/
1000000
D
);
map
.
put
(
"lng"
,(
r
.
lng
/
1000000
D
)
);
map
.
put
(
"lat"
,
r
.
lat
/
1000000
D
);
map
.
put
(
"lat"
,(
r
.
lat
/
1000000
D
)
);
return
map
;
return
map
;
}
}
}
}
catch
(
Ice
.
LocalException
e
)
{
}
catch
(
Ice
.
LocalException
e
)
{
log
.
error
(
"===
getRecentBsRecord
s_ICE_EXCEP:"
+
e
.
getMessage
(),
e
);
log
.
error
(
"===
convGeoGp
s_ICE_EXCEP:"
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"===
getRecentBsRecord
s_EXCEP:"
+
e
.
getMessage
(),
e
);
log
.
error
(
"===
convGeoGp
s_EXCEP:"
+
e
.
getMessage
(),
e
);
}
}
return
null
;
return
null
;
}
}
...
...
src/main/java/com/glsx/ice/iceClient/IcePoiSearchFTRClient.java
View file @
882b885
...
@@ -8,12 +8,13 @@ import com.glsx.ice.POI.geocoding_resultHolder;
...
@@ -8,12 +8,13 @@ import com.glsx.ice.POI.geocoding_resultHolder;
import
com.glsx.utils.SystemProperty
;
import
com.glsx.utils.SystemProperty
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
@Slf4j
@Slf4j
public
class
IcePoiSearchFTRClient
{
public
class
IcePoiSearchFTRClient
{
// ice接口服务器地址
// ice接口服务器地址
private
static
String
ICE_URL
=
SystemProperty
.
getProperty
(
"ice.poi
search
Url"
);
private
static
String
ICE_URL
=
SystemProperty
.
getProperty
(
"ice.poi
SearchFTR
Url"
);
static
Communicator
ic
=
Ice
.
Util
.
initialize
();
static
Communicator
ic
=
Ice
.
Util
.
initialize
();
static
Ice
.
ObjectPrx
base
=
ic
.
stringToProxy
(
ICE_URL
).
ice_timeout
(
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
"ice.connectTimeout"
)));
static
Ice
.
ObjectPrx
base
=
ic
.
stringToProxy
(
ICE_URL
).
ice_timeout
(
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
"ice.connectTimeout"
)));
static
IPOISearchFTRPrx
ipoiSearchFTRPrx
=
IPOISearchFTRPrxHelper
.
checkedCast
(
base
);
static
IPOISearchFTRPrx
ipoiSearchFTRPrx
=
IPOISearchFTRPrxHelper
.
checkedCast
(
base
);
...
@@ -23,7 +24,7 @@ public class IcePoiSearchFTRClient {
...
@@ -23,7 +24,7 @@ public class IcePoiSearchFTRClient {
*
*
* @return
* @return
*/
*/
public
static
Map
<
String
,
Object
>
Geocoding
(
String
address
)
{
public
static
Map
<
String
,
Object
>
Geocoding
(
String
address
)
{
//请求和响应对象
//请求和响应对象
geocoding_resultHolder
res
=
new
geocoding_resultHolder
();
geocoding_resultHolder
res
=
new
geocoding_resultHolder
();
try
{
try
{
...
@@ -31,11 +32,12 @@ public class IcePoiSearchFTRClient {
...
@@ -31,11 +32,12 @@ public class IcePoiSearchFTRClient {
log
.
error
(
"mapGeoConvert ice添加服务异常 servicePre is null"
);
log
.
error
(
"mapGeoConvert ice添加服务异常 servicePre is null"
);
return
null
;
return
null
;
}
}
ipoiSearchFTRPrx
.
Geocoding
(
address
,
res
);
ipoiSearchFTRPrx
.
Geocoding
(
address
,
res
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
)
{
geocoding_result
val
=
res
.
value
;
geocoding_result
val
=
res
.
value
;
map
=
new
HashMap
<>();
//POI层级 0~7
//POI层级 0~7
map
.
put
(
"level"
,
val
.
level
);
map
.
put
(
"level"
,
val
.
level
);
//可信度,分度越高越可信
//可信度,分度越高越可信
...
...
src/main/java/com/glsx/ice/iceClient/IceRtMileStatClient.java
View file @
882b885
...
@@ -29,7 +29,7 @@ public class IceRtMileStatClient {
...
@@ -29,7 +29,7 @@ public class IceRtMileStatClient {
*
*
* @return
* @return
*/
*/
public
static
Map
<
String
,
Object
>
getJourneyByGpsRecords
(
long
sn
,
int
dType
,
int
beginTime
,
int
endTime
)
{
public
static
Map
<
String
,
Object
>
getJourneyByGpsRecords
(
long
sn
,
int
dType
,
long
beginTime
,
long
endTime
)
{
try
{
try
{
if
(
mileagePrx
==
null
)
{
if
(
mileagePrx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
throw
new
Exception
(
"Invalid proxy"
);
...
@@ -40,16 +40,18 @@ public class IceRtMileStatClient {
...
@@ -40,16 +40,18 @@ public class IceRtMileStatClient {
req
.
userID
=
sn
;
req
.
userID
=
sn
;
req
.
apType
=
dType
;
req
.
apType
=
dType
;
//开始时间
//开始时间
req
.
beginTime
=
beginTime
;
req
.
beginTime
=
parseTimeMillis
(
beginTime
)
;
//结束时间
//结束时间
req
.
endTime
=
endTime
;
req
.
endTime
=
parseTimeMillis
(
endTime
)
;
//返回最后GPS记录时间
//返回最后GPS记录时间
req
.
bRetGpsTime
=
true
;
req
.
bRetGpsTime
=
true
;
mileagePrx
.
endUserMileStat
(
req
,
res
);
mileagePrx
.
endUserMileStat
(
req
,
res
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
log
.
info
(
"getJourneyByGpsRecords====="
+
res
.
value
.
oprResult
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
MileStatEndResponse
val
=
res
.
value
;
MileStatEndResponse
val
=
res
.
value
;
map
=
new
HashMap
<>();
//设备号
//设备号
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
//行驶里程:单位(米)
//行驶里程:单位(米)
...
@@ -95,7 +97,7 @@ public class IceRtMileStatClient {
...
@@ -95,7 +97,7 @@ public class IceRtMileStatClient {
//开始日期
//开始日期
//req.bgnDate = bgnDate;
//req.bgnDate = bgnDate;
//结束日期
//结束日期
//
req.endDate = endDate;
//
req.endDate = endDate;
//0:原始坐标 1:转换高德和百度坐标 2:转换高德坐标 3:转换百度坐标
//0:原始坐标 1:转换高德和百度坐标 2:转换高德坐标 3:转换百度坐标
req
.
extraMapReq
=
MapTypeEnum
.
DOUBLE_TYPE
.
getId
();
req
.
extraMapReq
=
MapTypeEnum
.
DOUBLE_TYPE
.
getId
();
...
@@ -109,9 +111,11 @@ public class IceRtMileStatClient {
...
@@ -109,9 +111,11 @@ public class IceRtMileStatClient {
req
.
endDate
=
eDate
;
req
.
endDate
=
eDate
;
mileagePrx
.
getJourneyRecords
(
req
,
res
);
mileagePrx
.
getJourneyRecords
(
req
,
res
);
log
.
info
(
"getJourneyRecords====="
+
res
.
value
.
oprResult
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
JourneyRecord
[]
vals
=
res
.
value
.
jourRecords
;
JourneyRecord
[]
vals
=
res
.
value
.
jourRecords
;
map
=
new
HashMap
<>();
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
List
<
Map
<
String
,
Object
>>
journeyrecords
=
Arrays
.
stream
(
vals
).
map
(
jrecord
->
{
List
<
Map
<
String
,
Object
>>
journeyrecords
=
Arrays
.
stream
(
vals
).
map
(
jrecord
->
{
...
@@ -167,9 +171,12 @@ public class IceRtMileStatClient {
...
@@ -167,9 +171,12 @@ public class IceRtMileStatClient {
req
.
endDate
=
eDate
;
req
.
endDate
=
eDate
;
mileagePrx
.
getDailyMileageRecords
(
req
,
res
);
mileagePrx
.
getDailyMileageRecords
(
req
,
res
);
log
.
info
(
"getDailyMileageRecords====="
+
res
.
value
.
oprResult
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
DailyMileRecord
[]
vals
=
res
.
value
.
dailMileRecords
;
DailyMileRecord
[]
vals
=
res
.
value
.
dailMileRecords
;
map
=
new
HashMap
<>();
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
List
<
Map
<
String
,
Object
>>
dailyrecords
=
Arrays
.
stream
(
vals
).
map
(
drecord
->
{
List
<
Map
<
String
,
Object
>>
dailyrecords
=
Arrays
.
stream
(
vals
).
map
(
drecord
->
{
...
@@ -209,9 +216,13 @@ public class IceRtMileStatClient {
...
@@ -209,9 +216,13 @@ public class IceRtMileStatClient {
//默认0,非0:获取日里程记录
//默认0,非0:获取日里程记录
//req.bReqDailyRecord
//req.bReqDailyRecord
mileagePrx
.
getToatlMileage
(
req
,
res
);
mileagePrx
.
getToatlMileage
(
req
,
res
);
log
.
info
(
"getTotalMileageRecords=====code:"
+
res
.
value
.
oprResult
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
DailyMileRecord
[]
vals
=
res
.
value
.
dailMileRecords
;
DailyMileRecord
[]
vals
=
res
.
value
.
dailMileRecords
;
log
.
info
(
"getTotalMileageRecords=====list:"
+
vals
.
length
);
map
=
new
HashMap
<>();
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
List
<
Map
<
String
,
Object
>>
dailyrecords
=
Arrays
.
stream
(
vals
).
map
(
drecord
->
{
List
<
Map
<
String
,
Object
>>
dailyrecords
=
Arrays
.
stream
(
vals
).
map
(
drecord
->
{
...
@@ -263,9 +274,13 @@ public class IceRtMileStatClient {
...
@@ -263,9 +274,13 @@ public class IceRtMileStatClient {
req
.
endMonth
=
em
;
req
.
endMonth
=
em
;
mileagePrx
.
getMonthResideRecords
(
req
,
res
);
mileagePrx
.
getMonthResideRecords
(
req
,
res
);
log
.
info
(
"getMonthResideRecords=====code:"
+
res
.
value
.
oprResult
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
MonthResideRecord
[]
vals
=
res
.
value
.
monResideRecords
;
MonthResideRecord
[]
vals
=
res
.
value
.
monResideRecords
;
log
.
info
(
"getMonthResideRecords=====list:"
+
vals
.
length
);
map
=
new
HashMap
<>();
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
List
<
Map
<
String
,
Object
>>
monthRecords
=
Arrays
.
stream
(
vals
).
map
(
mrecord
->
{
List
<
Map
<
String
,
Object
>>
monthRecords
=
Arrays
.
stream
(
vals
).
map
(
mrecord
->
{
...
@@ -321,7 +336,7 @@ public class IceRtMileStatClient {
...
@@ -321,7 +336,7 @@ public class IceRtMileStatClient {
req
.
minDuration
=
min_duration
;
req
.
minDuration
=
min_duration
;
req
.
extraMapReq
=
MapTypeEnum
.
DOUBLE_TYPE
.
getId
();
req
.
extraMapReq
=
MapTypeEnum
.
DOUBLE_TYPE
.
getId
();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM"
);
//注意月份是MM
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM
-dd
"
);
//注意月份是MM
Calendar
calendar
=
Calendar
.
getInstance
();
Calendar
calendar
=
Calendar
.
getInstance
();
calendar
.
setTime
(
simpleDateFormat
.
parse
(
start_date
));
//放入Date类型数据
calendar
.
setTime
(
simpleDateFormat
.
parse
(
start_date
));
//放入Date类型数据
...
@@ -333,9 +348,13 @@ public class IceRtMileStatClient {
...
@@ -333,9 +348,13 @@ public class IceRtMileStatClient {
req
.
endDate
=
em
;
req
.
endDate
=
em
;
mileagePrx
.
getStayPointRecords
(
req
,
res
);
mileagePrx
.
getStayPointRecords
(
req
,
res
);
log
.
info
(
"getStayPointRecords=====code:"
+
res
.
value
.
oprResult
);
Map
<
String
,
Object
>
map
=
null
;
Map
<
String
,
Object
>
map
=
null
;
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
StayPointRecord
[]
vals
=
res
.
value
.
stayPoints
;
StayPointRecord
[]
vals
=
res
.
value
.
stayPoints
;
log
.
info
(
"getStayPointRecords=====list:"
+
vals
.
length
);
map
=
new
HashMap
<>();
map
.
put
(
"sn"
,
sn
);
map
.
put
(
"sn"
,
sn
);
List
<
Map
<
String
,
Object
>>
stayRecords
=
Arrays
.
stream
(
vals
).
map
(
srecord
->
{
List
<
Map
<
String
,
Object
>>
stayRecords
=
Arrays
.
stream
(
vals
).
map
(
srecord
->
{
...
@@ -390,4 +409,10 @@ public class IceRtMileStatClient {
...
@@ -390,4 +409,10 @@ public class IceRtMileStatClient {
map
.
put
(
"addr"
,
beginPos
.
addr
);
map
.
put
(
"addr"
,
beginPos
.
addr
);
return
map
;
return
map
;
}
}
public
static
Integer
parseTimeMillis
(
long
time
)
throws
Exception
{
String
s
=
String
.
valueOf
(
time
);
return
Integer
.
parseInt
(
s
.
substring
(
0
,
s
.
length
()-
3
));
}
}
}
src/main/java/com/glsx/intercepter/AuthIntercepter.java
View file @
882b885
...
@@ -3,6 +3,7 @@ package com.glsx.intercepter;
...
@@ -3,6 +3,7 @@ package com.glsx.intercepter;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.exception.ApiErrorMessage
;
import
com.glsx.exception.ApiErrorMessage
;
import
com.glsx.utils.JwtUtil
;
import
com.glsx.utils.JwtUtil
;
import
io.jsonwebtoken.Claims
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -62,9 +63,12 @@ public class AuthIntercepter implements HandlerInterceptor {
...
@@ -62,9 +63,12 @@ public class AuthIntercepter implements HandlerInterceptor {
throw
ApiErrorMessage
.
TOKEN_TIME_OUT
.
exception
();
throw
ApiErrorMessage
.
TOKEN_TIME_OUT
.
exception
();
}
}
Claims
claims
=
jwtUtil
.
getClaimsFromToken
(
jwtToken
);
//todo 缓存接口的启用状态,key为appid+接口名,val为是否启用
//提示过期时间
//提示过期时间
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
OpenAPIConstant
.
TIME_FROMAT_NORMAL
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
OpenAPIConstant
.
TIME_FROMAT_NORMAL
);
String
expirTime
=
sdf
.
format
(
jwtUtil
.
getExpiredDateFromToken
(
jwtToken
));
String
expirTime
=
sdf
.
format
(
claims
.
getExpiration
(
));
log
.
info
(
"token过期时间:"
+
expirTime
);
log
.
info
(
"token过期时间:"
+
expirTime
);
//验证成功,放行
//验证成功,放行
...
...
src/main/java/com/glsx/model/BO/DeviceStatusBo.java
View file @
882b885
package
com
.
glsx
.
model
.
BO
;
package
com
.
glsx
.
model
.
BO
;
import
com.glsx.model.Basemodel
;
import
com.glsx.model.Basemodel
;
import
com.glsx.service.CommonParam
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.ToString
;
...
@@ -10,7 +11,7 @@ import javax.validation.constraints.NotNull;
...
@@ -10,7 +11,7 @@ import javax.validation.constraints.NotNull;
@Data
@Data
@ToString
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
public
class
DeviceStatusBo
extends
Basemodel
{
public
class
DeviceStatusBo
extends
Basemodel
implements
CommonParam
{
//设备号
//设备号
@NotBlank
(
message
=
"设备号sn不能为空"
)
@NotBlank
(
message
=
"设备号sn不能为空"
)
private
String
sn
;
private
String
sn
;
...
@@ -18,6 +19,16 @@ public class DeviceStatusBo extends Basemodel {
...
@@ -18,6 +19,16 @@ public class DeviceStatusBo extends Basemodel {
@NotNull
(
message
=
"设备类型不能为空"
)
@NotNull
(
message
=
"设备类型不能为空"
)
private
Integer
device_type
;
private
Integer
device_type
;
@Override
public
String
getLongSn
()
{
return
this
.
sn
;
}
@Override
public
Integer
getIntDeviceType
()
{
return
this
.
device_type
;
}
//# STR_DEV_TYPE_CHEYOU_CHEJI "01" 车机
//# STR_DEV_TYPE_CHEYOU_CHEJI "01" 车机
//# STR_DEV_TYPE_GLSX_OBD "02" OBD
//# STR_DEV_TYPE_GLSX_OBD "02" OBD
//# STR_DEV_TYPE_GBOX "03"
//# STR_DEV_TYPE_GBOX "03"
...
...
src/main/java/com/glsx/model/BO/GpsBsRecordsBo.java
View file @
882b885
package
com
.
glsx
.
model
.
BO
;
package
com
.
glsx
.
model
.
BO
;
import
com.glsx.model.BaseTimeRangeModel
;
import
com.glsx.model.BaseTimeRangeModel
;
import
com.glsx.service.CommonParam
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.ToString
;
import
lombok.ToString
;
...
@@ -9,11 +10,21 @@ import javax.validation.constraints.NotNull;
...
@@ -9,11 +10,21 @@ import javax.validation.constraints.NotNull;
@Data
@Data
@ToString
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
public
class
GpsBsRecordsBo
extends
BaseTimeRangeModel
{
public
class
GpsBsRecordsBo
extends
BaseTimeRangeModel
implements
CommonParam
{
//设备号
//设备号
@NotBlank
(
message
=
"设备号sn不能为空"
)
@NotBlank
(
message
=
"设备号sn不能为空"
)
private
String
sn
;
private
String
sn
;
//设备类型
//设备类型
@NotNull
(
message
=
"设备类型不能为空"
)
@NotNull
(
message
=
"设备类型不能为空"
)
private
Integer
device_type
;
private
Integer
device_type
;
@Override
public
String
getLongSn
()
{
return
this
.
sn
;
}
@Override
public
Integer
getIntDeviceType
()
{
return
this
.
device_type
;
}
}
}
src/main/java/com/glsx/model/BO/subscribeMessageBo.java
View file @
882b885
...
@@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
...
@@ -10,7 +10,7 @@ import javax.validation.constraints.NotNull;
@Data
@Data
@ToString
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
public
class
subscribeMessageBo
extends
Basemodel
{
public
class
subscribeMessageBo
extends
Basemodel
{
//消息类型ID
//消息类型ID
@NotNull
(
message
=
"消息类型ID不能为空"
)
@NotNull
(
message
=
"消息类型ID不能为空"
)
private
Integer
msgid
;
private
Integer
msgid
;
...
...
src/main/java/com/glsx/service/CommonParam.java
0 → 100644
View file @
882b885
package
com
.
glsx
.
service
;
public
interface
CommonParam
{
String
getLongSn
();
Integer
getIntDeviceType
();
}
src/main/java/com/glsx/service/IOpenApiHTTPService.java
0 → 100644
View file @
882b885
package
com
.
glsx
.
service
;
import
com.glsx.model.BO.CommandsBo
;
import
com.glsx.model.BO.DeviceDateBo
;
import
com.glsx.model.BO.DeviceSdeviceDateBo
;
import
com.glsx.model.BO.DeviceStatusBo
;
import
java.util.Map
;
public
interface
IOpenApiHTTPService
{
void
postCommands
(
CommandsBo
commandsBo
);
Map
<
String
,
Integer
>
getDeviceStatus
(
DeviceStatusBo
deviceStatusBo
);
String
getFenceTriggerRecords
(
DeviceDateBo
deviceDateBo
);
String
getRescueEventRecords
(
DeviceSdeviceDateBo
deviceDateBo
);
}
src/main/java/com/glsx/service/IOpenApiICEService.java
View file @
882b885
...
@@ -8,10 +8,6 @@ import java.util.Map;
...
@@ -8,10 +8,6 @@ import java.util.Map;
public
interface
IOpenApiICEService
{
public
interface
IOpenApiICEService
{
void
postCommands
(
CommandsBo
commandsBo
);
Map
<
String
,
Integer
>
getDeviceStatus
(
DeviceStatusBo
deviceStatusBo
);
LatestGpsRecordDto
getLatestGPSRecord
(
DeviceStatusBo
deviceStatusBo
);
LatestGpsRecordDto
getLatestGPSRecord
(
DeviceStatusBo
deviceStatusBo
);
LatestBsRecordDto
getLatestBsRecord
(
DeviceStatusBo
deviceStatusBo
);
LatestBsRecordDto
getLatestBsRecord
(
DeviceStatusBo
deviceStatusBo
);
...
@@ -49,8 +45,4 @@ public interface IOpenApiICEService {
...
@@ -49,8 +45,4 @@ public interface IOpenApiICEService {
Map
<
String
,
Object
>
getMonthResideRecords
(
DeviceMonthBo
deviceStatusBo
);
Map
<
String
,
Object
>
getMonthResideRecords
(
DeviceMonthBo
deviceStatusBo
);
Map
<
String
,
Object
>
getDeviceStayRecords
(
DeviceStayBo
deviceStayBo
);
Map
<
String
,
Object
>
getDeviceStayRecords
(
DeviceStayBo
deviceStayBo
);
String
getFenceTriggerRecords
(
DeviceDateBo
deviceDateBo
);
String
getRescueEventRecords
(
DeviceSdeviceDateBo
deviceDateBo
);
}
}
src/main/java/com/glsx/service/IOpenApiService.java
View file @
882b885
package
com
.
glsx
.
service
;
package
com
.
glsx
.
service
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BO.DataViewBo
;
import
com.glsx.model.BO.DeviceListBo
;
import
com.glsx.model.BO.TokenBo
;
import
com.glsx.model.BO.subscribeMessageBo
;
import
java.util.Map
;
import
java.util.Map
;
...
...
src/main/java/com/glsx/service/component/OpenApiInvoker.java
View file @
882b885
...
@@ -2,7 +2,9 @@ package com.glsx.service.component;
...
@@ -2,7 +2,9 @@ package com.glsx.service.component;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpResponse
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.exception.ApiException
;
import
com.glsx.utils.SystemProperty
;
import
com.glsx.utils.SystemProperty
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
...
@@ -13,7 +15,7 @@ import java.util.Map;
...
@@ -13,7 +15,7 @@ import java.util.Map;
* @author fengzhi
* @author fengzhi
* @version 1.0.0
* @version 1.0.0
* @ClassName OpenApiInvoker.java
* @ClassName OpenApiInvoker.java
* @description: http协议
调用围栏触发和碰撞预警
* @description: http协议
接口
* @createTime 2020年10月21日 14:26:00
* @createTime 2020年10月21日 14:26:00
*/
*/
@Slf4j
@Slf4j
...
@@ -22,28 +24,63 @@ public class OpenApiInvoker {
...
@@ -22,28 +24,63 @@ public class OpenApiInvoker {
/**
/**
*
*
*/
*/
p
ublic
String
invokerSync
(
String
methodName
,
Map
<
String
,
Object
>
params
)
{
p
rivate
String
invokeGet
(
String
url
,
Map
<
String
,
Object
>
params
)
{
if
(
params
==
null
)
{
if
(
params
==
null
)
{
log
.
info
(
"openapi data is NULL
"
);
log
.
info
(
"openapi data is NULL
:"
+
url
);
return
null
;
return
null
;
}
}
String
res
=
null
;
String
res
=
null
;
try
{
try
{
String
serverUrl
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_OPENAPI_SERVER
);
Integer
timeOut
=
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_TIME_OUT
));
Integer
timeOut
=
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_TIME_OUT
));
String
url
=
serverUrl
+
methodName
;
log
.
info
(
"invoker openapiGet serverUrl:"
+
url
);
log
.
info
(
"invoker openapi serverUrl:"
+
url
);
HttpResponse
httpResponse
=
HttpRequest
.
get
(
url
).
form
(
params
).
timeout
(
timeOut
*
1000
).
execute
();
HttpResponse
httpResponse
=
HttpRequest
.
get
(
url
).
form
(
params
).
timeout
(
timeOut
*
1000
).
execute
();
log
.
info
(
"httpResponse:"
+
httpResponse
.
getStatus
());
log
.
info
(
"httpResponse:"
+
httpResponse
.
getStatus
());
if
(
httpResponse
.
getStatus
()
==
200
)
if
(
httpResponse
.
getStatus
()
==
200
)
res
=
httpResponse
.
body
();
res
=
httpResponse
.
body
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"invoker openapi
error:"
+
e
.
getMessage
());
log
.
error
(
"invoker openapi
Get error:"
+
url
+
"==="
+
e
.
getMessage
());
e
.
printStackTrace
(
);
throw
new
ApiException
(
e
.
getMessage
()
);
}
}
log
.
info
(
"invoker openapi api res:"
+
res
);
log
.
info
(
"invoker openapi
Get
api res:"
+
res
);
return
res
;
return
res
;
}
}
private
String
invokePost
(
String
url
,
Map
<
String
,
Object
>
params
)
{
if
(
params
==
null
)
{
log
.
info
(
"openapi data is NULL:"
+
url
);
return
null
;
}
String
res
=
null
;
try
{
Integer
timeOut
=
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_TIME_OUT
));
log
.
info
(
"invoker openapiPost serverUrl:"
+
url
);
HttpResponse
httpResponse
=
HttpRequest
.
post
(
url
).
body
(
JSONObject
.
toJSONString
(
params
)).
timeout
(
timeOut
*
1000
).
execute
();
log
.
info
(
"httpResponse:"
+
httpResponse
.
getStatus
());
if
(
httpResponse
.
getStatus
()
==
200
)
res
=
httpResponse
.
body
();
}
catch
(
Exception
e
)
{
log
.
error
(
"invoker openapiPost error:"
+
url
+
"==="
+
e
.
getMessage
());
throw
new
ApiException
(
e
.
getMessage
());
}
log
.
info
(
"invoker openapiPost api res:"
+
url
+
"==="
+
res
);
return
res
;
}
public
String
invokeFenceOrRescue
(
String
methodName
,
Map
<
String
,
Object
>
params
)
{
String
serverUrl
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_OPENAPI_SERVER_1
);
String
url
=
serverUrl
+
methodName
;
return
invokeGet
(
url
,
params
);
}
public
String
invokCommandOrDeviceStatus
(
String
methodName
,
Map
<
String
,
Object
>
params
)
{
String
serverUrl
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
HTTP_OPENAPI_SERVER_2
);
String
url
=
serverUrl
+
methodName
;
return
invokePost
(
url
,
params
);
}
}
}
src/main/java/com/glsx/service/impl/OpenApiHTTPServiceImpl.java
0 → 100644
View file @
882b885
package
com
.
glsx
.
service
.
impl
;
import
com.glsx.base.aop.SysLog
;
import
com.glsx.base.controller.BaseService
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.exception.ApiException
;
import
com.glsx.model.BO.CommandsBo
;
import
com.glsx.model.BO.DeviceDateBo
;
import
com.glsx.model.BO.DeviceSdeviceDateBo
;
import
com.glsx.model.BO.DeviceStatusBo
;
import
com.glsx.service.IOpenApiHTTPService
;
import
com.glsx.service.component.OpenApiInvoker
;
import
com.glsx.utils.SystemProperty
;
import
net.sf.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author fengzhi
* @version V1.0
* @Description: http协议接口实现类
*/
@Service
public
class
OpenApiHTTPServiceImpl
extends
BaseService
implements
IOpenApiHTTPService
{
@Autowired
OpenApiInvoker
apiInvoker
;
@SysLog
@Override
public
void
postCommands
(
CommandsBo
commandsBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_POST_COMMANDS
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
commandsBo
.
getSn
());
params
.
put
(
"device_type"
,
commandsBo
.
getDevice_type
());
params
.
put
(
"commandid"
,
commandsBo
.
getCommandid
());
params
.
put
(
"command"
,
commandsBo
.
getCommand
());
String
jsonRes
=
apiInvoker
.
invokCommandOrDeviceStatus
(
methodName
,
params
);
JSONObject
jsonObj
=
JSONObject
.
fromObject
(
jsonRes
);
boolean
isSuccess
=
jsonObj
.
getBoolean
(
"success"
);
if
(!
isSuccess
){
String
msg
=
jsonObj
.
getString
(
"msg"
);
logi
(
"postCommands=====Failed====msg:"
+
msg
);
throw
new
ApiException
(
msg
);
}
}
@SysLog
@Override
public
Map
<
String
,
Integer
>
getDeviceStatus
(
DeviceStatusBo
deviceStatusBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_DEVICE_STATUS
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
deviceStatusBo
.
getSn
());
params
.
put
(
"device_type"
,
deviceStatusBo
.
getDevice_type
());
String
jsonRes
=
apiInvoker
.
invokCommandOrDeviceStatus
(
methodName
,
params
);
JSONObject
jsonObj
=
JSONObject
.
fromObject
(
jsonRes
);
boolean
isSuccess
=
jsonObj
.
getBoolean
(
"success"
);
if
(!
isSuccess
){
String
msg
=
jsonObj
.
getString
(
"msg"
);
logi
(
"getDeviceStatus=====Failed====msg:"
+
msg
);
throw
new
ApiException
(
msg
);
}
JSONObject
result
=
jsonObj
.
getJSONObject
(
"result"
);
Integer
status
=
result
.
getInt
(
"status"
);
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
map
.
put
(
"status"
,
status
);
return
map
;
}
@Override
public
String
getFenceTriggerRecords
(
DeviceDateBo
deviceDateBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_FENCE_RECORD
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
deviceDateBo
.
getSn
());
params
.
put
(
"device_type"
,
deviceDateBo
.
getDevice_type
());
params
.
put
(
"start_date"
,
deviceDateBo
.
getStart_date
());
params
.
put
(
"end_date"
,
deviceDateBo
.
getEnd_date
());
return
apiInvoker
.
invokeFenceOrRescue
(
methodName
,
params
);
}
@Override
public
String
getRescueEventRecords
(
DeviceSdeviceDateBo
deviceDateBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_RESCUE_RECORD
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
deviceDateBo
.
getSn
());
//这里的type为string(SOS:紧急救援,COLLIDE:碰撞,CUSTOMER_SUBMIT 客服提交)
params
.
put
(
"device_type"
,
deviceDateBo
.
getDevice_type
());
params
.
put
(
"start_date"
,
deviceDateBo
.
getStart_date
());
params
.
put
(
"end_date"
,
deviceDateBo
.
getEnd_date
());
return
apiInvoker
.
invokeFenceOrRescue
(
methodName
,
params
);
}
}
src/main/java/com/glsx/service/impl/OpenApiICEServiceImpl.java
View file @
882b885
...
@@ -3,17 +3,13 @@ package com.glsx.service.impl;
...
@@ -3,17 +3,13 @@ package com.glsx.service.impl;
import
com.glsx.base.aop.SysLog
;
import
com.glsx.base.aop.SysLog
;
import
com.glsx.base.controller.BaseService
;
import
com.glsx.base.controller.BaseService
;
import
com.glsx.base.enums.MapTypeEnum
;
import
com.glsx.base.enums.MapTypeEnum
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.ice.iceClient.*
;
import
com.glsx.ice.iceClient.*
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.DTO.*
;
import
com.glsx.model.DTO.*
;
import
com.glsx.service.IOpenApiICEService
;
import
com.glsx.service.IOpenApiICEService
;
import
com.glsx.service.component.OpenApiInvoker
;
import
com.glsx.utils.SystemProperty
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -21,29 +17,10 @@ import java.util.Map;
...
@@ -21,29 +17,10 @@ import java.util.Map;
/**
/**
* @author fengzhi
* @author fengzhi
* @version V1.0
* @version V1.0
* @Description:
开放平台
接口实现类
* @Description:
ICE
接口实现类
*/
*/
@Service
@Service
public
class
OpenApiICEServiceImpl
extends
BaseService
implements
IOpenApiICEService
{
public
class
OpenApiICEServiceImpl
extends
BaseService
implements
IOpenApiICEService
{
@Autowired
OpenApiInvoker
apiInvoker
;
//todo 接口还没给
@SysLog
@Override
public
void
postCommands
(
CommandsBo
commandsBo
)
{
}
//todo 接口还没给
@SysLog
@Override
public
Map
<
String
,
Integer
>
getDeviceStatus
(
DeviceStatusBo
deviceStatusBo
)
{
Map
<
String
,
Integer
>
map
=
new
HashMap
<>();
map
.
put
(
"status"
,
1
);
return
map
;
}
@SysLog
@SysLog
@Override
@Override
public
LatestGpsRecordDto
getLatestGPSRecord
(
DeviceStatusBo
deviceStatusBo
)
{
public
LatestGpsRecordDto
getLatestGPSRecord
(
DeviceStatusBo
deviceStatusBo
)
{
...
@@ -65,16 +42,10 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
...
@@ -65,16 +42,10 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
@SysLog
@SysLog
@Override
@Override
public
LatestGpsBsRecordDto
getLatestGpsBsRecord
(
DeviceStatusBo
deviceStatusBo
)
{
public
LatestGpsBsRecordDto
getLatestGpsBsRecord
(
DeviceStatusBo
deviceStatusBo
)
{
//todo ice接口有问题,暂用组合代替
long
sn
=
getSn
(
deviceStatusBo
);
long
sn
=
getSn
(
deviceStatusBo
);
Integer
dType
=
getDeviceType
(
deviceStatusBo
);
Integer
dType
=
getDeviceType
(
deviceStatusBo
);
LatestGpsRecordDto
gpsRecord
=
IceHDaoGpsClient
.
getLatestGpsRecord
(
sn
,
dType
,
MapTypeEnum
.
DOUBLE_TYPE
.
getId
());
LatestGpsBsRecordDto
res
=
IceHDaoGpsClient
.
getLatestGpsBsRecord
(
sn
,
dType
,
MapTypeEnum
.
DOUBLE_TYPE
.
getId
());
LatestBsRecordDto
bsRecord
=
IceHDaoGpsClient
.
getLatestBsRecord
(
sn
,
dType
);
return
res
;
LatestGpsBsRecordDto
gpsBsRecordDto
=
new
LatestGpsBsRecordDto
();
BeanUtils
.
copyProperties
(
gpsRecord
,
gpsBsRecordDto
);
BeanUtils
.
copyProperties
(
bsRecord
,
gpsBsRecordDto
);
//LatestGpsBsRecordDto latestGpsBsRecordDto = IceHDaoGpsClient.getDevicesGpsInfo(dId, 0, 0);
return
gpsBsRecordDto
;
}
}
@SysLog
@SysLog
...
@@ -155,7 +126,7 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
...
@@ -155,7 +126,7 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
public
Map
<
String
,
Object
>
getReverseGeocoding
(
BaseMapModel
mapModel
)
{
public
Map
<
String
,
Object
>
getReverseGeocoding
(
BaseMapModel
mapModel
)
{
float
lat
=
getLat
(
mapModel
);
float
lat
=
getLat
(
mapModel
);
float
lng
=
getLng
(
mapModel
);
float
lng
=
getLng
(
mapModel
);
String
address
=
IcePoiSearchNearClient
.
getReverseGeocoding
(
l
ng
,
lat
);
String
address
=
IcePoiSearchNearClient
.
getReverseGeocoding
(
l
at
,
lng
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"address"
,
address
);
map
.
put
(
"address"
,
address
);
return
map
;
return
map
;
...
@@ -164,7 +135,7 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
...
@@ -164,7 +135,7 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
@SysLog
@SysLog
@Override
@Override
public
Map
<
String
,
Object
>
getCoordTransForMap
(
CoordTransForMapBo
coordTransForMapBo
)
{
public
Map
<
String
,
Object
>
getCoordTransForMap
(
CoordTransForMapBo
coordTransForMapBo
)
{
int
lat
=
(
int
)
getLat
(
coordTransForMapBo
);
int
lat
=
getLat
(
coordTransForMapBo
).
intValue
(
);
int
lng
=
getLng
(
coordTransForMapBo
).
intValue
();
int
lng
=
getLng
(
coordTransForMapBo
).
intValue
();
int
map_type
=
coordTransForMapBo
.
getMaptype
();
int
map_type
=
coordTransForMapBo
.
getMaptype
();
Map
<
String
,
Object
>
map
=
IceHDaoGpsClient
.
convGeoGps
(
lng
,
lat
,
map_type
);
Map
<
String
,
Object
>
map
=
IceHDaoGpsClient
.
convGeoGps
(
lng
,
lat
,
map_type
);
...
@@ -176,8 +147,9 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
...
@@ -176,8 +147,9 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
public
Map
<
String
,
Object
>
getJourneyByGpsRecords
(
GpsBsRecordsBo
gpsBsRecordsBo
)
{
public
Map
<
String
,
Object
>
getJourneyByGpsRecords
(
GpsBsRecordsBo
gpsBsRecordsBo
)
{
long
sn
=
getSn
(
gpsBsRecordsBo
);
long
sn
=
getSn
(
gpsBsRecordsBo
);
Integer
dType
=
getDeviceType
(
gpsBsRecordsBo
);
Integer
dType
=
getDeviceType
(
gpsBsRecordsBo
);
int
start_time
=
Integer
.
parseInt
(
gpsBsRecordsBo
.
getStartTime
().
getTime
()
+
""
);
long
start_time
=
gpsBsRecordsBo
.
getStartTime
().
getTime
();
int
end_time
=
Integer
.
parseInt
(
gpsBsRecordsBo
.
getEndTime
().
getTime
()
+
""
);
long
end_time
=
gpsBsRecordsBo
.
getEndTime
().
getTime
();
logi
(
"getJourneyByGpsRecords====="
+
gpsBsRecordsBo
.
getStartTime
().
getTime
()+
"==="
+
end_time
);
Map
<
String
,
Object
>
map
=
IceRtMileStatClient
.
getJourneyByGpsRecords
(
sn
,
dType
,
start_time
,
end_time
);
Map
<
String
,
Object
>
map
=
IceRtMileStatClient
.
getJourneyByGpsRecords
(
sn
,
dType
,
start_time
,
end_time
);
return
map
;
return
map
;
}
}
...
@@ -237,27 +209,4 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
...
@@ -237,27 +209,4 @@ public class OpenApiICEServiceImpl extends BaseService implements IOpenApiICESer
Map
<
String
,
Object
>
map
=
IceRtMileStatClient
.
getDeviceStayRecords
(
sn
,
dType
,
start_date
,
end_date
,
period_type
,
max_duration
,
min_duration
);
Map
<
String
,
Object
>
map
=
IceRtMileStatClient
.
getDeviceStayRecords
(
sn
,
dType
,
start_date
,
end_date
,
period_type
,
max_duration
,
min_duration
);
return
map
;
return
map
;
}
}
@Override
public
String
getFenceTriggerRecords
(
DeviceDateBo
deviceDateBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_FENCE_RECORD
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
deviceDateBo
.
getSn
());
params
.
put
(
"device_type"
,
deviceDateBo
.
getDevice_type
());
params
.
put
(
"start_date"
,
deviceDateBo
.
getStart_date
());
params
.
put
(
"end_date"
,
deviceDateBo
.
getEnd_date
());
return
apiInvoker
.
invokerSync
(
methodName
,
params
);
}
@Override
public
String
getRescueEventRecords
(
DeviceSdeviceDateBo
deviceDateBo
)
{
String
methodName
=
SystemProperty
.
getProperty
(
OpenAPIConstant
.
METHOD_RESCUE_RECORD
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"sn"
,
deviceDateBo
.
getSn
());
//这里的type为string(SOS:紧急救援,COLLIDE:碰撞,CUSTOMER_SUBMIT 客服提交)
params
.
put
(
"device_type"
,
deviceDateBo
.
getDevice_type
());
params
.
put
(
"start_date"
,
deviceDateBo
.
getStart_date
());
params
.
put
(
"end_date"
,
deviceDateBo
.
getEnd_date
());
return
apiInvoker
.
invokerSync
(
methodName
,
params
);
}
}
}
src/main/java/com/glsx/service/impl/OpenApiServiceImpl.java
View file @
882b885
...
@@ -3,12 +3,15 @@ package com.glsx.service.impl;
...
@@ -3,12 +3,15 @@ package com.glsx.service.impl;
import
cn.com.glsx.openplatform.service.OpenApiService
;
import
cn.com.glsx.openplatform.service.OpenApiService
;
import
cn.hutool.db.Page
;
import
cn.hutool.db.Page
;
import
com.glsx.base.aop.SysLog
;
import
com.glsx.base.aop.SysLog
;
import
com.glsx.base.controller.
Base
Service
;
import
com.glsx.base.controller.
Jwt
Service
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.exception.ApiErrorMessage
;
import
com.glsx.exception.ApiErrorMessage
;
import
com.glsx.model.BO.*
;
import
com.glsx.exception.ApiException
;
import
com.glsx.model.BO.DataViewBo
;
import
com.glsx.model.BO.DeviceListBo
;
import
com.glsx.model.BO.TokenBo
;
import
com.glsx.model.BO.subscribeMessageBo
;
import
com.glsx.service.IOpenApiService
;
import
com.glsx.service.IOpenApiService
;
import
com.glsx.utils.JwtUtil
;
import
com.glsx.utils.MapUtils
;
import
com.glsx.utils.MapUtils
;
import
com.glsx.utils.RSAUtils
;
import
com.glsx.utils.RSAUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -21,13 +24,13 @@ import java.util.TreeMap;
...
@@ -21,13 +24,13 @@ import java.util.TreeMap;
/**
/**
* @author fengzhi
* @author fengzhi
* @version V1.0
* @version V1.0
* @Description: 开放平台
接口
实现类
* @Description: 开放平台
业务层
实现类
*/
*/
@Service
@Service
public
class
OpenApiServiceImpl
extends
Base
Service
implements
IOpenApiService
{
public
class
OpenApiServiceImpl
extends
Jwt
Service
implements
IOpenApiService
{
@Autowired
/*
JwtUtil
jwtTokenUtil
;
* 数据层服务
*/
@Autowired
@Autowired
OpenApiService
openApiService
;
OpenApiService
openApiService
;
...
@@ -39,17 +42,14 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
...
@@ -39,17 +42,14 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
public
String
getToken
(
TokenBo
tokenBo
)
{
public
String
getToken
(
TokenBo
tokenBo
)
{
//校验必传参数
//校验必传参数
TreeMap
<
String
,
String
>
params
=
MapUtils
.
transBean2Map
(
tokenBo
);
TreeMap
<
String
,
String
>
params
=
MapUtils
.
transBean2Map
(
tokenBo
);
//logi("参数对象:" + params);
logi
(
"参数对象:"
+
params
);
// boolean miss = params.entrySet().stream().anyMatch(kv -> StringUtils.isEmpty(kv.getValue()));
//if (miss)
// throw ApiErrorMessage.ARGS_NULL.exception();
//获取私钥
//获取私钥
Integer
appId
=
tokenBo
.
getAppId
();
Integer
appId
=
tokenBo
.
getAppId
();
//todo 测试参数修改
//todo 测试参数
,如果需要测试可以
修改
//
String privateKey = openApiService.getPrivateSecret(appId);
String
privateKey
=
openApiService
.
getPrivateSecret
(
appId
);
String
privateKey
=
OpenAPIConstant
.
TEST_PRIVATE_KEY
;
//
String privateKey = OpenAPIConstant.TEST_PRIVATE_KEY;
logi
(
"getToken私钥======"
+
privateKey
);
//获取公钥加密的密文
//获取公钥加密的密文
String
sign
=
tokenBo
.
getSign
();
String
sign
=
tokenBo
.
getSign
();
...
@@ -60,7 +60,7 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
...
@@ -60,7 +60,7 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
ApiErrorMessage
.
ARGS_ERROR
.
exception
(
"RSA解密错误==签名或私钥错误"
+
sign
);
throw
ApiErrorMessage
.
ARGS_ERROR
.
exception
(
"RSA解密错误==签名或私钥错误"
+
sign
);
}
}
logi
(
"获取明文:"
+
originalStr
);
//除了sign以外,按照参数字母升序(参数+参数值)拼接
//除了sign以外,按照参数字母升序(参数+参数值)拼接
StringBuffer
paramsStrbuf
=
new
StringBuffer
();
StringBuffer
paramsStrbuf
=
new
StringBuffer
();
params
.
remove
(
OpenAPIConstant
.
PARAM_SIGN
);
params
.
remove
(
OpenAPIConstant
.
PARAM_SIGN
);
...
@@ -77,7 +77,7 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
...
@@ -77,7 +77,7 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
//根据appid查询用户信息,将客户信息转化为jwt
//根据appid查询用户信息,将客户信息转化为jwt
Map
<
String
,
Object
>
infos
=
openApiService
.
getCustomerInfo
(
appId
);
Map
<
String
,
Object
>
infos
=
openApiService
.
getCustomerInfo
(
appId
);
logi
(
"OpenApiServiceImpl===Userinfos==="
+
infos
);
logi
(
"OpenApiServiceImpl===Userinfos==="
+
infos
);
String
jwtToken
=
jwt
Token
Util
.
generateToken
(
infos
);
String
jwtToken
=
jwtUtil
.
generateToken
(
infos
);
return
jwtToken
;
return
jwtToken
;
}
}
...
@@ -98,17 +98,26 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
...
@@ -98,17 +98,26 @@ public class OpenApiServiceImpl extends BaseService implements IOpenApiService {
@SysLog
@SysLog
@Override
@Override
public
Map
<
String
,
Integer
>
getDataView
(
DataViewBo
deviceStatusBo
)
{
public
Map
<
String
,
Integer
>
getDataView
(
DataViewBo
deviceStatusBo
)
{
Integer
customerI
d
=
getCustomerID
(
deviceStatusBo
);
Integer
appi
d
=
getCustomerID
(
deviceStatusBo
);
logi
(
"OpenApiServiceImpl===getDataView==customerId:"
+
customerI
d
);
logi
(
"OpenApiServiceImpl===getDataView==customerId:"
+
appi
d
);
Map
<
String
,
Integer
>
res
=
openApiService
.
getDataView
(
customerI
d
,
deviceStatusBo
.
getDevice_type
());
Map
<
String
,
Integer
>
res
=
openApiService
.
getDataView
(
appi
d
,
deviceStatusBo
.
getDevice_type
());
return
res
;
return
res
;
}
}
//todo 接口自己实现
@SysLog
@SysLog
@Override
@Override
public
void
subscribeMessage
(
subscribeMessageBo
subscribeMessageBo
)
{
public
void
subscribeMessage
(
subscribeMessageBo
subscribeMessageBo
)
{
Integer
appid
=
getCustomerID
(
subscribeMessageBo
);
int
msgID
=
subscribeMessageBo
.
getMsgid
();
int
deviceType
=
subscribeMessageBo
.
getDevice_type
();
int
method
=
subscribeMessageBo
.
getMethod
();
String
pushUrl
=
subscribeMessageBo
.
getPushurl
();
Map
<
String
,
Object
>
res
=
openApiService
.
subscribeMessage
(
appid
,
msgID
,
deviceType
,
method
,
pushUrl
);
boolean
isSuccess
=
(
boolean
)
res
.
get
(
"success"
);
if
(!
isSuccess
){
String
msg
=
(
String
)
res
.
get
(
"msg"
);
logi
(
"subscribeMessage=====Failed====msg:"
+
msg
);
throw
new
ApiException
(
msg
);
}
}
}
}
}
src/main/java/com/glsx/utils/MapUtils.java
View file @
882b885
...
@@ -4,7 +4,10 @@ import java.beans.BeanInfo;
...
@@ -4,7 +4,10 @@ import java.beans.BeanInfo;
import
java.beans.Introspector
;
import
java.beans.Introspector
;
import
java.beans.PropertyDescriptor
;
import
java.beans.PropertyDescriptor
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -42,4 +45,13 @@ public class MapUtils {
...
@@ -42,4 +45,13 @@ public class MapUtils {
return
map
;
return
map
;
}
}
/**
* 方案一:直接转map,key直接设置,val的index由key计算
* @Title: listToMap
* @Description: 把两个List转换为Map
*/
public
static
<
K
,
V
>
Map
<
K
,
V
>
listToMap
(
List
<
K
>
keys
,
List
<
V
>
values
)
{
return
keys
.
stream
().
collect
(
Collectors
.
toMap
(
key
->
key
,
key
->
values
.
get
(
keys
.
indexOf
(
key
))));
}
}
}
src/main/java/com/glsx/utils/RSAUtils.java
View file @
882b885
...
@@ -4,13 +4,12 @@ import org.apache.commons.codec.binary.Base64;
...
@@ -4,13 +4,12 @@ import org.apache.commons.codec.binary.Base64;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.crypto.Cipher
;
import
javax.crypto.Cipher
;
import
java.security.*
;
import
java.security.KeyFactory
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.PKCS8EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.security.spec.X509EncodedKeySpec
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
...
@@ -20,26 +19,28 @@ import java.util.Map;
...
@@ -20,26 +19,28 @@ import java.util.Map;
*/
*/
@Component
@Component
public
class
RSAUtils
{
public
class
RSAUtils
{
private
static
Map
<
Integer
,
String
>
keyMap
=
new
HashMap
<
Integer
,
String
>();
//用于封装随机产生的公钥与私钥
/*
private static Map<Integer, String> keyMap = new HashMap<Integer, String>(); //用于封装随机产生的公钥与私钥
public static void main(String[] args) throws Exception {
public static void main(String[] args) throws Exception {
//生成公钥和私钥
//生成公钥和私钥
genKeyPair();
genKeyPair();
//加密字符串
//加密字符串
String
message
=
"appId1grantType1time123456"
;
String message = "appId100000grantType1time123456";
System
.
out
.
println
(
"随机生成的公钥为:"
+
keyMap
.
get
(
0
));
String pubkey = OpenAPIConstant.TEST_PUBLIC_KEY;
System
.
out
.
println
(
"随机生成的私钥为:"
+
keyMap
.
get
(
1
));
String prikey = OpenAPIConstant.TEST_PRIVATE_KEY;
System.out.println("随机生成的公钥为:" + pubkey*//*keyMap.get(0)*//*);
System.out.println("随机生成的私钥为:" + prikey*//*keyMap.get(1)*//*);
//String messageEn = encrypt(message, OpenAPIConstant.TEST_PUBLIC_KEY);
//String messageEn = encrypt(message, OpenAPIConstant.TEST_PUBLIC_KEY);
String
messageEn
=
encrypt
(
message
,
keyMap
.
get
(
0
)
);
String messageEn = encrypt(message,
pubkey*//*keyMap.get(0)*//*
);
System.out.println(message + "\t加密后的字符串为:" + messageEn);
System.out.println(message + "\t加密后的字符串为:" + messageEn);
String
messageDe
=
decrypt
(
messageEn
,
keyMap
.
get
(
1
)
);
String messageDe = decrypt(messageEn,
prikey*//*keyMap.get(1)*//*
);
System.out.println("还原后的字符串为:" + messageDe);
System.out.println("还原后的字符串为:" + messageDe);
}
}
/**
*/
/**
* 随机生成密钥对
* 随机生成密钥对
* @throws NoSuchAlgorithmException
* @throws NoSuchAlgorithmException
*/
*/
/*
public static void genKeyPair() throws NoSuchAlgorithmException {
public static void genKeyPair() throws NoSuchAlgorithmException {
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("RSA");
...
@@ -55,7 +56,7 @@ public class RSAUtils {
...
@@ -55,7 +56,7 @@ public class RSAUtils {
// 将公钥和私钥保存到Map
// 将公钥和私钥保存到Map
keyMap.put(0,publicKeyString); //0表示公钥
keyMap.put(0,publicKeyString); //0表示公钥
keyMap.put(1,privateKeyString); //1表示私钥
keyMap.put(1,privateKeyString); //1表示私钥
}
}
*/
/**
/**
* RSA公钥加密
* RSA公钥加密
...
...
src/main/resources/config/application.properties
View file @
882b885
...
@@ -4,7 +4,7 @@ server.servlet.context-path=/open-platform-api
...
@@ -4,7 +4,7 @@ server.servlet.context-path=/open-platform-api
server.servlet.application-display-
name
=
open-platform-api
server.servlet.application-display-
name
=
open-platform-api
logging.config
=
classpath:logback.xml
logging.config
=
classpath:logback.xml
#
logging.path=/data/java_log/jetty/open-platform-api/open-platform-api.log
logging.path
=
/data/java_log/jetty/open-platform-api/open-platform-api.log
logging.level.root
=
INFO
logging.level.root
=
INFO
ore.starter.class-
name
=
Main
ore.starter.class-
name
=
Main
...
...
src/main/resources/logback.xml
View file @
882b885
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<property
resource=
"config/application.properties"
/>
<property
resource=
"config/application.properties"
/>
<property
name=
"APP_NAME"
value=
"${server.display-name}"
/>
<property
name=
"APP_NAME"
value=
"${server.display-name}"
/>
<!-- <property name="LOG_PATH" value="${logging.path}" />--
>
<property
name=
"LOG_PATH"
value=
"${logging.path}"
/
>
<property
name=
"LOG_LEVEL"
value=
"${logging.level}"
/>
<property
name=
"LOG_LEVEL"
value=
"${logging.level}"
/>
<contextName>
${APP_NAME}
</contextName>
<contextName>
${APP_NAME}
</contextName>
...
...
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