/**
* @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 ' '