@ -5,6 +5,9 @@ import cn.teammodel.common.PK;
import cn.teammodel.config.exception.ServiceException ;
import cn.teammodel.controller.admin.service.AdminIndexDutyService ;
import cn.teammodel.model.dto.admin.appraise.TimeRangeDto ;
import cn.teammodel.model.dto.admin.common.GroupDto ;
import cn.teammodel.model.dto.admin.common.RGroupList ;
import cn.teammodel.model.dto.admin.common.RMember ;
import cn.teammodel.model.dto.admin.teacher.TeacherDto ;
import cn.teammodel.model.dto.weekDuty.LessonRecordDto ;
import cn.teammodel.model.entity.User ;
@ -22,6 +25,8 @@ import cn.teammodel.security.utils.SecurityUtil;
import cn.teammodel.test.LessonRecordQueryService ;
import cn.teammodel.utils.GroupUtil ;
import cn.teammodel.utils.SchoolDateUtil ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.TypeReference ;
import com.azure.spring.data.cosmos.core.query.CosmosPageRequest ;
import lombok.extern.slf4j.Slf4j ;
import org.apache.commons.lang3.ObjectUtils ;
@ -65,6 +70,8 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
private Environment env ;
@Resource
private LessonRecordRepository lessonRecordRepository ;
@Resource
private StudentRepository studentRepository ;
/ * @Autowired
public AdminIndexDutyServiceImpl ( Environment env ) {
@ -267,8 +274,44 @@ public class AdminIndexDutyServiceImpl implements AdminIndexDutyService {
Set < String > classIds = records . stream ( ) . filter ( lessonRecord - > lessonRecord . getTmdid ( ) . equalsIgnoreCase ( teacherDto . getTmdId ( ) ) )
. flatMap ( record - > record . getGroupIds ( ) . stream ( ) )
. collect ( Collectors . toSet ( ) ) ;
GroupDto groupDto = new GroupDto ( ) ;
groupDto . setIds ( new ArrayList < > ( classIds ) ) ;
groupDto . setSchoolId ( teacherDto . getCode ( ) ) ;
String url = env . getProperty ( "ies.server-url-group" ) ;
//List<ClassInfo> classes = classRepository.findAllByCodeAndIdIn("Class-"+artFindDto.getCode(),classIds);
Map < String , Object > groupId = GroupUtil . getGroupId ( groupDto , new GroupUtil ( env ) , request , url ) ;
List < RGroupList > rGroupList = new ArrayList < > ( ) ;
List < RMember > rMembers = new ArrayList < > ( ) ;
for ( Map . Entry < String , Object > entry : groupId . entrySet ( ) ) {
String key = entry . getKey ( ) ;
Object value = entry . getValue ( ) ;
if ( key . equals ( "groups" ) ) {
String jsonGroups = JSON . toJSONString ( value ) ;
rGroupList = JSON . parseObject ( jsonGroups , new TypeReference < List < RGroupList > > ( ) { } ) ;
}
if ( key . equals ( "members" ) ) {
String jsonGroups = JSON . toJSONString ( value ) ;
rMembers = JSON . parseObject ( jsonGroups , new TypeReference < List < RMember > > ( ) { } ) ;
}
}
for ( String classId : classIds ) {
Map < String , Object > mapper = new HashMap < > ( ) ;
// 班级内学生总数
//int stuInClassCount = studentRepository.countByClassIdAndCode(classId, String.format(PK.STUDENT, teacherDto.getCode()));
int stuInClassCount = 0 ;
String className = "" ;
for ( RGroupList rGroup : rGroupList ) {
if ( rGroup . getId ( ) . equals ( classId ) ) {
List < RMember > members = rGroup . getMembers ( ) ;
stuInClassCount = members . size ( ) ;
className = rGroup . getName ( ) ;
}
}
mapper . put ( "stuInClassCount" , stuInClassCount ) ;
mapper . put ( "className" , className ) ;
// 计算本学期互动总数
int totalClientInteractionCount = records . stream ( ) . filter ( lessonRecord - >
lessonRecord . getGroupIds ( ) . contains ( classId ) )