package com.qxueyou.scc.admin.attendance.impl; import com.qxueyou.scc.admin.attendance.AttendanceService; import com.qxueyou.scc.base.service.impl.CommonAppService; import com.qxueyou.scc.base.util.CollectionUtils; import com.qxueyou.scc.teach.student.model.StuStudent; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @Service public class AttendanceServiceImpl extends CommonAppService implements AttendanceService { @Override public String attendanceUpAndAdd(String studentId, String subjectId) { String s=""; try{ SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); //ÉÏ¿Îʱ¼ä 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 args = CollectionUtils.newList(studentId); StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class); if(stuStudent!=null && subjectId!=null){ stuStudent.setSubjectId(subjectId); save(stuStudent); s = "³É¹¦Íê³ÉÇ©µ½"; } } else { String s3 = "8£º50:00"; compareTo = s2.compareTo(s3); if(compareTo<0) { s="δµ½Ç©µ½Ê±¼ä£¬ÇëÓëÉÏ¿Îʱ¼äǰ10·ÖÖÓÇ©µ½"; } else { StringBuffer hql=new StringBuffer("from StuStudent where studentId=? and deleteFlag is false"); List args = CollectionUtils.newList(studentId); StuStudent stuStudent = findUnique(hql.toString(), args, StuStudent.class); if(stuStudent!=null && subjectId!=null){ stuStudent.setSubjectId(subjectId); save(stuStudent); return "³É¹¦Íê³ÉÇ©µ½"; } } } } catch (Exception e) { e.printStackTrace(); } return s; } }