gz_att/bonus-modules/bonus-system/src/main/resources/mapper/att/AttSourceDataMapper.xml

519 lines
23 KiB
XML
Raw Normal View History

2024-12-02 11:13:48 +08:00
<?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.bonus.system.att.dao.AttSourceDataDao">
<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, province,is_outside_att, att_lon, att_lat, data_source, remark)
2024-12-02 11:13:48 +08:00
values (#{params.name}, #{params.idNumber}, #{params.orgId}, #{params.orgName},
#{params.attCurrentDay}, #{params.attCurrentTime}, #{params.attType},
2025-02-26 14:33:33 +08:00
#{params.attAddress}, #{params.province},#{params.isOutsideAtt}, #{params.attLon}, #{params.attLat},
#{params.dataSource},
2025-02-17 18:09:39 +08:00
#{params.remark})
2024-12-02 11:13:48 +08:00
</foreach>
</insert>
<insert id="insertAttData">
insert into att_data(user_id, org_id, att_current_day, att_status, att_type)
values (#{userId}, #{orgId}, #{attCurrentDay}, #{attStatus}, #{attType})
</insert>
<insert id="insertAttDayReport">
<foreach collection="list" item="params" separator=";">
replace into att_day_report(att_current_day, normal_num, late_num, early_num, skipping_num,
leave_num, address_error_num, ein_error_num, rest_num, out_num,outside_att_num,train_num)
values (#{params.attCurrentDay}, #{params.normalNum}, #{params.lateNum},
2024-12-02 11:13:48 +08:00
#{params.earlyNum}, #{params.skippingNum}, #{params.leaveNum},
2025-02-26 14:33:33 +08:00
#{params.addressErrorNum}, #{params.einErrorNum}, #{params.restNum}, #{params.outNum},
#{params.outsideAttNum},#{params.trainNum})
2024-12-02 11:13:48 +08:00
</foreach>
</insert>
<insert id="insertHoliday">
insert into sys_holiday(date, name, type)
values (#{date}, #{name}, #{type})
</insert>
<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)
2025-01-03 14:12:06 +08:00
values (#{item.userId}, #{item.name},#{item.orgId}, #{item.attCurrentDay}, #{item.attCurrentTime},
#{item.attAddress})
</foreach>
</insert>
2025-02-17 18:09:39 +08:00
<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">
2025-02-18 11:11:38 +08:00
insert into att_data(user_id, org_id, att_current_day, att_status, att_type)
2025-02-17 18:09:39 +08:00
values
<foreach collection="list" item="item" separator=",">
2025-02-18 11:11:38 +08:00
(#{item.userId}, #{item.orgId}, #{item.attCurrentDay}, #{item.attStatus}, #{item.attType})
2025-02-17 18:09:39 +08:00
</foreach>
;
2025-02-18 11:11:38 +08:00
insert into att_data_update(user_id, org_id, att_current_day, att_status, att_type)
2025-02-17 18:09:39 +08:00
values
<foreach collection="list" item="item" separator=",">
2025-02-18 11:11:38 +08:00
(#{item.userId}, #{item.orgId}, #{item.attCurrentDay}, #{item.attStatus}, #{item.attType})
2025-02-17 18:09:39 +08:00
</foreach>
;
</insert>
2025-02-18 21:01:41 +08:00
<insert id="insertAttMonthReportTemp">
insert into att_month_report(user_id, name, org_id, org_name, att_current_month,
required_days)
values
<foreach collection="list" item="params" separator=",">
2025-02-26 14:33:33 +08:00
(#{params.userId}, #{params.userName}, #{params.orgId}, #{params.orgName},
2025-02-18 21:01:41 +08:00
#{params.attCurrentMonth}, #{params.requiredDays})
</foreach>
</insert>
2024-12-02 11:13:48 +08:00
<update id="updateAttStatusData">
<foreach collection="list" item="params" separator=";">
update att_data set att_current_time = #{params.attCurrentTime},
att_address = #{params.attAddress}, province = #{params.province},
is_outside_att = #{params.isOutsideAtt},
att_lon = #{params.attLon},
att_lat = #{params.attLat},
2024-12-02 11:13:48 +08:00
data_source = #{params.dataSource},
2025-01-23 18:22:02 +08:00
error_remake = #{params.remark},
2024-12-02 11:13:48 +08:00
att_status = CASE
2024-12-26 11:24:17 +08:00
WHEN att_status in (SELECT dict_value
FROM sys_dict_data
2025-01-07 01:47:43 +08:00
where dict_type = 'att_status' and (is_leave = '1' or is_leave = '2') ) THEN att_status
2024-12-02 11:13:48 +08:00
ELSE #{params.attStatus}
END
2025-02-17 18:09:39 +08:00
where user_id = #{params.userId}
2024-12-02 11:13:48 +08:00
AND att_current_day = #{params.attCurrentDay} and att_type = #{params.attType};
2025-02-13 16:49:21 +08:00
2024-12-02 11:13:48 +08:00
update att_data_update set att_current_time = #{params.attCurrentTime},
att_address = #{params.attAddress}, province = #{params.province},
is_outside_att = #{params.isOutsideAtt},
att_lon = #{params.attLon},
att_lat = #{params.attLat},
2024-12-02 11:13:48 +08:00
data_source = #{params.dataSource},
2025-01-23 18:22:02 +08:00
error_remake = #{params.remark},
2024-12-02 11:13:48 +08:00
att_status = CASE
2024-12-26 11:24:17 +08:00
WHEN att_status in (SELECT dict_value
FROM sys_dict_data
2025-01-07 01:47:43 +08:00
where dict_type = 'att_status' and (is_leave = '1' or is_leave = '2')) THEN att_status
2024-12-02 11:13:48 +08:00
ELSE #{params.attStatus}
END
2025-02-17 18:09:39 +08:00
where is_update = 0 and user_id = #{params.userId}
2024-12-02 11:13:48 +08:00
and att_current_day = #{params.attCurrentDay} and att_type = #{params.attType}
</foreach>
</update>
2025-02-17 18:09:39 +08:00
<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>
2025-02-18 11:11:38 +08:00
<update id="updateLeaveData">
update att_data
set att_status = CASE
WHEN att_status = '11' THEN att_status
ELSE #{v.attStatus}
END
where user_id = #{v.userId}
and att_current_day = #{v.attCurrentDay}
and att_type = #{v.attType};
update att_data_update
set att_status = CASE
WHEN att_status = '11' THEN att_status
ELSE #{v.attStatus}
END
where user_id = #{v.userId}
and att_current_day = #{v.attCurrentDay}
and att_type = #{v.attType}
and is_update = 0;
</update>
2025-02-18 21:01:41 +08:00
<update id="updateAttMonthReport">
<foreach collection="list" item="v" separator=";">
update att_month_report
2025-02-26 14:33:33 +08:00
set
<if test='v.orgId != null'>
org_id = #{v.orgId},
</if>
<if test='v.orgName != null'>
org_name = #{v.orgName},
</if>
normal_num = #{v.normalNum},
late_num = #{v.lateNum},
early_num = #{v.earlyNum},
skipping_num = #{v.skippingNum},
leave_num = #{v.leaveNum},
2025-02-18 21:01:41 +08:00
address_error_num = #{v.addressErrorNum},
2025-02-26 14:33:33 +08:00
ein_error_num = #{v.einErrorNum},
rest_num = #{v.restNum},
out_num = #{v.outNum},
business_trip_num = #{v.businessTripNum},
train_num = #{v.trainNum},
2025-02-26 14:33:33 +08:00
outside_att_num = #{v.outsideAttNum}
2025-02-18 21:01:41 +08:00
where
user_id = #{v.userId}
and att_current_month = #{v.attCurrentMonth}
</foreach>
</update>
2025-02-19 20:02:19 +08:00
<update id="updateMonthReportRequiredDay">
update att_month_report
set required_days = #{requiredDays}
where user_id = #{userId}
and att_current_month = DATE_FORMAT(#{nowDate}, '%Y-%m')
</update>
2025-02-18 11:11:38 +08:00
2025-01-03 14:12:06 +08:00
<select id="getQsyAttendances" resultType="com.bonus.system.att.entity.AttSourceDataBean">
2025-02-17 18:09:39 +08:00
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,
2025-02-26 14:33:33 +08:00
IF(attendance_external = '外勤打卡', 1, 2) as isOutsideAtt,
2025-02-17 18:09:39 +08:00
'1' as dataSource
from gz_cloud.fc_sup_attendance sup
2025-02-17 18:09:39 +08:00
where sup.attendance_date = #{pushDate}
and is_wechat != 1
2025-01-03 14:12:06 +08:00
</select>
2025-02-17 18:09:39 +08:00
<!-- -->
2025-01-03 14:12:06 +08:00
<select id="getAllPerson" resultType="com.bonus.system.att.entity.AttDataBean">
2025-01-20 13:41:32 +08:00
select su.user_id, agpr.org_id, agpr.group_id, '1' as attType, '0' as attStatus
2025-01-03 14:12:06 +08:00
from sys_user su
2025-02-17 18:09:39 +08:00
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
2025-01-03 14:12:06 +08:00
union
2025-01-20 13:41:32 +08:00
select su.user_id, agpr.org_id, agpr.group_id, '2' as attType, '0' as attStatus
2025-01-03 14:12:06 +08:00
from sys_user su
2025-02-17 18:09:39 +08:00
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
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<select id="selectAttDayReport" resultType="com.bonus.system.att.entity.AttDayReportBean">
select att_current_day,
2025-02-26 14:33:33 +08:00
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 (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status'
and is_leave = '1') or
offWorkAttStatus in (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status'
and is_leave = '1')), 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,
IFNULL(sum(toWorkAttStatus = 26 or offWorkAttStatus = 26), 0) as outsideAttNum,
IFNULL(sum(toWorkAttStatus = 28 or offWorkAttStatus = 28), 0) as trainNum
2025-01-03 14:12:06 +08:00
from v_att_update_data
2025-02-18 21:01:41 +08:00
where att_current_day = #{pushDate}
GROUP BY att_current_day
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
<!--att_setting_history 的处理是为了获取当月最后一天在哪个考勤规则,去计算他的当月考勤天数 -->
2025-01-03 14:12:06 +08:00
<select id="selectAttMonthReport" resultType="com.bonus.system.att.entity.AttMonthReportBean">
2025-02-26 14:33:33 +08:00
SELECT v.user_id,
su.user_name,
suo.org_id,
so.org_name,
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,
IFNULL(sum(IF(toWorkAttStatus = 28, 0.5, 0)), 0) +
IFNULL(sum(IF(offWorkAttStatus = 28, 0.5, 0)), 0) AS trainNum,
2025-02-26 15:16:58 +08:00
IFNULL(sum(IF(toWorkAttStatus = 26, 0.5, 0)), 0) +
IFNULL(sum(IF(offWorkAttStatus = 26, 0.5, 0)), 0) AS outsideAttNum
2025-02-26 14:33:33 +08:00
FROM v_att_update_data v
LEFT JOIN sys_user su ON su.user_id = v.user_id
LEFT JOIN sys_user_org suo ON suo.user_id = v.user_id
LEFT JOIN sys_organization so ON so.id = suo.org_id
WHERE DATE_FORMAT(att_current_day, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
GROUP BY DATE_FORMAT(att_current_day, '%Y-%m'),
v.user_id
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<select id="selectHolidayByMonth" resultType="com.bonus.system.att.entity.Holiday">
select *
from sys_holiday
2025-02-17 18:09:39 +08:00
where DATE_FORMAT(`date`, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<select id="getSourceAttData" resultType="com.bonus.system.att.entity.AttSourceDataBean">
2025-02-17 18:09:39 +08:00
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;
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<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
2025-01-07 01:47:43 +08:00
where
2025-02-17 18:09:39 +08:00
<if test='pushType == "1"'>
DATE_FORMAT(c.checktime, '%Y-%m-%d') = #{pushDate}
2025-01-03 14:12:06 +08:00
</if>
2025-02-17 18:09:39 +08:00
<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
2025-01-03 14:12:06 +08:00
</if>
and u.name != '') a
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<select id="getLeaveData" resultType="com.bonus.system.att.entity.LeaveBean">
2025-02-18 11:11:38 +08:00
SELECT la.*,
2025-02-17 18:09:39 +08:00
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'
WHERE la.is_active = 1
2025-01-03 14:12:06 +08:00
AND la.examine_status = 1
AND sdd.dict_value IS NOT NULL
AND
(leave_start_date BETWEEN #{pushDate} - INTERVAL 15 DAY
2025-02-18 11:11:38 +08:00
and #{pushDate}
or #{pushDate} between leave_start_date and leave_end_date
)
2025-02-18 11:11:38 +08:00
ORDER BY
leave_start_date
2025-01-03 14:12:06 +08:00
</select>
2024-12-02 11:13:48 +08:00
2025-01-03 14:12:06 +08:00
<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>
2025-02-17 18:09:39 +08:00
<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>
2025-02-17 18:09:39 +08:00
<select id="getAttPerson" resultType="com.bonus.system.att.entity.AttDataBean">
2025-02-21 16:24:49 +08:00
SELECT ash.user_id,
2025-02-17 18:09:39 +08:00
ash.group_id,
2025-02-18 11:11:38 +08:00
suo.org_id,
2025-02-26 14:33:33 +08:00
'1' AS attType,
#{pushDate} AS attCurrentDay,
2025-02-26 14:33:33 +08:00
'0' AS attStatus
2025-02-17 18:09:39 +08:00
FROM att_setting_history ash
LEFT JOIN sys_user su ON ash.user_id = su.user_id
2025-02-18 11:11:38 +08:00
left join sys_user_org suo ON su.user_id = suo.user_id
2025-02-26 14:33:33 +08:00
WHERE ash.current_day = #{pushDate}
and suo.org_id is not null
2025-02-17 18:09:39 +08:00
UNION
2025-02-21 16:24:49 +08:00
SELECT ash.user_id,
2025-02-17 18:09:39 +08:00
ash.group_id,
2025-02-18 11:11:38 +08:00
suo.org_id,
2025-02-26 14:33:33 +08:00
'2' AS attType,
#{pushDate} AS attCurrentDay,
2025-02-26 14:33:33 +08:00
'0' AS attStatus
2025-02-17 18:09:39 +08:00
FROM att_setting_history ash
LEFT JOIN sys_user su ON ash.user_id = su.user_id
2025-02-18 11:11:38 +08:00
left join sys_user_org suo ON su.user_id = suo.user_id
2025-02-26 14:33:33 +08:00
WHERE ash.current_day = #{pushDate}
and suo.org_id is not null
2025-02-17 18:09:39 +08:00
</select>
2025-02-17 18:09:39 +08:00
<select id="getAttDataPerson" resultType="java.lang.Long">
SELECT distinct user_id
FROM att_data
WHERE att_current_day = #{pushDate}
</select>
2025-02-17 18:09:39 +08:00
<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 != ""'>
2025-02-17 18:09:39 +08:00
AND att_type = #{attType}
</if>
</select>
2025-02-17 18:09:39 +08:00
<select id="getAttDataUpdateByStatus" resultType="com.bonus.system.att.entity.AttDataBean">
SELECT
*
FROM
att_data_update
WHERE
att_current_day = #{pushDate}
AND att_status = 0
2025-02-18 11:11:38 +08:00
And is_update = 0
<if test='attType != ""'>
2025-02-17 18:09:39 +08:00
AND att_type = #{attType}
</if>
</select>
2025-02-17 18:09:39 +08:00
<select id="selectHolidayByDay" resultType="com.bonus.system.att.entity.Holiday">
2025-02-18 11:11:38 +08:00
SELECT *
FROM sys_holiday
2025-02-17 18:09:39 +08:00
WHERE
2025-02-18 11:11:38 +08:00
date = #{pushDate}
AND type = '1'
2025-02-17 18:09:39 +08:00
</select>
2025-02-18 21:01:41 +08:00
<select id="selectAttMonthReportTemp" resultType="com.bonus.system.att.entity.AttMonthReportBean">
2025-02-26 14:33:33 +08:00
SELECT su.user_id,
su.user_name,
suo.org_id,
so.org_name,
ash.group_id,
DATE_FORMAT(#{pushDate}, '%Y-%m') as attCurrentMonth
FROM att_setting_history ash
LEFT JOIN sys_user su ON su.user_id = ash.user_id
LEFT JOIN sys_user_org suo ON suo.user_id = su.user_id
LEFT JOIN sys_organization so ON so.id = suo.org_id
WHERE DATE_FORMAT(ash.current_day, '%Y-%m') = DATE_FORMAT(#{pushDate}, '%Y-%m')
and suo.org_id is not null
GROUP BY DATE_FORMAT(#{pushDate}, '%Y-%m'),
su.user_id
2025-02-18 21:01:41 +08:00
</select>
<select id="getAttMonthReportPerson" resultType="java.lang.Long">
2025-02-26 14:33:33 +08:00
SELECT user_id
FROM att_month_report
WHERE att_current_month = DATE_FORMAT(#{pushDate}, '%Y-%m')
</select>
2025-02-19 20:02:19 +08:00
<select id="getMonthReportTempDataIsExist" resultType="java.lang.Integer">
2025-02-26 14:33:33 +08:00
SELECT count(1)
FROM att_month_report
WHERE att_current_month = DATE_FORMAT(#{pushDate}, '%Y-%m')
and user_id = #{userId}
2025-02-19 20:02:19 +08:00
</select>
2025-02-19 20:02:19 +08:00
<select id="getAttSettingHistoryByUserAndDate" resultType="com.bonus.system.att.entity.AttGroupBean">
2025-02-26 14:33:33 +08:00
SELECT ash.group_id,
ash.user_id,
ash.current_day
from att_setting_history ash
WHERE ash.user_id = #{userId}
and locate(DATE_FORMAT(#{nowDate}, '%Y-%m'), ash.current_day)
order by current_day ASC
2025-02-19 20:02:19 +08:00
</select>
2025-02-19 20:02:19 +08:00
<select id="getOrgDataByUserId" resultType="com.bonus.system.att.entity.AttMonthReportBean">
2025-02-26 14:33:33 +08:00
SELECT su.user_id,
su.user_name,
suo.org_id,
so.org_name
FROM sys_user su
LEFT JOIN sys_user_org suo ON suo.user_id = su.user_id
LEFT JOIN sys_organization so ON so.id = suo.org_id
2025-02-19 20:02:19 +08:00
where su.user_id = #{userId}
</select>
2025-02-18 21:01:41 +08:00
2025-01-03 14:12:06 +08:00
</mapper>