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.gs-HR系统发送普通消息给系统用户
非多语言版本具体示例如下:Context ctx ;//可以通过传参传入Message message = MessageFactory.newMessage();//初始化消息对象message.se...
点击下载文档文档为doc格式
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
上一篇
已经是第一篇
下一篇



