Search in sources :

Example 86 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class PmphUserServiceImpl method getPersonalCenter.

@Override
public Map<String, Object> getPersonalCenter(HttpServletRequest request, String state, String materialName, String groupName, String title, String bookname, String name, String authProgress, String topicBookname) {
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser sessionPmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == sessionPmphUser) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    // 获取用户角色
    List<PmphRole> rolelist = roleService.getPmphRoleByUserId(sessionPmphUser.getId());
    // 用于装所有的数据map
    Map<String, Object> map = new HashMap<>();
    // 教师认证总数量
    Integer writerUserCount = writerUserService.getCount();
    // 机构认证数量orgList
    Integer orgerCount = orgUserService.getCount();
    // 小组
    PmphGroupListVO pmphGroup = new PmphGroupListVO();
    PageParameter<PmphGroupListVO> pageParameterPmphGroup = new PageParameter<>();
    pageParameterPmphGroup.setParameter(pmphGroup);
    // 小组结果
    PageResult<PmphGroupListVO> pageResultPmphGroup = pmphGroupService.getlistPmphGroup(pageParameterPmphGroup, sessionId);
    // 教材申报
    PageParameter<MaterialListVO> pageParameter2 = new PageParameter<>();
    MaterialListVO materialListVO = new MaterialListVO();
    materialListVO.setState(state);
    materialListVO.setMaterialName(materialName);
    pageParameter2.setParameter(materialListVO);
    // 教材申报的结果
    PageResult<MaterialListVO> pageResultMaterialListVO = materialService.listMaterials(pageParameter2, sessionId);
    // 文章审核
    PageParameter<CmsContentVO> pageParameter1 = new PageParameter<>();
    CmsContentVO cmsContentVO = new CmsContentVO();
    cmsContentVO.setTitle(title);
    cmsContentVO.setCategoryId(Const.CMS_CATEGORY_ID_1);
    pageParameter1.setParameter(cmsContentVO);
    // 文章审核的结果
    PageResult<CmsContentVO> pageResultCmsContentVO = cmsContentService.listCmsContent(pageParameter1, sessionId);
    map.put("cmsContent", pageResultCmsContentVO);
    // 图书纠错审核
    PageResult<BookCorrectionAuditVO> pageResultBookCorrectionAuditVO = bookCorrectionService.listBookCorrectionAudit(request, Const.PAGE_NUMBER, Const.PAGE_SIZE, bookname, null, null);
    map.put("bookCorrectionAudit", pageResultBookCorrectionAuditVO);
    // 图书评论审核
    PageParameter<BookUserCommentVO> pageParameter = new PageParameter<>();
    BookUserCommentVO bookUserCommentVO = new BookUserCommentVO();
    // 去除空格
    bookUserCommentVO.setName(name.replaceAll(" ", ""));
    pageParameter.setParameter(bookUserCommentVO);
    PageResult<BookUserCommentVO> pageResultBookUserCommentVO = bookUserCommentService.listBookUserCommentAdmin(pageParameter);
    map.put("bookUserComment", pageResultBookUserCommentVO);
    // 选题申报
    PageParameter<TopicDeclarationVO> pageParameter3 = new PageParameter<>();
    // 选题申报当前用户角色
    PmphIdentity pmphIdentity = pmphUserService.identity(sessionId);
    TopicDeclarationVO topicDeclarationVO = new TopicDeclarationVO();
    // 是否由主任受理
    if (pmphIdentity.getIsDirector()) {
        topicDeclarationVO.setIsDirectorHandling(true);
    }
    // 是否由运维人员受理
    if (pmphIdentity.getIsOpts()) {
        topicDeclarationVO.setIsOptsHandling(true);
    }
    // 是否由编辑受理
    if (pmphIdentity.getIsEditor()) {
        topicDeclarationVO.setIsEditorHandling(true);
    }
    for (PmphRole pmphRole : rolelist) {
        // 编辑
        if (2 == pmphRole.getId()) {
            topicDeclarationVO.setIsEditorHandling(true);
        }
        // 主任
        if (9 == pmphRole.getId()) {
            topicDeclarationVO.setIsDirectorHandling(true);
        }
    }
    String[] strs = authProgress.split(",");
    List<Long> progress = new ArrayList<>();
    for (String str : strs) {
        progress.add(Long.valueOf(str));
    }
    topicDeclarationVO.setBookname(topicBookname);
    pageParameter3.setParameter(topicDeclarationVO);
    // 
    if (sessionPmphUser.getIsAdmin()) {
        PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, null);
        // topicService.listCheckTopic(progress, pageParameter3);
        map.put("topicList", pageResultTopicDeclarationVO);
    } else {
        if (2 == rolelist.get(0).getId() || 9 == rolelist.get(0).getId() || 1 == rolelist.get(0).getId()) {
            PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = topicService.listMyTopic(progress, pageParameter3, sessionPmphUser.getId());
            // topicService.listCheckTopic(progress, pageParameter3);
            map.put("topicList", pageResultTopicDeclarationVO);
        } else {
            PageResult<TopicDeclarationVO> pageResultTopicDeclarationVO = new PageResult<>();
            List<TopicDeclarationVO> list = new ArrayList<>();
            pageResultTopicDeclarationVO.setPageNumber(0);
            pageResultTopicDeclarationVO.setRows(list);
            pageResultTopicDeclarationVO.setPageTotal(0);
            pageResultTopicDeclarationVO.setStart(0);
            pageResultTopicDeclarationVO.setTotal(0);
            ;
            map.put("topicList", pageResultTopicDeclarationVO);
        }
    }
    // 获取用户上次登录时间
    List<SysOperation> listSysOperation = sysOperationService.getSysOperation(sessionPmphUser.getId());
    Timestamp loginTime = DateUtil.getCurrentTime();
    if (!listSysOperation.isEmpty()) {
        loginTime = listSysOperation.get(0).getOperateDate();
    }
    // 把其他模块的数据都装入map中返回给前端
    map.put("materialList", pageResultMaterialListVO);
    map.put("pmphGroup", pageResultPmphGroup);
    map.put("writerUserCount", writerUserCount);
    map.put("orgUserCount", orgerCount);
    // 把用户信息存入map
    map.put("pmphUser", sessionPmphUser);
    // 把用户角色存入map
    map.put("pmphRole", rolelist);
    // 把选题申报的当前身份存入map
    map.put("pmphIdentity", pmphIdentity);
    // 存入用户上次操作时间
    map.put("loginTime", loginTime);
    return map;
}
Also used : SysOperation(com.bc.pmpheep.back.po.SysOperation) CmsContentVO(com.bc.pmpheep.back.vo.CmsContentVO) HashMap(java.util.HashMap) MaterialListVO(com.bc.pmpheep.back.vo.MaterialListVO) ArrayList(java.util.ArrayList) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) Timestamp(java.sql.Timestamp) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PmphRole(com.bc.pmpheep.back.po.PmphRole) PmphUser(com.bc.pmpheep.back.po.PmphUser) PmphIdentity(com.bc.pmpheep.back.vo.PmphIdentity) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TopicDeclarationVO(com.bc.pmpheep.back.vo.TopicDeclarationVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) BookUserCommentVO(com.bc.pmpheep.back.vo.BookUserCommentVO) PmphGroupListVO(com.bc.pmpheep.back.vo.PmphGroupListVO)

