批量选择数据,点击UI按钮,根据角色查询所有员工ID并发送CRM消息通知

 

/**
 * @codeName 批量选择数据,点击UI按钮,根据角色查询所有员工ID并发送CRM消息通知
 */
log.info(context)
List dataList = context.dataList as List;
Map updateData = [:]
dataList.each {
    item ->
        String id = item["_id"] as String;
        String status = item["status"] as String;
        updateData.put(id, ["status": status])
}
List idList = dataList.collect {
    x -> x["_id"]
}
log.info(idList)
/**
 * @codeName 根据角色查询所有员工ID并发送CRM消息通知
 */
List roleCodes = ["00000000000000000000000000000015"]
// 调用方法获取用户信息
def (boolean errorR, List dataR, String messageR) = Fx.auth.user.getUsersByRoleCodes(roleCodes)
if (errorR) {
    // 如果有错误信息,记录日志
    log.info("error: " + messageR)
} else {
    // 记录成功获取的数据
    log.info(dataR)
}
boolean isBj = false
// 定义正则表达式模式 需要过滤的 userId 列表
def bJPattern = ~/^(1186|1187|1188|1189|1050|1075)$/
List userIdList = [];
dataR.each { itemR ->
    String userId = itemR['userId'] as String;
    isBj = bJPattern.matcher(userId).matches();
    if (!isBj) {
        userIdList.add(userId);
    }
}
log.info(userIdList)
List partitionList = Fx.utils.listPartition(idList, 100)
partitionList.each { item ->
    //根据id分批组装数据
    List ids = item as List
    ids.each { id ->
        String stringId = id as String
        List partitionListR = Fx.utils.listPartition(userIdList, 50)
        partitionListR.each { itemR2 ->
            log.info(updateData[stringId]['status'])
            if (updateData[stringId]['status'] == '1') {
                //根据id分批组装数据
                List userIds = itemR2 as List
                Fx.log.info("当前id分批组装数据条数:" + userIds.size())
                log.info(userIds)
                //Fx.log.info("实际发送的数据条数:" + userIdList.size())
                Notice objectNotify = Notice.objectNotice("ReceivedPaymentObj", stringId)
                def (Boolean dataErrorR, String dataNoticeR, String errorMessageR) = Fx.message.sendNotice("到款认领", "请确认到款认领", userIds, objectNotify)
                if (dataErrorR) {
                    log.info(errorMessageR)
                } else {
                    log.info(dataNoticeR)
                }
            } else {
                log.info(dataList[stringId]['name'] + ":已认领")
            }
        }
    }
}
return ''

参考:

 1、context.dataList
context | 纷享销客 | 帮助中心
2、Fx.auth.user.getRolesByUsers
Fx.auth | 纷享销客 | 帮助中心
3、Fx.message.sendNotice
Fx.message | 纷享销客 | 帮助中心
注意:
返回值:字符串,空则表示当前页面刷新,不进行跳转;URL或者其他信息,会在新选项卡或新页面进行跳转。
return ' '

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值