@ -17,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.yipin.liuwanr.helper.UserUtil ;
import com.yipin.liuwanr.helper.UserUtil ;
import com.yipin.liuwanr.mapper.ProjectManagementMapper ;
import com.yipin.liuwanr.mapper.ProjectManagementMapper ;
import com.yipin.liuwanr.mapper.ScoreIndexMapper ;
import com.yipin.liuwanr.mapper.ScoreIndexMapper ;
import org.springframework.util.LinkedMultiValueMap ;
@Service
@Service
public class ProjectManagementService {
public class ProjectManagementService {
@ -77,18 +78,23 @@ public class ProjectManagementService {
public HashMap < String , Object > queryManagements ( ProjectManagement vo , Integer pageNo , Integer pageSize ) {
public HashMap < String , Object > queryManagements ( ProjectManagement vo , Integer pageNo , Integer pageSize ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
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 ) ;
PageHelper . startPage ( pageNo , pageSize ) ;
//条件查询
//条件查询
List < ProjectManagement > list = mapper . queryManagementsExport ( vo ) ;
List < ProjectManagement > list = mapper . queryManagementsExportTest ( vo ) ;
// //获取用户的角色信息
// String roleId = mapper.queryRoleIds(vo.getUserId());
// if (null != roleId) {
// if (roleId.contains("3")) {
// vo.setUserId(null);
// List<ProjectManagement> projectManagements = mapper.queryManagementsExport(vo);
// list.addAll(projectManagements);
// }
// }
PageInfo < ProjectManagement > info = new PageInfo < ProjectManagement > ( list ) ;
PageInfo < ProjectManagement > info = new PageInfo < ProjectManagement > ( list ) ;
resp . put ( "retvalue" , new PageResult ( info . getTotal ( ) , list ) ) ;
resp . put ( "retvalue" , new PageResult ( info . getTotal ( ) , list ) ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
@ -110,25 +116,21 @@ public class ProjectManagementService {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
//获取用户的角色信息
//获取用户的角色信息
// String roleId = mapper.queryRoleIds(vo.getUserId());
Integer roleId = mapper . queryRoleId ( vo . getUserId ( ) ) ;
// if (null != roleId) {
if ( null ! = roleId ) {
// //角色不对(学生没有权限)
//角色不对(学生没有权限)
// if (roleId.contains("4")) {
if ( roleId = = 4 ) {
// resp.put("retcode", 300);
resp . put ( "retcode" , 300 ) ;
// resp.put("retvalue", "抱歉,您的权限不能访问该地址!");
resp . put ( "retvalue" , "抱歉,您的权限不能访问该地址!" ) ;
// return resp;
return resp ;
// }
}
// //角色等于管理员或者超级管理员
//角色等于管理员或者超级管理员
// else if (roleId.contains("1")) {
else if ( roleId = = 1 ) {
// vo.setUserId(null);
vo . setUserId ( null ) ;
// }
}
// }
}
//条件查询
//条件查询
List < ProjectManagement > list = mapper . queryManagements ( vo ) ;
List < ProjectManagement > list = mapper . queryManagements ( vo ) ;
// if (vo.getFounder()==null||vo.getFounder()==3){
// List<ProjectManagement> list2 = mapper.queryUserManagements(vo);
// list.addAll(list2);
// }
resp . put ( "retvalue" , list ) ;
resp . put ( "retvalue" , list ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -153,10 +155,10 @@ public class ProjectManagementService {
try {
try {
for ( Integer po : projectId ) {
for ( Integer po : projectId ) {
//判分点
//判分点
List < Judgment_ Points > points = mapper . queryProjectIds ( po ) ;
List < JudgmentPoints > points = mapper . queryProjectIds ( po ) ;
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
//判分点
//判分点
Judgment_ Points pos = points . get ( i ) ;
JudgmentPoints pos = points . get ( i ) ;
Integer pointId = pos . getJudgmentPointsId ( ) ; //判分点id
Integer pointId = pos . getJudgmentPointsId ( ) ; //判分点id
String projectIds = pos . getProjectId ( ) ; //项目id
String projectIds = pos . getProjectId ( ) ; //项目id
@ -216,7 +218,7 @@ public class ProjectManagementService {
if ( null ! = management ) {
if ( null ! = management ) {
// 判分点信息
// 判分点信息
List < Judgment_ Points > points = mapper . getByProjectId ( projectId ) ;
List < JudgmentPoints > points = mapper . getByProjectId ( projectId ) ;
//判分点不为空
//判分点不为空
if ( null ! = points & & ! points . isEmpty ( ) ) {
if ( null ! = points & & ! points . isEmpty ( ) ) {
//存储判分点id
//存储判分点id
@ -228,7 +230,7 @@ public class ProjectManagementService {
if ( scores . size ( ) > 0 & & ! scores . isEmpty ( ) ) {
if ( scores . size ( ) > 0 & & ! scores . isEmpty ( ) ) {
//为有分数的赋值
//为有分数的赋值
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
Judgment_ Points point = points . get ( i ) ;
JudgmentPoints point = points . get ( i ) ;
for ( int j = 0 ; j < scores . size ( ) ; j + + ) {
for ( int j = 0 ; j < scores . size ( ) ; j + + ) {
ScoreIndex score = scores . get ( j ) ;
ScoreIndex score = scores . get ( j ) ;
if ( point . getJudgmentPointsId ( ) . equals ( score . getJudgmentPointsId ( ) ) ) {
if ( point . getJudgmentPointsId ( ) . equals ( score . getJudgmentPointsId ( ) ) ) {
@ -242,14 +244,14 @@ public class ProjectManagementService {
//为没值的赋值
//为没值的赋值
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
if ( ! indexs . contains ( i ) ) {
if ( ! indexs . contains ( i ) ) {
Judgment_ Points points3 = points . get ( i ) ;
JudgmentPoints points3 = points . get ( i ) ;
points3 . setScore ( 0 ) ;
points3 . setScore ( 0 ) ;
points . set ( i , points3 ) ;
points . set ( i , points3 ) ;
}
}
}
}
} else {
} else {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
Judgment_ Points point = points . get ( i ) ;
JudgmentPoints point = points . get ( i ) ;
//给分数赋值
//给分数赋值
point . setScore ( 0 ) ;
point . setScore ( 0 ) ;
//修改该判分点
//修改该判分点
@ -276,12 +278,70 @@ public class ProjectManagementService {
}
}
/ * *
* 根据项目管理id查询对应交易类判分点信息
*
* @param projectId
* @return
* /
public HashMap < String , Object > getTrdingJudgmentPoints ( Integer projectId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
try {
// 项目信息
ProjectManagement management = mapper . getProjectId ( projectId ) ;
if ( null ! = management ) {
// 判分点信息
List < JudgmentPoints > points = mapper . queryJudgmentPoints ( projectId ) ;
// 角色信息
List < Role > 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 < String , Object > getProject ( Integer projectId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
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
* @return
* /
* /
public HashMap < String , Object > queryAllJudgmentPoints ( Judgment_Points points ) {
public HashMap < String , Object > queryAllJudgmentPoints ( JudgmentPoints points ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
resp . put ( "retvalue" , mapper . queryAllJudgmentPoints ( points ) ) ;
resp . put ( "retvalue" , mapper . queryAllJudgmentPoints ( points ) ) ;
@ -305,13 +365,13 @@ public class ProjectManagementService {
public HashMap < String , Object > getByjudgmentPointsId ( List < Integer > judgmentPointsId , Integer projectId , Integer userId ) {
public HashMap < String , Object > getByjudgmentPointsId ( List < Integer > judgmentPointsId , Integer projectId , Integer userId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
List < Judgment_ Points > points = mapper . getByjudgmentPointsIds ( judgmentPointsId ) ;
List < JudgmentPoints > points = mapper . getByjudgmentPointsIds ( judgmentPointsId ) ;
List < ScoreIndex > scores = indexMapper . queryScore ( judgmentPointsId , projectId , userId ) ;
List < ScoreIndex > scores = indexMapper . queryScore ( judgmentPointsId , projectId , userId ) ;
List < Integer > indexs = new ArrayList < Integer > ( ) ;
List < Integer > indexs = new ArrayList < Integer > ( ) ;
//为新增项目时勾选判分点赋值
//为新增项目时勾选判分点赋值
if ( scores . size ( ) < = 0 ) {
if ( scores . size ( ) < = 0 ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
Judgment_ Points points2 = points . get ( i ) ;
JudgmentPoints points2 = points . get ( i ) ;
points2 . setScore ( 0 ) ;
points2 . setScore ( 0 ) ;
points . set ( i , points2 ) ;
points . set ( i , points2 ) ;
}
}
@ -320,7 +380,7 @@ public class ProjectManagementService {
else {
else {
//为有分数的赋值
//为有分数的赋值
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
Judgment_ Points point = points . get ( i ) ;
JudgmentPoints point = points . get ( i ) ;
for ( int j = 0 ; j < scores . size ( ) ; j + + ) {
for ( int j = 0 ; j < scores . size ( ) ; j + + ) {
ScoreIndex score = scores . get ( j ) ;
ScoreIndex score = scores . get ( j ) ;
if ( point . getJudgmentPointsId ( ) . equals ( score . getJudgmentPointsId ( ) ) ) {
if ( point . getJudgmentPointsId ( ) . equals ( score . getJudgmentPointsId ( ) ) ) {
@ -334,7 +394,7 @@ public class ProjectManagementService {
//为没值的赋值
//为没值的赋值
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
for ( int i = 0 ; i < points . size ( ) ; i + + ) {
if ( ! indexs . contains ( i ) ) {
if ( ! indexs . contains ( i ) ) {
Judgment_ Points points3 = points . get ( i ) ;
JudgmentPoints points3 = points . get ( i ) ;
points3 . setScore ( 0 ) ;
points3 . setScore ( 0 ) ;
points . set ( i , points3 ) ;
points . set ( i , points3 ) ;
}
}
@ -373,7 +433,6 @@ public class ProjectManagementService {
return resp ;
return resp ;
}
}
/ * *
/ * *
* 查询单个项目判分点信息 , 根据项目id
* 查询单个项目判分点信息 , 根据项目id
*
*
@ -382,8 +441,60 @@ public class ProjectManagementService {
* /
* /
public HashMap < String , Object > getJudgmentPoints ( Integer projectId ) {
public HashMap < String , Object > getJudgmentPoints ( Integer projectId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
HashMap < String , Object > score = new HashMap < String , Object > ( ) ;
List < ScoreIndex > scoreIndexList = null ;
try {
List < TradingJudgmentPoints > judgmentPointsList = mapper . getJudgmentPoints ( projectId ) ;
Integer size = judgmentPointsList . size ( ) ;
for ( int i = 0 ; i < size ; i + + ) {
TradingJudgmentPoints tradingJudgmentPoints = judgmentPointsList . get ( i ) ;
Integer judgmentPointsId = tradingJudgmentPoints . getId ( ) ;
Integer systemId = tradingJudgmentPoints . getSystemId ( ) ;
scoreIndexList = mapper . getScore ( judgmentPointsId , systemId , projectId ) ;
score . put ( "scoreIndexList" + i , scoreIndexList ) ;
}
List < Role > 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 < String , Object > getZZJudgmentPoints ( Integer projectId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > obj = new HashMap < String , Object > ( ) ;
HashMap < String , Object > score = new HashMap < String , Object > ( ) ;
List < ScoreIndex > scoreIndexList = null ;
try {
try {
resp . put ( "retvalue" , mapper . getJudgmentPoints ( projectId ) ) ;
List < JudgmentPoints > judgmentPointsList = mapper . getZZJudgmentPoints ( projectId ) ;
Integer size = judgmentPointsList . size ( ) ;
for ( int i = 0 ; i < size ; i + + ) {
JudgmentPoints judgmentPoints = judgmentPointsList . get ( i ) ;
Integer judgmentPointsId = judgmentPoints . getJudgmentPointsId ( ) ;
Integer systemId = judgmentPoints . getSystemId ( ) ;
scoreIndexList = mapper . getScore ( judgmentPointsId , systemId , projectId ) ;
score . put ( "scoreIndexList" + i , scoreIndexList ) ;
}
List < Role > roleList = mapper . queryProjectId ( projectId ) ;
obj . put ( "roleList" , roleList ) ;
obj . put ( "judgmentPointsList" , judgmentPointsList ) ;
obj . put ( "scoreIndexList" , scoreIndexList ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
logger . error ( e . getMessage ( ) ) ;
@ -465,17 +576,83 @@ public class ProjectManagementService {
* @return
* @return
* /
* /
@Transactional
@Transactional
public HashMap < String , Object > insertProjectManagement ( ProjectManagement pro , List < Judgment_Points > points , List < Integer > roles ) {
public HashMap < String , Object > newAddProjectManagement ( ProjectManagement pro , List < JudgmentPoints > points , List < Integer > roles ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
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 < String > 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 < size ; i + + ) {
Integer roleId = roles . get ( i ) ;
mapper . updateRoleProjectId ( roleId , projectId ) ;
}
}
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Add Failed" ) ;
System . out . println ( e . getMessage ( ) ) ;
throw new RuntimeException ( ) ;
}
return resp ;
}
/ * *
* 添加项目管理信息
*
* @return
* /
@Transactional
public HashMap < String , Object > insertProjectManagement ( ProjectManagement pro , List < JudgmentPoints > points , List < Integer > roles ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
try {
//只允许一个Founder
// if (pro.getFounder()==1){//超管
// pro.setFounder(1);
// }else if (pro.getFounder()==2){//管理员
// pro.setFounder(2);
// }else if (pro.getFounder()==3){//老师
// pro.setFounder(3);
// }
// 添加项目信息
// 添加项目信息
mapper . insertProjectManagement ( pro ) ;
mapper . insertProjectManagement ( pro ) ;
// 取出添加的项目信息的id
// 取出添加的项目信息的id
@ -487,7 +664,7 @@ public class ProjectManagementService {
//判分点id
//判分点id
Integer pointId = points . get ( i ) . getJudgmentPointsId ( ) ;
Integer pointId = points . get ( i ) . getJudgmentPointsId ( ) ;
//根据该判分点得到数据库存储的对应数据
//根据该判分点得到数据库存储的对应数据
Judgment_ Points point = mapper . getByjudgmentPointsId ( pointId ) ;
JudgmentPoints point = mapper . getByjudgmentPointsId ( pointId ) ;
//取出绑定的项目id
//取出绑定的项目id
String projectIds = point . getProjectId ( ) ;
String projectIds = point . getProjectId ( ) ;
//取出实验要求
//取出实验要求
@ -517,13 +694,17 @@ public class ProjectManagementService {
}
}
// 得到判分指标信息
// 得到判分指标信息
ScoreIndex scoreIndex = new ScoreIndex ( points . get ( i ) . getScore ( ) , pointId , projectId , pro . getUserId ( ) ) ;
ScoreIndex scoreIndex = new ScoreIndex ( points . get ( i ) . getScore ( ) , pointId , projectId , pro . getUserId ( ) , pro . getSystemId ( ) ) ;
// 在判分指标中添加对应信息
// 在判分指标中添加对应信息
indexMapper . addScoreIndex ( scoreIndex ) ;
indexMapper . addScoreIndex ( scoreIndex ) ;
}
}
// 修改角色信息中的项目管理id
// 修改角色信息中的项目管理id
if ( roles ! = null & & roles . size ( ) > 0 ) {
if ( roles ! = null & & roles . size ( ) > 0 ) {
mapper . updateRoleProjectId ( roles , projectId ) ;
Integer size = roles . size ( ) ;
for ( int i = 0 ; i < size ; i + + ) {
Integer roleId = roles . get ( i ) ;
mapper . updateRoleProjectId ( roleId , projectId ) ;
}
}
}
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
@ -543,7 +724,7 @@ public class ProjectManagementService {
try {
try {
Integer count = mapper . getByprojectName ( projectName ) ;
Integer count = mapper . getByprojectName ( projectName ) ;
if ( count > = 1 ) {
if ( count > = 1 ) {
resp . put ( "retcode" , 201 ) ;
resp . put ( "retcode" , 300 ) ;
resp . put ( "retvalue" , "该项目名称已存在" ) ;
resp . put ( "retvalue" , "该项目名称已存在" ) ;
} else {
} else {
resp . put ( "retcode" , 200 ) ;
resp . put ( "retcode" , 200 ) ;
@ -563,7 +744,7 @@ public class ProjectManagementService {
* @return
* @return
* /
* /
@Transactional
@Transactional
public HashMap < String , Object > updateProjectManagement ( ProjectManagement pro , List < Judgment_ Points > points ,
public HashMap < String , Object > updateProjectManagement ( ProjectManagement pro , List < JudgmentPoints > points ,
List < Integer > roles ) {
List < Integer > roles ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
@ -587,9 +768,10 @@ public class ProjectManagementService {
String experimentalRequirements1 = points . get ( i ) . getExperimentalRequirements ( ) ;
String experimentalRequirements1 = points . get ( i ) . getExperimentalRequirements ( ) ;
//前端传来的分数
//前端传来的分数
Integer score1 = points . get ( i ) . getScore ( ) ;
Integer score1 = points . get ( i ) . getScore ( ) ;
Integer systemId = pro . getSystemId ( ) ;
//判分点信息
//判分点信息
Judgment_ Points point = mapper . getByjudgmentPointsId ( pointId ) ;
JudgmentPoints point = mapper . getByjudgmentPointsId ( pointId ) ;
String projectIds = point . getProjectId ( ) ;
String projectIds = point . getProjectId ( ) ;
String experimentalRequirements2 = point . getExperimentalRequirements ( ) ;
String experimentalRequirements2 = point . getExperimentalRequirements ( ) ;
@ -599,11 +781,11 @@ public class ProjectManagementService {
Integer score2 = indexMapper . getbyJudgmentPointsIdScore ( pointId , project , userId ) ;
Integer score2 = indexMapper . getbyJudgmentPointsIdScore ( pointId , project , userId ) ;
// 如果分数不一致,则修改分数表中的分数
// 如果分数不一致,则修改分数表中的分数
if ( score2 ! = null & & score1 ! = score2 ) {
if ( score2 ! = null & & score1 ! = score2 ) {
indexMapper . updateScore ( new ScoreIndex ( score1 , pointId , project , userId ) ) ;
indexMapper . updateScore ( new ScoreIndex ( score1 , pointId , project , userId , systemId ) ) ;
}
}
// 如果数据库中该判分点分数为空,则添加分数
// 如果数据库中该判分点分数为空,则添加分数
else if ( score2 = = null ) {
else if ( score2 = = null ) {
indexMapper . addScoreIndex ( new ScoreIndex ( score1 , pointId , project , pro . getUserId ( ) ) ) ;
indexMapper . addScoreIndex ( new ScoreIndex ( score1 , pointId , project , pro . getUserId ( ) , systemId ) ) ;
}
}
//如果前端传来的实验要求与数据库中不一致,则修改数据库中的判分点信息
//如果前端传来的实验要求与数据库中不一致,则修改数据库中的判分点信息
if ( ! experimentalRequirements2 . equals ( experimentalRequirements1 ) ) {
if ( ! experimentalRequirements2 . equals ( experimentalRequirements1 ) ) {
@ -634,7 +816,7 @@ public class ProjectManagementService {
mapper . updateProject ( new String ( buff ) , experimentalRequirements1 , pointId ) ;
mapper . updateProject ( new String ( buff ) , experimentalRequirements1 , pointId ) ;
}
}
// 添加分数
// 添加分数
indexMapper . addScoreIndex ( new ScoreIndex ( score1 , pointId , project , pro . getUserId ( ) ) ) ;
indexMapper . addScoreIndex ( new ScoreIndex ( score1 , pointId , project , pro . getUserId ( ) , systemId ) ) ;
}
}
judgments . remove ( pointId ) ;
judgments . remove ( pointId ) ;
}
}
@ -643,7 +825,7 @@ public class ProjectManagementService {
for ( int i = 0 ; i < judgments . size ( ) ; i + + ) {
for ( int i = 0 ; i < judgments . size ( ) ; i + + ) {
Integer judgmentPointsId = judgments . get ( i ) ;
Integer judgmentPointsId = judgments . get ( i ) ;
Judgment_ Points point = mapper . getByjudgmentPointsId ( judgmentPointsId ) ;
JudgmentPoints point = mapper . getByjudgmentPointsId ( judgmentPointsId ) ;
String projectIds = point . getProjectId ( ) ;
String projectIds = point . getProjectId ( ) ;
// 删除分数表中对应的判分点id+项目id数据
// 删除分数表中对应的判分点id+项目id数据
indexMapper . removeScore ( judgmentPointsId , project , userId ) ;
indexMapper . removeScore ( judgmentPointsId , project , userId ) ;
@ -671,9 +853,151 @@ public class ProjectManagementService {
}
}
}
}
if ( roleid . size ( ) > 0 & & ! roleid . isEmpty ( ) ) {
if ( roles ! = null & & roles . size ( ) > 0 ) {
// 修改对应角色的项目id
Integer size = roles . size ( ) ;
mapper . updateRoleProjectId ( roleid , project ) ;
for ( int i = 0 ; i < size ; i + + ) {
Integer roleId = roles . get ( i ) ;
mapper . updateRoleProjectId ( roleId , project ) ;
}
}
//修改项目信息
mapper . updateProjectManagement ( pro ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Update Failed" ) ;
throw new RuntimeException ( ) ;
}
return resp ;
}
/ * *
* 新修改修改项目管理信息
*
* @return
* /
@Transactional
public HashMap < String , Object > newUpdateProjectManagement ( ProjectManagement pro , List < JudgmentPoints > points ,
List < Integer > roles ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
//项目id
Integer project = pro . getProjectId ( ) ;
// int del = mapper.delete(project);
//用户id
Integer userId = pro . getUserId ( ) ;
try {
//删除项目原本绑定的判分点
int del = mapper . delete ( project ) ;
// 取出该项目对应的判分点id
List < Integer > judgments = mapper . getByPointProjectId ( project ) ;
// 取出该项目对应的角色id
List < Integer > 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 < String > 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 < String > str3 = Arrays . asList ( projectIds . split ( "," ) ) ;
if ( str3 . contains ( project . toString ( ) ) ) {
List < String > arrayList = new ArrayList < String > ( str3 ) ;
arrayList . remove ( project . toString ( ) ) ;
// 删除字符中项目id
projectIds = StringUtils . strip ( arrayList . toString ( ) , "[]" ) . replace ( " " , "" ) ;
// 修改判分点中的项目id
mapper . updateProject ( projectIds , null , judgments . get ( i ) ) ;
}
}
// 用来存储需要修改的角色id
List < Integer > roleid = new ArrayList < Integer > ( ) ;
// 遍历前端传来的新的角色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 < size ; i + + ) {
Integer roleId = roles . get ( i ) ;
mapper . updateRoleProjectId ( roleId , project ) ;
}
}
}
//修改项目信息
//修改项目信息