|
@@ -26,6 +26,7 @@ import org.brynhild.graduation.timetable.factory.SpecificationFactory
|
|
|
import org.brynhild.graduation.timetable.service.ITimeTableService
|
|
|
import org.brynhild.graduation.transfer.file.dto.FileInfo
|
|
|
import org.brynhild.graduation.transfer.timetable.bo.ClassStatisticInfo
|
|
|
+import org.brynhild.graduation.transfer.timetable.bo.CourseStatisticInfo
|
|
|
import org.brynhild.graduation.transfer.timetable.bo.StudentStatisticInfo
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.AdminAddTimeTable
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.AdminDeleteTimeTable
|
|
@@ -33,6 +34,7 @@ import org.brynhild.graduation.transfer.timetable.vo.AdminModifyTimeTable
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.AdminQueryClassStatistic
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.AdminQueryStudentStatistic
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingClassRequest
|
|
|
+import org.brynhild.graduation.transfer.timetable.vo.QueryTeachingCourseStatisticRequest
|
|
|
import org.brynhild.graduation.transfer.timetable.vo.QueryTimeTableRequest
|
|
|
import org.brynhild.graduation.transfer.view.ViewConvertor
|
|
|
import org.springframework.beans.factory.annotation.Autowired
|
|
@@ -307,6 +309,83 @@ class TimeTableServiceImpl implements ITimeTableService {
|
|
|
return new Result(true,"查询成功",classes)
|
|
|
}
|
|
|
|
|
|
+ private List<CourseStatisticInfo> getTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request){
|
|
|
+ def timeTableByClass = tableRepository.findTimeTableByTeacher(request.id)
|
|
|
+ def courseMap=new HashMap<Long, Course>()
|
|
|
+ def countMap=new HashMap<Long,Long>()
|
|
|
+ def actualCountMap=new HashMap<Long,Long>()
|
|
|
+
|
|
|
+ def courseIdSet = timeTableByClass.stream().map { it.courseId }.collect(Collectors.toSet())
|
|
|
+ for(courseId in courseIdSet){
|
|
|
+ courseRepository.findById(courseId).ifPresent {courseMap.put(courseId,it)}
|
|
|
+ }
|
|
|
+ timeTableByClass.stream().forEach {
|
|
|
+ countMap.computeIfAbsent(it.courseId,i->0L)
|
|
|
+ countMap.put(it.courseId,countMap.get(it.courseId)+1)
|
|
|
+ }
|
|
|
+ List<CourseStatisticInfo> infoList=new ArrayList<>()
|
|
|
+
|
|
|
+ for(timetable in timeTableByClass){
|
|
|
+ def startSignInTime=timetable.getStartSignInTime()
|
|
|
+ def endSignInTime = timetable.getEndSignInTime()
|
|
|
+
|
|
|
+ def startSignOutTime=timetable.getStartSignOutTime()
|
|
|
+ def endSignOutTime=timetable.getEndSignOutTime()
|
|
|
+
|
|
|
+ println "${startSignInTime}----${endSignInTime}"
|
|
|
+ println "${startSignOutTime}----${endSignOutTime}"
|
|
|
+
|
|
|
+ def listOfRecords = signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(startSignInTime, endSignInTime, timetable.areaId)
|
|
|
+ def signIn = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
|
|
|
+ listOfRecords=signInRecordRepository.findSignInRecordByTimeBetweenAndAreaId(timetable.startSignOutTime,timetable.endSignOutTime,timetable.areaId)
|
|
|
+ def signOut = listOfRecords.stream().map { it.userId }.collect(Collectors.toSet())
|
|
|
+ signIn.retainAll(signOut)
|
|
|
+
|
|
|
+ actualCountMap.computeIfAbsent(timetable.courseId,i->0L)
|
|
|
+ actualCountMap.put(timetable.courseId,actualCountMap.get(timetable.courseId)+signIn.size())
|
|
|
+ }
|
|
|
+
|
|
|
+ for(course in courseMap.values()){
|
|
|
+ infoList.add(new CourseStatisticInfo(course,countMap.get(course.id),actualCountMap.getOrDefault(course.id,0L)))
|
|
|
+ }
|
|
|
+
|
|
|
+ infoList=infoList.sort()
|
|
|
+ return infoList
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ Result queryTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request) {
|
|
|
+ def optional = userRepository.findById(request.id)
|
|
|
+ if(optional.isEmpty()){
|
|
|
+ return new Result(false,"用户不存在")
|
|
|
+ }
|
|
|
+ return new Result(true,"查询成功",getTeachingCourseStatistic(request))
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ Result generateTeachingCourseStatistic(QueryTeachingCourseStatisticRequest request) {
|
|
|
+ def optional = userRepository.findById(request.id)
|
|
|
+ if(optional.isEmpty()){
|
|
|
+ return new Result(false,"用户不存在")
|
|
|
+ }
|
|
|
+ def user=optional.get()
|
|
|
+ def result=getTeachingCourseStatistic(request)
|
|
|
+ def filename="docOutput/teaching-class-${request.id}.docx"
|
|
|
+ def map=new HashMap<String,String>()
|
|
|
+ map.put("title","${user.name}教学课程")
|
|
|
+ WordExecutor.generateTeachingCourseStatisticReport(filename,result ,map)
|
|
|
+ def localFile=new LocalFile();
|
|
|
+ localFile.path="teaching-class-${request.id}.docx"
|
|
|
+ cosJavaRepository.addUploadFileTaskSync(new File(filename),localFile)
|
|
|
+
|
|
|
+ FileInfo fileInfo = new FileInfo();
|
|
|
+ fileInfo.setPath(config.getRedirectPath() + localFile.getPath());
|
|
|
+ def list=new ArrayList<FileInfo>()
|
|
|
+ list.add(fileInfo)
|
|
|
+
|
|
|
+ return new Result(true,"生成成功",list)
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
@Resource
|
|
|
void setConfig(CosConfig config) {
|