在 com.project.emos.wx.service 包中,创建 CheckinService 接口
public interface CheckinService {/*** 检测当天是否可以签到* @param userId* @param date* @return*/public String validCanCheckIn(int userId, String date);}
在 com.project.emos.wx.service.impl 包中,创建 CheckinServiceImpl 实现类。
/*** @author JianqingWeng* @Description* @create 2021-06-19 16:35*/@Service@Scope("prototype")@Slf4jpublic class CheckinServiceImpl implements CheckinService {@Autowiredprivate SystemConstants systemConstants;@Autowiredprivate TbHolidaysDao holidaysDao;@Autowiredprivate TbWorkdayDao workdayDao;@Autowiredprivate TbCheckinDao checkinDao;@Overridepublic String validCanCheckIn(int userId, String date) {boolean bool_1 = holidaysDao.searchTodayIsHolidays() != null ? true : false;boolean bool_2 = workdayDao.searchTodayIsWorkday() != null ? true : false;String type = "工作日";if (DateUtil.date().isWeekend()) {type = "节假日";}if (bool_1) {type = "节假日";} else if (bool_2) {type = "工作日";}if (type.equals("节假日")) {return "节假日不需要考勤";}DateTime now = DateUtil.date();String start = DateUtil.today() + " "+ systemConstants.attendanceStartTime;String end = DateUtil.today() + " "+ systemConstants.attendanceEndTime;DateTime attendanceStart = DateUtil.parse(start);DateTime attendanceEnd = DateUtil.parse(end);if (now.isBefore(attendanceStart)) {return "没有到上班考勤开始时间";}if (now.isAfter(attendanceEnd)) {return "超过了上班考勤结束时间";}// 执行到这里才真正的要打卡HashMap map = new HashMap();map.put("userId", userId);map.put("date", date);map.put("start", start);map.put("end", end);boolean bool = checkinDao.haveCheckin(map) != null ? true : false;return bool ? "今日已经考勤,不用重复考勤" : "可以考勤";}}
