Search in sources :

Example 11 with DecPosition

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

the class TextbookServiceImpl method updateTextbooks.

@Override
public Integer updateTextbooks(Long[] ids, String sessionId) {
    // 获取当前用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    // }
    if (null == ids) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
    }
    List<Textbook> textbooks = textbookDao.getTextbooks(ids);
    // 判断书籍是否存在
    if (textbooks.size() > 0) {
        for (Textbook textbook : textbooks) {
            // 是否存在策划编辑
            if (ObjectUtil.isNull(textbook.getPlanningEditor())) {
                throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未选择策划编辑,不能名单确认");
            }
            // 是否发布主编
            if (!textbook.getIsChiefPublished()) {
                throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未发布主编/副主编,不能名单确认");
            }
            List<DecPosition> decPosition = decPositionService.getDecPositionByTextbookId(textbook.getId());
            // 是否确认编委
            if (decPosition.size() == 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未确认编委,不能名单确认");
            }
        }
    }
    Integer count = 0;
    if (CollectionUtil.isNotEmpty(textbooks)) {
        count = textbookDao.updateTextbooks(textbooks);
    }
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) DecPosition(com.bc.pmpheep.back.po.DecPosition) Textbook(com.bc.pmpheep.back.po.Textbook) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 12 with DecPosition

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

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

the class DecPositionServiceTest method add.

private DecPosition add() {
    DecPosition decPosition = new DecPosition();
    decPosition.setDeclarationId(5L);
    decPosition.setTextbookId(1L);
    decPosition.setPresetPosition(2);
    decPositionService.addDecPosition(decPosition);
    DecPosition decPosition2 = new DecPosition(8L, 3L, 7);
    decPositionService.addDecPosition(decPosition2);
    DecPosition decPosition3 = new DecPosition(8L, 2L, 6);
    decPositionService.addDecPosition(decPosition3);
    DecPosition decPosition4 = new DecPosition(5L, 3L, 1);
    decPositionService.addDecPosition(decPosition4);
    DecPosition decPosition5 = new DecPosition(2L, 1L, 3);
    decPositionService.addDecPosition(decPosition5);
    return decPosition3;
}
Also used : DecPosition(com.bc.pmpheep.back.po.DecPosition)

Example 14 with DecPosition

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

the class DecPositionServiceTest method testUpdateDecPosition.

@Test
@Rollback(Const.ISROLLBACK)
public void testUpdateDecPosition() {
    DecPosition decPosition = add();
    decPosition.setIsOnList(true);
    decPosition.setChosenPosition(1);
    Integer count = decPositionService.updateDecPosition(decPosition);
    Assert.assertTrue("更新数据失败", count > 0);
}
Also used : DecPosition(com.bc.pmpheep.back.po.DecPosition) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

DecPosition (com.bc.pmpheep.back.po.DecPosition)14 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)8 ArrayList (java.util.ArrayList)7 Textbook (com.bc.pmpheep.back.po.Textbook)6 Declaration (com.bc.pmpheep.back.po.Declaration)5 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)4 Material (com.bc.pmpheep.back.po.Material)4 PmphUser (com.bc.pmpheep.back.po.PmphUser)4 NewDecPosition (com.bc.pmpheep.back.vo.NewDecPosition)3 BaseTest (com.bc.pmpheep.test.BaseTest)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 Rollback (org.springframework.test.annotation.Rollback)3 OrgUser (com.bc.pmpheep.back.po.OrgUser)2 UserMessage (com.bc.pmpheep.back.po.UserMessage)2 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)2 Message (com.bc.pmpheep.general.po.Message)2 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)2 Gson (com.google.gson.Gson)2 Map (java.util.Map)2