/**
* @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 | 纷享销客 | 帮助中心