use of com.bc.pmpheep.service.exception.CheckedServiceException 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> 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);
/**
* 下面是发布更新最终结果表的数据
*/
// 获取这些书的申报者
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);
}
}
}
}
}
}
// 先删除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);
}
// 当教材遴选结束时给为遴选上的用户推送消息
Material material2 = materialService.getMaterialById(materialId);
if (ObjectUtil.notNull(material2)) {
if (material2.getIsAllTextbookPublished()) {
List<Declaration> declaration = declarationService.getPositionChooseLossByMaterialId(materialId);
systemMessageService.sendWhenPositionChooserLoss(materialId, declaration);
}
}
// 遍历被遴选人发送动态 和被修改成专家
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;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class TextbookServiceImpl method updateTextbooks.
@Override
public Integer updateTextbooks(Long[] ids, String sessionId) {
// 获取当前用户
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
}
// }
if (null == ids) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "书籍id为空");
}
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> decPosition = decPositionService.getDecPositionByTextbookId(textbook.getId());
// 是否确认编委
if (decPosition.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "还未确认编委,不能名单确认");
}
}
}
Integer count = 0;
if (CollectionUtil.isNotEmpty(textbooks)) {
count = textbookDao.updateTextbooks(textbooks);
}
return count;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class TopicServiceImpl method listOpts.
@Override
public PageResult<TopicOPtsManagerVO> listOpts(String sessionId, PageParameter<TopicOPtsManagerVO> pageParameter) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空!");
}
PageResult<TopicOPtsManagerVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
Integer total = 0;
String submitTime = DateUtil.date2Str(pageParameter.getParameter().getSubmitTime(), "yyyy-MM-dd");
if (pmphUser.getIsAdmin()) {
total = topicDao.listTotal(pageParameter.getParameter().getBookname(), submitTime);
if (total > 0) {
List<TopicOPtsManagerVO> list = topicDao.list(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
list = addTypeName(list);
pageResult.setRows(list);
}
} else {
total = topicDao.listOptsTotal(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
if (total > 0) {
List<TopicOPtsManagerVO> list = topicDao.listOpts(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
list = addTypeName(list);
pageResult.setRows(list);
}
}
pageResult.setTotal(total);
return pageResult;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class TopicServiceImpl method update.
@Override
public String update(TopicLog topicLog, String sessionId, Topic topic) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空!");
}
topicLog.setUserId(pmphUser.getId());
if (ObjectUtil.isNull(topic) || ObjectUtil.isNull(topic.getId())) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "该选题不存在");
}
if (!StringUtil.isEmpty(topic.getAuthFeedback())) {
if (topic.getAuthFeedback().length() > 200) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "审核意见过长,请不要超过200个字符");
}
}
if (!StringUtil.isEmpty(topic.getReasonDirector())) {
if (topic.getReasonDirector().length() > 200) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "退回原因过长,请不要超过200个字符");
}
}
if (!StringUtil.isEmpty(topic.getReasonEditor())) {
if (topic.getReasonEditor().length() > 200) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.ILLEGAL_PARAM, "退回原因过长,请不要超过200个字符");
}
}
String result = "FIAL";
if (topicDao.update(topic) > 0) {
topicLogService.add(topicLog);
result = "SUCCESS";
}
WriterUserTrendst writerUserTrendst = new WriterUserTrendst();
writerUserTrendst.setUserId(topicDao.getTopicTextVO(topic.getId()).getUserId());
writerUserTrendst.setBookId(topic.getId());
writerUserTrendst.setType(9);
writerUserTrendst.setIsPublic(false);
if (ObjectUtil.notNull(topic.getAuthProgress())) {
if (StringUtil.isEmpty(topic.getAuthFeedback())) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "审核意见不能为空");
}
if (3 == topic.getAuthProgress()) {
Map<String, Object> detail = new HashMap<String, Object>();
detail.put("title", CheckedExceptionBusiness.TOPIC);
detail.put("content", "您的选题《" + topicDao.get(topic.getId()).getBookname() + "》已经通过。");
detail.put("img", 1);
writerUserTrendst.setDetail(new Gson().toJson(detail));
// 创建本版号并将本版号放入数据中
// String editionnum = "10" + new SimpleDateFormat("yyyy").format(new Date());
// String vn = topicDao.get(topic.getId()).getVn();
// if (StringUtil.isEmpty(vn)) {
// vn = topicDao.getMaxTopicVn();
// if (StringUtil.isEmpty(vn)) {
// vn = editionnum + "000001";
// } else {
// vn = editionnum + Integer.parseInt(vn.substring(7)) + 1000000 + 1 + "";
// }
// }
// topic.setNote("选题通过");
// topic.setVn(vn);
// topicDao.update(topic);
// String remark = topic.getAuthFeedback();
// TopicTextVO topicTextVO = topicTextVO(topicLog, sessionId, topic.getId());
// String sql = "insert into i_declarestates
// (editionnum,rwusercode,rwusername,topicname,readerpeople,sources,fontcount,piccount,timetohand,subject,booktype,levels,depositbank,bankaccount,selectreason,publishingvalue,content,authorbuybooks,authorsponsor,originalname,originalauthor,originalnationality,originalpress,publishagerevision,topicnumber,auditstates,remark,creattime,states)";
// sql += "values('" + vn + "','" + topicTextVO.getUsername() + "','" +
// topicTextVO.getRealname()
// + "','','" + topicTextVO.getReadType() + "','" + topicTextVO.getSourceType()
// + "','"
// + topicTextVO.getWordNumber() + "','" + topicTextVO.getPictureNumber() +
// "','"
// + DateUtil.formatTimeStamp("yyyy-MM-dd", topicTextVO.getDeadline()) + "','"
// + topicTextVO.getSubject() + "','" + topicTextVO.getTypeName() + "','" +
// topicTextVO.getRank()
// + "','" + topicTextVO.getBank() + "','" + topicTextVO.getAccountNumber() +
// "','"
// + topicTextVO.getTopicExtra().getReason() + "','" +
// topicTextVO.getTopicExtra().getPrice()
// + "','" + topicTextVO.getTopicExtra().getScore() + "','" +
// topicTextVO.getPurchase() + "','"
// + topicTextVO.getSponsorship() + "','" + topicTextVO.getOriginalBookname() +
// "','"
// + topicTextVO.getOriginalAuthor() + "','" + topicTextVO.getNation() +
// "','','"
// + topicTextVO.getEdition() + "','','11','" + remark + "',GETDATE(),1)";
// SqlHelper.executeUpdate(sql, null);
} else {
Map<String, Object> detail = new HashMap<String, Object>();
detail.put("title", CheckedExceptionBusiness.TOPIC);
detail.put("content", "您的选题《" + topicDao.get(topic.getId()).getBookname() + "》未通过。");
detail.put("img", 2);
writerUserTrendst.setDetail(new Gson().toJson(detail));
}
writerUserTrendstService.addWriterUserTrendst(writerUserTrendst);
}
return result;
}
use of com.bc.pmpheep.service.exception.CheckedServiceException in project pmph by BCSquad.
the class TopicServiceImpl method listTopicEditorVOs.
@Override
public PageResult<TopicEditorVO> listTopicEditorVOs(String sessionId, PageParameter<TopicEditorVO> pageParameter) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (ObjectUtil.isNull(pmphUser)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
PageResult<TopicEditorVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
Integer total = 0;
String submitTime = DateUtil.date2Str(pageParameter.getParameter().getSubmitTime(), "yyyy-MM-dd");
if (pmphUser.getIsAdmin()) {
total = topicDao.totalEditorView(pageParameter.getParameter().getBookname(), submitTime);
if (total > 0) {
List<TopicEditorVO> list = topicDao.listEditorView(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
list = addTypeNameEditor(list);
pageResult.setRows(list);
}
} else {
total = topicDao.totalTopicEditorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
if (total > 0) {
List<TopicEditorVO> list = topicDao.listTopicEditorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
list = addTypeNameEditor(list);
pageResult.setRows(list);
}
}
pageResult.setTotal(total);
return pageResult;
}
Aggregations