use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class PmphGroupMemberServiceImpl method addEditorBookGroup.
@Override
public String addEditorBookGroup(Long textbookId, String sessionId) throws CheckedServiceException {
String result = "FAIL";
// 获取用户信息 进行判断用户是否有权限操作
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "该用户为空");
}
// 查询书籍信息
Textbook textbook = textbookService.getTextbookById(textbookId);
// 查询教材信息
Material material = materialService.getMaterialById(textbook.getMaterialId());
// 查询该教材是否存在项目编辑
MaterialProjectEditor materialProjectEditor = materialProjectEditorService.getMaterialProjectEditorByMaterialIdAndUserId(material.getId(), pmphUser.getId());
// 通过书籍id查询所有主编、副主编、编委
List<TextbookDecVO> textbookDecVOs = decPositionService.getTextbookEditorList(textbookId);
List<PmphGroupMember> list = new ArrayList<PmphGroupMember>(textbookDecVOs.size());
// 通过书籍id查询小组
PmphGroup pmphGroup = pmphGroupService.getPmphGroupByTextbookId(textbookId);
// 判断当前教材是否有更新小组的权限
// 小组权限的判断
Long materialId = textbook.getMaterialId();
String myPower = textbookService.listBookPosition(1, 9999, null, "[" + textbookId + "]", null, materialId, sessionId).getRows().get(0).getMyPower();
String groupPower = myPower.substring(6, 7);
if ("1".equals(groupPower)) {
// if(null!=material.getPlanPermission()||null!=material.getProjectPermission()){
// if(!BinaryUtil.getBit(material.getPlanPermission(), 7)||!BinaryUtil.getBit(material.getProjectPermission(), 7)){
// throw new CheckedServiceException(CheckedExceptionBusiness.GROUP,
// CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有更新成员权限 ");
// }
// }
// 通过小组id查询小组现有成员
List<PmphGroupMember> pmphGroupMembers = pmphGroupMemberDao.listPmphGroupMembers(pmphGroup.getId());
List<Long> groupUserIdList = new ArrayList<Long>(pmphGroupMembers.size());
for (PmphGroupMember pmphGroupMember : pmphGroupMembers) {
groupUserIdList.add(pmphGroupMember.getUserId());
}
// 通过遍历把不存在的成员添加到list中
for (TextbookDecVO textbookDecVO : textbookDecVOs) {
Long userId = textbookDecVO.getUserId();
if (!groupUserIdList.contains(userId)) {
list.add(new PmphGroupMember(userId, Const.TRUE, textbook.getMaterialId(), textbookId));
}
}
if (CollectionUtil.isEmpty(list)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.SUCCESS, "小组成员已是最新");
}
pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
result = "SUCCESS";
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.ILLEGAL_PARAM, "该用户没有更新成员权限 ");
}
return result;
}
use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class PmphGroupServiceImpl method addEditorSelcetionGroup.
@Override
public PmphGroup addEditorSelcetionGroup(String sessionId, List<PmphGroupMember> list, Long textbookId) throws CheckedServiceException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
if (list.size() == 0) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "成员名单为空,更新失败");
}
Textbook textbook = textbookService.getTextbookById(textbookId);
list.get(0).setTextbookId(textbookId);
list.get(0).setMaterialId(textbook.getMaterialId());
// 未上传小组头像时,获取默认小组头像路径
String groupImage = RouteUtil.DEFAULT_GROUP_IMAGE;
PmphGroup pmphGroup = new PmphGroup();
// 查询小组名称是否已存在 不存在直接用书名
if (ObjectUtil.isNull(pmphGroupDao.getPmphGroupByGroupName(textbook.getTextbookName()))) {
pmphGroup.setGroupName(textbook.getTextbookName());
} else {
// 存在则用书名加当前小组总数进行区分
Long count = pmphGroupDao.getPmphGroupCount();
pmphGroup.setGroupName(textbook.getTextbookName() + count);
}
pmphGroup.setGroupImage(groupImage);
pmphGroup.setBookId(textbookId);
pmphGroup.setFounderId(pmphUser.getId());
pmphGroupDao.addPmphGroup(pmphGroup);
if (null != pmphGroup.getId()) {
// 判断是否新增小组成功,如果成功则调用PmphGroupMemberService添加小组成员的方法将创建者添加到小组中
PmphGroupMember pmphGroupMember = new PmphGroupMember();
pmphGroupMember.setGroupId(pmphGroup.getId());
pmphGroupMember.setIsFounder(true);
pmphGroupMember.setUserId(pmphUser.getId());
pmphGroupMember.setDisplayName(pmphUser.getRealname());
pmphGroupMemberService.addPmphGroupMember(pmphGroupMember);
// 批量把前台传入的作家用户添加到该小组
pmphGroupMemberService.addPmphGroupMemberOnGroup(pmphGroup.getId(), list, sessionId);
} else {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.OBJECT_NOT_FOUND, "添加小组和成员失败");
}
return pmphGroup;
}
use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class PmphUserServiceImpl method getListPmphUser.
@Override
public PageResult<PmphUserManagerVO> getListPmphUser(PageParameter<PmphUserManagerVO> pageParameter, Long groupId) throws CheckedServiceException {
String name = pageParameter.getParameter().getName();
if (StringUtil.notEmpty(name)) {
pageParameter.getParameter().setName(name);
}
String path = pageParameter.getParameter().getPath();
Long departmentId = pageParameter.getParameter().getDepartmentId();
if (StringUtil.notEmpty(path) && ObjectUtil.notNull(departmentId)) {
pageParameter.getParameter().setPath(path + "-" + java.lang.String.valueOf(departmentId) + '-');
}
PageResult<PmphUserManagerVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
int total = pmphUserDao.getListPmphUserTotal(pageParameter);
if (total > 0) {
List<PmphUserManagerVO> list = pmphUserDao.getListPmphUser(pageParameter);
for (PmphUserManagerVO pmphUserManagerVO : list) {
List<PmphRoleVO> pmphRoles = pmphRoleDao.listPmphUserRoleByUserId(pmphUserManagerVO.getId());
pmphUserManagerVO.setPmphRoles(pmphRoles);
}
pageResult.setRows(list);
}
pageResult.setTotal(total);
// 设置职位
if (null != pageResult.getRows() && pageResult.getRows().size() > 0 && null != groupId) {
// 清空职位
for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
pmphUserManagerVO.setPosition("无");
}
PmphGroup pmphGroup = pmphGroupService.getPmphGroupById(groupId);
Long bookId = pmphGroup.getBookId();
if (null != bookId && bookId.intValue() > 0) {
Textbook textbook = textbookService.getTextbookById(bookId);
Material material = materialService.getMaterialById(textbook.getMaterialId());
List<MaterialProjectEditorVO> projects = materialProjectEditorService.listMaterialProjectEditors(textbook.getMaterialId());
for (PmphUserManagerVO pmphUserManagerVO : pageResult.getRows()) {
Long pmphUserId = pmphUserManagerVO.getId();
String posotion = null;
if (material.getDirector().intValue() == pmphUserId.intValue()) {
posotion = "主任";
}
if (null != projects && projects.size() > 0) {
for (MaterialProjectEditorVO item : projects) {
if (item.getEditorId().intValue() == pmphUserId.intValue()) {
posotion += (posotion == null) ? "项目编辑" : ",项目编辑";
break;
}
}
}
if (textbook.getPlanningEditor().intValue() == pmphUserId.intValue()) {
posotion += (posotion == null) ? "策划编辑" : ",策划编辑";
}
pmphUserManagerVO.setPosition(posotion == null ? "无" : posotion);
}
}
}
// 设置职位 end
return pageResult;
}
use of com.bc.pmpheep.back.po.Textbook in project pmph by BCSquad.
the class TextbookServiceImpl method getBookListVOs.
public List<BookListVO> getBookListVOs(Long materialId) throws CheckedServiceException {
if (ObjectUtil.isNull(materialId)) {
throw new CheckedServiceException(CheckedExceptionBusiness.TEXTBOOK, CheckedExceptionResult.NULL_PARAM, "教材id不能为空");
}
Material material = materialService.getMaterialById(materialId);
Long materialType = material.getMaterialType();
String path;
try {
path = materialTypeService.getMaterialTypeById(materialType).getPath();
} catch (NullPointerException e) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.ILLEGAL_PARAM, "找不到此教材的分类");
}
if (StringUtil.isEmpty(path)) {
throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL_TYPE, CheckedExceptionResult.NULL_PARAM, "分类路径为空");
}
if (path.indexOf("0-") != -1) {
path = path.replaceFirst("0-", "");
}
String[] pathType = path.split("-");
for (int i = 0; i < pathType.length; i++) {
String type = materialTypeService.getMaterialTypeById(Long.valueOf(pathType[i])).getTypeName();
pathType[i] = pathType[i].replace(pathType[i], type);
}
List<Textbook> bookList = textbookDao.getTextbookByMaterialId(materialId);
List<BookListVO> books = new ArrayList<>();
if (null == bookList || bookList.isEmpty()) {
BookListVO bookListVO = new BookListVO();
bookListVO.setMaterialId(material.getId());
bookListVO.setMaterialName(material.getMaterialName());
bookListVO.setMaterialRound(material.getMaterialRound());
bookListVO.setMaterialType(pathType);
bookListVO.setIsPublic(material.getIsPublic());
books.add(bookListVO);
return books;
}
for (Textbook textbook : bookList) {
BookListVO bookListVO = new BookListVO();
bookListVO.setMaterialId(material.getId());
bookListVO.setMaterialName(material.getMaterialName());
bookListVO.setMaterialRound(material.getMaterialRound());
bookListVO.setMaterialType(pathType);
bookListVO.setIsPublic(material.getIsPublic());
bookListVO.setTextbook(textbook);
if (CollectionUtil.isNotEmpty(decPositionService.listDecPositionsByTextbookId(textbook.getId())) && decPositionService.listDecPositionsByTextbookId(textbook.getId()).size() > 0) {
bookListVO.setAllowedDelete(false);
} else {
bookListVO.setAllowedDelete(true);
}
books.add(bookListVO);
}
return books;
}
use of com.bc.pmpheep.back.po.Textbook 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;
}
Aggregations