@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController ;
import java.math.BigDecimal ;
import java.math.RoundingMode ;
import java.util.* ;
/ * *
@ -45,7 +46,7 @@ public class StuIndexController {
@Autowired
private TeaExamManageMapper teaExamManageMapper ;
@Autowired
private SysResourceDataMapper sysResourceData Mapper;
private TeaResourceCenterMapper teaResourceCenter Mapper;
@Autowired
private StuIndexService stuIndexService ;
@Autowired
@ -112,23 +113,12 @@ public class StuIndexController {
@PostMapping ( "getIndexResourceCenter" )
public ResultEntity < Map < String , Integer > > getIndexResourceCenter ( @RequestParam String schoolId ) {
Map < String , Integer > map = new HashMap < > ( ) ;
SysResourceDataExample example = new SysResourceDataExample ( ) ;
List < String > idlist = new ArrayList < > ( ) ;
idlist . add ( schoolId ) ;
idlist . add ( Constant . BUILT_IN_SCHOOL_ID ) ;
example . createCriteria ( ) . andSchoolIdIn ( idlist ) ;
List < SysResourceData > sysResourceData = sysResourceDataMapper . selectByExample ( example ) ;
int size = sysResourceData . size ( ) ;
map . put ( "资源总量" , size ) ;
int videoNum = 0 ;
for ( SysResourceData sysResourceDatum : sysResourceData ) {
String resourceName = sysResourceDatum . getResourceName ( ) ;
if ( resourceName . toUpperCase ( ) . contains ( ".MP4" ) | | resourceName . toUpperCase ( ) . contains ( ".AVI" ) | | resourceName . toUpperCase ( ) . contains ( ".WMV" ) ) {
videoNum + + ;
}
}
map . put ( "视频数量" , videoNum ) ;
map . put ( "课件数量" , size - videoNum ) ;
List < Integer > list = teaResourceCenterMapper . getSizeByType ( schoolId ) ;
Integer key = list . get ( 0 ) ;
Integer value = list . get ( 1 ) ;
map . put ( "视频数量" , key ) ;
map . put ( "课件数量" , value ) ;
map . put ( "资源总量" , key + value ) ;
return new ResultEntity < > ( map ) ;
}
@ -244,11 +234,11 @@ public class StuIndexController {
public ResultEntity < AllModuleProgressDto > getAllModuleProgress ( @RequestParam String userId , @RequestParam String schoolId ) {
AllModuleProgressDto allModuleProgressDto = new AllModuleProgressDto ( ) ;
//实训演练完成进度 = 已完成模块数量/总模块数量
int progressFinishNum = stuTrainingMapper . selectProgressFinish ( userId ) ; //已学任务数量
BigDecimal progressFinishNum = stuTrainingMapper . selectProgressFinish ( userId ) ; //已学任务数量
int totalChapterNum = sysCourseChapterMapper . selectChapterBySchoolId ( schoolId ) ; //总章节数量
if ( progressFinishNum ! = 0 & & totalChapterNum ! = 0 ) {
double finalProgress = ( double ) progressFinishNum / totalChapterNum ; //任务进度 = 已学数量/总章节数量
BigDecimal totalChapterNum = sysCourseChapterMapper . selectChapterBySchoolId ( schoolId ) ; //总章节数量
if ( ( progressFinishNum ! = null & & progressFinishNum . intValue ( ) ! = 0 ) & & ( totalChapterNum ! = null & & totalChapterNum . intValue ( ) ! = 0 ) ) {
BigDecimal finalProgress = progressFinishNum . divide ( totalChapterNum , 2 , RoundingMode . HALF_UP ) . multiply ( BigDecimal . valueOf ( 100 ) ) ; //任务进度 = 已学数量/总章节数量
allModuleProgressDto . setTrainingProgress ( finalProgress ) ;
}