提交 e2a58854 编写于 作者: doc_wei's avatar doc_wei

考勤打卡-->添加节假日不打卡功能

考勤报表-->添加节假日不打卡功能的计算
上级 9d397ebc
......@@ -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<String, Object> map = inputObject.getParams();
Map<String, Object> 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<String, Object> workTime = getWorkTime(userId, todayYMD, timeId, staffId);
Map<String, Object> workTime = getWorkTime(userId, today, timeId, staffId);
if(Integer.parseInt(workTime.get("type").toString()) == CheckTypeFrom.CHECT_BTN_FROM_OVERTIME.getType()){
timeId = "-";
}
// 2.判断显示打上班卡或者下班卡
Map<String, Object> result = getChectBtn(todayYMD, userId, timeId, workTime, nowTimeHMS);
Map<String, Object> 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<String, Object> getWorkTime(String userId, String todayYMD, String timeId, String staffId) throws Exception {
private Map<String, Object> getWorkTime(String userId, String today, String timeId, String staffId) throws Exception {
Map<String, Object> workTime;
// 判断今天是否是加班日
List<Map<String, Object>> overTimeMation = checkWorkOvertimeDao.queryPassThisDayAndCreateId(userId, todayYMD);
List<Map<String, Object>> 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<String, Object> getChectBtn(String todayYMD, String userId, String timeId, Map<String, Object> workTime, String nowTimeHMS) throws Exception {
private Map<String, Object> getChectBtn(String today, String userId, String timeId, Map<String, Object> workTime, String nowTimeHMS) throws Exception {
// 获取今天的打卡记录
Map<String, Object> isAlreadyCheck = checkWorkDao.queryisAlreadyCheck(todayYMD, userId, timeId);
Integer checkState = getCheckState(isAlreadyCheck, nowTimeHMS, workTime);
Map<String, Object> isAlreadyCheck = checkWorkDao.queryisAlreadyCheck(today, userId, timeId);
Integer checkState = getCheckState(isAlreadyCheck, nowTimeHMS, workTime, today);
Map<String, Object> 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<String, Object> isAlreadyCheck, String nowTimeHMS, Map<String, Object> workTime) throws ParseException {
private Integer getCheckState(Map<String, Object> isAlreadyCheck, String nowTimeHMS, Map<String, Object> 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<String, Object> map = inputObject.getParams();
// 1.获取所有的考勤班次在指定日期内需要上班多少天
Map<String, Integer> 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<Map<String, Object>> beans = checkWorkDao.queryCheckWorkReport(map);
setShouldTime(beans, timeWorkDay);
......@@ -702,6 +709,7 @@ public class CheckWorkServiceImpl implements CheckWorkService {
private void setShouldTime(List<Map<String, Object>> beans, Map<String, Integer> timeWorkDay){
for(Map<String, Object> 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<String> 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<Map<String, Object>> workTime){
Map<String, Object> timeMation = workTime.stream().filter(item -> item.get("timeId").toString().equals(timeId)).collect(Collectors.toList()).get(0);
if(timeMation != null && !timeMation.isEmpty()){
......
......@@ -106,7 +106,7 @@
<property id="monthMation" name="monthMation" ref="required" var="当前月上个年月" />
<property id="timeId" name="timeId" ref="required" var="班次id" />
</url>
<url id="checkwork015" path="/post/CheckWorkController/queryCheckWorkReport" val="获取考勤报表数据" allUse="2">
<url id="checkwork015" path="/post/CheckWorkController/queryCheckWorkReport" val="获取考勤报表数据" method="POST" allUse="2">
<property id="limit" name="limit" ref="required,num" var="分页参数,每页多少条数据" />
<property id="page" name="page" ref="required,num" var="分页参数,第几页"/>
<property id="userName" name="userName" ref="" var="员工姓名"/>
......@@ -117,7 +117,7 @@
<property id="endTime" name="endTime" ref="required" var="最后时间" />
<property id="timeId" name="timeId" ref="" var="班次id" />
</url>
<url id="checkwork016" path="/post/CheckWorkController/queryCheckWorkEcharts" val="获取考勤图标数据" allUse="2">
<url id="checkwork016" path="/post/CheckWorkController/queryCheckWorkEcharts" val="获取考勤图标数据" method="POST" allUse="2">
<property id="userName" name="userName" ref="" var="员工姓名"/>
<property id="companyName" name="companyName" ref="" var="公司"/>
<property id="departmentName" name="departmentName" ref="" var="部门"/>
......
/*******************************************************************************
* 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<Map<String, Object>> queryWhetherIsHolidayByDate(@Param("day") String day) throws Exception;
}
/*******************************************************************************
* 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;
}
/*******************************************************************************
* 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<Map<String, Object>> holiday = sysScheduleCommonDao.queryWhetherIsHolidayByDate(day);
if(holiday == null || holiday.isEmpty()){
return false;
}
return true;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.skyeye.eve.dao.SysScheduleCommonDao">
<select id="queryWhetherIsHolidayByDate" resultType="java.util.Map">
SELECT
a.id
FROM
schedule_day a
WHERE #{day} >= DATE_FORMAT(a.start_time, '%Y-%m-%d')
AND DATE_FORMAT(a.end_time, '%Y-%m-%d') >= #{day}
AND a.type = 3
</select>
</mapper>
\ No newline at end of file
......@@ -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<Map<String, Object>> beans = scheduleDayDao.queryScheduleDayMationTodayByUserId(map);
outputObject.setBeans(beans);
if(beans != null && !beans.isEmpty())
if(beans != null && !beans.isEmpty()) {
outputObject.settotal(beans.size());
}
}
/**
......
......@@ -89,12 +89,4 @@ public interface WagesStaffMationDao {
*/
public Map<String, Object> queryWagesStaffPaymentDetail(@Param("staffId") String staffId, @Param("payMonth") String payMonth) throws Exception;
/**
* 根据指定天判断是否属于节假日
*
* @param day 指定天,格式为yyyy-mm-dd
* @return
* @throws Exception
*/
List<Map<String, Object>> queryWhetherIsHolidayByDate(@Param("day") String day) throws Exception;
}
......@@ -32,13 +32,4 @@ public interface WagesStaffMationService {
*/
void setLastMonthBe(List<Map<String, Object>> staffWorkTime, Map<String, String> staffModelFieldMap, String lastMonthDate) throws Exception;
/**
* 判断指定日期是否是节假日
*
* @param yesterdayTime 昨天的日期,格式为yyyy-mm-dd
* @return
* @throws Exception
*/
boolean judgeISHoliday(String yesterdayTime) throws Exception;
}
......@@ -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<String, Object> bean : staffWorkTime) {
List<Map<String, Object>> days = (List<Map<String, Object>>) 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<Map<String, Object>> holiday = wagesStaffMationDao.queryWhetherIsHolidayByDate(yesterdayTime);
if(holiday == null || holiday.isEmpty()){
return false;
}
return true;
}
}
......@@ -240,14 +240,4 @@
AND date_format(b.cancel_day, '%Y-%m') = #{lastMonthDate}
</select>
<select id="queryWhetherIsHolidayByDate" resultType="java.util.Map">
SELECT
a.id
FROM
schedule_day a
WHERE #{day} >= DATE_FORMAT(a.start_time, '%Y-%m-%d')
AND DATE_FORMAT(a.end_time, '%Y-%m-%d') >= #{day}
AND a.type = 3
</select>
</mapper>
\ No newline at end of file
......@@ -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<Map<String, Object>> 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);
// 判断昨天的日期是周几
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册