Search in sources :

Example 1 with Declaration

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

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

use of com.bc.pmpheep.back.po.Declaration 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> decMainPosition = decPositionService.getMainDecPositionByTextbookId(textbook.getId());
            // 确认是否有主编副主编
            if (decMainPosition.size() == 0) {
                throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未遴选主编/副主编,不能进行公布");
            }
            // textbookDao.
            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);
    /*下面是向主任、项目编辑、策划编辑 发送企业微信推送*/
    // 向列表中书籍的主任、项目编辑、策划编辑,发送微信推送,内容拼接如下
    localMethodToLeaderWXMsg(pmphUser, textbooks, "结果公布");
    /**
     * 下面是发布更新最终结果表的数据
     */
    // 获取这些书的申报者
    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);
                        }
                    }
                }
            }
        }
    }
    // 被撤销的职位的人发动态
    for (DecPositionPublished old : olds) {
        // 初始化 是否被撤销
        boolean isDismissed = true;
        // 初始化 被撤销的职位
        int dismissPosition = old.getChosenPosition();
        for (DecPositionPublished now : decPositionPublishedLst) {
            if (old.getDeclarationId().equals(now.getDeclarationId()) && old.getTextbookId().equals(now.getTextbookId())) {
                isDismissed = false;
                // 被撤销的职务数字 = 原职务数字 按位与 (新职务数字 按位取反) [即原本有现在没有的]
                dismissPosition = old.getChosenPosition() & (~now.getChosenPosition());
            }
        }
        if (isDismissed) {
            // 撤销需要发动态的,从此处打开
            // 转换为文字
            String dismissPositionStr = "";
            if ((dismissPosition & 4) > 0) {
                dismissPositionStr += "主编";
            }
            if ((dismissPosition & 2) > 0) {
                dismissPositionStr += "副主编";
            }
            if ((dismissPosition & 1) > 0) {
                dismissPositionStr += "编委";
            }
            if ((dismissPosition & 8) > 0) {
                if (dismissPositionStr.length() > 0) {
                    dismissPositionStr += ",";
                }
                dismissPositionStr += "数字编委";
            }
            if (dismissPositionStr.length() > 0) {
                // 若存在被撤销的职务 发动态给相应作者
                // 添加动态信息
                WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
                writerUserTrendst.setUserId(old.getWriterUserId());
                // 自己可见
                writerUserTrendst.setIsPublic(false);
                writerUserTrendst.setType(8);
                String detail = "";
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("title", CheckedExceptionBusiness.MATERIAL);
                // map.put("content", "抱歉,您《" + old.getTextbookName() + "》的"+dismissPositionStr+"职务已被取消。");
                map.put("content", "您参加的教材“" + material.getMaterialName() + "”的《" + old.getTextbookName() + "》遴选已结束。");
                map.put("img", 2);
                detail = new Gson().toJson(map);
                writerUserTrendst.setDetail(detail);
                writerUserTrendst.setCmsContentId(null);
                writerUserTrendst.setBookId(materialId);
                writerUserTrendst.setBookCommentId(null);
                writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
            }
        }
    }
    // 先删除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, pmphUser);
    }
    // 当教材遴选结束时给为遴选上的用户推送消息
    Material material2 = materialService.getMaterialById(materialId);
    if (ObjectUtil.notNull(material2)) {
        if (material2.getIsAllTextbookPublished()) {
            List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
            systemMessageService.sendWhenPositionChooserLoss(materialId, declaration, pmphUser);
            if (null != declaration && declaration.size() > 0) {
                for (Declaration d : declaration) {
                    // 添加动态信息
                    WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
                    writerUserTrendst.setUserId(d.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", "教材已遴选结束,很遗憾,您未入选");
                    map.put("img", 2);
                    detail = new Gson().toJson(map);
                    writerUserTrendst.setDetail(detail);
                    writerUserTrendst.setCmsContentId(null);
                    writerUserTrendst.setBookId(materialId);
                    writerUserTrendst.setBookCommentId(null);
                    writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
                }
            }
        }
    }
    // 遍历被遴选人发送动态 和被修改成专家
    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 4 with Declaration

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

the class WriterUserServiceImpl method getListexpertUser.

@Override
public PageResult<WriterUserManagerVO> getListexpertUser(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);
    }
    if (!ObjectUtil.isNull(groupId)) {
        pageParameter.getParameter().setGroupId(groupId);
    }
    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.getListexpertUserTotal(pageParameter);
        if (total > 0) {
            List<WriterUserManagerVO> list = writerUserDao.getListexpertUser(pageParameter);
            for (int i = 0; i < list.size(); i++) {
                WriterUserManagerVO vo = list.get(i);
                String title = vo.getTitle();
                if (title != null) {
                    if (ObjectUtil.isNumber(title)) {
                        vo.setTitle(dataDictionaryDao.getDataDictionaryItemNameByCode(Const.WRITER_USER_TITLE, title));
                    }
                }
                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 (int i = 0; i < list.size(); i++) {
                WriterUserManagerVO vo = list.get(i);
                String voS = com.alibaba.fastjson.JSON.toJSONString(vo).replaceAll("-", "");
                vo = com.alibaba.fastjson.JSON.parseObject(voS, WriterUserManagerVO.class);
                list.remove(i);
                list.add(i, vo);
                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 5 with Declaration

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

the class TextbookLogServiceImpl method addTextbookLog.

@Override
public void addTextbookLog(List<DecPosition> oldlist, Long textbookId, Long updaterId, int userType) throws CheckedServiceException {
    if (null == textbookId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "书籍为空!");
    }
    if (null == updaterId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK_LOG, CheckedExceptionResult.NULL_PARAM, "修改者为空!");
    }
    List<DecPosition> newlist = decPositionService.listChosenDecPositionsByTextbookId(textbookId);
    int addSumZhuBian = 0;
    StringBuilder addZhuBian = new StringBuilder("");
    int redSumZhuBian = 0;
    StringBuilder redZhuBian = new StringBuilder("");
    int addSumFuZhuBian = 0;
    StringBuilder addFuZhuBian = new StringBuilder("");
    int redSumFuZhuBian = 0;
    StringBuilder redFuZhuBian = new StringBuilder("");
    int addSumBianWei = 0;
    StringBuilder addBianWei = new StringBuilder("");
    int redSumBianWei = 0;
    StringBuilder redBianWei = new StringBuilder("");
    int addSumShuZiBianWei = 0;
    StringBuilder addShuZiBianWei = new StringBuilder("");
    int redSumShuZiBianWei = 0;
    StringBuilder redShuZiBianWei = new StringBuilder("");
    // 新旧申报的id
    List<Long> ids = new ArrayList<>(oldlist.size() + newlist.size());
    for (DecPosition oldDecPosition : oldlist) {
        ids.add(oldDecPosition.getDeclarationId());
    }
    for (DecPosition newDecPosition : newlist) {
        ids.add(newDecPosition.getDeclarationId());
    }
    List<Declaration> declarations = declarationService.getDeclarationByIds(ids);
    // 增加的
    for (DecPosition newDecPosition : newlist) {
        // 申报者
        Long declarationId = newDecPosition.getDeclarationId();
        // 新的申报表
        Declaration declaration = new Declaration();
        for (Declaration tempDeclaration : declarations) {
            if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
                declaration = tempDeclaration;
                break;
            }
        }
        // 新选的职位
        Integer newChosenPosition = newDecPosition.getChosenPosition();
        // 是否是新增
        boolean isAdd = true;
        // 遍历出所有的旧的信息
        for (DecPosition oldDecPosition : oldlist) {
            if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
                isAdd = false;
                break;
            }
        }
        if (isAdd) {
            // 新增的主编
            if (null != newChosenPosition && (newChosenPosition == 4 || newChosenPosition == 12)) {
                addSumZhuBian++;
                addZhuBian.append("," + declaration.getRealname());
            }
            // 新增的副主编
            if (null != newChosenPosition && (newChosenPosition == 2 || newChosenPosition == 10)) {
                addSumFuZhuBian++;
                addFuZhuBian.append("," + declaration.getRealname());
            }
            // 新增的编委
            if (null != newChosenPosition && (newChosenPosition == 1 || newChosenPosition == 9)) {
                addSumBianWei++;
                addBianWei.append("," + declaration.getRealname());
            }
            // 新增的数字编委
            if (null != newChosenPosition && (newChosenPosition == 8 || newChosenPosition == 12 || newChosenPosition == 10 || newChosenPosition == 9)) {
                addSumShuZiBianWei++;
                addShuZiBianWei.append("," + declaration.getRealname());
            }
        }
    }
    // 减少的
    for (DecPosition oldDecPosition : oldlist) {
        // 申报者
        Long declarationId = oldDecPosition.getDeclarationId();
        // 老的申报表
        Declaration declaration = new Declaration();
        for (Declaration tempDeclaration : declarations) {
            if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
                declaration = tempDeclaration;
                break;
            }
        }
        // 老的的职位
        Integer oldChosenPosition = oldDecPosition.getChosenPosition();
        // 是否删除
        boolean isDel = true;
        // 遍历出所有新的信息
        for (DecPosition newDecPosition : newlist) {
            if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue()) {
                isDel = false;
                break;
            }
        }
        if (isDel) {
            // 移除了主编
            if (null != oldChosenPosition && (oldChosenPosition == 4 || oldChosenPosition == 12)) {
                redSumZhuBian++;
                redZhuBian.append("," + declaration.getRealname());
            }
            // 移除了副主编
            if (null != oldChosenPosition && (oldChosenPosition == 2 || oldChosenPosition == 10)) {
                redSumFuZhuBian++;
                redFuZhuBian.append("," + declaration.getRealname());
            }
            // 移除了编委
            if (null != oldChosenPosition && (oldChosenPosition == 1 || oldChosenPosition == 9)) {
                redSumBianWei++;
                redBianWei.append("," + declaration.getRealname());
            }
            // 移除了编委
            if (null != oldChosenPosition && (oldChosenPosition == 8 || oldChosenPosition == 12 || oldChosenPosition == 10 || oldChosenPosition == 9)) {
                redSumShuZiBianWei++;
                redShuZiBianWei.append("," + declaration.getRealname());
            }
        }
    }
    // 职位被修改的
    StringBuilder updateString = new StringBuilder("");
    boolean allUpdate = false;
    for (DecPosition newDecPosition : newlist) {
        // 申报者
        Long declarationId = newDecPosition.getDeclarationId();
        // 新的申报表
        Declaration declaration = new Declaration();
        for (Declaration tempDeclaration : declarations) {
            if (tempDeclaration.getId().intValue() == declarationId.intValue()) {
                declaration = tempDeclaration;
                break;
            }
        }
        // 新选的职位
        Integer newChosenPosition = newDecPosition.getChosenPosition();
        Integer newRank = newDecPosition.getRank();
        newRank = newRank == null ? 0 : newRank;
        // 是否是新增
        boolean isUpdate = false;
        // 遍历出所有的旧的信息
        for (DecPosition oldDecPosition : oldlist) {
            Integer oldChosenPosition = oldDecPosition.getChosenPosition();
            Integer oldRank = oldDecPosition.getRank();
            oldRank = oldRank == null ? 0 : oldRank;
            // 修改的是职位或者排序 都算
            if (oldDecPosition.getDeclarationId().intValue() == newDecPosition.getDeclarationId().intValue() && !(newChosenPosition.intValue() == oldChosenPosition.intValue() && newRank.intValue() == oldRank.intValue())) {
                isUpdate = true;
                break;
            }
        }
        if (isUpdate) {
            allUpdate = true;
            updateString.append("," + declaration.getRealname());
        }
    }
    // 遍历错误信息
    if (addSumZhuBian > 0 || redSumZhuBian > 0 || addSumFuZhuBian > 0 || redSumFuZhuBian > 0 || addSumBianWei > 0 || redSumBianWei > 0 || addSumShuZiBianWei > 0 || redSumShuZiBianWei > 0 || allUpdate) {
        StringBuilder detail = new StringBuilder("");
        if (redSumZhuBian > 0) {
            detail.append("移除了" + redSumZhuBian + "位主编:[" + redZhuBian.toString().substring(1) + "];");
        }
        if (redSumFuZhuBian > 0) {
            detail.append("移除了" + redSumFuZhuBian + "位副主编:[" + redFuZhuBian.toString().substring(1) + "];");
        }
        if (redSumBianWei > 0) {
            detail.append("移除了" + redSumBianWei + "位编委:[" + redBianWei.toString().substring(1) + "];");
        }
        if (redSumShuZiBianWei > 0) {
            detail.append("移除了" + redSumShuZiBianWei + "位数字编辑:[" + redShuZiBianWei.toString().substring(1) + "];");
        }
        if (addSumZhuBian > 0) {
            detail.append("增加了" + addSumZhuBian + "位主编:[" + addZhuBian.toString().substring(1) + "];");
        }
        if (addSumFuZhuBian > 0) {
            detail.append("增加了" + addSumFuZhuBian + "位副主编:[" + addFuZhuBian.toString().substring(1) + "];");
        }
        if (addSumBianWei > 0) {
            detail.append("增加了" + addSumBianWei + "位编委:[" + addBianWei.toString().substring(1) + "];");
        }
        if (addSumShuZiBianWei > 0) {
            detail.append("增加了" + addSumShuZiBianWei + "位数字编辑:[" + addShuZiBianWei.toString().substring(1) + "];");
        }
        if (allUpdate) {
            detail.append("修改了:[" + updateString.toString().substring(1) + "]的职位信息;");
        }
        String detail2 = detail.toString();
        // 去掉最后一个;
        detail2 = detail2.substring(0, detail2.length() - 1);
        TextbookLog textbookLog = new TextbookLog();
        textbookLog.setDetail(detail2.length() >= 100 ? detail2.substring(0, 95) + "..." : detail2);
        textbookLog.setIsPmphUpdater(userType == 1);
        textbookLog.setTextbookId(textbookId);
        textbookLog.setUpdaterId(updaterId);
        textbookLogDao.addTextbookLog(textbookLog);
    }
}
Also used : ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TextbookLog(com.bc.pmpheep.back.po.TextbookLog) DecPosition(com.bc.pmpheep.back.po.DecPosition) Declaration(com.bc.pmpheep.back.po.Declaration)

Aggregations

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