use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenKickingOutGroup.
/**
* 任意用户被踢出进入小组 向被踢出人发出
*
* @author Mryang
* @createDate 2017年11月17日 下午2:16:36
* @param inviterName
* 踢出人名字
* @param groupId
* 小组id
* @param invitedPersonIds
* 被踢出人ids
* @param invitedPersonType
* 被踢出人类型: 1=社内用户/2=作家/3=机构用户
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenKickingOutGroup(String inviterName, Long groupId, List<Long> invitedPersonIds, short invitedPersonType) throws CheckedServiceException, IOException {
if (StringUtils.isEmpty(inviterName)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "邀请人为空");
}
if (null == invitedPersonIds || invitedPersonIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "被邀请人为空");
}
// 获取小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
if (null == pmphGroup) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "小组不存在");
}
String msgContent = "您被[<font color='red'>" + inviterName + "</font>]移出群组[<font color='red'>" + pmphGroup.getGroupName() + "]</font>";
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(invitedPersonIds.size());
List<String> userIds = new ArrayList<String>(invitedPersonIds.size());
for (Long id : invitedPersonIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, invitedPersonType, null);
userMessageList.add(userMessage);
userIds.add(invitedPersonType + "_" + id);
}
// 发送消息
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 sendWhenManagerCertificationAudit.
/**
* 学校管理员认证 向机构用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午3:01:42
* @param orguserIds
* 机构用户ids
* @param isPass
* true 通过/false 退回
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenManagerCertificationAudit(List<Long> orguserIds, boolean isPass) throws CheckedServiceException, IOException {
if (null == orguserIds || orguserIds.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.SCHOOL_ADMIN_CHECK, CheckedExceptionResult.NULL_PARAM, "认证的管理员为空");
}
// 存入消息主体
// 退回
String msgContent = "抱歉,您提交的管理员认证资料已被退回,请您修改后重试";
if (isPass) {
// 通过
msgContent = "恭喜!您提交的管理员认证资料已通过审核";
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 组装消息和消息对象
List<UserMessage> userMessageList = new ArrayList<UserMessage>(orguserIds.size());
List<String> userIds = new ArrayList<String>(orguserIds.size());
// 发送消息
for (Long id : orguserIds) {
UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), id, new Short("3"), null);
userMessageList.add(userMessage);
userIds.add("3_" + id);
}
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 sendWhenPubfinalResult.
/**
* 某一本书的最终结果公布 或者 整套教材全部公布时 向当选者和学校管理员发送消息
*
* @author Mryang
* @createDate 2017年11月19日 上午11:24:31
* @param textBookId
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenPubfinalResult(Long textBookId, List<DecPositionPublished> decPositionPublishedLst) throws CheckedServiceException, IOException {
Textbook textbook = textbookService.getTextbookById(textBookId);
Material material = materialService.getMaterialById(textbook.getMaterialId());
// 给主编、副主编、编委、数字编委发送
String msg = "";
for (DecPositionPublished decPosition : decPositionPublishedLst) {
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (null != decPosition.getRank() && decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的第一主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的副主编";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || 9 == decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 1) {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的编委";
} else {
msg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,恭喜您当选[<font color='red'>" + textbook.getTextbookName() + "</font>]的编委、数字编委";
}
}
// 获取申报表
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
// 存入消息主体
Message message = new Message(msg);
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, msg, DateUtil.getCurrentTime());
List<String> userIds = new ArrayList<String>(1);
userIds.add("2_" + declaration.getUserId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
// 给学校管理员发送消息
if (material.getIsAllTextbookPublished()) {
// 所有都发布了
String orgMsg = "《<font color='red'>" + material.getMaterialName() + "</font>》的编写团队遴选已结束,贵校共[{sum}]位老师当选,名单如下:";
// 根据教材Id查询对应的书籍集合
List<Textbook> textbooks = textbookService.getTextbookByMaterialId(material.getId());
List<Long> bookIds = new ArrayList<Long>();
for (Textbook book : textbooks) {
bookIds.add(book.getId());
}
// 根据书籍获取当选了该书籍的人员所属机构
List<Org> orgs = orgService.listBeElectedOrgByBookIds(bookIds);
for (Org org : orgs) {
// 根据orgid和bookid获取该机构某些已公布的书的申报职位
List<DecPosition> decPositions = decPositionService.listDecPositionsByTextbookIdAndOrgid(bookIds, org.getId());
if (null != decPositions && decPositions.size() > 0) {
String msgContent = orgMsg;
int sum = 0;
for (int i = 0; i < decPositions.size(); i++) {
DecPosition decPosition = decPositions.get(i);
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
msgContent += "</br>" + "[<font color='red'>" + declaration.getRealname() + "</font>]";
msgContent += " - " + textbookService.getTextbookById(decPosition.getTextbookId()).getTextbookName() + " - ";
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msgContent += "数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msgContent += "第一主编";
} else {
msgContent += "第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msgContent += "主编";
} else {
msgContent += "主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msgContent += "副主编";
} else {
msgContent += "副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || decPosition.getChosenPosition() == 9) {
if (decPosition.getChosenPosition() == 1) {
msgContent += "编委";
} else {
msgContent += "编委、数字编委";
}
}
}
sum++;
}
msgContent.replace("{sum}", String.valueOf(sum));
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 获取机构管理员
OrgUser orgUser = orgUserService.getOrgUserByOrgId(org.getId());
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), 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("3_" + orgUser.getId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
// 《全国高等学校五年制临床医学专业第九轮规划教材》的编写团队遴选已结束,贵校共[5]位老师当选,名单如下:
// [丁志国] - 局部解剖学 - 第一主编
// [王海滨] - 医学影像学 - 第二主编
// [雷国华] - 医学计算机应用 - 副主编
// [孙风梅] - 医学文献检索与论文写作 - 编委
// [宋守君] - 医患沟通 - 编委
} else {
String orgMsg = "《<font color='red'>" + material.getMaterialName() + "</font>》[<font color='red'>" + textbook.getTextbookName() + "</font>]的最终结果已公布,贵校老师";
// 《全国高等学校五年制临床医学专业第九轮规划教材》[传染病学]的最终结果已公布,贵校老师[丁志国]当选第一主编,[丁志国]当选第一主编,[丁志国]当选第一主编
// 先要将学校分队
List<Long> bookIds = new ArrayList<Long>();
bookIds.add(textBookId);
// 根据教材Id查询对应的书籍集合
List<Org> orgs = orgService.listBeElectedOrgByBookIds(bookIds);
for (Org org : orgs) {
// 根据orgid和bookid获取该机构某些已公布的书的申报职位
List<DecPosition> decPositions = decPositionService.listDecPositionsByTextbookIdAndOrgid(bookIds, org.getId());
if (null != decPositions && decPositions.size() > 0) {
// 拼装消息
String msgContent = orgMsg;
for (int i = 0; i < decPositions.size(); i++) {
DecPosition decPosition = decPositions.get(i);
Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
if (i > 0) {
msgContent += ",";
}
msgContent += "[<font color='red'>" + declaration.getRealname() + "</font>]当选";
if (null != decPosition.getChosenPosition()) {
if (decPosition.getChosenPosition() == 8) {
msgContent += "数字编委";
}
if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
if (decPosition.getRank() == 1) {
if (decPosition.getChosenPosition() == 4) {
msgContent += "第一主编";
} else {
msgContent += "第一主编、数字编委";
}
} else {
if (decPosition.getChosenPosition() == 4) {
msgContent += "主编";
} else {
msgContent += "主编、数字编委";
}
}
}
if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
if (decPosition.getChosenPosition() == 2) {
msgContent += "副主编";
} else {
msgContent += "副主编、数字编委";
}
}
if (decPosition.getChosenPosition() == 1 || decPosition.getChosenPosition() == 9) {
if (decPosition.getChosenPosition() == 1) {
msgContent += "编委";
} else {
msgContent += "编委、数字编委";
}
}
}
}
// 存入消息主体
Message message = new Message(msgContent);
message = messageService.add(message);
String msg_id = message.getId();
// 获取机构管理员
OrgUser orgUser = orgUserService.getOrgUserByOrgId(org.getId());
// 发送消息给申报者
userMessageService.addUserMessage(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), 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("3_" + orgUser.getId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
}
}
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class SystemMessageService method sendWhenInformalEssayAudit.
/**
* 随笔文章审核 向作家用户发送消息
*
* @author Mryang
* @createDate 2017年11月17日 下午5:23:16
* @param cmsContentId
* @param isPass
* true通过/false 不通过
* @throws CheckedServiceException
* @throws IOException
*/
public void sendWhenInformalEssayAudit(Long cmsContentId, boolean isPass) throws CheckedServiceException, IOException {
CmsContent cmsContent = cmsContentService.getCmsContentById(cmsContentId);
if (null == cmsContent) {
throw new CheckedServiceException(CheckedExceptionBusiness.CMS, CheckedExceptionResult.NULL_PARAM, "文章不存在");
}
String msgContent = "抱歉,您的文章《<font color='red'>" + cmsContent.getTitle() + "</font>》没有通过审核,请您修改后重试 ";
if (isPass) {
msgContent = "恭喜!您的文章《<font color='red'>" + cmsContent.getTitle() + "</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"), cmsContent.getAuthorId(), 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_" + cmsContent.getAuthorId());
myWebSocketHandler.sendWebSocketMessageToUser(userIds, webScocketMessage);
}
use of com.bc.pmpheep.websocket.WebScocketMessage in project pmph by BCSquad.
the class PmphGroupMessageServiceImpl method deletePmphGroupMessageById.
/**
* @param id
* @return 影响行数
* @throws CheckedServiceException
* @throws IOException
*/
@Override
public String deletePmphGroupMessageById(Long id, String sessionId) throws CheckedServiceException, IOException {
if (null == id) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "主键为空");
}
PmphGroupMessage pmphGroupMessage = pmphGroupMessageDao.getPmphGroupMessageById(id);
Long groupId = pmphGroupMessage.getGroupId();
int num = pmphGroupMessageDao.deletePmphGroupMessageById(id);
if (num > 0) {
// 删除成功 撤销消息
WebScocketMessage webScocketMessage = new WebScocketMessage();
webScocketMessage.setId(String.valueOf(id));
webScocketMessage.setGroupId(groupId);
webScocketMessage.setSendType(Const.SEND_MSG_TYPE_1);
List<PmphGroupMemberVO> list = pmphGroupMemberService.listPmphGroupMember(groupId, sessionId);
List<String> ids = new ArrayList<String>();
for (PmphGroupMemberVO groupMemberVO : list) {
String tempId = (groupMemberVO.getIsWriter() ? "2" : "1") + "_" + groupMemberVO.getUserId();
ids.add(tempId);
}
handler.sendWebSocketMessageToUser(ids, webScocketMessage);
}
return "SUCCESS";
}
Aggregations