mirror of https://github.com/ZhongFuCheng3y/austin
commit
6ac0f13ba5
@ -0,0 +1,37 @@
|
||||
package com.java3y.austin.common.enums;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* 短信渠道商
|
||||
* @author 3y
|
||||
*/
|
||||
@Getter
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
public enum SmsSupplier {
|
||||
|
||||
|
||||
TENCENT(10,"腾讯渠道商"),
|
||||
YUN_PAIN(20,"云片渠道商");
|
||||
private Integer code;
|
||||
private String description;
|
||||
|
||||
|
||||
/**
|
||||
* 根据状态获取描述信息
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public static String getDescriptionByStatus(Integer code) {
|
||||
for (SmsStatus value : SmsStatus.values()) {
|
||||
if (value.getCode().equals(code)) {
|
||||
return value.getDescription();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package com.java3y.austin.handler.receipt;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.dingtalk.api.DefaultDingTalkClient;
|
||||
import com.dingtalk.api.DingTalkClient;
|
||||
import com.dingtalk.api.request.OapiMessageCorpconversationGetsendresultRequest;
|
||||
import com.dingtalk.api.response.OapiMessageCorpconversationGetsendresultResponse;
|
||||
import com.java3y.austin.common.constant.SendAccountConstant;
|
||||
import com.java3y.austin.common.dto.account.DingDingWorkNoticeAccount;
|
||||
import com.java3y.austin.support.utils.AccountUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 拉取钉钉工作消息回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DingDingWorkReceipt {
|
||||
|
||||
private static final String URL = "https://oapi.dingtalk.com/topapi/message/corpconversation/getsendresult";
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private AccountUtils accountUtils;
|
||||
public void pull() {
|
||||
// try {
|
||||
// for (int index = SendAccountConstant.START; true; index = index + SendAccountConstant.STEP) {
|
||||
// DingDingWorkNoticeAccount account = accountUtils.getAccount(index, SendAccountConstant.DING_DING_WORK_NOTICE_ACCOUNT_KEY, SendAccountConstant.DING_DING_WORK_NOTICE_PREFIX, DingDingWorkNoticeAccount.class);
|
||||
// if (account == null) {
|
||||
// break;
|
||||
// }
|
||||
// String accessToken = redisTemplate.opsForValue().get(SendAccountConstant.DING_DING_ACCESS_TOKEN_PREFIX + index);
|
||||
// DingTalkClient client = new DefaultDingTalkClient(URL);
|
||||
// OapiMessageCorpconversationGetsendresultRequest req = new OapiMessageCorpconversationGetsendresultRequest();
|
||||
// req.setAgentId(Long.valueOf(account.getAgentId()));
|
||||
// req.setTaskId(456L);
|
||||
// OapiMessageCorpconversationGetsendresultResponse rsp = client.execute(req, accessToken);
|
||||
// System.out.println(rsp.getBody());
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// log.error("DingDingWorkReceipt#pull");
|
||||
// }
|
||||
}
|
||||
}
|
@ -1,108 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
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,14 @@
|
||||
package com.java3y.austin.handler.receipt.stater;
|
||||
|
||||
/**
|
||||
* 拉取回执信息 启动器
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
public interface ReceiptMessageStater {
|
||||
|
||||
/**
|
||||
* 启动拉取回执
|
||||
*/
|
||||
void start();
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.java3y.austin.handler.receipt.stater.impl;
|
||||
|
||||
import com.java3y.austin.common.constant.CommonConstant;
|
||||
import com.java3y.austin.common.enums.ChannelType;
|
||||
import com.java3y.austin.handler.handler.impl.DingDingWorkNoticeHandler;
|
||||
import com.java3y.austin.handler.receipt.stater.ReceiptMessageStater;
|
||||
import com.java3y.austin.support.dao.ChannelAccountDao;
|
||||
import com.java3y.austin.support.domain.ChannelAccount;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 拉取 钉钉工作消息的回执 内容 【未完成】
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
public class DingDingWorkReceiptStaterImpl implements ReceiptMessageStater {
|
||||
|
||||
@Autowired
|
||||
private DingDingWorkNoticeHandler workNoticeHandler;
|
||||
|
||||
@Autowired
|
||||
private ChannelAccountDao channelAccountDao;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
List<ChannelAccount> accountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.DING_DING_WORK_NOTICE.getCode());
|
||||
for (ChannelAccount channelAccount : accountList) {
|
||||
workNoticeHandler.pull(channelAccount.getId());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.java3y.austin.handler.receipt.stater.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.java3y.austin.common.constant.CommonConstant;
|
||||
import com.java3y.austin.common.dto.account.sms.SmsAccount;
|
||||
import com.java3y.austin.common.enums.ChannelType;
|
||||
import com.java3y.austin.handler.receipt.stater.ReceiptMessageStater;
|
||||
import com.java3y.austin.handler.script.SmsScript;
|
||||
import com.java3y.austin.support.dao.ChannelAccountDao;
|
||||
import com.java3y.austin.support.dao.SmsRecordDao;
|
||||
import com.java3y.austin.support.domain.ChannelAccount;
|
||||
import com.java3y.austin.support.domain.SmsRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 拉取短信回执信息
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SmsPullReceiptStarterImpl implements ReceiptMessageStater {
|
||||
|
||||
@Autowired
|
||||
private ChannelAccountDao channelAccountDao;
|
||||
|
||||
@Autowired
|
||||
private Map<String, SmsScript> scriptMap;
|
||||
|
||||
@Autowired
|
||||
private SmsRecordDao smsRecordDao;
|
||||
|
||||
/**
|
||||
* 拉取消息并入库
|
||||
*/
|
||||
public void start() {
|
||||
try {
|
||||
List<ChannelAccount> channelAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.SMS.getCode());
|
||||
for (ChannelAccount channelAccount : channelAccountList) {
|
||||
SmsAccount smsAccount = JSON.parseObject(channelAccount.getAccountConfig(), SmsAccount.class);
|
||||
List<SmsRecord> smsRecordList = scriptMap.get(smsAccount.getScriptName()).pull(smsAccount.getScriptName());
|
||||
if (CollUtil.isNotEmpty(smsRecordList)) {
|
||||
smsRecordDao.saveAll(smsRecordList);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SmsPullReceiptStarter#start fail:{}", Throwables.getStackTraceAsString(e));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.java3y.austin.support.utils;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.java3y.austin.common.constant.CommonConstant;
|
||||
import com.java3y.austin.common.dto.account.WeChatOfficialAccount;
|
||||
import com.java3y.austin.common.enums.ChannelType;
|
||||
import com.java3y.austin.support.dao.ChannelAccountDao;
|
||||
import com.java3y.austin.support.domain.ChannelAccount;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信服务号/微信小程序 工具类
|
||||
*
|
||||
* @author 3y
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WxServiceUtils {
|
||||
|
||||
public static Map<Long, WxMpService> wxMpServiceMap = new HashMap<>();
|
||||
public static Map<Long, WeChatOfficialAccount> accountHashMap = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
private ChannelAccountDao channelAccountDao;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
List<ChannelAccount> officialAccountList = channelAccountDao.findAllByIsDeletedEqualsAndSendChannelEquals(CommonConstant.FALSE, ChannelType.OFFICIAL_ACCOUNT.getCode());
|
||||
for (ChannelAccount channelAccount : officialAccountList) {
|
||||
WeChatOfficialAccount weChatOfficialAccount = JSON.parseObject(channelAccount.getAccountConfig(), WeChatOfficialAccount.class);
|
||||
wxMpServiceMap.put(channelAccount.getId(), initService(weChatOfficialAccount));
|
||||
accountHashMap.put(channelAccount.getId(), weChatOfficialAccount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化微信服务号
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WxMpService initService(WeChatOfficialAccount officialAccount) {
|
||||
WxMpService wxMpService = new WxMpServiceImpl();
|
||||
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
|
||||
config.setAppId(officialAccount.getAppId());
|
||||
config.setSecret(officialAccount.getSecret());
|
||||
wxMpService.setWxMpConfigStorage(config);
|
||||
return wxMpService;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.java3y.austin.web.vo.amis;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* amis的通用转化类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CommonAmisVo {
|
||||
|
||||
private String type;
|
||||
|
||||
private String label;
|
||||
|
||||
private String value;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean required;
|
||||
}
|
@ -1,11 +1,4 @@
|
||||
discardMsgIds = []
|
||||
deduplicationRule = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
|
||||
emailAccount = [{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423432@qq.com","pass":"234324324","from":"123123@qq.com","starttlsEnable":"true","auth":true,"sslEnable":true}},{"email_20":{"host":"smtp.163.com","port":465,"user":"23423423@163.com","pass":"234234324","from":"112312312@163.com","starttlsEnable":"false","auth":true,"sslEnable":true}}]
|
||||
smsAccount = [{"sms_10":{"url":"sms.tencentcloudapi.com","region":"ap-guangzhou","secretId":"234234","secretKey":"234324324","smsSdkAppId":"2343242","templateId":"234234","signName":"Java3y公众号","supplierId":10,"supplierName":"腾讯云"}},{"sms_20":{"url":"https://sms.yunpian.com/v2/sms/tpl_batch_send.json","apikey":"23423432","tpl_id":"23423432","supplierId":20,"supplierName":"云片"}}]
|
||||
enterpriseWechatAccount = [{"enterprise_wechat_10":{"corpId":"23423423","corpSecret":"-234324234","agentId":1000002,"token":"234234","aesKey":"23423423"}}]
|
||||
dingDingRobotAccount = [{"ding_ding_robot_10":{"secret":"234324324324","webhook":"https://oapi.dingtalk.com/robot/send?access_token=8d03b68d081f732343243242343247328b0c3003d164715d2c6c6e56"}}]
|
||||
dingDingWorkNoticeAccount =[{"ding_ding_work_notice_10":{"appKey":"23423423","appSecret":"tQpvmkR863dYcuKDVfM23432432432423Nlx_fYLLLlpPJWHvWKbTu","agentId":"1523423423242"}}]
|
||||
flowControlRule = {"flow_control_40":1}
|
||||
geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}]
|
||||
feiShuAccountRobot = [{"fei_shu_robot_10":{"webhook":"https://open.feishu.cn/open-apis/bot/v2/hook/c24b09ef-9aa3-4aad-9239-a7e05fcaf6ec"}}]
|
||||
msgTypeSmsConfig = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]
|
||||
flowControl = {"flow_control_40":1}
|
Loading…
Reference in new issue