Search in sources :

Example 31 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class DecPositionServiceImpl method listDeclarationSituationBookResultVOs.

@Override
public PageResult<DeclarationSituationBookResultVO> listDeclarationSituationBookResultVOs(PageParameter<DeclarationSituationBookResultVO> pageParameter) throws CheckedServiceException {
    if (ObjectUtil.isNull(pageParameter.getParameter().getMaterialId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
    }
    String bookName = pageParameter.getParameter().getBookName();
    if (StringUtil.notEmpty(bookName)) {
        pageParameter.getParameter().setBookName(bookName);
    }
    PageResult<DeclarationSituationBookResultVO> pageResult = new PageResult<DeclarationSituationBookResultVO>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    int total = decPositionDao.getBooks(pageParameter.getParameter().getMaterialId());
    if (total > 0) {
        List<DeclarationSituationBookResultVO> books = decPositionDao.getBookListOne(pageParameter);
        List<DeclarationSituationBookResultVO> presets = decPositionDao.getBookResultPreset(pageParameter);
        List<DeclarationSituationBookResultVO> chosens = decPositionDao.getBookResultChosen(pageParameter);
        List<DeclarationSituationBookResultVO> middle = new ArrayList<>();
        List<DeclarationSituationBookResultVO> list = new ArrayList<>();
        if (null == presets || presets.isEmpty()) {
            for (DeclarationSituationBookResultVO book : books) {
                // 计算申报人数
                Integer presetPersons = book.getPresetPositionEditor() + book.getPresetPositionSubeditor() + book.getPresetPositionEditorial() + book.getPresetDigitalEditor();
                book.setPresetPersons(presetPersons);
                list.add(book);
            }
            pageResult.setRows(list);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationSituationBookResultVO book : books) {
            for (DeclarationSituationBookResultVO preset : presets) {
                if (preset.getId().equals(book.getId())) {
                    book.setPresetPositionEditor(preset.getPresetPositionEditor());
                    book.setPresetPositionSubeditor(preset.getPresetPositionSubeditor());
                    book.setPresetPositionEditorial(preset.getPresetPositionEditorial());
                    book.setPresetDigitalEditor(preset.getPresetDigitalEditor());
                    break;
                }
            }
            // 计算申报人数
            Integer presetPersons = book.getPresetPositionEditor() + book.getPresetPositionSubeditor() + book.getPresetPositionEditorial() + book.getPresetDigitalEditor();
            book.setPresetPersons(presetPersons);
            middle.add(book);
        }
        if (null == chosens || chosens.isEmpty()) {
            pageResult.setRows(middle);
            pageResult.setTotal(total);
            return pageResult;
        }
        for (DeclarationSituationBookResultVO book : middle) {
            for (DeclarationSituationBookResultVO chosen : chosens) {
                if (chosen.getId().equals(book.getId())) {
                    book.setChosenPositionEditor(chosen.getChosenPositionEditor());
                    book.setChosenPositionSubeditor(chosen.getChosenPositionSubeditor());
                    book.setChosenPositionEditorial(chosen.getChosenPositionEditorial());
                    book.setIsDigitalEditor(chosen.getIsDigitalEditor());
                    break;
                }
            }
            // 计算当选人数
            Integer chosenPersons = book.getChosenPositionEditor() + book.getChosenPositionSubeditor() + book.getChosenPositionEditorial() + book.getIsDigitalEditor();
            book.setChosenPersons(chosenPersons);
            list.add(book);
        }
        pageResult.setRows(list);
        pageResult.setTotal(total);
    }
    return pageResult;
}
Also used : ArrayList(java.util.ArrayList) DeclarationSituationBookResultVO(com.bc.pmpheep.back.vo.DeclarationSituationBookResultVO) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Example 32 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException 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 33 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class DecPositionServiceImpl method saveBooks.

@Override
public long saveBooks(DecPositionVO decPositionVO, HttpServletRequest request) throws IOException {
    List<NewDecPosition> list = decPositionVO.getList();
    if (CollectionUtil.isEmpty(list)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "添加内容不能为空");
    }
    List<DecPosition> istDecPositions = decPositionDao.listDecPositions(list.get(0).getDeclarationId());
    if (CollectionUtil.isEmpty(istDecPositions)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "内容不能为空");
    }
    String newId = ",";
    for (NewDecPosition newDecPosition : list) {
        // 遍历所有的id
        newId += newDecPosition.getId() + ",";
    }
    for (DecPosition DecPosition : istDecPositions) {
        // 遍历原数据
        if (!newId.contains("," + DecPosition.getId() + ",")) {
            if (ObjectUtil.notNull(DecPosition.getId())) {
                decPositionDao.deleteDecPosition(DecPosition.getId());
            }
        }
    }
    for (NewDecPosition newDecPosition : list) {
        Long id = newDecPosition.getId();
        Long declarationId = newDecPosition.getDeclarationId();
        Long textbookId = newDecPosition.getTextbookId();
        String file = newDecPosition.getFile();
        String showPosition = newDecPosition.getShowPosition();
        DecPosition decPosition = new DecPosition();
        if ("编委".equals(showPosition)) {
            decPosition.setPresetPosition(1);
        } else if ("副主编".equals(showPosition)) {
            decPosition.setPresetPosition(2);
        } else if ("副主编,编委".equals(showPosition)) {
            decPosition.setPresetPosition(3);
        } else if ("主编".equals(showPosition)) {
            decPosition.setPresetPosition(4);
        } else if ("主编,编委".equals(showPosition)) {
            decPosition.setPresetPosition(5);
        } else if ("主编,副主编".equals(showPosition)) {
            decPosition.setPresetPosition(6);
        } else if ("主编,副主编,编委".equals(showPosition)) {
            decPosition.setPresetPosition(7);
        } else if ("数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(8);
        } else if ("编委,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(9);
        } else if ("副主编,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(10);
        } else if ("副主编,编委,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(11);
        } else if ("主编,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(12);
        } else if ("主编,编委,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(13);
        } else if ("主编,副主编,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(14);
        } else if ("主编,副主编,编委,数字编委".equals(showPosition)) {
            decPosition.setPresetPosition(15);
        }
        File files = null;
        String fileName = null;
        if (StringUtil.isEmpty(file)) {
            decPosition.setSyllabusId(null);
            decPosition.setSyllabusName(null);
        } else {
            files = new File(file);
            if (files.exists()) {
                // 获取原文件名字
                fileName = files.getName();
                decPosition.setSyllabusName(fileName);
            } else {
                decPosition.setSyllabusId(null);
                decPosition.setSyllabusName(null);
            }
        }
        decPosition.setDeclarationId(declarationId);
        decPosition.setTextbookId(textbookId);
        decPosition.setId(id);
        if (ObjectUtil.isNull(id)) {
            // 保存或者修改
            decPositionDao.addDecPosition(decPosition);
            String fileNames = null;
            String mongoId = null;
            if (ObjectUtil.notNull(decPosition.getId()) && StringUtil.notEmpty(file)) {
                // mongoId = fileService.saveLocalFile(files, FileType.SYLLABUS,
                // decPosition.getId());
                byte[] fileByte = (byte[]) request.getSession(false).getAttribute(file);
                fileNames = (String) request.getSession(false).getAttribute("fileName_" + file);
                InputStream input = new ByteArrayInputStream(fileByte);
                mongoId = fileService.save(input, fileNames, FileType.SYLLABUS, decPosition.getId());
                if (StringUtil.isEmpty(mongoId)) {
                    throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.FILE_UPLOAD_FAILED, "文件上传失败!");
                }
            }
            if (StringUtil.notEmpty(mongoId)) {
                decPosition.setSyllabusId(mongoId);
                decPosition.setSyllabusName(fileNames);
                decPositionDao.updateDecPosition(decPosition);
            }
        } else {
            decPositionDao.updateDecPosition(decPosition);
        }
    }
    return list.size();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DecPosition(com.bc.pmpheep.back.po.DecPosition) NewDecPosition(com.bc.pmpheep.back.vo.NewDecPosition) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) File(java.io.File) NewDecPosition(com.bc.pmpheep.back.vo.NewDecPosition)

