Search in sources :

Example 6 with DecPositionPublished

use of com.bc.pmpheep.back.po.DecPositionPublished in project pmph by BCSquad.

the class WriterUserServiceImpl method getListWriterUser.

/**
 * 功能描述:分页查询作家用户
 *
 * @param page
 *            传入的查询数据
 * @return 需要的Page对象
 */
@Override
public PageResult<WriterUserManagerVO> getListWriterUser(PageParameter<WriterUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
    String name = pageParameter.getParameter().getName();
    if (StringUtil.notEmpty(name)) {
        pageParameter.getParameter().setName(name);
    }
    String orgName = pageParameter.getParameter().getOrgName();
    if (StringUtil.notEmpty(orgName)) {
        pageParameter.getParameter().setOrgName(orgName);
    }
    PageResult<WriterUserManagerVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 当rank为1的时候 查询教师用户
    int total = 0;
    if (pageParameter.getParameter().getRank() == null || pageParameter.getParameter().getRank() != 1) {
        // 当rank不为1的时候
        total = writerUserDao.getListWriterUserTotal(pageParameter);
        if (total > 0) {
            List<WriterUserManagerVO> list = writerUserDao.getListWriterUser(pageParameter);
            for (WriterUserManagerVO vo : list) {
                switch(vo.getRank()) {
                    case 0:
                        vo.setRankName("普通用户");
                        break;
                    case 1:
                        vo.setRankName("教师用户");
                        break;
                    case 2:
                        vo.setRankName("作家用户");
                        break;
                    case 3:
                        vo.setRankName("专家用户");
                        break;
                    default:
                        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
                }
            }
            pageResult.setRows(list);
        }
        pageResult.setTotal(total);
    } else {
        total = writerUserDao.getLsitisTeacherTotal(pageParameter);
        if (total > 0) {
            List<WriterUserManagerVO> list = writerUserDao.getLsitisTeacher(pageParameter);
            for (WriterUserManagerVO vo : list) {
                switch(vo.getRank()) {
                    case 0:
                        vo.setRankName("普通用户");
                        break;
                    case 1:
                        vo.setRankName("教师用户");
                        break;
                    case 2:
                        vo.setRankName("作家用户");
                        break;
                    case 3:
                        vo.setRankName("专家用户");
                        break;
                    default:
                        throw new CheckedServiceException(CheckedExceptionBusiness.WRITER_USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "该用户没有身份");
                }
            }
            pageResult.setRows(list);
        }
        pageResult.setTotal(total);
    }
    // 设置职位
    if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
        // 清空职位
        for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
            writerUserManagerVO.setPosition("无");
        }
        // 设置职位
        PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
        Long bookId = pmphGroup.getBookId();
        if (null != bookId && bookId.intValue() > 0) {
            // 查询这本书的发布职位
            List<DecPositionPublished> publisheds = decPositionPublishedService.getDecPositionPublishedListByBookId(bookId);
            if (null != publisheds && publisheds.size() > 0) {
                Map<Long, String> userIdsAndPostions = new HashMap<Long, String>();
                for (DecPositionPublished published : publisheds) {
                    Declaration declaration = declarationService.getDeclarationById(published.getDeclarationId());
                    String postiton = "无";
                    if (published.getChosenPosition().intValue() == 4 && null != published.getRank() && published.getRank() == 1) {
                        postiton = "主编(第一主编)";
                    } else if (published.getChosenPosition().intValue() == 4) {
                        postiton = "主编";
                    } else if (published.getChosenPosition().intValue() == 12 && null != published.getRank() && published.getRank() == 1) {
                        postiton = "主编(第一主编),数字编委";
                    } else if (published.getChosenPosition().intValue() == 12) {
                        postiton = "主编,数字编委";
                    } else if (published.getChosenPosition().intValue() == 2) {
                        postiton = "副主编";
                    } else if (published.getChosenPosition().intValue() == 10) {
                        postiton = "副主编,数字编委";
                    } else if (published.getChosenPosition().intValue() == 1) {
                        postiton = "编委";
                    } else if (published.getChosenPosition().intValue() == 9) {
                        postiton = "编委,数字编委";
                    }
                    userIdsAndPostions.put(declaration.getUserId(), postiton);
                }
                for (WriterUserManagerVO writerUserManagerVO : pageResult.getRows()) {
                    String postion = userIdsAndPostions.get(writerUserManagerVO.getId());
                    if (null != postion) {
                        writerUserManagerVO.setPosition(postion);
                    }
                }
            }
        }
    }
    // 设置职位 end
    return pageResult;
}
Also used : WriterUserManagerVO(com.bc.pmpheep.back.vo.WriterUserManagerVO) HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) Declaration(com.bc.pmpheep.back.po.Declaration)

Example 7 with DecPositionPublished

use of com.bc.pmpheep.back.po.DecPositionPublished 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

DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)7 Textbook (com.bc.pmpheep.back.po.Textbook)5 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)5 ArrayList (java.util.ArrayList)5 DecPosition (com.bc.pmpheep.back.po.DecPosition)4 Declaration (com.bc.pmpheep.back.po.Declaration)4 Material (com.bc.pmpheep.back.po.Material)3 PmphUser (com.bc.pmpheep.back.po.PmphUser)3 HashMap (java.util.HashMap)3 UserMessage (com.bc.pmpheep.back.po.UserMessage)2 NewDecPosition (com.bc.pmpheep.back.vo.NewDecPosition)2 Message (com.bc.pmpheep.general.po.Message)2 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)2 PageResult (com.bc.pmpheep.back.plugin.PageResult)1 Org (com.bc.pmpheep.back.po.Org)1 OrgUser (com.bc.pmpheep.back.po.OrgUser)1 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)1 PmphRole (com.bc.pmpheep.back.po.PmphRole)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)1