20250103问题修改

This commit is contained in:
fl 2025-01-03 14:12:06 +08:00
parent 7c34233279
commit dc0de44ac3
5 changed files with 297 additions and 274 deletions

View File

@ -142,6 +142,8 @@ public interface AttSourceDataDao {
*/
List<AttSourceDataBean> getSourceAttNoInOutData();
void updateHisData(String date);
void delHisData(String date);
/**
@ -156,4 +158,6 @@ public interface AttSourceDataDao {
* @param longBreakRecords
*/
void insertWorkAbnormal(List<AttSourceDataBean> longBreakRecords);
int getFirstAttendanceData(String date);
}

View File

@ -60,7 +60,7 @@ public class AttTasks {
private volatile boolean executed = false; // 标志位表示任务是否已经执行过
// @Scheduled(cron = "0 0/10 * * * ?")
@Scheduled(initialDelay = 60000, fixedDelay = 60000 * 10)
// @Scheduled(initialDelay = 60000, fixedDelay = 60000 * 10)
@Async
public void getAttTasks() {
log.info("--------考勤定时器开启------");
@ -72,7 +72,7 @@ public class AttTasks {
/**
* 历史考勤数据
*/
// @Scheduled(initialDelay = 60000 * 4,fixedDelay = 60000 * 30)
@Scheduled(initialDelay = 6000 * 4,fixedDelay = 60000 * 30)
@Async
public void getHisAttTasks() {
log.info("--------考勤定时器开启------");
@ -80,22 +80,11 @@ public class AttTasks {
return; // 如果任务已经执行过直接返回
}
executed = true; // 设置标志位表示任务已经执行过
// String startDate = "2024-11-01";
// String endDate = "2024-11-05";
// List<String> dateList = getStrDateListBetween(startDate, endDate);
List<String> dateList = new ArrayList<>();
dateList.add("2024-11-02");
dateList.add("2024-11-03");
dateList.add("2024-11-09");
dateList.add("2024-11-10");
dateList.add("2024-11-16");
dateList.add("2024-11-17");
dateList.add("2024-11-23");
dateList.add("2024-11-24");
dateList.add("2024-11-30");
dateList.add("2024-12-01");
dateList.add("2024-12-07");
dateList.add("2024-12-08");
String startDate = "2024-12-26";
String endDate = "2024-12-26";
List<String> dateList = getStrDateListBetween(startDate, endDate);
// List<String> dateList = new ArrayList<>();
// dateList.add("2024-10-18");
hisAttPush(dateList);
log.info("--------考勤定时器完毕------");
}
@ -132,7 +121,13 @@ public class AttTasks {
private void delHisData(String date) {
attSourceDataDao.delHisData(date);
//查询基础数据是否完备
int i = attSourceDataDao.getFirstAttendanceData(date);
if(i > 0){
attSourceDataDao.updateHisData(date);
}else{
attSourceDataDao.delHisData(date);
}
}
@ -144,7 +139,7 @@ public class AttTasks {
*/
private void pushAttData(String pushDate, int pushType) {
//获取黔送云的考勤数据
getQsyAttendanceData(pushDate, pushType);
// getQsyAttendanceData(pushDate, pushType);
//获取考勤机中的考勤数据
getMachineAttendanceData(pushDate, pushType);
// //查出每一个考勤组的应出勤天数以及考勤组的规则
@ -289,6 +284,9 @@ public class AttTasks {
*/
private void threadLeaveData(LeaveBean c, String pushDate) {
//1.将请假区间变成日期集合
// if(c.getUserId() == 879L){
// System.out.println("徐军");
// }
List<String> dateList = getStrDateListBetween(c.getLeaveStartDate(), c.getLeaveEndDate());
if (!dateList.isEmpty()) {
dateList.forEach(v -> {

View File

@ -46,12 +46,11 @@
<select id="selectAttAllList" resultType="com.bonus.system.att.entity.AttDetailByMonthBean">
select
amr.user_id as userId,
user_id as userId,
name as name,
amr.org_id as orgId,
amr.org_name as orgName,
org_id as orgId,
org_name as orgName,
att_current_month as attCurrentMonth,
count(awa.user_id) as outCount,
coalesce(required_days,0) as requiredDays,
coalesce(normal_num,0) as normalNum,
coalesce(late_num,0) as lateNum,
@ -61,20 +60,21 @@
coalesce(address_error_num,0) as addressErrorNum,
coalesce(ein_error_num,0) as einErrorNum
from att_month_report amr
LEFT JOIN att_work_abnormal awa ON LOCATE(amr.att_current_month,awa.att_current_day) and awa.user_id =
amr.user_id
where amr.is_active = 1
and amr.required_days != amr.normal_num
<if test="attCurrentMonth != null and attCurrentMonth != '' ">
and amr.att_current_month = #{attCurrentMonth}
</if>
<if test="orgId != null and orgId != '' ">
and amr.org_id = #{orgId}
</if>
<if test="name != null and name != '' ">
and INSTR(amr.name,#{name}) > 0
</if>
GROUP BY amr.att_current_month,amr.user_id
<if test="orgId != null and orgId != ''">
AND amr.org_id = #{orgId}
</if>
<if test="name != null and name != ''">
AND amr.name like concat('%', #{name}, '%')
</if>
group by user_id
</select>
<select id="getOrgParentId" resultType="com.bonus.system.basic.domain.SysOrg">

View File

@ -53,7 +53,8 @@
<insert id="insertWorkAbnormal">
<foreach collection="list" item="item" separator=";">
replace into att_work_abnormal(user_id, user_name,org_id, att_current_day,att_current_time, att_address)
values (#{item.userId}, #{item.name},#{item.orgId}, #{item.attCurrentDay}, #{item.attCurrentTime}, #{item.attAddress})
values (#{item.userId}, #{item.name},#{item.orgId}, #{item.attCurrentDay}, #{item.attCurrentTime},
#{item.attAddress})
</foreach>
</insert>
@ -109,252 +110,273 @@
</if>
</update>
<!-- <delete id="delHisData">-->
<!-- delete from att_source_data where att_current_day = #{date};-->
<!-- delete from att_data where att_current_day = #{date};-->
<!-- delete from att_data_update where att_current_day = #{date};-->
<!-- </delete>-->
<delete id="delHisData">
delete from att_source_data where att_current_day = #{date};
update att_data set att_current_time = null,att_status = 0,att_address = null,att_lon = null,att_lat = null where att_current_day = #{date};
update att_data_update set att_current_time = null,att_status = 0,att_address = null,att_lon = null,att_lat = null where att_current_day = #{date};
<delete id="updateHisData">
delete
from att_source_data
where att_current_day = #{date} and data_source != 3;
update att_data
set att_current_time = null,
att_status = 0,
att_address = null,
att_lon = null,
att_lat = null
where att_current_day = #{date};
update att_data_update
set att_current_time = null,
att_status = 0,
att_address = null,
att_lon = null,
att_lat = null
where att_current_day = #{date};
</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
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
</select>
<delete id="delHisData">
delete
from att_source_data
where att_current_day = #{date} and data_source != 3;
delete
from att_data
where att_current_day = #{date};
delete
from att_data_update
where att_current_day = #{date};
</delete>
<select id="getAllPerson" resultType="com.bonus.system.att.entity.AttDataBean">
select su.user_id, agpr.org_id, g.id as groupId, '1' as attType, '0' as attStatus
from sys_user su
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
left join att_group g on g.id = agpr.group_id
where su.is_active = 1
and agpr.org_id is not null
union
select su.user_id, agpr.org_id, g.id as groupId, '2' as attType, '0' as attStatus
from sys_user su
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
left join att_group g on g.id = agpr.group_id
where su.is_active = 1
and agpr.org_id is not null
</select>
<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
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
</select>
<select id="selectAttDayReport" resultType="com.bonus.system.att.entity.AttDayReportBean">
select att_current_day,
org_id,
IFNULL(sum(toWorkAttStatus = 1 and offWorkAttStatus = 1), 0) as normalNum,
IFNULL(sum(toWorkAttStatus = 2 or offWorkAttStatus = 2), 0) as lateNum,
IFNULL(sum(toWorkAttStatus = 3 or offWorkAttStatus = 3), 0) as skippingNum,
IFNULL(sum(toWorkAttStatus = 4 or offWorkAttStatus = 4), 0) as earlyNum,
IFNULL(sum(toWorkAttStatus = 5 or offWorkAttStatus = 5), 0) as restNum,
IFNULL(sum(toWorkAttStatus in (12, 13, 14, 15, 16, 17, 18) or
offWorkAttStatus in (12, 13, 14, 15, 16, 17, 18)), 0) as leaveNum,
IFNULL(sum(toWorkAttStatus = 7 or offWorkAttStatus = 7), 0) as outNum,
IFNULL(sum(toWorkAttStatus = 8 or offWorkAttStatus = 8), 0) as einErrorNum,
IFNULL(sum(toWorkAttStatus = 9 or offWorkAttStatus = 9), 0) as addressErrorNum
from v_att_update_data
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
GROUP BY att_current_day, org_id
</select>
<select id="getAllPerson" resultType="com.bonus.system.att.entity.AttDataBean">
select su.user_id, agpr.org_id, g.id as groupId, '1' as attType, '0' as attStatus
from sys_user su
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
left join att_group g on g.id = agpr.group_id
where su.is_active = 1
and agpr.org_id is not null
union
select su.user_id, agpr.org_id, g.id as groupId, '2' as attType, '0' as attStatus
from sys_user su
left join att_group_person_relation agpr on agpr.user_id = su.user_id and agpr.is_active = 1
left join att_group g on g.id = agpr.group_id
where su.is_active = 1
and agpr.org_id is not null
</select>
<select id="selectAttMonthReport" resultType="com.bonus.system.att.entity.AttMonthReportBean">
select v.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(toWorkAttStatus = 1 and offWorkAttStatus = 1), 0) as normalNum,
IFNULL(sum(toWorkAttStatus = 2 or offWorkAttStatus = 2), 0) as lateNum,
IFNULL(sum(toWorkAttStatus = 3 or offWorkAttStatus = 3), 0) as skippingNum,
IFNULL(sum(toWorkAttStatus = 4 or offWorkAttStatus = 4), 0) as earlyNum,
IFNULL(sum(toWorkAttStatus = 5 or offWorkAttStatus = 5), 0) as restNum,
IFNULL(sum(toWorkAttStatus in (12, 13, 14, 15, 16, 17, 18) or
offWorkAttStatus in (12, 13, 14, 15, 16, 17, 18)), 0) as leaveNum,
IFNULL(sum(toWorkAttStatus = 7 or offWorkAttStatus = 7), 0) as outNum,
IFNULL(sum(toWorkAttStatus = 8 or offWorkAttStatus = 8), 0) as einErrorNum,
IFNULL(sum(toWorkAttStatus = 9 or offWorkAttStatus = 9), 0) as addressErrorNum
from v_att_update_data v
left join sys_user su on su.user_id = v.user_id
left join sys_organization so on so.id = v.org_id
left join att_group_person_relation g
on g.user_id = v.user_id and g.org_id = v.org_id and g.is_active = 1
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.org_id, v.user_id;
</select>
<select id="selectAttDayReport" resultType="com.bonus.system.att.entity.AttDayReportBean">
select att_current_day,
org_id,
IFNULL(sum(toWorkAttStatus = 1 and offWorkAttStatus = 1), 0) as normalNum,
IFNULL(sum(toWorkAttStatus = 2 or offWorkAttStatus = 2), 0) as lateNum,
IFNULL(sum(toWorkAttStatus = 3 or offWorkAttStatus = 3), 0) as skippingNum,
IFNULL(sum(toWorkAttStatus = 4 or offWorkAttStatus = 4), 0) as earlyNum,
IFNULL(sum(toWorkAttStatus = 5 or offWorkAttStatus = 5), 0) as restNum,
IFNULL(sum(toWorkAttStatus in (12, 13, 14, 15, 16, 17, 18) or
offWorkAttStatus in (12, 13, 14, 15, 16, 17, 18)), 0) as leaveNum,
IFNULL(sum(toWorkAttStatus = 7 or offWorkAttStatus = 7), 0) as outNum,
IFNULL(sum(toWorkAttStatus = 8 or offWorkAttStatus = 8), 0) as einErrorNum,
IFNULL(sum(toWorkAttStatus = 9 or offWorkAttStatus = 9), 0) as addressErrorNum
from v_att_update_data
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
GROUP BY att_current_day, org_id
</select>
<select id="selectHolidayByMonth" resultType="com.bonus.system.att.entity.Holiday">
select *
from sys_holiday
where `date`
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
</select>
<select id="selectAttMonthReport" resultType="com.bonus.system.att.entity.AttMonthReportBean">
select v.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(toWorkAttStatus = 1 and offWorkAttStatus = 1), 0) as normalNum,
IFNULL(sum(toWorkAttStatus = 2 or offWorkAttStatus = 2), 0) as lateNum,
IFNULL(sum(toWorkAttStatus = 3 or offWorkAttStatus = 3), 0) as skippingNum,
IFNULL(sum(toWorkAttStatus = 4 or offWorkAttStatus = 4), 0) as earlyNum,
IFNULL(sum(toWorkAttStatus = 5 or offWorkAttStatus = 5), 0) as restNum,
IFNULL(sum(toWorkAttStatus in (12, 13, 14, 15, 16, 17, 18) or
offWorkAttStatus in (12, 13, 14, 15, 16, 17, 18)), 0) as leaveNum,
IFNULL(sum(toWorkAttStatus = 7 or offWorkAttStatus = 7), 0) as outNum,
IFNULL(sum(toWorkAttStatus = 8 or offWorkAttStatus = 8), 0) as einErrorNum,
IFNULL(sum(toWorkAttStatus = 9 or offWorkAttStatus = 9), 0) as addressErrorNum
from v_att_update_data v
left join sys_user su on su.user_id = v.user_id
left join sys_organization so on so.id = v.org_id
left join att_group_person_relation g
on g.user_id = v.user_id and g.org_id = v.org_id and g.is_active = 1
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.org_id, v.user_id;
</select>
<select id="getPersonLeaveApplyStatus" resultType="java.lang.Integer">
select DISTINCT sdd.dict_value
from leave_apply la
left join sys_dict_data sdd on sdd.dict_label = la.leave_type
where user_id = #{userId}
and org_id = #{orgId}
and CONCAT(#{attCurrentDay}, '|', #{attType})
BETWEEN CONCAT(leave_start_date, '|', leave_start_interval)
AND CONCAT(leave_end_date, '|', leave_end_interval)
AND examine_status = 1
GROUP BY la.user_id
ORDER BY la.create_time DESC
</select>
<select id="selectHolidayByMonth" resultType="com.bonus.system.att.entity.Holiday">
select *
from sys_holiday
where `date`
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
</select>
<select id="getSourceAttData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and g.id is not null and asd.data_source = 1
union
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and g.id is not null
and asd.data_source in (2,3)
and (asd.att_type = 1
or asd.att_type = 2);
</select>
<select id="getPersonLeaveApplyStatus" resultType="java.lang.Integer">
select DISTINCT sdd.dict_value
from leave_apply la
left join sys_dict_data sdd on sdd.dict_label = la.leave_type
where user_id = #{userId}
and org_id = #{orgId}
and CONCAT(#{attCurrentDay}, '|', #{attType})
BETWEEN CONCAT(leave_start_date, '|', leave_start_interval)
AND CONCAT(leave_end_date, '|', leave_end_interval)
AND examine_status = 1
GROUP BY la.user_id
ORDER BY la.create_time DESC
</select>
<select id="selectAttIsExist" resultType="java.lang.Boolean">
SELECT count(0)
FROM att_data
WHERE user_id = #{userId}
and org_id = #{orgId}
and att_type = #{attType}
and att_current_day = #{attCurrentDay}
</select>
<select id="getSourceAttData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and g.id is not null and asd.data_source = 1
union
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and g.id is not null
and asd.data_source in (2,3)
and (asd.att_type = 1
or asd.att_type = 2);
</select>
<select id="selectAttUpdateIsExist" resultType="java.lang.Boolean">
SELECT count(0)
FROM att_data_update
WHERE user_id = #{userId}
and org_id = #{orgId}
and att_type = #{attType}
and att_current_day = #{attCurrentDay}
</select>
<select id="selectAttIsExist" resultType="java.lang.Boolean">
SELECT count(0)
FROM att_data
WHERE user_id = #{userId}
and org_id = #{orgId}
and att_type = #{attType}
and att_current_day = #{attCurrentDay}
</select>
<select id="getMachineAttendances" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select *
from (select u.name,
'0' as idNumber,
'0' as orgId,
'0' as orgName,
DATE_FORMAT(c.checktime, '%Y-%m-%d') as attCurrentDay,
DATE_FORMAT(c.checktime, '%Y-%m-%d %H:%i:%s') as attCurrentTime,
if(i.alias like '%进%', 1, (if(i.alias like '%出%', 2, 0))) as attType,
i.alias as attAddress,
'0' as attLon,
'0' as attLat,
'2' as dataSource
from zkeco.checkinout c
left join zkeco.iclock i on i.sn = c.sn
left join zkeco.userinfo u on u.userid = c.userid
where DATE_FORMAT(c.checktime, '%Y-%m-%d')
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and u.name != '') a
</select>
<select id="selectAttUpdateIsExist" resultType="java.lang.Boolean">
SELECT count(0)
FROM att_data_update
WHERE user_id = #{userId}
and org_id = #{orgId}
and att_type = #{attType}
and att_current_day = #{attCurrentDay}
</select>
<select id="getLeaveData" resultType="com.bonus.system.att.entity.LeaveBean">
SELECT la.*,
sdd.dict_value AS attStatus
FROM leave_apply la
LEFT JOIN sys_dict_data sdd ON sdd.dict_label = if(la.type is not null,la.type,la.leave_type)
AND sdd.dict_type = 'att_status'
LEFT JOIN att_group_person_relation agpr ON la.user_id = agpr.user_id
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
</select>
<select id="getMachineAttendances" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select *
from (select u.name,
'0' as idNumber,
'0' as orgId,
'0' as orgName,
DATE_FORMAT(c.checktime, '%Y-%m-%d') as attCurrentDay,
DATE_FORMAT(c.checktime, '%Y-%m-%d %H:%i:%s') as attCurrentTime,
if(i.alias like '%进%', 1, (if(i.alias like '%出%', 2, 0))) as attType,
i.alias as attAddress,
'0' as attLon,
'0' as attLat,
'2' as dataSource
from zkeco.checkinout c
left join zkeco.iclock i on i.sn = c.sn
left join zkeco.userinfo u on u.userid = c.userid
where DATE_FORMAT(c.checktime, '%Y-%m-%d')
<if test=' pushType == "1" '>
>= #{pushDate}
</if>
<if test=' pushType == "2" '>
= #{pushDate}
</if>
and u.name != '') a
</select>
<select id="getSourceAttNoInOutData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day >= CURDATE()
and g.id is not null
and asd.data_source = 2
and asd.att_type = 0
</select>
<select id="getLeaveData" resultType="com.bonus.system.att.entity.LeaveBean">
SELECT la.*,
sdd.dict_value AS attStatus
FROM leave_apply la
LEFT JOIN sys_dict_data sdd ON sdd.dict_label = if(la.type is not null, la.type, la.leave_type)
AND sdd.dict_type = 'att_status'
LEFT JOIN att_group_person_relation agpr ON la.user_id = agpr.user_id
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
</select>
<select id="getLeaveDataByUserId" resultType="java.lang.Integer">
SELECT
count(1)
FROM
leave_apply la
WHERE
la.is_active = 1
AND la.examine_status = 1
AND user_id = #{userId}
AND #{attCurrentDay} BETWEEN leave_start_date and leave_end_date
</select>
</mapper>
<select id="getSourceAttNoInOutData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
select asd.*,
su.user_id,
ag.org_id as orgId,
g.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_group_person_relation ag on ag.user_id = su.user_id and ag.is_active = 1
left join att_group g on g.id = ag.group_id
where att_current_day >= CURDATE()
and g.id is not null
and asd.data_source = 2
and asd.att_type = 0
</select>
<select id="getLeaveDataByUserId" resultType="java.lang.Integer">
SELECT count(1)
FROM leave_apply la
WHERE la.is_active = 1
AND la.examine_status = 1
AND user_id = #{userId}
AND #{attCurrentDay} BETWEEN leave_start_date and leave_end_date
</select>
<select id="getFirstAttendanceData" resultType="java.lang.Integer">
select count(0)
from att_data
where att_current_day = #{date}
</select>
</mapper>

View File

@ -5,7 +5,7 @@
<mapper namespace="com.bonus.system.att.dao.AttendanceDetailsDao">
<select id="selectAttDetailsList" resultType="com.bonus.system.att.entity.AttDataDetailsBean">
select su.user_name, so.org_name,COUNT( awa.user_id ) as outCount,
select su.user_name, so.org_name,COUNT( DISTINCT awa.user_id ) as outCount,
COUNT(DISTINCT asd.att_current_time ) AS attCount,
v.* from v_att_update_data v
left join sys_user su on su.user_id = v.user_id
@ -161,18 +161,18 @@
<select id="getAttDayReportList" resultType="com.bonus.system.att.entity.AttDayReportBean">
SELECT adr.*,
COUNT(awa.user_id) as outCount
IF(awa.outCount is null,0,awa.outCount) as outCount
FROM att_day_report adr
LEFT JOIN att_work_abnormal awa
LEFT JOIN (SELECT att_current_day,org_id,count( DISTINCT user_id) as outCount FROM att_work_abnormal GROUP BY att_current_day,org_id) awa
ON awa.att_current_day = adr.att_current_day and awa.org_id = adr.org_id
WHERE adr.att_current_day BETWEEN #{startDate} AND #{endDate}
GROUP BY adr.att_current_day
</select>
<select id="getAttMonthReportList" resultType="com.bonus.system.att.entity.AttMonthReportBean">
select v.*, v.name as userName,count(awa.user_id) as outCount from att_month_report v
select v.*, v.name as userName,IF(awa.outCount is null,0,awa.outCount) as outCount from att_month_report v
left join att_group_person_relation p on p.user_id = v.user_id and p.is_active = 1
LEFT JOIN att_work_abnormal awa ON LOCATE(v.att_current_month,awa.att_current_day) and awa.user_id = v.user_id
LEFT JOIN (SELECT user_id,count(user_id) as outCount FROM att_work_abnormal WHERE LOCATE(#{month},att_current_day) GROUP BY user_id) awa ON awa.user_id = v.user_id
where v.att_current_month = #{month} and p.group_id is not null
<if test="orgId != null and orgId != ''">
AND v.org_id = #{orgId}
@ -180,7 +180,6 @@
<if test="userName != null and userName != ''">
AND v.name like concat('%', #{userName}, '%')
</if>
GROUP BY v.att_current_month,v.user_id
</select>
<select id="getAttDayReportDetailsList" resultType="com.bonus.system.att.entity.AttDataDetailsBean">
@ -326,7 +325,7 @@
and att_current_day = #{attCurrentDay}
</if>
<if test="userName != null and userName != ''">
and locate(#{userName},awa.user_name)
and `name` = #{userName}
</if>
</where>
ORDER BY