Example 34 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException 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 35 with CheckedServiceException

use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.

the class DeclarationServiceImpl method pageDeclaration.

@Override
public PageResult<DeclarationListVO> pageDeclaration(Integer pageNumber, Integer pageSize, Long materialId, String textBookids, String realname, String position, String title, String orgName, Long orgId, String unitName, Integer positionType, Integer onlineProgress, Integer offlineProgress, Boolean haveFile) throws CheckedServiceException {
    if (null == materialId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "教材为空");
    }
    Gson gson = new Gson();
    List<Long> bookIds = gson.fromJson(textBookids, new TypeToken<ArrayList<Long>>() {
    }.getType());
    // 拼装复合参数
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("materialId", materialId);
    if (null != bookIds && bookIds.size() > 0) {
        // 书籍ids
        map.put("bookIds", bookIds);
    }
    if (StringUtil.notEmpty(realname)) {
        // 账号或者姓名
        map.put("realname", StringUtil.toAllCheck(realname));
    }
    if (StringUtil.notEmpty(position)) {
        // 职务
        map.put("position", StringUtil.toAllCheck(position));
    }
    if (StringUtil.notEmpty(title)) {
        // 职称
        map.put("title", StringUtil.toAllCheck(title));
    }
    if (StringUtil.notEmpty(orgName)) {
        // 工作单位
        map.put("orgName", StringUtil.toAllCheck(orgName));
    }
    if (null != orgId) {
        // 申报单位
        map.put("orgId", orgId);
    }
    if (StringUtil.notEmpty(unitName)) {
        // 申报单位
        map.put("unitName", StringUtil.toAllCheck(unitName));
    }
    if (null != positionType && positionType != 0) {
        // 申报职位
        map.put("positionType", positionType);
    }
    if (null != onlineProgress && onlineProgress != 0) {
        // 学校审核进度
        map.put("onlineProgress", onlineProgress);
    }
    if (null != offlineProgress) {
        // 0 未收到 // 2 已收到
        // 纸质表进度
        map.put("offlineProgress", offlineProgress);
    }
    if (null != haveFile) {
        // 有无教材大纲
        map.put("haveFile", haveFile);
    }
    // 包装参数实体
    PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
    // 返回实体
    PageResult<DeclarationListVO> pageResult = new PageResult<>();
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    // 获取总数
    Integer total = declarationDao.listDeclarationTotal(pageParameter);
    if (null != total && total > 0) {
        List<DeclarationListVO> rows = declarationDao.listDeclaration(pageParameter);
        pageResult.setRows(rows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : HashMap(java.util.HashMap) DeclarationListVO(com.bc.pmpheep.back.vo.DeclarationListVO) Gson(com.google.gson.Gson) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) PageResult(com.bc.pmpheep.back.plugin.PageResult) TypeToken(com.google.gson.reflect.TypeToken) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)208 PmphUser (com.bc.pmpheep.back.po.PmphUser)81 ArrayList (java.util.ArrayList)73 PageResult (com.bc.pmpheep.back.plugin.PageResult)33 Material (com.bc.pmpheep.back.po.Material)30 IOException (java.io.IOException)30 HashMap (java.util.HashMap)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)25 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)24 Workbook (org.apache.poi.ss.usermodel.Workbook)23 UserMessage (com.bc.pmpheep.back.po.UserMessage)22 LogDetail (com.bc.pmpheep.annotation.LogDetail)20 Message (com.bc.pmpheep.general.po.Message)20 Textbook (com.bc.pmpheep.back.po.Textbook)18 WriterUser (com.bc.pmpheep.back.po.WriterUser)17 OutputStream (java.io.OutputStream)17 CmsContent (com.bc.pmpheep.back.po.CmsContent)16 BufferedOutputStream (java.io.BufferedOutputStream)16 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)14