添加短信服务接口和转辙机发送短信告警信息功能
This commit is contained in:
parent
d21863effd
commit
de74214d67
@ -12,6 +12,8 @@ public enum TencentSMSTemplate {
|
||||
VerificationCode_International("JiuLian", 453984, 2),
|
||||
OrderNotice("玖琏科技", 260120, 4),
|
||||
SystemNotice("玖琏科技", 0000, 3),
|
||||
|
||||
ZzjAlertNotice("玖琏科技", 1206126, 2),
|
||||
;
|
||||
|
||||
private String sign;
|
||||
|
@ -0,0 +1,42 @@
|
||||
package club.joylink.rtss.controller;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.ISmsService;
|
||||
import club.joylink.rtss.vo.SmsResponse;
|
||||
import club.joylink.rtss.vo.sms.ZzjAlertSmsParamVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 短信接口
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/sms")
|
||||
public class SmsController {
|
||||
@Autowired
|
||||
private ISmsService iSmsService;
|
||||
|
||||
@PostMapping("/zzjAlert")
|
||||
public void sendZzjAlert(@RequestBody ZzjAlertSmsParamVo paramVo) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL
|
||||
.assertTrue(paramVo.isValidRequest());
|
||||
long ts = System.currentTimeMillis();
|
||||
List<String> params = new ArrayList<>();
|
||||
params.add(paramVo.getDeviceName());
|
||||
params.add(paramVo.getDescription());
|
||||
SmsResponse resp = this.iSmsService.sendZzjAlertNotice(paramVo.getMobile(),
|
||||
paramVo.getNationCode(), params, ts);
|
||||
BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.assertTrue(resp.getResult() == 0,
|
||||
String.format("短信发送服务调用异常:[result: %s, errmsg: %s]", resp.getResult(), resp.getErrmsg()));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -22,6 +22,8 @@ public interface ISmsService {
|
||||
*/
|
||||
SmsResponse sendValidateCode(String mobile, String nationCode, List<String> params, long ts);
|
||||
|
||||
SmsResponse sendZzjAlertNotice(String mobile, String nationCode, List<String> parmas, long ts);
|
||||
|
||||
/**
|
||||
* 发送订单通知
|
||||
*/
|
||||
|
@ -114,6 +114,11 @@ public class TcSmsService implements ISmsService {
|
||||
return sendToOneOnTpl(template, mobile, nationCode, params, ts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsResponse sendZzjAlertNotice(String mobile, String nationCode, List<String> parmas, long ts) {
|
||||
return sendToOneOnTpl(TencentSMSTemplate.ZzjAlertNotice, mobile, nationCode, parmas, ts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmsResponse sendOrderNotice(List<InternationalMobile> internationalMobileList, List<String> params) {
|
||||
return sendToMultiOnTpl(TencentSMSTemplate.OrderNotice, internationalMobileList, params);
|
||||
|
27
src/main/java/club/joylink/rtss/vo/sms/SmsParamVo.java
Normal file
27
src/main/java/club/joylink/rtss/vo/sms/SmsParamVo.java
Normal file
@ -0,0 +1,27 @@
|
||||
package club.joylink.rtss.vo.sms;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class SmsParamVo {
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 国际码
|
||||
*/
|
||||
private String nationCode = "86";
|
||||
/**
|
||||
* 请求校验
|
||||
*/
|
||||
String checksum;
|
||||
|
||||
public abstract String calCheckSum();
|
||||
|
||||
public boolean isValidRequest() {
|
||||
return this.calCheckSum().equals(checksum);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package club.joylink.rtss.vo.sms;
|
||||
|
||||
import club.joylink.rtss.util.EncryptUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 转辙机告警短信消息参数
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class ZzjAlertSmsParamVo extends SmsParamVo {
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String deviceName;
|
||||
/**
|
||||
* 故障描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
@Override
|
||||
public String calCheckSum() {
|
||||
return EncryptUtil.md5(String.format("[%s]-%s::%s::%s", "joylink", this.getMobile(), this.deviceName, this.description));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user