ems 异常通知

yun-zuoyi
zhang.xw 3 years ago
parent 01644081a5
commit 6559511a76

@ -1171,9 +1171,12 @@ public class WhiteController extends CoreBaseController {
private static final Long ACCESS_TOKEN_EXPIRE_TIME = 7080L;
private static final String ACCESS_TOKEN_KEY = "ding_talk:access_token";
private static final String ACCESS_EMS_TOKEN_KEY = "ding_talk_ems:access_token";
private static final String ACCESS_MENU_TOKEN_KEY = "ding_talk:menu_access_token";
/**
*
*
@ -1248,7 +1251,7 @@ public class WhiteController extends CoreBaseController {
return ResultBean.fail(e).setMsg("发送失败");
}
BatchSendOTOHeaders batchSendOTOHeaders = new BatchSendOTOHeaders();
batchSendOTOHeaders.xAcsDingtalkAccessToken = getAccessToken();
batchSendOTOHeaders.xAcsDingtalkAccessToken = getAccessToken(dingSendBatchRequestModel.getSoftType());
BatchSendOTORequest batchSendOTORequest = new BatchSendOTORequest();
List<String> userIdList = new ArrayList<String>();
phoneNumberList.forEach(el -> {
@ -1267,6 +1270,9 @@ public class WhiteController extends CoreBaseController {
// userIdList.add("070537336424114523");
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
if (Objects.equals(dingSendBatchRequestModel.getSoftType(), "ems")) {
dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_EMS_APP_KEY);
}
batchSendOTORequest.setRobotCode(dingTalkAppKey);
batchSendOTORequest.setUserIds(userIdList);
// markdown officialImageMsg
@ -1351,18 +1357,27 @@ public class WhiteController extends CoreBaseController {
*
* @return
*/
private String getAccessToken() {
Object accessTokenCached = redisCore.getObject(ACCESS_TOKEN_KEY);
private String getAccessToken(String softType) {
String accessTokenKey = ACCESS_TOKEN_KEY;
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET);
if (Objects.equals(softType, "ems")) {
accessTokenKey = ACCESS_EMS_TOKEN_KEY;
dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_EMS_APP_KEY);
dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_EMS_APP_SECRET);
}
Object accessTokenCached = redisCore.getObject(accessTokenKey);
if (accessTokenCached != null) {
LOGGER.info("通过缓存获取到的钉钉token, key={},value={}", ACCESS_TOKEN_KEY, accessTokenCached);
LOGGER.info("通过缓存获取andon到的钉钉token, key={},value={}", accessTokenKey, accessTokenCached);
return String.valueOf(accessTokenCached);
}
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkoauth2_1_0.Client client = null;
String dingTalkAppKey = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_KEY);
String dingTalkAppSecret = RedisCacheTool.getSysConfigStrVal(PlatformConstWords.DINGTALK_APP_SECRET);
try {
client = new com.aliyun.dingtalkoauth2_1_0.Client(config);
} catch (Exception e) {
@ -1374,8 +1389,8 @@ public class WhiteController extends CoreBaseController {
try {
GetAccessTokenResponse response = client.getAccessToken(getAccessTokenRequest);
if (!StringUtils.isEmpty(response.body.accessToken)) {
LOGGER.info("插入钉钉token缓存, key={},value={}", ACCESS_TOKEN_KEY, response.body.accessToken);
redisCore.putObject(ACCESS_TOKEN_KEY, response.body.accessToken, ACCESS_TOKEN_EXPIRE_TIME);
LOGGER.info("插入钉钉token缓存, key={},value={}", accessTokenKey, response.body.accessToken);
redisCore.putObject(accessTokenKey, response.body.accessToken, ACCESS_TOKEN_EXPIRE_TIME);
}
return response.body.accessToken;
} catch (TeaException err) {

@ -11,7 +11,7 @@ logging.config=classpath:log4j2-spring-dev.xml
########\u5E73\u53F0\u76F8\u5173\u53C2\u6570##########
#\u662F\u5426\u5F00\u542Fredis\u7F13\u5B58
impp.config.redis=true
#impp.config.redis=true
#\u662F\u5426\u5F00\u542FrabbitMQ
impp.config.rabbitmq=true
#\u662F\u5426\u5F00\u542Fswagger
@ -115,6 +115,14 @@ redis.hostName=192.168.1.55
redis.port=16376
#\u5982\u679C\u6709\u5BC6\u7801
redis.password=
impp.config.redis=false
impp.config.sentinel.redis = true
spring.redis.sentinel.master=mymaster
spring.redis.sentinel.password =
spring.redis.sentinel.nodes= 192.168.2.246:6382,192.168.2.246:6383,192.168.2.246:6384
##\u5176\u4ED6redis\u914D\u7F6E\u9700\u8981\u8C03\u6574\u7684\u52A0\u5728\u6B64\u5904
################## rabbitMQ\u914D\u7F6E ####################
spring.rabbitmq.vhost=/

@ -7,13 +7,13 @@
<Property name="log4j2.level" value="INFO"/>
<!-- 日志输出格式 -->
<Property name="info_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %p %c(%M:%L) - %m%n</Property>
<Property name="info_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%X{traceId}] %p %c(%M:%L) - %m%n</Property>
</Properties>
<appenders>
<!-- impp 日志拦截 -->
<ImppLog4j2Appender name="impp_log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %t [%c{1.}(%M:%L)] ==>> %msg%xEx"/>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %t %X{traceId} [%c{1.}(%M:%L)] ==>> %msg%xEx"/>
</ImppLog4j2Appender>
<!--控制台日志-->

@ -10,14 +10,14 @@
<Property name="logFileRootPath" value="../logs"/>
<Property name="project.name" value="i3core"/>
<!-- 日志输出格式 -->
<Property name="info_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %p %c(%M:%L) - %m%n</Property>
<Property name="file_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %p %-5level %class{36} %L %M - %msg%xEx%n</Property>
<Property name="info_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%X{traceId}] %p %c(%M:%L) - %m%n</Property>
<Property name="file_pattern">%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] [%X{traceId}] %p %-5level %class{36} %L %M - %msg%xEx%n</Property>
</Properties>
<appenders>
<!-- impp 日志拦截 -->
<ImppLog4j2Appender name="impp_log">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %t [%c{1.}(%M:%L)] ==>> %msg%xEx"/>
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5p %t %X{traceId} [%c{1.}(%M:%L)] ==>> %msg%xEx"/>
</ImppLog4j2Appender>
<!-- 应用日志文件-->

Loading…
Cancel
Save