工具类:读excel 入到库里面(1)

@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);
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值