Search in sources :

Example 16 with PmphUser

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

the class DecPositionServiceImpl method updateDecPositionEditorSelection.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Integer updateDecPositionEditorSelection(String jsonDecPosition, Integer selectionType, Integer editorOrSubeditorType, Integer unselectedHold, Long textbookId, String sessionId) throws CheckedServiceException, IOException {
    if (StringUtil.isEmpty(jsonDecPosition)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "遴选职位不能为空");
    }
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    Integer count = 0;
    List<DecPosition> decPositions = // json字符串转List对象集合
    new JsonUtil().getArrayListObjectFromStr(DecPosition.class, jsonDecPosition);
    // 编委遴选界面 (0:未选中)
    Integer unselectedHold_0 = 0;
    if (CollectionUtil.isEmpty(decPositions) && unselectedHold_0 == unselectedHold && 2 == editorOrSubeditorType && 1 == selectionType) {
        // 编委遴选界面,没有人员被选中也可以进行暂存
        // 查询书籍下所有申报id
        List<Long> ids = decPositionService.getDecPositionIdByBookId(textbookId, editorOrSubeditorType);
        // 初始化作家职位申报表
        if (CollectionUtil.isNotEmpty(ids)) {
            decPositionService.updateDecPositionSetDefault(ids, editorOrSubeditorType);
        }
    } else {
        if (CollectionUtil.isEmpty(decPositions)) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "遴选职位为空");
        }
        // (1:确定,2:发布)
        Integer selectionType_1 = 1;
        Integer selectionType_2 = 2;
        // 获取书籍id
        textbookId = decPositions.get(0).getTextbookId();
        // 原来的历史遴选记录
        List<DecPosition> oldlist = decPositionService.listChosenDecPositionsByTextbookId(textbookId);
        // 1:确定
        if (selectionType_1.intValue() == selectionType.intValue()) {
            // 查询书籍下所有申报id
            List<Long> ids = decPositionService.getDecPositionIdByBookId(textbookId, editorOrSubeditorType);
            if (2 == editorOrSubeditorType) {
                // 遴选的编委ID
                List<Long> newEditorialMemberIds = new ArrayList<Long>();
                for (DecPosition decPosition : decPositions) {
                    if (1 == decPosition.getChosenPosition() || 8 == decPosition.getChosenPosition()) {
                        if (!ids.contains(decPosition.getId())) {
                            newEditorialMemberIds.add(decPosition.getId());
                        }
                    }
                }
                if (newEditorialMemberIds.isEmpty()) {
                    Textbook textbook = textbookService.getTextbookById(textbookId);
                    if (0 != textbook.getRevisionTimes()) {
                        textbookService.updatRevisionTimesByTextBookId(-1, textbookId);
                    }
                } else {
                    textbookService.updatRevisionTimesByTextBookId(1, textbookId);
                }
                // 清楚dec_position_temp表
                decPositionTempService.deleteDecPositionTempByTextbookId(textbookId);
            }
            // 初始化作家职位申报表
            if (CollectionUtil.isNotEmpty(ids)) {
                decPositionService.updateDecPositionSetDefault(ids, editorOrSubeditorType);
            }
            if (CollectionUtil.isNotEmpty(decPositions)) {
                count = decPositionDao.updateDecPositionEditorSelection(decPositions);
            }
            if (ObjectUtil.isNull(textbookId)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
            }
            // 用户类型
            Integer userType = 1;
            // 获取修改者id
            Long updaterId = pmphUser.getId();
            // 添加新的遴选记录
            textbookLogService.addTextbookLog(oldlist, textbookId, updaterId, userType);
        }
        // 2:发布
        if (selectionType_2.intValue() == selectionType.intValue()) {
            // 发布的时候 先确认
            this.updateDecPositionEditorSelection(jsonDecPosition, 1, editorOrSubeditorType, unselectedHold, textbookId, sessionId);
            if (ObjectUtil.isNull(textbookId)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
            }
            // 获取当前书籍书申报信息(包含没有被遴选上的)
            List<DecPosition> decPositionsList = decPositionService.listDecPositionsByTextBookIds(new ArrayList<Long>(Arrays.asList(textbookId)));
            if (CollectionUtil.isEmpty(decPositionsList)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "当前书籍还未遴选主编,副主编");
            }
            // DecPositionPublished对象集合
            List<DecPositionPublished> decPositionPublisheds = new ArrayList<DecPositionPublished>(decPositionsList.size());
            for (DecPosition decPosition : decPositionsList) {
                // 筛选出遴选上的主编副主编人员
                Integer chosenPosition = decPosition.getChosenPosition();
                if (null != chosenPosition && (chosenPosition == 4 || chosenPosition == 2 || chosenPosition == 12 || chosenPosition == 10)) {
                    chosenPosition = chosenPosition > 8 ? chosenPosition - 8 : chosenPosition;
                    decPositionPublisheds.add(new DecPositionPublished(pmphUser.getId(), decPosition.getDeclarationId(), textbookId, decPosition.getPresetPosition(), chosenPosition, decPosition.getRank(), decPosition.getSyllabusId(), decPosition.getSyllabusName()));
                }
            }
            // 已经公布的列表
            List<DecPositionPublished> lst = decPositionPublishedService.getDecPositionPublishedListByBookId(textbookId);
            List<DecPositionPublished> addNew = new ArrayList<DecPositionPublished>(16);
            for (DecPositionPublished item : lst) {
                // 编委 | 数字编委
                if (item.getChosenPosition() == 1 || item.getChosenPosition() >= 8) {
                    // item.setChosenPosition(item.getChosenPosition() > 8
                    // ?(item.getChosenPosition()-8):item.getChosenPosition() );
                    addNew.add(item);
                }
            }
            // 加入主编副主编
            for (DecPositionPublished item : decPositionPublisheds) {
                boolean no = true;
                for (DecPositionPublished itemadd : addNew) {
                    if (itemadd.getDeclarationId().intValue() == item.getDeclarationId().intValue()) {
                        no = false;
                        itemadd.setChosenPosition(item.getChosenPosition() + 8);
                        break;
                    }
                }
                if (no) {
                    addNew.add(item);
                }
            }
            // clear Id
            for (DecPositionPublished item : addNew) {
                item.setId(null);
            }
            // 对比重新发布之前于之后的不同
            List<DecPositionPublished> newMessage = new ArrayList<>();
            for (DecPositionPublished now : decPositionPublisheds) {
                DecPositionPublished published = decPositionPublishedService.getDecPositionByDeclarationId(now.getDeclarationId(), now.getTextbookId());
                if (ObjectUtil.isNull(published)) {
                    newMessage.add(now);
                }
                for (DecPositionPublished old : lst) {
                    if (now.getDeclarationId().equals(old.getDeclarationId())) {
                        if (!now.getChosenPosition().equals(old.getChosenPosition()) || !now.getRank().equals(old.getRank())) {
                            newMessage.add(now);
                        }
                    }
                }
            }
            // 先删除当前发布人已发布的
            decPositionPublishedService.deleteDecPositionPublishedByTextBookId(textbookId);
            // 再添加
            decPositionPublishedService.batchInsertDecPositionPublished(addNew);
            // 发布时更新textbook表中is_chief_published(是否已公布主编/副主编)字段
            count = textbookService.updateTextbook(new Textbook(textbookId, true));
            if (count > 0) {
                // 发送消息
                systemMessageService.sendWhenConfirmFirstEditor(textbookId, newMessage);
            }
        }
    }
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished) JsonUtil(com.bc.pmpheep.back.util.JsonUtil) DecPosition(com.bc.pmpheep.back.po.DecPosition) NewDecPosition(com.bc.pmpheep.back.vo.NewDecPosition) Textbook(com.bc.pmpheep.back.po.Textbook)

