@ -19,11 +19,12 @@ import com.yipin.liuwanr.helper.ExcelExportHelper;
import com.yipin.liuwanr.mapper.AssesmentMapper ;
import com.yipin.liuwanr.mapper.RecordMapper ;
import com.yipin.liuwanr.vo.PracticeRecordVo ;
import org.springframework.util.StringUtils ;
/ * *
* 练习记录
* @author 或然
*
* @author 或然
* /
@Service
public class PracticeService {
@ -40,27 +41,28 @@ public class PracticeService {
/ * *
* 练习记录 And 考核记录
*
* @param studentId
* @param projectPermissions
* @param pageNum
* @param pageSize
* @return
* /
public HashMap < String , Object > queryStudentByPage ( Integer studentId , Integer projectPermissions , Integer courseId , Integer pageNum , Integer pageSize ) {
public HashMap < String , Object > queryStudentByPage ( Integer studentId , Integer projectPermissions , Integer courseId , Integer pageNum , Integer pageSize ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
if ( studentId ! = null & & courseId ! = null & & projectPermissions ! = null ) {
if ( ! StringUtils . isEmpty ( courseId ) & & ! StringUtils . isEmpty ( studentId ) & & projectPermissions ! = null ) {
PageHelper . startPage ( pageNum , pageSize ) ;
List < Record > records = mapper . getByStudentId ( projectPermissions , courseId , studentId ) ;
PageInfo < Record > info = new PageInfo < Record > ( records ) ;
List < Record > records = mapper . getByStudentId ( projectPermissions , courseId , studentId ) ;
PageInfo < Record > info = new PageInfo < Record > ( records ) ;
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 , records , totalPages ) ) ;
resp . put ( "retvalue" , new PageResult ( total , records , totalPages ) ) ;
}
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {
@ -74,29 +76,33 @@ public class PracticeService {
/ * *
* 练习记录 and 考核记录导出
*
* @param response
* @param studentId : 学生id
* @param projectPermissions : 权限 ( 练习 、 考核 )
* @param titles ( 标题 )
* @return
* /
public HashMap < String , Object > exportPractice ( HttpServletResponse response , Integer studentId , Integer projectPermissions , Integer courseId , String [ ] titles ) {
String fileName = null ;
String sheetName = null ;
public HashMap < String , Object > exportPractice ( HttpServletResponse response , Integer studentId , Integer projectPermissions , Integer courseId , String [ ] titles ) {
String fileName = null ;
String sheetName = null ;
List < Record > records = null ;
try {
List < Record > records = mapper . getByStudentId ( projectPermissions , courseId , studentId ) ;
if ( records . size ( ) > 0 & & ! records . isEmpty ( ) ) {
if ( projectPermissions = = 0 ) {
if ( ! StringUtils . isEmpty ( courseId ) & & ! StringUtils . isEmpty ( studentId ) ) {
records = mapper . getByStudentId ( projectPermissions , courseId , studentId ) ;
}
if ( records . size ( ) > 0 & & ! records . isEmpty ( ) ) {
if ( projectPermissions = = 0 ) {
fileName = "练习记录.xls" ;
sheetName = "练习记录" ;
} else if ( projectPermissions = = 1 ) {
} else if ( projectPermissions = = 1 ) {
fileName = "考核记录.xls" ;
sheetName = "考核记录" ;
}
HSSFWorkbook bos = ExcelExportHelper . exportPractice ( records , sheetName , titles ) ;
HSSFWorkbook bos = ExcelExportHelper . exportPractice ( records , sheetName , titles ) ;
response . setHeader ( "content-Type" , "application/vnd.ms-excel" ) ;
response . setHeader ( "Content-disposition" , "attachment;filename=" + URLEncoder . encode ( fileName , "UTF-8" ) ) ;
response . setHeader ( "Content-disposition" , "attachment;filename=" + URLEncoder . encode ( fileName , "UTF-8" ) ) ;
response . flushBuffer ( ) ;
bos . write ( response . getOutputStream ( ) ) ;
bos . close ( ) ;
@ -111,43 +117,44 @@ public class PracticeService {
/ * *
* 练习信息
*
* @param studentId
* @return
* /
public HashMap < String , Object > queryPracticeVo ( Integer studentId , Integer courseId ) {
public HashMap < String , Object > queryPracticeVo ( Integer studentId , Integer courseId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
if ( studentId ! = null & & courseId ! = null ) {
if ( ! StringUtils . isEmpty ( courseId ) & & ! StringUtils . isEmpty ( studentId ) ) {
// 学生个人的练习信息
PracticeRecordVo practiceVo = mapper . getByPracticeVO ( studentId , courseId ) ;
PracticeRecordVo practiceVo = mapper . getByPracticeVO ( studentId , courseId ) ;
// 练习项目数量
Integer practiceNumber = mapper . queryPracticeNumber ( courseId ) ;
if ( practiceNumber ! = null ) {
Integer practiceNumber = mapper . queryPracticeNumber ( courseId ) ;
if ( practiceNumber ! = null ) {
practiceVo . setPracticeNumber ( practiceNumber ) ;
// 求完成项目数量
Integer accomplishNumber = mapper . queryAccomplishNumber ( studentId , courseId ) ;
if ( accomplishNumber ! = null ) {
Integer accomplishNumber = mapper . queryAccomplishNumber ( studentId , courseId ) ;
if ( accomplishNumber ! = null ) {
practiceVo . setAccomplishNumber ( accomplishNumber ) ;
}
} else {
} else {
practiceVo . setPracticeNumber ( 0 ) ;
practiceVo . setAccomplishNumber ( 0 ) ;
}
// 练习总次数
Integer sumNumber = mapper . querySumNumber ( studentId , courseId ) ;
if ( sumNumber ! = null ) {
Integer sumNumber = mapper . querySumNumber ( studentId , courseId ) ;
if ( sumNumber ! = null ) {
practiceVo . setSumNumber ( sumNumber ) ;
} else {
} else {
practiceVo . setSumNumber ( 0 ) ;
}
PracticeRecordVo vo = mapper . queryCountry ( courseId ) ;
if ( vo ! = null ) {
PracticeRecordVo vo = mapper . queryCountry ( courseId ) ;
if ( vo ! = null ) {
//全国实训积分平均分
practiceVo . setAvgintegral ( vo . getAvgintegral ( ) ) ;
//全国最高实训积分
practiceVo . setHeightintegral ( vo . getHeightintegral ( ) ) ;
} else {
} else {
//全国实训积分平均分
practiceVo . setAvgintegral ( 0 ) ;
//全国最高实训积分
@ -166,11 +173,11 @@ public class PracticeService {
}
public HashMap < String , Object > queryAllExperiment ( Integer coure seId ) {
public HashMap < String , Object > queryAllExperiment ( Integer courseId ) {
HashMap < String , Object > resp = new HashMap < String , Object > ( ) ;
try {
if ( coureseId ! = null ) {
resp . put ( "retvalue" , assesment . queryGetByAssesmentProject ( coure seId ) ) ;
if ( ! StringUtils . isEmpty ( courseId ) ) {
resp . put ( "retvalue" , assesment . queryGetByAssesmentProject ( courseId ) ) ;
}
resp . put ( "retcode" , 200 ) ;
} catch ( Exception e ) {