btxtgxq-system-city/src/main/resources/mybatis/mapper/usersignout/usersignout-mapper.xml

536 lines
19 KiB
XML
Raw Normal View History

2021-06-15 18:23: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.cm.systemcity.dao.usersignout.IUserSignoutDao">
<resultMap id="userSignoutDTO" type="com.cm.systemcity.pojo.dtos.usersignout.UserSignoutDTO">
<id property="userSignoutId" column="user_signout_id"/>
<result property="userName" column="user_name"/>
<result property="signoutLongitude" column="signout_longitude"/>
<result property="signoutLatitude" column="signout_latitude"/>
<result property="isEarly" column="is_early"/>
<result property="isOutside" column="is_outside"/>
<result property="amPm" column="am_pm"/>
<result property="creator" column="creator"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="userPhone" column="user_phone"/>
<result property="userAvatar" column="user_avatar"/>
</resultMap>
<resultMap id="userSignoutDetailDTO" type="com.cm.systemcity.pojo.dtos.usersignout.UserSignoutDetailDTO" extends="userSignoutDTO">
<result property="communityBossLevel" column="community_boss_level"/>
<result property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="communityIds" column="community_ids"/>
<result property="communityNames" column="community_names"/>
<result property="departmentIds" column="department_ids"/>
<result property="departmentNames" column="department_names"/>
<result property="positionIds" column="position_ids"/>
<result property="positionNames" column="position_names"/>
</resultMap>
<resultMap id="userUnSignoutDetailDTO" type="com.cm.systemcity.pojo.dtos.usersignout.UserUnSignoutDetailDTO">
<id property="userId" column="user_id"/>
<result property="userName" column="user_name"/>
<result property="userPhone" column="user_phone"/>
<result property="userAvatar" column="user_avatar"/>
<result property="communityBossLevel" column="community_boss_level"/>
<result property="areaId" column="area_id"/>
<result property="areaName" column="area_name"/>
<result property="departmentIds" column="department_ids"/>
<result property="departmentNames" column="department_names"/>
<result property="positionIds" column="position_ids"/>
<result property="positionNames" column="position_names"/>
<result property="communityIds" column="community_ids"/>
<result property="communityNames" column="community_names"/>
</resultMap>
<!-- 新增人员签退 -->
<insert id="saveUserSignout" parameterType="map">
INSERT INTO city_user_signout(
user_signout_id,
user_name,
signout_longitude,
signout_latitude,
is_early,
is_outside,
am_pm,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
#{userSignoutId},
#{userName},
#{signoutLongitude},
#{signoutLatitude},
#{isEarly},
#{isOutside},
#{amPm},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
<!-- 删除人员签退 -->
<update id="removeUserSignout" parameterType="map">
UPDATE
city_user_signout
SET
is_delete = 1,
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
user_signout_id IN
<foreach collection="userSignoutIds" index="index" open="(" separator="," close=")">
#{userSignoutIds[${index}]}
</foreach>
</update>
<!-- 修改人员签退 -->
<update id="updateUserSignout" parameterType="map">
UPDATE
city_user_signout
SET
<if test="userId != null and userId != ''">
user_id = #{userId},
</if>
<if test="userName != null and userName != ''">
user_name = #{userName},
</if>
<if test="signoutLongitude != null and signoutLongitude != ''">
signout_longitude = #{signoutLongitude},
</if>
<if test="signoutLatitude != null and signoutLatitude != ''">
signout_latitude = #{signoutLatitude},
</if>
<if test="isEarly != null">
is_early = #{isEarly},
</if>
<if test="isOutside != null">
is_outside = #{isOutside},
</if>
<if test="amPm != null and amPm != ''">
am_pm = #{amPm},
</if>
modifier = #{modifier},
gmt_modified = #{gmtModified}
WHERE
user_signout_id = #{userSignoutId}
</update>
<!-- 人员签退列表 -->
<select id="listUserSignout" parameterType="map" resultMap="userSignoutDTO">
SELECT
t1.user_signout_id,
t1.user_name,
t1.signout_longitude,
t1.signout_latitude,
t1.is_early,
t1.is_outside,
t1.am_pm,
t1.creator,
t1.gmt_create
FROM
city_user_signout t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND
t1.user_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
t1.gmt_create <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
t1.gmt_create <![CDATA[ <= ]]> #{endTime}
</if>
<if test="signTime != null and signTime != ''">
AND
LEFT(t1.gmt_create, 10) = #{signTime}
2021-07-30 10:21:22 +08:00
</if><!--
2021-06-15 18:23:48 +08:00
<if test="amPm != null and amPm != ''">
AND
t1.am_pm = #{amPm}
2021-07-30 10:21:22 +08:00
</if>-->
2021-06-15 18:23:48 +08:00
<if test="creator != null and creator != ''">
AND
t1.creator = #{creator}
</if>
<if test="userSignoutIds != null and userSignoutIds.size > 0">
AND
t1.user_signout_id IN
<foreach collection="userSignoutIds" index="index" open="(" separator="," close=")">
#{userSignoutIds[${index}]}
</foreach>
</if>
<if test="userIds != null and userIds.size > 0">
AND
t1.creator IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
2021-06-15 18:23:48 +08:00
ORDER BY
t1.gmt_create DESC
</select>
<!-- 人员签退详情 -->
<select id="getUserSignout" parameterType="map" resultMap="userSignoutDTO">
SELECT
t1.user_signout_id,
t1.user_name,
t1.signout_longitude,
t1.signout_latitude,
t1.is_early,
t1.is_outside,
t1.am_pm,
t1.creator,
t1.gmt_create
FROM
city_user_signout t1
WHERE
t1.is_delete = 0
<if test="userSignoutId != null and userSignoutId != ''">
AND
t1.user_signout_id = #{userSignoutId}
</if>
<if test="creator != null and creator != ''">
AND
t1.creator = #{creator}
</if>
<if test="signTime != null and signTime != ''">
AND
LEFT(t1.gmt_create, 10) = #{signTime}
</if>
<if test="amPm != null and amPm != ''">
AND
t1.am_pm = #{amPm}
</if>
</select>
<!-- 分页人员签到详细列表 -->
<select id="listUserSignoutDetail" parameterType="map" resultMap="userSignoutDetailDTO">
SELECT
*
FROM (
SELECT
t1.user_signout_id,
t1.user_name,
t1.signout_longitude,
t1.signout_latitude,
t1.is_early,
t1.is_outside,
t1.am_pm,
t1.creator,
LEFT(t1.gmt_create, 19) gmt_create,
t2.user_phone,
t2.user_avatar,
t3.community_boss_level,
t3.area_id,
t3.area_name,
GROUP_CONCAT(t5.department_id) department_ids,
GROUP_CONCAT(t5.department_name) department_names,
GROUP_CONCAT(t7.position_id) position_ids,
GROUP_CONCAT(t7.position_name) position_names,
GROUP_CONCAT(t9.community_id) community_ids,
GROUP_CONCAT(t9.community_name) community_names,
GROUP_CONCAT(t10.role_id) role_ids
FROM
city_user_signout t1
INNER JOIN
sys_user t2
ON
t1.creator = t2.user_id AND t2.is_delete = 0
LEFT JOIN
city_community_boss t3
ON
t1.creator = t3.community_boss_id AND t3.is_delete = 0
LEFT JOIN
sys_department_user t4
ON
t1.creator = t4.user_id
LEFT JOIN
sys_department t5
ON
t4.department_id = t5.department_id AND t5.is_delete = 0
LEFT JOIN
sys_position_user t6
ON
t1.creator = t6.user_id
LEFT JOIN
sys_position t7
ON
t6.position_id = t7.position_id AND t7.is_delete = 0
LEFT JOIN
city_community_boss_community t8
ON
t3.community_boss_id = t8.community_boss_id
LEFT JOIN
city_community t9
ON
t8.community_id = t9.community_id
LEFT JOIN
sys_role_user t10
ON
t1.creator = t10.user_id
WHERE
t1.is_delete = 0
GROUP BY
t1.user_signout_id,
t1.user_name,
t1.signout_longitude,
t1.signout_latitude,
t1.is_early,
t1.is_outside,
t1.am_pm,
t1.creator,
t1.gmt_create,
t2.user_phone,
t2.user_avatar,
t3.community_boss_level,
t3.area_id,
t3.area_name
) mt1
WHERE
1 = 1
<if test="keywords != null and keywords != ''">
AND
mt1.user_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(mt1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(mt1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="signTime != null and signTime != ''">
AND
LEFT(mt1.gmt_create, 10) = #{signTime}
</if>
<if test="amPm != null and amPm != ''">
AND
mt1.am_pm = #{amPm}
</if>
<if test="isEarly != null">
AND
mt1.is_early = #{isEarly}
</if>
<if test="areaId != null and areaId != ''">
AND
mt1.area_id = #{areaId}
</if>
<if test="communityId != null and communityId != ''">
AND
mt1.community_ids LIKE CONCAT('%', #{communityId}, '%')
</if>
<if test="departmentId != null and departmentId != ''">
AND
mt1.department_ids LIKE CONCAT('%', #{departmentId}, '%')
</if>
<if test="communityBossLevel != null and communityBossLevel != ''">
AND
mt1.community_boss_level = #{communityBossLevel}
</if>
<if test="roleId != null and roleId != ''">
AND
mt1.role_ids LIKE CONCAT('%', #{roleId}, '%')
</if>
<if test="userSignoutIds != null and userSignoutIds.size > 0">
AND
mt1.user_signout_id IN
<foreach collection="userSignoutIds" index="index" open="(" separator="," close=")">
#{userSignoutIds[${index}]}
</foreach>
</if>
<if test="userIds != null and userIds.size > 0">
AND
mt1.creator IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
ORDER BY
mt1.gmt_create DESC
</select>
<!-- 人员未签到详细列表 -->
<select id="listUserUnSignoutDetail" parameterType="map" resultMap="userUnSignoutDetailDTO">
SELECT
*
FROM (
SELECT
t1.user_id,
t1.user_username,
t1.user_name,
t1.user_phone,
t1.user_avatar,
t2.community_boss_level,
t2.area_id,
t2.area_name,
GROUP_CONCAT( t4.department_id ) department_ids,
GROUP_CONCAT( t4.department_name ) department_names,
GROUP_CONCAT( t6.position_id ) position_ids,
GROUP_CONCAT( t6.position_name ) position_names,
GROUP_CONCAT( t8.community_id ) community_ids,
GROUP_CONCAT( t8.community_name ) community_names,
GROUP_CONCAT( t9.role_id ) role_ids
FROM
sys_user t1
LEFT JOIN
city_community_boss t2 ON t1.user_id = t2.community_boss_id
AND
t2.is_delete = 0
LEFT JOIN
sys_department_user t3 ON t1.user_id = t3.user_id
LEFT JOIN
sys_department t4 ON t3.department_id = t4.department_id
AND
t4.is_delete = 0
LEFT JOIN
sys_position_user t5 ON t1.user_id = t5.user_id
LEFT JOIN
sys_position t6 ON t5.position_id = t6.position_id
AND
t6.is_delete = 0
LEFT JOIN
city_community_boss_community t7 ON t2.community_boss_id = t7.community_boss_id
LEFT JOIN
city_community t8 ON t7.community_id = t8.community_id
LEFT JOIN
sys_role_user t9 ON t1.user_id = t9.user_id
WHERE
t1.is_delete = 0
AND
t1.user_id NOT IN (
SELECT
st1.creator
FROM
city_user_signout st1
WHERE
st1.is_delete = 0
<if test="amPm != null and amPm != ''">
AND
st1.am_pm = #{amPm}
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(st1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(st1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
GROUP BY
st1.creator
)
AND
t1.user_id NOT IN (
SELECT
st2.creator
FROM
city_leave st2
WHERE
st2.is_delete = 0
<if test="showTime != null and showTime != ''">
AND (
LEFT(st2.leave_time, 10) <![CDATA[ <= ]]> #{showTime}
AND
LEFT(st2.leave_time_end, 10) <![CDATA[ >= ]]> #{showTime}
)
</if>
<if test="leaveTimeList != null and leaveTimeList.size > 0">
AND
<foreach collection="leaveTimeList" index="index" open="(" separator="OR" close=")">
st2.leave_time <![CDATA[ <= ]]> #{leaveTimeList[${index}].showTodayStartTime}
AND
st2.leave_time_end <![CDATA[ >= ]]> #{leaveTimeList[${index}].showTodayStartTimeEnd}
</foreach>
</if>
GROUP BY
st2.creator
)
GROUP BY
t1.user_id,
t1.user_username,
t1.user_name,
t1.user_phone,
t1.user_email,
t1.user_avatar,
t2.community_boss_level,
t2.area_id,
t2.area_name
) mt1
WHERE
mt1.user_username != 'admin'
<if test="keywords != null and keywords != ''">
AND
mt1.user_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="areaId != null and areaId != ''">
AND
mt1.area_id = #{areaId}
</if>
<if test="communityId != null and communityId != ''">
AND
mt1.community_ids LIKE CONCAT('%', #{communityId}, '%')
</if>
<if test="departmentId != null and departmentId != ''">
AND
mt1.department_ids LIKE CONCAT('%', #{departmentId}, '%')
</if>
<if test="communityBossLevel != null and communityBossLevel != ''">
AND
mt1.community_boss_level = #{communityBossLevel}
</if>
<if test="roleId != null and roleId != ''">
AND
mt1.role_ids LIKE CONCAT('%', #{roleId}, '%')
</if>
<if test="userIds != null and userIds.size > 0">
AND
mt1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</select>
<!-- 统计签退次数 -->
<select id="countUserSignout" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM (
SELECT
creator
FROM
city_user_signout
WHERE
is_delete = 0
<if test="showTime != null and showTime != ''">
AND
LEFT(gmt_create, 10) = #{showTime}
</if>
<if test="amPm != null and amPm != ''">
AND
am_pm = #{amPm}
</if>
<if test="userIds != null and userIds.size > 0">
AND
creator IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
GROUP BY
creator
) mt
</select>
</mapper>