gz_att_wechat/src/main/resources/mappers/wechat/WeChatMapper.xml

534 lines
21 KiB
XML
Raw Normal View History

2025-01-20 09:47:39 +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.boot.manager.manager.dao.WeChatDao">
<insert id="insertEvection">
INSERT INTO leave_apply_wechat(uuid, user_id, user_name, org_id, org_name, type, leave_type, leave_reason,
leave_start_date,
leave_start_interval,
leave_end_date,
leave_end_interval,
leave_duration, source, create_user_id, is_agree, location, host_user_id,
host_user_name, remark
2025-02-20 16:36:23 +08:00
, leave_form_id, submit_id, examine_status, is_plateau, plateau_subsidy,is_update,is_sync)
2025-01-20 09:47:39 +08:00
VALUES (#{uuid}, #{userId}, #{userName}, #{orgId}, #{orgName}, '出差', '出差', #{leaveReason},
#{leaveStartDate},
#{leaveStartInterval},
#{leaveEndDate},
#{leaveEndInterval},
#{leaveDuration}, #{source}, #{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{hostUserName},
#{remark},
2025-02-20 16:36:23 +08:00
#{leaveFormId}, #{createUserId}, '1', #{isPlateau}, #{plateauSubsidy},'0','0')
2025-01-20 09:47:39 +08:00
</insert>
<insert id="insertLeaveReporting">
INSERT INTO leave_apply_wechat(uuid, user_id, user_name, org_id, org_name, leave_type, type, leave_reason,
leave_start_date,
leave_start_interval,
leave_end_date,
leave_end_interval,
leave_duration, source, create_user_id, is_agree, location, host_user_id,
2025-02-20 19:41:46 +08:00
host_user_name, remark, examine_status,is_update,is_sync)
2025-01-20 09:47:39 +08:00
VALUES (#{uuid}, #{userId}, #{userName}, #{orgId}, #{orgName}, #{leaveType}, '请假', #{leaveReason},
#{leaveStartDate},
#{leaveStartInterval},
#{leaveEndDate},
#{leaveEndInterval},
#{leaveDuration}, #{source}, #{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{hostUserName},
2025-02-20 19:41:46 +08:00
#{remark}, '1','0','0')
2025-01-20 09:47:39 +08:00
</insert>
2025-02-17 18:07:13 +08:00
<insert id="insertHoliday">
INSERT INTO leave_apply_wechat(uuid, user_id, user_name, org_id, org_name, leave_type, type, leave_reason,
leave_start_date,
leave_start_interval,
leave_end_date,
leave_end_interval,
leave_duration, source, create_user_id, is_agree, location, host_user_id,
host_user_name, remark, examine_status,is_update,is_sync,is_business)
2025-02-17 18:07:13 +08:00
VALUES (#{uuid}, #{userId}, #{userName}, #{orgId}, #{orgName}, #{leaveType}, #{type}, #{leaveReason},
#{leaveStartDate},
#{leaveStartInterval},
#{leaveEndDate},
#{leaveEndInterval},
#{leaveDuration}, #{source}, #{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{hostUserName},
#{remark}, '0','0','0',#{isBusiness})
2025-02-17 18:07:13 +08:00
</insert>
2025-01-20 09:47:39 +08:00
<update id="updateUser">
update sys_user_wechat
set password = #{password}
where user_id = #{userId}
</update>
2025-02-17 18:07:13 +08:00
<update id="updateHoliday">
UPDATE leave_apply_wechat
<set>
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="orgId != null and orgId != ''">
org_id = #{orgId},
</if>
<if test="orgName != null and orgName != ''">
org_name = #{orgName},
</if>
2025-03-06 10:46:56 +08:00
<if test="leaveType != null and leaveType != ''">
leave_type = #{leaveType},
</if>
<if test="type != null and type != ''">
`type` = #{type},
</if>
2025-02-17 18:07:13 +08:00
leave_reason = #{leaveReason},
leave_start_date = #{leaveStartDate},
leave_start_interval = #{leaveStartInterval},
leave_end_date = #{leaveEndDate},
leave_end_interval = #{leaveEndInterval},
leave_duration = #{leaveDuration},
update_user_id = #{updateUserId},
is_agree = #{isAgree},
location = #{location},
host_user_id = #{hostUserId},
2025-02-20 16:36:23 +08:00
remark = #{remark},
is_update = '1',
is_business = #{isBusiness},
examine_status = '0'
2025-02-17 18:07:13 +08:00
</set>
where uuid = #{uuid}
</update>
<update id="deleteHolidayById">
2025-02-20 16:36:23 +08:00
update leave_apply_wechat SET is_active = '0',is_update = '1' WHERE uuid = #{uuid}
2025-02-17 18:07:13 +08:00
</update>
<update id="editHoliday">
UPDATE leave_apply_wechat
<set>
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="orgId != null and orgId != ''">
org_id = #{orgId},
</if>
<if test="orgName != null and orgName != ''">
org_name = #{orgName},
</if>
leave_type = #{leaveType},
type = #{type},
2025-02-17 18:07:13 +08:00
leave_reason = #{leaveReason},
leave_start_date = #{leaveStartDate},
leave_start_interval = #{leaveStartInterval},
leave_end_date = #{leaveEndDate},
leave_end_interval = #{leaveEndInterval},
leave_duration = #{leaveDuration},
source = #{source},
update_user_id = #{updateUserId},
is_agree = #{isAgree},
location = #{location},
host_user_id = #{hostUserId},
host_user_name = #{hostUserName},
2025-02-20 16:36:23 +08:00
remark = #{remark},
is_update = '1'
2025-02-17 18:07:13 +08:00
</set>
where uuid = #{uuid}
</update>
<update id="editEvection">
UPDATE leave_apply_wechat
<set>
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="orgId != null and orgId != ''">
org_id = #{orgId},
</if>
<if test="orgName != null and orgName != ''">
org_name = #{orgName},
</if>
leave_reason = #{leaveReason},
leave_start_date = #{leaveStartDate},
leave_start_interval = #{leaveStartInterval},
leave_end_date = #{leaveEndDate},
leave_end_interval = #{leaveEndInterval},
leave_duration = #{leaveDuration},
source = #{source},
update_user_id = #{updateUserId},
is_agree = #{isAgree},
location = #{location},
host_user_id = #{hostUserId},
host_user_name = #{hostUserName},
2025-02-20 16:36:23 +08:00
remark = #{remark},
is_update = '1'
2025-02-17 18:07:13 +08:00
</set>
where leave_form_id = #{uuid}
</update>
<update id="deleteEvectionById">
2025-02-20 16:36:23 +08:00
update leave_apply_wechat SET is_active = '0',is_update = '1' WHERE leave_form_id = #{uuid}
2025-02-17 18:07:13 +08:00
</update>
2025-01-20 09:47:39 +08:00
<select id="getById" resultType="com.bonus.boot.manager.manager.entity.UserDto">
select su.id,
su.username as username,
su.phone,
su.org_id as orgId,
sru.roleId as roleId
from sys_user su
left join sys_role_user sru on su.id = sru.userId
where su.id = #{id}
</select>
<select id="getByUserId" resultType="com.bonus.boot.manager.manager.entity.UserDto">
select su.user_id,
su.username as username,
su.phone,
su.org_id as orgId,
sru.roleId as roleId
from sys_user su
left join sys_role_user sru on su.id = sru.userId
where su.user_id = #{userId}
</select>
2025-02-14 18:08:50 +08:00
<select id="getSelectUserCurrent" resultType="com.bonus.boot.manager.manager.model.SysUser">
2025-01-20 09:47:39 +08:00
select user_id as userId,
user_name as username,
phone
from sys_user_wechat
where is_active = 1
and user_id!=#{userId}
</select>
<select id="getTravelPersonSelect" resultType="com.bonus.boot.manager.manager.model.SysUser">
select user_id as userId,
user_name as username,
phone
from sys_user_wechat
where is_active = 1
</select>
2025-02-14 18:08:50 +08:00
<select id="getSysUserWechat" resultType="com.bonus.boot.manager.appManage.entity.SysUserWechat">
2025-01-20 09:47:39 +08:00
select aa.user_id as userId,
aa.user_name as username,
aa.phone,
2025-02-14 18:08:50 +08:00
aa.is_face as isFace,
aa.open_id as openId,
bb.user_id as faceId
2025-01-20 09:47:39 +08:00
from sys_user_wechat aa
LEFT JOIN sys_user_face_wechat bb ON aa.user_id = bb.user_id
where aa.is_active = 1
and aa.user_id = #{userId}
</select>
<select id="getEvectionList" resultType="com.bonus.boot.manager.manager.entity.EvectionBean">
2025-02-14 18:08:50 +08:00
SELECT b.*
FROM (SELECT a.*,
GROUP_CONCAT(a.user_ids SEPARATOR ',') AS travelers,
GROUP_CONCAT(a.user_name SEPARATOR ',') AS travelersName,
su.user_id,
su.user_name AS userName
FROM (SELECT l.id,
l.user_id as user_ids,
l.user_name,
l.org_id,
l.org_name,
l.create_time,
l.type,
l.leave_type,
l.leave_reason,
l.leave_start_date as leaveStartDate,
l.leave_start_interval,
l.leave_end_date as leaveEndDate,
l.leave_end_interval,
l.leave_duration as leaveDuration,
l.location,
l.leave_form_id as uuid,
l.submit_id,
l.update_time
FROM leave_apply_wechat l
WHERE l.is_active = '1'
AND l.type = '出差'
GROUP BY l.id,
l.user_id,
l.user_name,
l.org_id,
l.org_name,
l.create_time,
l.type,
l.leave_type,
l.leave_reason,
l.leave_start_date,
l.leave_start_interval,
l.leave_end_date,
l.leave_end_interval,
l.leave_duration,
l.examine_status,
l.submit_id) a
LEFT JOIN sys_user_wechat su ON su.user_id = a.submit_id
GROUP BY a.uuid) b
WHERE b.submit_id = #{userId}
2025-01-20 09:47:39 +08:00
ORDER BY b.leaveStartDate DESC
</select>
<select id="selectWchatc" resultType="com.bonus.boot.manager.manager.entity.EvectionBean">
SELECT *,leave_type as leaveType
FROM leave_apply_wechat
<where>
<if test="userId != null and userId != ''">
AND user_id = #{userId}
</if>
<if test="orgId != null">
AND org_id = #{orgId}
</if>
<if test="invoiceDate != null and invoiceDate != ''">
AND STR_TO_DATE(leave_start_date, '%Y-%m-%d') <![CDATA[ <= ]]> STR_TO_DATE(#{invoiceDate}, '%Y-%m-%d')
AND STR_TO_DATE(leave_end_date, '%Y-%m-%d') <![CDATA[ >= ]]> STR_TO_DATE(#{invoiceDate}, '%Y-%m-%d')
</if>
</where>
</select>
<select id="selectEvectionById" resultType="com.bonus.boot.manager.manager.entity.EvectionBean">
SELECT a.*,
2025-02-14 18:08:50 +08:00
GROUP_CONCAT(a.user_ids SEPARATOR ',') AS travelers,
GROUP_CONCAT(a.user_name SEPARATOR ',') AS travelersName,
2025-01-20 09:47:39 +08:00
su.user_id,
2025-02-14 18:08:50 +08:00
su.user_name as userName
2025-01-20 09:47:39 +08:00
FROM (SELECT l.id,
2025-02-14 18:08:50 +08:00
l.user_id as user_ids,
2025-01-20 09:47:39 +08:00
l.user_name,
l.org_id,
l.org_name,
l.create_time,
l.type,
l.leave_type,
2025-02-14 18:08:50 +08:00
l.leave_reason as leaveReason,
2025-01-20 09:47:39 +08:00
l.leave_start_date as leaveStartDate,
l.leave_start_interval,
2025-02-14 18:08:50 +08:00
l.leave_end_date as leaveEndDate,
2025-01-20 09:47:39 +08:00
l.leave_end_interval,
2025-02-14 18:08:50 +08:00
l.leave_duration as leaveDuration,
l.leave_form_id as uuid,
2025-01-20 09:47:39 +08:00
l.submit_id,
l.host_user_id,
2025-02-14 18:08:50 +08:00
l.host_user_name as hostUserName,
l.is_agree as isAgree,
2025-01-20 09:47:39 +08:00
l.location,
2025-02-14 18:08:50 +08:00
l.remark,
l.is_plateau as isPlateau,
l.plateau_subsidy as plateauSubsidy
2025-01-20 09:47:39 +08:00
FROM leave_apply_wechat l
WHERE l.is_active = '1'
AND l.type = '出差'
and l.leave_form_id = #{uuid}
GROUP BY l.id,
l.user_id,
l.user_name,
l.org_id,
l.org_name,
l.create_time,
l.type,
l.leave_type,
l.leave_reason,
l.leave_start_date,
l.leave_start_interval,
l.leave_end_date,
l.leave_end_interval,
l.leave_duration,
l.examine_status,
l.submit_id,
l.host_user_id,
l.is_agree,
l.location,
2025-02-14 18:08:50 +08:00
l.remark,
l.is_plateau,
l.plateau_subsidy
2025-01-20 09:47:39 +08:00
ORDER BY l.update_time DESC) a
LEFT JOIN sys_user_wechat su ON su.user_id = a.submit_id
GROUP BY uuid
</select>
<select id="getLeaveReportingList" resultType="com.bonus.boot.manager.manager.entity.LeaveReportingBean">
2025-02-14 18:08:50 +08:00
SELECT l.user_id,
l.uuid,
l.user_name as userName,
l.org_id,
l.org_name,
l.create_time,
l.leave_type as leaveType,
l.type,
l.leave_reason as leaveReason,
l.leave_start_date as leaveStartDate,
l.leave_start_interval,
l.leave_end_date as leaveEndDate,
l.leave_end_interval,
l.leave_duration as leaveDuration
FROM leave_apply_wechat l
WHERE l.is_active = '1'
AND l.type = '请假'
and l.user_id = #{userId}
GROUP BY l.uuid,
l.user_id,
l.user_name,
l.org_id,
l.org_name,
l.create_time,
l.leave_type,
l.type,
l.leave_reason,
l.leave_start_date,
l.leave_start_interval,
l.leave_end_date,
l.leave_end_interval,
l.leave_duration,
l.examine_status
2025-01-20 09:47:39 +08:00
ORDER BY l.leave_start_date DESC
</select>
<select id="selectLeaveReportingById"
resultType="com.bonus.boot.manager.manager.entity.LeaveReportingBean">
SELECT l.uuid,
l.user_id,
2025-02-14 18:08:50 +08:00
l.user_name as userName,
2025-01-20 09:47:39 +08:00
l.org_id,
l.org_name,
l.create_time,
2025-02-14 18:08:50 +08:00
l.leave_type as leaveType,
2025-01-20 09:47:39 +08:00
l.type,
2025-02-14 18:08:50 +08:00
l.leave_reason as leaveReason,
2025-01-20 09:47:39 +08:00
l.leave_start_date as leaveStartDate,
l.leave_start_interval,
2025-02-14 18:08:50 +08:00
l.leave_end_date as leaveEndDate,
2025-01-20 09:47:39 +08:00
l.leave_end_interval,
2025-02-14 18:08:50 +08:00
l.leave_duration as leaveDuration,
2025-01-20 09:47:39 +08:00
l.host_user_id,
2025-02-14 18:08:50 +08:00
l.host_user_name as hostUserName,
l.is_agree as isAgree,
2025-01-20 09:47:39 +08:00
l.location,
2025-02-14 18:08:50 +08:00
l.remark as remark
FROM leave_apply_wechat l
2025-01-20 09:47:39 +08:00
WHERE l.uuid = #{uuid}
</select>
<select id="getHolidayType" resultType="com.bonus.boot.manager.manager.entity.LeaveReportingBean">
2025-02-14 18:08:50 +08:00
SELECT dict_code AS id,
dict_label AS type
FROM sys_dict_data_wechat
WHERE STATUS = 0 and dict_type = #{dictType}
2025-01-20 09:47:39 +08:00
</select>
<select id="getFestivalAndHoliday" resultType="com.bonus.boot.manager.manager.entity.LeaveReportingBean">
SELECT id, date, `name`, type
FROM
sys_holiday_wechat
where
type ='1'
</select>
2025-01-22 14:46:28 +08:00
<select id="getAttTypeByUserId" resultType="java.lang.String">
2025-02-14 18:08:50 +08:00
SELECT is_pd
FROM `sys_user_wechat`
2025-01-22 14:46:28 +08:00
WHERE user_id = #{userId}
</select>
2025-01-20 09:47:39 +08:00
2025-02-17 18:07:13 +08:00
<select id="getHolidaysList" resultType="com.bonus.boot.manager.manager.entity.HolidayBean">
SELECT DISTINCT la.id,
la.uuid,
la.user_id,
la.user_name,
la.org_id,
la.org_name,
la.create_time,
la.leave_type,
la.leave_reason,
la.leave_start_date as leaveStartDate,
la.leave_start_interval as leaveStartInterval,
la.leave_end_date as leaveEndDate,
la.leave_end_interval as leaveEndInterval,
la.leave_duration as leaveDuration,
la.examine_status as examineStatus
2025-02-17 18:07:13 +08:00
FROM leave_apply_wechat la
WHERE la.is_active = '1'
2025-03-06 10:00:14 +08:00
<if test="type != null and type != '' ">
<choose>
<when test="type == '临时外出'">
and ( locate(#{type},la.type) or locate('培训',la.type) )
</when>
<otherwise>
and locate(#{type},la.type)
</otherwise>
</choose>
</if>
2025-02-17 18:07:13 +08:00
and la.user_id = #{userId}
ORDER BY la.update_time DESC
</select>
<select id="getHolidaysDetail" resultType="com.bonus.boot.manager.manager.entity.HolidayBean">
SELECT DISTINCT la.id,
la.uuid,
la.user_id,
la.user_name,
la.org_id,
la.org_name,
la.leave_type,
la.type,
2025-02-17 18:07:13 +08:00
la.leave_reason,
la.leave_start_date,
la.leave_start_interval,
la.leave_end_date,
la.leave_end_interval,
la.leave_duration,
la.source,
la.create_user_id,
la.is_agree,
la.location,
la.host_user_id,
la.host_user_name,
la.remark,
la.examine_status,
la.is_business
2025-02-17 18:07:13 +08:00
FROM leave_apply_wechat la
WHERE la.is_active = '1'
and la.uuid = #{uuId}
</select>
2025-02-20 16:36:23 +08:00
<!--判断数据是否处于同步状态,若处于同步状态则禁止操作-->
<select id="dataIsSync" resultType="java.lang.Integer">
SELECT is_sync AS isSync
FROM leave_apply_wechat
<where>
<if test="type == 1">
2025-02-20 19:41:46 +08:00
AND leave_form_id = #{params.uuid}
2025-02-20 16:36:23 +08:00
</if>
<if test="type == 2">
2025-02-20 19:41:46 +08:00
AND `uuid` = #{params.uuid}
2025-02-20 16:36:23 +08:00
</if>
</where>
LIMIT 1
</select>
2025-02-20 18:28:45 +08:00
<!--查询出差详情-->
<select id="getEvectionById" resultType="com.bonus.boot.manager.manager.entity.EvectionBean">
SELECT la.uuid,
la.leave_start_date AS leaveStartDate,
la.leave_end_date AS leaveEndDate,
2025-02-20 19:41:46 +08:00
la.org_id AS orgId
2025-02-20 18:28:45 +08:00
FROM leave_apply_wechat la
<where>
<if test="type == 1">
AND la.uuid = #{uuid}
</if>
<if test="type == 2">
AND la.leave_form_id = #{uuid} AND submit_id = user_id
</if>
</where>
</select>
<!--判断出差报备数据是否被核对-->
<select id="isCheck" resultType="java.lang.Integer">
SELECT status
FROM leave_check_wechat lc
WHERE lc.org_id = #{orgId} AND (DATE_FORMAT(#{leaveStartDate},'%Y-%m') = lc.month OR DATE_FORMAT(#{leaveEndDate},'%Y-%m') = lc.month)
AND lc.is_active = '1'
ORDER BY lc.create_time
</select>
2025-02-17 18:07:13 +08:00
2025-01-20 09:47:39 +08:00
</mapper>