Search in sources :

Example 11 with Message

use of com.bc.pmpheep.general.po.Message 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);
            }
        }
    }
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) Org(com.bc.pmpheep.back.po.Org) OrgUser(com.bc.pmpheep.back.po.OrgUser) ArrayList(java.util.ArrayList) Material(com.bc.pmpheep.back.po.Material) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished) DecPosition(com.bc.pmpheep.back.po.DecPosition) Textbook(com.bc.pmpheep.back.po.Textbook) Declaration(com.bc.pmpheep.back.po.Declaration)

Example 12 with Message

use of com.bc.pmpheep.general.po.Message 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);
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage)

Example 13 with Message

use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.

the class UserMessageServiceImpl method updateMyMessageDetail.

@Override
public MyMessageVO updateMyMessageDetail(Long id) throws CheckedServiceException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "消息id为空!");
    }
    MyMessageVO myMessageVO = userMessageDao.getMyMessageDetail(id);
    switch(myMessageVO.getSenderType()) {
        case 0:
            myMessageVO.setSenderName("系统");
            break;
        case 1:
            PmphUser pmphUser = pmphUserService.get(myMessageVO.getSenderId());
            myMessageVO.setSenderAvatar(pmphUser.getAvatar());
            myMessageVO.setSenderName(pmphUser.getRealname());
            break;
        case 2:
            WriterUser writerUser = writerUserService.get(myMessageVO.getSenderId());
            myMessageVO.setSenderAvatar(writerUser.getAvatar());
            myMessageVO.setSenderName(writerUser.getRealname());
            break;
        case 3:
            // 现在没有机构用户
            break;
        default:
            throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "发送者类型不正确!");
    }
    Message message = messageService.get(myMessageVO.getMsgId());
    if (ObjectUtil.isNull(message)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "没有获取到消息详情");
    }
    myMessageVO.setContent(message.getContent());
    List<MessageAttachment> messageAttachments = messageAttachmentService.getMessageAttachmentByMsgId(myMessageVO.getMsgId());
    for (MessageAttachment messageAttachment : messageAttachments) {
        messageAttachment.setAttachment(RouteUtil.MONGODB_FILE + messageAttachment.getAttachment());
    }
    myMessageVO.setMessageAttachments(messageAttachments);
    UserMessage userMessage = new UserMessage();
    userMessage.setId(id);
    userMessage.setIsRead(true);
    userMessageDao.updateUserMessage(userMessage);
    return myMessageVO;
}
Also used : MessageAttachment(com.bc.pmpheep.back.po.MessageAttachment) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) PmphUser(com.bc.pmpheep.back.po.PmphUser) MyMessageVO(com.bc.pmpheep.back.vo.MyMessageVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WriterUser(com.bc.pmpheep.back.po.WriterUser)

Example 14 with Message

use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.

the class SystemMessageService method sendWhenSubmitDeclarationForm.

/**
 * 作家教材申报表 给学校管理员发送或者人卫教材相关人员发送消息
 *
 * @author Mryang
 * @createDate 2017年11月17日 下午4:31:19
 * @param declarationId
 *            申报id
 * @throws CheckedServiceException
 * @throws IOException
 */
public void sendWhenSubmitDeclarationForm(Long declarationId) 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());
    if (declaration.getOrgId() == 0) {
        // 提交的人卫社
        // 项目编辑 策划编辑 主任 id
        String msgContent = "[<font color='red'>" + declaration.getRealname() + "</font>]提交了《<font color='red'>" + material.getMaterialName() + "</font>》申报表,请及时进行资料审核";
        // 存入消息主体
        Message message = new Message(msgContent);
        message = messageService.add(message);
        String msg_id = message.getId();
        // 主任id
        Long directorId = material.getDirector();
        // 项目编辑列表
        List<MaterialProjectEditorVO> materialProjectEditorList = materialProjectEditorService.listMaterialProjectEditors(material.getId());
        // 批量保存的消息集合
        List<UserMessage> userMessageList = new ArrayList<UserMessage>(materialProjectEditorList.size() + 1);
        List<String> userIds = new ArrayList<String>(materialProjectEditorList.size() + 1);
        userMessageList.add(new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), directorId, new Short("1"), null));
        userIds.add("1_" + directorId);
        for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditorList) {
            UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), materialProjectEditor.getEditorId(), new Short("1"), null);
            userMessageList.add(userMessage);
            userIds.add("1_" + materialProjectEditor.getEditorId());
        }
        // 策划编辑
        // 我申报的书籍
        List<DecPosition> decPositionList = decPositionService.listDecPositions(declarationId);
        for (DecPosition decPosition : decPositionList) {
            Textbook textbook = textbookService.getTextbookById(decPosition.getTextbookId());
            if (null != textbook && null != textbook.getPlanningEditor()) {
                UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), textbook.getPlanningEditor(), new Short("1"), null);
                userMessageList.add(userMessage);
                userIds.add("1_" + textbook.getPlanningEditor());
            }
        }
        // 发送消息
        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);
    } else {
        // 提交的机构
        String msgContent = "贵校老师[<font color='red'>" + declaration.getRealname() + "</font>]提交了《<font color='red'>" + material.getMaterialName() + "</font>》申报表,请及时进行资料审核、打印并快递申报纸质表";
        // 存入消息主体
        Message message = new Message(msgContent);
        message = messageService.add(message);
        String msg_id = message.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>(orgUserList.size());
        for (OrgUser orgUser : orgUserList) {
            UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), orgUser.getId(), new Short("3"), null);
            userMessageList.add(userMessage);
            userIds.add("3_" + orgUser.getId());
        }
        // 发送消息
        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);
    }
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) OrgUser(com.bc.pmpheep.back.po.OrgUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) DecPosition(com.bc.pmpheep.back.po.DecPosition) Textbook(com.bc.pmpheep.back.po.Textbook) Declaration(com.bc.pmpheep.back.po.Declaration)

