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 d05e3c87
authored
Dec 21, 2020
by
fz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1.service添加公共获取客户信息的方法
2.添加ICE接口(dist)
1 parent
b405fce7
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
294 additions
and
104 deletions
pom.xml
src/main/java/com/glsx/base/controller/BaseService.java
src/main/java/com/glsx/constant/OpenAPIConstant.java
src/main/java/com/glsx/controller/OpenApiController.java
src/main/java/com/glsx/ice/iceClient/IceDistrictClient.java
src/main/java/com/glsx/ice/iceClient/IceHDaoGpsClient.java
src/main/java/com/glsx/intercepter/AuthIntercepter.java
src/main/java/com/glsx/model/BO/DistBO.java
src/main/java/com/glsx/model/BaseTimeRangeModel.java
src/main/java/com/glsx/model/DTO/DistDetilDto.java
src/main/java/com/glsx/model/DTO/DistInfoDto.java
src/main/java/com/glsx/service/OpenApiService.java
src/main/java/com/glsx/service/impl/OpenApiServiceImpl.java
src/main/java/com/glsx/utils/RSAUtils.java
pom.xml
View file @
d05e3c8
...
...
@@ -19,54 +19,55 @@
</properties>
<dependencies>
<!--<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
</dependency>-->
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
</dependency>
<!--ICE-->
<dependency>
<groupId>
Ice
</groupId>
<artifactId>
Ice
</artifactId>
<version>
${Ice.version}
</version>
</dependency>
<!--jwt-->
<dependency>
<groupId>
com.auth0
</groupId>
<artifactId>
java-jwt
</artifactId>
<version>
${jwt.version}
</version>
</dependency>
<dependency>
<groupId>
io.jsonwebtoken
</groupId>
<artifactId>
jjwt
</artifactId>
<version>
${jjwt.version}
</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
${org.projectlombok.version}
</version>
</dependency>
<!--dubbo api 服务-->
<dependency>
<groupId>
cn.com.glsx.openplatform
</groupId>
<artifactId>
rpc-openplatform-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!--swagger2-->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.9.2
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.9.2
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/java/com/glsx/base/controller/BaseService.java
View file @
d05e3c8
package
com
.
glsx
.
base
.
controller
;
import
com.glsx.config.SystemProperty
;
import
com.glsx.model.Basemodel
;
import
com.glsx.utils.JwtUtil
;
import
io.jsonwebtoken.Claims
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,19 +18,34 @@ public class BaseService {
@Autowired
private
SystemProperty
systemProperty
;
public
String
getProperty
(
String
propertyName
){
@Autowired
private
JwtUtil
jwtUtil
;
protected
String
getProperty
(
String
propertyName
){
return
systemProperty
.
getProperty
(
propertyName
);
}
p
ublic
void
logd
(
String
message
){
p
rotected
void
logd
(
String
message
){
log
.
debug
(
message
);
}
p
ublic
void
logi
(
String
message
){
p
rotected
void
logi
(
String
message
){
log
.
info
(
message
);
}
p
ublic
void
loge
(
String
message
,
Throwable
e
){
p
rotected
void
loge
(
String
message
,
Throwable
e
){
log
.
error
(
message
,
e
);
}
private
Claims
getCustomerFromToken
(
Basemodel
basemodel
){
return
jwtUtil
.
getClaimsFromToken
(
basemodel
.
getToken
());
}
public
String
getCustomerProperty
(
Basemodel
basemodel
,
String
propertyName
){
return
(
String
)
getCustomerFromToken
(
basemodel
).
get
(
propertyName
);
}
public
Integer
getCustomerID
(
Basemodel
basemodel
){
return
Integer
.
parseInt
(
getCustomerProperty
(
basemodel
,
"appid"
));
}
}
src/main/java/com/glsx/constant/OpenAPIConstant.java
View file @
d05e3c8
...
...
@@ -6,9 +6,9 @@ package com.glsx.constant;
* @version V1.0
*/
public
class
OpenAPIConstant
{
public
static
final
String
TEST_PRIVATE_KEY
=
"MII
CdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJLYAe7vz8bZX0/Ro1c7SxwoAmzbH85MfPTWIPl4QQ6QRoZTThlzsRqDggGsRXPc1PVXv02o6v+oC7xV8ewG4GKJJ6RScuVVcGPbgDMIrc6J3LLKl5ullUDA3+KiWrAOQ8mHD9KcO9tN8y8uii3aDQapKl4DtyThaKyx37oYJ1BJAgMBAAECgYBhpzLJ8kML6zzeOPzWIwFVLSpHuAVTzTwAGnJ9VMJ26+1qoPW8KVrq1e/cKvNZFM+uhPccryvwbpG3YrRqkTwgZoodnBe06WlQH2iqdXfeW5bXcVfcbFNMlztDO2JgXuhPHajvgb28+4bd2wHr0aQk6cDSxWo3jOUpY9eezGoY7QJBAOCLz7/wtVEH5CfbD7K6707l8NNgZbxGqs41WtVWCLoUAx3WOPj0GR6p8ns7Ng5zykn8nnO72qqfVP/s5Q6alGcCQQCnac1Jmbfa7P38Or7qZYfTIvVNUxPXiMpK5GieYFEF0FAnKtmVGvLUk70ghDKi4Bm+/RYTs+e7fX3qjgb7gYfPAkA1FFezw67YzMi+MyZu1YmkWO6oyOzDqODPhgVG0OOXOQvTjcRB9VHK0dmkD8cje3OiMbkzGoECPE/Xf6RV42yZAkBCl8ZuEXRd5El/jIqmyG5H4S78bCCHasU1Fzg6T4vLKTrI6bWVJxwSzRW9Gnjd6xCytQ+UFMsH/Hoa1BYY80RnAkEArY7J7I37JsL1L+tNaSsD7vdb/+9eSv81n5dzh2yhyMCKgMhvPbqFn3V5p6gaL5YnCjN4ulxqvay79cohnyn9+A=
="
;
public
static
final
String
TEST_PRIVATE_KEY
=
"MII
BVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAr4QOskcQI5/s3fbY7tYsqoz+FQFGtGH6LIpp7QcyoZ/v/8h28nZ8Jy5xA/++TRG24aG9bOSP5/soITx+7JMTlQIDAQABAkBRubfuI1DMhccRg8N3Uprxvz0AItv9WjHXU4wHJnbY8o6x8KPOMnob7gvLjZaF+R9P4s0qhOHySJgp14DErIvxAiEA1R+qzOeoo7KDIYp5JjU1w21ahGSTAv5kchokz4FlSLsCIQDS04EcLS4VASJNjHCY74+qw1o07XTY/cSpl2ue8Ow37wIhAKhOIMk+bLwRnmLfgvr8bF/PvPrunfZwRYyiPs2sJvs/AiBvVxnheo7SsvWdxOSWMDZMdb0HJLzH+EVLV1eT6iKmawIgTGwHe+QSl0N2GHQY1bNBi4ynWWLKK6GBIwwBiv5gtEQ
="
;
public
static
final
String
TEST_TOKEN
=
"yRaUk3pOtRxYLH2nNoNBXSEC4zvPicu2d6gAOh+NLXl7TIiR8kDL/aMJQcjN4LDqLAnBosahygnRro6ZCoR7KXoE0bmJ+5Ozhv3Hz+vvzUyGEjGmorIVXIlS/KkZWAwIguFYhXXSDLHwxfZZHMQxTtARAv3hpf7nM++YeGCnNUQ="
;
public
static
final
String
TEST_PUBLIC_KEY
=
"M
IGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCS2AHu78/G2V9P0aNXO0scKAJs2x/OTHz01iD5eEEOkEaGU04Zc7Eag4IBrEVz3NT1V79NqOr/qAu8VfHsBuBiiSekUnLlVXBj24AzCK3OidyyypebpZVAwN/iolqwDkPJhw/SnDvbTfMvLoot2g0GqSpeA7ck4Wissd+6GCdQSQIDAQAB
"
;
public
static
final
String
TEST_PUBLIC_KEY
=
"M
FwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK+EDrJHECOf7N322O7WLKqM/hUBRrRh+iyKae0HMqGf7//IdvJ2fCcucQP/vk0RtuGhvWzkj+f7KCE8fuyTE5UCAwEAAQ==
"
;
public
static
final
String
TIME_FROMAT_NORMAL
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
PARAM_SIGN
=
"sign"
;
...
...
src/main/java/com/glsx/controller/OpenApiController.java
View file @
d05e3c8
package
com
.
glsx
.
controller
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.DTO.*
;
import
com.glsx.model.Result
;
import
com.glsx.service.OpenApiService
;
...
...
@@ -39,8 +40,8 @@ public class OpenApiController {
*/
@PostMapping
(
"deviceList"
)
public
Result
getDeviceList
(
@RequestBody
DeviceListBo
deviceListBo
){
DeviceListDTO
deviceListVo
=
openApiService
.
getDeviceList
(
deviceListBo
);
return
Result
.
ok
().
data
(
d
eviceListVo
);
Map
<
String
,
Object
>
data
=
openApiService
.
getDeviceList
(
deviceListBo
);
return
Result
.
ok
().
data
(
d
ata
);
}
/*
...
...
@@ -153,4 +154,23 @@ public class OpenApiController {
BsRecordsDto
recentBsRecords
=
openApiService
.
getRecentBsRecords
(
deviceStatusBo
);
return
Result
.
ok
().
data
(
recentBsRecords
);
}
/*
* 通过经纬度查询所属行政区域
*/
@PostMapping
(
"distInfoByPos"
)
public
Result
getDistInfoByPos
(
@RequestBody
DistBO
mapModel
){
DistInfoDto
distInfo
=
openApiService
.
getDistInfoByPos
(
mapModel
);
return
Result
.
ok
().
data
(
distInfo
);
}
/*
* 通过经纬度查询所属省份城市区域()
*/
@PostMapping
(
"distDetailByPos"
)
public
Result
getDistDetailByPos
(
@RequestBody
DistBO
mapModel
){
DistDetilDto
distDetail
=
openApiService
.
getDistDetailByPos
(
mapModel
);
return
Result
.
ok
().
data
(
distDetail
);
}
}
src/main/java/com/glsx/ice/iceClient/IceDistrictClient.java
View file @
d05e3c8
package
com
.
glsx
.
ice
.
iceClient
;
import
Ice.StringHolder
;
import
com.glsx.config.SystemProperty
;
import
com.glsx.ice.DISTRICT.IDistrictFinderPrx
;
import
com.glsx.ice.DISTRICT.IDistrictFinderPrxHelper
;
import
com.glsx.model.BO.DistBO
;
import
com.glsx.model.DTO.BsRecordDto
;
import
com.glsx.model.DTO.DistDetilDto
;
import
com.glsx.model.DTO.DistInfoDto
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.List
;
@Slf4j
...
...
@@ -16,9 +21,10 @@ public class IceDistrictClient {
/**
* 通过经纬度查询所属行政区域
*
* @return
*/
public
static
List
<
BsRecordDto
>
getDistInfoByPos
(
float
lng
,
float
lat
)
{
public
static
DistInfoDto
getDistInfoByPos
(
float
lng
,
float
lat
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
...
...
@@ -27,10 +33,16 @@ public class IceDistrictClient {
Ice
.
IntHolder
distCode
=
new
Ice
.
IntHolder
();
Ice
.
StringHolder
strDistName
=
new
Ice
.
StringHolder
();
boolean
res
=
prx
.
get_distinfo_by_pos
(
lng
,
lat
,
distCode
,
strDistName
);
boolean
res
=
prx
.
get_distinfo_by_pos
(
lng
,
lat
,
distCode
,
strDistName
);
DistInfoDto
infoDto
=
null
;
if
(
res
)
{
log
.
info
(
"success===getDistInfoByPos:"
+
distCode
+
"=="
+
strDistName
);
int
dist_code
=
distCode
.
value
;
String
dist_name
=
strDistName
.
value
;
infoDto
=
new
DistInfoDto
();
infoDto
.
setDist_code
(
dist_code
);
infoDto
.
setDist_name
(
dist_name
);
log
.
info
(
"success===getDistInfoByPos:"
+
distCode
+
"=="
+
strDistName
);
return
infoDto
;
}
}
catch
(
Ice
.
LocalException
e
)
{
log
.
error
(
"===getDistInfoByPos_ICE_EXCEP:"
+
e
.
getMessage
(),
e
);
...
...
@@ -40,5 +52,42 @@ public class IceDistrictClient {
return
null
;
}
/**
* 通过经纬度查询所属省份城市区域
*
* @return
*/
public
static
DistDetilDto
getDistDetailByPos
(
float
lng
,
float
lat
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
}
Ice
.
StringHolder
strProvName
=
new
Ice
.
StringHolder
();
Ice
.
StringHolder
strCityName
=
new
Ice
.
StringHolder
();
Ice
.
StringHolder
strCountyName
=
new
Ice
.
StringHolder
();
boolean
res
=
prx
.
get_distdetail_by_pos
(
lng
,
lat
,
strProvName
,
strCityName
,
strCountyName
);
DistDetilDto
detilDto
=
null
;
if
(
res
)
{
String
provName
=
strProvName
.
value
;
String
cityName
=
strCityName
.
value
;
String
countyName
=
strCountyName
.
value
;
detilDto
=
new
DistDetilDto
();
detilDto
.
setProv_name
(
provName
);
detilDto
.
setCity_name
(
cityName
);
detilDto
.
setCounty_name
(
countyName
);
log
.
info
(
"success===getDistDetailByPos:"
+
provName
+
"=="
+
cityName
+
"=="
+
countyName
);
return
detilDto
;
}
}
catch
(
Ice
.
LocalException
e
)
{
log
.
error
(
"===getDistDetailByPos_ICE_EXCEP:"
+
e
.
getMessage
(),
e
);
}
catch
(
Exception
e
)
{
log
.
error
(
"===getDistDetailByPos_EXCEP:"
+
e
.
getMessage
(),
e
);
}
return
null
;
}
}
src/main/java/com/glsx/ice/iceClient/IceHDaoGpsClient.java
View file @
d05e3c8
...
...
@@ -18,7 +18,7 @@ public class IceHDaoGpsClient {
static
Ice
.
ObjectPrx
base
=
ic
.
stringToProxy
(
url
).
ice_timeout
(
Integer
.
parseInt
(
SystemProperty
.
getProperty
(
"ice.connectTimeout"
)));
static
DaoGpsServicePrx
prx
=
DaoGpsServicePrxHelper
.
checkedCast
(
base
);
public
static
LatestGpsRecordDto
getLatestGpsRecord
(
Long
userId
,
Integer
deviceType
,
Integer
mapType
)
{
public
static
LatestGpsRecordDto
getLatestGpsRecord
(
Long
sn
,
Integer
deviceType
,
Integer
mapType
)
{
LatestGpsRecordDto
gpsRecord
=
null
;
try
{
if
(
prx
==
null
)
{
...
...
@@ -26,13 +26,14 @@ public class IceHDaoGpsClient {
}
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestRgpsGetRequest
req
=
new
LatestRgpsGetRequest
(
userId
,
deviceType
,
mapType
);
LatestRgpsGetRequest
req
=
new
LatestRgpsGetRequest
(
sn
,
deviceType
,
mapType
);
LatestRgpsGetResponseHolder
res
=
new
LatestRgpsGetResponseHolder
();
boolean
ret
=
false
;
ret
=
prx
.
getLatestRgpsRecord
(
req
,
res
);
if
(
ret
)
{
log
.
info
(
"===getLatestRGPSRecord:"
+
res
.
value
.
record
);
gpsRecord
=
new
LatestGpsRecordDto
();
gpsRecord
.
setSn
(
sn
+
""
);
gpsRecord
.
setGlng
(
res
.
value
.
record
.
gLng
/
1000000
D
);
gpsRecord
.
setGlat
(
res
.
value
.
record
.
gLat
/
1000000
D
);
gpsRecord
.
setLng
(
res
.
value
.
record
.
lng
/
1000000
D
);
...
...
@@ -48,7 +49,7 @@ public class IceHDaoGpsClient {
return
gpsRecord
;
}
public
static
LatestBsRecordDto
getLatestBsRecord
(
long
userId
,
Integer
deviceType
)
{
public
static
LatestBsRecordDto
getLatestBsRecord
(
long
sn
,
Integer
deviceType
)
{
LatestBsRecordDto
bsRecord
=
null
;
try
{
if
(
prx
==
null
)
{
...
...
@@ -58,11 +59,12 @@ public class IceHDaoGpsClient {
// 第2个参数:2: OBD; 4: DDbox(DVD) 5: Tracker 6: rearMirror 7: car recorder
LatestBsGetResponseHolder
res
=
new
LatestBsGetResponseHolder
();
boolean
ret
=
false
;
LatestBsGetRequest
req
=
new
LatestBsGetRequest
(
userId
,
deviceType
);
LatestBsGetRequest
req
=
new
LatestBsGetRequest
(
sn
,
deviceType
);
ret
=
prx
.
getLatestBsRecord
(
req
,
res
);
if
(
ret
)
{
log
.
info
(
"===LatestBsRecord:"
+
res
.
value
.
record
);
bsRecord
=
new
LatestBsRecordDto
();
bsRecord
.
setSn
(
sn
+
""
);
bsRecord
.
setGpstime
(
res
.
value
.
record
.
gpsTime
);
bsRecord
.
setMcc
(
res
.
value
.
record
.
mcc
);
bsRecord
.
setMnc
(
res
.
value
.
record
.
mnc
);
...
...
@@ -131,7 +133,7 @@ public class IceHDaoGpsClient {
* @param endTime 结束时间
* @return
*/
public
static
GpsRecordsDto
getGpsRecords
(
int
apType
,
Date
startTime
,
Date
endTime
,
long
userId
)
{
public
static
GpsRecordsDto
getGpsRecords
(
int
apType
,
Date
startTime
,
Date
endTime
,
long
sn
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
...
...
@@ -146,8 +148,7 @@ public class IceHDaoGpsClient {
req
.
startTime
=
new
Long
(
startTime
.
getTime
()
/
1000
).
intValue
();
req
.
endTime
=
new
Long
(
endTime
.
getTime
()
/
1000
).
intValue
();
req
.
extraMapReq
=
1
;
req
.
reqCount
=
0
;
req
.
userID
=
userId
;
req
.
userID
=
sn
;
prx
.
getGpsRecords
(
req
,
res
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
...
...
@@ -184,7 +185,6 @@ public class IceHDaoGpsClient {
req
.
apType
=
apType
;
req
.
startTime
=
new
Long
(
startTime
.
getTime
()
/
1000
).
intValue
();
req
.
endTime
=
new
Long
(
endTime
.
getTime
()
/
1000
).
intValue
();
req
.
reqCount
=
0
;
req
.
userID
=
userId
;
prx
.
getBsRecords
(
req
,
res
);
...
...
@@ -203,7 +203,7 @@ public class IceHDaoGpsClient {
//查询首次GPS点
public
static
FirstGpsRecordDto
getFirstGpsRecord
(
int
apType
,
long
userId
)
{
public
static
FirstGpsRecordDto
getFirstGpsRecord
(
int
apType
,
long
sn
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
...
...
@@ -213,7 +213,7 @@ public class IceHDaoGpsClient {
GpsGetRequest
req
=
new
GpsGetRequest
();
req
.
apType
=
apType
;
req
.
reqCount
=
0
;
req
.
userID
=
userId
;
req
.
userID
=
sn
;
prx
.
getFirstGpsRecord
(
req
,
res
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
...
...
@@ -239,14 +239,17 @@ public class IceHDaoGpsClient {
return
null
;
}
public
static
GpsRecordsDto
getRecentGpsRecords
(
long
userID
,
int
apType
,
int
apSubType
,
int
extraMapReq
,
int
reqCount
)
{
public
static
GpsRecordsDto
getRecentGpsRecords
(
long
sn
,
int
apType
,
int
reqCount
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
}
GpsRecordsDto
gpsRecordsDto
=
new
GpsRecordsDto
();
RecentGpsGetResponseHolder
res
=
new
RecentGpsGetResponseHolder
(
new
RecentGpsGetResponse
());
RecentGpsGetRequest
req
=
new
RecentGpsGetRequest
(
userID
,
apType
,
apSubType
,
extraMapReq
,
reqCount
);
RecentGpsGetRequest
req
=
new
RecentGpsGetRequest
();
req
.
userID
=
sn
;
req
.
apType
=
apType
;
req
.
reqCount
=
reqCount
;
prx
.
getRecentGpsRecords
(
req
,
res
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
...
...
@@ -262,7 +265,7 @@ public class IceHDaoGpsClient {
return
null
;
}
public
static
BsRecordsDto
getRecentBsRecords
(
int
apType
,
long
userId
)
{
public
static
BsRecordsDto
getRecentBsRecords
(
long
sn
,
int
apType
,
int
reqCount
)
{
try
{
if
(
prx
==
null
)
{
throw
new
Exception
(
"Invalid proxy"
);
...
...
@@ -271,8 +274,8 @@ public class IceHDaoGpsClient {
RecentBsGetResponseHolder
res
=
new
RecentBsGetResponseHolder
(
new
RecentBsGetResponse
());
RecentBsGetRequest
req
=
new
RecentBsGetRequest
();
req
.
apType
=
apType
;
req
.
reqCount
=
0
;
req
.
userID
=
userId
;
req
.
reqCount
=
reqCount
;
req
.
userID
=
sn
;
prx
.
getRecentBsRecords
(
req
,
res
);
if
(
res
!=
null
&&
res
.
value
!=
null
&&
res
.
value
.
oprResult
==
0
)
{
...
...
src/main/java/com/glsx/intercepter/AuthIntercepter.java
View file @
d05e3c8
...
...
@@ -54,7 +54,7 @@ public class AuthIntercepter implements HandlerInterceptor {
//解析验证token
tokenExpired
=
jwtUtil
.
isTokenExpired
(
jwtToken
);
}
catch
(
Exception
e
){
throw
ApiErrorMessage
.
TOKEN_ERROR
.
exception
();
throw
ApiErrorMessage
.
TOKEN_ERROR
.
exception
(
jwtToken
);
}
if
(
tokenExpired
){
...
...
src/main/java/com/glsx/model/BO/DistBO.java
0 → 100644
View file @
d05e3c8
package
com
.
glsx
.
model
.
BO
;
import
com.glsx.model.BaseMapModel
;
import
lombok.Data
;
import
lombok.ToString
;
@Data
@ToString
(
callSuper
=
true
)
public
class
DistBO
extends
BaseMapModel
{
}
src/main/java/com/glsx/model/BaseTimeRangeModel.java
View file @
d05e3c8
package
com
.
glsx
.
model
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
lombok.ToString
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.util.Date
;
@Data
@ToString
(
callSuper
=
true
)
public
class
BaseTimeRangeModel
extends
Basemodel
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
startTime
;
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
endTime
;
}
src/main/java/com/glsx/model/DTO/DistDetilDto.java
0 → 100644
View file @
d05e3c8
package
com
.
glsx
.
model
.
DTO
;
import
lombok.Data
;
@Data
public
class
DistDetilDto
{
//所属省份
private
String
prov_name
;
//所属城市
private
String
city_name
;
//所属县城
private
String
county_name
;
}
src/main/java/com/glsx/model/DTO/DistInfoDto.java
0 → 100644
View file @
d05e3c8
package
com
.
glsx
.
model
.
DTO
;
import
lombok.Data
;
@Data
public
class
DistInfoDto
{
//行政编码
private
Integer
dist_code
;
//行政区域名称
private
String
dist_name
;
}
src/main/java/com/glsx/service/OpenApiService.java
View file @
d05e3c8
package
com
.
glsx
.
service
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.DTO.*
;
import
java.util.Map
;
...
...
@@ -9,7 +10,7 @@ import java.util.Map;
public
interface
OpenApiService
{
String
getToken
(
TokenBo
grantType
);
DeviceListDTO
getDeviceList
(
DeviceListBo
deviceListBo
);
Map
<
String
,
Object
>
getDeviceList
(
DeviceListBo
deviceListBo
);
void
postCommands
(
CommandsBo
commandsBo
);
...
...
@@ -31,7 +32,11 @@ public interface OpenApiService {
FirstGpsRecordDto
getFirstGpsRecord
(
DeviceStatusBo
deviceStatusBo
);
GpsRecordsDto
getRecentGpsRecords
(
DeviceStatusBo
deviceStatusBo
);
GpsRecordsDto
getRecentGpsRecords
(
DeviceStatus
Count
Bo
deviceStatusBo
);
BsRecordsDto
getRecentBsRecords
(
DeviceStatusBo
deviceStatusBo
);
BsRecordsDto
getRecentBsRecords
(
DeviceStatusCountBo
deviceStatusBo
);
DistInfoDto
getDistInfoByPos
(
DistBO
distBO
);
DistDetilDto
getDistDetailByPos
(
DistBO
distBO
);
}
src/main/java/com/glsx/service/impl/OpenApiServiceImpl.java
View file @
d05e3c8
package
com
.
glsx
.
service
.
impl
;
import
cn.com.glsx.openplatform.service.IceOpenApiService
;
import
cn.hutool.db.Page
;
import
com.glsx.base.controller.BaseService
;
import
com.glsx.constant.OpenAPIConstant
;
import
com.glsx.enums.MapTypeEnum
;
import
com.glsx.exception.ApiErrorMessage
;
import
com.glsx.ice.iceClient.IceDistrictClient
;
import
com.glsx.ice.iceClient.IceHDaoGpsClient
;
import
com.glsx.model.BO.*
;
import
com.glsx.model.BaseMapModel
;
import
com.glsx.model.DTO.*
;
import
com.glsx.service.OpenApiService
;
import
com.glsx.utils.JwtUtil
;
import
com.glsx.utils.MapUtils
;
import
com.glsx.utils.RSAUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.
HashMap
;
import
java.util.
Date
;
import
java.util.Map
;
import
java.util.TreeMap
;
/**
* @Description: 开放平台接口实现类
* @author fengzhi
* @version V1.0
* @Description: 开放平台接口实现类
*/
@Service
public
class
OpenApiServiceImpl
extends
BaseService
implements
OpenApiService
{
...
...
@@ -38,30 +42,30 @@ public class OpenApiServiceImpl extends BaseService implements OpenApiService {
//校验必传参数
TreeMap
<
String
,
String
>
params
=
MapUtils
.
transBean2Map
(
tokenBo
);
logi
(
"参数对象:"
+
params
);
boolean
miss
=
params
.
entrySet
().
stream
().
anyMatch
(
kv
->
StringUtils
.
isEmpty
(
kv
.
getValue
()));
if
(
miss
)
boolean
miss
=
params
.
entrySet
().
stream
().
anyMatch
(
kv
->
StringUtils
.
isEmpty
(
kv
.
getValue
()));
if
(
miss
)
throw
ApiErrorMessage
.
ARGS_NULL
.
exception
();
//
todo 根据appID查询客户信息
//
获取私钥
Integer
appId
=
tokenBo
.
getAppId
();
//todo 测试参数修改
String
privateKey
=
OpenAPIConstant
.
TEST_PRIVATE_KEY
/*iceOpenApiService.getPrivateSecret(appId)*/
;
//获取公钥加密的密文
String
sign
=
tokenBo
.
getSign
();
//todo 获取私钥
String
privateKey
=
OpenAPIConstant
.
TEST_PRIVATE_KEY
;
String
originalStr
=
""
;
try
{
//私钥解密获取明文
originalStr
=
RSAUtils
.
decrypt
(
sign
,
privateKey
);
}
catch
(
Exception
e
)
{
throw
ApiErrorMessage
.
ARGS_ERROR
.
exception
(
"RSA解密错误=="
+
sign
);
throw
ApiErrorMessage
.
ARGS_ERROR
.
exception
(
"RSA解密错误==签名或私钥错误"
+
sign
);
}
//除了sign以外,按照参数字母升序(参数+参数值)拼接
StringBuffer
paramsStrbuf
=
new
StringBuffer
();
params
.
remove
(
OpenAPIConstant
.
PARAM_SIGN
);
params
.
entrySet
().
stream
().
forEach
(
kv
->
{
params
.
entrySet
().
stream
().
forEach
(
kv
->
{
paramsStrbuf
.
append
(
kv
.
getKey
()).
append
(
kv
.
getValue
());
});
String
paramsStr
=
paramsStrbuf
.
toString
();
...
...
@@ -71,11 +75,9 @@ public class OpenApiServiceImpl extends BaseService implements OpenApiService {
throw
ApiErrorMessage
.
ARGS_ERROR
.
exception
(
"请求参数被篡改"
);
}
//todo 将客户信息转化为jwt
Map
<
String
,
Object
>
infos
=
new
HashMap
<>();
infos
.
put
(
"fzs"
,
"haha"
);
infos
.
put
(
"fzn"
,
123
);
infos
.
put
(
"fzl"
,
22
);
//根据appid查询用户信息,将客户信息转化为jwt
Map
<
String
,
Object
>
infos
=
iceOpenApiService
.
getCustomerInfo
(
appId
);
logi
(
"OpenApiService===Userinfos==="
+
infos
);
String
jwtToken
=
jwtTokenUtil
.
generateToken
(
infos
);
logi
(
"OpenApiService===返回jwt==="
+
jwtToken
);
return
jwtToken
;
...
...
@@ -85,105 +87,155 @@ public class OpenApiServiceImpl extends BaseService implements OpenApiService {
* 参数用公钥加密后的密文
*/
@Override
public
DeviceListDTO
getDeviceList
(
DeviceListBo
deviceListBo
)
{
logi
(
"OpenApiService===getDeviceList==="
+
deviceListBo
);
DeviceListDTO
deviceListDTO
=
new
DeviceListDTO
();
deviceListDTO
.
setTotal
(
100
);
return
deviceListDTO
;
public
Map
<
String
,
Object
>
getDeviceList
(
DeviceListBo
deviceListBo
)
{
logi
(
"OpenApiService===getDeviceList开始==="
+
deviceListBo
);
Page
page
=
new
Page
(
deviceListBo
.
getPageNo
(),
deviceListBo
.
getPageSize
());
Date
start_time
=
deviceListBo
.
getStartTime
();
Date
end_time
=
deviceListBo
.
getEndTime
();
Integer
appid
=
getCustomerID
(
deviceListBo
);
Map
<
String
,
Object
>
res
=
iceOpenApiService
.
getDeviceList
(
appid
,
page
,
start_time
,
end_time
);
logi
(
"OpenApiService===getDeviceList返回==="
+
res
.
toString
());
return
res
;
}
//todo 接口还没给
@Override
public
void
postCommands
(
CommandsBo
commandsBo
)
{
logi
(
"OpenApiService===postCommands
"
);
logi
(
"OpenApiService===postCommands
开始==="
+
commandsBo
);
}
//todo 接口还没给
@Override
public
Integer
getDeviceStatus
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getDeviceStatus"
);
logi
(
"OpenApiService===getDeviceStatus
开始
"
);
return
null
;
}
@Override
public
Map
<
String
,
Integer
>
getDataView
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getDataView"
);
int
userID
=
1
;
return
iceOpenApiService
.
getDataView
(
userID
);
logi
(
"OpenApiService===getDataView开始==="
+
deviceStatusBo
);
Integer
customerId
=
getCustomerID
(
deviceStatusBo
);
logi
(
"OpenApiService===getDataView==customerId:"
+
customerId
);
Map
<
String
,
Integer
>
res
=
iceOpenApiService
.
getDataView
(
customerId
,
deviceStatusBo
.
getDevice_type
());
logi
(
"OpenApiService===getDataView==res:"
+
res
);
return
res
;
}
//todo 接口还没给
@Override
public
void
subscribeMessage
(
subscribeMessageBo
subscribeMessageBo
)
{
logi
(
"OpenApiService===subscribeMessage
"
);
logi
(
"OpenApiService===subscribeMessage
开始==="
+
subscribeMessageBo
);
}
@Override
public
LatestGpsRecordDto
getLatestGPSRecord
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getLatestRGPSRecord"
);
long
dId
=
61000593
;
Integer
dType
=
6
;
//todo 调用参数
LatestGpsRecordDto
gpsRecord
=
IceHDaoGpsClient
.
getLatestGpsRecord
(
dId
,
dType
,
MapTypeEnum
.
NONE_TYPE
.
getId
());
//todo 设置sn
logi
(
"OpenApiService===getLatestGPSRecord开始==="
+
deviceStatusBo
);
long
sn
=
Long
.
parseLong
(
deviceStatusBo
.
getSn
());
Integer
dType
=
deviceStatusBo
.
getDevice_type
();
LatestGpsRecordDto
gpsRecord
=
IceHDaoGpsClient
.
getLatestGpsRecord
(
sn
,
dType
,
MapTypeEnum
.
NONE_TYPE
.
getId
());
logi
(
"OpenApiService===getLatestGPSRecord==返回:"
+
gpsRecord
);
return
gpsRecord
;
}
@Override
public
LatestBsRecordDto
getLatestBsRecord
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getLatestBsRecord"
+
deviceStatusBo
);
long
dId
=
61000593
;
Integer
dType
=
6
;
//todo 调用参数
LatestBsRecordDto
bsRecord
=
IceHDaoGpsClient
.
getLatestBsRecord
(
dId
,
dType
);
//todo 设置sn
logi
(
"OpenApiService===getLatestBsRecord开始=="
+
deviceStatusBo
);
Integer
customerId
=
getCustomerID
(
deviceStatusBo
);
logi
(
"OpenApiService===getLatestBsRecord开始==customerId:"
+
customerId
);
long
sn
=
Long
.
parseLong
(
deviceStatusBo
.
getSn
());
Integer
dType
=
deviceStatusBo
.
getDevice_type
();
LatestBsRecordDto
bsRecord
=
IceHDaoGpsClient
.
getLatestBsRecord
(
sn
,
dType
);
logi
(
"OpenApiService===getLatestBsRecord返回:"
+
bsRecord
);
return
bsRecord
;
}
@Override
public
LatestGpsBsRecordDto
getLatestGpsBsRecord
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getLatestGpsBsRecord==="
+
deviceStatusBo
);
long
[]
dId
=
{
61000593
};
//todo 调用参数
LatestGpsBsRecordDto
latestGpsBsRecordDto
=
IceHDaoGpsClient
.
getDevicesGpsInfo
(
dId
,
0
,
0
);
return
latestGpsBsRecordDto
;
logi
(
"OpenApiService===getLatestGpsBsRecord开始=="
+
deviceStatusBo
);
//todo ice接口有问题,暂用组合代替
long
sn
=
Long
.
parseLong
(
deviceStatusBo
.
getSn
());
Integer
dType
=
deviceStatusBo
.
getDevice_type
();
LatestGpsRecordDto
gpsRecord
=
IceHDaoGpsClient
.
getLatestGpsRecord
(
sn
,
dType
,
MapTypeEnum
.
NONE_TYPE
.
getId
());
LatestBsRecordDto
bsRecord
=
IceHDaoGpsClient
.
getLatestBsRecord
(
sn
,
dType
);
LatestGpsBsRecordDto
gpsBsRecordDto
=
new
LatestGpsBsRecordDto
();
BeanUtils
.
copyProperties
(
gpsRecord
,
gpsBsRecordDto
);
BeanUtils
.
copyProperties
(
bsRecord
,
gpsBsRecordDto
);
//LatestGpsBsRecordDto latestGpsBsRecordDto = IceHDaoGpsClient.getDevicesGpsInfo(dId, 0, 0);
logi
(
"OpenApiService===getLatestGpsBsRecord返回:"
+
gpsBsRecordDto
);
return
gpsBsRecordDto
;
}
@Override
public
GpsRecordsDto
getGpsRecords
(
GpsBsRecordsBo
gpsRecordsBo
)
{
logi
(
"OpenApiService===getGpsRecords==="
+
gpsRecordsBo
);
GpsRecordsDto
gpsRecordsDto
=
IceHDaoGpsClient
.
getGpsRecords
(
1
,
gpsRecordsBo
.
getStartTime
(),
gpsRecordsBo
.
getEndTime
(),
1
);
logi
(
"OpenApiService===getGpsRecords开始==="
+
gpsRecordsBo
);
long
sn
=
Long
.
parseLong
(
gpsRecordsBo
.
getSn
());
Integer
dType
=
gpsRecordsBo
.
getDevice_type
();
GpsRecordsDto
gpsRecordsDto
=
IceHDaoGpsClient
.
getGpsRecords
(
dType
,
gpsRecordsBo
.
getStartTime
(),
gpsRecordsBo
.
getEndTime
(),
sn
);
logi
(
"OpenApiService===getGpsRecords返回:"
+
gpsRecordsDto
);
return
gpsRecordsDto
;
}
@Override
public
BsRecordsDto
getBsRecords
(
GpsBsRecordsBo
gpsRecordsBo
)
{
logi
(
"OpenApiService===getGpsRecords==="
+
gpsRecordsBo
);
BsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getBsRecords
(
1
,
gpsRecordsBo
.
getStartTime
(),
gpsRecordsBo
.
getEndTime
(),
1
);
public
BsRecordsDto
getBsRecords
(
GpsBsRecordsBo
bsRecordsBo
)
{
logi
(
"OpenApiService===getGpsRecords开始==="
+
bsRecordsBo
);
long
sn
=
Long
.
parseLong
(
bsRecordsBo
.
getSn
());
Integer
dType
=
bsRecordsBo
.
getDevice_type
();
BsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getBsRecords
(
dType
,
bsRecordsBo
.
getStartTime
(),
bsRecordsBo
.
getEndTime
(),
sn
);
logi
(
"OpenApiService===getBsRecords返回:"
+
bsRecordsDto
);
return
bsRecordsDto
;
}
@Override
public
FirstGpsRecordDto
getFirstGpsRecord
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getFirstGpsRecord==="
+
deviceStatusBo
);
FirstGpsRecordDto
firstGpsRecordDto
=
IceHDaoGpsClient
.
getFirstGpsRecord
(
1
,
1
);
logi
(
"OpenApiService===getFirstGpsRecord开始==="
+
deviceStatusBo
);
long
sn
=
Long
.
parseLong
(
deviceStatusBo
.
getSn
());
Integer
dType
=
deviceStatusBo
.
getDevice_type
();
FirstGpsRecordDto
firstGpsRecordDto
=
IceHDaoGpsClient
.
getFirstGpsRecord
(
dType
,
sn
);
logi
(
"OpenApiService===getFirstGpsRecord返回:"
+
firstGpsRecordDto
);
return
firstGpsRecordDto
;
}
@Override
public
GpsRecordsDto
getRecentGpsRecords
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getRecentGpsRecords==="
+
deviceStatusBo
);
GpsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getRecentGpsRecords
(
1
,
1
,
1
,
1
,
1
);
public
GpsRecordsDto
getRecentGpsRecords
(
DeviceStatusCountBo
deviceStatusCountBo
)
{
logi
(
"OpenApiService===getRecentGpsRecords开始==="
+
deviceStatusCountBo
);
long
sn
=
Long
.
parseLong
(
deviceStatusCountBo
.
getSn
());
Integer
dType
=
deviceStatusCountBo
.
getDevice_type
();
Integer
count
=
deviceStatusCountBo
.
getCount
();
GpsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getRecentGpsRecords
(
sn
,
dType
,
count
);
logi
(
"OpenApiService===getRecentGpsRecords返回:"
+
bsRecordsDto
);
return
bsRecordsDto
;
}
@Override
public
BsRecordsDto
getRecentBsRecords
(
DeviceStatusBo
deviceStatusBo
)
{
logi
(
"OpenApiService===getRecentBsRecords==="
+
deviceStatusBo
);
BsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getRecentBsRecords
(
1
,
1
);
public
BsRecordsDto
getRecentBsRecords
(
DeviceStatusCountBo
deviceStatusCountBo
)
{
logi
(
"OpenApiService===getRecentBsRecords开始==="
+
deviceStatusCountBo
);
long
sn
=
Long
.
parseLong
(
deviceStatusCountBo
.
getSn
());
Integer
dType
=
deviceStatusCountBo
.
getDevice_type
();
Integer
count
=
deviceStatusCountBo
.
getCount
();
BsRecordsDto
bsRecordsDto
=
IceHDaoGpsClient
.
getRecentBsRecords
(
sn
,
dType
,
count
);
return
bsRecordsDto
;
}
@Override
public
DistInfoDto
getDistInfoByPos
(
DistBO
distBO
)
{
logi
(
"OpenApiService===getDistInfoByPos开始==="
+
distBO
);
float
lat
=
distBO
.
getLat
().
floatValue
();
float
lng
=
distBO
.
getLng
().
floatValue
();
DistInfoDto
res
=
IceDistrictClient
.
getDistInfoByPos
(
lng
,
lat
);
logi
(
"OpenApiService===getDistInfoByPos返回==="
+
res
);
return
res
;
}
@Override
public
DistDetilDto
getDistDetailByPos
(
DistBO
distBO
)
{
logi
(
"OpenApiService===getDistDetailByPos开始==="
+
distBO
);
float
lat
=
distBO
.
getLat
().
floatValue
();
float
lng
=
distBO
.
getLng
().
floatValue
();
DistDetilDto
res
=
IceDistrictClient
.
getDistDetailByPos
(
lng
,
lat
);
logi
(
"OpenApiService===getDistDetailByPos返回==="
+
res
);
return
res
;
}
}
src/main/java/com/glsx/utils/RSAUtils.java
View file @
d05e3c8
...
...
@@ -25,7 +25,7 @@ public class RSAUtils {
//生成公钥和私钥
genKeyPair
();
//加密字符串
String
message
=
"appId
123456grantType1time1427093913
"
;
String
message
=
"appId
4grantType1time123456
"
;
System
.
out
.
println
(
"随机生成的公钥为:"
+
keyMap
.
get
(
0
));
System
.
out
.
println
(
"随机生成的私钥为:"
+
keyMap
.
get
(
1
));
//String messageEn = encrypt(message, OpenAPIConstant.TEST_PUBLIC_KEY);
...
...
@@ -43,7 +43,7 @@ public class RSAUtils {
// KeyPairGenerator类用于生成公钥和私钥对,基于RSA算法生成对象
KeyPairGenerator
keyPairGen
=
KeyPairGenerator
.
getInstance
(
"RSA"
);
// 初始化密钥对生成器,密钥大小为96-1024位
keyPairGen
.
initialize
(
1024
,
new
SecureRandom
());
keyPairGen
.
initialize
(
512
,
new
SecureRandom
());
// 生成一个密钥对,保存在keyPair中
KeyPair
keyPair
=
keyPairGen
.
generateKeyPair
();
RSAPrivateKey
privateKey
=
(
RSAPrivateKey
)
keyPair
.
getPrivate
();
// 得到私钥
...
...
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