update - 添加发送钉钉的逻辑
This commit is contained in:
parent
4cc0daa969
commit
cca89c95ed
6
pom.xml
6
pom.xml
@ -21,6 +21,7 @@
|
||||
<lombok.version>1.18.22</lombok.version>
|
||||
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
||||
<mysql.version>8.0.20</mysql.version>
|
||||
<dingtalk.version>2.0.0</dingtalk.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
@ -75,6 +76,11 @@
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||
<version>${dingtalk.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
@ -103,6 +103,10 @@
|
||||
<groupId>cn.axzo.karma</groupId>
|
||||
<artifactId>karma-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibaba-dingtalk-service-sdk</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package cn.axzo.workflow.server.common.util;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiRobotSendRequest;
|
||||
import com.dingtalk.api.response.OapiRobotSendResponse;
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
/**
|
||||
* 钉钉告警处理
|
||||
*
|
||||
* @author wangli
|
||||
* @since 2024/1/12 14:34
|
||||
*/
|
||||
public class DingTalkUtils {
|
||||
|
||||
private static final String dingtalk_robot_webhook = "https://oapi.dingtalk" +
|
||||
".com/robot/send?access_token=341ee2907f3ebc15dc495fb7771a646230058710999fec7838066c109849878e";
|
||||
|
||||
@SneakyThrows
|
||||
public static void sendDingTalk(String profile, Object req, Throwable throwable) {
|
||||
DingTalkClient client = new DefaultDingTalkClient(dingtalk_robot_webhook);
|
||||
OapiRobotSendRequest request = new OapiRobotSendRequest();
|
||||
|
||||
request.setMsgtype("markdown");
|
||||
OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown();
|
||||
markdown.setTitle("Notice 流程实例创建失败, Env: " + profile);
|
||||
markdown.setText("#### [" + profile + "]流程实例创建失败\n" +
|
||||
"> 创建参数: " + JSON.toJSONString(req) + "\n\n" +
|
||||
"> ###### 异常信息: " + JSON.toJSONString(throwable) + " \n");
|
||||
request.setMarkdown(markdown);
|
||||
OapiRobotSendResponse response = client.execute(request);
|
||||
}
|
||||
}
|
||||
@ -16,12 +16,14 @@ import cn.axzo.workflow.common.model.response.bpmn.process.HistoricProcessInstan
|
||||
import cn.axzo.workflow.common.model.response.bpmn.process.ProcessNodeDetailVO;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessInstanceService;
|
||||
import cn.axzo.workflow.server.common.annotation.RepeatSubmit;
|
||||
import cn.axzo.workflow.server.common.util.DingTalkUtils;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -52,6 +54,8 @@ public class BpmnProcessInstanceController implements ProcessInstanceApi {
|
||||
|
||||
@Resource
|
||||
private BpmnProcessInstanceService bpmnProcessInstanceService;
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
/**
|
||||
* 我发起的审批列表
|
||||
@ -72,7 +76,15 @@ public class BpmnProcessInstanceController implements ProcessInstanceApi {
|
||||
@RepeatSubmit
|
||||
public CommonResponse<String> createProcessInstance(@Validated @RequestBody BpmnProcessInstanceCreateDTO dto) {
|
||||
log.info("发起审核createProcessInstance===>>>参数:{}", JSON.toJSONString(dto));
|
||||
String result = bpmnProcessInstanceService.createProcessInstance(dto);
|
||||
|
||||
String result = "";
|
||||
try {
|
||||
result = bpmnProcessInstanceService.createProcessInstance(dto);
|
||||
} catch (Exception e) {
|
||||
log.error("发起审核createProcessInstance===>>>异常:{}", e.getMessage());
|
||||
DingTalkUtils.sendDingTalk(profile, dto, e);
|
||||
return CommonResponse.fail(e.getMessage());
|
||||
}
|
||||
return success(result);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user