消息推送问题
管理员大大,用webSockt向客户端发送消息时消息会被存到数据库中吗,如果有的话对应的表是哪张表?如果我要用定时任务来做发待办消息的功能,消息体要怎么定义才能够让消息保存在数据库中,员工登录之后就可以查看到,我现在写的逻辑员工未登录时如果执行了定时任务,发了消息,员工登录之后是看不到的在消息提示栏里,应该怎么解决呢?感谢
附上代码,加粗的是发送websocket的方法,调用的是后台的服务,定时任务执行的时候后发送待办是正常的,但是只有当前人登录才能看到,我想要的效果是定时任务条件达到发送待办,员工不管是否在线都能收到,不在线的员工登录之后能够在消息提示栏中看到,这种该怎么实现呢?
/********************
this.entityManager; //实体管理器
this.applications; //访问系统内服务
this.organization; //组织访问
this.org; //组织快速访问方法
this.service; ///webSerivces客户端
*******************/
print("========转正待办推送服务扫描开始========");
// print(personList);
// 获取人员登记完成视图中的所有数据已提交数据
function getJobId(){
//serviceRoot 服务根
//path 路径
//string 数据字符串,json转字符串可以用 JSON.stringify( json )
var json = {filterList: []};
var resp = applications.putQuery( "x_query_assemble_surface", "/jaxrs/view/7b71c72a-2866-4a13-86c9-7d5eac89383a/bundle", JSON.stringify(json) );
// print( resp.toString() );
var result = JSON.parse( resp.toString() );
return result.data.valueList;
}
// 获取视图数据
function getViewData(){
var idList = getJobId();
var json = {filterList: [], bundleList : idList };
var resp = applications.putQuery( "x_query_assemble_surface", "/jaxrs/view/7b71c72a-2866-4a13-86c9-7d5eac89383a/execute", JSON.stringify(json) );
//print( resp.toString() );
var result = JSON.parse( resp.toString() );
return result.data.grid;
}
//获取数据字典数据
function getDictData(dictId,applicationId){
var data = {};
var serviceRoot = "x_processplatform_assemble_surface";
var path = "applicationdict/"+dictId+"/application/"+applicationId;
var resp = applications.getQuery( serviceRoot, path );
var json = JSON.parse( resp.toString() );
var result = {};
if(json.type == "success" && json.data){
result = json.data;
}
return result;
}
// 获取某个人所在的组织
function getCurrentUserInOrg(name) {
var data = {};
data["personList"] = ;
var string = JSON.stringify(data);
var apps = this.applications;
var serviceRoot = "x_organization_assemble_express";
var path = "unit/list/person";
var resp = apps.postQuery( serviceRoot, path , string);
var json = JSON.parse( resp.toString() );
var result = {};
if(json.type == "success" && json.data) {
result = json.data;
}
return result;
}
// 发送消息
function sendMessage(type, person, title, body) {
var data = {};
data["type"] = type;
data["person"] = person;
data["title"] = title;
data["body"] = body;
var string = JSON.stringify(data);
var apps = this.applications;
var serviceRoot = "x_message_assemble_communicate";
var path = "ws";
var resp = apps.postQuery( serviceRoot, path , string);
var json = JSON.parse( resp.toString() );
var result = {};
if(json.type == "success" && json.data) {
result = json.data;
print("发消息结果 : " + result);
}
return result;
}
for(var i = 0; i < getViewData().length; i++) {
// 获取开始时间
var start = getViewData().data.PROBATION_PERIOD_START;
// 获取结束时间
var end = getViewData().data.PROBATION_PERIOD_END;
// 获取待转正人姓名
var positivePersonName = getViewData().data.subject;
// // 获取拟稿人
// var person = getViewData().data.PERSON;
var startDate = new Date(Date.parse(start.replace(/-/g, "/")));
var endDate = new Date(Date.parse(end.replace(/-/g, "/")));
// 当前时间
var now = new Date();
var period = endDate - now;
period = period / 1000 / 60 / 60 / 24;
period = period.toFixed(0);
print(period);
// 获取拟稿人组织
var result = getCurrentUserInOrg(person);
var unitArr = result.unitList;
// 获取消息发送配置的岗位
// 查询数据字典
var dict = getDictData("2fed4681-94f2-4e3f-88f7-940d16a60f73", "5214c863-df98-4ff4-914b-a35f3126f923");
var positiveOrg = dict.data.positiveOrg;
// print(getViewData().data.IS_COMPLETED == true);
// 获取字典中配置的组织下的所有成员
if(getViewData().data.IS_COMPLETED == true && period == 89) { // 已提交的快到期的
print("-----出现匹配人员------");
for(var j = 0; j < positiveOrg.length; j++) {
print("获取人员组织: " + positiveOrg);
var personList = this.org.listPersonWithUnit(positiveOrg);
for(k = 0; k < personList.length; k++) {
var person = personList.distinguishedName;
print("需要发送消息人员:" + person);
sendMessage("task_press", person, positivePersonName + " 距离转正日期还有两周,请注意", {applicationName : "人员管理", processName : "外部人员转正"});
print("给 " + person + " 发送消息成功");
}
}
}
}
print("========转正待办推动服务扫描结束========"); 您好:您现在调用的这个接口 只有用户在线的时候能发送。
用户不在线是无法接收的。
您可以参考一下自定义消息
https://www.yuque.com/o2oa/course/gi80ay 自定义消息之后用户怎么接受呢?我按照官方文档中调方法定制了消息,但是前台消息栏中没有显示啊,有个需求是在员工试用期结束前两周发送消息给转正的办理人员提醒他给员工办理转正,之前用的WebSocket您说只能在线发送,需要定制消息,现在定制了之后怎么让他显示在前台的消息栏中呢?https://www.o2oa.net:443/x_file_assemble_control/jaxrs/file/6bf855be-b381-4cb9-8a3d-04502ea1c638/download/stream 1请问您地址的配置是什么! 还需要配置地址吗?怎么配呢,官方文档中没有说要配置地址啊,是message.json中的配置吗?https://www.o2oa.net:443/x_file_assemble_control/jaxrs/file/996f609a-dad7-4ce3-ad14-c5a428a8f0a8/download/stream 您好:
请看红框
https://www.o2oa.net:443/x_file_assemble_control/jaxrs/file/5e0af09d-08d7-4e77-a49f-d3e610554153/download/stream 论坛管理员 发表于 2021-6-25 11:28
您好:
请看红框
同问,自定义消息设置为custom_create ,脚本中消息能发出去,通过脚本也能查询到消息,但是页面右上角消息栏没有展示呢。
页:
[1]