use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenQuitGroup.
/**
* 任意用户退出小组 给小组创建者和管理员发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午2:41:26
* @param exitPersonName
* 退出人姓名
* @param groupId
* 退出的小组id
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenQuitGroup(String exitPersonName, Long groupId) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(exitPersonName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "退出人为空");
}
// 获取小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
}
List<PmphGroupMemberVO> PmphGroupMemberVOList = pmphGroupMemberService.listPmphGroupMember(groupId, null);
if (null == PmphGroupMemberVOList || PmphGroupMemberVOList.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组没有成员");
}
// 存入消息主体
String msgContent = "[<font color='red'>" + exitPersonName + "</font>]退出了[" + pmphGroup.getGroupName() + "]小组";
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(PmphGroupMemberVOList.size());
List<String> userIds = new ArrayList<String>(PmphGroupMemberVOList.size());
for (PmphGroupMemberVO pmphGroupMemberVO : PmphGroupMemberVOList) {
if (pmphGroupMemberVO.getIsFounder() || pmphGroupMemberVO.getIsAdmin()) {
// 给创建者和管理员发送
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), pmphGroupMemberVO.getUserId(), pmphGroupMemberVO.getUserType(), null);
userMessageList.add(userMessage);
userIds.add(pmphGroupMemberVO.getUserType() + "_" + pmphGroupMemberVO.getUserId());
}
}
// 发送消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenDeclarationFormAudit.
/**
* 教材申报表审核 向作家用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午4:42:14
* @param declarationId
* 申报id
* @param isPass
* true 通过/false 退回
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenDeclarationFormAudit(Long declarationId, boolean isPass, String returnCause) throws CheckedServiceException, IOException {
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(declarationId);
if (null == declaration) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "申报表不存在");
}
if (null == declaration.getOrgId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
// 获取教材
Material material = materialService.getMaterialById(declaration.getMaterialId());
String msgContent = "";
if (declaration.getOrgId() == 0) {
// 提交的人卫社
msgContent = "抱歉,您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>出版社</font>]退回,退回原因:" + returnCause + ",请您核对后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表已通过[<font color='red'>出版社</font>]审核";
}
} else {
// 提交的机构
msgContent = "抱歉,您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>学校管理员</font>]退回,退回原因:" + returnCause + ",请您核对后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表已通过[<font color='red'>学校管理员</font>]审核";
}
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 发送消息
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null));
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenReceiptAudit.
/**
* 出版社收到纸质表 审核
*
* @author Mryang
* @createDate 2017年11月17日 下午5:08:49
* @param declarationId
* @param isPass
* true收到资质表 / false退回资质表
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenReceiptAudit(Long declarationId, boolean isPass) throws CheckedServiceException, IOException {
Declaration declaration = declarationService.getDeclarationById(declarationId);
if (null == declaration) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "申报表不存在");
}
if (null == declaration.getOrgId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "管理员为空");
}
Material material = materialService.getMaterialById(declaration.getMaterialId());
String orgMsgContent = "抱歉,贵校老师[<font color='red'>" + declaration.getRealname() + "</font>]在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表被退回";
String writerMsgContent = "抱歉,您在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表被退回,请您核对后重试";
if (isPass) {
// 收到
orgMsgContent = "您好,人民卫生出版社已收到贵校老师[<font color='red'>" + declaration.getRealname() + "</font>]在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表";
writerMsgContent = "您好,人民卫生出版社已收到您在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表,感谢您的参与,请耐心等待遴选结果";
} else {
// 取消收到
orgMsgContent = "抱歉,贵校老师[<font color='red'>" + declaration.getRealname() + "</font>]在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表被退回";
writerMsgContent = "抱歉,您在《<font color='red'>" + material.getMaterialName() + "</font>》提交的申报纸质表被退回,请您核对后重试";
}
// 存入消息主体
Message orgUserMessage = new Message(orgMsgContent);
orgUserMessage = messageService.add(orgUserMessage);
String orgMsg_id = orgUserMessage.getId();
List<Long> orgIds = new ArrayList<Long>(1);
orgIds.add(declaration.getOrgId());
List<OrgUser> OrgUserList = orgUserService.getOrgUserListByOrgIds(orgIds);
List<UserMessage> userMessageList = new ArrayList<UserMessage>(OrgUserList.size());
List<String> userIds = new ArrayList<String>(1);
for (OrgUser orgUser : OrgUserList) {
userMessageList.add(new UserMessage(orgMsg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), null));
userIds.add("3_" + orgUser.getId());
}
// 有学校管理员发信息
if (null != OrgUserList && OrgUserList.size() > 0) {
// 发送消息给管理员
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(orgMsg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, orgMsgContent, DateUtil.getCurrentTime());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
// ------------------------给申报者发送消息--------------------
// 存入消息主体
Message writerUserMessage = new Message(writerMsgContent);
writerUserMessage = messageService.add(writerUserMessage);
String writerMsg_id = writerUserMessage.getId();
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(writerMsg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null));
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(writerMsg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, writerMsgContent, DateUtil.getCurrentTime());
userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenPositionChooserLoss.
/**
* 给教材已结束并且未遴选上的作家推送消息
*
* @param materialId
* @param declaration
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenPositionChooserLoss(Long materialId, List<Declaration> declarations) throws CheckedServiceException, IOException {
Material material = materialService.getMaterialById(materialId);
if (ObjectUtil.isNull(material)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "教材为空");
}
String msg = null;
if (material.getIsAllTextbookPublished() && declarations.size() > 0) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》教材遴选已结束,未选中,感谢您的支持与参与。";
}
// 当消息不为空时才进行下面操作
if (StringUtil.notEmpty(msg)) {
// 存入消息主体
Message message = new Message(msg);
message = messageService.add(message);
String msg_id = message.getId();
for (Declaration declaration : declarations) {
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null));
// websocket推送页面消息
WebScocketMessage webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msg, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenDeclarationFormAuditToOrgUser.
/**
* 人卫社审核教材申报表 向机构用户发送信息
*
* @introduction
* @author Mryang
* @createDate 2018年1月22日 上午10:12:34
* @param declarationId
* @param isPass
* @param returnCause 退回原因
* @param onlineProgress 4 == 退回给学校,5 == 退回给个人
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenDeclarationFormAuditToOrgUser(Long declarationId, boolean isPass, String returnCause, Integer onlineProgress) throws CheckedServiceException, IOException {
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(declarationId);
if (null == declaration) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "申报表不存在");
}
if (null == declaration.getOrgId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
// 获取教材
Material material = materialService.getMaterialById(declaration.getMaterialId());
String msgContent = null;
if (isPass) {
// 通过
msgContent = "恭喜!您校[" + declaration.getRealname() + "]提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表已通过[<font color='red'>出版社</font>]审核";
} else {
// 出版社退回给学校==4
if (4 == onlineProgress.intValue()) {
msgContent = "抱歉!您校[" + declaration.getRealname() + "]提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>出版社</font>]退回,退回原因:" + returnCause + ",请核对后重试";
} else if (5 == onlineProgress.intValue()) {
// 出版社退回给个人==5
msgContent = "抱歉!您提交的《<font color='red'>" + material.getMaterialName() + "</font>》申报表被[<font color='red'>出版社</font>]退回,退回原因:" + returnCause + ",请您核对后重试";
}
}
WebScocketMessage webScocketMessage = null;
List<String> userIds = null;
if (4 == onlineProgress.intValue()) {
// 获取机构用户
List<Long> orgIds = new ArrayList<Long>(1);
if (CollectionUtil.isEmpty(orgIds) || orgIds.size() == 0) {
orgIds.add(declaration.getOrgId());
}
List<OrgUser> orgUserList = orgUserService.getOrgUserListByOrgIds(orgIds);
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 消息集合
List<UserMessage> userMessageList = new ArrayList<UserMessage>();
userIds = new ArrayList<String>();
for (OrgUser orgUser : orgUserList) {
userMessageList.add(new // 消息内容id
UserMessage(// 消息内容id
msg_id, // 消息标题
messageTitle, // 消息类型
new Short("0"), // 发送者id 0- 系统
0L, // 发送者类型 0- 系统
new Short("0"), // 接收者id
orgUser.getId(), // 接收者类型 (3- 机构用户 )
new Short("3"), // 教材id
null));
userIds.add("3_" + orgUser.getId().toString());
}
// 发送消息
// 批量插入消息
userMessageService.addUserMessageBatch(userMessageList);
// websocket推送页面消息
webScocketMessage = new // 消息id
WebScocketMessage(// 消息id
msg_id, // 消息类型 0=系统消息/1=站内群发/2=站内私信(作家和机构用户不能群发)/3 小组互动
Const.MSG_TYPE_0, // 发送者id 0=系统/其他=用户id
0L, // 发送者姓名
"系统", // 发送者类型 0=系统/1=社内用户/2=作家用户/3=机构用户
Const.SENDER_TYPE_0, // 发送类型 0 新增 1 撤回 2 删除
Const.SEND_MSG_TYPE_0, // 头像
"", // 消息标题
messageTitle, // 消息内容
msgContent, // 发送时间
DateUtil.getCurrentTime());
} else if (5 == onlineProgress.intValue()) {
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 发送消息
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null));
// websocket推送页面消息
webScocketMessage = new WebScocketMessage(msg_id, Const.MSG_TYPE_0, 0L, "系统", Const.SENDER_TYPE_0, Const.SEND_MSG_TYPE_0, RouteUtil.DEFAULT_USER_AVATAR, messageTitle, msgContent, DateUtil.getCurrentTime());
userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
}
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
Aggregations