123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package com.fdkankan.contro.service.impl;
- import cn.hutool.core.util.StrUtil;
- import com.fdkankan.contro.service.IBuildSceneDTService;
- import com.fdkankan.dingtalk.DingTalkSendUtils;
- import com.fdkankan.fyun.config.FYunFileConfig;
- import com.taobao.api.ApiException;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import java.io.UnsupportedEncodingException;
- import java.security.InvalidKeyException;
- import java.security.NoSuchAlgorithmException;
- import java.util.concurrent.CompletableFuture;
- /**
- * <p>
- * TODO
- * </p>
- *
- * @author dengsixing
- * @since 2022/4/20
- **/
- @Slf4j
- @Service
- public class BuildSceneDTServiceImpl implements IBuildSceneDTService {
- public static final String DINGTALK_MSG_PATTERN = "**环境**: %s\n\n" +
- "**服务器名称**: %s\n\n" +
- "**失败原因**: %s\n\n" +
- "**num**: %s\n\n" +
- "**server-path**: %s\n\n";
- public static final String contentExt = "**algorithm-log**: [%sbuild_log/%s/console.log](%sbuild_log/%s/console.log)";
- @Autowired
- private DingTalkSendUtils dingTalkSendUtils;
- @Autowired
- private FYunFileConfig fYunFileConfig;
- @Value("${main.url}")
- private String mainUrl;
- @Override
- public void handModelFail(String reason, String serverPath, String num, String hostName) {
- String logPath = String.format(contentExt,fYunFileConfig.getHost(),num,fYunFileConfig.getHost(),num);
- this.handModelFail(reason, serverPath, num, hostName, logPath);
- }
- @Override
- public void handModelFail(String reason, String serverPath, String num, String hostName, String logPath) {
- try {
- log.info("发送钉钉消息,content:{}", logPath);
- String content = String.format(this.DINGTALK_MSG_PATTERN, this.mainUrl, hostName, reason, num, serverPath) + logPath;
- log.info("发送钉钉消息,content:{}", content);
- dingTalkSendUtils.sendActioncardMsgToDingRobot(content,"场景计算失败");
- } catch (ApiException | UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException apiException) {
- log.error("发送钉钉消息失败", apiException);
- }
- }
- @Override
- public void handBaseFail(String reason, String serverPath, String num, String hostName) {
- try {
- String content = String.format(this.DINGTALK_MSG_PATTERN, this.mainUrl, hostName, reason, num, serverPath);
- log.info("发送钉钉消息,content:{}", content);
- dingTalkSendUtils.sendActioncardMsgToDingRobot(content,"场景计算失败");
- } catch (ApiException | UnsupportedEncodingException | NoSuchAlgorithmException | InvalidKeyException apiException) {
- log.error("发送钉钉消息失败", apiException);
- }
- }
- }
|