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