Search in sources :

Example 1 with WriterUserTrendst

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

the class BookUserCommentServiceImpl method updateBookUserCommentByAuth.

@Override
public String updateBookUserCommentByAuth(Long[] ids, Integer isAuth, String sessionId) throws CheckedServiceException {
    String result = "FAIL";
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ArrayUtil.isEmpty(ids)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
    }
    if (ObjectUtil.isNull(isAuth)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "审核内容为空");
    }
    int num = 0;
    for (Long id : ids) {
        BookUserComment bookUserComment = bookUserCommentDao.getBookUserCommentById(id);
        if (bookUserComment.getIsAuth() != 0) {
            throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.ILLEGAL_PARAM, "您选中的评论中有已经审核完成的评论,请确认后再次提交");
        }
        if (isAuth == 1) {
            WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
            writerUserTrendst.setUserId(bookUserComment.getWriterId());
            writerUserTrendst.setType(5);
            writerUserTrendst.setBookId(bookUserComment.getBookId());
            writerUserTrendst.setBookCommentId(id);
            writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
        }
        bookUserComment.setId(id);
        bookUserComment.setIsAuth(isAuth);
        bookUserComment.setAuthUserId(pmphUser.getId());
        bookUserComment.setAuthDate(DateUtil.getCurrentTime());
        num += bookUserCommentDao.updateBookUserComment(bookUserComment);
        if (isAuth == 1) {
            // 更新评分
            bookService.updateBookCore(bookUserComment.getBookId());
            // 更新书的评论数
            bookService.updateUpComments(bookUserComment.getBookId());
        }
        // 当用户评论过后 增加相应积分
        if (isAuth == 1) {
            String ruleName = "图书评论";
            writerPointLogService.addWriterPointLogByRuleName(ruleName, bookUserComment.getWriterId());
        }
    }
    if (num > 0) {
        result = "SUCCESS";
    }
    return result;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) BookUserComment(com.bc.pmpheep.back.po.BookUserComment) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterPoint(com.bc.pmpheep.back.po.WriterPoint)

Example 2 with WriterUserTrendst

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

the class DeclarationServiceImpl method confirmPaperList.

@Override
public Declaration confirmPaperList(Long id, Integer offlineProgress, String sessionId) throws CheckedServiceException, IOException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "主键不能为空!");
    }
    if (ObjectUtil.isNull(offlineProgress)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "确认收到纸质表不能为空!");
    }
    // 纸质表审核人id
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.OBJECT_NOT_FOUND, "审核人为空!");
    }
    // 纸质表审核人Id为登陆用户ID
    Long authUserId = pmphUser.getId();
    // 获取当前作家用户申报信息
    Declaration declarationCon = declarationDao.getDeclarationById(id);
    // 获取教材
    Material material = materialService.getMaterialById(declarationCon.getMaterialId());
    if (ObjectUtil.isNull(declarationCon)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.OBJECT_NOT_FOUND, "查询结果为空!");
    }
    // 纸质表审核人id
    declarationCon.setAuthUserId(authUserId);
    Date date = new Date();
    // 纸质表收到时间
    declarationCon.setPaperDate(new Timestamp(date.getTime()));
    declarationCon.setOfflineProgress(offlineProgress);
    declarationDao.updateDeclaration(declarationCon);
    WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
    writerUserTrendst.setUserId(declarationCon.getUserId());
    // 自己可见
    writerUserTrendst.setIsPublic(false);
    writerUserTrendst.setType(8);
    String detail = "";
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("title", CheckedExceptionBusiness.MATERIAL);
    if (0 == offlineProgress) {
        map.put("content", "抱歉,您在《" + material.getMaterialName() + "》提交的申报纸质表被退回,请您核对后重试。");
    } else {
        map.put("content", "您好,人民卫生出版社已收到您在《" + material.getMaterialName() + "》提交的申报纸质表,感谢您的参与,请耐心等待遴选结果。");
    }
    map.put("img", 1);
    detail = new Gson().toJson(map);
    writerUserTrendst.setDetail(detail);
    writerUserTrendst.setCmsContentId(null);
    writerUserTrendst.setBookId(declarationCon.getMaterialId());
    writerUserTrendst.setBookCommentId(null);
    writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
    Boolean isPass = true;
    if (0 == offlineProgress) {
        isPass = false;
    }
    // 发送系统消息
    systemMessageService.sendWhenReceiptAudit(declarationCon.getId(), isPass);
    return declarationCon;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) Timestamp(java.sql.Timestamp) Date(java.util.Date) Declaration(com.bc.pmpheep.back.po.Declaration)

