1、接入企业微信各种消息类型

2、更新部分注释、提供将apollo配置样例
pull/11/head
3y 3 years ago
parent bb31cbb09f
commit 631eabe209

@ -193,8 +193,10 @@ docker exec -it kafka sh
$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinBusiness --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1
$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinLog --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1
$KAFKA_HOME/bin/kafka-topics.sh --create --topic austinRecall --partitions 1 --zookeeper zookeeper:2181 --replication-factor 1
```
查看刚创建的topic信息
@ -284,8 +286,13 @@ PS我的namespace是`boss.austin`
![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4c4636a5620a454b931aea8b248e2890~tplv-k3u1fbpfcp-watermark.image?)
apollo配置样例可看example/apollo.properties文件的内容
`dynamic-tp-apollo-dtp`它是一个apollo的namespace存放着动态线程池的配置
动态线程池样例配置可看 dynamic-tp-apollo-dtp.yml 文件的内容
## 06、安装PROMETHEUS和GRAFANA(可选)
存放`docker-compose.yml`的信息:

@ -5,6 +5,8 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Map;
/**
* @author 3y
*
@ -21,7 +23,7 @@ public class EnterpriseWeChatContentModel extends ContentModel {
private String sendType;
/**
* -
*
*/
private String content;
@ -30,9 +32,54 @@ public class EnterpriseWeChatContentModel extends ContentModel {
*/
private String mediaId;
/**
*
*/
private String title;
/**
*
*/
private String description;
/**
*
*/
private String url;
/**
*
*/
private String btnTxt;
/**
*
* [{"title":"中秋节礼品领取","description":"今年中秋节公司有豪礼相送","url":"URL","picurl":"http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png","appid":"wx123123123123123","pagepath":"pages/index?userid=zhangsan&orderid=123123123"}]
*/
private String articles;
/**
* mpnews
* [{"title":"Title","thumb_media_id":"MEDIA_ID","author":"Author","content_source_url":"URL","content":"Content","digest":"Digest description"}]
*/
private String mpNewsArticle;
/**
*
*/
private String appId;
private String page;
private Boolean emphasisFirstItem;
private String contentItems;
/**
* https://developer.work.weixin.qq.com/document/path/90372#%E6%96%87%E6%9C%AC%E6%B6%88%E6%81%AF
*/
}

@ -27,6 +27,8 @@ public enum SendMessageType {
LINK("110", "链接消息", "link", "link"),
ACTION_CARD("120", "跳转卡片消息", "actionCard", "action_card"),
OA("130", "OA消息", null, "oa"),
MP_NEWS("140", "图文消息(mpnews)", null, null),
;
private String code;

@ -8,6 +8,7 @@ import com.java3y.austin.common.constant.SendAccountConstant;
import com.java3y.austin.common.domain.TaskInfo;
import com.java3y.austin.common.dto.model.EnterpriseWeChatContentModel;
import com.java3y.austin.common.enums.ChannelType;
import com.java3y.austin.common.enums.SendMessageType;
import com.java3y.austin.handler.handler.BaseHandler;
import com.java3y.austin.handler.handler.Handler;
import com.java3y.austin.support.domain.MessageTemplate;
@ -17,6 +18,8 @@ import me.chanjar.weixin.common.error.WxMpErrorMsgEnum;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl;
import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
import me.chanjar.weixin.cp.bean.article.MpnewsArticle;
import me.chanjar.weixin.cp.bean.article.NewArticle;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
@ -24,6 +27,9 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
* @author 3y
*
@ -63,7 +69,6 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
}
/**
* WxCpServiceImpl
*
@ -90,14 +95,42 @@ public class EnterpriseWeChatHandler extends BaseHandler implements Handler {
} else {
userId = StringUtils.join(taskInfo.getReceiver(), DELIMITER);
}
EnterpriseWeChatContentModel enterpriseWeChatContentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel();
return WxCpMessage
.TEXT()
.agentId(agentId)
.toUser(userId)
.content(enterpriseWeChatContentModel.getContent())
.build();
EnterpriseWeChatContentModel contentModel = (EnterpriseWeChatContentModel) taskInfo.getContentModel();
// 通用配置
WxCpMessage wxCpMessage = null;
if (SendMessageType.TEXT.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.TEXT().content(contentModel.getContent()).build();
} else if (SendMessageType.IMAGE.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.IMAGE().mediaId(contentModel.getMediaId()).build();
} else if (SendMessageType.VOICE.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.VOICE().mediaId(contentModel.getMediaId()).build();
} else if (SendMessageType.VIDEO.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.VIDEO().mediaId(contentModel.getMediaId()).description(contentModel.getDescription()).title(contentModel.getTitle()).build();
} else if (SendMessageType.FILE.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.FILE().mediaId(contentModel.getMediaId()).build();
} else if (SendMessageType.TEXT_CARD.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.TEXTCARD().url(contentModel.getUrl()).title(contentModel.getTitle()).description(contentModel.getDescription()).btnTxt(contentModel.getBtnTxt()).build();
} else if (SendMessageType.NEWS.getCode().equals(contentModel.getSendType())) {
List<NewArticle> newArticles = JSON.parseArray(contentModel.getArticles(), NewArticle.class);
wxCpMessage = WxCpMessage.NEWS().articles(newArticles).build();
} else if (SendMessageType.MP_NEWS.getCode().equals(contentModel.getSendType())) {
List<MpnewsArticle> mpNewsArticles = JSON.parseArray(contentModel.getMpNewsArticle(), MpnewsArticle.class);
wxCpMessage = WxCpMessage.MPNEWS().articles(mpNewsArticles).build();
} else if (SendMessageType.MARKDOWN.getCode().equals(contentModel.getSendType())) {
wxCpMessage = WxCpMessage.MARKDOWN().content(contentModel.getContent()).build();
} else if (SendMessageType.MINI_PROGRAM_NOTICE.getCode().equals(contentModel.getSendType())) {
Map contentItems = JSON.parseObject(contentModel.getContentItems(), Map.class);
wxCpMessage = WxCpMessage.newMiniProgramNoticeBuilder().appId(contentModel.getAppId()).page(contentModel.getPage()).emphasisFirstItem(contentModel.getEmphasisFirstItem()).contentItems(contentItems).title(contentModel.getTitle()).description(contentModel.getDescription()).build();
} else if (SendMessageType.TEMPLATE_CARD.getCode().equals(contentModel.getSendType())) {
// WxJava 未支持
}
wxCpMessage.setAgentId(agentId);
wxCpMessage.setToUser(userId);
return wxCpMessage;
}
@Override
public void recall(MessageTemplate messageTemplate) {

@ -49,7 +49,7 @@ public class PipelineConfig {
}
/**
*
*
* 1.
* 2.MQ
* @return
@ -63,9 +63,7 @@ public class PipelineConfig {
/**
* pipeline
*
* BusinessCodeProcessTemplate
*
* @return
*/
@Bean

@ -1,7 +1,7 @@
protected-mode no
port 6379
timeout 0
save 900 1 # 900s内至少一次写操作则执行bgsave进行RDB持久化
save 900 1
save 300 10
save 60 10000
rdbcompression yes

@ -0,0 +1,10 @@
discard = []
deduplication = {"deduplication_10":{"num":1,"time":300},"deduplication_20":{"num":5}}
emailAccount =[{"email_10":{"host":"smtp.qq.com","port":465,"user":"23423432@qq.com","pass":"23423432","from":"234234234@qq.com"}}]
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"}}]
flowControl = {"flow_control_40":1}
geTuiAccount = [{"ge_tui_account_10":{"appId":"23423423","appKey":"234234234","masterSecret":"2342342342342"}}]
msg_type_sms_config = [{"message_type_10":[{"weights":99,"scriptName":"TencentSmsScript"},{"weights":1,"scriptName":"YunPianSmsScript"}]},{"message_type_20":[{"weights":20,"scriptName":"YunPianSmsScript"}]},{"message_type_30":[{"weights":20,"scriptName":"TencentSmsScript"}]},{"message_type_40":[{"weights":20,"scriptName":"TencentSmsScript"}]}]

@ -37,7 +37,7 @@
<maven.compiler.source>${target.java.version}</maven.compiler.source>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
<log4j.version>2.17.1</log4j.version>
<weixin-java>4.1.0</weixin-java>
<weixin-java>4.3.0</weixin-java>
</properties>
<dependencyManagement>

Loading…
Cancel
Save