diff --git a/skyeye-checkwork/src/main/java/com/skyeye/eve/service/impl/CheckWorkServiceImpl.java b/skyeye-checkwork/src/main/java/com/skyeye/eve/service/impl/CheckWorkServiceImpl.java index 274de36148be1836891d331f94a9ac55fe41bf68..a9f81ccdb6170ed7e35f77a69b553f54e22ff6fa 100644 --- a/skyeye-checkwork/src/main/java/com/skyeye/eve/service/impl/CheckWorkServiceImpl.java +++ b/skyeye-checkwork/src/main/java/com/skyeye/eve/service/impl/CheckWorkServiceImpl.java @@ -16,10 +16,7 @@ import com.skyeye.common.util.ToolUtil; import com.skyeye.eve.dao.CheckWorkDao; import com.skyeye.eve.dao.CheckWorkOvertimeDao; import com.skyeye.eve.dao.CheckWorkTimeDao; -import com.skyeye.eve.service.CheckWorkBusinessTripService; -import com.skyeye.eve.service.CheckWorkLeaveService; -import com.skyeye.eve.service.CheckWorkOvertimeService; -import com.skyeye.eve.service.CheckWorkService; +import com.skyeye.eve.service.*; import com.skyeye.exception.CustomException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,6 +62,9 @@ public class CheckWorkServiceImpl implements CheckWorkService { @Autowired private CheckWorkOvertimeDao checkWorkOvertimeDao; + @Autowired + private SysScheduleCommonService sysScheduleCommonService; + public static enum CheckTypeFrom{ CHECT_BTN_FROM_TIMEID(1, "根据班次id计算考勤按钮的显示状态"), CHECT_BTN_FROM_OVERTIME(2, "根据加班日计算考勤按钮的显示状态"); @@ -93,7 +93,6 @@ public class CheckWorkServiceImpl implements CheckWorkService { * @return void 返回类型 * @throws */ - @SuppressWarnings("static-access") @Override @Transactional(value = "transactionManager") public void insertCheckWorkStartWork(InputObject inputObject, OutputObject outputObject) throws Exception { @@ -167,7 +166,6 @@ public class CheckWorkServiceImpl implements CheckWorkService { * @return void 返回类型 * @throws */ - @SuppressWarnings("static-access") @Override @Transactional(value = "transactionManager") public void editCheckWorkEndWork(InputObject inputObject, OutputObject outputObject) throws Exception { @@ -416,33 +414,30 @@ public class CheckWorkServiceImpl implements CheckWorkService { outputObject.setBean(bean); outputObject.settotal(1); } - + /** - * - * @Title: queryCheckWorkTimeToShowButton - * @Description: 判断显示打上班卡或者下班卡 - * @param inputObject - * @param outputObject - * @throws Exception 参数 - * @return void 返回类型 - * @throws - */ + * 判断显示打上班卡或者下班卡 + * + * @param inputObject + * @param outputObject + * @throws Exception + */ @Override public void queryCheckWorkTimeToShowButton(InputObject inputObject, OutputObject outputObject) throws Exception { Map map = inputObject.getParams(); Map user = inputObject.getLogParams(); - String todayYMD = DateUtil.getYmdTimeAndToString(); + String today = DateUtil.getYmdTimeAndToString(); String userId = user.get("id").toString(); String timeId = map.get("timeId").toString(); String staffId = user.get("staffId").toString(); String nowTimeHMS = DateUtil.getHmsTimeAndToString(); // 1.获取当前用户的考勤班次信息 - Map workTime = getWorkTime(userId, todayYMD, timeId, staffId); + Map workTime = getWorkTime(userId, today, timeId, staffId); if(Integer.parseInt(workTime.get("type").toString()) == CheckTypeFrom.CHECT_BTN_FROM_OVERTIME.getType()){ timeId = "-"; } // 2.判断显示打上班卡或者下班卡 - Map result = getChectBtn(todayYMD, userId, timeId, workTime, nowTimeHMS); + Map result = getChectBtn(today, userId, timeId, workTime, nowTimeHMS); outputObject.setBean(result); } @@ -450,16 +445,16 @@ public class CheckWorkServiceImpl implements CheckWorkService { * 获取当前用户的考勤班次信息 * * @param userId 用户id - * @param todayYMD 指定日期,格式为yyyy-MM-dd(一般为今天的日期) + * @param today 指定日期,格式为yyyy-MM-dd(一般为今天的日期) * @param timeId 班次id * @param staffId 员工id * @return * @throws Exception */ - private Map getWorkTime(String userId, String todayYMD, String timeId, String staffId) throws Exception { + private Map getWorkTime(String userId, String today, String timeId, String staffId) throws Exception { Map workTime; // 判断今天是否是加班日 - List> overTimeMation = checkWorkOvertimeDao.queryPassThisDayAndCreateId(userId, todayYMD); + List> overTimeMation = checkWorkOvertimeDao.queryPassThisDayAndCreateId(userId, today); if(overTimeMation != null && !overTimeMation.isEmpty()){ // 根据加班日判断显示打上班卡或者下班卡 workTime = overTimeMation.get(0); @@ -477,17 +472,18 @@ public class CheckWorkServiceImpl implements CheckWorkService { /** * 判断显示打上班卡或者下班卡 * - * @param todayYMD 指定日期,格式为yyyy-MM-dd(一般为今天的日期) + * @param today 指定日期,格式为yyyy-MM-dd(一般为今天的日期) * @param userId 用户id * @param timeId 班次id + * @param workTime 考勤班次信息 * @param nowTimeHMS 指定日期,格式为HH:mm:ss(一般为当前时间) * @return * @throws Exception */ - private Map getChectBtn(String todayYMD, String userId, String timeId, Map workTime, String nowTimeHMS) throws Exception { + private Map getChectBtn(String today, String userId, String timeId, Map workTime, String nowTimeHMS) throws Exception { // 获取今天的打卡记录 - Map isAlreadyCheck = checkWorkDao.queryisAlreadyCheck(todayYMD, userId, timeId); - Integer checkState = getCheckState(isAlreadyCheck, nowTimeHMS, workTime); + Map isAlreadyCheck = checkWorkDao.queryisAlreadyCheck(today, userId, timeId); + Integer checkState = getCheckState(isAlreadyCheck, nowTimeHMS, workTime, today); Map result = new HashMap<>(); result.put("isCheck", checkState); result.putAll(workTime); @@ -504,11 +500,20 @@ public class CheckWorkServiceImpl implements CheckWorkService { * @param isAlreadyCheck 今日打卡信息 * @param nowTimeHMS 指定日期,格式为HH:mm:ss * @param workTime 班次考勤信息 + * @param today 指定日期,格式为yyyy-MM-dd(一般为今天的日期) * @return - * @throws ParseException + * @throws Exception */ - private Integer getCheckState(Map isAlreadyCheck, String nowTimeHMS, Map workTime) throws ParseException { + private Integer getCheckState(Map isAlreadyCheck, String nowTimeHMS, Map workTime, + String today) throws Exception { Integer checkState = null; + if(Integer.parseInt(workTime.get("type").toString()) == CheckTypeFrom.CHECT_BTN_FROM_TIMEID.getType()){ + if(sysScheduleCommonService.judgeISHoliday(today)){ + // 今天不是加班日,但是是节假日,则不显示按钮 + checkState = 4; + return checkState; + } + } if (isAlreadyCheck == null && DateUtil.compareTimeHMS(nowTimeHMS, workTime.get("clockOut").toString())) { // 今日没有打卡,且没有到下班时间,显示早卡按钮 checkState = 1; @@ -691,7 +696,9 @@ public class CheckWorkServiceImpl implements CheckWorkService { @Override public void queryCheckWorkReport(InputObject inputObject, OutputObject outputObject) throws Exception { Map map = inputObject.getParams(); + // 1.获取所有的考勤班次在指定日期内需要上班多少天 Map timeWorkDay = getAllCheckWorkTime(map.get("startTime").toString(), map.get("endTime").toString()); + // 2.分页获取员工考勤信息 Page pages = PageHelper.startPage(Integer.parseInt(map.get("page").toString()), Integer.parseInt(map.get("limit").toString())); List> beans = checkWorkDao.queryCheckWorkReport(map); setShouldTime(beans, timeWorkDay); @@ -702,6 +709,7 @@ public class CheckWorkServiceImpl implements CheckWorkService { private void setShouldTime(List> beans, Map timeWorkDay){ for(Map bean: beans){ String[] timsIds = bean.get("timsIds").toString().split(","); + // 该员工在指定日期范围内应该上班的天数 Integer shouldTime = 0; for(String timeId: timsIds){ if(!ToolUtil.isBlank(timeId)){ @@ -734,6 +742,10 @@ public class CheckWorkServiceImpl implements CheckWorkService { // 1.获取范围内的所有日期 List days = DateUtil.getDays(startTime, endTime); for(String day: days){ + if(sysScheduleCommonService.judgeISHoliday(day)){ + // 如果是法定节假日,则不参与计算 + continue; + } // 判断日期是周几 int weekDay = DateUtil.getWeek(day); // 判断日期是单周还是双周 @@ -759,7 +771,6 @@ public class CheckWorkServiceImpl implements CheckWorkService { * @return: boolean * @throws */ - @SuppressWarnings("unchecked") private boolean getTimeWhetherWork(String timeId, int weekDay, int weekType, List> workTime){ Map timeMation = workTime.stream().filter(item -> item.get("timeId").toString().equals(timeId)).collect(Collectors.toList()).get(0); if(timeMation != null && !timeMation.isEmpty()){ diff --git a/skyeye-checkwork/src/main/resources/reqmapping/mapping/checkwork.xml b/skyeye-checkwork/src/main/resources/reqmapping/mapping/checkwork.xml index 44a5e7ba51b907e825fde5a96f760b66bf6cad33..787c57d4f4987f7bf779fc0cea1667b6a3477bf7 100644 --- a/skyeye-checkwork/src/main/resources/reqmapping/mapping/checkwork.xml +++ b/skyeye-checkwork/src/main/resources/reqmapping/mapping/checkwork.xml @@ -106,7 +106,7 @@ - + @@ -117,7 +117,7 @@ - + diff --git a/skyeye-common/src/main/java/com/skyeye/eve/dao/SysScheduleCommonDao.java b/skyeye-common/src/main/java/com/skyeye/eve/dao/SysScheduleCommonDao.java new file mode 100644 index 0000000000000000000000000000000000000000..35915709fb28bdd2f1449ca4dc8deee0bc08d71a --- /dev/null +++ b/skyeye-common/src/main/java/com/skyeye/eve/dao/SysScheduleCommonDao.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.eve.dao; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: SysScheduleCommonDao + * @Description: 节假日公共部分 + * @author: skyeye云系列--卫志强 + * @date: 2021/11/28 9:48 + * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +public interface SysScheduleCommonDao { + + /** + * 根据指定天判断是否属于节假日 + * + * @param day 指定天,格式为yyyy-mm-dd + * @return + * @throws Exception + */ + List> queryWhetherIsHolidayByDate(@Param("day") String day) throws Exception; + +} diff --git a/skyeye-common/src/main/java/com/skyeye/eve/service/SysScheduleCommonService.java b/skyeye-common/src/main/java/com/skyeye/eve/service/SysScheduleCommonService.java new file mode 100644 index 0000000000000000000000000000000000000000..aaf640f154943d5d3acf05ee4902ea00adc91a46 --- /dev/null +++ b/skyeye-common/src/main/java/com/skyeye/eve/service/SysScheduleCommonService.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.eve.service; + +/** + * @ClassName: SysScheduleCommonService + * @Description: 节假日公共部分 + * @author: skyeye云系列--卫志强 + * @date: 2021/11/28 9:49 + * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +public interface SysScheduleCommonService { + + /** + * 判断指定日期是否是节假日 + * + * @param day 日期,格式为yyyy-mm-dd + * @return true:是节假日;false:不是节假日 + * @throws Exception + */ + boolean judgeISHoliday(String day) throws Exception; + +} diff --git a/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysScheduleCommonServiceImpl.java b/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysScheduleCommonServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9acc6304656bd1c384f92e658b34d21bed21bb96 --- /dev/null +++ b/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysScheduleCommonServiceImpl.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.eve.service.impl; + +import com.skyeye.eve.dao.SysScheduleCommonDao; +import com.skyeye.eve.service.SysScheduleCommonService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @ClassName: SysScheduleCommonServiceImpl + * @Description: 节假日公共部分 + * @author: skyeye云系列--卫志强 + * @date: 2021/11/28 9:49 + * @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@Service +public class SysScheduleCommonServiceImpl implements SysScheduleCommonService { + + @Autowired + private SysScheduleCommonDao sysScheduleCommonDao; + + /** + * 判断指定日期是否是节假日 + * + * @param day 日期,格式为yyyy-mm-dd + * @return true:是节假日;false:不是节假日 + * @throws Exception + */ + @Override + public boolean judgeISHoliday(String day) throws Exception { + List> holiday = sysScheduleCommonDao.queryWhetherIsHolidayByDate(day); + if(holiday == null || holiday.isEmpty()){ + return false; + } + return true; + } + +} diff --git a/skyeye-common/src/main/resources/mapper/common/SysScheduleCommonMapper.xml b/skyeye-common/src/main/resources/mapper/common/SysScheduleCommonMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..46d59a2e3cb22e197c323cb00a369b8d8394c4e7 --- /dev/null +++ b/skyeye-common/src/main/resources/mapper/common/SysScheduleCommonMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/skyeye-schedule/src/main/java/com/skyeye/eve/service/impl/ScheduleDayServiceImpl.java b/skyeye-schedule/src/main/java/com/skyeye/eve/service/impl/ScheduleDayServiceImpl.java index 7908b346f12b3cf31b9e4728f8425113f822f92c..edb71c960ae7f84a47bd7a76ce95fb34c25c3aad 100644 --- a/skyeye-schedule/src/main/java/com/skyeye/eve/service/impl/ScheduleDayServiceImpl.java +++ b/skyeye-schedule/src/main/java/com/skyeye/eve/service/impl/ScheduleDayServiceImpl.java @@ -123,7 +123,7 @@ public class ScheduleDayServiceImpl implements ScheduleDayService{ /** * * @Title: queryScheduleDayMationByUserId - * @Description: 根据用户日程信息 + * @Description: 根据用户id获取日程信息 * @param inputObject * @param outputObject * @throws Exception 参数 @@ -162,8 +162,9 @@ public class ScheduleDayServiceImpl implements ScheduleDayService{ map.put("userId", user.get("id")); List> beans = scheduleDayDao.queryScheduleDayMationTodayByUserId(map); outputObject.setBeans(beans); - if(beans != null && !beans.isEmpty()) + if(beans != null && !beans.isEmpty()) { outputObject.settotal(beans.size()); + } } /** diff --git a/skyeye-wages/src/main/java/com/skyeye/eve/dao/WagesStaffMationDao.java b/skyeye-wages/src/main/java/com/skyeye/eve/dao/WagesStaffMationDao.java index 93dcec7a39457e821d40facff5b9b9b9af404689..b8cf94215191246da88c259a262ea2f7a070a55e 100644 --- a/skyeye-wages/src/main/java/com/skyeye/eve/dao/WagesStaffMationDao.java +++ b/skyeye-wages/src/main/java/com/skyeye/eve/dao/WagesStaffMationDao.java @@ -89,12 +89,4 @@ public interface WagesStaffMationDao { */ public Map queryWagesStaffPaymentDetail(@Param("staffId") String staffId, @Param("payMonth") String payMonth) throws Exception; - /** - * 根据指定天判断是否属于节假日 - * - * @param day 指定天,格式为yyyy-mm-dd - * @return - * @throws Exception - */ - List> queryWhetherIsHolidayByDate(@Param("day") String day) throws Exception; } diff --git a/skyeye-wages/src/main/java/com/skyeye/eve/service/WagesStaffMationService.java b/skyeye-wages/src/main/java/com/skyeye/eve/service/WagesStaffMationService.java index 966b18177c729c6e93ccc9c08861e7c882517fbf..1dc7a0d1734dc36f29ebcf6a3bc52f2d44c30d45 100644 --- a/skyeye-wages/src/main/java/com/skyeye/eve/service/WagesStaffMationService.java +++ b/skyeye-wages/src/main/java/com/skyeye/eve/service/WagesStaffMationService.java @@ -32,13 +32,4 @@ public interface WagesStaffMationService { */ void setLastMonthBe(List> staffWorkTime, Map staffModelFieldMap, String lastMonthDate) throws Exception; - /** - * 判断指定日期是否是节假日 - * - * @param yesterdayTime 昨天的日期,格式为yyyy-mm-dd - * @return - * @throws Exception - */ - boolean judgeISHoliday(String yesterdayTime) throws Exception; - } diff --git a/skyeye-wages/src/main/java/com/skyeye/eve/service/impl/WagesStaffMationServiceImpl.java b/skyeye-wages/src/main/java/com/skyeye/eve/service/impl/WagesStaffMationServiceImpl.java index cbae6c3b12af042d973c387605edb123c56c288c..e5e5425ddad581f50358adffc3732f0a42595e43 100644 --- a/skyeye-wages/src/main/java/com/skyeye/eve/service/impl/WagesStaffMationServiceImpl.java +++ b/skyeye-wages/src/main/java/com/skyeye/eve/service/impl/WagesStaffMationServiceImpl.java @@ -14,6 +14,7 @@ import com.skyeye.common.util.DateUtil; import com.skyeye.eve.dao.WagesModelDao; import com.skyeye.eve.dao.WagesModelFieldDao; import com.skyeye.eve.dao.WagesStaffMationDao; +import com.skyeye.eve.service.SysScheduleCommonService; import com.skyeye.eve.service.WagesStaffMationService; import com.skyeye.wages.constant.WagesConstant; import org.slf4j.Logger; @@ -52,6 +53,9 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService { @Autowired private WagesModelFieldDao wagesModelFieldDao; + @Autowired + private SysScheduleCommonService sysScheduleCommonService; + /** * 计薪资字段状态 */ @@ -198,7 +202,7 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService { for (Map bean : staffWorkTime) { List> days = (List>) bean.get("days"); for (String day : lastMonthDays) {// 周几 - if(this.judgeISHoliday(day)){ + if(sysScheduleCommonService.judgeISHoliday(day)){ // 如果是节假日,则不计算 continue; } @@ -229,20 +233,4 @@ public class WagesStaffMationServiceImpl implements WagesStaffMationService { staffModelFieldMap.put(WagesConstant.DEFAULT_WAGES_FIELD_TYPE.LAST_MONTH_BE_HOUR.getKey(), CalculationUtil.divide(lastMonthBeHour, "60", 2)); } - /** - * 判断指定日期是否是节假日 - * - * @param yesterdayTime 昨天的日期,格式为yyyy-mm-dd - * @return - * @throws Exception - */ - @Override - public boolean judgeISHoliday(String yesterdayTime) throws Exception { - List> holiday = wagesStaffMationDao.queryWhetherIsHolidayByDate(yesterdayTime); - if(holiday == null || holiday.isEmpty()){ - return false; - } - return true; - } - } diff --git a/skyeye-wages/src/main/resources/mapper/wages/WagesStaffMationMapper.xml b/skyeye-wages/src/main/resources/mapper/wages/WagesStaffMationMapper.xml index b5ef8a7b78a8a41ac9e145b848bbdeb63fd8ede0..96e6449496af921e9cf72c47efc6098bc4c71f0d 100644 --- a/skyeye-wages/src/main/resources/mapper/wages/WagesStaffMationMapper.xml +++ b/skyeye-wages/src/main/resources/mapper/wages/WagesStaffMationMapper.xml @@ -240,14 +240,4 @@ AND date_format(b.cancel_day, '%Y-%m') = #{lastMonthDate} - - \ No newline at end of file diff --git a/skyeye-web/src/main/java/com/skyeye/sys/quartz/CheckWorkQuartz.java b/skyeye-web/src/main/java/com/skyeye/sys/quartz/CheckWorkQuartz.java index ead67bd130464fadb761c73cd8db71ed90f96f7d..09786b20fb99519eb4fc04589ab083f7ccab46e8 100644 --- a/skyeye-web/src/main/java/com/skyeye/sys/quartz/CheckWorkQuartz.java +++ b/skyeye-web/src/main/java/com/skyeye/sys/quartz/CheckWorkQuartz.java @@ -13,7 +13,7 @@ import com.skyeye.eve.dao.CheckWorkLeaveDao; import com.skyeye.eve.dao.CheckWorkTimeDao; import com.skyeye.eve.entity.quartz.SysQuartzRunHistory; import com.skyeye.eve.service.SysQuartzRunHistoryService; -import com.skyeye.eve.service.WagesStaffMationService; +import com.skyeye.eve.service.SysScheduleCommonService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -53,7 +53,7 @@ public class CheckWorkQuartz { private CheckWorkLeaveDao checkWorkLeaveDao; @Autowired - private WagesStaffMationService wagesStaffMationService; + private SysScheduleCommonService sysScheduleCommonService; @Autowired private SysQuartzRunHistoryService sysQuartzRunHistoryService; @@ -72,7 +72,7 @@ public class CheckWorkQuartz { List> workTime = getAllCheckWorkTime(); // 得到昨天的时间 String yesterdayTime = DateUtil.getSpecifiedDayMation(DateUtil.getTimeAndToString(), "yyyy-MM-dd", 0, 1, 7); - if(workTime != null && !workTime.isEmpty() && !wagesStaffMationService.judgeISHoliday(yesterdayTime)){ + if(workTime != null && !workTime.isEmpty() && !sysScheduleCommonService.judgeISHoliday(yesterdayTime)){ // 班次信息不为空,并且昨天不是节假日 log.info("Fill in the clocking information for timing task execution time is {}", yesterdayTime); // 判断昨天的日期是周几