Commit d6aa0173 by Ren Ping

fix:消息预警正常改为一般

1 parent 046915fe
......@@ -14,7 +14,7 @@ import java.util.Objects;
*/
public enum MsgTagEnum {
URGENT(0, "紧急"),
NORMAL(1, "正常");
NORMAL(1, "一般");
private Integer code;
private String name;
......
......@@ -77,7 +77,7 @@ public interface IBeanRemoteService {
/**
* 查询分部列表
* 查询分部详情
*
* @param accessToken ACCESS_TOKEN
* @param bsTagId 列表接口查到的bsId
......
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));
}
}
......@@ -11,12 +11,12 @@ spring:
cloud:
nacos:
discovery:
server-addr: 192.168.10.92:8848
server-addr: 127.0.0.1:8848
group: project
username: nacos
password: nacos
config:
server-addr: 192.168.10.92:8848
server-addr: 127.0.0.1:8848
group: project
file-extension: yaml
import-check:
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!