派生自 projectDept/qhighschool

EricsHu
2022-12-05 068fc7f2e81178e55fa191a13709af64b1a163f6
src/main/java/com/qxueyou/scc/admin/attendance/impl/AttendanceServiceImpl.java
@@ -1,9 +1,12 @@
package com.qxueyou.scc.admin.attendance.impl;
import com.qxueyou.scc.admin.attendance.AttendanceService;
import com.qxueyou.scc.base.model.Pager;
import com.qxueyou.scc.base.model.Result;
import com.qxueyou.scc.base.service.ICommonService;
import com.qxueyou.scc.base.service.impl.CommonAppService;
import com.qxueyou.scc.base.util.CollectionUtils;
import com.qxueyou.scc.base.util.TraceUtils;
import com.qxueyou.scc.teach.student.model.StuStudent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -19,48 +22,40 @@
    @Override
    public String attendanceUpAndAdd(String studentId, String subjectId) {
        String s="";
        StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
        List<Object> args = CollectionUtils.newList(studentId);
        StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
        try{
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            //上课时间
            String s1 = "9:00:00";
            //如果上课时间(9点)>当前时间
            //上课时间
            String s1 = "9:00:00";
            //如果上课时间(9点)>当前时间
            String s2 = sdf.format(new Date());
            int compareTo = s1.compareTo(s2);
            if(compareTo>0)
            {
                s="签到时间已过,本节课按照旷课处理";
                StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
                List<Object> args = CollectionUtils.newList(studentId);
                StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
                if(stuStudent!=null && subjectId!=null){
                    stuStudent.setSubjectId(subjectId);
                    save(stuStudent);
                    s = "成功完成签到";
                }
                s="签到时间已过,本节课按照旷课处理";
                stuStudent.setAttendanceStatus("旷课");
            }
            else
            {
                String s3 = "8:50:00";
                String s3 = "8:50:00";
                compareTo = s2.compareTo(s3);
                if(compareTo<0)
                {
                    s="未到签到时间,请与上课时间前10分钟签到";
                    s="未到签到时间,请与上课时间前10分钟签到";
                    stuStudent.setAttendanceStatus("未打卡");
                }
                else
                {
                    StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
                    List<Object> args = CollectionUtils.newList(studentId);
                    StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
                    if(stuStudent!=null && subjectId!=null){
                        stuStudent.setSubjectId(subjectId);
                        save(stuStudent);
                        return "成功完成签到";
                        stuStudent.setAttendanceStatus("已打卡");
                        s = "成功完成签到";
                    }
                }
            }
@@ -69,6 +64,46 @@
        {
            e.printStackTrace();
        }
        save(stuStudent);
        return s;
    }
    @Override
    public List<StuStudent> findAttendanceList(Integer limit, Integer pageNum, String keyword, String subjectId) {
        StringBuffer hql=new StringBuffer("from StuStudent where name like ? and subjectId = ? and deleteFlag is false");
        List<Object> args = CollectionUtils.newList(keyword + "%",subjectId);
        hql.append(" order by createTime desc");
        List<StuStudent> list = findList(hql.toString(), new Pager(limit, pageNum), args, StuStudent.class);
        return list;
    }
    @Override
    public Result updateAttendanceStatus(String studentId, String attendanceStatus) {
        StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false");
        List<Object> args = CollectionUtils.newList(studentId);
        StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class);
        if(stuStudent!=null && attendanceStatus!=null){
            stuStudent.setAttendanceStatus(attendanceStatus);
            save(stuStudent);
            return new Result(true);
        }
        return new Result(false);
    }
    @Override
    public int findAttendanceListCount(String keyword, String subjectId) {
        StringBuffer hql=new StringBuffer("from StuStudent where name like ? and subjectId = ? and deleteFlag is false");
        List<Object> args = CollectionUtils.newList(keyword + "%",subjectId);
        return findCount(hql.toString(),args);
    }
}