@ -27,32 +27,33 @@ import com.yipin.liuwanr.vo.AssesmentStudentVo;
@Service
public class AssesmentService {
private static Logger logger = Logger . getLogger ( AssesmentService . class ) ;
private static Logger logger = Logger . getLogger ( AssesmentService . class ) ;
@Autowired
private AssesmentMapper mapper ;
/ * *
* 考核管理列表查询
*
* @param assesment
* @param pageNo
* @param pageSize
* @return
* /
public HashMap < String , Object > queryAssesmentCondition ( Assesment assesment , Integer pageNo , Integer pageSize ) {
public HashMap < String , Object > queryAssesmentCondition ( Assesment assesment , Integer pageNo , Integer pageSize ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
PageHelper . startPage ( pageNo , pageSize ) ;
List < Assesment > assesments = mapper . getByCondition ( assesment ) ;
PageInfo < Assesment > info = new PageInfo < Assesment > ( assesments ) ;
PageInfo < Assesment > info = new PageInfo < Assesment > ( assesments ) ;
int total1 = ( int ) info . getTotal ( ) ;
int totalPages ;
totalPages = total1 / pageSize ;
if ( total1 % pageSize ! = 0 ) {
totalPages + + ;
if ( total1 % pageSize ! = 0 ) {
totalPages + + ;
}
long total = total1 ;
resp . put ( "retvalue" , new PageResult ( total , assesments , totalPages ) ) ;
resp . put ( "retvalue" , new PageResult ( total , assesments , totalPages ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( RuntimeException e ) {
logger . error ( e . getMessage ( ) ) ;
@ -66,29 +67,33 @@ public class AssesmentService {
/ * *
* 创建考核
*
* @param vo
* @return
* /
@Transactional
public HashMap < String , Object > addAssesment ( AssesmentStudentVo vo ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
Assesment assesment = vo . getAssesment ( ) ;
List < Integer > studentIds = vo . getStudentIds ( ) ;
Assesment assesment = vo . getAssesment ( ) ;
List < Integer > studentIds = vo . getStudentIds ( ) ;
try {
//转换时间格式
assesment = AssesmentHelper . helpAssesment ( assesment ) ;
if ( assesment . getExperimentalClassId ( ) ! = null ) {
if ( assesment . getExperimentalClassId ( ) ! = null ) {
//行政班级id
List < String > classid = mapper . queryClassId ( studentIds ) ;
List < String > classid = mapper . queryClassId ( studentIds ) ;
String classId = String . join ( "," , classid ) ;
assesment . setClassId ( classId ) ;
}
//考核人数
assesment . setAssessmentSize ( studentIds . size ( ) ) ;
//判分点数量
Integer pointNumber = mapper . queryPointNumber ( assesment . getExperimentId ( ) ) ;
assesment . setAssessmentNumber ( pointNumber ) ;
//添加考核
mapper . insertAssesment ( assesment ) ;
//得到考核id
Integer assesmentId = assesment . getId ( ) ;
Integer assesmentId = assesment . getId ( ) ;
//往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目
mapper . insertRecore ( studentIds , assesment . getExperimentId ( ) , assesment . getCourseId ( ) , assesmentId ) ;
@ -97,7 +102,7 @@ public class AssesmentService {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Add Failed" ) ;
return resp ;
throw new RuntimeException ( ) ;
}
return resp ;
}
@ -105,6 +110,7 @@ public class AssesmentService {
/ * *
* 查询选中的学生有哪些正在参与考核
*
* @param studentIds
* @return
* /
@ -112,7 +118,7 @@ public class AssesmentService {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
//查询出来的学生信息
List < Student > stu = mapper . queryStudentisAssess ( studentIds ) ;
List < Student > stu = mapper . queryStudentisAssess ( studentIds ) ;
resp . put ( "retcode" , 200 ) ;
resp . put ( "retvalue" , stu ) ;
} catch ( Exception e ) {
@ -127,21 +133,22 @@ public class AssesmentService {
/ * *
* 根据id查询考核的信息
*
* @param id
* @return
* /
public HashMap < String , Object > queryGetById ( Integer id ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
try {
//考核信息
Assesment assesment = mapper . queryGetById ( id ) ;
Assesment assesment = mapper . queryGetById ( id ) ;
//之前选中的学生
List < Student > students = mapper . queryStudent ( id ) ;
List < Student > students = mapper . queryStudent ( id ) ;
obj . add ( assesment ) ;
obj . add ( students ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
@ -155,29 +162,28 @@ public class AssesmentService {
/ * *
* 修改考核管理
* @param vo
* @return
* /
@Transactional
public HashMap < String , Object > updateAssesment ( Assesment assesment , List < Integer > studentIds ) {
public HashMap < String , Object > updateAssesment ( Assesment assesment , List < Integer > studentIds ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
assesment = AssesmentHelper . helpAssesment ( assesment ) ;
try {
//数据库存储的考核信息
Assesment before = mapper . queryGetById ( assesment . getId ( ) ) ;
Assesment before = mapper . queryGetById ( assesment . getId ( ) ) ;
//数据库存储的学生
List < Student > students = mapper . queryStudent ( assesment . getId ( ) ) ;
if ( assesment . getExperimentalClassId ( ) ! = null ) {
List < Student > students = mapper . queryStudent ( assesment . getId ( ) ) ;
if ( assesment . getExperimentalClassId ( ) ! = null ) {
//新的行政班级id
List < String > classid = mapper . queryClassId ( studentIds ) ;
List < String > classid = mapper . queryClassId ( studentIds ) ;
String classId = String . join ( "," , classid ) ;
if ( ! classId . equals ( before . getClassId ( ) ) ) {
if ( ! classId . equals ( before . getClassId ( ) ) ) {
assesment . setClassId ( classId ) ;
} else {
} else {
assesment . setClassId ( before . getClassId ( ) ) ;
}
} else if ( assesment . getClassId ( ) ! = null ) {
} else if ( assesment . getClassId ( ) ! = null ) {
assesment . setExperimentalClassId ( null ) ;
}
// 比较两批学生的信息
@ -192,15 +198,18 @@ public class AssesmentService {
}
}
//前端传来的添加
if ( studentIds . size ( ) > 0 ) {
if ( studentIds . size ( ) > 0 ) {
mapper . insertRecore ( studentIds , assesment . getExperimentId ( ) , assesment . getCourseId ( ) , assesment . getId ( ) ) ;
}
//后端剩余的删除
if ( students . size ( ) > 0 ) {
if ( students . size ( ) > 0 ) {
mapper . deleteRecord ( assesment . getId ( ) , students ) ;
}
//更新考核
assesment . setAssessmentSize ( studentIds . size ( ) ) ; //考核人数
//判分点数量
Integer pointNumber = mapper . queryPointNumber ( assesment . getExperimentId ( ) ) ;
assesment . setAssessmentNumber ( pointNumber ) ;
mapper . updateAssesment ( assesment ) ;
resp . put ( "retcode" , 200 ) ;
@ -208,30 +217,31 @@ public class AssesmentService {
logger . error ( e . getMessage ( ) ) ;
resp . put ( "retcode" , 500 ) ;
resp . put ( "retvalue" , "Update Failed" ) ;
return resp ;
throw new RuntimeException ( ) ;
}
return resp ;
}
/ * *
* 启动考核前的判断
*
* @param assesmentId
* @return
* /
public HashMap < String , Object > assessmentJudgment ( Integer assesmentId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Student > obj = new ArrayList < Student > ( ) ;
List < Student > obj = new ArrayList < Student > ( ) ;
try {
List < Integer > datas = mapper . getStudentisAssess ( ) ;
List < Student > students = mapper . queryStudent ( assesmentId ) ;
List < Integer > datas = mapper . getStudentisAssess ( ) ;
List < Student > students = mapper . queryStudent ( assesmentId ) ;
for ( int i = 0 ; i < students . size ( ) ; i + + ) {
Student stu = students . get ( i ) ;
if ( datas . contains ( stu . getStudentId ( ) ) ) {
Student stu = students . get ( i ) ;
if ( datas . contains ( stu . getStudentId ( ) ) ) {
obj . add ( stu ) ;
}
}
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
@ -243,12 +253,8 @@ public class AssesmentService {
}
/ * *
* 修改考核状态
* @param id
* @param state
* @return
* /
public HashMap < String , Object > updateState ( Assesment assesment ) {
@ -261,26 +267,27 @@ public class AssesmentService {
try {
String createTime = assesment . getCreationTime ( ) ;
String endTime = assesment . getEndTime ( ) ;
String timeSum = assesment . getTimesum ( ) ;
String timeSum = assesment . getTimesum ( ) ;
if ( createTime ! = null & & ! createTime . equals ( "" ) ) {
if ( createTime ! = null & & ! createTime . equals ( "" ) ) {
starttime = Long . parseLong ( assesment . getCreationTime ( ) ) ;
assesment . setCreationTime ( AssesmentHelper . longPointDate ( starttime ) ) ;
}
if ( endTime ! = null & & ! endTime . equals ( "" ) ) {
if ( endTime ! = null & & ! endTime . equals ( "" ) ) {
endtime = Long . parseLong ( assesment . getEndTime ( ) ) ;
assesment . setEndTime ( AssesmentHelper . longPointDate ( endtime ) ) ;
} if ( timeSum ! = null & & ! timeSum . equals ( "" ) ) {
datas = timeSum . split ( "h" ) ;
if ( datas ! = null & & datas . length > 0 ) {
hour = Integer . parseInt ( datas [ 0 ] ) ;
if ( datas . length > 2 ) {
minute = Integer . parseInt ( datas [ 1 ] ) ;
}
if ( timeSum ! = null & & ! timeSum . equals ( "" ) ) {
datas = timeSum . split ( "h" ) ;
if ( datas ! = null & & datas . length > 0 ) {
hour = Integer . parseInt ( datas [ 0 ] ) ;
if ( datas . length > 2 ) {
minute = Integer . parseInt ( datas [ 1 ] ) ;
}
long time = ( ( hour * 60 ) + minute ) * 60 * 1000 ;
endTime = AssesmentHelper . longPointDate ( starttime + time ) ;
}
long time = ( ( hour * 60 ) + minute ) * 60 * 1000 ;
endTime = AssesmentHelper . longPointDate ( starttime + time ) ;
assesment . setEndTime ( endTime ) ;
}
mapper . updateAssesmentState ( assesment ) ;
@ -297,6 +304,7 @@ public class AssesmentService {
/ * *
* 查询实验班级一级栏目
*
* @param staffId : 教师id
* @return
* /
@ -317,13 +325,14 @@ public class AssesmentService {
/ * *
* 查询实验班级名称 , 以及班级一下的学生
*
* @param cretionTime
* @return
* /
public HashMap < String , Object > queryCretionTime ( String cretionTime , Integer staffId ) {
public HashMap < String , Object > queryCretionTime ( String cretionTime , Integer staffId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , mapper . queryExperimentalClass ( cretionTime , staffId ) ) ;
resp . put ( "retvalue" , mapper . queryExperimentalClass ( cretionTime , staffId ) ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
@ -337,6 +346,7 @@ public class AssesmentService {
/ * *
* 考核信息展示
*
* @param assesmentId
* @return
* /
@ -357,19 +367,20 @@ public class AssesmentService {
/ * *
* 班级筛选
*
* @param assesmentId
* @return
* /
public HashMap < String , Object > getByclass ( Integer assesmentId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
try {
ExperimentalClass experimentalClasses = mapper . queryExperimental ( assesmentId ) ;
List < SutdentClass > classes = mapper . queryClass ( assesmentId ) ;
ExperimentalClass experimentalClasses = mapper . queryExperimental ( assesmentId ) ;
List < SutdentClass > classes = mapper . queryClass ( assesmentId ) ;
obj . add ( experimentalClasses ) ;
obj . add ( classes ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
@ -383,41 +394,36 @@ public class AssesmentService {
/ * *
* 成绩概况
* @param assesmentId
* @param projectId
* @param experimentalClassId
* @param classId
* @return
* /
public HashMap < String , Object > queryScore ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
public HashMap < String , Object > queryScore ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
Score score = new Score ( ) ;
Score score = new Score ( ) ;
int size = 0 ;
try {
List < Integer > scores = mapper . queryScore ( assesmentId , experimentalClassId , classId ) ;
if ( scores . size ( ) > 0 ) {
size = scores . size ( ) ;
List < Integer > scores = mapper . queryScore ( assesmentId , experimentalClassId , classId ) ;
if ( scores . size ( ) > 0 ) {
size = scores . size ( ) ;
//最低分
score . setMin ( scores . get ( 0 ) ) ;
//最高分
score . setMax ( scores . get ( size - 1 ) ) ;
score . setMax ( scores . get ( size - 1 ) ) ;
//考核人数
score . setPeopleSize ( size ) ;
//中位数
double median = 0 . 0 ;
if ( size % 2 = = 1 ) {
median = scores . get ( ( size - 1 ) / 2 ) ;
} else {
median = ( scores . get ( ( size / 2 - 1 ) ) + scores . get ( size / 2 ) + 0 . 0 ) / 2 ;
double median = 0 . 0 ;
if ( size % 2 = = 1 ) {
median = scores . get ( ( size - 1 ) / 2 ) ;
} else {
median = ( scores . get ( ( size / 2 - 1 ) ) + scores . get ( size / 2 ) + 0 . 0 ) / 2 ;
}
score . setMedian ( median ) ;
//平均分
int avg = 0 ;
int avg = 0 ;
for ( int i = 0 ; i < scores . size ( ) ; i + + ) {
avg + = scores . get ( i ) ;
avg + = scores . get ( i ) ;
}
score . setAvg ( avg * 1 . 0 / size ) ;
} else {
score . setAvg ( avg * 1 . 0 / size ) ;
} else {
//最低分
score . setMin ( 0 ) ;
//最高分
@ -429,8 +435,7 @@ public class AssesmentService {
//平均分
score . setAvg ( 0 ) ;
}
//判分点数量
Integer pointNumber = mapper . queryPointNumber ( assesmentId ) ;
Integer pointNumber = mapper . getAssesmentNumber ( assesmentId ) ;
if ( StringUtils . isEmpty ( pointNumber ) ) {
score . setPointNumber ( 0 ) ;
} else {
@ -444,6 +449,7 @@ public class AssesmentService {
score . setError ( error ) ;
}
}
resp . put ( "retvalue" , score ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
@ -458,50 +464,51 @@ public class AssesmentService {
/ * *
* 成绩柱状图
*
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return
* /
public HashMap < String , Object > queryHistogram ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
public HashMap < String , Object > queryHistogram ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Integer > obj = new ArrayList < Integer > ( ) ;
List < Integer > obj = new ArrayList < Integer > ( ) ;
try {
Integer one = 0 ;
Integer two = 0 ;
Integer three = 0 ;
Integer four = 0 ;
Integer five = 0 ;
Integer six = 0 ;
Integer seven = 0 ;
Integer eight = 0 ;
Integer nine = 0 ;
Integer ten = 0 ;
List < Record > scores = mapper . queryScore2 ( assesmentId , experimentalClassId , classId ) ;
Integer one = 0 ;
Integer two = 0 ;
Integer three = 0 ;
Integer four = 0 ;
Integer five = 0 ;
Integer six = 0 ;
Integer seven = 0 ;
Integer eight = 0 ;
Integer nine = 0 ;
Integer ten = 0 ;
List < Record > scores = mapper . queryScore2 ( assesmentId , experimentalClassId , classId ) ;
for ( int i = 0 ; i < scores . size ( ) ; i + + ) {
Integer score = scores . get ( i ) . getScore ( ) ;
Integer number = scores . get ( i ) . getNumber ( ) ;
if ( score > = 0 & & score < = 10 ) {
one + = number ;
} else if ( score > 10 & & score < = 20 ) {
two + = number ;
} else if ( score > 20 & & score < = 30 ) {
three + = number ;
} else if ( score > 30 & & score < = 40 ) {
four + = number ;
} else if ( score > 40 & & score < = 50 ) {
five + = number ;
} else if ( score > 50 & & score < = 60 ) {
six + = number ;
} else if ( score > 60 & & score < = 70 ) {
seven + = number ;
} else if ( score > 70 & & score < = 80 ) {
eight + = number ;
} else if ( score > 80 & & score < = 90 ) {
nine + = number ;
} else if ( score > 90 & & score < = 100 ) {
ten + = number ;
Integer score = scores . get ( i ) . getScore ( ) ;
Integer number = scores . get ( i ) . getNumber ( ) ;
if ( score > = 0 & & score < = 10 ) {
one + = number ;
} else if ( score > 10 & & score < = 20 ) {
two + = number ;
} else if ( score > 20 & & score < = 30 ) {
three + = number ;
} else if ( score > 30 & & score < = 40 ) {
four + = number ;
} else if ( score > 40 & & score < = 50 ) {
five + = number ;
} else if ( score > 50 & & score < = 60 ) {
six + = number ;
} else if ( score > 60 & & score < = 70 ) {
seven + = number ;
} else if ( score > 70 & & score < = 80 ) {
eight + = number ;
} else if ( score > 80 & & score < = 90 ) {
nine + = number ;
} else if ( score > 90 & & score < = 100 ) {
ten + = number ;
}
}
@ -532,28 +539,29 @@ public class AssesmentService {
/ * *
* 错误分布折线图
*
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return
* /
public HashMap < String , Object > getLinechart ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
public HashMap < String , Object > getLinechart ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
List < Object > obj = new ArrayList < Object > ( ) ;
try {
List < PointRecord > errors = mapper . queryError ( assesmentId , experimentalClassId , classId ) ;
List < String > names = new ArrayList < String > ( ) ;
List < Integer > datas = new ArrayList < Integer > ( ) ;
List < PointRecord > errors = mapper . queryError ( assesmentId , experimentalClassId , classId ) ;
List < String > names = new ArrayList < String > ( ) ;
List < Integer > datas = new ArrayList < Integer > ( ) ;
for ( int i = 0 ; i < errors . size ( ) ; i + + ) {
PointRecord pointRecord = errors . get ( i ) ;
PointRecord pointRecord = errors . get ( i ) ;
names . add ( pointRecord . getJudgmentPointsName ( ) ) ;
datas . add ( pointRecord . getNumber ( ) ) ;
}
obj . add ( names ) ;
obj . add ( datas ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retvalue" , obj ) ;
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
logger . error ( e . getMessage ( ) ) ;
@ -567,12 +575,13 @@ public class AssesmentService {
/ * *
* 成绩明细
*
* @param assesmentId
* @param experimentalClassId
* @param classId
* @return
* /
public HashMap < String , Object > queryAssesmentScore ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
public HashMap < String , Object > queryAssesmentScore ( Integer assesmentId , Integer experimentalClassId , List < Integer > classId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
resp . put ( "retvalue" , mapper . queryScore3 ( assesmentId , experimentalClassId , classId ) ) ;