Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-performance
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
姜武杰
clx-performance
Commits
1ccc8d3b
提交
1ccc8d3b
authored
6月 18, 2024
作者:
艾庆国
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'refs/heads/v16.3_line_warn_20240528' into test
上级
5eddfc2f
a21623eb
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
67 行增加
和
4 行删除
+67
-4
TempLineWarnController.java
...x/performance/controller/temp/TempLineWarnController.java
+7
-2
LineWarnWeatherWarnServiceImpl.java
...service/impl/linewarn/LineWarnWeatherWarnServiceImpl.java
+7
-2
GdService.java
...src/main/java/com/clx/performance/utils/gd/GdService.java
+47
-0
GdUtils.java
...b/src/main/java/com/clx/performance/utils/gd/GdUtils.java
+6
-0
没有找到文件。
performance-web/src/main/java/com/clx/performance/controller/temp/TempLineWarnController.java
浏览文件 @
1ccc8d3b
...
...
@@ -78,13 +78,18 @@ public class TempLineWarnController {
if
(
feignAddressVO
.
getSendAddress
()!=
null
&&
StringUtils
.
isNotBlank
(
feignAddressVO
.
getSendAddress
().
getCityCode
())){
String
weather
=
gdUtils
.
getWeather
(
feignAddressVO
.
getSendAddress
().
getCityCode
());
String
cityCode
=
gdUtils
.
getCity
(
feignAddressVO
.
getSendAddress
().
getLongitude
(),
feignAddressVO
.
getSendAddress
().
getLatitude
());
String
weather
=
gdUtils
.
getWeather
(
cityCode
);
result
.
put
(
"send"
,
weather
);
}
if
(
feignAddressVO
.
getReceiveAddress
()!=
null
&&
StringUtils
.
isNotBlank
(
feignAddressVO
.
getReceiveAddress
().
getCityCode
())){
String
weather
=
gdUtils
.
getWeather
(
feignAddressVO
.
getReceiveAddress
().
getCityCode
());
String
cityCode
=
gdUtils
.
getCity
(
feignAddressVO
.
getReceiveAddress
().
getLongitude
(),
feignAddressVO
.
getReceiveAddress
().
getLatitude
());
String
weather
=
gdUtils
.
getWeather
(
cityCode
);
result
.
put
(
"receive"
,
weather
);
}
...
...
performance-web/src/main/java/com/clx/performance/service/impl/linewarn/LineWarnWeatherWarnServiceImpl.java
浏览文件 @
1ccc8d3b
...
...
@@ -72,7 +72,10 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
if
(
feignAddressVO
.
getSendAddress
()!=
null
&&
StringUtils
.
isNotBlank
(
feignAddressVO
.
getSendAddress
().
getCityCode
())){
String
weather
=
gdUtils
.
getWeather
(
feignAddressVO
.
getSendAddress
().
getCityCode
());
String
cityCode
=
gdUtils
.
getCity
(
feignAddressVO
.
getSendAddress
().
getLongitude
(),
feignAddressVO
.
getSendAddress
().
getLatitude
());
String
weather
=
gdUtils
.
getWeather
(
cityCode
);
if
(
weatherCheck
(
weather
)){
// 更新
lineWarnCommonService
.
lineWarnInfoUpdate
(
orderGoods
,
lineWarnInfo
,
lineWarnConfig
,
weather
);
...
...
@@ -80,7 +83,9 @@ public class LineWarnWeatherWarnServiceImpl implements LineWarnWeatherWarnServic
}
if
(
feignAddressVO
.
getReceiveAddress
()!=
null
&&
StringUtils
.
isNotBlank
(
feignAddressVO
.
getReceiveAddress
().
getCityCode
())){
String
weather
=
gdUtils
.
getWeather
(
feignAddressVO
.
getReceiveAddress
().
getCityCode
());
String
cityCode
=
gdUtils
.
getCity
(
feignAddressVO
.
getReceiveAddress
().
getLongitude
(),
feignAddressVO
.
getReceiveAddress
().
getLatitude
());
String
weather
=
gdUtils
.
getWeather
(
cityCode
);
if
(
weatherCheck
(
weather
)){
// 更新
lineWarnCommonService
.
lineWarnInfoUpdate
(
orderGoods
,
lineWarnInfo
,
lineWarnConfig
,
weather
);
...
...
performance-web/src/main/java/com/clx/performance/utils/gd/GdService.java
浏览文件 @
1ccc8d3b
...
...
@@ -35,6 +35,7 @@ public class GdService {
private
static
final
String
WEATHER_API
=
"https://restapi.amap.com/v3/weather/weatherInfo?parameters"
;
//天气
private
static
final
String
CITY_API
=
"https://restapi.amap.com/v3/geocode/regeo?parameters"
;
//城市
private
String
gaodeKey
=
"b2550e16bbc7bf9f6cd168e0f21709fc"
;
...
...
@@ -405,4 +406,50 @@ public class GdService {
return
weather
;
}
public
String
getCity
(
BigDecimal
longitude
,
BigDecimal
latitude
){
return
getCity
(
gaodeKey
,
longitude
,
latitude
);
}
public
static
String
getCity
(
String
key
,
BigDecimal
longitude
,
BigDecimal
latitude
)
{
String
url
=
CITY_API
+
"?output=json&location="
+
longitude
+
","
+
latitude
+
"&key="
+
key
;
String
resultStr
;
try
{
resultStr
=
HttpUtils
.
httpGetRequest
(
url
);
}
catch
(
Exception
e
)
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德地理编码接口异常"
);
}
if
(
StringUtils
.
isBlank
(
resultStr
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 返回结果空"
);}
JSONObject
retJSONObject
=
JSONObject
.
parseObject
(
resultStr
);
if
(
Objects
.
isNull
(
retJSONObject
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 返回结果转换异常, result:"
+
resultStr
);}
Integer
status
=
retJSONObject
.
getInteger
(
"status"
);
if
(!
Objects
.
equals
(
1
,
status
))
{
if
(
Objects
.
equals
(
10001
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 无效key, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
10002
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 没有权限使用相应的服务或者请求接口的路径拼写错误, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
10003
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 访问已超出日访问量, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
10004
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 单位时间内访问过于频繁, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
10010
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, IP访问超限, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
10044
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 账号维度日调用量超出限制, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
40000
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 余额耗尽, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
40002
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 购买服务到期, result:"
+
resultStr
);}
else
if
(
Objects
.
equals
(
20802
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 路线计算失败, result:"
+
resultStr
);
}
else
if
(
Objects
.
equals
(
20803
,
status
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 起点终点距离过长, result:"
+
resultStr
);
}
else
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德天气接口异常, 状态异常, result:"
+
resultStr
);}
}
// 解析
String
adcode
=
retJSONObject
.
getJSONObject
(
"regeocode"
).
getJSONObject
(
"addressComponent"
).
getString
(
"adcode"
);
if
(
StringUtils
.
isBlank
(
adcode
))
{
throw
new
ServiceSystemException
(
ResultCodeEnum
.
FAIL
,
"调用高德城市编码接口异常, result:"
+
resultStr
);}
return
adcode
;
}
}
performance-web/src/main/java/com/clx/performance/utils/gd/GdUtils.java
浏览文件 @
1ccc8d3b
...
...
@@ -89,6 +89,12 @@ public class GdUtils {
return
gdService
.
getWeather
(
city
);
}
/**
* 天气
*/
public
String
getCity
(
BigDecimal
longitude
,
BigDecimal
latitude
){
return
gdService
.
getCity
(
longitude
,
latitude
);
}
/**
* 获取线路
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论