Example 87 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class SurveyServiceImpl method addSurvey.

@Override
public Survey addSurvey(Survey survey, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(survey)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    survey.setUserId(pmphUser.getId());
    return this.addSurvey(survey);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException)

Example 88 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class SurveyTemplateServiceImpl method addSurveyTemplateVO.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public SurveyTemplate addSurveyTemplateVO(String questionAnswerJosn, SurveyTemplateVO surveyTemplateVO, String sessionId) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MESSAGE, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    if (ObjectUtil.isNull(surveyTemplateVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    if (StringUtil.isEmpty(questionAnswerJosn)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问题及问题选项为空");
    }
    // json字符串转List对象集合
    List<SurveyQuestionListVO> surveyQuestionListVO;
    try {
        surveyQuestionListVO = new JsonUtil().getArrayListObjectFromStr(SurveyQuestionListVO.class, questionAnswerJosn);
    } catch (Exception e) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.VO_CONVERSION_FAILED, "json字符串转List对象失败");
    }
    if (CollectionUtil.isEmpty(surveyQuestionListVO)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    // 问卷名称
    String templateName = surveyTemplateVO.getTemplateName();
    if (templateName.length() > 50) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷标题不能超过50个字符");
    }
    // 问卷概述
    String intro = surveyTemplateVO.getIntro();
    if (templateName.length() > 200) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷概述不能超过200个字符");
    }
    if (templateName.length() > 200) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "问卷概述不能超过200个字符");
    }
    // 问卷调查类型
    Long typeId = surveyTemplateVO.getTypeId();
    // 问卷创建人
    Long userId = pmphUser.getId();
    SurveyTemplate surveyTemplate = // 添加模版表
    addSurveyTemplate(new SurveyTemplate(templateName, intro, typeId, userId));
    // 获取模版id
    Long templateId = surveyTemplate.getId();
    if (ObjectUtil.isNull(templateId)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "新增模版失败");
    }
    Survey survey = // 添加问卷表
    surveyService.addSurvey(new Survey(templateName, intro, templateId, typeId, userId));
    if (ObjectUtil.isNull(survey.getId())) {
        throw new CheckedServiceException(CheckedExceptionBusiness.QUESTIONNAIRE_SURVEY, CheckedExceptionResult.NULL_PARAM, "新增问卷失败");
    }
    // 添加问题及问题选项
    List<Long> newIds = addQuestionAndOption(surveyQuestionListVO);
    // 模版问题中间表
    List<SurveyTemplateQuestion> surveyTemplateQuestions = new ArrayList<SurveyTemplateQuestion>(newIds.size());
    for (Long questionId : newIds) {
        surveyTemplateQuestions.add(new SurveyTemplateQuestion(templateId, questionId));
    }
    // 添加模版问题中间表
    surveyTemplateQuestionDao.batchInsertSurveyTemplateQuestion(surveyTemplateQuestions);
    System.out.println(surveyTemplate.toString());
    return surveyTemplate;
}
Also used : SurveyTemplate(com.bc.pmpheep.back.po.SurveyTemplate) SurveyQuestionListVO(com.bc.pmpheep.back.vo.SurveyQuestionListVO) PmphUser(com.bc.pmpheep.back.po.PmphUser) ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) JsonUtil(com.bc.pmpheep.back.util.JsonUtil) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) Survey(com.bc.pmpheep.back.po.Survey) SurveyTemplateQuestion(com.bc.pmpheep.back.po.SurveyTemplateQuestion)

