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, "未能创建目录");
}
}
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);
}
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;
}
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;
}
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;
}
Aggregations