提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.bpm.service.message; |
H |
2 |
|
|
3 |
import com.iailab.framework.web.config.WebProperties; |
|
4 |
import com.iailab.module.bpm.convert.message.BpmMessageConvert; |
|
5 |
import com.iailab.module.bpm.enums.message.BpmMessageEnum; |
|
6 |
import com.iailab.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceApproveReqDTO; |
|
7 |
import com.iailab.module.bpm.service.message.dto.BpmMessageSendWhenProcessInstanceRejectReqDTO; |
|
8 |
import com.iailab.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO; |
bb2880
|
9 |
import com.iailab.module.bpm.service.message.dto.BpmMessageSendWhenTaskTimeoutReqDTO; |
e7c126
|
10 |
import com.iailab.module.system.api.sms.SmsSendApi; |
H |
11 |
import lombok.extern.slf4j.Slf4j; |
|
12 |
import org.springframework.stereotype.Service; |
|
13 |
import org.springframework.validation.annotation.Validated; |
|
14 |
|
|
15 |
import javax.annotation.Resource; |
|
16 |
import java.util.HashMap; |
|
17 |
import java.util.Map; |
|
18 |
|
|
19 |
/** |
|
20 |
* BPM 消息 Service 实现类 |
|
21 |
* |
|
22 |
* @author iailab |
|
23 |
*/ |
|
24 |
@Service |
|
25 |
@Validated |
|
26 |
@Slf4j |
|
27 |
public class BpmMessageServiceImpl implements BpmMessageService { |
|
28 |
|
|
29 |
@Resource |
|
30 |
private SmsSendApi smsSendApi; |
|
31 |
|
|
32 |
@Resource |
|
33 |
private WebProperties webProperties; |
|
34 |
|
|
35 |
@Override |
|
36 |
public void sendMessageWhenProcessInstanceApprove(BpmMessageSendWhenProcessInstanceApproveReqDTO reqDTO) { |
|
37 |
Map<String, Object> templateParams = new HashMap<>(); |
|
38 |
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); |
|
39 |
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); |
|
40 |
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), |
|
41 |
BpmMessageEnum.PROCESS_INSTANCE_APPROVE.getSmsTemplateCode(), templateParams)); |
|
42 |
} |
|
43 |
|
|
44 |
@Override |
|
45 |
public void sendMessageWhenProcessInstanceReject(BpmMessageSendWhenProcessInstanceRejectReqDTO reqDTO) { |
|
46 |
Map<String, Object> templateParams = new HashMap<>(); |
|
47 |
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); |
|
48 |
templateParams.put("reason", reqDTO.getReason()); |
|
49 |
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); |
|
50 |
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getStartUserId(), |
|
51 |
BpmMessageEnum.PROCESS_INSTANCE_REJECT.getSmsTemplateCode(), templateParams)); |
|
52 |
} |
|
53 |
|
|
54 |
@Override |
|
55 |
public void sendMessageWhenTaskAssigned(BpmMessageSendWhenTaskCreatedReqDTO reqDTO) { |
|
56 |
Map<String, Object> templateParams = new HashMap<>(); |
|
57 |
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); |
|
58 |
templateParams.put("taskName", reqDTO.getTaskName()); |
|
59 |
templateParams.put("startUserNickname", reqDTO.getStartUserNickname()); |
|
60 |
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); |
|
61 |
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), |
|
62 |
BpmMessageEnum.TASK_ASSIGNED.getSmsTemplateCode(), templateParams)); |
|
63 |
} |
|
64 |
|
bb2880
|
65 |
@Override |
H |
66 |
public void sendMessageWhenTaskTimeout(BpmMessageSendWhenTaskTimeoutReqDTO reqDTO) { |
|
67 |
Map<String, Object> templateParams = new HashMap<>(); |
|
68 |
templateParams.put("processInstanceName", reqDTO.getProcessInstanceName()); |
|
69 |
templateParams.put("taskName", reqDTO.getTaskName()); |
|
70 |
templateParams.put("detailUrl", getProcessInstanceDetailUrl(reqDTO.getProcessInstanceId())); |
|
71 |
smsSendApi.sendSingleSmsToAdmin(BpmMessageConvert.INSTANCE.convert(reqDTO.getAssigneeUserId(), |
|
72 |
BpmMessageEnum.TASK_TIMEOUT.getSmsTemplateCode(), templateParams)).checkError(); |
|
73 |
} |
|
74 |
|
e7c126
|
75 |
private String getProcessInstanceDetailUrl(String taskId) { |
H |
76 |
return webProperties.getAdminUi().getUrl() + "/bpm/process-instance/detail?id=" + taskId; |
|
77 |
} |
|
78 |
|
|
79 |
} |