150 lines
6.3 KiB
XML
150 lines
6.3 KiB
XML
|
|
<?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.sercurityControl.proteam.dutyTask.mapper.DutyMgeMapper">
|
||
|
|
<!--更新/修改 值班人员数据-->
|
||
|
|
<insert id="addOrUpdateData">
|
||
|
|
<if test="id !=null and id!=''">
|
||
|
|
UPDATE tb_duty_person SET post = #{post},user_name = #{userName},id_number = #{idNumber},phone =
|
||
|
|
#{phone},update_time = #{updateTime}
|
||
|
|
WHERE id = #{id}
|
||
|
|
</if>
|
||
|
|
<if test="id ==null or id==''">
|
||
|
|
INSERT into tb_duty_person(post,user_name,id_number,phone,create_time,update_time,create_day)
|
||
|
|
VALUES(#{post},#{userName},#{idNumber},#{phone},#{createTime},#{updateTime},#{createDay})
|
||
|
|
</if>
|
||
|
|
</insert>
|
||
|
|
<!--新增人员排班表-->
|
||
|
|
<insert id="addSchedulingPersonData">
|
||
|
|
INSERT INTO tb_scheduling_perosn (user_id,user_name,remark,user_type,scheduling_date,create_time,create_day)
|
||
|
|
VALUES (
|
||
|
|
#{userId},#{userName},#{remark},#{type},#{date},#{createTime},#{createDay}
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
<!--登录用户绑定值班员-->
|
||
|
|
<insert id="addUserBanding">
|
||
|
|
INSERT INTO tb_user_banding (login_user_id,login_name,scheduling_id,scheduling_name,banding_date,create_time,create_day)
|
||
|
|
VALUES (
|
||
|
|
#{loginUserId},#{loginName},#{schedulingId},#{schedulingName},#{bandingDate},#{createTime},#{createDay}
|
||
|
|
)
|
||
|
|
</insert>
|
||
|
|
<insert id="addDutyPerson" keyProperty="id" useGeneratedKeys="true">
|
||
|
|
INSERT into tb_duty_person(post,user_name,id_number,phone,create_time,update_time,create_day)
|
||
|
|
VALUES(#{post},#{userName},NULL,NULL,#{createTime},#{updateTime},#{createDay})
|
||
|
|
</insert>
|
||
|
|
<!--删除值班人员数据-->
|
||
|
|
<update id="delData">
|
||
|
|
UPDATE tb_duty_person SET is_flag = '1' WHERE id = #{id}
|
||
|
|
</update>
|
||
|
|
<!--删除排班人员-->
|
||
|
|
<delete id="delSchedulingPersonData">
|
||
|
|
DELETE FROM tb_scheduling_perosn WHERE scheduling_date BETWEEN #{startTime} AND #{endTime}
|
||
|
|
</delete>
|
||
|
|
<!--移除绑定的用户-->
|
||
|
|
<delete id="removeUserBanding">
|
||
|
|
DELETE FROM tb_user_banding WHERE id = #{id}
|
||
|
|
</delete>
|
||
|
|
|
||
|
|
<!--值班人员管理列表-->
|
||
|
|
<select id="getDutyPersonList" resultType="com.sercurityControl.proteam.dutyTask.domain.DutyPersonEntity">
|
||
|
|
SELECT
|
||
|
|
id,
|
||
|
|
post,
|
||
|
|
user_name AS userName,
|
||
|
|
id_number AS idNumber,
|
||
|
|
phone
|
||
|
|
FROM tb_duty_person
|
||
|
|
WHERE is_flag = '0'
|
||
|
|
<if test="userName!=null and userName !=''">
|
||
|
|
AND INSTR(user_name,#{userName}) > 0
|
||
|
|
</if>
|
||
|
|
ORDER BY update_time DESC
|
||
|
|
</select>
|
||
|
|
<!--验证某字段是否存在-->
|
||
|
|
<select id="isRepeat" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM tb_duty_person
|
||
|
|
WHERE is_flag = '0' AND ${param} = #{value}
|
||
|
|
</select>
|
||
|
|
<!--根据id获取值班人员详情数据-->
|
||
|
|
<select id="getPersonDataById" resultType="com.sercurityControl.proteam.dutyTask.domain.DutyPersonEntity">
|
||
|
|
SELECT
|
||
|
|
id,
|
||
|
|
post,
|
||
|
|
user_name AS userName,
|
||
|
|
id_number AS idNumber,
|
||
|
|
phone
|
||
|
|
FROM tb_duty_person
|
||
|
|
WHERE is_flag = '0' AND id = #{id}
|
||
|
|
</select>
|
||
|
|
<!--根据岗位类型获取值班人员-->
|
||
|
|
<select id="getPersonByType" resultType="com.sercurityControl.proteam.dutyTask.domain.DutyPersonEntity">
|
||
|
|
SELECT
|
||
|
|
id,
|
||
|
|
post,
|
||
|
|
user_name AS userName
|
||
|
|
FROM tb_duty_person
|
||
|
|
WHERE is_flag = '0'
|
||
|
|
</select>
|
||
|
|
<!--根据日期获取排班人员表-->
|
||
|
|
<select id="getSchedulingPersonData"
|
||
|
|
resultType="com.sercurityControl.proteam.dutyTask.domain.SchedulingPersonVo">
|
||
|
|
SELECT
|
||
|
|
user_id AS userId,
|
||
|
|
scheduling_date AS `date`,
|
||
|
|
user_name AS userName,
|
||
|
|
remark
|
||
|
|
FROM tb_scheduling_perosn
|
||
|
|
WHERE scheduling_date BETWEEN #{createTime} AND #{createDay}
|
||
|
|
AND user_type = #{type}
|
||
|
|
ORDER BY user_type
|
||
|
|
</select>
|
||
|
|
<!--根据日期获取当日排班人员-->
|
||
|
|
<select id="getSchedulingPersonByDate"
|
||
|
|
resultType="com.sercurityControl.proteam.dutyTask.domain.SchedulingPersonVo">
|
||
|
|
SELECT
|
||
|
|
tsp.user_id AS userId,
|
||
|
|
tsp.user_name AS userName
|
||
|
|
FROM tb_scheduling_perosn tsp
|
||
|
|
LEFT JOIN tb_user_banding tub ON tsp.user_id = tub.scheduling_id AND tub.banding_date = #{currentDay} AND tub.is_flag = '0'
|
||
|
|
WHERE tsp.scheduling_date = #{currentDay} AND tsp.user_type IN ('5','6','7','8','9','10','11') AND tsp.is_flag = '0'
|
||
|
|
AND tub.id IS NULL
|
||
|
|
</select>
|
||
|
|
<!--判断用户是否绑定-->
|
||
|
|
<select id="userIsBanding" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM tb_user_banding
|
||
|
|
WHERE login_user_id = #{userId} AND banding_date = #{createDay} AND is_flag = '0'
|
||
|
|
</select>
|
||
|
|
<!--用户绑定值班员列表-->
|
||
|
|
<select id="getUserBandingList" resultType="com.sercurityControl.proteam.dutyTask.domain.UserBandingVo">
|
||
|
|
SELECT
|
||
|
|
id,
|
||
|
|
login_name AS loginName,
|
||
|
|
scheduling_name AS schedulingName,
|
||
|
|
banding_date AS bandingDate
|
||
|
|
FROM tb_user_banding
|
||
|
|
<where>
|
||
|
|
is_flag = '0'
|
||
|
|
<if test="bandingDate!=null and bandingDate!=''">
|
||
|
|
AND banding_date = #{bandingDate}
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</select>
|
||
|
|
<!--用户是否绑定值班员-->
|
||
|
|
<select id="isBanding" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM tb_user_banding
|
||
|
|
WHERE login_user_id = #{loginUserId} AND banding_date = #{createDay} AND is_flag = '0'
|
||
|
|
</select>
|
||
|
|
<select id="isBanding2" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM tb_user_banding
|
||
|
|
WHERE scheduling_id = #{schedulingId} AND banding_date = #{createDay} AND is_flag = '0'
|
||
|
|
</select>
|
||
|
|
<select id="getDutyPerson" resultType="com.sercurityControl.proteam.dutyTask.domain.DutyPersonVo">
|
||
|
|
SELECT id,user_name AS userName FROM tb_duty_person WHERE user_name = #{params.userName} AND post = #{post} AND is_flag = '0'
|
||
|
|
</select>
|
||
|
|
<!--查询是否已录入排班数据-->
|
||
|
|
<select id="getIsAddNum" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*)
|
||
|
|
FROM tb_scheduling_perosn tsp
|
||
|
|
WHERE scheduling_date BETWEEN #{createTime} AND #{createDay} AND is_flag = '0'
|
||
|
|
</select>
|
||
|
|
|
||
|
|
</mapper>
|