Search in sources :

Example 56 with PmphUser

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

the class PmphUserController method resources.

/**
 * <pre>
 * 功能描述:根据用户 id 跳转到用户权限的列表页面
 * 使用示范:
 *
 * @param userId
 * @param model
 * @return
 * </pre>
 */
@ResponseBody
@LogDetail(businessType = BUSSINESS_TYPE, logRemark = "查询指定用户 id 所拥有的权限")
@RequestMapping(value = "/resources/{id}", method = RequestMethod.GET)
public ResponseBean resources(@PathVariable("id") Long userId) {
    Map<String, Object> result = new HashMap<String, Object>();
    List<PmphPermission> resourceList = userService.getListAllResource(userId);
    PmphUser user = userService.get(userId);
    result.put("resources", resourceList);
    result.put("user", user);
    return new ResponseBean(result);
}
Also used : HashMap(java.util.HashMap) PmphPermission(com.bc.pmpheep.back.po.PmphPermission) PmphUser(com.bc.pmpheep.back.po.PmphUser) ResponseBean(com.bc.pmpheep.controller.bean.ResponseBean) LogDetail(com.bc.pmpheep.annotation.LogDetail) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 57 with PmphUser

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

the class OperationLogInterceptor method postHandle.

/**
 * <pre>
 * 功能描述:在调用controller具体方法中,返回前拦截
 * 使用示范:
 *
 * @param request HttpServletRequest
 * @param response HttpServletRequest
 * @param object Object
 * @throws Exception
 * </pre>
 */
@SuppressWarnings("rawtypes")
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object object, ModelAndView modelAndView) throws Exception {
    if (object instanceof HandlerMethod) {
        // 完整请求路径
        String requestUri = request.getRequestURI();
        // 项目路径
        String contextPath = request.getContextPath();
        // 模块路径
        String url = requestUri.substring(contextPath.length());
        Boolean isAccess = false;
        // 不拦截excludeUrls中配置的url请求
        for (String requestUrl : excludeUrls) {
            if (requestUrl.endsWith("/**")) {
                if (url.startsWith(requestUrl.substring(0, requestUrl.length() - 3))) {
                    isAccess = true;
                    break;
                }
            } else if (url.startsWith(requestUrl)) {
                isAccess = true;
                break;
            }
        }
        if (!isAccess) {
            HandlerMethod handlerMethod = (HandlerMethod) object;
            // 类名
            Class cls = handlerMethod.getBeanType();
            // 类中的所有方法
            Method[] methods = cls.getMethods();
            // 方法用途
            String logRemark = "";
            // 业务类型
            String businessType = "";
            HttpSession session = null;
            try {
                session = request.getSession();
            } catch (Exception e) {
                logger.warn("session为空时出现异常:{}", e.getMessage());
            }
            if (ObjectUtil.notNull(session)) {
                PmphUser pmphUser = (PmphUser) session.getAttribute(Const.SESSION_PMPH_USER);
                if (ObjectUtil.notNull(pmphUser)) {
                    // 调用接口方法
                    String subUrl = url.substring(url.lastIndexOf("/") + 1, url.length());
                    for (Method method : methods) {
                        LogDetail logObj = method.getAnnotation(LogDetail.class);
                        if (ObjectUtil.notNull(logObj) && method.getName().equals(subUrl)) {
                            logRemark = logObj.logRemark();
                            businessType = logObj.businessType();
                            break;
                        }
                    }
                    // 获取用户访问设备类型
                    String deviceType = DeviceUtils.isMobileDevice(request);
                    // 此处调用 sysOperationService 保存方法
                    sysOperationService.addSysOperation(new SysOperation(pmphUser.getId(), pmphUser.getUsername(), pmphUser.getRealname(), DateUtil.getCurrentTime(), url + "-" + logRemark, StringUtil.getClientIP(request), businessType, deviceType));
                }
            }
        }
    }
}
Also used : LogDetail(com.bc.pmpheep.annotation.LogDetail) SysOperation(com.bc.pmpheep.back.po.SysOperation) PmphUser(com.bc.pmpheep.back.po.PmphUser) HttpSession(javax.servlet.http.HttpSession) HandlerMethod(org.springframework.web.method.HandlerMethod) Method(java.lang.reflect.Method) HandlerMethod(org.springframework.web.method.HandlerMethod)

