mirror of https://github.com/ZhongFuCheng3y/austin
commit
9eea4e256f
@ -1,38 +0,0 @@
|
||||
package com.java3y.austin.common.dto.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
* 钉钉 自定义机器人 + 工作通知
|
||||
* <p>
|
||||
* https://open.dingtalk.com/document/group/custom-robot-access
|
||||
* <p>
|
||||
* https://open.dingtalk.com/document/orgapp-server/asynchronous-sending-of-enterprise-session-messages
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DingDingContentModel extends ContentModel {
|
||||
|
||||
/**
|
||||
* 发送类型
|
||||
*/
|
||||
private String sendType;
|
||||
|
||||
/**
|
||||
* 【文本消息】需要发送的内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 图片、文件、语音消息 需要发送使用的素材ID字段
|
||||
*/
|
||||
private String mediaId;
|
||||
|
||||
// ...
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.java3y.austin.handler.domain.sms;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 对于每种消息类型的 短信配置
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MessageTypeSmsConfig {
|
||||
|
||||
/**
|
||||
* 权重(决定着流量的占比)
|
||||
*/
|
||||
private Integer weights;
|
||||
|
||||
/**
|
||||
* script名称
|
||||
*/
|
||||
private String scriptName;
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.java3y.austin.handler.domain.sms;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 云片网短信调用发送接口返回值
|
||||
* @author 3y
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class YunPianSendResult {
|
||||
|
||||
/**
|
||||
* totalCount
|
||||
*/
|
||||
@JSONField(name = "total_count")
|
||||
private Integer totalCount;
|
||||
/**
|
||||
* totalFee
|
||||
*/
|
||||
@JSONField(name = "total_fee")
|
||||
private String totalFee;
|
||||
/**
|
||||
* unit
|
||||
*/
|
||||
@JSONField(name = "unit")
|
||||
private String unit;
|
||||
/**
|
||||
* data
|
||||
*/
|
||||
@JSONField(name = "data")
|
||||
private List<DataDTO> data;
|
||||
|
||||
/**
|
||||
* DataDTO
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public static class DataDTO {
|
||||
/**
|
||||
* httpStatusCode
|
||||
*/
|
||||
@JSONField(name = "http_status_code")
|
||||
private Integer httpStatusCode;
|
||||
/**
|
||||
* code
|
||||
*/
|
||||
@JSONField(name = "code")
|
||||
private Integer code;
|
||||
/**
|
||||
* msg
|
||||
*/
|
||||
@JSONField(name = "msg")
|
||||
private String msg;
|
||||
/**
|
||||
* count
|
||||
*/
|
||||
@JSONField(name = "count")
|
||||
private Integer count;
|
||||
/**
|
||||
* fee
|
||||
*/
|
||||
@JSONField(name = "fee")
|
||||
private Integer fee;
|
||||
/**
|
||||
* unit
|
||||
*/
|
||||
@JSONField(name = "unit")
|
||||
private String unit;
|
||||
/**
|
||||
* mobile
|
||||
*/
|
||||
@JSONField(name = "mobile")
|
||||
private String mobile;
|
||||
/**
|
||||
* sid
|
||||
*/
|
||||
@JSONField(name = "sid")
|
||||
private String sid;
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.java3y.austin.handler.receipt;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.java3y.austin.common.constant.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.TencentSmsAccount;
|
||||
import com.java3y.austin.common.enums.SmsStatus;
|
||||
import com.java3y.austin.support.config.SupportThreadPoolConfig;
|
||||
import com.java3y.austin.support.domain.SmsRecord;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatus;
|
||||
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusRequest;
|
||||
import com.tencentcloudapi.sms.v20210111.models.PullSmsSendStatusResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拉取短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsReceipt {
|
||||
|
||||
@Autowired
|
||||
private TencentSmsReceipt tencentSmsReceipt;
|
||||
|
||||
@Autowired
|
||||
private YunPianSmsReceipt yunPianSmsReceipt;
|
||||
|
||||
@PostConstruct
|
||||
private void init() {
|
||||
SupportThreadPoolConfig.getPendingSingleThreadPool().execute(() -> {
|
||||
while (true) {
|
||||
|
||||
// TODO 回执这里自行打开(免得报错)
|
||||
// tencentSmsReceipt.pull();
|
||||
// yunPianSmsReceipt.pull();
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package com.java3y.austin.handler.receipt;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.java3y.austin.common.constant.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.TencentSmsAccount;
|
||||
import com.java3y.austin.common.enums.SmsStatus;
|
||||
import com.java3y.austin.support.config.SupportThreadPoolConfig;
|
||||
import com.java3y.austin.support.dao.SmsRecordDao;
|
||||
import com.java3y.austin.support.domain.SmsRecord;
|
||||
import com.java3y.austin.support.utils.AccountUtils;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||
import com.tencentcloudapi.sms.v20210111.models.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 拉取腾讯云短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TencentSmsReceipt {
|
||||
|
||||
|
||||
@Autowired
|
||||
private AccountUtils accountUtils;
|
||||
|
||||
@Autowired
|
||||
private SmsRecordDao smsRecordDao;
|
||||
|
||||
|
||||
/**
|
||||
* 拉取消息并入库
|
||||
*/
|
||||
public void pull() {
|
||||
|
||||
// 获取腾讯云账号信息
|
||||
TencentSmsAccount account = accountUtils.getAccount(10, SendAccountConstant.SMS_ACCOUNT_KEY, SendAccountConstant.SMS_PREFIX, TencentSmsAccount.class);
|
||||
try {
|
||||
SmsClient client = getSmsClient(account);
|
||||
|
||||
// 每次拉取10条
|
||||
PullSmsSendStatusRequest req = new PullSmsSendStatusRequest();
|
||||
req.setLimit(10L);
|
||||
req.setSmsSdkAppId(account.getSmsSdkAppId());
|
||||
|
||||
PullSmsSendStatusResponse resp = client.PullSmsSendStatus(req);
|
||||
List<SmsRecord> smsRecordList = new ArrayList<>();
|
||||
if (resp != null && resp.getPullSmsSendStatusSet() != null && resp.getPullSmsSendStatusSet().length > 0) {
|
||||
log.debug("receipt sms:{}", JSON.toJSONString(resp.getPullSmsSendStatusSet()));
|
||||
for (PullSmsSendStatus pullSmsSendStatus : resp.getPullSmsSendStatusSet()) {
|
||||
SmsRecord smsRecord = SmsRecord.builder()
|
||||
.sendDate(Integer.valueOf(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN)))
|
||||
.messageTemplateId(0L)
|
||||
.phone(Long.valueOf(pullSmsSendStatus.getSubscriberNumber()))
|
||||
.supplierId(account.getSupplierId())
|
||||
.supplierName(account.getSupplierName())
|
||||
.msgContent("")
|
||||
.seriesId(pullSmsSendStatus.getSerialNo())
|
||||
.chargingNum(0)
|
||||
.status("SUCCESS".equals(pullSmsSendStatus.getReportStatus()) ? SmsStatus.RECEIVE_SUCCESS.getCode() : SmsStatus.RECEIVE_FAIL.getCode())
|
||||
.reportContent(pullSmsSendStatus.getDescription())
|
||||
.updated(Math.toIntExact(pullSmsSendStatus.getUserReceiveTime()))
|
||||
.created(Math.toIntExact(DateUtil.currentSeconds()))
|
||||
.build();
|
||||
smsRecordList.add(smsRecord);
|
||||
}
|
||||
}
|
||||
if (!CollUtil.isEmpty(smsRecordList)) {
|
||||
smsRecordDao.saveAll(smsRecordList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("TencentSmsReceipt#init fail!{}", Throwables.getStackTraceAsString(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造smsClient
|
||||
*
|
||||
* @param account
|
||||
* @return
|
||||
*/
|
||||
private SmsClient getSmsClient(TencentSmsAccount account) {
|
||||
Credential cred = new Credential(account.getSecretId(), account.getSecretKey());
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint(account.getUrl());
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
return new SmsClient(cred, account.getRegion(), clientProfile);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.java3y.austin.handler.receipt;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 拉取云片网短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class YunPianSmsReceipt {
|
||||
/**
|
||||
* 拉取消息并入库
|
||||
*/
|
||||
public void pull() {
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
/**
|
||||
* sms发送脚本的抽象类
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class BaseSmsScript implements SmsScript {
|
||||
|
||||
@Autowired
|
||||
private SmsScriptHolder smsScriptHolder;
|
||||
|
||||
@PostConstruct
|
||||
public void registerProcessScript() {
|
||||
if (ArrayUtils.isEmpty(this.getClass().getAnnotations())) {
|
||||
log.error("BaseSmsScript can not find annotation!");
|
||||
return;
|
||||
}
|
||||
Annotation handlerAnnotations = null;
|
||||
for (Annotation annotation : this.getClass().getAnnotations()) {
|
||||
if (annotation instanceof SmsScriptHandler) {
|
||||
handlerAnnotations = annotation;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (handlerAnnotations == null) {
|
||||
log.error("handler annotations not declared");
|
||||
return;
|
||||
}
|
||||
//注册handler
|
||||
smsScriptHolder.putHandler(((SmsScriptHandler) handlerAnnotations).value(), this);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* 标识 短信渠道
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Component
|
||||
public @interface SmsScriptHandler {
|
||||
|
||||
/**
|
||||
* 这里输入脚本名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String value();
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* sendAccount->SmsScript的映射关系
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
public class SmsScriptHolder {
|
||||
|
||||
private Map<String, SmsScript> handlers = new HashMap<>(8);
|
||||
|
||||
public void putHandler(String scriptName, SmsScript handler) {
|
||||
handlers.put(scriptName, handler);
|
||||
}
|
||||
public SmsScript route(String scriptName) {
|
||||
return handlers.get(scriptName);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
package com.java3y.austin.handler.wechat;
|
||||
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatMiniProgramParam;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.java3y.austin.handler.script;
|
||||
package com.java3y.austin.handler.wechat;
|
||||
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatOfficialParam;
|
||||
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
@ -1,9 +1,9 @@
|
||||
package com.java3y.austin.handler.script.impl;
|
||||
package com.java3y.austin.handler.wechat.impl;
|
||||
|
||||
import com.java3y.austin.common.constant.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.WeChatOfficialAccount;
|
||||
import com.java3y.austin.handler.domain.wechat.WeChatOfficialParam;
|
||||
import com.java3y.austin.handler.script.OfficialAccountService;
|
||||
import com.java3y.austin.handler.wechat.OfficialAccountService;
|
||||
import com.java3y.austin.support.utils.AccountUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
@ -0,0 +1,67 @@
|
||||
package com.java3y.austin.web.vo.amis;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 3y
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SmsTimeLineVo {
|
||||
|
||||
/**
|
||||
* items
|
||||
*/
|
||||
private List<SmsTimeLineVo.ItemsVO> items;
|
||||
|
||||
/**
|
||||
* ItemsVO
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public static class ItemsVO {
|
||||
/**
|
||||
* 业务ID
|
||||
*/
|
||||
private String businessId;
|
||||
/**
|
||||
* detail 发送内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 发送状态
|
||||
*/
|
||||
private String sendType;
|
||||
|
||||
/**
|
||||
* 回执状态
|
||||
*/
|
||||
private String receiveType;
|
||||
|
||||
/**
|
||||
* 回执报告
|
||||
*/
|
||||
private String receiveContent;
|
||||
|
||||
/**
|
||||
* 发送时间
|
||||
*/
|
||||
private String sendTime;
|
||||
|
||||
/**
|
||||
* 回执时间
|
||||
*/
|
||||
private String receiveTime;
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue