s-HR系统发送普通消息给系统用户

栏目:eas cloud知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

s-HR系统发送普通消息给系统用户

非多语言版本具体示例如下:

Context ctx ;//可以通过传参传入
Message message = MessageFactory.newMessage();//初始化消息对象
message.setBooleanHeader("isSendCommon", Boolean.TRUE);
message.setLocaleStringHeader("title","");//消息头
message.setLocaleStringHeader("body","");//消息内容
//常用分类设置,可以参考对应枚举
message.setIntHeader("type", MsgType.NOTICE_VALUE);//通知类消息
message.setIntHeader("bizType", MsgBizType.HR_VALUE);//HR 业务领域
message.setIntHeader("priority", MsgPriority.HIGH_VALUE);//高优先级别
message.setIntHeader("sourceStatus", MsgSourceStatus.EMPTY_VALUE);//状态空

message.setStringHeader("solution", ctx.getSolution());//解决方案
message.setStringHeader("databaseCenter", ctx.getAIS());//数据中心
message.setStringHeader("receiver", userId);//消息接收人,如果是多个人,需要进行循环发送消息,这个根据业务需要进行处理
message.setStringHeader("senderId", userId);//消息发送人
//如果是通过链接能打开东西,可以增加url的设置
message.setStringHeader("url", "/shr/dynamic.do?uipk=xxx&method=xxx");
//注意,url中的参数,不需要进行url转码处理
//发送
DirectSenderAgent.getSenderAgent().sendMessage(message);


总体在8.5以上参考:com.kingdee.shr.base.syssetting.app.io.fileImport.ImportTaskExecutor#sendComplateMessage

多语言版本具体示例说明如下:

Context ctx = this.context;
String userId = ctx.getCaller().toString();//获取上下文,场景不同有差异
Message message = MessageFactory.newMessage();//初始化消息对象
message.setBooleanHeader("isSendCommon", Boolean.TRUE);
ImportTaskInfo task = this.task.getTaskInfo();
   //消息头设置,s-HR860SP1及以上版本需要处理多语言
if (ImportTaskStateEnum.DONE.getValue() != task.getState().getValue()) {
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_stop", LocaleUtils.locale_l1, task.getName()), LocaleUtils.locale_l1);
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_stop", LocaleUtils.locale_l2, task.getName()), LocaleUtils.locale_l2);
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_stop", LocaleUtils.locale_l3, task.getName()), LocaleUtils.locale_l3);
//title = MessageFormat.format(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_stop",context), task.getName());  //"导入任务【{0}】中止执行"
} else {
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_completed", LocaleUtils.locale_l1, task.getName()), LocaleUtils.locale_l1);
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_completed", LocaleUtils.locale_l2, task.getName()), LocaleUtils.locale_l2);
message.setLocaleStringHeader("title", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_completed", LocaleUtils.locale_l3, task.getName()), LocaleUtils.locale_l3);
//title = MessageFormat.format(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "import_task_completed",context), task.getName());  //"导入任务【{0}】完成执行"
}
//消息体设置,s-HR860SP1及以上版本需要处理多语言
StringBuffer bodySb1 = new StringBuffer(message.getLocaleStringHeader("title", LocaleUtils.locale_l1));
StringBuffer bodySb2 = new StringBuffer(message.getLocaleStringHeader("title", LocaleUtils.locale_l2));
StringBuffer bodySb3 = new StringBuffer(message.getLocaleStringHeader("title", LocaleUtils.locale_l3));
bodySb1.append(" ");
bodySb2.append(" ");
bodySb3.append(" ");

bodySb1.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "success",LocaleUtils.locale_l1)).append(":").append(task.getSuccessCount()).append("  ");  //成功
bodySb1.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "fails",LocaleUtils.locale_l1)).append(":").append(task.getFailureCount()).append("  ");  //失败
bodySb1.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "surplus",LocaleUtils.locale_l1)).append(":").append(task.getTotleCount() - task.getSuccessCount() - task.getFailureCount()).append(" ");  //剩余
if (!StringUtils.isEmpty(task.getResultDesc())) {
bodySb1.append(task.getResultDesc()).append(" ");
}
bodySb2.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "success",LocaleUtils.locale_l2)).append(":").append(task.getSuccessCount()).append("  ");  //成功
bodySb2.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "fails",LocaleUtils.locale_l2)).append(":").append(task.getFailureCount()).append("  ");  //失败
bodySb2.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "surplus",LocaleUtils.locale_l2)).append(":").append(task.getTotleCount() - task.getSuccessCount() - task.getFailureCount()).append(" ");  //剩余
if (!StringUtils.isEmpty(task.getResultDesc())) {
bodySb2.append(task.getResultDesc()).append(" ");
}
bodySb3.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "success",LocaleUtils.locale_l3)).append(":").append(task.getSuccessCount()).append("  ");  //成功
bodySb3.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "fails",LocaleUtils.locale_l3)).append(":").append(task.getFailureCount()).append("  ");  //失败
bodySb3.append(SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "surplus",LocaleUtils.locale_l3)).append(":").append(task.getTotleCount() - task.getSuccessCount() - task.getFailureCount()).append(" ");  //剩余
if (!StringUtils.isEmpty(task.getResultDesc())) {
bodySb3.append(task.getResultDesc()).append(" ");
}
message.setLocaleStringHeader("body", bodySb1.toString(), LocaleUtils.locale_l1);
message.setLocaleStringHeader("body", bodySb2.toString(), LocaleUtils.locale_l2);
message.setLocaleStringHeader("body", bodySb3.toString(), LocaleUtils.locale_l3);
//消息发送者,s-HR860SP1及以上版本需要处理多语言,可以根据需要调整为对应用户
message.setLocaleStringHeader("sender", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l1), LocaleUtils.locale_l1);  //"系统自动发送"
message.setLocaleStringHeader("sender", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l2), LocaleUtils.locale_l2);  //"系统自动发送"
message.setLocaleStringHeader("sender", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l3), LocaleUtils.locale_l3);  //"系统自动发送"
//initiatorName,s-HR860SP1及以上版本需要处理多语言,可调整
message.setLocaleStringHeader("initiatorName", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l1), LocaleUtils.locale_l1);  //"系统自动发送"
message.setLocaleStringHeader("initiatorName", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l2), LocaleUtils.locale_l2);  //"系统自动发送"
message.setLocaleStringHeader("initiatorName", SHRServerResource.getString(Constants.COMMON_SERVICE_RESOURCE, "sys_auto_send",LocaleUtils.locale_l3), LocaleUtils.locale_l3);  //"系统自动发送"
//常用分类设置,可以参考对应枚举
message.setIntHeader("type", MsgType.NOTICE_VALUE);
message.setIntHeader("bizType", MsgBizType.HR_VALUE);
message.setIntHeader("priority", MsgPriority.HIGH_VALUE);
message.setIntHeader("sourceStatus", MsgSourceStatus.EMPTY_VALUE);

message.setStringHeader("solution", ctx.getSolution());
message.setStringHeader("databaseCenter", ctx.getAIS());
message.setStringHeader("receiver", userId);
message.setStringHeader("senderId", userId);
//如果是通过链接能打开东西,可以增加url的设置
message.setStringHeader("url", "/shr/dynamic.do?uipk=xxx&method=xxx");
//注意,url中的参数,不需要进行url转码处理
//发送
DirectSenderAgent.getSenderAgent().sendMessage(message);



以上举例中:

Context ctx //可以自己传
引入Constants全路径:com.kingdee.shr.base.syssetting.constant.Constants
自己的发送消息中,ImportTaskInfo task = this.task.getTaskInfo();及相关代码需要去掉
message.setLocaleStringHeader("body","");存入自己的消息内容
message.setLocaleStringHeader("title","");存入自己的消息头
message.setStringHeader("url", "/shr/dynamic.do?uipk=xxx&method=xxx");//消息需要url跳转,才设置此属性,注意,url中的参数,不需要进行url转码处理
其他的值基本一样,有特殊的再调整



请问这个接口为什么发不了消息到小铃铛,但数据库里面已经有数据

s-HR系统发送普通消息给系统用户

非多语言版本具体示例如下:Context ctx ;//可以通过传参传入Message message = MessageFactory.newMessage();//初始化消息对象message.se...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息