Example 58 with PmphUser

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

the class MigrationStageFour method material.

protected void material() {
    String tableName = "teach_material";
    String sql = "select " + "a.materid, " + "a.matername, " + "a.teachround round, " + "i.new_pk  booktypesid, " + "a.showenddate, " + "a.enddate, " + "a.agedeaddate, " + "a.mailaddress, " + "CASE WHEN a.flowtype=10 THEN '0' ELSE '1' END is_published," + "CASE WHEN a.flowtype=12 THEN '1' ELSE '0' END is_all_textbook_published, " + "j.new_pk DepartmentId , " + "d.newuserid director, " + "a.isbookmulti, " + "a.ispositionmulti, " + "a.isuselearnexp, " + "a.isfilllearnexp, " + "a.isuseworkexp, " + "a.isfillworkexp, " + "a.isuseteachexp, " + "a.isfillteachexp, " + "a.isuseacadeexp, " + "a.isfillacadeexp, " + "a.isusematerpartexp, " + "a.isfillmaterpartexp, " + "a.isusecountry, " + "a.isfillcountry, " + "a.isuseprovexce, " + "a.isfillprovexce, " + "a.isuseschoolconstr, " + "a.isfillschoolconstr, " + "a.isuseeditormater, " + "a.isfilleditormater, " + "a.isusematerwrite, " + "a.isfillmaterwrite, " + "a.isuseothermaterwrite, " + "a.isfillothermaterwrite, " + "a.isusescientresearch, " + "a.isfillscientresearch, " + "if(a.isdelete =1 ,true,false) isdelete, " + "a.createdate, " + "g.new_pk founder_id, " + "a.updatedate, " + // 如果更新者为空那么默认创建者
    "ifnull(h.new_pk,g.new_pk) mender_id  " + "from teach_material a  " + "LEFT JOIN ( " + "select DISTINCT e.materid,d.rolename,a.userid,a.new_pk newuserid,f.new_pk neworgid from sys_user  a " + "LEFT JOIN  sys_userorganize b on b.userid=a.userid " + "LEFT JOIN  sys_userrole   c on   c.userid =a.userid  " + "LEFT JOIN  sys_role   d  on d.roleid =c.roleid " + "LEFT JOIN teach_material e on e.createorgid = b.orgid  " + "LEFT JOIN ba_organize f on f.orgid = b.orgid " + "where d.rolename like '%主任%' and e.materid is not null  GROUP BY e.materid " + ") d on d.materid = a.materid " + "LEFT JOIN sys_user g on g.userid = a.createuserid " + "LEFT JOIN sys_user h on h.userid = a.updateuserid  " + "LEFT JOIN sys_booktypes i on i.BookTypesID = a. booktypesid  " + "LEFT JOIN ba_organize j on a.createorgid = j.orgid " + "LEFT JOIN site_article k ON a.materid = k.materid " + "WHERE true GROUP BY a.materid ;";
    // 增加new_pk字段
    JdbcHelper.addColumn(tableName);
    List<Map<String, Object>> maps = JdbcHelper.getJdbcTemplate().queryForList(sql);
    List<Map<String, Object>> excel = new LinkedList<>();
    Map<String, Object> result = new LinkedHashMap<>();
    int count = 0;
    int correctCount = 0;
    int[] state = { 0, 0, 0 };
    StringBuilder reason = new StringBuilder();
    StringBuilder dealWith = new StringBuilder();
    // 模块名称
    excptionList.add(new Object[] { "教材" });
    // 模块标题
    excptionList.add(new Object[] { "教材名称", "问题", "原因分析", "处理方式" });
    int excptionListOldSize = excptionList.size();
    for (Map<String, Object> oldMaterial : maps) {
        StringBuilder exception = new StringBuilder();
        String materialId = String.valueOf(oldMaterial.get("materid"));
        String matername = (String) oldMaterial.get("matername");
        if (StringUtil.isEmpty(matername)) {
            oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("教材名称为空。"));
            excel.add(oldMaterial);
            if (state[0] == 0) {
                reason.append("找不到教材名称。");
                dealWith.append("放弃迁移。");
                state[0] = 1;
            }
            continue;
        }
        String mailaddress = (String) oldMaterial.get("mailaddress");
        if (StringUtil.isEmpty(mailaddress)) {
            oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("邮寄地址为空。"));
            excel.add(oldMaterial);
            if (state[1] == 0) {
                reason.append("找不到邮寄地址。");
                dealWith.append("放弃迁移。");
                state[1] = 1;
            }
            continue;
        }
        Long departmentId = (Long) oldMaterial.get("DepartmentId");
        if (ObjectUtil.isNull(departmentId)) {
            // oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("创建部门为空。"));
            // excel.add(oldMaterial);
            // continue;
            departmentId = 0L;
        }
        Long director = (Long) oldMaterial.get("director");
        if (ObjectUtil.isNull(director)) {
            // oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("主任为空。"));
            // excel.add(oldMaterial);
            // continue;
            director = 0L;
        }
        Long founder_id = (Long) oldMaterial.get("founder_id");
        if (ObjectUtil.isNull(founder_id)) {
            // oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("创建人为空。"));
            // excel.add(oldMaterial);
            // continue;
            founder_id = 0L;
            // 设置成wuz
            PmphUser pmphUser = pmphUserService.getPmphUser("wuz");
            if (null != pmphUser && null != pmphUser.getId()) {
                founder_id = pmphUser.getId();
            }
            if (null != pmphUser.getDepartmentId()) {
                departmentId = pmphUser.getDepartmentId();
            }
        }
        Integer round = (Integer) oldMaterial.get("round");
        if (ObjectUtil.isNull(round)) {
            // 没有轮次的设置默认值为0。
            // oldMaterial.put(SQLParameters.EXCEL_EX_HEADER,
            // exception.append("轮次为空,设默认值1。"));
            // excel.add(oldMaterial);
            // ------------------------------------------------------------------------------------------
            Matcher m = Pattern.compile("第(.*?)轮").matcher(matername);
            round = m.find() ? SystemMessageService.rank(m.group(1)) : 0;
            if (null == round) {
                round = 0;
                excptionList.add(new Object[] { matername, "教材没有对应的轮次", "原专家库没有轮次信息", "导入新库表,设默认值0" });
            }
        }
        Long booktypesid = (Long) oldMaterial.get("booktypesid");
        if (ObjectUtil.isNull(booktypesid)) {
            oldMaterial.put(SQLParameters.EXCEL_EX_HEADER, exception.append("架构为空,设为默认0。"));
            excel.add(oldMaterial);
            booktypesid = 0L;
            if (state[2] == 0) {
                reason.append("找不到教材架构。");
                dealWith.append("设为默认值0迁入数据库。");
                state[2] = 1;
            }
            excptionList.add(new Object[] { matername, "教材没有分类", "原专家库没有分类信息", "导入新库表,设为默认0" });
        }
        Long mender_id = (Long) oldMaterial.get("mender_id");
        if (ObjectUtil.isNull(mender_id)) {
            // oldMaterial.put(SQLParameters.EXCEL_EX_HEADER,
            // exception.append("修改人为空,设置默认为创建者。"));
            // excel.add(oldMaterial);
            mender_id = founder_id;
        }
        Material material = new Material();
        material.setMaterialName(matername);
        material.setMaterialRound(round);
        material.setMaterialType(booktypesid);
        material.setDeadline((Timestamp) oldMaterial.get("showenddate"));
        material.setActualDeadline((Timestamp) oldMaterial.get("enddate"));
        material.setAgeDeadline((Timestamp) oldMaterial.get("agedeaddate"));
        material.setMailAddress(mailaddress);
        material.setDepartmentId(departmentId);
        // director,
        material.setDirector(director);
        // is_multi_books,
        material.setIsMultiBooks("1".equals(String.valueOf(oldMaterial.get("isbookmulti"))));
        // is_multi_position,
        material.setIsMultiPosition("1".equals(String.valueOf(oldMaterial.get("ispositionmulti"))));
        // is_edu_exp_used,
        material.setIsEduExpUsed("1".equals(String.valueOf(oldMaterial.get("isuselearnexp"))));
        // is_edu_exp_required,
        material.setIsEduExpRequired("1".equals(String.valueOf(oldMaterial.get("isfilllearnexp"))));
        // is_work_exp_used,
        material.setIsWorkExpUsed("1".equals(String.valueOf(oldMaterial.get("isuseworkexp"))));
        // is_work_exp_required,
        material.setIsWorkExpRequired("1".equals(String.valueOf(oldMaterial.get("isfillworkexp"))));
        // is_teach_exp_used,
        material.setIsTeachExpUsed("1".equals(String.valueOf(oldMaterial.get("isuseteachexp"))));
        // is_teach_exp_required,
        material.setIsTeachExpRequired("1".equals(String.valueOf(oldMaterial.get("isfillteachexp"))));
        // is_acade_used,
        material.setIsAcadeUsed("1".equals(String.valueOf(oldMaterial.get("isuseacadeexp"))));
        // is_acade_required,
        material.setIsAcadeRequired("1".equals(String.valueOf(oldMaterial.get("isfillacadeexp"))));
        // is_last_position_used,
        material.setIsLastPositionUsed("1".equals(String.valueOf(oldMaterial.get("isusematerpartexp"))));
        // is_last_position_required,
        material.setIsLastPositionRequired("1".equals(String.valueOf(oldMaterial.get("isfillmaterpartexp"))));
        material.setIsCourseUsed("1".equals(String.valueOf(oldMaterial.get("isusecountry"))) || "1".equals(String.valueOf(oldMaterial.get("isuseprovexce"))) || // is_course_used,
        "1".equals(String.valueOf(oldMaterial.get("isuseschoolconstr"))));
        material.setIsCourseRequired("1".equals(String.valueOf(oldMaterial.get("isfillcountry"))) || "1".equals(String.valueOf(oldMaterial.get("isfillprovexce"))) || // is_course_required,
        "1".equals(String.valueOf(oldMaterial.get("isfillschoolconstr"))));
        // is_national_plan_used,
        material.setIsNationalPlanUsed("1".equals(String.valueOf(oldMaterial.get("isuseeditormater"))));
        // is_national_plan_required,
        material.setIsNationalPlanRequired("1".equals(String.valueOf(oldMaterial.get("isfilleditormater"))));
        // is_textbook_writer_used,
        material.setIsTextbookUsed("1".equals(String.valueOf(oldMaterial.get("isusematerwrite"))));
        // is_textbook_writer_required,
        material.setIsTextbookRequired("1".equals(String.valueOf(oldMaterial.get("isfillmaterwrite"))));
        // is_other_textbook_used,
        material.setIsPmphTextbookUsed("1".equals(String.valueOf(oldMaterial.get("isuseothermaterwrite"))));
        // is_other_textbook_required,
        material.setIsPmphTextbookRequired("1".equals(String.valueOf(oldMaterial.get("isfillothermaterwrite"))));
        // is_research_used,
        material.setIsResearchUsed("1".equals(String.valueOf(oldMaterial.get("isusescientresearch"))));
        // is_research_required,
        material.setIsResearchRequired("1".equals(String.valueOf(oldMaterial.get("isfillscientresearch"))));
        // is_published,
        material.setIsPublished("1".equals(String.valueOf(oldMaterial.get("is_published"))));
        // is_public
        material.setIsPublic(true);
        material.setIsAllTextbookPublished(// is_all_textbook_published
        "1".equals(String.valueOf(oldMaterial.get("is_all_textbook_published"))));
        // is_force_end
        material.setIsForceEnd(false);
        // is_deleted,
        material.setIsDeleted("1".equals(String.valueOf(oldMaterial.get("isdelete"))));
        // gmt_create,
        material.setGmtCreate((Timestamp) oldMaterial.get("createdate"));
        // founder_id,
        material.setFounderId(founder_id);
        // gmt_update,
        material.setGmtUpdate((Timestamp) oldMaterial.get("updatedate"));
        // 修改者
        Long mender_Id = (Long) oldMaterial.get("mender_id");
        mender_Id = mender_Id == null ? material.getFounderId() : mender_Id;
        // mender_id
        material.setMenderId(mender_Id);
        // 主编学术专著情况
        material.setIsMonographUsed(false);
        // 主编学术专著情况必填
        material.setIsMonographRequired(false);
        // 出版行业获奖情况
        material.setIsPublishRewardUsed(false);
        // 出版行业获奖情况必填
        material.setIsPublishRewardRequired(false);
        // SCI论文投稿及影响因子
        material.setIsSciUsed(false);
        // SCI论文投稿及影响因子必填
        material.setIsSciRequired(false);
        // 临床医学获奖情况
        material.setIsClinicalRewardUsed(false);
        // 临床医学获奖情况必填
        material.setIsClinicalRewardRequired(false);
        // 学术荣誉授予情况
        material.setIsAcadeRewardUsed(false);
        // 学术荣誉授予情况必填
        material.setIsAcadeRewardRequired(false);
        // 设置权限
        material.setProjectPermission(Integer.valueOf("11110011", 2));
        material.setPlanPermission(Integer.valueOf("00010000", 2));
        material = materialService.addMaterial(material);
        count++;
        long pk = material.getId();
        // 更新旧表中new_pk字段
        JdbcHelper.updateNewPrimaryKey(tableName, pk, "materid", materialId);
        if (null == oldMaterial.get("exception")) {
            correctCount++;
        }
        // 保存教材,为下面保存教材社区做准备
        materials.add(material);
    }
    // 没有错误数据
    if (excptionList.size() == excptionListOldSize) {
        excptionList.remove(excptionList.size() - 1);
        excptionList.remove(excptionList.size() - 1);
    } else {
        // 插入一个空行
        excptionList.add(new String[] { "" });
    }
    if (excel.size() > 0) {
        try {
            excelHelper.exportFromMaps(excel, "教材信息表", "material");
        } catch (IOException ex) {
            logger.error("异常数据导出到Excel失败", ex);
        }
    }
    if (correctCount != maps.size()) {
        result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "material");
        result.put(SQLParameters.EXCEL_HEADER_DESCRIPTION, "教材信息表");
        result.put(SQLParameters.EXCEL_HEADER_SUM_DATA, maps.size());
        result.put(SQLParameters.EXCEL_HEADER_MIGRATED_DATA, count);
        result.put(SQLParameters.EXCEL_HEADER_CORECT_DATA, correctCount);
        result.put(SQLParameters.EXCEL_HEADER_TRANSFERED_DATA, count - correctCount);
        result.put(SQLParameters.EXCEL_HEADER_NO_MIGRATED_DATA, maps.size() - count);
        result.put(SQLParameters.EXCEL_HEADER_EXCEPTION_REASON, reason.toString());
        result.put(SQLParameters.EXCEL_HEADER_DEAL_WITH, dealWith.toString());
        SQLParameters.STATISTICS_RESULT.add(result);
    }
    logger.info("'{}'表迁移完成,异常条目数量:{}", tableName, excel.size());
    logger.info("原数据库中共有{}条数据,迁移了{}条数据", maps.size(), count);
    // 记录信息
    Map<String, Object> msg = new HashMap<String, Object>();
    msg.put("result", "" + tableName + " 表迁移完成" + count + "/" + maps.size());
    SQLParameters.STATISTICS.add(msg);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Material(com.bc.pmpheep.back.po.Material) IOException(java.io.IOException) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 59 with PmphUser

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

the class MigrationStageThree method pmphUser.

protected void pmphUser() {
    // 此表图一程序中已添加new_pk
    String tableName = "sys_user";
    String sql = "SELECT a.userid,a.usercode,a.`password`,a.isvalid,a.username,d.new_pk," + "b.handset,b.email,e.filedir,a.memo,a.sortno, " + "(SELECT q.rolename FROM sys_userrole p " + "LEFT JOIN sys_role q ON p.roleid = q.roleid " + "WHERE p.userid = a.userid AND q.rolename='主任')rolename " + "FROM sys_user a " + "LEFT JOIN sys_userext b ON a.userid = b.userid " + "LEFT JOIN sys_userorganize c ON a.userid = c.userid " + "LEFT JOIN ba_organize d ON c.orgid = d.orgid " + "LEFT JOIN (SELECT * FROM pub_addfileinfo x WHERE x.fileid IN (SELECT MAX(y.fileid) " + "FROM pub_addfileinfo y WHERE y.childsystemname='sys_userext_avatar' " + "GROUP BY y.operuserid))e " + "ON a.userid = e.operuserid " + "WHERE a.sysflag = 0 OR a.usercode = 'admin';";
    List<Map<String, Object>> maps = JdbcHelper.getJdbcTemplate().queryForList(sql);
    List<Map<String, Object>> excel = new LinkedList<>();
    Map<String, Object> result = new LinkedHashMap<>();
    int count = 0;
    int correctCount = 0;
    int[] state = { 0, 0, 0, 0 };
    StringBuilder reason = new StringBuilder();
    StringBuilder dealWith = new StringBuilder();
    for (Map<String, Object> map : maps) {
        StringBuilder sb = new StringBuilder();
        String userId = (String) map.get("userid");
        String userName = (String) map.get("usercode");
        if (StringUtil.isEmpty(userName)) {
            map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("找不到用户的登陆账号。"));
            excel.add(map);
            if (state[0] == 0) {
                reason.append("找不到用户的登陆账号。");
                dealWith.append("放弃迁移。");
                state[0] = 1;
            }
            continue;
        }
        String password = "888888";
        if ("admin".equals(userName)) {
            password = "123";
        }
        Integer isDisabled = (Integer) map.get("isvalid");
        String realName = (String) map.get("username");
        if (StringUtil.isEmpty(realName)) {
            realName = userName;
        }
        Long departmentId = (Long) map.get("new_pk");
        if (ObjectUtil.isNull(departmentId)) {
            departmentId = 0L;
            map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("此用户没有所属的社内部门。"));
            excel.add(map);
            if (state[1] == 0) {
                reason.append("此用户没有所属的社内部门。");
                dealWith.append("设为人民卫生出版社迁入数据库。");
                state[1] = 1;
            }
        }
        if (departmentId > number) {
            departmentId = 0L;
            map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("此用户所属部门为学校机构。"));
            excel.add(map);
            if (state[2] == 0) {
                reason.append("此用户所属部门为学校机构。");
                dealWith.append("设为人民卫生出版社迁入数据库。");
                state[2] = 1;
            }
        }
        String handphone = (String) map.get("handset");
        String email = (String) map.get("email");
        String avatar = (String) map.get("filedir");
        String note = (String) map.get("memo");
        Integer sort = (Integer) map.get("sortno");
        if (ObjectUtil.notNull(sort) && sort < 0) {
            sort = 999;
        }
        String director = (String) map.get("rolename");
        PmphUser pmphUser = new PmphUser();
        pmphUser.setUsername(userName);
        pmphUser.setPassword(password);
        pmphUser.setIsDisabled(isDisabled != 1);
        pmphUser.setRealname(realName);
        pmphUser.setDepartmentId(departmentId);
        pmphUser.setHandphone(handphone);
        pmphUser.setEmail(email);
        pmphUser.setAvatar("DEFAULT");
        pmphUser.setNote(note);
        pmphUser.setSort(sort);
        pmphUser.setIsDirector("主任".equals(director));
        pmphUser = pmphUserService.add(pmphUser);
        Long pk = pmphUser.getId();
        JdbcHelper.updateNewPrimaryKey(tableName, pk, "userid", userId);
        JdbcHelper.updateNewPrimaryKey("sys_userext", pk, "userid", userId);
        count++;
        if (null != avatar) {
            String mongoId = "";
            try {
                mongoId = fileService.migrateFile(avatar, ImageType.PMPH_USER_AVATAR, pk);
            } catch (IOException ex) {
                mongoId = "DEFAULT";
                logger.error("文件读取异常,路径<{}>,异常信息:{}", avatar, ex.getMessage());
                map.put(SQLParameters.EXCEL_EX_HEADER, sb.append("文件读取异常。"));
                excel.add(map);
                if (state[3] == 0) {
                    reason.append("社内用户头像文件丢失。");
                    dealWith.append("设为默认头像迁入数据库。");
                    state[3] = 1;
                }
            }
            pmphUser.setAvatar(mongoId);
            pmphUser.setPassword(null);
            pmphUserService.update(pmphUser);
        }
        if (null == map.get("exception")) {
            correctCount++;
        }
    }
    if (excel.size() > 0) {
        try {
            excelHelper.exportFromMaps(excel, "社内用户表", "pmph_user");
        } catch (IOException ex) {
            logger.error("异常数据导出到Excel失败", ex);
        }
    }
    if (correctCount != maps.size()) {
        result.put(SQLParameters.EXCEL_HEADER_TABLENAME, "pmph_user");
        result.put(SQLParameters.EXCEL_HEADER_DESCRIPTION, "社内用户表");
        result.put(SQLParameters.EXCEL_HEADER_SUM_DATA, maps.size());
        result.put(SQLParameters.EXCEL_HEADER_MIGRATED_DATA, count);
        result.put(SQLParameters.EXCEL_HEADER_CORECT_DATA, correctCount);
        result.put(SQLParameters.EXCEL_HEADER_TRANSFERED_DATA, count - correctCount);
        result.put(SQLParameters.EXCEL_HEADER_NO_MIGRATED_DATA, maps.size() - count);
        result.put(SQLParameters.EXCEL_HEADER_EXCEPTION_REASON, reason.toString());
        result.put(SQLParameters.EXCEL_HEADER_DEAL_WITH, dealWith.toString());
        SQLParameters.STATISTICS_RESULT.add(result);
    }
    logger.info("pmph_user表迁移完成");
    logger.info("原数据库表共有{}条数据,迁移了{}条数据", maps.size(), count);
    // 记录信息
    Map<String, Object> msg = new HashMap<String, Object>();
    msg.put("result", "pmph_user表迁移完成" + count + "/" + maps.size());
    SQLParameters.STATISTICS.add(msg);
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IOException(java.io.IOException) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 60 with PmphUser

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

