Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 37626852
authored
Jul 12, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-dingwf-0715' into develop
2 parents
8e51050c
1a054066
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
15 deletions
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/SaasUtils.java
View file @
3762685
...
...
@@ -23,12 +23,12 @@ public class SaasUtils {
/**
* 根据提供的地址信息,获取对应的片区图层定义的工作队;如果没有找到,返回为空
*/
public
List
<
BlockInfo
>
queryBlocks
(
String
location
,
String
address
)
{
public
List
<
BlockInfo
>
queryBlocks
ByLocation
(
String
location
)
{
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log
.
info
(
"===> queryBlocks
({}, {})"
,
location
,
address
);
log
.
info
(
"===> queryBlocks
ByLocation({})"
,
location
);
RestTemplate
restTemplate
=
new
RestTemplate
();
// 设置请求头
...
...
@@ -39,14 +39,62 @@ public class SaasUtils {
String
url
;
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"ak"
,
"284c57cbabad4755a9c657885a8df3e2"
);
if
(
StringUtils
.
isNotEmpty
(
location
))
{
url
=
"https://pea-test.bshg.com.cn/v1/xyfendan"
;
String
[]
coordinates
=
location
.
split
(
","
);
params
.
add
(
"coordinate"
,
String
.
format
(
"{\"x\":%s, \"y\":%s}"
,
coordinates
[
0
],
coordinates
[
1
]));
}
else
{
params
.
add
(
"need_district"
,
"false"
);
params
.
add
(
"need_layer"
,
"true"
);
// params.add("related_point_fields", "");
params
.
add
(
"area_fields"
,
"名称,唯一编号,区块"
);
log
.
info
(
"request params ==> {}"
,
params
);
// 构建请求实体
HttpEntity
<
MultiValueMap
<
String
,
Object
>>
requestEntity
=
new
HttpEntity
<>(
params
,
headers
);
// 发送POST请求
ResponseEntity
<
String
>
responseEntity
=
restTemplate
.
exchange
(
url
,
HttpMethod
.
POST
,
requestEntity
,
String
.
class
);
// 获取响应结果
String
responseBody
=
responseEntity
.
getBody
();
log
.
info
(
"after call saas ==> {}"
,
responseEntity
.
getBody
());
// 使用Jackson库解析JSON数据
List
<
BlockInfo
>
blocks
=
new
ArrayList
<>();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
JsonNode
responseJson
=
objectMapper
.
readTree
(
responseBody
);
// 坐标模式
for
(
JsonNode
r
:
responseJson
.
get
(
"result"
))
{
// 分单接口暂时无图层返回
if
(
r
.
get
(
"field3"
)
!=
null
&&
r
.
get
(
"field1"
)
!=
null
)
{
blocks
.
add
(
new
BlockInfo
().
setBlockId
(
r
.
get
(
"field3"
).
asText
()).
setBlockName
(
r
.
get
(
"field1"
).
asText
()));
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"处理异常: {}"
,
e
.
getMessage
());
}
return
blocks
;
}
public
List
<
BlockInfo
>
queryBlocksByAddress
(
String
address
)
{
// 根据坐标 查询分单接口,获得区块、图层列表 ===> 查询map_block_info表,根据优先级,确定 工作队;
// 根据工作队+图层,查询 capacity_team_stat,返回
// todo 由于saas的分单接口尚未完成,目前仅仅是调用分单获取图层、区块名称,对于我们的容量查询没有真正使用,目前采用随机返回方式
// 创建RestTemplate实例
log
.
info
(
"===> queryBlocksByAddress({})"
,
address
);
RestTemplate
restTemplate
=
new
RestTemplate
();
// 设置请求头
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
setContentType
(
MediaType
.
APPLICATION_FORM_URLENCODED
);
// 构建请求参数
String
url
;
MultiValueMap
<
String
,
Object
>
params
=
new
LinkedMultiValueMap
<>();
params
.
add
(
"ak"
,
"284c57cbabad4755a9c657885a8df3e2"
);
url
=
"https://pea-test.bshg.com.cn/v2/fendan"
;
params
.
add
(
"addresses"
,
String
.
format
(
"[{\"address\":\"%s\"}]"
,
address
));
}
params
.
add
(
"need_district"
,
"false"
);
params
.
add
(
"need_layer"
,
"true"
);
// params.add("related_point_fields", "");
...
...
@@ -67,26 +115,24 @@ public class SaasUtils {
ObjectMapper
objectMapper
=
new
ObjectMapper
();
try
{
JsonNode
responseJson
=
objectMapper
.
readTree
(
responseBody
);
// 地址模式
// 获取areaResults[0]的值
for
(
JsonNode
r
:
responseJson
.
get
(
"result"
).
get
(
0
).
get
(
"areaResults"
))
{
// 分单接口暂时无图层返回
if
(
r
.
get
(
"field3"
)
!=
null
&&
r
.
get
(
"field1"
)
!=
null
)
{
if
(
r
.
get
(
"field3"
)
!=
null
&&
r
.
get
(
"field1"
)
!=
null
)
{
blocks
.
add
(
new
BlockInfo
().
setBlockId
(
r
.
get
(
"field3"
).
asText
()).
setBlockName
(
r
.
get
(
"field1"
).
asText
()));
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
"处理异常: {}"
,
e
.
getMessage
());
}
return
blocks
;
}
public
List
<
String
>
queryBlockIds
(
String
location
,
String
address
)
{
return
queryBlocks
(
location
,
address
).
stream
().
map
(
BlockInfo:
:
getBlockId
).
collect
(
Collectors
.
toList
());
}
@lombok
.
Data
@Accessors
(
chain
=
true
)
static
class
BlockInfo
{
public
static
class
BlockInfo
{
private
String
layer
;
private
String
blockId
;
private
String
blockName
;
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/CapacityQueryServiceImpl.java
View file @
3762685
...
...
@@ -12,6 +12,7 @@ import com.dituhui.pea.order.entity.*;
import
com.dituhui.pea.order.service.CapacityQueryService
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -49,12 +50,17 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
// 单条容量查询
log
.
info
(
"===> queryMatchCapacityData()"
);
List
<
String
>
layerIds
=
capacityUtils
.
getLayers
(
reqDTO
.
getBrand
(),
reqDTO
.
getType
(),
reqDTO
.
getSkill
());
List
<
String
>
blockIds
=
saasUtils
.
queryBlockIds
(
reqDTO
.
getLocation
(),
reqDTO
.
getAddress
());
if
(
blockIds
==
null
||
blockIds
.
size
()
==
0
)
{
List
<
String
>
blockIds
=
null
;
if
(
StringUtils
.
isNotBlank
(
reqDTO
.
getLocation
()))
{
blockIds
=
saasUtils
.
queryBlocksByLocation
(
reqDTO
.
getLocation
()).
stream
().
map
(
SaasUtils
.
BlockInfo
::
getBlockId
).
collect
(
Collectors
.
toList
());
}
else
{
blockIds
=
saasUtils
.
queryBlocksByAddress
(
reqDTO
.
getAddress
()).
stream
().
map
(
SaasUtils
.
BlockInfo
::
getBlockId
).
collect
(
Collectors
.
toList
());
}
if
(
blockIds
.
size
()
==
0
)
{
log
.
error
(
"分单接口没有查到对应的结果"
);
Result
.
failed
(
String
.
format
(
"分单接口(address:%s)(location:%s) 没有查到配置区块"
,
reqDTO
.
getAddress
(),
reqDTO
.
getLocation
()));
}
List
<
String
>
teamIds
=
capacityUtils
.
getTeamIdsByBlockIdsAndLayerIds
(
blockIds
,
layerIds
);
if
(
teamIds
==
null
||
teamIds
.
size
()
==
0
)
{
Result
.
failed
(
"没有找到匹配的工作队"
);
...
...
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