Example 89 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class TextbookServiceImpl method listBookPosition.

@Override
public PageResult<BookPositionVO> listBookPosition(Integer pageNumber, Integer pageSize, Integer state, String textBookIds, String bookName, Long materialId, String sessionId) {
    // 验证用户
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_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;
        }
    }
    // 教材项目编辑检查
    if (null == power) {
        List<MaterialProjectEditorVO> materialProjectEditors = materialProjectEditorService.listMaterialProjectEditors(materialId);
        if (null != materialProjectEditors && materialProjectEditors.size() > 0) {
            for (MaterialProjectEditorVO materialProjectEditor : materialProjectEditors) {
                if (null != materialProjectEditor && null != materialProjectEditor.getEditorId() && materialProjectEditor.getEditorId().equals(pmphUser.getId())) {
                    // 我是教材的项目编辑
                    power = 3;
                }
            }
        }
    }
    // 教材策划编辑检查
    if (null == power) {
        Integer num = materialService.getPlanningEditorSum(materialId, pmphUser.getId());
        if (null != num && num > 0) {
            // 我是教材的策划编辑编辑
            power = 4;
        }
    }
    if (null == power) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "该教材您没操作权限");
    }
    // 拼装复合参数
    Map<String, Object> map = new HashMap<String, Object>();
    // 教材id
    map.put("materialId", materialId);
    if (StringUtil.notEmpty(textBookIds)) {
        Gson gson = new Gson();
        List<Long> bookIds = gson.fromJson(textBookIds, new TypeToken<ArrayList<Long>>() {
        }.getType());
        if (null != bookIds && bookIds.size() > 0) {
            // 书籍id
            map.put("list", bookIds);
        }
    }
    if (null != state && !state.equals(0)) {
        // 书籍状态
        map.put("state", state);
    }
    String bookNameTemp = StringUtil.toAllCheck(bookName);
    if (null != bookNameTemp) {
        // 书籍名称
        map.put("bookName", bookNameTemp);
    }
    // 用户id
    map.put("pmphUserId", pmphUser.getId());
    // 用户id
    map.put("power", power);
    PageParameter<Map<String, Object>> pageParameter = new PageParameter<Map<String, Object>>(pageNumber, pageSize, map);
    PageResult<BookPositionVO> pageResult = new PageResult<>();
    // 获取总数
    Integer total = textbookDao.listBookPositionTotal(pageParameter);
    if (null != total && total > 0) {
        List<BookPositionVO> rows = textbookDao.listBookPosition(pageParameter);
        // 下面进行授权
        for (BookPositionVO row : rows) {
            String rowpower = "000000";
            if (power == 1 || power == 2) {
                // 管理员或者主任
                rowpower = "11111111";
            } else if (power == 3) {
                // 教材项目编辑
                // 因为项目编辑的权限不是全部 ,因此要检查我是不是这本书的策划编辑,如果是 ,这本书我的权利就是项目编辑+策划编辑的权利
                Integer tempProjectPermission = material.getProjectPermission();
                if (null != row && null != row.getPlanningEditor() && null != pmphUser.getId() && row.getPlanningEditor().intValue() == pmphUser.getId().intValue()) {
                    // 我又是策划编辑
                    tempProjectPermission = (tempProjectPermission | material.getPlanPermission());
                }
                rowpower = StringUtil.tentToBinary(tempProjectPermission);
            } else if (power == 4) {
                // 教材策划编辑
                rowpower = StringUtil.tentToBinary(material.getPlanPermission());
            }
            // 把权限拿出来一个个判断
            // 分配策划编辑的权限
            String s1 = rowpower.substring(0, 1);
            String s2 = rowpower.substring(1, 2);
            String s3 = rowpower.substring(2, 3);
            String s4 = rowpower.substring(3, 4);
            String s5 = rowpower.substring(4, 5);
            String s6 = rowpower.substring(5, 6);
            String s7 = rowpower.substring(6, 7);
            // qiangzhijiesu
            String s8 = rowpower.substring(7, 8);
            if (material.getIsForceEnd() || material.getIsAllTextbookPublished()) {
                // 教材结束或者强制结束
                s2 = "0";
                s3 = "0";
                s4 = "0";
                s5 = "0";
                s6 = "0";
            } else if (row.getIsLocked() || row.getIsPublished()) {
                // 书籍已经发布了或者确认了名单
                s2 = (power == 1 || power == 2) ? s2 : "0";
                s3 = (power == 1 || power == 2) ? s3 : "0";
                s4 = (power == 1 || power == 2) ? s4 : "0";
                s5 = "0";
            }
            rowpower = s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8;
            row.setMyPower(rowpower);
        }
        pageResult.setRows(rows);
    }
    pageResult.setTotal(total);
    PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
    return pageResult;
}
Also used : 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) PageParameter(com.bc.pmpheep.back.plugin.PageParameter) MaterialProjectEditorVO(com.bc.pmpheep.back.vo.MaterialProjectEditorVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphRole(com.bc.pmpheep.back.po.PmphRole) BookPositionVO(com.bc.pmpheep.back.vo.BookPositionVO) TypeToken(com.google.gson.reflect.TypeToken) Map(java.util.Map) HashMap(java.util.HashMap)

Example 90 with PmphUser

use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.

the class TopicServiceImpl method listTopicDirectorVOs.

public PageResult<TopicDirectorVO> listTopicDirectorVOs(String sessionId, PageParameter<TopicDirectorVO> pageParameter) throws CheckedServiceException {
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (ObjectUtil.isNull(pmphUser)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.TOPIC, CheckedExceptionResult.NULL_PARAM, "用户为空");
    }
    PageResult<TopicDirectorVO> 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.totalDirectorView(pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicDirectorVO> list = topicDao.listDirectorView(pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameDirector(list);
            pageResult.setRows(list);
        }
    } else {
        total = topicDao.totalTopicDirectorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime);
        if (total > 0) {
            List<TopicDirectorVO> list = topicDao.listTopicDirectorVOs(pmphUser.getId(), pageParameter.getParameter().getBookname(), submitTime, pageParameter.getStart(), pageParameter.getPageSize());
            list = addTypeNameDirector(list);
            pageResult.setRows(list);
        }
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) TopicDirectorVO(com.bc.pmpheep.back.vo.TopicDirectorVO) PageResult(com.bc.pmpheep.back.plugin.PageResult)