Example 15 with Message

use of com.bc.pmpheep.general.po.Message in project pmph by BCSquad.

the class SystemMessageService method sendWhenConfirmFirstEditor.

/**
 * 遴选主编副主编时点击发布按钮之后向主编、副主编发送消息
 *
 * @author Mryang
 * @createDate 2017年11月17日 下午1:57:04
 * @param bookId
 *            教材书籍id
 * @throws CheckedServiceException
 * @throws IOException
 */
public void sendWhenConfirmFirstEditor(Long bookId, List<DecPositionPublished> newMessage) throws CheckedServiceException, IOException {
    // 获取教材书籍
    Textbook textbook = textbookService.getTextbookById(bookId);
    if (textbook.getIsPublished()) {
        sendWhenPubfinalResult(bookId, newMessage);
        return;
    }
    // 获取教材
    Material material = materialService.getMaterialById(textbook.getMaterialId());
    if (null == material) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "该书籍没有找到对应的教材");
    }
    // 获取这本书的申报遴选列表
    for (DecPositionPublished decPosition : newMessage) {
        if (null != decPosition && null != decPosition.getChosenPosition() && null != decPosition.getRank()) {
            // 筛选出主编、副主编
            Declaration declaration = declarationService.getDeclarationById(decPosition.getDeclarationId());
            // 消息内容
            String msgContent = "";
            if (decPosition.getChosenPosition() == 4 || decPosition.getChosenPosition() == 12) {
                if (decPosition.getRank() == 1) {
                    if (decPosition.getChosenPosition() == 12) {
                        msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的第一主编和数字编委,您现在可以开始遴选编委了,最终结果以遴选结果公告为准";
                    } else {
                        msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的第一主编,您现在可以开始遴选编委了,最终结果以遴选结果公告为准";
                    }
                } else {
                    if (decPosition.getChosenPosition() == 12) {
                        msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的主编与数字编委,最终结果以遴选结果公告为准";
                    } else {
                        msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的主编,最终结果以遴选结果公告为准";
                    }
                }
            }
            if (decPosition.getChosenPosition() == 2 || decPosition.getChosenPosition() == 10) {
                if (decPosition.getChosenPosition() == 10) {
                    msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的副主编和数字编委,最终结果以遴选结果公告为准";
                } else {
                    msgContent = "恭喜您被选为《<font color='red'>" + material.getMaterialName() + "</font>》<font color='red'>[" + textbook.getTextbookName() + "</font>]的副主编,最终结果以遴选结果公告为准";
                }
            }
            Message message = new Message(msgContent);
            message = messageService.add(message);
            String msg_id = message.getId();
            UserMessage userMessage = new UserMessage(msg_id, messageTitle, new Short("0"), 0L, new Short("0"), declaration.getUserId(), new Short("2"), null);
            userMessageService.addUserMessage(userMessage);
            // 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);
        }
    }
}
Also used : UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) Message(com.bc.pmpheep.general.po.Message) Textbook(com.bc.pmpheep.back.po.Textbook) ArrayList(java.util.ArrayList) Material(com.bc.pmpheep.back.po.Material) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) UserMessage(com.bc.pmpheep.back.po.UserMessage) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished) Declaration(com.bc.pmpheep.back.po.Declaration)

Aggregations

Message (com.bc.pmpheep.general.po.Message)27 UserMessage (com.bc.pmpheep.back.po.UserMessage)21 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)20 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)20 ArrayList (java.util.ArrayList)19 Declaration (com.bc.pmpheep.back.po.Declaration)7 Material (com.bc.pmpheep.back.po.Material)7 OrgUser (com.bc.pmpheep.back.po.OrgUser)7 PmphUser (com.bc.pmpheep.back.po.PmphUser)6 WriterUser (com.bc.pmpheep.back.po.WriterUser)5 BaseTest (com.bc.pmpheep.test.BaseTest)4 Test (org.junit.Test)4 MessageAttachment (com.bc.pmpheep.back.po.MessageAttachment)3 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)3 Textbook (com.bc.pmpheep.back.po.Textbook)3 PageResult (com.bc.pmpheep.back.plugin.PageResult)2 CmsContent (com.bc.pmpheep.back.po.CmsContent)2 DecPosition (com.bc.pmpheep.back.po.DecPosition)2 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)2 MyMessageVO (com.bc.pmpheep.back.vo.MyMessageVO)2