项目列表展示,名字去重

master
shijie 4 years ago
parent 18683df583
commit b62d61d468
  1. 454
      src/main/java/com/yipin/liuwanr/mapper/Project_ManagementMapper.java
  2. 15
      src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java

@ -15,226 +15,246 @@ import com.yipin.liuwanr.entity.Role;
/** /**
* 项目管理系统 项目管理表 * 项目管理系统 项目管理表
*
* @author 86151
* *
* @author 86151
*/ */
public interface Project_ManagementMapper { public interface Project_ManagementMapper {
/** /**
* 查询项目名称 * 查询项目名称
* @param projectName *
* @return * @param projectName
*/ * @return
@Select("select count(*) from hr_project_management where projectName=#{projectName}") */
Integer getByprojectName(String projectName); @Select("select count(*) from hr_project_management where projectName=#{projectName}")
Integer getByprojectName(String projectName);
/**
* 分页查询+条件查询 /**
* * 分页查询+条件查询
* @param management *
* @return * @param management
*/ * @return
@Select({ "<script>", */
"select projectId,projectName,projectPermissions,founder,creationTime,state from hr_project_management where isdel=0", @Select({"<script>",
" <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>", "select projectId,projectName,projectPermissions,founder,creationTime,state from hr_project_management where isdel=0",
" <if test='founder!=null'> and founder=#{founder}</if>", " <if test='projectPermissions!=null'> and projectPermissions=#{projectPermissions}</if>",
" <if test='state!=null'> and state=#{state}</if>", " <if test='founder!=null'> and founder=#{founder}</if>",
" <if test='systemId!=null'> and systemId=#{systemId}</if>", " <if test='userId!=null'> and (userId=#{userId} or founder = 0)</if>",
" <if test='userId!=null'> and userId=#{userId}</if>", " <if test='state!=null'> and state=#{state}</if>",
" <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>", " <if test='systemId!=null'> and systemId=#{systemId}</if>",
" ORDER BY creationTime desc", " <if test='projectName!=null'> and projectName like concat('%',#{projectName},'%')</if>",
"</script>" }) " ORDER BY creationTime desc",
List<Project_Management> queryManagements(Project_Management management); "</script>"})
List<Project_Management> queryManagements(Project_Management management);
/**
* 根据实验项目id查询信息 /**
* * 根据实验项目id查询信息
* @param projectId *
* @return * @param projectId
*/ * @return
@Select("select projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId from hr_project_management where isdel=0 and projectId=#{projectId}") */
Project_Management getProjectId(Integer projectId); @Select("select projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId from hr_project_management where isdel=0 and projectId=#{projectId}")
Project_Management getProjectId(Integer projectId);
/** /**
* 批量删除 * 根据实验项目id查询项目名称
* @param projectId *
*/ * @param projectId
@Update("<script>" + "<foreach collection = 'point' item ='projectId' open='' close='' separator=';'>" * @return
+ "update hr_project_management set isdel=1 where projectId=#{projectId}</foreach>" */
+ "</script>") @Select("select projectName from hr_project_management where isdel=0 and projectId=#{projectId}")
void deleteProjectManagement(@Param("point") List<Integer> projectId); String getNameByProjectId(Integer projectId);
/**
/** * 批量删除
* 添加角色信息 *
* * @param projectId
* @param role */
* @return @Update("<script>" + "<foreach collection = 'point' item ='projectId' open='' close='' separator=';'>"
*/ + "update hr_project_management set isdel=1 where projectId=#{projectId}</foreach>"
@Insert("insert into hr_role (roleNumber,roleType,roleAttribute) VALUES (#{roleNumber},#{roleType},#{roleAttribute})") + "</script>")
@Options(useGeneratedKeys = true, keyProperty = "roleId", keyColumn = "roleId") void deleteProjectManagement(@Param("point") List<Integer> projectId);
void insertRole(Role role);
/** /**
* 点击实验数据中单个角色后的编辑按钮,修改角色信息 * 添加角色信息
* *
* @param role * @param role
*/ * @return
@Update("update hr_role set roleNumber=#{roleNumber},roleType=#{roleType},roleAttribute=#{roleAttribute} where roleId=#{roleId}") */
void updateRole(Role role); @Insert("insert into hr_role (roleNumber,roleType,roleAttribute) VALUES (#{roleNumber},#{roleType},#{roleAttribute})")
@Options(useGeneratedKeys = true, keyProperty = "roleId", keyColumn = "roleId")
void insertRole(Role role);
/**
* 点击编辑或者创建项目管理页面的保存按钮后, /**
* 修改角色表中的对应数据的项目id * 点击实验数据中单个角色后的编辑按钮,修改角色信息
* @param ids *
* @param projectId * @param role
*/ */
@Update("<script>" + @Update("update hr_role set roleNumber=#{roleNumber},roleType=#{roleType},roleAttribute=#{roleAttribute} where roleId=#{roleId}")
"<foreach collection = 'ids' item ='id' open='' close='' separator=';'>" void updateRole(Role role);
+ "update hr_role set projectId=#{projectId} where roleId=#{id}</foreach>"
+ "</script>")
void updateRoleProjectId(@Param("ids")List<Integer> ids,@Param("projectId")Integer projectId); /**
* 点击编辑或者创建项目管理页面的保存按钮后,
* 修改角色表中的对应数据的项目id
@Delete("delete from hr_role where projectId=#{projectId}") *
void deleteRole(Integer projectId); * @param ids
* @param projectId
/** */
* 添加角色信息后在创建编辑页面的角色信息展示 @Update("<script>" +
* "<foreach collection = 'ids' item ='id' open='' close='' separator=';'>"
* @param role + "update hr_role set projectId=#{projectId} where roleId=#{id}</foreach>"
* @return + "</script>")
*/ void updateRoleProjectId(@Param("ids") List<Integer> ids, @Param("projectId") Integer projectId);
@Select({ "<script>",
"select roleId,roleNumber,roleType,roleAttribute from hr_role where roleId in",
"<foreach collection='role' item='ro' open='(' separator=',' close=')'>" + "#{ro} " + "</foreach> ", @Delete("delete from hr_role where projectId=#{projectId}")
"</script>" }) void deleteRole(Integer projectId);
List<Role> getByRoleId(@Param("role") List<Integer> role);
/**
* 添加角色信息后在创建编辑页面的角色信息展示
/** *
* 点击具体某个项目信息的编辑按钮, * @param role
* 跳转到编辑项目管理页面的实验数据的信息展示 * @return
* @param projectId */
* @return @Select({"<script>",
*/ "select roleId,roleNumber,roleType,roleAttribute from hr_role where roleId in",
@Select("select roleId,roleNumber,roleType,roleAttribute from hr_role where projectId=#{projectId}") "<foreach collection='role' item='ro' open='(' separator=',' close=')'>" + "#{ro} " + "</foreach> ",
List<Role> queryProjectId(Integer projectId); "</script>"})
List<Role> getByRoleId(@Param("role") List<Integer> role);
/**
* 添加判分点面板的判分信息展示 /**
* @return * 点击具体某个项目信息的编辑按钮,
*/ * 跳转到编辑项目管理页面的实验数据的信息展示
@Select({ "<script>", *
"select judgmentPointsId,judgmentPointsName from hr_judgment_points where isdel=0 and systemId=#{systemId} and isopen=0", * @param projectId
" <if test='judgmentPointsName!=null'> and judgmentPointsName like concat('%','${judgmentPointsName}','%')</if>", * @return
"</script>" }) */
List<Judgment_Points> queryAllJudgmentPoints(Judgment_Points points); @Select("select roleId,roleNumber,roleType,roleAttribute from hr_role where projectId=#{projectId}")
List<Role> queryProjectId(Integer projectId);
/**
* 从判分点添加面板选择完数据后 /**
* 创建项目管理页面的实验任务信息展示 * 添加判分点面板的判分信息展示
* @param point *
* @return * @return
*/ */
@Select({ "<script>", @Select({"<script>",
"select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and judgmentPointsId in", "select judgmentPointsId,judgmentPointsName from hr_judgment_points where isdel=0 and systemId=#{systemId} and isopen=0",
"<foreach collection='point' item='po' open='(' separator=',' close=')'>" + "#{po} " + "</foreach> ", " <if test='judgmentPointsName!=null'> and judgmentPointsName like concat('%','${judgmentPointsName}','%')</if>",
"</script>" }) "</script>"})
List<Judgment_Points> getByjudgmentPointsIds(@Param("point") List<Integer> point); List<Judgment_Points> queryAllJudgmentPoints(Judgment_Points points);
/**
* 点击具体某个项目信息的编辑按钮, /**
* 跳转到编辑项目管理页面的实验任务的信息展示 * 从判分点添加面板选择完数据后
* @param projectId * 创建项目管理页面的实验任务信息展示
* @return *
*/ * @param point
@Select("select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") * @return
List<Judgment_Points> getByProjectId(Integer projectId); */
@Select({"<script>",
"select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and judgmentPointsId in",
@Select("select judgmentPointsId,projectId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") "<foreach collection='point' item='po' open='(' separator=',' close=')'>" + "#{po} " + "</foreach> ",
List<Judgment_Points> queryProjectIds(Integer projectId); "</script>"})
List<Judgment_Points> getByjudgmentPointsIds(@Param("point") List<Integer> point);
/**
* 取出判分点中的项目管理的id /**
* @param judgmentPointsId * 点击具体某个项目信息的编辑按钮,
* @return * 跳转到编辑项目管理页面的实验任务的信息展示
*/ *
@Select("select projectId,experimentalRequirements from hr_judgment_points where judgmentPointsId=#{judgmentPointsId}") * @param projectId
Judgment_Points getByjudgmentPointsId(Integer judgmentPointsId); * @return
*/
/** @Select("select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0")
* 点击保存按按需要修改判分点表中对应的项目id,实验要求 List<Judgment_Points> getByProjectId(Integer projectId);
* @param projectId
* @param judgmentPointsId
*/ @Select("select judgmentPointsId,projectId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0")
@Update({"<script>", List<Judgment_Points> queryProjectIds(Integer projectId);
"update hr_judgment_points set projectId=#{projectId}",
" <if test='experimentalRequirements!=null'>,experimentalRequirements=#{experimentalRequirements}</if>", /**
" where judgmentPointsId=#{judgmentPointsId}", * 取出判分点中的项目管理的id
"</script>"}) *
void updateProject(String projectId,String experimentalRequirements,Integer judgmentPointsId); * @param judgmentPointsId
* @return
*/
/** @Select("select projectId,experimentalRequirements from hr_judgment_points where judgmentPointsId=#{judgmentPointsId}")
* 添加项目管理信息 Judgment_Points getByjudgmentPointsId(Integer judgmentPointsId);
*
* @param management /**
*/ * 点击保存按按需要修改判分点表中对应的项目id,实验要求
@Insert("INSERT INTO hr_project_management(projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,isExperiment,isAttendance,isdel)" *
+ " VALUES (#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},1,#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},0,0,0)") * @param projectId
@Options(useGeneratedKeys = true,keyProperty = "projectId",keyColumn = "projectId") * @param judgmentPointsId
void insertProjectManagement(Project_Management management); */
@Update({"<script>",
/** "update hr_judgment_points set projectId=#{projectId}",
* 修改项目管理信息 " <if test='experimentalRequirements!=null'>,experimentalRequirements=#{experimentalRequirements}</if>",
* " where judgmentPointsId=#{judgmentPointsId}",
* @param management "</script>"})
*/ void updateProject(String projectId, String experimentalRequirements, Integer judgmentPointsId);
@Update("update hr_project_management set projectName=#{projectName},projectPermissions=#{projectPermissions},experimentalGoal=#{experimentalGoal},caseDescription=#{caseDescription},experimentSuggests=#{experimentSuggests},state=#{state},"
+ "isstartexperimental=#{isstartexperimental},isstartexperimentSuggests=#{isstartexperimentSuggests} where projectId=#{projectId}")
void updateProjectManagement(Project_Management management); /**
* 添加项目管理信息
/** *
* 根据项目id,查询出该项目所有的判分点id * @param management
* @param projectId */
* @return @Insert("INSERT INTO hr_project_management(projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,isExperiment,isAttendance,isdel)"
*/ + " VALUES (#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},#{founder},#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},0,0,0)")
@Select("select judgmentPointsId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") @Options(useGeneratedKeys = true, keyProperty = "projectId", keyColumn = "projectId")
List<Integer> getByPointProjectId(Integer projectId); void insertProjectManagement(Project_Management management);
/** /**
* 根据项目id,查询出该项目所有的角色id * 修改项目管理信息
* @param projectId *
* @return * @param management
*/ */
@Select("select roleId from hr_role where projectId=#{projectId}") @Update("update hr_project_management set projectName=#{projectName},projectPermissions=#{projectPermissions},experimentalGoal=#{experimentalGoal},caseDescription=#{caseDescription},experimentSuggests=#{experimentSuggests},state=#{state},"
List<Integer> getByRoleProjectId(Integer projectId); + "isstartexperimental=#{isstartexperimental},isstartexperimentSuggests=#{isstartexperimentSuggests} where projectId=#{projectId}")
void updateProjectManagement(Project_Management management);
/** /**
* 查询用户角色 * 根据项目id,查询出该项目所有的判分点id
* @param userId *
* @return * @param projectId
*/ * @return
@Select("SELECT ro.roleId FROM user us,role ro WHERE ro.roleId=us.accountRole AND us.userId=#{userId}") */
@Select("select judgmentPointsId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0")
List<Integer> getByPointProjectId(Integer projectId);
/**
* 根据项目id,查询出该项目所有的角色id
*
* @param projectId
* @return
*/
@Select("select roleId from hr_role where projectId=#{projectId}")
List<Integer> getByRoleProjectId(Integer projectId);
/**
* 查询用户角色
*
* @param userId
* @return
*/
@Select("SELECT ro.roleId FROM user us,role ro WHERE ro.roleId=us.accountRole AND us.userId=#{userId}")
Integer queryRole(Integer userId); Integer queryRole(Integer userId);
/** /**
* 查询用户角色 * 查询用户角色
* @param userId *
* @return * @param userId
*/ * @return
@Select("SELECT accountRole FROM user WHERE userId=#{userId}") */
Integer queryRoleId(Integer userId); @Select("SELECT accountRole FROM user WHERE userId=#{userId}")
Integer queryRoleId(Integer userId);
} }

@ -408,7 +408,7 @@ public class Project_ManagementService {
String projectName = pro.getProjectName(); String projectName = pro.getProjectName();
Integer count = mapper.getByprojectName(projectName); Integer count = mapper.getByprojectName(projectName);
if (count != null) { if (count != null) {
projectName += (count + 1); projectName += (count + 1);
pro.setProjectName(projectName); pro.setProjectName(projectName);
} }
// 添加项目信息 // 添加项目信息
@ -592,11 +592,16 @@ public class Project_ManagementService {
} }
//项目名称去重 //项目名称去重
String projectName = pro.getProjectName(); String projectName = pro.getProjectName();
Integer count = mapper.getByprojectName(projectName);
if (count != null) { String name = mapper.getNameByProjectId(pro.getProjectId());
projectName += (count + 1); if (projectName != null && !projectName.equals(name)) {
pro.setProjectName(projectName); Integer count = mapper.getByprojectName(projectName);
if (count != null && count > 1) {
projectName += (count + 1);
pro.setProjectName(projectName);
}
} }
//修改项目信息 //修改项目信息
mapper.updateProjectManagement(pro); mapper.updateProjectManagement(pro);
resp.put("retcode", 200); resp.put("retcode", 200);

Loading…
Cancel
Save