考勤计算重构
This commit is contained in:
parent
5bbbc22e30
commit
37bedd187d
|
|
@ -72,7 +72,7 @@ public interface AttSourceDataDao {
|
|||
* 查询一个月的节假日
|
||||
* @return list bean
|
||||
*/
|
||||
List<Holiday> selectHolidayByMonth(@Param("pushDate")String pushDate, @Param("pushType")int pushType);
|
||||
List<Holiday> selectHolidayByMonth(@Param("pushDate")String pushDate);
|
||||
|
||||
/**
|
||||
* 查询人员的请假数据
|
||||
|
|
@ -156,4 +156,73 @@ public interface AttSourceDataDao {
|
|||
int getFirstAttendanceData(String date);
|
||||
|
||||
void deleteAttMonthReport(String pushDate);
|
||||
|
||||
/**
|
||||
* 查询指定时间内存在考勤人员列表的日期
|
||||
* @param startDate
|
||||
* @param days
|
||||
* @return
|
||||
*/
|
||||
List<String> getAttSettingDate(@Param("startDate") String startDate,@Param("days") int days);
|
||||
|
||||
/**
|
||||
* 查询历史某天应考勤人员
|
||||
* @param currentDay
|
||||
* @return
|
||||
*/
|
||||
List<AttGroupBean> getAttSettingHistoryDate(String currentDay);
|
||||
|
||||
/**
|
||||
* 将历史某天应考勤人员插入到考勤人员列表
|
||||
* @param attList
|
||||
*/
|
||||
void insertAttSettingHistoryData(List<AttGroupBean> attList);
|
||||
|
||||
/**
|
||||
* 查询当天应考勤人员
|
||||
* @param pushDate
|
||||
* @return
|
||||
*/
|
||||
List<AttDataBean> getAttPerson(String pushDate);
|
||||
|
||||
void insertAttDataList(List<AttDataBean> listPerson);
|
||||
|
||||
/**
|
||||
* 查询当天考勤模版人员
|
||||
* @param pushDate
|
||||
* @return
|
||||
*/
|
||||
List<Long> getAttDataPerson(String pushDate);
|
||||
|
||||
/***
|
||||
* 查询当天考勤状态为未打卡人员(att_data)
|
||||
* @param pushDate
|
||||
* @return
|
||||
*/
|
||||
List<AttDataBean> getAttDataByStatus(@Param("pushDate") String pushDate,@Param("attType") String attType);
|
||||
|
||||
/***
|
||||
* 查询当天考勤状态为未打卡人员(att_data_update)
|
||||
* @param pushDate
|
||||
* @return
|
||||
*/
|
||||
List<AttDataBean> getAttDataUpdateByStatus(@Param("pushDate") String pushDate,@Param("attType") String attType);
|
||||
|
||||
/**
|
||||
* 超过时间未打卡的补为旷工(att_data)
|
||||
* @param list
|
||||
*/
|
||||
void updateAttDataList(List<AttDataBean> list);
|
||||
/**
|
||||
* 超过时间未打卡的补为旷工(att_data_update)
|
||||
* @param list
|
||||
*/
|
||||
void updateAttDataUpdateList(List<AttDataBean> list);
|
||||
|
||||
/**
|
||||
* 当日是否为法假
|
||||
* @param pushDate
|
||||
* @return
|
||||
*/
|
||||
List<Holiday> selectHolidayByDay(String pushDate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ public class AttGroupBean {
|
|||
*/
|
||||
private List<SysTree> treeList;
|
||||
|
||||
/**
|
||||
* 是否有法定节假日
|
||||
*/
|
||||
private Integer isHaveHoliday;
|
||||
|
||||
/**
|
||||
* 创建用户编号
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ public class AttSourceDataBean {
|
|||
* 打卡地址
|
||||
*/
|
||||
private String attAddress;
|
||||
/**
|
||||
* 打卡省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 打卡经度
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public class AttendanceDetailsServiceImpl implements AttendanceDetailsService {
|
|||
}
|
||||
// 使用增强的 for 循环遍历 Set
|
||||
for (String item : keys) {
|
||||
List<AttGroupBean> groupList = attTasks.getGroupData(item, 2);
|
||||
List<AttGroupBean> groupList = attTasks.getGroupData(item);
|
||||
attTasks.createReportData(groupList, item, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ public class AttTasks {
|
|||
/**
|
||||
* 历史考勤数据
|
||||
*/
|
||||
@Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
|
||||
// @Scheduled(initialDelay = 6000,fixedDelay = 60000 * 30)
|
||||
@Scheduled(cron = "0 50 19 * * ?")
|
||||
@Async
|
||||
public void getHisAttTasks() {
|
||||
log.info("--------考勤定时器开启------");
|
||||
|
|
@ -81,7 +82,7 @@ public class AttTasks {
|
|||
return; // 如果任务已经执行过,直接返回
|
||||
}
|
||||
executed = true; // 设置标志位,表示任务已经执行过
|
||||
String startDate = "2025-01-03";
|
||||
String startDate = "2025-01-01";
|
||||
String endDate = "2025-01-31";
|
||||
List<String> dateList = getStrDateListBetween(startDate, endDate);
|
||||
// List<String> dateList = new ArrayList<>();
|
||||
|
|
@ -140,7 +141,7 @@ public class AttTasks {
|
|||
executorService.submit(() -> {
|
||||
for (String date : batch) {
|
||||
try {
|
||||
// delHisData(date);
|
||||
delHisData(date);
|
||||
pushAttData(date, 2);
|
||||
} catch (Exception e) {
|
||||
// 记录异常并继续处理下一个日期
|
||||
|
|
@ -178,11 +179,11 @@ public class AttTasks {
|
|||
*/
|
||||
private void pushAttData(String pushDate, int pushType) {
|
||||
//获取黔送云的考勤数据
|
||||
// getQsyAttendanceData(pushDate, pushType);
|
||||
// //获取考勤机中的考勤数据
|
||||
// getMachineAttendanceData(pushDate, pushType);
|
||||
getQsyAttendanceData(pushDate, pushType);
|
||||
//获取考勤机中的考勤数据
|
||||
getMachineAttendanceData(pushDate, pushType);
|
||||
// //查出每一个考勤组的应出勤天数以及考勤组的规则
|
||||
List<AttGroupBean> groupList = getGroupData(pushDate, pushType);
|
||||
List<AttGroupBean> groupList = getGroupData(pushDate);
|
||||
// //新增默认考勤数据到考勤数据和修改表
|
||||
insertAttData(groupList, pushDate, pushType);
|
||||
//更新请假数据
|
||||
|
|
@ -201,8 +202,14 @@ public class AttTasks {
|
|||
orElseGet(ArrayList::new);
|
||||
if (!attSourceList.isEmpty()) {
|
||||
attSourceList.forEach(c -> {
|
||||
c.setAttAddress(AddressCoordinateFormatUtil.
|
||||
coordinateToAddress(c.getAttLon(), c.getAttLat()));
|
||||
String address;
|
||||
try {
|
||||
address = AddressCoordinateFormatUtil.
|
||||
coordinateToAddress(c.getAttLon(), c.getAttLat());
|
||||
}catch (IllegalArgumentException e){
|
||||
address = "地址未转化成功";
|
||||
}
|
||||
c.setAttAddress(address);
|
||||
if ("0".equals(c.getAttType())) {
|
||||
int i = checkTime(c.getAttCurrentTime());
|
||||
c.setAttType(String.valueOf(i));
|
||||
|
|
@ -358,7 +365,6 @@ public class AttTasks {
|
|||
} else {
|
||||
tf = true;
|
||||
}
|
||||
|
||||
if (tf) {
|
||||
replaceHolidayData(toWorkBean, 0);
|
||||
replaceHolidayData(offWorkBean, 0);
|
||||
|
|
@ -394,7 +400,7 @@ public class AttTasks {
|
|||
*
|
||||
* @return 考勤组集合
|
||||
*/
|
||||
public List<AttGroupBean> getGroupData(String pushDate, int pushType) {
|
||||
public List<AttGroupBean> getGroupData(String pushDate) {
|
||||
//查出考勤组的数据
|
||||
List<AttGroupBean> groupList = Optional.ofNullable(attGroupDao.selectAttGroupList(new AttGroupBean())).
|
||||
orElseGet(ArrayList::new);
|
||||
|
|
@ -402,7 +408,7 @@ public class AttTasks {
|
|||
return new ArrayList<>();
|
||||
}
|
||||
//查询当月否有节假日或补班
|
||||
List<Holiday> holidays = attSourceDataDao.selectHolidayByMonth(pushDate, pushType);
|
||||
List<Holiday> holidays = attSourceDataDao.selectHolidayByMonth(pushDate);
|
||||
groupList.forEach(c -> {
|
||||
//应考勤天
|
||||
List<String> attDayList = WorkdayCalculator.getWorkDay(c.getAttDay(),
|
||||
|
|
@ -903,7 +909,7 @@ public class AttTasks {
|
|||
if (items.isEmpty()) {
|
||||
continue; // 如果列表为空,跳过
|
||||
}
|
||||
//五点之前的数据属于过来当天的下班打卡,不计入
|
||||
//五点之前的数据属于过来当天的下班打卡,不计入
|
||||
LocalTime noonEnd = LocalTime.of(5, 0);
|
||||
// 获取上班时间并转换为 LocalTime 以便比较
|
||||
LocalTime toWorkTime = LocalTime.parse(attGroupBean.getToWorkTime(), timeFormatter);
|
||||
|
|
@ -1123,8 +1129,6 @@ public class AttTasks {
|
|||
date1 = DateUtils.parseDate(DateUtils.getAfterDate(DateUtils.getYyyyMmDd(attTime)) + " " + standardTime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ("1".equals(attType)) { // 上班打卡
|
||||
// 计算时间差
|
||||
// 减 1 原因:30上班,30:59不算迟到,类似于默认可以迟到一分钟
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
select ags.*, ag.id as groupId, ag.group_name, ag.att_type
|
||||
from att_group ag
|
||||
left join att_group_setting ags on ags.group_id = ag.id and ags.is_active = 1
|
||||
left join att_group_person_relation agpr on agpr.group_id = ag.id and agpr.is_active = 1
|
||||
where ag.is_active = 1
|
||||
<if test="groupName != null and groupName != '' ">
|
||||
and ag.group_name = #{groupName}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@
|
|||
<insert id="insertAttSourceData">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
replace into att_source_data(name, id_number, org_id, org_name, att_current_day,
|
||||
att_current_time, att_type, att_address, att_lon, att_lat, data_source, remark)
|
||||
att_current_time, att_type, att_address, province, att_lon, att_lat, data_source, remark)
|
||||
values (#{params.name}, #{params.idNumber}, #{params.orgId}, #{params.orgName},
|
||||
#{params.attCurrentDay}, #{params.attCurrentTime}, #{params.attType},
|
||||
#{params.attAddress}, #{params.attLon}, #{params.attLat}, #{params.dataSource}, #{params.remark})
|
||||
#{params.attAddress}, #{province}, #{params.attLon}, #{params.attLat}, #{params.dataSource},
|
||||
#{params.remark})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
@ -37,7 +38,8 @@
|
|||
values (#{params.userId}, #{params.userName}, #{params.orgId}, #{params.orgName},
|
||||
#{params.attCurrentMonth}, #{params.requiredDays}, #{params.normalNum}, #{params.lateNum},
|
||||
#{params.earlyNum}, #{params.skippingNum}, #{params.leaveNum},
|
||||
#{params.addressErrorNum}, #{params.einErrorNum}, #{params.restNum}, #{params.outNum}, #{params.businessTripNum})
|
||||
#{params.addressErrorNum}, #{params.einErrorNum}, #{params.restNum}, #{params.outNum},
|
||||
#{params.businessTripNum})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
@ -57,16 +59,33 @@
|
|||
#{item.attAddress})
|
||||
</foreach>
|
||||
</insert>
|
||||
<insert id="insertAttSettingHistoryData">
|
||||
replace into att_setting_history(user_id, group_id, current_day) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.userId},#{item.groupId},#{item.currentDay})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertAttDataList">
|
||||
insert into att_data(user_id, att_current_day, att_status, att_type)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.userId}, #{item.attCurrentDay}, #{item.attStatus}, #{item.attType})
|
||||
</foreach>
|
||||
;
|
||||
insert into att_data_update(user_id, att_current_day, att_status, att_type)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.userId}, #{item.attCurrentDay}, #{item.attStatus}, #{item.attType})
|
||||
</foreach>
|
||||
;
|
||||
</insert>
|
||||
|
||||
<!-- replace into att_data(user_id, org_id, att_current_day, att_current_time,-->
|
||||
<!-- att_type, att_address, att_lon, att_lat, data_source, att_status, error_remake)-->
|
||||
<!-- values (#{params.userId}, #{params.orgId}, #{params.attCurrentDay},-->
|
||||
<!-- #{params.attCurrentTime}, #{params.attType}, #{params.attAddress}, #{params.attLon},-->
|
||||
<!-- #{params.attLat}, #{params.dataSource}, #{params.attStatus}, #{params.errorRemake});-->
|
||||
<update id="updateAttStatusData">
|
||||
<foreach collection="list" item="params" separator=";">
|
||||
update att_data set att_current_time = #{params.attCurrentTime},
|
||||
att_address = #{params.attAddress}, att_lon = #{params.attLon}, att_lat = #{params.attLat},
|
||||
att_address = #{params.attAddress}, province = #{params.province}, att_lon = #{params.attLon}, att_lat =
|
||||
#{params.attLat},
|
||||
data_source = #{params.dataSource},
|
||||
error_remake = #{params.remark},
|
||||
att_status = CASE
|
||||
|
|
@ -75,11 +94,12 @@
|
|||
where dict_type = 'att_status' and (is_leave = '1' or is_leave = '2') ) THEN att_status
|
||||
ELSE #{params.attStatus}
|
||||
END
|
||||
where user_id = #{params.userId} and org_id = #{params.orgId}
|
||||
where user_id = #{params.userId}
|
||||
AND att_current_day = #{params.attCurrentDay} and att_type = #{params.attType};
|
||||
|
||||
update att_data_update set att_current_time = #{params.attCurrentTime},
|
||||
att_address = #{params.attAddress}, att_lon = #{params.attLon}, att_lat = #{params.attLat},
|
||||
att_address = #{params.attAddress}, province = #{params.province}, att_lon = #{params.attLon}, att_lat =
|
||||
#{params.attLat},
|
||||
data_source = #{params.dataSource},
|
||||
error_remake = #{params.remark},
|
||||
att_status = CASE
|
||||
|
|
@ -88,7 +108,7 @@
|
|||
where dict_type = 'att_status' and (is_leave = '1' or is_leave = '2')) THEN att_status
|
||||
ELSE #{params.attStatus}
|
||||
END
|
||||
where is_update = 0 and user_id = #{params.userId} and org_id = #{params.orgId}
|
||||
where is_update = 0 and user_id = #{params.userId}
|
||||
and att_current_day = #{params.attCurrentDay} and att_type = #{params.attType}
|
||||
</foreach>
|
||||
</update>
|
||||
|
|
@ -110,10 +130,31 @@
|
|||
</if>
|
||||
</update>
|
||||
|
||||
<update id="updateAttDataList">
|
||||
<foreach collection="list" item="v" separator=";">
|
||||
update att_data set att_status = #{v.attStatus}
|
||||
where user_id = #{v.userId} and att_current_day = #{v.attCurrentDay}
|
||||
<if test='v.attType != null and v.attType != ""'>
|
||||
and att_type = #{v.attType}
|
||||
</if>
|
||||
</foreach>
|
||||
</update>
|
||||
<update id="updateAttDataUpdateList">
|
||||
<foreach collection="list" item="v" separator=";">
|
||||
update att_data_update set att_status = #{v.attStatus}
|
||||
where is_update = 0 and user_id = #{v.userId}
|
||||
and att_current_day = #{v.attCurrentDay}
|
||||
<if test='v.attType != null and v.attType != ""'>
|
||||
and att_type = #{v.attType}
|
||||
</if>
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="updateHisData">
|
||||
delete
|
||||
from att_source_data
|
||||
where att_current_day = #{date} and data_source != 3;
|
||||
where att_current_day = #{date}
|
||||
and data_source != 3;
|
||||
update att_data
|
||||
set att_current_time = null,
|
||||
att_status = 0,
|
||||
|
|
@ -133,7 +174,8 @@
|
|||
<delete id="delHisData">
|
||||
delete
|
||||
from att_source_data
|
||||
where att_current_day = #{date} and data_source != 3;
|
||||
where att_current_day = #{date}
|
||||
and data_source != 3;
|
||||
delete
|
||||
from att_data
|
||||
where att_current_day = #{date};
|
||||
|
|
@ -148,31 +190,34 @@
|
|||
</delete>
|
||||
|
||||
<select id="getQsyAttendances" resultType="com.bonus.system.att.entity.AttSourceDataBean">
|
||||
select name, id_number, '0' as orgId, '0' as orgName,
|
||||
attendance_date as attCurrentDay, attendance_time as attCurrentTime,
|
||||
CASE attendance_type WHEN '上班' THEN 1 ELSE 2 END as attType,
|
||||
'0' as attAddress, lon as attLon, lat as attLat, '1' as dataSource
|
||||
select name,
|
||||
id_number,
|
||||
'0' as orgId,
|
||||
'0' as orgName,
|
||||
attendance_date as attCurrentDay,
|
||||
attendance_time as attCurrentTime,
|
||||
CASE attendance_type WHEN '上班' THEN 1 ELSE 2 END as attType,
|
||||
'0' as attAddress,
|
||||
lon as attLon,
|
||||
lat as attLat,
|
||||
'1' as dataSource
|
||||
from gz_cloud.fc_sup_attendance sup
|
||||
where sup.attendance_date
|
||||
<if test=' pushType == "1" '>
|
||||
>= #{pushDate}
|
||||
</if>
|
||||
<if test=' pushType == "2" '>
|
||||
= #{pushDate}
|
||||
</if>
|
||||
and is_wechat != 1
|
||||
where sup.attendance_date = #{pushDate}
|
||||
and is_wechat != 1
|
||||
</select>
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<select id="getAllPerson" resultType="com.bonus.system.att.entity.AttDataBean">
|
||||
select su.user_id, agpr.org_id, agpr.group_id, '1' as attType, '0' as attStatus
|
||||
from sys_user su
|
||||
left join att_setting_history agpr on agpr.user_id = su.user_id and agpr.current_day = #{pushDate}
|
||||
where su.is_active = 1 and agpr.org_id is not null
|
||||
left join att_setting_history agpr on agpr.user_id = su.user_id and agpr.current_day = #{pushDate}
|
||||
where su.is_active = 1
|
||||
and agpr.org_id is not null
|
||||
union
|
||||
select su.user_id, agpr.org_id, agpr.group_id, '2' as attType, '0' as attStatus
|
||||
from sys_user su
|
||||
left join att_setting_history agpr on agpr.user_id = su.user_id and agpr.current_day = #{pushDate}
|
||||
where su.is_active = 1 and agpr.org_id is not null
|
||||
left join att_setting_history agpr on agpr.user_id = su.user_id and agpr.current_day = #{pushDate}
|
||||
where su.is_active = 1
|
||||
and agpr.org_id is not null
|
||||
</select>
|
||||
|
||||
<select id="selectAttDayReport" resultType="com.bonus.system.att.entity.AttDayReportBean">
|
||||
|
|
@ -206,52 +251,58 @@
|
|||
|
||||
<!--att_setting_history 的处理是为了获取当月最后一天在哪个考勤规则,去计算他的当月考勤天数 -->
|
||||
<select id="selectAttMonthReport" resultType="com.bonus.system.att.entity.AttMonthReportBean">
|
||||
SELECT
|
||||
g.org_id,
|
||||
v.user_id,
|
||||
su.user_name,
|
||||
so.org_name,
|
||||
g.group_id,
|
||||
DATE_FORMAT( att_current_day, '%Y-%m' ) AS attCurrentMonth,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 1, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 1, 0.5, 0 )), 0 ) AS normalNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 2, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 2, 0.5, 0 )), 0 ) AS lateNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 3, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 3, 0.5, 0 )), 0 ) AS skippingNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 4, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 4, 0.5, 0 )), 0 ) AS earlyNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 5, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 5, 0.5, 0 )), 0 ) AS restNum,
|
||||
sum(
|
||||
IF
|
||||
( toWorkAttStatus IN ( SELECT dict_value FROM sys_dict_data WHERE dict_type = 'att_status' AND is_leave = '1' ), 0.5, 0 ))+ sum(
|
||||
IF
|
||||
( offWorkAttStatus IN ( SELECT dict_value FROM sys_dict_data WHERE dict_type = 'att_status' AND is_leave = '1' ), 0.5, 0 )) AS leaveNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 7, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 7, 0.5, 0 )), 0 ) AS outNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 8, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 8, 0.5, 0 )), 0 ) AS einErrorNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 9, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 9, 0.5, 0 )), 0 ) AS addressErrorNum,
|
||||
IFNULL( sum( IF ( toWorkAttStatus = 10, 0.5, 0 )), 0 ) + IFNULL( sum( IF ( offWorkAttStatus = 10, 0.5, 0 )), 0 ) AS businessTripNum
|
||||
FROM
|
||||
v_att_update_data v
|
||||
LEFT JOIN sys_user su ON su.user_id = v.user_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
( SELECT DISTINCT * FROM att_setting_history WHERE DATE_FORMAT( current_day, '%Y-%m' ) = DATE_FORMAT(#{pushDate}, '%Y-%m' ) ORDER BY current_day DESC ) a
|
||||
GROUP BY
|
||||
user_id
|
||||
) g ON g.user_id = v.user_id
|
||||
LEFT JOIN sys_organization so ON so.id = g.org_id
|
||||
WHERE
|
||||
DATE_FORMAT( att_current_day, '%Y-%m' ) = DATE_FORMAT(#{pushDate}, '%Y-%m' )
|
||||
SELECT g.org_id,
|
||||
v.user_id,
|
||||
su.user_name,
|
||||
so.org_name,
|
||||
g.group_id,
|
||||
DATE_FORMAT(att_current_day, '%Y-%m') AS attCurrentMonth,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 1, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 1, 0.5, 0)), 0) AS normalNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 2, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 2, 0.5, 0)), 0) AS lateNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 3, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 3, 0.5, 0)), 0) AS skippingNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 4, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 4, 0.5, 0)), 0) AS earlyNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 5, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 5, 0.5, 0)), 0) AS restNum,
|
||||
sum(
|
||||
IF
|
||||
(toWorkAttStatus IN
|
||||
(SELECT dict_value FROM sys_dict_data WHERE dict_type = 'att_status' AND is_leave = '1'), 0.5,
|
||||
0)) + sum(
|
||||
IF
|
||||
(offWorkAttStatus IN
|
||||
(SELECT dict_value FROM sys_dict_data WHERE dict_type = 'att_status' AND is_leave = '1'), 0.5,
|
||||
0)) AS leaveNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 7, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 7, 0.5, 0)), 0) AS outNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 8, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 8, 0.5, 0)), 0) AS einErrorNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 9, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 9, 0.5, 0)), 0) AS addressErrorNum,
|
||||
IFNULL(sum(IF(toWorkAttStatus = 10, 0.5, 0)), 0) +
|
||||
IFNULL(sum(IF(offWorkAttStatus = 10, 0.5, 0)), 0) AS businessTripNum
|
||||
FROM v_att_update_data v
|
||||
LEFT JOIN sys_user su ON su.user_id = v.user_id
|
||||
LEFT JOIN (SELECT *
|
||||
FROM (SELECT DISTINCT *
|
||||
FROM att_setting_history
|
||||
WHERE DATE_FORMAT(current_day, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
ORDER BY current_day DESC) a
|
||||
GROUP BY user_id) g ON g.user_id = v.user_id
|
||||
LEFT JOIN sys_organization so ON so.id = g.org_id
|
||||
WHERE DATE_FORMAT(att_current_day, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
AND g.group_id IS NOT NULL
|
||||
GROUP BY
|
||||
DATE_FORMAT( att_current_day, '%Y-%m' ),
|
||||
v.user_id
|
||||
GROUP BY DATE_FORMAT(att_current_day, '%Y-%m'),
|
||||
v.user_id
|
||||
</select>
|
||||
|
||||
<select id="selectHolidayByMonth" resultType="com.bonus.system.att.entity.Holiday">
|
||||
select *
|
||||
from sys_holiday
|
||||
where
|
||||
DATE_FORMAT(`date`, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
where DATE_FORMAT(`date`, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
|
||||
</select>
|
||||
|
||||
<select id="getPersonLeaveApplyStatus" resultType="java.lang.Integer">
|
||||
|
|
@ -269,32 +320,31 @@
|
|||
</select>
|
||||
|
||||
<select id="getSourceAttData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
|
||||
select asd.*,
|
||||
su.user_id,
|
||||
ag.org_id as orgId,
|
||||
ag.group_id as groupId,
|
||||
g.att_type as groupType
|
||||
from att_source_data asd
|
||||
left join sys_user su on su.id_number = asd.id_number
|
||||
left join att_setting_history ag on ag.user_id = su.user_id and ag.current_day = #{pushDate}
|
||||
left join att_group g on g.id = ag.group_id
|
||||
where att_current_day = #{pushDate}
|
||||
and g.id is not null and asd.data_source = 1
|
||||
union
|
||||
select asd.*,
|
||||
su.user_id,
|
||||
ag.org_id as orgId,
|
||||
ag.group_id as groupId,
|
||||
g.att_type as groupType
|
||||
from att_source_data asd
|
||||
left join sys_user su on su.user_name = asd.name
|
||||
left join att_setting_history ag on ag.user_id = su.user_id and ag.current_day = #{pushDate}
|
||||
left join att_group g on g.id = ag.group_id
|
||||
where att_current_day = #{pushDate}
|
||||
and g.id is not null
|
||||
and asd.data_source in (2,3)
|
||||
and (asd.att_type = 1
|
||||
or asd.att_type = 2);
|
||||
SELECT asd.*,
|
||||
su.user_id,
|
||||
ag.group_id AS groupId,
|
||||
g.att_type AS groupType
|
||||
FROM (SELECT * FROM att_source_data WHERE att_current_day = #{pushDate} AND data_source = 1) asd
|
||||
LEFT JOIN sys_user su ON su.id_number = asd.id_number
|
||||
LEFT JOIN att_setting_history ag ON ag.user_id = su.user_id
|
||||
AND ag.current_day = #{pushDate}
|
||||
LEFT JOIN att_group g ON g.id = ag.group_id
|
||||
UNION
|
||||
SELECT asd.*,
|
||||
su.user_id,
|
||||
ag.group_id AS groupId,
|
||||
g.att_type AS groupType
|
||||
FROM (SELECT *
|
||||
FROM att_source_data
|
||||
WHERE att_current_day = #{pushDate}
|
||||
AND data_source IN (2, 3)
|
||||
AND (att_type = 1 OR att_type = 2)) asd
|
||||
LEFT JOIN sys_user su ON su.user_name = asd.
|
||||
NAME
|
||||
LEFT JOIN att_setting_history ag ON ag.user_id = su.user_id
|
||||
AND ag.current_day = #{pushDate}
|
||||
LEFT JOIN att_group g ON g.id = ag.group_id;
|
||||
|
||||
</select>
|
||||
|
||||
<select id="selectAttIsExist" resultType="java.lang.Boolean">
|
||||
|
|
@ -330,37 +380,34 @@
|
|||
left join zkeco.iclock i on i.sn = c.sn
|
||||
left join zkeco.userinfo u on u.userid = c.userid
|
||||
where
|
||||
<if test=' pushType == "1" '>
|
||||
DATE_FORMAT(c.checktime, '%Y-%m-%d') >= #{pushDate}
|
||||
<if test='pushType == "1"'>
|
||||
DATE_FORMAT(c.checktime, '%Y-%m-%d') = #{pushDate}
|
||||
</if>
|
||||
<if test=' pushType == "2" '>
|
||||
DATE_FORMAT(c.checktime, '%Y-%m-%d %H:%i:%s') BETWEEN concat(#{pushDate},' 00:00:00') AND DATE_ADD(DATE_ADD(concat(#{pushDate},' 00:00:00'), INTERVAL 1 DAY), INTERVAL 5 HOUR) - INTERVAL 1 SECOND
|
||||
<if test='pushType == "2"'>
|
||||
DATE_FORMAT(c.checktime, '%Y-%m-%d %H:%i:%s') BETWEEN concat(#{pushDate},' 00:00:00') AND
|
||||
DATE_ADD(DATE_ADD(concat(#{pushDate},' 00:00:00'), INTERVAL 1 DAY), INTERVAL 5 HOUR) - INTERVAL 1 SECOND
|
||||
</if>
|
||||
and u.name != '') a
|
||||
</select>
|
||||
|
||||
<select id="getLeaveData" resultType="com.bonus.system.att.entity.LeaveBean">
|
||||
SELECT
|
||||
agpr.org_id,
|
||||
ag.att_type,
|
||||
la.*,
|
||||
sdd.dict_value AS attStatus
|
||||
FROM
|
||||
leave_apply la
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_label =
|
||||
IF
|
||||
( la.leave_type IS NOT NULL, la.leave_type, la.type )
|
||||
AND sdd.dict_type = 'att_status'
|
||||
LEFT JOIN att_group_person_relation agpr ON la.user_id = agpr.user_id
|
||||
LEFT JOIN att_group ag ON ag.id = agpr.group_id
|
||||
AND ag.is_active = '1'
|
||||
WHERE
|
||||
la.is_active = 1
|
||||
SELECT agpr.org_id,
|
||||
ag.att_type,
|
||||
la.*,
|
||||
sdd.dict_value AS attStatus
|
||||
FROM leave_apply la
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_label =
|
||||
IF
|
||||
(la.leave_type IS NOT NULL, la.leave_type, la.type)
|
||||
AND sdd.dict_type = 'att_status'
|
||||
LEFT JOIN att_group_person_relation agpr ON la.user_id = agpr.user_id
|
||||
LEFT JOIN att_group ag ON ag.id = agpr.group_id
|
||||
AND ag.is_active = '1'
|
||||
WHERE la.is_active = 1
|
||||
AND la.examine_status = 1
|
||||
AND sdd.dict_value IS NOT NULL
|
||||
AND agpr.is_active = 1
|
||||
ORDER BY
|
||||
leave_start_date DESC
|
||||
ORDER BY leave_start_date DESC
|
||||
</select>
|
||||
|
||||
<select id="getLeaveDataByUserId" resultType="java.lang.Integer">
|
||||
|
|
@ -376,4 +423,82 @@
|
|||
from att_data
|
||||
where att_current_day = #{date}
|
||||
</select>
|
||||
<select id="getAttSettingDate" resultType="java.lang.String">
|
||||
SELECT DISTINCT current_day
|
||||
FROM `att_setting_history`
|
||||
WHERE current_day > DATE_ADD(#{startDate}, INTERVAL -#{days} DAY)
|
||||
ORDER BY current_day DESC
|
||||
</select>
|
||||
|
||||
<select id="getAttSettingHistoryDate" resultType="com.bonus.system.att.entity.AttGroupBean">
|
||||
SELECT *
|
||||
FROM (SELECT group_id,
|
||||
user_id,
|
||||
#{currentDay} as currentDay
|
||||
FROM att_group_person_relation
|
||||
WHERE #{currentDay} BETWEEN DATE_FORMAT(effective_time, '%Y-%m-%d')
|
||||
AND DATE_FORMAT(IFNULL(NOW(), expiring_time), '%Y-%m-%d')
|
||||
ORDER BY user_id,
|
||||
effective_time DESC LIMIT 10000000) aa
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
<select id="getAttPerson" resultType="com.bonus.system.att.entity.AttDataBean">
|
||||
SELECT su.user_id,
|
||||
ash.group_id,
|
||||
'1' AS attType,
|
||||
'0' AS attStatus
|
||||
FROM att_setting_history ash
|
||||
LEFT JOIN sys_user su ON ash.user_id = su.user_id
|
||||
AND su.is_active = 1
|
||||
WHERE ash.current_day = #{pushDate}
|
||||
UNION
|
||||
SELECT su.user_id,
|
||||
ash.group_id,
|
||||
'2' AS attType,
|
||||
'0' AS attStatus
|
||||
FROM att_setting_history ash
|
||||
LEFT JOIN sys_user su ON ash.user_id = su.user_id
|
||||
AND su.is_active = 1
|
||||
WHERE ash.current_day = #{pushDate}
|
||||
</select>
|
||||
<select id="getAttDataPerson" resultType="java.lang.Long">
|
||||
SELECT distinct user_id
|
||||
FROM att_data
|
||||
WHERE att_current_day = #{pushDate}
|
||||
</select>
|
||||
<select id="getAttDataByStatus" resultType="com.bonus.system.att.entity.AttDataBean">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
att_data
|
||||
WHERE
|
||||
att_current_day = #{pushDate}
|
||||
AND att_status = 0
|
||||
<if test='attType != ""'>
|
||||
AND att_type = #{attType}
|
||||
</if>
|
||||
</select>
|
||||
<select id="getAttDataUpdateByStatus" resultType="com.bonus.system.att.entity.AttDataBean">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
att_data_update
|
||||
WHERE
|
||||
att_current_day = #{pushDate}
|
||||
AND att_status = 0
|
||||
And is_update = 0
|
||||
<if test='attType != ""'>
|
||||
AND att_type = #{attType}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectHolidayByDay" resultType="com.bonus.system.att.entity.Holiday">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_holiday
|
||||
WHERE
|
||||
date = #{pushDate}
|
||||
AND type = '1'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue