根据角色查询所有员工ID并发送CRM消息通知

/**
 * @author QiaoChu
 * @codeName 根据角色查询所有员工ID并发送CRM消息通知
 * @description 根据角色查询所有员工ID并发送CRM消息通知
 * @note 排除合伙人
 * @createTime 2024-09-30
 * @函数需求编号
 */
List roleCodes = ["00000000000000000000000000000015"]
// 调用方法获取用户信息
def (boolean error, List data, String message) = Fx.auth.user.getUsersByRoleCodes(roleCodes)
if (error) {
    // 如果有错误信息,记录日志
    log.info("error: " + message)
} else {
    // 记录成功获取的数据
    log.info(data)
}
boolean isBj = false
// 定义正则表达式模式 需要过滤的 userId 列表
def bJPattern = ~/^(1186|1187|1188|1189|1050|1075)$/
List userIdList = [];
data.each { item ->
    String userId = item['userId'] as String;
    isBj = bJPattern.matcher(userId).matches();
    if (!isBj) {
        userIdList.add(userId);
    }
}
log.info(userIdList)
String id = context.data['_id'] as String;
log.info(id)
List partitionList = Fx.utils.listPartition(userIdList, 50)
partitionList.each { item ->
    //根据id分批组装数据
    List userIds = item as List
    Fx.log.info("当前id分批组装数据条数:" + userIds.size())
    log.info(userIds)
    Fx.log.info("实际发送的数据条数:" + userIdList.size())
    Notice objectNotify = Notice.objectNotice("ReceivedPaymentObj", id)
    def (Boolean dataError, String dataNotice, String errorMessage) = Fx.message.sendNotice("到款认领", "请确认到款认领", userIds, objectNotify)
    if (dataError) {
        log.info(errorMessage)
    } else {
        log.info(dataNotice)
    }
}

参考:
1、Fx.auth.user.getRolesByUsers
Fx.auth | 纷享销客 | 帮助中心
2、Fx.message.sendNotice
Fx.message | 纷享销客 | 帮助中心

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值