Aggregations

PmphUser (com.bc.pmpheep.back.po.PmphUser)102 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)81 ArrayList (java.util.ArrayList)33 PageResult (com.bc.pmpheep.back.plugin.PageResult)17 HashMap (java.util.HashMap)13 Material (com.bc.pmpheep.back.po.Material)11 WriterUser (com.bc.pmpheep.back.po.WriterUser)11 WebScocketMessage (com.bc.pmpheep.websocket.WebScocketMessage)10 PmphRole (com.bc.pmpheep.back.po.PmphRole)9 UserMessage (com.bc.pmpheep.back.po.UserMessage)9 PmphGroupMemberVO (com.bc.pmpheep.back.vo.PmphGroupMemberVO)9 BaseTest (com.bc.pmpheep.test.BaseTest)9 Test (org.junit.Test)9 CmsContent (com.bc.pmpheep.back.po.CmsContent)8 PmphGroupMember (com.bc.pmpheep.back.po.PmphGroupMember)8 PmphGroup (com.bc.pmpheep.back.po.PmphGroup)7 Textbook (com.bc.pmpheep.back.po.Textbook)7 WriterUserTrendst (com.bc.pmpheep.back.po.WriterUserTrendst)6 Gson (com.google.gson.Gson)6 OrgUser (com.bc.pmpheep.back.po.OrgUser)5