|
|
@@ -4,12 +4,14 @@ import com.njuzr.eaibackend.exception.MyException;
|
|
|
import com.njuzr.eaibackend.mapper.BehaviorOverviewMapper;
|
|
|
import com.njuzr.eaibackend.mapper.AssignmentMapper;
|
|
|
import com.njuzr.eaibackend.mapper.ClassMapper;
|
|
|
+import com.njuzr.eaibackend.mapper.WindowSwitchRecordMapper;
|
|
|
import com.njuzr.eaibackend.po.BehaviorOverview;
|
|
|
import com.njuzr.eaibackend.po.Assignment;
|
|
|
import com.njuzr.eaibackend.po.Class;
|
|
|
import com.njuzr.eaibackend.service.ClassService;
|
|
|
import com.njuzr.eaibackend.vo.BehaviorOverviewVO;
|
|
|
import com.njuzr.eaibackend.vo.StudentInfoVO;
|
|
|
+import com.njuzr.eaibackend.vo.WindowSwitchSummaryVO;
|
|
|
import com.njuzr.eaibackend.utils.ZipExport;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.Set;
|
|
|
@@ -41,15 +43,17 @@ public class ExportBehaviorOverviewService {
|
|
|
private final ClassService classService;
|
|
|
private final AssignmentMapper assignmentMapper;
|
|
|
private final ClassMapper classMapper;
|
|
|
+ private final WindowSwitchRecordMapper windowSwitchRecordMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- public ExportBehaviorOverviewService(BehaviorOverviewService behaviorOverviewService, BehaviorOverviewMapper behaviorOverviewMapper, UserService userService, ClassService classService, AssignmentMapper assignmentMapper, ClassMapper classMapper) {
|
|
|
+ public ExportBehaviorOverviewService(BehaviorOverviewService behaviorOverviewService, BehaviorOverviewMapper behaviorOverviewMapper, UserService userService, ClassService classService, AssignmentMapper assignmentMapper, ClassMapper classMapper, WindowSwitchRecordMapper windowSwitchRecordMapper) {
|
|
|
this.behaviorOverviewService = behaviorOverviewService;
|
|
|
this.behaviorOverviewMapper = behaviorOverviewMapper;
|
|
|
this.userService = userService;
|
|
|
this.classService = classService;
|
|
|
this.assignmentMapper = assignmentMapper;
|
|
|
this.classMapper = classMapper;
|
|
|
+ this.windowSwitchRecordMapper = windowSwitchRecordMapper;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -147,7 +151,7 @@ public class ExportBehaviorOverviewService {
|
|
|
int rowIdx = 0;
|
|
|
Row header = summary.createRow(rowIdx++);
|
|
|
String[] headers = new String[]{
|
|
|
- "name", "studentId", "assignmentId", "insertCount", "deleteCount", "copyCount", "copyCharacterCount", "longPauseCount"
|
|
|
+ "name", "studentId", "assignmentId", "insertCount", "deleteCount", "copyCount", "copyCharacterCount", "longPauseCount", "windowSwitchCount"
|
|
|
};
|
|
|
for (int i = 0; i < headers.length; i++) {
|
|
|
header.createCell(i).setCellValue(headers[i]);
|
|
|
@@ -167,6 +171,8 @@ public class ExportBehaviorOverviewService {
|
|
|
Long studentId = student.getStudentId();
|
|
|
if (studentId == null) continue;
|
|
|
|
|
|
+ long windowSwitchCount = getWindowSwitchCount(studentId, assignmentId);
|
|
|
+
|
|
|
// 查询该学生在指定作业的行为概览
|
|
|
BehaviorOverviewVO vo = behaviorOverviewService.getBehaviorOverview(studentId, assignmentId);
|
|
|
if (vo != null) {
|
|
|
@@ -180,7 +186,8 @@ public class ExportBehaviorOverviewService {
|
|
|
row.createCell(col++).setCellValue(vo.getDeleteCount() == null ? 0 : vo.getDeleteCount());
|
|
|
row.createCell(col++).setCellValue(vo.getCopyCount() == null ? 0 : vo.getCopyCount());
|
|
|
row.createCell(col++).setCellValue(vo.getCopyCharacterCount() == null ? 0 : vo.getCopyCharacterCount());
|
|
|
- row.createCell(col).setCellValue(vo.getLongPauseCount() == null ? 0 : vo.getLongPauseCount());
|
|
|
+ row.createCell(col++).setCellValue(vo.getLongPauseCount() == null ? 0 : vo.getLongPauseCount());
|
|
|
+ row.createCell(col).setCellValue(windowSwitchCount);
|
|
|
|
|
|
// 为每个学生创建一个事件明细sheet
|
|
|
String sheetName = safeSheetName(name != null ? name : "Unknown");
|
|
|
@@ -198,7 +205,8 @@ public class ExportBehaviorOverviewService {
|
|
|
row.createCell(col++).setCellValue(0);
|
|
|
row.createCell(col++).setCellValue(0);
|
|
|
row.createCell(col++).setCellValue(0);
|
|
|
- row.createCell(col).setCellValue(0);
|
|
|
+ row.createCell(col++).setCellValue(0);
|
|
|
+ row.createCell(col).setCellValue(windowSwitchCount);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -326,13 +334,15 @@ public class ExportBehaviorOverviewService {
|
|
|
int rowIdx = 0;
|
|
|
Row header = sheet.createRow(rowIdx++);
|
|
|
String[] headers = new String[]{
|
|
|
- "studentId", "assignmentId", "insertCount", "deleteCount", "copyCount", "copyCharacterCount", "longPauseCount"
|
|
|
+ "studentId", "assignmentId", "insertCount", "deleteCount", "copyCount", "copyCharacterCount", "longPauseCount", "windowSwitchCount"
|
|
|
};
|
|
|
for (int i = 0; i < headers.length; i++) {
|
|
|
Cell cell = header.createCell(i);
|
|
|
cell.setCellValue(headers[i]);
|
|
|
}
|
|
|
|
|
|
+ long windowSwitchCount = getWindowSwitchCount(overview.getStudentId(), overview.getAssignmentId());
|
|
|
+
|
|
|
Row row = sheet.createRow(rowIdx);
|
|
|
int col = 0;
|
|
|
row.createCell(col++).setCellValue(overview.getStudentId() == null ? 0 : overview.getStudentId());
|
|
|
@@ -341,7 +351,8 @@ public class ExportBehaviorOverviewService {
|
|
|
row.createCell(col++).setCellValue(overview.getDeleteCount() == null ? 0 : overview.getDeleteCount());
|
|
|
row.createCell(col++).setCellValue(overview.getCopyCount() == null ? 0 : overview.getCopyCount());
|
|
|
row.createCell(col++).setCellValue(overview.getCopyCharacterCount() == null ? 0 : overview.getCopyCharacterCount());
|
|
|
- row.createCell(col).setCellValue(overview.getLongPauseCount() == null ? 0 : overview.getLongPauseCount());
|
|
|
+ row.createCell(col++).setCellValue(overview.getLongPauseCount() == null ? 0 : overview.getLongPauseCount());
|
|
|
+ row.createCell(col).setCellValue(windowSwitchCount);
|
|
|
|
|
|
for (int i = 0; i < headers.length; i++) {
|
|
|
sheet.autoSizeColumn(i);
|
|
|
@@ -408,5 +419,23 @@ public class ExportBehaviorOverviewService {
|
|
|
return v == null ? 0 : v;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询某学生某作业的窗口切换总次数,若无记录则返回 0
|
|
|
+ */
|
|
|
+ private long getWindowSwitchCount(Long studentId, Long assignmentId) {
|
|
|
+ if (studentId == null || assignmentId == null) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ WindowSwitchSummaryVO summary = windowSwitchRecordMapper
|
|
|
+ .selectSummaryByStudentAndAssignment(studentId, assignmentId);
|
|
|
+ return summary != null && summary.getTotalSwitchCount() != null
|
|
|
+ ? summary.getTotalSwitchCount()
|
|
|
+ : 0L;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 已改为批量映射方式,不再需要单查姓名方法
|
|
|
}
|