Example 3 with WriterUserTrendst

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

the class DeclarationServiceImpl method onlineProgress.

@Override
public Declaration onlineProgress(Long id, Integer onlineProgress, String returnCause) throws CheckedServiceException, IOException {
    if (ObjectUtil.isNull(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "主键不能为空!");
    }
    if (ObjectUtil.isNull(onlineProgress)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "审核进度不能为空!");
    }
    // 获取当前作家用户申报信息
    Declaration declarationCon = declarationDao.getDeclarationById(id);
    // 获取教材
    Material material = materialService.getMaterialById(declarationCon.getMaterialId());
    // 提交出版社,出版社点击通过
    if (3 == onlineProgress.intValue() && 1 == declarationCon.getOnlineProgress() && 0 == declarationCon.getOrgId()) {
        declarationCon.setOnlineProgress(onlineProgress);
        declarationDao.updateDeclaration(declarationCon);
        // 添加动态信息
        WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
        writerUserTrendst.setUserId(declarationCon.getUserId());
        // 自己可见
        writerUserTrendst.setIsPublic(false);
        writerUserTrendst.setType(8);
        String detail = "";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.MATERIAL);
        map.put("content", "恭喜!您提交的《" + material.getMaterialName() + "》申报表已通过出版社审核。");
        map.put("img", 1);
        detail = new Gson().toJson(map);
        writerUserTrendst.setDetail(detail);
        writerUserTrendst.setCmsContentId(null);
        writerUserTrendst.setBookId(declarationCon.getMaterialId());
        writerUserTrendst.setBookCommentId(null);
        writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
        // 发送系统消息
        systemMessageService.sendWhenDeclarationFormAudit(declarationCon.getId(), true, returnCause);
    // 获取审核进度是4并且已经通过审核单位并且不是提交到出版社0则被退回给申报单位
    // 提交审核单位,审核单位已经通过,出版社退回给申报单位操作
    } else if (4 == onlineProgress.intValue() && 3 == declarationCon.getOnlineProgress() && 0 != declarationCon.getOrgId()) {
        List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
        for (DecPosition decPositions : decPosition) {
            Integer chosenPosition = decPositions.getChosenPosition();
            if (null != chosenPosition && chosenPosition.intValue() > 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给申报单位!");
            }
        }
        declarationCon.setOnlineProgress(onlineProgress);
        if (StringUtil.strLength(returnCause) > 100) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
        }
        declarationCon.setReturnCause(returnCause);
        declarationDao.updateDeclaration(declarationCon);
        // 添加动态信息
        /*WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
			writerUserTrendst.setUserId(declarationCon.getUserId());
			writerUserTrendst.setIsPublic(false);// 自己可见
			writerUserTrendst.setType(8);
			String detail = "";
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("title", CheckedExceptionBusiness.MATERIAL);
			map.put("content", "抱歉,贵校老师" + declarationCon.getRealname() + "提交的《" + material.getMaterialName()
					+ "》申报表被出版社退回,退回原因:" + returnCause + ",请贵校核对后重试。");
			map.put("img", 2);
			detail = new Gson().toJson(map);
			writerUserTrendst.setDetail(detail);
			writerUserTrendst.setCmsContentId(null);
			writerUserTrendst.setBookId(declarationCon.getMaterialId());
			writerUserTrendst.setBookCommentId(null);
			writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);*/
        // 发送系统消息
        systemMessageService.sendWhenDeclarationFormAuditToOrgUser(declarationCon.getId(), false, returnCause, onlineProgress);
    // 获取审核进度是5并且已经通过审核单位并且不是提交到出版社0则被退回给个人
    // 提交审核单位,审核单位已经通过,出版社退回给个人操作
    } else if (5 == onlineProgress.intValue() && 3 == declarationCon.getOnlineProgress() && 0 != declarationCon.getOrgId()) {
        List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
        for (DecPosition decPositions : decPosition) {
            Integer chosenPosition = decPositions.getChosenPosition();
            if (null != chosenPosition && chosenPosition.intValue() > 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给个人!");
            }
        }
        declarationCon.setOnlineProgress(onlineProgress);
        if (StringUtil.strLength(returnCause) > 100) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
        }
        declarationCon.setReturnCause(returnCause);
        declarationDao.updateDeclaration(declarationCon);
        // 添加动态信息
        WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
        writerUserTrendst.setUserId(declarationCon.getUserId());
        // 自己可见
        writerUserTrendst.setIsPublic(false);
        writerUserTrendst.setType(8);
        String detail = "";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.MATERIAL);
        map.put("content", "抱歉,您提交的《" + material.getMaterialName() + "》申报表被出版社退回," + "退回原因:" + returnCause + ",请您核对后重试。");
        map.put("img", 2);
        detail = new Gson().toJson(map);
        writerUserTrendst.setDetail(detail);
        writerUserTrendst.setCmsContentId(null);
        writerUserTrendst.setBookId(declarationCon.getMaterialId());
        writerUserTrendst.setBookCommentId(null);
        writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
        // 发送系统消息
        systemMessageService.sendWhenDeclarationFormAuditToOrgUser(declarationCon.getId(), false, returnCause, onlineProgress);
    // 获取审核进度是5并且机构id为出版社0则被退回给个人
    // 提交到出版社,出版社退回给个人操作
    } else if (5 == onlineProgress.intValue() && 0 == declarationCon.getOrgId()) {
        List<DecPosition> decPosition = decPositionDao.listDecPositions(id);
        for (DecPosition decPositions : decPosition) {
            Integer chosenPosition = decPositions.getChosenPosition();
            if (null != chosenPosition && chosenPosition.intValue() > 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "已遴选职务,不可退回给个人!");
            }
        }
        declarationCon.setOnlineProgress(onlineProgress);
        if (StringUtil.strLength(returnCause) > 100) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "最多只能输入100个字符,请重新输入!");
        }
        declarationCon.setReturnCause(returnCause);
        declarationDao.updateDeclaration(declarationCon);
        // 添加动态信息
        WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
        writerUserTrendst.setUserId(declarationCon.getUserId());
        // 自己可见
        writerUserTrendst.setIsPublic(false);
        writerUserTrendst.setType(8);
        String detail = "";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.MATERIAL);
        map.put("content", "抱歉,您提交的《" + material.getMaterialName() + "》申报表被出版社退回," + "退回原因:" + returnCause + ",请您核对后重试。");
        map.put("img", 2);
        detail = new Gson().toJson(map);
        writerUserTrendst.setDetail(detail);
        writerUserTrendst.setCmsContentId(null);
        writerUserTrendst.setBookId(declarationCon.getMaterialId());
        writerUserTrendst.setBookCommentId(null);
        writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
        // 发送系统消息
        systemMessageService.sendWhenDeclarationFormAudit(declarationCon.getId(), false, returnCause);
    }
    return declarationCon;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) DecPosition(com.bc.pmpheep.back.po.DecPosition) List(java.util.List) ArrayList(java.util.ArrayList) Declaration(com.bc.pmpheep.back.po.Declaration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with WriterUserTrendst

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

the class TextbookServiceImpl method updateTextbookAndMaterial.

@Override
public Integer updateTextbookAndMaterial(Long[] ids, String sessionId, Long materialId) throws CheckedServiceException, Exception {
    // 获取当前用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    // if (!pmphUser.getIsAdmin()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
    // CheckedExceptionResult.ILLEGAL_PARAM,
    // "该用户没有操作权限");
    // }
    // 教材权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    Integer power = null;
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName())) {
            // 我是系统管理原
            power = 1;
        }
    }
    // 教材主任检查
    Material material = materialService.getMaterialById(materialId);
    if (null == power) {
        if (null != material && null != material.getDirector() && pmphUser.getId().equals(material.getDirector())) {
            // 我是教材的主任
            power = 2;
        }
    }
    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, "还未确认编委,不能进行公布");
            }
        }
    }
    Material materials = new Material();
    List<Long> textBookIds = new ArrayList<>(textbooks.size());
    for (Textbook textbook : textbooks) {
        // if(Const.TRUE==textbook.getIsPublished()){
        // throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK,
        // CheckedExceptionResult.ILLEGAL_PARAM,"名单已确认");
        // }
        // if(textbook.getIsPublished()) {
        Textbook textbook2 = new Textbook(textbook.getId(), textbook.getRevisionTimes().intValue() + 1).setIsPublished(true);
        textbook2.setRevisionTimes(textbook.getRevisionTimes().intValue() + 1);
        textbookDao.updateTextbook(textbook2);
        // }else {
        // Textbook textbook2 = new Textbook(textbook.getId(), 0).setIsPublished(true);
        // textbook2.setRevisionTimes(0) ;
        // textbookDao.updateTextbook(textbook2);
        // }
        materials.setId(textbook.getMaterialId());
        textBookIds.add(textbook.getId());
    }
    // textbookDao.updateBookPublished(textBooks);
    // textbookDao.updateTextbook(textbook);
    /**
     * 下面是发布更新最终结果表的数据
     */
    // 获取这些书的申报者
    List<DecPosition> lst = decPositionService.listDecPositionsByTextBookIds(textBookIds);
    // 这些书的被遴选者
    List<DecPositionPublished> decPositionPublishedLst = new ArrayList<DecPositionPublished>(lst.size());
    for (DecPosition decPosition : lst) {
        if (null == decPosition || null == decPosition.getChosenPosition() || decPosition.getChosenPosition() <= 0) {
            continue;
        }
        DecPositionPublished decPositionPublished = new DecPositionPublished();
        decPositionPublished.setPublisherId(pmphUser.getId());
        decPositionPublished.setDeclarationId(decPosition.getDeclarationId());
        decPositionPublished.setTextbookId(decPosition.getTextbookId());
        decPositionPublished.setPresetPosition(decPosition.getPresetPosition());
        decPositionPublished.setIsOnList(true);
        decPositionPublished.setChosenPosition(decPosition.getChosenPosition());
        decPositionPublished.setRank(decPosition.getRank());
        decPositionPublished.setSyllabusId(decPosition.getSyllabusId());
        decPositionPublished.setSyllabusName(decPosition.getSyllabusName());
        decPositionPublishedLst.add(decPositionPublished);
    }
    List<DecPositionPublished> olds = decPositionPublishedService.getDecPositionPublishedListByBookIds(textBookIds);
    List<DecPositionPublished> sends = new ArrayList<>();
    for (DecPositionPublished now : decPositionPublishedLst) {
        if (ObjectUtil.notNull(now.getRank())) {
            sends.add(now);
        } else {
            DecPositionPublished published = decPositionPublishedService.getDecPositionByDeclarationId(now.getDeclarationId(), now.getTextbookId());
            if (ObjectUtil.isNull(published)) {
                sends.add(now);
            }
            for (DecPositionPublished old : olds) {
                if (old.getDeclarationId().equals(now.getDeclarationId()) && old.getTextbookId().equals(now.getTextbookId())) {
                    if (!old.getChosenPosition().equals(now.getChosenPosition())) {
                        sends.add(now);
                    } else {
                        if (null == now.getRank() && null == now.getRank()) {
                        } else if (null != now.getRank() && null != now.getRank()) {
                            if (!now.getRank().equals(now.getRank())) {
                                sends.add(now);
                            }
                        } else {
                            sends.add(now);
                        }
                    }
                }
            }
        }
    }
    // 先删除dec_position_published表中的所有数据
    decPositionPublishedService.deleteDecPositionPublishedByBookIds(textBookIds);
    // 向dec_position_published插入新数据
    decPositionPublishedService.batchInsertDecPositionPublished(decPositionPublishedLst);
    /**
     * 发布更新最终结果表的数据 ---end ---
     */
    // List<Textbook> books = materialDao.getMaterialAndTextbook(materials);
    List<Textbook> books = textbookService.getTextbookByMaterialId(materials.getId());
    Integer count = 0;
    /* 通过遍历查看教材下面所有书籍是否公布,当数据全部公布则该教材改为最终公布 */
    for (Textbook book : books) {
        if (book.getIsPublished()) {
            count++;
        }
    }
    if (count == books.size()) {
        // 检查有没有再次公布
        PageResult<BookPositionVO> listBookPosition = this.listBookPosition(1, 9999999, null, null, null, materials.getId(), sessionId);
        boolean haveNo = true;
        for (BookPositionVO bookPositionVO : listBookPosition.getRows()) {
            if (bookPositionVO.getIsPublished() && bookPositionVO.getRepub()) {
                haveNo = false;
                break;
            }
        }
        if (haveNo) {
            count = materialDao.updateMaterialPublished(materials);
        }
    }
    // 发送消息
    for (Textbook textbook : textbooks) {
        systemMessageService.sendWhenPubfinalResult(textbook.getId(), sends);
    }
    // 当教材遴选结束时给为遴选上的用户推送消息
    Material material2 = materialService.getMaterialById(materialId);
    if (ObjectUtil.notNull(material2)) {
        if (material2.getIsAllTextbookPublished()) {
            List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
            systemMessageService.sendWhenPositionChooserLoss(materialId, declaration);
        }
    }
    // 遍历被遴选人发送动态 和被修改成专家
    for (DecPositionPublished decPositionPublished : decPositionPublishedLst) {
        if (null == decPositionPublished || null == decPositionPublished.getChosenPosition() || decPositionPublished.getChosenPosition() <= 0) {
            continue;
        }
        // 获取申报表
        Declaration declarationById = declarationService.getDeclarationById(decPositionPublished.getDeclarationId());
        // 修改成专家
        WriterUser writerUser = new WriterUser();
        writerUser.setId(declarationById.getUserId());
        writerUser.setIsExpert(true);
        writerUser.setRank(3);
        writerUserService.update(writerUser);
        // 获取书籍
        Textbook textbook = textbookService.getTextbookById(decPositionPublished.getTextbookId());
        // 作家遴选
        String showChosenPosition = "";
        if (decPositionPublished.getChosenPosition() != 0) {
            switch(decPositionPublished.getChosenPosition()) {
                case 1:
                    showChosenPosition = "编委";
                    break;
                case 2:
                    showChosenPosition = "副主编";
                    break;
                case 3:
                    showChosenPosition = "副主编,编委";
                    break;
                case 4:
                    showChosenPosition = "主编";
                    break;
                case 5:
                    showChosenPosition = "主编,编委";
                    break;
                case 6:
                    showChosenPosition = "主编,副主编";
                    break;
                case 7:
                    showChosenPosition = "主编,副主编,编委";
                    break;
                case 8:
                    showChosenPosition = "数字编委";
                    break;
                case 9:
                    showChosenPosition = "编委,数字编委";
                    break;
                case 10:
                    showChosenPosition = "副主编,数字编委";
                    break;
                case 11:
                    showChosenPosition = "副主编,编委,数字编委";
                    break;
                case 12:
                    showChosenPosition = "主编,数字编委";
                    break;
                case 13:
                    showChosenPosition = "主编,编委,数字编委";
                    break;
                case 14:
                    showChosenPosition = "主编,副主编,数字编委";
                    break;
                case 15:
                    showChosenPosition = "主编,副主编,编委,数字编委";
                    break;
                default:
                    break;
            }
        }
        // 添加动态信息
        WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
        writerUserTrendst.setUserId(declarationById.getUserId());
        // 自己可见
        writerUserTrendst.setIsPublic(false);
        writerUserTrendst.setType(8);
        String detail = "";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("title", CheckedExceptionBusiness.MATERIAL);
        map.put("content", "您已被遴选为《" + textbook.getTextbookName() + "》的" + showChosenPosition + "。");
        map.put("img", 1);
        detail = new Gson().toJson(map);
        writerUserTrendst.setDetail(detail);
        writerUserTrendst.setCmsContentId(null);
        writerUserTrendst.setBookId(declarationById.getMaterialId());
        writerUserTrendst.setBookCommentId(null);
        writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
    }
    return count;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) PmphRole(com.bc.pmpheep.back.po.PmphRole) Declaration(com.bc.pmpheep.back.po.Declaration) WriterUser(com.bc.pmpheep.back.po.WriterUser) WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished) BookPositionVO(com.bc.pmpheep.back.vo.BookPositionVO) DecPosition(com.bc.pmpheep.back.po.DecPosition) Textbook(com.bc.pmpheep.back.po.Textbook)

Example 5 with WriterUserTrendst

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

the class TopicServiceImpl method update.

@Override
public String update(TopicLog topicLog, String sessionId, Topic topic) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空!");
    }
    topicLog.setUserId(pmphUser.getId());
    if (ObjectUtil.isNull(topic) || ObjectUtil.isNull(topic.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "该选题不存在");
    }
    if (!StringUtil.isEmpty(topic.getAuthFeedback())) {
        if (topic.getAuthFeedback().length() > 200) {
            throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "审核意见过长,请不要超过200个字符");
        }
    }
    if (!StringUtil.isEmpty(topic.getReasonDirector())) {
        if (topic.getReasonDirector().length() > 200) {
            throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "退回原因过长,请不要超过200个字符");
        }
    }
    if (!StringUtil.isEmpty(topic.getReasonEditor())) {
        if (topic.getReasonEditor().length() > 200) {
            throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "退回原因过长,请不要超过200个字符");
        }
    }
    String result = "FIAL";
    if (topicDao.update(topic) > 0) {
        topicLogService.add(topicLog);
        result = "SUCCESS";
    }
    WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
    writerUserTrendst.setUserId(topicDao.getTopicTextVO(topic.getId()).getUserId());
    writerUserTrendst.setBookId(topic.getId());
    writerUserTrendst.setType(9);
    writerUserTrendst.setIsPublic(false);
    if (ObjectUtil.notNull(topic.getAuthProgress())) {
        if (StringUtil.isEmpty(topic.getAuthFeedback())) {
            throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "审核意见不能为空");
        }
        if (3 == topic.getAuthProgress()) {
            Map<String, Object> detail = new HashMap<String, Object>();
            detail.put("title", CheckedExceptionBusiness.TOPIC);
            detail.put("content", "您的选题《" + topicDao.get(topic.getId()).getBookname() + "》已经通过。");
            detail.put("img", 1);
            writerUserTrendst.setDetail(new Gson().toJson(detail));
        // 创建本版号并将本版号放入数据中
        // String editionnum = "10" + new SimpleDateFormat("yyyy").format(new Date());
        // String vn = topicDao.get(topic.getId()).getVn();
        // if (StringUtil.isEmpty(vn)) {
        // vn = topicDao.getMaxTopicVn();
        // if (StringUtil.isEmpty(vn)) {
        // vn = editionnum + "000001";
        // } else {
        // vn = editionnum + Integer.parseInt(vn.substring(7)) + 1000000 + 1 + "";
        // }
        // }
        // topic.setNote("选题通过");
        // topic.setVn(vn);
        // topicDao.update(topic);
        // String remark = topic.getAuthFeedback();
        // TopicTextVO topicTextVO = topicTextVO(topicLog, sessionId, topic.getId());
        // String sql = "insert into i_declarestates
        // (editionnum,rwusercode,rwusername,topicname,readerpeople,sources,fontcount,piccount,timetohand,subject,booktype,levels,depositbank,bankaccount,selectreason,publishingvalue,content,authorbuybooks,authorsponsor,originalname,originalauthor,originalnationality,originalpress,publishagerevision,topicnumber,auditstates,remark,creattime,states)";
        // sql += "values('" + vn + "','" + topicTextVO.getUsername() + "','" +
        // topicTextVO.getRealname()
        // + "','','" + topicTextVO.getReadType() + "','" + topicTextVO.getSourceType()
        // + "','"
        // + topicTextVO.getWordNumber() + "','" + topicTextVO.getPictureNumber() +
        // "','"
        // + DateUtil.formatTimeStamp("yyyy-MM-dd", topicTextVO.getDeadline()) + "','"
        // + topicTextVO.getSubject() + "','" + topicTextVO.getTypeName() + "','" +
        // topicTextVO.getRank()
        // + "','" + topicTextVO.getBank() + "','" + topicTextVO.getAccountNumber() +
        // "','"
        // + topicTextVO.getTopicExtra().getReason() + "','" +
        // topicTextVO.getTopicExtra().getPrice()
        // + "','" + topicTextVO.getTopicExtra().getScore() + "','" +
        // topicTextVO.getPurchase() + "','"
        // + topicTextVO.getSponsorship() + "','" + topicTextVO.getOriginalBookname() +
        // "','"
        // + topicTextVO.getOriginalAuthor() + "','" + topicTextVO.getNation() +
        // "','','"
        // + topicTextVO.getEdition() + "','','11','" + remark + "',GETDATE(),1)";
        // SqlHelper.executeUpdate(sql, null);
        } else {
            Map<String, Object> detail = new HashMap<String, Object>();
            detail.put("title", CheckedExceptionBusiness.TOPIC);
            detail.put("content", "您的选题《" + topicDao.get(topic.getId()).getBookname() + "》未通过。");
            detail.put("img", 2);
            writerUserTrendst.setDetail(new Gson().toJson(detail));
        }
        writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
    }
    return result;
}
Also used : WriterUserTrendst(com.bc.pmpheep.back.po.WriterUserTrendst) PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) JSONObject(net.sf.json.JSONObject)

Aggregations

WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)9 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)8 PmphUser (com.bc.pmpheep.back.po.PmphUser)6 Gson (com.google.gson.Gson)5 HashMap (java.util.HashMap)5 Declaration (com.bc.pmpheep.back.po.Declaration)3 Material (com.bc.pmpheep.back.po.Material)3 CmsContent (com.bc.pmpheep.back.po.CmsContent)2 DecPosition (com.bc.pmpheep.back.po.DecPosition)2 ArrayList (java.util.ArrayList)2 BookCorrection (com.bc.pmpheep.back.po.BookCorrection)1 BookUserComment (com.bc.pmpheep.back.po.BookUserComment)1 DecPositionPublished (com.bc.pmpheep.back.po.DecPositionPublished)1 PmphRole (com.bc.pmpheep.back.po.PmphRole)1 Textbook (com.bc.pmpheep.back.po.Textbook)1 WriterPoint (com.bc.pmpheep.back.po.WriterPoint)1 WriterUser (com.bc.pmpheep.back.po.WriterUser)1 BookPositionVO (com.bc.pmpheep.back.vo.BookPositionVO)1 BaseTest (com.bc.pmpheep.test.BaseTest)1 Timestamp (java.sql.Timestamp)1