Example 17 with PmphUser

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

the class DecPositionServiceImpl method batchPublishEditor.

@Override
public Integer batchPublishEditor(List<Long> textbookIds, String sessionId) throws CheckedServiceException, IOException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(pmphUser.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(textbookIds)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "未选中书籍");
    }
    Integer count = 0;
    for (Long textbookId : textbookIds) {
        // 查询当前书籍已遴选的主编,副主编
        List<DecPosition> listDecPositions = this.getEditorByTextbookId(textbookId);
        if (CollectionUtil.isEmpty(listDecPositions)) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "当前选中书籍还未遴选主编,副主编");
        }
        // DecPositionPublished对象集合
        List<DecPositionPublished> decPositionPublisheds = new ArrayList<DecPositionPublished>(listDecPositions.size());
        for (DecPosition decPosition : listDecPositions) {
            decPositionPublisheds.add(new DecPositionPublished(pmphUser.getId(), decPosition.getDeclarationId(), textbookId, decPosition.getPresetPosition(), decPosition.getChosenPosition(), decPosition.getRank(), decPosition.getSyllabusId(), decPosition.getSyllabusName()));
        }
        // 删除已发布的主编,副主编
        decPositionPublishedService.deletePublishedEditorByTextbookId(textbookId);
        // 重新发布
        // 再添加
        decPositionPublishedService.batchInsertDecPositionPublished(decPositionPublisheds);
        // 发布时更新textbook表中is_chief_published(是否已公布主编/副主编)字段
        count = textbookService.updateTextbook(new Textbook(textbookId, true));
        if (count > 0) {
            // 发送消息
            systemMessageService.sendWhenConfirmFirstEditor(textbookId, decPositionPublisheds);
        }
    }
    return count;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) DecPosition(com.bc.pmpheep.back.po.DecPosition) NewDecPosition(com.bc.pmpheep.back.vo.NewDecPosition) ArrayList(java.util.ArrayList) Textbook(com.bc.pmpheep.back.po.Textbook) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) DecPositionPublished(com.bc.pmpheep.back.po.DecPositionPublished)

Example 18 with PmphUser

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

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

the class MaterialExtraServiceImpl method noticePublished.

@Override
public Integer noticePublished(Long materialId, List<Long> orgIds, String sessionId) throws CheckedServiceException, IOException {
    if (CollectionUtil.isEmpty(orgIds)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "机构为空");
    }
    // 防止网络延迟重复提交
    Set<Long> newOrgIdSet = new HashSet<>();
    newOrgIdSet.addAll(orgIds);
    List<Long> listOrgIds = new ArrayList<Long>(newOrgIdSet.size());
    listOrgIds.addAll(newOrgIdSet);
    // 获取当前用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    Integer count = 0;
    List<MaterialOrg> materialOrgList = new ArrayList<MaterialOrg>(listOrgIds.size());
    // 根据教材ID查询教材-机构关联表
    List<Long> OrgIds = materialOrgService.getListMaterialOrgByMaterialId(materialId);
    if (CollectionUtil.isEmpty(OrgIds)) {
        // 为空,初次发布
        for (Long orgId : listOrgIds) {
            materialOrgList.add(new MaterialOrg(materialId, orgId));
        }
        count = materialOrgService.addMaterialOrgs(materialOrgList);
        if (count > 0) {
            systemMessageService.materialSend(materialId, listOrgIds);
        }
    } else {
        // 不为空
        // 新选中的机构
        List<Long> newOrgIds = new ArrayList<Long>();
        for (Long orgId : listOrgIds) {
            if (!OrgIds.contains(orgId)) {
                newOrgIds.add(orgId);
                materialOrgList.add(new MaterialOrg(materialId, orgId));
            }
        }
        if (CollectionUtil.isEmpty(materialOrgList)) {
            throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA, CheckedExceptionResult.ILLEGAL_PARAM, "当前选中的学校已收到消息,无需要再次发送");
        }
        count = materialOrgService.addMaterialOrgs(materialOrgList);
        if (count > 0) {
            systemMessageService.materialSend(materialId, newOrgIds);
        }
    }
    CmsContent cmsContent = cmsContentService.getCmsContentByMaterialId(materialId);
    if (ObjectUtil.notNull(cmsContent)) {
        // throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_EXTRA,
        // CheckedExceptionResult.NULL_PARAM, "没有找到对应的教材通知信息");
        cmsContentService.updateCmsContent(new CmsContent(cmsContent.getId(), true, false, Const.CMS_AUTHOR_STATUS_2, // authUserId
        0L, // 为0代表系统审核
        DateUtil.formatTimeStamp("yyyy-MM-dd HH:mm:ss", DateUtil.getCurrentTime())));
    }
    count = materialService.updateMaterial(new Material(materialId, true), sessionId);
    return count;
}
Also used : CmsContent(com.bc.pmpheep.back.po.CmsContent) PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Material(com.bc.pmpheep.back.po.Material) MaterialOrg(com.bc.pmpheep.back.po.MaterialOrg) HashSet(java.util.HashSet)

Example 20 with PmphUser

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

the class MaterialServiceImpl method updateMaterial.

@Override
public String updateMaterial(Long id, String sessionId) throws CheckedServiceException {
    Material material = materialDao.getMaterialById(id);
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (pmphUser.getIsAdmin() || pmphUser.getId().equals(material.getDirector()) || pmphUser.getId().equals(material.getFounderId())) {
        List<Textbook> list = textbookService.getTextbookByMaterialId(id);
        for (Textbook textbook : list) {
            PmphGroup group = pmphGroupService.getPmphGroupByTextbookId(textbook.getId());
            if (ObjectUtil.notNull(group)) {
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您在" + textbook.getTextbookName() + "书籍下还有未解散的小组,请先解散小组");
            }
        }
        material = new Material();
        material.setId(id);
        material.setIsDeleted(true);
        materialDao.updateMaterial(material);
        cmsContentService.updateCmsContentByMaterialId(id);
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "您没有删除教材" + material.getMaterialName() + "的权限");
    }
    return "SUCCESS";
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Textbook(com.bc.pmpheep.back.po.Textbook) PmphGroup(com.bc.pmpheep.back.po.PmphGroup) Material(com.bc.pmpheep.back.po.Material) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5