the class BookCorrectionServiceImpl method listBookCorrectionAudit.

@Override
public PageResult<BookCorrectionAuditVO> listBookCorrectionAudit(HttpServletRequest request, Integer pageNumber, Integer pageSize, String bookname, Boolean isOver, Boolean result) throws CheckedServiceException {
    if (null == request.getSession(false)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "会话过期");
    }
    // 获取当前用户
    String sessionId = CookiesUtil.getSessionId(request);
    PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
    if (null == pmphUser || null == pmphUser.getId()) {
        throw new CheckedServiceException(CheckedExceptionBusiness.MATERIAL, CheckedExceptionResult.NULL_PARAM, "请求用户不存在");
    }
    if (null == pageNumber || pageNumber < 1) {
        pageNumber = 1;
    }
    if (null == pageSize || pageSize < 1) {
        pageSize = Integer.MAX_VALUE;
    }
    Long editorId = pmphUser.getId();
    // 权限的检查
    List<PmphRole> pmphRoles = pmphUserService.getListUserRole(pmphUser.getId());
    // 系统管理员权限检查
    for (PmphRole pmphRole : pmphRoles) {
        if (null != pmphRole && null != pmphRole.getRoleName() && "系统管理员".equals(pmphRole.getRoleName().trim())) {
            // 我是系统管理原
            editorId = null;
        }
    }
    // 权限由菜单控制
    editorId = null;
    Map<String, Object> map = new HashMap<String, Object>(4);
    map.put("start", (pageNumber - 1) * pageSize);
    map.put("pageSize", pageSize);
    map.put("result", result);
    map.put("bookname", StringUtil.toAllCheck(bookname));
    map.put("editorId", editorId);
    if (null != isOver && isOver) {
        // APP的已完成
        map.put("isOver", 1);
    } else {
        map.put("isOver", 2);
    }
    // 返回实体
    PageResult<BookCorrectionAuditVO> pageResult = new PageResult<BookCorrectionAuditVO>();
    pageResult.setPageNumber(pageNumber);
    pageResult.setPageSize(pageSize);
    // 获取总数
    Integer total = bookCorrectionDao.listBookCorrectionAuditTotal(map);
    if (null != total && total > 0) {
        List<BookCorrectionAuditVO> rows = bookCorrectionDao.listBookCorrectionAudit(map);
        pageResult.setRows(rows);
    }
    pageResult.setTotal(total);
    return pageResult;
}
Also used : PmphUser(com.bc.pmpheep.back.po.PmphUser) HashMap(java.util.HashMap) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) BookCorrectionAuditVO(com.bc.pmpheep.back.vo.BookCorrectionAuditVO) PageResult(com.bc.pmpheep.back.plugin.PageResult) PmphRole(com.bc.pmpheep.back.po.PmphRole)

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