@Override
public Result adminStudentLesson(JSONObject jsonObject) {
EduStudentRecord studentRecord = JSONObject.parseObject(jsonObject.toJSONString(), EduStudentRecord.class);
EduClazzPlan clazzPlan = JSONObject.parseObject(jsonObject.toJSONString(), EduClazzPlan.class);
Integer status = jsonObject.getInteger("lessonStatus");
clazzPlan.setStatus(status);
String mobile = jsonObject.getString("mobile");
Integer fromDate = jsonObject.getInteger("fromDate");
Integer toDate = jsonObject.getInteger("toDate");
PageHelper.startPage(studentRecord.getPage(), studentRecord.getPage_size());
ArrayList<HashMap<String, Object>> lessonList = studentRecordDao.adminSelectStudentLesson(mobile, studentRecord, clazzPlan, fromDate, toDate);
Set<String> lessonArrangeCodeList = lessonList.stream().map(hashMap -> (String) hashMap.get("lessonArrangeCode")).collect(Collectors.toSet());
//查询学生/教师 申请信息,后台备注显示
List<EduTeacherApply> teacherApplies = null;
Set<Integer> teaIdList = lessonList.stream().filter(map -> map.get("lessonStatus").equals(4))
.map(hashMap -> (Integer) hashMap.get("userTeacherId")).collect(Collectors.toSet());
if (teaIdList.size() > 0) teacherApplies = teacherApplyDao.getTeaApplyByIds(teaIdList, lessonArrangeCodeList);
Set<Integer> stuIdList = lessonList.stream().filter(map -> null != map.get("studentLessonStatus"))
.filter(map -> map.get("studentLessonStatus").equals(3) || map.get("studentLessonStatus").equals(4)
|| map.get("studentLessonStatus").equals(5))
.map(hashMap -> (Integer) hashMap.get("studentId")).collect(Collectors.toSet());
List<EduStudentApply> studentApplies = null;
if (stuIdList.size() > 0){
Example stuApplyExample = new Example(EduStudentApply.class).selectProperties("studentId","lessonArrangeCode","applyReason");
stuApplyExample.and().andEqualTo("applyType", 4)
.andIn("studentId", stuIdList).andIn("lessonArrangeCode", lessonArrangeCodeList);
studentApplies = studentApplyDao.selectByExample(stuApplyExample);
}
for (HashMap<String, Object> next : lessonList) {
String lessonArrangeCode = (String) next.get("lessonArrangeCode");
String stopLessonArrangeCode = (String) next.get("abnormalLessonArrangeCode");
Integer startDate = (Integer) next.get("startDate");
Integer clazzStudentStatus = (Integer) next.get("clazzStudentStatus");
Integer studentLessonStatus = (Integer) next.get("studentLessonStatus");
Integer lessonStatus = (Integer) next.get("lessonStatus");
Integer studentId = (Integer) next.get("studentId");
Integer userTeacherId = (Integer) next.get("userTeacherId");
String clazzCode = (String) next.get("clazzCode");
Object stopReason = next.get("stopReason");
// 1=已签到,2=缺勤,3=请假中,4=请假中待确认,5=已请假,6=已补课,
// 7:未开始,8:未签到,9:已结束,11:已停课,12:已暂停,13:已转出
if (null == studentLessonStatus) {
if (lessonStatus == 1){
next.put("studentLessonStatus", 7);
}else if (lessonStatus == 2){
next.put("studentLessonStatus", 8);
}
}else {
if (studentLessonStatus == 1 && lessonStatus == 3){
next.put("studentLessonStatus", 9);
}else if (studentLessonStatus == 3 || studentLessonStatus == 4 || studentLessonStatus == 5){
for (EduStudentApply studentApply : studentApplies) {
if (studentId.equals(studentApply.getStudentId()) && lessonArrangeCode.equals(studentApply.getLessonArrangeCode())){
next.put("remark", studentApply.getApplyReason()); // 备注学生请假理由
}
}
}
}
if (lessonStatus == 4) next.put("studentLessonStatus", 12);
if (null != stopReason && !"".equals(stopReason)) next.put("remark", stopReason);
int compare = -2;
if (null != stopLessonArrangeCode && !"".equals(stopLessonArrangeCode)) {
compare = lessonArrangeCode.compareTo(stopLessonArrangeCode);
}
if (compare >= 0) {
if (2 == clazzStudentStatus) { // 已停课
next.put("studentLessonStatus", 11);
}else if (3 == clazzStudentStatus){ // 已转班
next.put("studentLessonStatus", 13);
}
}
if (null != teacherApplies && teacherApplies.size() > 0) {
for (EduTeacherApply teacherApply : teacherApplies) {
if (clazzCode.equals(teacherApply.getClazzCode()) && lessonArrangeCode.equals(teacherApply.getLessonArrangeCode())
&& startDate.equals(teacherApply.getStartDate()) && userTeacherId.equals(teacherApply.getUserTeacherId())) {
next.put("remark", teacherApply.getApplyReason()); //备注教师请假理由
}
}
}
}
PageInfo<HashMap<String, Object>> pageInfo = new PageInfo<>(lessonList);
HashMap<Object, Object> map = new HashMap<>();
map.put("totalCount", pageInfo.getTotal());
map.put("totalPageCount", pageInfo.getPages());
map.put("info", lessonList);
return Result.success(map);
}