附上官方文档链接供参考:https://developers.dingtalk.com/document/app/asynchronous-sending-of-enterprise-session-messages
接下来上代码,实测可用:(通知多人时,是将list数据转成了String字符串)
// 发送钉钉消息通知
dDComponent.sendMessage(receivers, "“事项已上传成功");
//发送钉消息通知管理员
String sql="select account_id from tbl_user_role_info a ,tbl_user_info b where a.user_id=b.user_id and a.role_id='admin'";
List<DDBean> list=jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(DDBean.class));
log.info("接收者list:"+list.size());
if (!CollectionUtils.isEmpty(list)){
StringBuilder sb = new StringBuilder();
String account_id = "";
for(int i=0;i<list.size();i++){
if(i<list.size()-1){

本文档展示了如何使用Java代码调用钉钉接口来发送工作通知,包括发送给个人和管理员。首先提供了官方文档链接,然后提供了一个实际的Java代码示例,从数据库查询管理员账号并构建接收者列表,最后发送通知。代码中使用了Spring JDBC的jdbcTemplate进行数据库操作,并确保了异常处理。
最低0.47元/天 解锁文章
8705





