派生自 projectDept/qhighschool

yn147
2023-04-04 1808cd0769da0a746a93430ba1a3258856b92741
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.qxueyou.scc.admin.studentFiles.Impl;
 
import com.qxueyou.scc.admin.studentFiles.StudentFilesService;
import com.qxueyou.scc.base.model.Pager;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.service.impl.CommonAppService;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.teach.student.model.QStuStudent;
import com.qxueyou.scc.teach.student.model.StuStudent;
import com.qxueyou.scc.user.model.QUser;
import org.springframework.stereotype.Service;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
 
@Service
public class StudentFilesServiceImpl extends CommonAppService implements StudentFilesService {
    @Override
    public List<Map<String, Object>> getStudentLst(String classId, String keyword, Pager pager) {
        QUser qUser = QUser.user;
        QStuStudent qStuStudent = QStuStudent.stuStudent;
        return this.getQueryFactory()
                .select(qStuStudent.studentId, qStuStudent.name, qStuStudent.studentNo, qStuStudent.sex,
                        qStuStudent.mobilePhone, qStuStudent.status, qStuStudent.studyDuration, qStuStudent.tenantId, qStuStudent.score,qStuStudent.attendanceStatus, qStuStudent.graduationText,qStuStudent.comment,
                        qUser.imgPath)
                .from(qUser, qStuStudent)
                .where(qUser.deleteFlag.isFalse().and(qUser.userId.eq(qStuStudent.userId))
                        .and(qStuStudent.classId.eq(classId)).and(qStuStudent.name.like("%" + keyword + "%")).and(qStuStudent.deleteFlag.isFalse()))
                .limit(pager.getPageSize()).offset(pager.getOffset()).orderBy(qStuStudent.createTime.desc()).fetch().stream().map(tuple -> {
                    Map<String, Object> map = new HashMap<String, Object>();
                    map.put("studentId", tuple.get(qStuStudent.studentId));
                    map.put("name", tuple.get(qStuStudent.name));
                    map.put("studentNo", tuple.get(qStuStudent.studentNo));
                    map.put("studentNumber", tuple.get(qStuStudent.studentNo));
                    map.put("sex", tuple.get(qStuStudent.sex));
                    map.put("mobilePhone", tuple.get(qStuStudent.mobilePhone));
                    map.put("status", tuple.get(qStuStudent.status));
                    map.put("studyDuration", tuple.get(qStuStudent.studyDuration));
                    map.put("tenantId", tuple.get(qStuStudent.tenantId));
                    map.put("score", tuple.get(qStuStudent.score));
                    map.put("graduationText", tuple.get(qStuStudent.graduationText));
                    map.put("attendanceStatus", tuple.get(qStuStudent.attendanceStatus));
                    map.put("comment", tuple.get(qStuStudent.comment));
                    map.put("imgPath", tuple.get(qUser.imgPath));
                    return map;
                }).collect(Collectors.toList());
    }
    @Override
    public int getStudentsCount(String classId, String keyword) {
//        //TODO 判断是否为补考分组
//        ClsClass cls = clsService.read(classId);
//        String hql=null;
//        if(cls!=null && cls.getClassTypes()!=null && "1".equals(cls.getClassTypes())){
//            //TODO 补考分组需要另一种查询学员 stu.tenantId = class.classId
//             hql = "from StuStudent where tenantId=:classId and name like :keyword and deleteFlag is false";
//        }else {
        String    hql = "from StuStudent where classId=:classId and name like :keyword and deleteFlag is false";
//        }
        return findCountByComplexHql(hql, CollectionUtils.newObjectMap("classId", classId, "keyword", "%" + keyword + "%" ));
 
    }
 
    @Override
    public String studentCommentAddAndUp(String[] studentIds,String comment) {
        StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
 
        List<Object> args = CollectionUtils.newList(studentIds);
 
        StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
 
        stuStudent.setComment(comment);
 
        save(stuStudent);
        return "";
    }
}