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 d6aa0173
authored
Nov 30, 2023
by
Ren Ping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:消息预警正常改为一般
1 parent
046915fe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
29 deletions
project-order/src/main/java/com/dituhui/pea/order/enums/MsgTagEnum.java
project-order/src/main/java/com/dituhui/pea/order/feign/IBeanRemoteService.java
project-order/src/test/java/com/dituhui/pea/order/common/BeanRemoteServiceTest.java
project-order/src/test/resources/application.yaml
project-order/src/main/java/com/dituhui/pea/order/enums/MsgTagEnum.java
View file @
d6aa017
...
...
@@ -14,7 +14,7 @@ import java.util.Objects;
*/
public
enum
MsgTagEnum
{
URGENT
(
0
,
"紧急"
),
NORMAL
(
1
,
"
正常
"
);
NORMAL
(
1
,
"
一般
"
);
private
Integer
code
;
private
String
name
;
...
...
project-order/src/main/java/com/dituhui/pea/order/feign/IBeanRemoteService.java
View file @
d6aa017
...
...
@@ -77,7 +77,7 @@ public interface IBeanRemoteService {
/**
* 查询分部
列表
* 查询分部
详情
*
* @param accessToken ACCESS_TOKEN
* @param bsTagId 列表接口查到的bsId
...
...
project-order/src/test/java/com/dituhui/pea/order/common/BeanRemoteServiceTest.java
View file @
d6aa017
package
com
.
dituhui
.
pea
.
order
.
common
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.order.OrderServiceApplication
;
import
com.dituhui.pea.order.common.jackson.DateUtil
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.feign.IBeanRemoteService
;
import
com.dituhui.pea.order.feign.bean.AccessToken
;
import
com.dituhui.pea.order.feign.bean.AllotResultParam
;
import
com.dituhui.pea.order.feign.bean.BeanR
;
import
com.dituhui.pea.order.feign.bean.*
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.junit.jupiter.api.Test
;
...
...
@@ -15,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.ActiveProfiles
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
...
...
@@ -23,7 +21,9 @@ import java.time.ZoneId;
@Slf4j
@ActiveProfiles
(
"dev"
)
@SpringBootTest
(
classes
=
OrderServiceApplication
.
class
)
@RequiredArgsConstructor
public
class
BeanRemoteServiceTest
{
private
final
static
String
CACHE_ACCESS_TOKEN_KEY
=
"BEAN:APP:ACCESS_TOKEN"
;
@Value
(
"${bean.app-key}"
)
private
String
appKey
;
...
...
@@ -34,15 +34,50 @@ public class BeanRemoteServiceTest {
@Autowired
private
IBeanRemoteService
beanRemoteService
;
@Autowired
private
RedisService
redisService
;
@Test
public
void
getToken
()
{
getRemoteBeanAccessToken
(
appKey
,
secretKey
);
}
private
String
getAccessToken
()
{
if
(
redisService
.
hasKey
(
CACHE_ACCESS_TOKEN_KEY
))
{
return
redisService
.
get
(
CACHE_ACCESS_TOKEN_KEY
);
}
AccessToken
.
Result
remoteBeanAccessToken
=
getRemoteBeanAccessToken
(
appKey
,
secretKey
);
final
String
accessToken
=
remoteBeanAccessToken
.
getAccess_token
();
//提前500秒到期
final
long
expireTime
=
Long
.
parseLong
(
remoteBeanAccessToken
.
getExpire_time
())
-
(
System
.
currentTimeMillis
()
+
500
*
1000
);
//存REDIS获取
redisService
.
set
(
CACHE_ACCESS_TOKEN_KEY
,
accessToken
,
expireTime
);
return
accessToken
;
}
private
AccessToken
.
Result
getRemoteBeanAccessToken
(
String
appKey
,
String
secretKey
)
{
final
long
timeMillis
=
System
.
currentTimeMillis
();
final
String
verifyCode
=
DigestUtils
.
md5Hex
(
secretKey
+
"_"
+
timeMillis
);
AccessToken
.
Request
requestParam
=
new
AccessToken
.
Request
();
requestParam
.
setTimestamp
(
timeMillis
);
requestParam
.
setAppKey
(
appKey
);
requestParam
.
setVerifyCode
(
verifyCode
);
log
.
info
(
">>> 【获取accessToken】请求参数:{}"
,
JsonUtil
.
toJson
(
requestParam
));
BeanR
<
AccessToken
.
Result
>
accessTokenR
=
beanRemoteService
.
getAccessToken
(
requestParam
);
log
.
info
(
">>> 【获取accessToken】响应结果:{}"
,
JsonUtil
.
toJson
(
accessTokenR
));
if
(!
"0"
.
equals
(
accessTokenR
.
getStatus
()))
{
throw
new
BusinessException
(
"获取 Bean Access Token 失败:"
+
accessTokenR
.
getMessage
());
}
return
accessTokenR
.
getData
();
}
@Test
public
void
updateOrder
()
{
AccessToken
.
Result
tokenResult
=
getRemoteBeanAccessToken
(
appKey
,
secretKey
);
String
accessToken
=
tokenResult
.
getAccess_token
();
String
accessToken
=
getAccessToken
();
AllotResultParam
allotResultParam
=
new
AllotResultParam
();
allotResultParam
.
setRisId
(
"P40125"
);
...
...
@@ -55,24 +90,8 @@ public class BeanRemoteServiceTest {
allotResultParam
.
setAppointmentStartTime
(
startTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
().
toEpochMilli
());
allotResultParam
.
setAppointmentEndTime
(
endTime
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
().
toEpochMilli
());
log
.
info
(
"
[服务工单派单结果更新]【/api/openapi/task/updateAllotResult】请求参数-------------------->
{}"
,
JsonUtil
.
toJson
(
allotResultParam
));
log
.
info
(
"
>>> 【服务工单派单结果更新】请求参数:
{}"
,
JsonUtil
.
toJson
(
allotResultParam
));
BeanR
<?>
beanR
=
beanRemoteService
.
allotResultUpdate
(
accessToken
,
allotResultParam
);
log
.
info
(
"[服务工单派单结果更新]【/api/openapi/task/updateAllotResult】返回值-------------------->{}"
,
JsonUtil
.
toJson
(
beanR
));
}
private
AccessToken
.
Result
getRemoteBeanAccessToken
(
String
appKey
,
String
secretKey
)
{
final
long
timeMillis
=
System
.
currentTimeMillis
();
final
String
verifyCode
=
DigestUtils
.
md5Hex
(
secretKey
+
"_"
+
timeMillis
);
AccessToken
.
Request
requestParam
=
new
AccessToken
.
Request
();
requestParam
.
setTimestamp
(
timeMillis
);
requestParam
.
setAppKey
(
appKey
);
requestParam
.
setVerifyCode
(
verifyCode
);
log
.
info
(
"[BEAN]【BeanRemoteServiceImpl】请求参数------------->{}"
,
JsonUtil
.
toJson
(
requestParam
));
BeanR
<
AccessToken
.
Result
>
accessTokenR
=
beanRemoteService
.
getAccessToken
(
requestParam
);
log
.
info
(
"[BEAN]【BeanRemoteServiceImpl】响应结果------------->{}"
,
JsonUtil
.
toJson
(
accessTokenR
));
return
accessTokenR
.
getData
();
log
.
info
(
">>> 【服务工单派单结果更新】响应结果:{}"
,
JsonUtil
.
toJson
(
beanR
));
}
}
project-order/src/test/resources/application.yaml
View file @
d6aa017
...
...
@@ -11,12 +11,12 @@ spring:
cloud
:
nacos
:
discovery
:
server-addr
:
1
92.168.10.92
:8848
server-addr
:
1
27.0.0.1
:8848
group
:
project
username
:
nacos
password
:
nacos
config
:
server-addr
:
1
92.168.10.92
:8848
server-addr
:
1
27.0.0.1
:8848
group
:
project
file-extension
:
yaml
import-check
:
...
...
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