<?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.yanzhu.manage.mapper.AttendanceUbiDataMapper">
    
    <resultMap type="AttendanceUbiData" id="AttendanceUbiDataResult">
        <result property="id"    column="id"    />
        <result property="comId"    column="comId"    />
        <result property="comName" column="comName"/>
        <result property="projectName" column="projectName"/>
        <result property="projectId"    column="projectId"    />
        <result property="subDeptId"    column="sub_dept_id"    />
        <result property="subDeptName"    column="sub_dept_name"    />
        <result property="userId"    column="userId"    />
        <result property="admitGuid" column="admitGuid" />
        <result property="userName"    column="userName"    />
        <result property="subDeptGroup"    column="sub_dept_group"    />
        <result property="subDeptGroupName"    column="sub_dept_group_name"    />
        <result property="craftType"    column="craft_type"    />
        <result property="craftPost"    column="craft_post"    />
        <result property="inTime"    column="inTime"    />
        <result property="inData"    column="inData"    />
        <result property="outTime"    column="outTime"    />
        <result property="outData"    column="outData"    />
        <result property="deviceNo"    column="deviceNo"    />
        <result property="isDel"    column="is_del"    />
        <result property="state"    column="state"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="eventGuid" column="eventGuid"/>
        <result property="inPhoto" column="inPhoto"/>
        <result property="outPhoto" column="outPhoto"/>
    </resultMap>

    <sql id="selectAttendanceUbiDataVo">
        select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid,
               eventGuid,inPhoto,outPhoto,comName,projectName,sub_dept_id,sub_dept_name,
               inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
    </sql>
    <sql id="selectAttendanceUbiDataAllVo">
        select id, comId, projectId, userId, userName, sub_dept_group, sub_dept_group_name, craft_type, craft_post,admitGuid,
               eventGuid,inPhoto,outPhoto,inData,outData,comName,projectName,sub_dept_id,sub_dept_name,
               inTime, outTime, deviceNo, is_del, state, remark, create_by, create_time, update_by, update_time from attendance_ubi_data
    </sql>    <select id="selectAttendanceUbiDataList" parameterType="AttendanceUbiData" resultMap="AttendanceUbiDataResult">
        <include refid="selectAttendanceUbiDataVo"/>
        <where>  
            <if test="comId != null "> and comId = #{comId}</if>
            <if test="projectId != null "> and projectId = #{projectId}</if>
            <if test="subDeptId != null "> and sub_dept_id = #{subDeptId}</if>
            <if test="userId != null "> and userId = #{userId}</if>
            <if test="userName != null  and userName != ''"> and userName like concat('%', #{userName}, '%')</if>
            <if test="subDeptGroup != null "> and sub_dept_group = #{subDeptGroup}</if>
            <if test="subDeptGroupName != null  and subDeptGroupName != ''"> and sub_dept_group_name like concat('%', #{subDeptGroupName}, '%')</if>
            <if test="craftType != null  and craftType != ''"> and craft_type = #{craftType}</if>
            <if test="craftPost != null  and craftPost != ''"> and craft_post = #{craftPost}</if>
            <if test="inTime != null "> and date(inTime) = date(#{inTime})</if>
            <if test="inData != null  and inData != ''"> and inData = #{inData}</if>
            <if test="outTime != null "> and date(outTime) = date(#{outTime})</if>
            <if test="outData != null  and outData != ''"> and outData = #{outData}</if>
            <if test="deviceNo != null  and deviceNo != ''"> and deviceNo = #{deviceNo}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="state != null "> and state = #{state}</if>
        </where>
    </select>

    <select id="queryAttendaceInfo" parameterType="AttendanceUbiData" resultMap="AttendanceUbiDataResult">
        <include refid="selectAttendanceUbiDataVo"/>
        <where>
            <if test="comId != null "> and comId = #{comId}</if>
            <if test="projectId != null "> and projectId = #{projectId}</if>
            <if test="subDeptId != null "> and sub_dept_id = #{subDeptId}</if>
            <if test="userId != null "> and userId = #{userId}</if>
            <if test="admitGuid != null and admitGuid != ''"> and admitGuid = #{admitGuid}</if>
            <if test="userName != null  and userName != ''"> and userName like concat('%', #{userName}, '%')</if>
            <if test="inTime != null "> and date(inTime) = date(#{inTime})</if>
            <if test="outTime != null "> and date(outTime) = date(#{outTime})</if>
            <if test="deviceNo != null  and deviceNo != ''"> and deviceNo = #{deviceNo}</if>
        </where>
    </select>
    
    <select id="selectAttendanceUbiDataById" parameterType="Long" resultMap="AttendanceUbiDataResult">
        <include refid="selectAttendanceUbiDataVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAttendanceUbiData" parameterType="AttendanceUbiData" useGeneratedKeys="true" keyProperty="id">
        insert into attendance_ubi_data
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="comId != null">comId,</if>
            <if test="projectId != null">projectId,</if>
            <if test="userId != null">userId,</if>
            <if test="userName != null">userName,</if>
            <if test="subDeptGroup != null">sub_dept_group,</if>
            <if test="subDeptGroupName != null">sub_dept_group_name,</if>
            <if test="craftType != null">craft_type,</if>
            <if test="craftPost != null">craft_post,</if>
            <if test="inTime != null">inTime,</if>
            <if test="inData != null">inData,</if>
            <if test="outTime != null">outTime,</if>
            <if test="outData != null">outData,</if>
            <if test="deviceNo != null">deviceNo,</if>
            <if test="isDel != null">is_del,</if>
            <if test="subDeptId != null">sub_dept_id,</if>
            <if test="subDeptName != null">sub_dept_name,</if>
            <if test="comName != null">comName,</if>
            <if test="projectName != null">projectName,</if>
            <if test="admitGuid != null">admitGuid,</if>
            <if test="eventGuid != null">eventGuid,</if>
            <if test="inPhoto != null">inPhoto,</if>
            <if test="outPhoto != null">outPhoto,</if>
            <if test="state != null">state,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="comId != null">#{comId},</if>
            <if test="projectId != null">#{projectId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="userName != null">#{userName},</if>
            <if test="subDeptGroup != null">#{subDeptGroup},</if>
            <if test="subDeptGroupName != null">#{subDeptGroupName},</if>
            <if test="craftType != null">#{craftType},</if>
            <if test="craftPost != null">#{craftPost},</if>
            <if test="inTime != null">#{inTime},</if>
            <if test="inData != null">#{inData},</if>
            <if test="outTime != null">#{outTime},</if>
            <if test="outData != null">#{outData},</if>
            <if test="deviceNo != null">#{deviceNo},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="subDeptId != null">#{subDeptId},</if>
            <if test="subDeptName != null">#{subDeptName},</if>
            <if test="comName != null">#{comName},</if>
            <if test="projectName != null">#{projectName},</if>
            <if test="admitGuid != null">#{admitGuid},</if>
            <if test="eventGuid != null">#{eventGuid},</if>
            <if test="inPhoto != null">#{inPhoto},</if>
            <if test="outPhoto != null">#{outPhoto},</if>
            <if test="state != null">#{state},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateAttendanceUbiData" parameterType="AttendanceUbiData">
        update attendance_ubi_data
        <trim prefix="SET" suffixOverrides=",">
            <if test="comId != null">comId = #{comId},</if>
            <if test="projectId != null">projectId = #{projectId},</if>
            <if test="userId != null">userId = #{userId},</if>
            <if test="userName != null">userName = #{userName},</if>
            <if test="subDeptGroup != null">sub_dept_group = #{subDeptGroup},</if>
            <if test="subDeptGroupName != null">sub_dept_group_name = #{subDeptGroupName},</if>
            <if test="craftType != null">craft_type = #{craftType},</if>
            <if test="craftPost != null">craft_post = #{craftPost},</if>
            <if test="inTime != null">inTime = #{inTime},</if>
            <if test="inData != null">inData = #{inData},</if>
            <if test="outTime != null">outTime = #{outTime},</if>
            <if test="outData != null">outData = #{outData},</if>
            <if test="deviceNo != null">deviceNo = #{deviceNo},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="subDeptId != null">sub_dept_id = #{subDeptId},</if>
            <if test="subDeptName != null">sub_dept_name = #{subDeptName},</if>
            <if test="comName != null">comName = #{comName},</if>
            <if test="projectName != null">projectName = #{projectName},</if>
            <if test="admitGuid != null">admitGuid = #{admitGuid},</if>
            <if test="eventGuid != null">eventGuid = #{eventGuid},</if>
            <if test="inPhoto != null">inPhoto = #{inPhoto},</if>
            <if test="outPhoto != null">outPhoto = #{outPhoto},</if>
            <if test="state != null">state = #{state},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAttendanceUbiDataById" parameterType="Long">
        delete from attendance_ubi_data where id = #{id}
    </delete>

    <delete id="deleteAttendanceUbiDataByIds" parameterType="String">
        delete from attendance_ubi_data where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>