package com.yipin.liuwanr.service; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.helper.UserUtil; import com.yipin.liuwanr.mapper.ProjectManagementMapper; import com.yipin.liuwanr.mapper.ScoreIndexMapper; import org.apache.commons.lang3.StringUtils; import org.jboss.logging.Logger; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @Service public class ProjectManagementService { private static Logger logger = Logger.getLogger(ProjectManagementService.class); @Autowired private ProjectManagementMapper mapper; @Autowired private ScoreIndexMapper indexMapper; /** * 查询用户角色 * * @param userId * @return */ public HashMap queryRole(Integer userId) { HashMap resp = new HashMap(); try { Integer roleId = mapper.queryRoleId(userId); if (null != roleId) { //角色为教师 if (roleId == 3) { resp.put("retvalue", 1); } //角色为管理员 else if (roleId == 1 || roleId == 2) { resp.put("retvalue", 0); } else if (roleId == 4) { resp.put("retcode", 300); resp.put("retvalue", "Role does not meet the requirements"); return resp; } resp.put("retcode", 200); } else { resp.put("retcode", 300); resp.put("retvalue", "user does not exist"); } } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 条件查询 * * @param vo * @return */ public HashMap queryManagements(ProjectManagement vo, Integer pageNo, Integer pageSize) { HashMap resp = new HashMap(); try { //获取用户的角色信息 Integer roleId = mapper.queryRoleId(vo.getUserId()); if (null != roleId) { //角色不对(学生没有权限) if (roleId == 4) { resp.put("retcode", 300); resp.put("retvalue", "抱歉,您的权限不能访问该地址!"); return resp; } //角色等于管理员或者超级管理员 else if (roleId == 1 ) { vo.setUserId(null); } } PageHelper.startPage(pageNo, pageSize); //条件查询 List list = mapper.queryManagementsExportTest(vo); PageInfo info = new PageInfo(list); resp.put("retvalue", new PageResult(info.getTotal(), list)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 分页查询+条件查询 * * @param vo * @return */ public HashMap queryAllManagements(ProjectManagement vo) { HashMap resp = new HashMap(); try { //获取用户的角色信息 Integer roleId = mapper.queryRoleId(vo.getUserId()); if (null != roleId) { //角色不对(学生没有权限) if (roleId == 4) { resp.put("retcode", 300); resp.put("retvalue", "抱歉,您的权限不能访问该地址!"); return resp; } //角色等于管理员或者超级管理员 else if (roleId == 1 ) { vo.setUserId(null); } } //分页 PageHelper.startPage(vo.getPageNo(), vo.getPageSize()); //条件查询 List list = mapper.queryManagements(vo); //管理员权限id String adminId = "13"; if (adminId.equals(vo.getFounder())){ //查完管理员,再查管理员+教师权限的 13,14 ProjectManagement vo1 = new ProjectManagement(); BeanUtils.copyProperties(vo,vo1); vo1.setFounder("13,14"); List list1 = mapper.queryManagements(vo1); list.addAll(list1); } resp.put("retvalue",list); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 批量删除 * * @param projectId:项目管理id * @return */ @Transactional public HashMap deleteProjectManagement(List projectId) { HashMap resp = new HashMap(); try { for (Integer po : projectId) { //判分点 List points = mapper.queryProjectIds(po); for (int i = 0; i < points.size(); i++) { //判分点 JudgmentPoints pos = points.get(i); Integer pointId = pos.getJudgmentPointsId();//判分点id String projectIds = pos.getProjectId();//项目id //判分点中删除项目 if (!StringUtils.isEmpty(projectIds)) { List lists = Arrays.asList(projectIds.split(",")); List obj = new ArrayList(lists); String prijectId = po.toString(); if (lists.contains(prijectId)) { obj.remove(prijectId); projectIds = StringUtils.strip(obj.toString(), "[]").replace(" ", ""); mapper.updateProject(projectIds, null, pointId); } } } //删除分数 indexMapper.removeAllprojectId(po); mapper.deleteRole(po); } int size = projectId.size(); for (int i = 0;i result = mapper.queryproject(id); if (result.size()==0){ mapper.daleteManegement(id); } mapper.deleteProjectManagement(id); } resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Delete Failed"); throw new RuntimeException(); } return resp; } /** * 根据项目管理id查询对应信息 * * @param projectId * @return */ public HashMap getProjectId(Integer projectId) { HashMap resp = new HashMap(); List judgmentPointsId = new ArrayList(); List obj = new ArrayList(); List indexs = new ArrayList(); try { // 项目信息 ProjectManagement management = mapper.getProjectId(projectId); if (null != management) { // 判分点信息 List points = mapper.getByProjectId(projectId); //判分点不为空 if (null != points && !points.isEmpty()) { //存储判分点id for (int i = 0; i < points.size(); i++) { judgmentPointsId.add(points.get(i).getJudgmentPointsId()); } //得到对应判分点的分数 List scores = indexMapper.queryScore(judgmentPointsId, projectId, management.getUserId()); if (scores.size() > 0 && !scores.isEmpty()) { //为有分数的赋值 for (int i = 0; i < points.size(); i++) { JudgmentPoints point = points.get(i); for (int j = 0; j < scores.size(); j++) { ScoreIndex score = scores.get(j); if (point.getJudgmentPointsId().equals(score.getJudgmentPointsId())) { point.setScore(score.getScore()); points.set(i, point); indexs.add(i); break; } } } //为没值的赋值 for (int i = 0; i < points.size(); i++) { if (!indexs.contains(i)) { JudgmentPoints points3 = points.get(i); points3.setScore(0); points.set(i, points3); } } } else { for (int i = 0; i < points.size(); i++) { JudgmentPoints point = points.get(i); //给分数赋值 point.setScore(0); //修改该判分点 points.set(i, point); } } } // 角色信息 List roles = mapper.queryProjectId(projectId); // 存数据 obj.add(management); obj.add(points); obj.add(roles); } resp.put("retvalue", obj); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 根据项目管理id查询对应交易类判分点信息 * * @param projectId * @return */ public HashMap getTrdingJudgmentPoints(Integer projectId) { HashMap resp = new HashMap(); List obj = new ArrayList(); try { // 项目信息 ProjectManagement management = mapper.getProjectId(projectId); if (null != management) { // 判分点信息 List points = mapper.queryJudgmentPoints(projectId); // 角色信息 List roles = mapper.queryProjectId(projectId); // 存数据 obj.add(management); obj.add(points); obj.add(roles); } resp.put("retvalue", obj); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 根据项目管理id查询对应交易类判分点信息 * * @param projectId * @return */ public HashMap getProject(Integer projectId) { HashMap resp = new HashMap(); try { // 项目信息 ProjectManagement management = mapper.getProjectId(projectId); resp.put("retvalue", management); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 添加判分点页面的判分点信息展示 * * @return */ public HashMap queryAllJudgmentPoints(JudgmentPoints points) { HashMap resp = new HashMap(); try { resp.put("retvalue", mapper.queryAllJudgmentPoints(points)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Add Failed"); return resp; } return resp; } /** * 创建项目管理页面的判分点信息展示 * * @param judgmentPointsId 判分点id * @return */ public HashMap getByjudgmentPointsId(List judgmentPointsId, Integer projectId, Integer userId) { HashMap resp = new HashMap(); try { List points = mapper.getByjudgmentPointsIds(judgmentPointsId); List scores = indexMapper.queryScore(judgmentPointsId, projectId, userId); List indexs = new ArrayList(); //为新增项目时勾选判分点赋值 if (scores.size() <= 0) { for (int i = 0; i < points.size(); i++) { JudgmentPoints points2 = points.get(i); points2.setScore(0); points.set(i, points2); } } //为修改项目时勾选判分点赋值 else { //为有分数的赋值 for (int i = 0; i < points.size(); i++) { JudgmentPoints point = points.get(i); for (int j = 0; j < scores.size(); j++) { ScoreIndex score = scores.get(j); if (point.getJudgmentPointsId().equals(score.getJudgmentPointsId())) { point.setScore(score.getScore()); points.set(i, point); indexs.add(i); break; } } } //为没值的赋值 for (int i = 0; i < points.size(); i++) { if (!indexs.contains(i)) { JudgmentPoints points3 = points.get(i); points3.setScore(0); points.set(i, points3); } } } resp.put("retvalue", points); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 平均分配分值 * * @param number * @return */ public HashMap avgValues(Integer number) { HashMap resp = new HashMap(); try { resp.put("retvalue", UserUtil.averageValue(number)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Calculation ERROR"); return resp; } return resp; } /** * 查询单个项目判分点信息,根据项目id * * @param projectId 项目id * @return */ public HashMap getJudgmentPoints(Integer projectId) { HashMap resp = new HashMap(); HashMap obj = new HashMap(); HashMap score = new HashMap(); List scoreIndexList = null; try { //根据projectId查询判分点交易类型 List judgmentPointsList = mapper.getJudgmentPoints(projectId); Integer size = judgmentPointsList.size(); for (int i = 0; i roleList = mapper.queryProjectId(projectId); obj.put("roleList",roleList); obj.put("judgmentPointsList", judgmentPointsList); obj.put("scoreIndexList", score); resp.put("retvalue", obj); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 查询职站单个项目判分点信息,根据项目id * * @param projectId 项目id * @return */ public HashMap getZZJudgmentPoints(Integer projectId) { HashMap resp = new HashMap(); HashMap obj = new HashMap(); HashMap score = new HashMap(); List scoreIndexList = null; try { List judgmentPointsList = mapper.getZZJudgmentPoints(projectId); Integer size = judgmentPointsList.size(); for (int i = 0; i roleList = mapper.queryProjectId(projectId); obj.put("roleList",roleList); obj.put("judgmentPointsList", judgmentPointsList); obj.put("scoreIndexList", score); resp.put("retvalue", obj); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 查询单个项目判分点信息 * * @param roleId 角色ID * @return */ public HashMap getByRoleId(List roleId) { HashMap resp = new HashMap(); try { resp.put("retvalue", mapper.getByRoleId(roleId)); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Inquiry Failed"); return resp; } return resp; } /** * 修改角色信息 * * @param role 角色信息 * @return */ public HashMap updateRole(Role role) { HashMap resp = new HashMap(); try { mapper.updateRole(role); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "UPDATE ERROR"); return resp; } return resp; } /** * 添加角色信息 * * @param role 角色信息 * @return */ public HashMap insertRole(Role role) { HashMap resp = new HashMap(); try { mapper.insertRole(role); Integer roleId = role.getRoleId(); resp.put("retvalue", roleId); resp.put("retcode", 200); } catch (Exception e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "Add Failed"); return resp; } return resp; } /** * 添加项目管理信息 * * @return */ @Transactional public HashMap newAddProjectManagement(ProjectManagement pro, List points, List roles) { HashMap resp = new HashMap(); try { // 添加项目信息 mapper.insertProjectManagement(pro); // 取出添加的项目信息的id Integer projectId = pro.getProjectId(); for (int i = 0; i < points.size(); i++) { //拼接判分点中的项目id StringBuffer buff = new StringBuffer(); //判分点id Integer pointId = points.get(i).getJudgmentPointsId(); //根据该判分点得到数据库存储的对应数据 JudgmentPoints point = mapper.newGetProjectId(pointId); //取出绑定的项目id String projectIds = point.getProjectId(); //取出实验要求 String experimentalRequirements = point.getExperimentalRequirements(); //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id if (!StringUtils.isEmpty(projectIds)) { List lists = Arrays.asList(projectIds.split(",")); if (!lists.contains(projectId.toString())) { buff.append(projectIds); buff.append(","); buff.append(projectId); } } //数据库中该判分点未绑定任何项目id else if (projectIds == null) { buff.append(projectId); } //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 if (experimentalRequirements != null && !experimentalRequirements.equals("") && experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { mapper.updateTradingJudgmentPoints(new String(buff), pointId); } //数据库中的实验要求与前端传来的实验要求信息不一致 else if (!experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { mapper.updateTradingJudgmentPoints(new String(buff), pointId); } // 得到判分指标信息 ScoreIndex scoreIndex = new ScoreIndex(points.get(i).getScore(), pointId, projectId, pro.getUserId(),pro.getSystemId()); // 在判分指标中添加对应信息 indexMapper.addScoreIndex(scoreIndex); } // 修改角色信息中的项目管理id if (roles != null && roles.size() > 0) { Integer size = roles.size(); for (int i = 0; i insertProjectManagement(ProjectManagement pro, List points, List roles) { HashMap resp = new HashMap(); try { // 添加项目信息 mapper.insertProjectManagement(pro); // 取出添加的项目信息的id Integer projectId = pro.getProjectId(); for (int i = 0; i < points.size(); i++) { //拼接判分点中的项目id StringBuffer buff = new StringBuffer(); //判分点id Integer pointId = points.get(i).getJudgmentPointsId(); //根据该判分点得到数据库存储的对应数据 JudgmentPoints point = mapper.getByjudgmentPointsId(pointId); //JudgmentPoints point = mapper.newGetProjectId(pointId); //取出绑定的项目id String projectIds = point.getProjectId(); //取出实验要求 String experimentalRequirements = point.getExperimentalRequirements(); //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id if (!StringUtils.isEmpty(projectIds)) { List lists = Arrays.asList(projectIds.split(",")); if (!lists.contains(projectId.toString())) { buff.append(projectIds); buff.append(","); buff.append(projectId); } } //数据库中该判分点未绑定任何项目id else if (projectIds == null) { buff.append(projectId); } //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 if (experimentalRequirements != null && !experimentalRequirements.equals("") && experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { mapper.updateProject(new String(buff), null, pointId); } //数据库中的实验要求与前端传来的实验要求信息不一致 else if (!experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { mapper.updateProject(new String(buff), points.get(i).getExperimentalRequirements(), pointId); } // 得到判分指标信息 ScoreIndex scoreIndex = new ScoreIndex(points.get(i).getScore(), pointId, projectId, pro.getUserId(),pro.getSystemId()); // 在判分指标中添加对应信息 indexMapper.addScoreIndex(scoreIndex); } // 修改角色信息中的项目管理id if (roles != null && roles.size() > 0) { Integer size = roles.size(); for (int i = 0; i getByName(String projectName){ HashMap resp = new HashMap(); try{ Integer count = mapper.getByprojectName(projectName); if(count>=1){ resp.put("retcode", 300); resp.put("retvalue", "该项目名称已存在"); }else{ resp.put("retcode", 200); } }catch (RuntimeException e){ logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "QUERY Failed"); throw new RuntimeException(); } return resp; } /** * 修改项目管理信息 * * @return */ @Transactional public HashMap updateProjectManagement(ProjectManagement pro, List points, List roles) { HashMap resp = new HashMap(); //项目id Integer project = pro.getProjectId(); //用户id Integer userId = pro.getUserId(); try { // 取出该项目对应的判分点id List judgments = mapper.getByPointProjectId(project); // 取出该项目对应的角色id List rolesIds = mapper.getByRoleProjectId(project); for (int i = 0; i < points.size(); i++) { //拼接判分点中的项目id StringBuffer buff = new StringBuffer(); //前端传来的判分点id Integer pointId = points.get(i).getJudgmentPointsId(); //前端传来的实验要求 String experimentalRequirements1 = points.get(i).getExperimentalRequirements(); //前端传来的分数 Integer score1 = points.get(i).getScore(); Integer systemId = pro.getSystemId(); //判分点信息 JudgmentPoints point = mapper.getByjudgmentPointsId(pointId); String projectIds = point.getProjectId(); String experimentalRequirements2 = point.getExperimentalRequirements(); // 如果数据库中有,则取出分数,进行比较 if (judgments.contains(pointId)) { //分数 Integer score2 = indexMapper.getbyJudgmentPointsIdScore(pointId, project, userId); // 如果分数不一致,则修改分数表中的分数 if (score2 != null && score1 != score2) { indexMapper.updateScore(new ScoreIndex(score1, pointId, project, userId,systemId)); } // 如果数据库中该判分点分数为空,则添加分数 else if (score2 == null) { indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId(),systemId)); } //如果前端传来的实验要求与数据库中不一致,则修改数据库中的判分点信息 if (!experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateProject(point.getProjectId(), experimentalRequirements1, pointId); } } else { //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id if (!StringUtils.isEmpty(projectIds)) { List lists = Arrays.asList(projectIds.split(",")); if (!lists.contains(project.toString())) { buff.append(projectIds); buff.append(","); buff.append(project); } } //数据库中该判分点未绑定任何项目id else if (StringUtils.isEmpty(projectIds)) { buff.append(project); } //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 if (experimentalRequirements2 != null && !experimentalRequirements2.equals("") && experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateProject(new String(buff), null, pointId); } //数据库中的实验要求与前端传来的实验要求信息不一致 else if (!experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateProject(new String(buff), experimentalRequirements1, pointId); } // 添加分数 indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId(),systemId)); } judgments.remove(pointId); } // 从判分点id中删除该项目的id for (int i = 0; i < judgments.size(); i++) { Integer judgmentPointsId = judgments.get(i); JudgmentPoints point = mapper.getByjudgmentPointsId(judgmentPointsId); String projectIds = point.getProjectId(); // 删除分数表中对应的判分点id+项目id数据 indexMapper.removeScore(judgmentPointsId, project, userId); // 对取出的数据,删除该项目的id List str3 = Arrays.asList(projectIds.split(",")); if (str3.contains(project.toString())) { List arrayList = new ArrayList(str3); arrayList.remove(project.toString()); // 删除字符中项目id projectIds = StringUtils.strip(arrayList.toString(), "[]").replace(" ", ""); // 修改判分点中的项目id mapper.updateProject(projectIds, null, judgments.get(i)); } } // 用来存储需要修改的角色id List roleid = new ArrayList(); // 遍历前端传来的新的角色id for (int i = 0; i < roles.size(); i++) { // 如果前端传来的数据,在数据库中没有,则存起来 if (!rolesIds.contains(roles.get(i))) { roleid.add(roles.get(i)); } } if (roles != null && roles.size() > 0) { Integer size = roles.size(); for (int i = 0; i newUpdateProjectManagement(ProjectManagement pro, List points, List roles) { HashMap resp = new HashMap(); //项目id Integer project = pro.getProjectId(); // int del = mapper.delete(project); //用户id Integer userId = pro.getUserId(); try { //删除项目原本绑定的判分点 int del = mapper.delete(project); // 取出该项目对应的判分点id List judgments = mapper.getByPointProjectId(project); // 取出该项目对应的角色id List rolesIds = mapper.getByRoleProjectId(project); for (int i = 0; i < points.size(); i++) { //拼接判分点中的项目id StringBuffer buff = new StringBuffer(); //前端传来的判分点id Integer pointId = points.get(i).getJudgmentPointsId(); //前端传来的实验要求 String experimentalRequirements1 = points.get(i).getExperimentalRequirements(); //前端传来的分数 Integer score1 = points.get(i).getScore(); Integer systemId = pro.getSystemId(); //判分点信息 JudgmentPoints point = mapper.getNewByjudgmentPointsId(pointId); String projectIds = point.getProjectId(); String experimentalRequirements2 = point.getExperimentalRequirements(); // 如果数据库中有,则取出分数,进行比较 if (judgments.contains(pointId)) { //分数 Integer score2 = indexMapper.getbyJudgmentPointsIdScore(pointId, project, userId); // 如果分数不一致,则修改分数表中的分数 if (score2 != null && score1 != score2) { indexMapper.updateScore(new ScoreIndex(score1, pointId, project, userId,systemId)); } // 如果数据库中该判分点分数为空,则添加分数 else if (score2 == null) { indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId(),systemId)); } //如果前端传来的实验要求与数据库中不一致,则修改数据库中的判分点信息 if (!experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateTradingJudgmentPoints(point.getProjectId(), pointId); } } else { //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id if (!StringUtils.isEmpty(projectIds)) { List lists = Arrays.asList(projectIds.split(",")); if (!lists.contains(project.toString())) { buff.append(projectIds); buff.append(","); buff.append(project); } } //数据库中该判分点未绑定任何项目id else if (StringUtils.isEmpty(projectIds)) { buff.append(project); } //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 if (experimentalRequirements2 != null && !experimentalRequirements2.equals("") && experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateTradingJudgmentPoints(new String(buff), pointId); } //数据库中的实验要求与前端传来的实验要求信息不一致 else if (!experimentalRequirements2.equals(experimentalRequirements1)) { mapper.updateTradingJudgmentPoints(new String(buff), pointId); } // 添加分数 indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId(),systemId)); } judgments.remove(pointId); } // 从判分点id中删除该项目的id for (int i = 0; i < judgments.size(); i++) { Integer judgmentPointsId = judgments.get(i); JudgmentPoints point = mapper.getByjudgmentPointsId(judgmentPointsId); String projectIds = point.getProjectId(); // 删除分数表中对应的判分点id+项目id数据 indexMapper.removeScore(judgmentPointsId, project, userId); // 对取出的数据,删除该项目的id List str3 = Arrays.asList(projectIds.split(",")); if (str3.contains(project.toString())) { List arrayList = new ArrayList(str3); arrayList.remove(project.toString()); // 删除字符中项目id projectIds = StringUtils.strip(arrayList.toString(), "[]").replace(" ", ""); // 修改判分点中的项目id mapper.updateProject(projectIds, null, judgments.get(i)); } } // 用来存储需要修改的角色id List roleid = new ArrayList(); // 遍历前端传来的新的角色id for (int i = 0; i < roles.size(); i++) { // 如果前端传来的数据,在数据库中没有,则存起来 if (!rolesIds.contains(roles.get(i))) { roleid.add(roles.get(i)); } } if (roles != null && roles.size() > 0) { Integer size = roles.size(); for (int i = 0; i getManagements(Integer projectPermissions){ HashMap resp = new HashMap(); try{ List projectManagements = mapper.getManagements(projectPermissions); resp.put("retcode", 200); resp.put("retvalue",projectManagements); }catch (RuntimeException e){ logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "数据有误,查询失败!"); throw new RuntimeException(); } return resp; } /** * 项目启用/禁用 */ public HashMap enable(Integer id, Integer enable) { HashMap resp = new HashMap(); try { mapper.enable(id, enable); resp.put("retcode", 200); resp.put("retvalue","SUCCESS"); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); resp.put("retvalue", "SERVER ERROR"); throw new RuntimeException(); } return resp; } }