Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
cfld-region-outline
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cfld-backend
cfld-region-outline
Commits
698b272f
Commit
698b272f
authored
Dec 17, 2023
by
zhouxudong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加调用经纬度接口
parent
bb10ffac
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
13 deletions
+76
-13
BusinessService.java
...main/java/com/lyy/admin/common/utils/BusinessService.java
+54
-5
application-dev.yml
src/main/resources/application-dev.yml
+5
-2
application-local.yml
src/main/resources/application-local.yml
+5
-2
application-prod.yml
src/main/resources/application-prod.yml
+5
-2
application-test.yml
src/main/resources/application-test.yml
+7
-2
No files found.
src/main/java/com/lyy/admin/common/utils/BusinessService.java
View file @
698b272f
...
...
@@ -2,11 +2,18 @@ package com.lyy.admin.common.utils;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.reactive.function.client.WebClient
;
import
reactor.core.publisher.Mono
;
import
java.time.Duration
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -17,22 +24,64 @@ import java.util.Map;
@Component
@Slf4j
public
class
BusinessService
{
@Autowired
private
WebClient
webClient
;
@Autowired
private
WebClient
webClient
;
@Value
(
"${business.url.thread}"
)
private
String
url
;
// 地理/逆地理编码
@Value
(
"${business.url.geocode}"
)
private
String
geocode
;
public
AjaxResult
savThread
(
Map
<
String
,
Object
>
params
)
{
public
AjaxResult
savThread
(
Map
<
String
,
Object
>
params
)
{
AjaxResult
block
=
this
.
webClient
.
post
()
.
uri
(
url
)
.
bodyValue
(
params
)
.
bodyValue
(
params
)
.
retrieve
()
.
bodyToMono
(
AjaxResult
.
class
)
.
block
();
log
.
info
(
"注册保存线索信息:参数:{},结果:{}"
,
params
,
JSONUtil
.
toJsonStr
(
block
));
log
.
info
(
"注册保存线索信息:参数:{},结果:{}"
,
params
,
JSONUtil
.
toJsonStr
(
block
));
return
block
;
}
/**
* @description: 返回格式 116.225202,39.897665
* @date: 2023/12/17 15:56
* @param: [address, city]
* @return: java.lang.String
*/
public
String
getUserIdetify
(
String
address
,
String
city
)
{
String
url
=
this
.
geocode
+
address
;
if
(
StringUtils
.
isNotBlank
(
city
))
{
url
=
url
+
"&city="
+
city
;
}
Map
result
=
this
.
webClient
.
get
()
.
uri
(
url
)
.
header
(
HttpHeaders
.
CONTENT_TYPE
,
MediaType
.
APPLICATION_JSON_VALUE
)
.
retrieve
()
.
bodyToMono
(
String
.
class
)
.
timeout
(
Duration
.
ofSeconds
(
4
))
.
onErrorResume
(
e
->
{
log
.
error
(
"调用高德接口换取经纬度标识失败:"
,
e
);
log
.
error
(
"调用高德接口换取经纬度标识:{}"
,
address
);
return
Mono
.
empty
();
})
.
map
(
str
->
JSONUtil
.
toBean
(
str
,
Map
.
class
))
.
block
();
log
.
info
(
"调用经纬度返回参数:{}"
,
result
);
if
(
ObjectUtils
.
isNotEmpty
(
result
)
&&
result
.
get
(
"status"
).
equals
(
"1"
)
&&
result
.
get
(
"infocode"
).
equals
(
"10000"
))
{
String
geocodes
=
JSONUtil
.
toJsonStr
(
result
.
get
(
"geocodes"
));
List
<
Map
>
maps
=
JSONUtil
.
toList
(
geocodes
,
Map
.
class
);
Map
map
=
maps
.
get
(
0
);
return
map
.
get
(
"location"
).
toString
();
}
return
null
;
}
}
src/main/resources/application-dev.yml
View file @
698b272f
...
...
@@ -75,11 +75,15 @@ huaweiObs:
sk
:
uZIdUJIwO0sKGVY0hltF9I6IbHEmjwCRco5JV7aM
bucketName
:
cfld-hw-obs-01
geocode
:
key
:
34182f92976cdab1bb4059352fc9e4a8
business
:
url
:
thread
:
localhost:8087/lyy/api/threadInfo/v1.0/save
geocode
:
https://restapi.amap.com/v3/geocode/geo?key=${geocode.key}&address=
mybatis-plus
:
configuration
:
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
\ No newline at end of file
log-impl
:
org.apache.ibatis.logging.stdout.StdOutImpl
src/main/resources/application-local.yml
View file @
698b272f
...
...
@@ -74,6 +74,10 @@ huaweiObs:
sk
:
uZIdUJIwO0sKGVY0hltF9I6IbHEmjwCRco5JV7aM
bucketName
:
cfld-hw-obs-01
geocode
:
key
:
34182f92976cdab1bb4059352fc9e4a8
business
:
url
:
thread
:
localhost:8087/lyy/api/threadInfo/v1.0/save
\ No newline at end of file
thread
:
localhost:8087/lyy/api/threadInfo/v1.0/save
geocode
:
https://restapi.amap.com/v3/geocode/geo?key=${geocode.key}&address=
src/main/resources/application-prod.yml
View file @
698b272f
...
...
@@ -77,9 +77,13 @@ huaweiObs:
swagger
:
enabled
:
false
geocode
:
key
:
34182f92976cdab1bb4059352fc9e4a8
business
:
url
:
thread
:
localhost:8087/lyy/api/threadInfo/v1.0/save
geocode
:
https://restapi.amap.com/v3/geocode/geo?key=${geocode.key}&address=
mybatis-plus
:
configuration
:
log-impl
:
org.apache.ibatis.logging.slf4j.Slf4jImpl
\ No newline at end of file
log-impl
:
org.apache.ibatis.logging.slf4j.Slf4jImpl
src/main/resources/application-test.yml
View file @
698b272f
...
...
@@ -74,9 +74,15 @@ huaweiObs:
sk
:
uZIdUJIwO0sKGVY0hltF9I6IbHEmjwCRco5JV7aM
bucketName
:
cfld-hw-obs-01
geocode
:
key
:
34182f92976cdab1bb4059352fc9e4a8
business
:
url
:
thread
:
http://test.api.liyeyun.com/lyy/api/threadInfo/v1.0/save
geocode
:
https://restapi.amap.com/v3/geocode/geo?key=${geocode.key}&address=
mybatis-plus
:
configuration
:
log-impl
:
org.apache.ibatis.logging.slf4j.Slf4jImpl
\ No newline at end of file
log-impl
:
org.apache.ibatis.logging.slf4j.Slf4jImpl
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment