Search in sources :

Example 1 with CheckedServiceException

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

the class WordHelper method export.

/**
 * 将某套教材单本书籍下的多个专家信息批量导出Word到指定目录
 *
 * @param materialName
 *            教材名称
 * @param textbookPath
 *            系统唯一临时文件目录/教材名/书序和书名的组合,例如"/home/temp35723882/五年九轮/1.心理学"
 * @param list
 *            DeclarationEtcBO对象集合
 * @param filter
 *            使用可填项的二进制选中
 * @throws CheckedServiceException
 *             已检查的异常
 */
public void export(String materialName, String textbookPath, List<DeclarationEtcBO> list, String filter, List<MaterialExtension> extensions) throws CheckedServiceException {
    HashMap<String, XWPFDocument> map = fromDeclarationEtcBOList(materialName, list, filter, extensions);
    if (createPath(textbookPath)) {
        if (!textbookPath.endsWith(File.separator)) {
            textbookPath = textbookPath.concat(File.separator);
        }
        File file;
        for (Map.Entry<String, XWPFDocument> entry : map.entrySet()) {
            file = new File(textbookPath.concat(entry.getKey()));
            try {
                FileOutputStream out = new FileOutputStream(file);
                entry.getValue().write(out);
                out.flush();
                out.close();
            } catch (IOException ex) {
                logger.error("Word导出错误:{}", ex.getMessage());
                throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.FILE_CREATION_FAILED, "未能创建Word文件");
            }
        }
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.DIRECTORY_CREATION_FAILED, "未能创建目录");
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) XWPFDocument(org.apache.poi.xwpf.usermodel.XWPFDocument) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) IOException(java.io.IOException) File(java.io.File) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with CheckedServiceException

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

the class BookCorrectionServiceImpl method updateToAcceptancing.

@Override
public Integer updateToAcceptancing(Long id) throws CheckedServiceException {
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION, CheckedExceptionResult.NULL_PARAM, "主键为空");
    }
    BookCorrection bookCorrection = this.getBookCorrectionById(id);
    if (!bookCorrection.getIsAuthorReplied()) {
    // throw new CheckedServiceException(CheckedExceptionBusiness.BOOK_CORRECTION,
    // CheckedExceptionResult.NULL_PARAM, "请先主编审核");
    }
    bookCorrection.setIsEditorHandling(true);
    return this.updateBookCorrection(bookCorrection);
}
Also used : BookCorrection(com.bc.pmpheep.back.po.BookCorrection) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 3 with CheckedServiceException

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

the class BookUserCommentServiceImpl method deleteBookUserCommentById.

@Override
public String deleteBookUserCommentById(Long[] ids) throws CheckedServiceException {
    if (ArrayUtil.isEmpty(ids)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "评论id为空");
    }
    String result = "FAIL";
    for (Long id : ids) {
        BookUserComment bookUserComment = bookUserCommentDao.getBookUserCommentById(id);
        Long bookId = bookUserComment.getBookId();
        if (bookUserComment.getIsAuth() == 1) {
            bookService.updateDownComments(bookId);
        }
    }
    int num = bookUserCommentDao.deleteBookUserCommentById(ids);
    if (num > 0) {
        result = "SUCCESS";
    } else {
        throw new CheckedServiceException(CheckedExceptionBusiness.BOOK, CheckedExceptionResult.NULL_PARAM, "删除失败");
    }
    return result;
}
Also used : BookUserComment(com.bc.pmpheep.back.po.BookUserComment) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) WriterPoint(com.bc.pmpheep.back.po.WriterPoint)

Example 4 with CheckedServiceException

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

the class BookUserCommentServiceImpl method updateBookUserCommentByAuth.

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

Example 5 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)319 PmphUser (com.bc.pmpheep.back.po.PmphUser)94 ArrayList (java.util.ArrayList)86 HashMap (java.util.HashMap)58 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)47 LogDetail (com.bc.pmpheep.annotation.LogDetail)46 Workbook (org.apache.poi.ss.usermodel.Workbook)43 PageResult (com.bc.pmpheep.back.plugin.PageResult)42 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)34 ServletOutputStream (javax.servlet.ServletOutputStream)33 Message (com.bc.pmpheep.general.po.Message)31 PageParameter (com.bc.pmpheep.back.plugin.PageParameter)28 Map (java.util.Map)27 IOException (java.io.IOException)25 Material (com.bc.pmpheep.back.po.Material)22 WriterUser (com.bc.pmpheep.back.po.WriterUser)21 ResponseBean (com.bc.pmpheep.controller.bean.ResponseBean)20 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)20 UserMessage (com.bc.pmpheep.back.po.UserMessage)18 InputStream (java.io.InputStream)17