Search in sources :

Example 16 with Declaration

use of com.bc.pmpheep.back.po.Declaration 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);
}
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) WebScocketMessage(com.bc.pmpheep.websocket.WebScocketMessage) UserMessage(com.bc.pmpheep.back.po.UserMessage) Declaration(com.bc.pmpheep.back.po.Declaration)

Example 17 with Declaration

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

the class DeclarationServiceTest method getDeclarationByMaterialIdAndUserId.

@Test
public void getDeclarationByMaterialIdAndUserId() {
    add();
    Declaration declaration = declarationService.getDeclarationByMaterialIdAndUserId(2L, 1L);
    Assert.assertNotNull("获取作家申报表信息失败", declaration);
}
Also used : Declaration(com.bc.pmpheep.back.po.Declaration) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 18 with Declaration

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

the class DeclarationServiceTest method testAddDeclaration.

@Test
@Rollback(Const.ISROLLBACK)
public void testAddDeclaration() {
    Declaration declaration = new Declaration();
    declaration.setMaterialId(5L);
    declaration.setUserId(6L);
    declaration = declarationService.addDeclaration(declaration);
    Assert.assertTrue("添加数据失败", declaration.getId() > 0);
}
Also used : Declaration(com.bc.pmpheep.back.po.Declaration) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 19 with Declaration

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

the class DeclarationServiceTest method testGetDeclaration.

@Test
@Rollback(Const.ISROLLBACK)
public void testGetDeclaration() {
    long id = add().getId();
    Declaration declaration = declarationService.getDeclarationById(id);
    Assert.assertNotNull("获取作家申报表信息失败", declaration);
}
Also used : Declaration(com.bc.pmpheep.back.po.Declaration) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Aggregations

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