| | |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | // /** |
| | | // * 新增 |
| | | // */ |
| | | // @PostMapping("/AppSave") |
| | | // @ApiOperationSupport(order = 4) |
| | | // @ApiOperation(value = "新增", notes = "传入attendance") |
| | | // public R AppSave(@Valid Attendance attendance) { |
| | | // System.out.println("attendance = " + attendance); |
| | | // Enclosure enclosure = new Enclosure(); |
| | | // enclosure.setAnumber(attendance.getNumber()); |
| | | // //查询当前处警人员的电子围栏信息 |
| | | // Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure); |
| | | // //判断是否在所在区域打卡,返回数据 |
| | | // if (onArea){ |
| | | // //查询当前考勤人员的部门信息 |
| | | // //获取打卡时间标准 |
| | | // R<List<DictBiz>> attendanceType = iDictBizService.getList("attendanceStandard"); |
| | | // List<DictBiz> dictBizList = attendanceType.getData(); |
| | | // //定义打卡时间标准,上午,下午 |
| | | // StringBuilder forenoon = new StringBuilder(); |
| | | // StringBuilder afternoon = new StringBuilder(); |
| | | // String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | // for (DictBiz dictBiz:dictBizList) { |
| | | // if (dictBiz.getDictValue().contains("上午")){ |
| | | // forenoon=forenoon.append(dictBiz.getDictKey()); |
| | | // } |
| | | // if (dictBiz.getDictValue().contains("下午")){ |
| | | // afternoon=afternoon.append(dictBiz.getDictKey()); |
| | | // } |
| | | // } |
| | | // //上午打卡时间标准 |
| | | // String forenoonWorkTime = format+" "+forenoon.toString().split("-")[0]+":00"; |
| | | // String forenoonOfDutyTime = format+" "+forenoon.toString().split("-")[1]+":00"; |
| | | // //下午打卡时间标准 |
| | | // String afternoonWorkTime = format+" "+afternoon.toString().split("-")[0]+":00"; |
| | | // String afternoonOfDutyTime = format+" "+afternoon.toString().split("-")[1]+":00"; |
| | | // //查询当前人员当天打卡信息 |
| | | // List<Attendance> attendanceList = attendanceService.selAttendanceListNow(attendance.getNumber()); |
| | | // //判断打卡时间 |
| | | // try { |
| | | // long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendance.getClocktime()).getTime(); |
| | | // //当天第一次打卡 |
| | | // if(attendanceList.size()==0){ |
| | | // //当天还没有打卡,即为当天第一个打卡 |
| | | // |
| | | // //判断打卡时间是上午还是下午 |
| | | // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | // //下午 |
| | | // //正常上班 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){ |
| | | // //正常上班 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("0"); |
| | | // } |
| | | // //迟到 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0 |
| | | // ){ |
| | | // //迟到上班 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("1"); |
| | | // } |
| | | // |
| | | // //正常下班 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | // && |
| | | // time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | // ){ |
| | | // //正常下班 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // } |
| | | // |
| | | // //加班 |
| | | // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | // //下午下班 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // } |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // }else { |
| | | // //上午 |
| | | // //正常上班 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0){ |
| | | // //正常上午上班 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("0"); |
| | | // } |
| | | // //迟到 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 |
| | | // && |
| | | // time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<=0 |
| | | // ){ |
| | | // //迟到上班 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("1"); |
| | | // } |
| | | // |
| | | // |
| | | // //正常下班 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>0 |
| | | // && |
| | | // time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | // ){ |
| | | // //正常下班 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // } |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // //打卡时间和上午上班时间 |
| | | // } |
| | | // //已经打过一次卡,当天第二次打卡 |
| | | // if(attendanceList.size()==1){ |
| | | // //判断第一次打卡的时间范围,上午还是下午 |
| | | // long time1 = 0; |
| | | // try { |
| | | // time1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendanceList.get(0).getClocktime()).getTime(); |
| | | // } catch (ParseException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // //上午下班时间的半个小时后 |
| | | // if (time1-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0) { |
| | | // //下午 |
| | | // //更新上班信息 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() <= 0) { |
| | | // //更新上班时间 |
| | | // //正常上班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setId(attendanceList.get(0).getId()); |
| | | // //更新考勤消息 |
| | | // return R.status(attendanceService.updateById(attendance)); |
| | | // } |
| | | // |
| | | // //早退 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0 |
| | | // && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0 |
| | | // ) { |
| | | // //早退 |
| | | // attendance.setAttendancetype("2"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤消息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // |
| | | // //正常下班 |
| | | // if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000) <= 0 |
| | | // && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() >= 0 |
| | | // ) { |
| | | // //新增下班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤消息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // |
| | | // //其他时间修改 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000>0){ |
| | | // //加班 |
| | | //// attendance.setAttendancetype("加班"); |
| | | // attendance.setId(attendanceList.get(0).getId()); |
| | | // //更新考勤消息 |
| | | // return R.status(attendanceService.updateById(attendance)); |
| | | // } |
| | | // |
| | | // |
| | | // }else { |
| | | // //上午 |
| | | // //更新 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() <= 0) { |
| | | // //更新上班时间 |
| | | // //正常上班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setId(attendanceList.get(0).getId()); |
| | | // //更新考勤消息 |
| | | // return R.status(attendanceService.updateById(attendance)); |
| | | // } |
| | | // //上午早退 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() > 0 |
| | | // && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() < 0 |
| | | // ) { |
| | | // //早退 |
| | | // attendance.setAttendancetype("2"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤消息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // //下午早退 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0 |
| | | // && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0 |
| | | // ) { |
| | | // //早退 |
| | | // attendance.setAttendancetype("2"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤消息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // |
| | | // //上午正常下班 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0 |
| | | // && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | // ){ |
| | | // //下班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤信息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // //下午正常下班 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0 |
| | | // && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | // ){ |
| | | // //下班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setClocktype("1"); |
| | | // //新增考勤信息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // |
| | | // //正常上班 |
| | | // if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | // && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0 |
| | | // ){ |
| | | // //上班 |
| | | // attendance.setAttendancetype("0"); |
| | | // attendance.setClocktype("0"); |
| | | // //新增考勤信息 |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // } |
| | | // } |
| | | // //第三次打卡 |
| | | // if (attendanceList.size()==2){ |
| | | // //第三次记录打卡如果时间范围在上午的在早退时间及下班后的半小时范围内,则更新上一次打卡记录 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 |
| | | // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<0 |
| | | // ){ |
| | | // Attendance attendance1 = attendanceList.get(1); |
| | | // attendance1.setClocktime(attendance.getClocktime()); |
| | | // //更新打卡信息 |
| | | // return R.status(attendanceService.updateById(attendance1)); |
| | | // } |
| | | // //第三次打卡记录时间返回在上午下班半小时后到下午上班 |
| | | // if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){ |
| | | // //新增正常打卡信息 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("0"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // //第三次打卡记录时间返回在下午上班到下午下班之前 |
| | | // if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | // //判断第二次是否已经打卡上班 |
| | | // if (attendanceList.get(1).getClocktype().equals("0")){ |
| | | // //修改打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("2"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // }else { |
| | | // //新增上班迟到打卡信息 |
| | | // attendance.setClocktype("0"); |
| | | // attendance.setAttendancetype("1"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // } |
| | | // //下午正常下班时间节点 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){ |
| | | // //新增下班正常打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // //其他时间修改 |
| | | // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | // //修改打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("2"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // } |
| | | // //第四次打卡 |
| | | // if (attendanceList.size()==3){ |
| | | // //第四次打卡记录时间返回在上午下班半小时后到下午上班 |
| | | // if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){ |
| | | // Attendance attendance2 = attendanceList.get(2); |
| | | // attendance2.setClocktime(attendance.getClocktime()); |
| | | // //更新正常打卡信息 |
| | | // return R.status(attendanceService.updateById(attendance2)); |
| | | // } |
| | | // //第四次打卡记录时间返回在下午上班到下午下班之前 |
| | | // if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | // //判断第二次是否是早退或者迟到 |
| | | // //迟到 |
| | | // if (attendanceList.get(2).getAttendancetype().equals("1")){ |
| | | // //新增下班早退打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("2"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // }else { |
| | | // //早退 |
| | | // //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态 |
| | | // Attendance attendance2 = attendanceList.get(2); |
| | | // attendance2.setClocktime(attendance.getClocktime()); |
| | | // return R.status(attendanceService.updateById(attendance2)); |
| | | // } |
| | | // } |
| | | // //下午正常下班时间节点 |
| | | // if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | // && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){ |
| | | // //如果上一次为早退,则只更新信息 |
| | | // if (attendanceList.get(2).getAttendancetype().equals("2")) { |
| | | // //修改打卡信息 |
| | | // Attendance attendance2 = attendanceList.get(2); |
| | | // attendance2.setClocktime(attendance.getClocktime()); |
| | | // return R.status(attendanceService.updateById(attendance2)); |
| | | // }else { |
| | | // //新增正常下班打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | // } |
| | | // //其他时间 |
| | | // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | // //修改打卡信息 |
| | | // Attendance attendance2 = attendanceList.get(2); |
| | | // attendance2.setClocktime(attendance.getClocktime()); |
| | | // return R.status(attendanceService.updateById(attendance2)); |
| | | // } |
| | | // } |
| | | // //第五次打卡 |
| | | // if (attendanceList.size()==4){ |
| | | // //只有在下午下班后可以有新增加班考勤数据,其他情况则是更新第四次的记录 |
| | | // //第五次打卡记录时间返回在下午上班到下午下班后的30分钟之前 |
| | | //// if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | //// && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | //// //早退 |
| | | //// //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态 |
| | | //// Attendance attendance3 = attendanceList.get(3); |
| | | //// attendance3.setClocktime(attendance.getClocktime()); |
| | | //// return R.status(attendanceService.updateById(attendance3)); |
| | | //// } |
| | | // Attendance attendance3 = attendanceList.get(3); |
| | | // attendance3.setClocktime(attendance.getClocktime()); |
| | | // return R.status(attendanceService.updateById(attendance3)); |
| | | // //下午正常下班30分钟后时间节点 |
| | | //// if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //// //如果上一次为早退,则只更新信息 |
| | | //// //新增正常下班打卡信息 |
| | | //// attendance.setClocktype("1"); |
| | | //// attendance.setAttendancetype("0"); |
| | | //// return R.status(attendanceService.save(attendance)); |
| | | //// } |
| | | // } |
| | | // } catch (ParseException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | // return R.status(false); |
| | | // } |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | |
| | | //查询当前处警人员的电子围栏信息 |
| | | Boolean onArea = iEnclosureService.isOnArea(attendance.getJd(),attendance.getWd(),enclosure); |
| | | //判断是否在所在区域打卡,返回数据 |
| | | if (onArea){ |
| | | if (onArea) { |
| | | //查询当前考勤人员的部门信息 |
| | | |
| | | //获取当前日期是礼拜几 |
| | | attendance.setWeek(new SimpleDateFormat("EEEE").format(new Date())); |
| | | //获取打卡时间标准 |
| | | R<List<DictBiz>> attendanceType = iDictBizService.getList("attendanceStandard"); |
| | | List<DictBiz> dictBizList = attendanceType.getData(); |
| | |
| | | StringBuilder forenoon = new StringBuilder(); |
| | | StringBuilder afternoon = new StringBuilder(); |
| | | String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | for (DictBiz dictBiz:dictBizList) { |
| | | if (dictBiz.getDictValue().contains("上午")){ |
| | | forenoon=forenoon.append(dictBiz.getDictKey()); |
| | | for (DictBiz dictBiz : dictBizList) { |
| | | if (dictBiz.getDictValue().contains("上午")) { |
| | | forenoon = forenoon.append(dictBiz.getDictKey()); |
| | | } |
| | | if (dictBiz.getDictValue().contains("下午")){ |
| | | afternoon=afternoon.append(dictBiz.getDictKey()); |
| | | if (dictBiz.getDictValue().contains("下午")) { |
| | | afternoon = afternoon.append(dictBiz.getDictKey()); |
| | | } |
| | | } |
| | | //上午打卡时间标准 |
| | | String forenoonWorkTime = format+" "+forenoon.toString().split("-")[0]+":00"; |
| | | String forenoonOfDutyTime = format+" "+forenoon.toString().split("-")[1]+":00"; |
| | | String forenoonWorkTime = format + " " + forenoon.toString().split("-")[0] + ":00"; |
| | | String forenoonOfDutyTime = format + " " + forenoon.toString().split("-")[1] + ":00"; |
| | | //下午打卡时间标准 |
| | | String afternoonWorkTime = format+" "+afternoon.toString().split("-")[0]+":00"; |
| | | String afternoonOfDutyTime = format+" "+afternoon.toString().split("-")[1]+":00"; |
| | | String afternoonWorkTime = format + " " + afternoon.toString().split("-")[0] + ":00"; |
| | | String afternoonOfDutyTime = format + " " + afternoon.toString().split("-")[1] + ":00"; |
| | | //查询当前人员当天打卡信息 |
| | | List<Attendance> attendanceList = attendanceService.selAttendanceListNow(attendance.getNumber()); |
| | | //判断打卡时间 |
| | | try { |
| | | long time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendance.getClocktime()).getTime(); |
| | | //当天第一次打卡 |
| | | if(attendanceList.size()==0){ |
| | | //当天还没有打卡,即为当天第一个打卡 |
| | | |
| | | //判断打卡时间是上午还是下午 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //下午 |
| | | //正常上班 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){ |
| | | //正常上班 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("0"); |
| | | //判断上午上班之前半小时前打卡为无效打卡 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)<0){ |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("4"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //上午上班半小时前到上班时间打卡为正常打卡 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()-30*60*1000)>=0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0) { |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //上午上班后到上班下班前打卡为正常打卡 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<0) { |
| | | //查询当前时间之前当前考勤人员的最新的一条考勤数据 |
| | | Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber()); |
| | | if (null!=attendanceNow.getAttendancetype()){ |
| | | if (attendanceNow.getAttendancetype().equals("0") || attendanceNow.getClocktype().equals("1")) { |
| | | //下班早退 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("2"); |
| | | } |
| | | //迟到 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0 |
| | | ){ |
| | | //迟到上班 |
| | | if (attendanceNow.getAttendancetype().equals("4")){ |
| | | //上班迟到 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("1"); |
| | | } |
| | | |
| | | //正常下班 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | && |
| | | time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | ){ |
| | | //正常下班 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | } |
| | | |
| | | //加班 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //下午下班 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | } |
| | | return R.status(attendanceService.save(attendance)); |
| | | }else { |
| | | //上午 |
| | | //正常上班 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()<=0){ |
| | | //正常上午上班 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("0"); |
| | | } |
| | | //迟到 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 |
| | | && |
| | | time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()<=0 |
| | | ){ |
| | | //迟到上班 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("1"); |
| | | } |
| | | |
| | | |
| | | //正常下班 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>0 |
| | | && |
| | | time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | ){ |
| | | //正常下班 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | } |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //打卡时间和上午上班时间 |
| | | } |
| | | //已经打过一次卡,当天第二次打卡 |
| | | if(attendanceList.size()==1){ |
| | | //判断第一次打卡的时间范围,上午还是下午 |
| | | long time1 = 0; |
| | | try { |
| | | time1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attendanceList.get(0).getClocktime()).getTime(); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | //上午下班时间的半个小时后 |
| | | if (time1-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0) { |
| | | //下午 |
| | | //更新上班信息 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() <= 0) { |
| | | //更新上班时间 |
| | | //正常上班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setId(attendanceList.get(0).getId()); |
| | | //更新考勤消息 |
| | | return R.status(attendanceService.updateById(attendance)); |
| | | } |
| | | |
| | | //早退 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0 |
| | | && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0 |
| | | ) { |
| | | //早退 |
| | | attendance.setAttendancetype("2"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤消息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //正常下班 |
| | | if (time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000) <= 0 |
| | | && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() >= 0 |
| | | ) { |
| | | //新增下班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤消息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //其他时间修改 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000>0){ |
| | | //加班 |
| | | // attendance.setAttendancetype("加班"); |
| | | attendance.setId(attendanceList.get(0).getId()); |
| | | //更新考勤消息 |
| | | return R.status(attendanceService.updateById(attendance)); |
| | | } |
| | | |
| | | |
| | | }else { |
| | | //上午 |
| | | //更新 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() <= 0) { |
| | | //更新上班时间 |
| | | //正常上班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setId(attendanceList.get(0).getId()); |
| | | //更新考勤消息 |
| | | return R.status(attendanceService.updateById(attendance)); |
| | | } |
| | | //上午早退 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime() > 0 |
| | | && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime() < 0 |
| | | ) { |
| | | //早退 |
| | | attendance.setAttendancetype("2"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤消息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //下午早退 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime() > 0 |
| | | && time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime() < 0 |
| | | ) { |
| | | //早退 |
| | | attendance.setAttendancetype("2"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤消息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //上午正常下班 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0 |
| | | && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | ){ |
| | | //下班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤信息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //下午正常下班 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0 |
| | | && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | ){ |
| | | //下班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setClocktype("1"); |
| | | //新增考勤信息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //正常上班 |
| | | if (time - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | && time - (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0 |
| | | ){ |
| | | //上班 |
| | | attendance.setAttendancetype("0"); |
| | | attendance.setClocktype("0"); |
| | | //新增考勤信息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | } |
| | | } |
| | | //第三次打卡 |
| | | if (attendanceList.size()==2){ |
| | | //第三次记录打卡如果时间范围在上午的在早退时间及下班后的半小时范围内,则更新上一次打卡记录 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonWorkTime).getTime()>0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<0 |
| | | ){ |
| | | Attendance attendance1 = attendanceList.get(1); |
| | | attendance1.setClocktime(attendance.getClocktime()); |
| | | //更新打卡信息 |
| | | return R.status(attendanceService.updateById(attendance1)); |
| | | } |
| | | //第三次打卡记录时间返回在上午下班半小时后到下午上班 |
| | | if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){ |
| | | //新增正常打卡信息 |
| | | //上班迟到 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | attendance.setAttendancetype("1"); |
| | | } |
| | | //第三次打卡记录时间返回在下午上班到下午下班之前 |
| | | if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | //判断第二次是否已经打卡上班 |
| | | if (attendanceList.get(1).getClocktype().equals("0")){ |
| | | //修改打卡信息 |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //正常下班时间-下班半小时后 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()>=0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)<=0){ |
| | | //正常下班打卡 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //上午下班半小时后-下午上班之前半小時打卡为无效打卡 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)<0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //无效打卡 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("4"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //下午上班之前半小時-下午上班时间之前打卡为下午正常上班打卡 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()-30*60*1000)>=0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0){ |
| | | //下午正常打卡 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | //下午上班之后到下午下班之前 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | //查询当前时间之前当前考勤人员的最新的一条考勤数据 |
| | | Attendance attendanceNow = attendanceService.selAttendanceNewNow(attendance.getNumber()); |
| | | if (null!=attendanceNow.getAttendancetype()){ |
| | | if (attendanceNow.getAttendancetype().equals("0") && attendanceNow.getClocktype().equals("0")) { |
| | | //下班早退 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("2"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | }else { |
| | | //新增上班迟到打卡信息 |
| | | } |
| | | if (attendanceNow.getClocktype().equals("1")) { |
| | | //下班早退 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("2"); |
| | | } |
| | | if (attendanceNow.getAttendancetype().equals("4")){ |
| | | //上班迟到 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("1"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | }else { |
| | | //上班迟到 |
| | | attendance.setClocktype("0"); |
| | | attendance.setAttendancetype("1"); |
| | | } |
| | | //下午正常下班时间节点 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){ |
| | | //新增下班正常打卡信息 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //其他时间修改 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //修改打卡信息 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("2"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //第四次打卡 |
| | | if (attendanceList.size()==3){ |
| | | //第四次打卡记录时间返回在上午下班半小时后到下午上班 |
| | | if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()<=0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(forenoonOfDutyTime).getTime()+30*60*1000)>=0){ |
| | | Attendance attendance2 = attendanceList.get(2); |
| | | attendance2.setClocktime(attendance.getClocktime()); |
| | | //更新正常打卡信息 |
| | | return R.status(attendanceService.updateById(attendance2)); |
| | | } |
| | | //第四次打卡记录时间返回在下午上班到下午下班之前 |
| | | if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | //判断第二次是否是早退或者迟到 |
| | | //迟到 |
| | | if (attendanceList.get(2).getAttendancetype().equals("1")){ |
| | | //新增下班早退打卡信息 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("2"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | }else { |
| | | //早退 |
| | | //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态 |
| | | Attendance attendance2 = attendanceList.get(2); |
| | | attendance2.setClocktime(attendance.getClocktime()); |
| | | return R.status(attendanceService.updateById(attendance2)); |
| | | } |
| | | } |
| | | //下午正常下班时间节点 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0){ |
| | | //如果上一次为早退,则只更新信息 |
| | | if (attendanceList.get(2).getAttendancetype().equals("2")) { |
| | | //修改打卡信息 |
| | | Attendance attendance2 = attendanceList.get(2); |
| | | attendance2.setClocktime(attendance.getClocktime()); |
| | | return R.status(attendanceService.updateById(attendance2)); |
| | | }else { |
| | | //新增正常下班打卡信息 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | } |
| | | //其他时间 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //修改打卡信息 |
| | | Attendance attendance2 = attendanceList.get(2); |
| | | attendance2.setClocktime(attendance.getClocktime()); |
| | | return R.status(attendanceService.updateById(attendance2)); |
| | | } |
| | | |
| | | //正常打下午下班卡 |
| | | if (time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()>=0 |
| | | && time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)<=0 |
| | | ){ |
| | | //下午正常下班打卡 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("0"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | //第五次打卡 |
| | | if (attendanceList.size()==4){ |
| | | //只有在下午下班后可以有新增加班考勤数据,其他情况则是更新第四次的记录 |
| | | //第五次打卡记录时间返回在下午上班到下午下班后的30分钟之前 |
| | | // if(time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonWorkTime).getTime()>0 |
| | | // && time-new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()<0){ |
| | | // //早退 |
| | | // //更新上班早退打卡信息,只更新打卡时间,不更新考勤状态 |
| | | // Attendance attendance3 = attendanceList.get(3); |
| | | // attendance3.setClocktime(attendance.getClocktime()); |
| | | // return R.status(attendanceService.updateById(attendance3)); |
| | | // } |
| | | Attendance attendance3 = attendanceList.get(3); |
| | | attendance3.setClocktime(attendance.getClocktime()); |
| | | return R.status(attendanceService.updateById(attendance3)); |
| | | //下午正常下班30分钟后时间节点 |
| | | // if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | // //如果上一次为早退,则只更新信息 |
| | | // //新增正常下班打卡信息 |
| | | // attendance.setClocktype("1"); |
| | | // attendance.setAttendancetype("0"); |
| | | // return R.status(attendanceService.save(attendance)); |
| | | // } |
| | | |
| | | //打卡时间超过下午下班打卡时间后的半小时为无效打卡 |
| | | if (time-(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(afternoonOfDutyTime).getTime()+30*60*1000)>0){ |
| | | //下午下班打卡无效 |
| | | attendance.setClocktype("1"); |
| | | attendance.setAttendancetype("4"); |
| | | return R.status(attendanceService.save(attendance)); |
| | | } |
| | | |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |