TEntranceGuardPersonInfoMapper.xml 7.44 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
<?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.zehong.system.mapper.TEntranceGuardPersonInfoMapper">
    
    <resultMap type="TEntranceGuardPersonInfo" id="TEntranceGuardPersonInfoResult">
        <result property="entranceGuardPersonId"    column="entrance_guard_person_id"    />
        <result property="personName"    column="person_name"    />
        <result property="personNum"    column="person_num"    />
        <result property="actionType"    column="action_type"    />
        <result property="actionTime"    column="action_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <resultMap id="statisticsPersonByActionTypeResult"   type="HashMap">
        <result property="actionType" column="action_type" jdbcType="VARCHAR" />
        <result property="counts" column="counts" jdbcType="DATE"/>
    </resultMap>

    <sql id="selectTEntranceGuardPersonInfoVo">
        select entrance_guard_person_id, person_name, person_num, action_type, action_time, create_by, create_time, update_by, update_time, is_del, remark from t_entrance_guard_person_info
    </sql>

    <select id="selectTEntranceGuardPersonInfoList" parameterType="TEntranceGuardPersonInfo" resultMap="TEntranceGuardPersonInfoResult">
        <include refid="selectTEntranceGuardPersonInfoVo"/>
        <where>  
            <if test="personName != null  and personName != ''"> and person_name like concat('%', #{personName}, '%')</if>
            <if test="personNum != null  and personNum != ''"> and person_num = #{personNum}</if>
            <if test="actionType != null  and actionType != ''"> and action_type = #{actionType}</if>
            <if test="actionTime != null "> and action_time = #{actionTime}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectTEntranceGuardPersonInfoById" parameterType="Long" resultMap="TEntranceGuardPersonInfoResult">
        <include refid="selectTEntranceGuardPersonInfoVo"/>
        where entrance_guard_person_id = #{entranceGuardPersonId}
    </select>
        
    <insert id="insertTEntranceGuardPersonInfo" parameterType="TEntranceGuardPersonInfo" useGeneratedKeys="true" keyProperty="entranceGuardPersonId">
        insert into t_entrance_guard_person_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="personName != null">person_name,</if>
            <if test="personNum != null">person_num,</if>
            <if test="actionType != null">action_type,</if>
            <if test="actionTime != null">action_time,</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>
            <if test="isDel != null">is_del,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="personName != null">#{personName},</if>
            <if test="personNum != null">#{personNum},</if>
            <if test="actionType != null">#{actionType},</if>
            <if test="actionTime != null">#{actionTime},</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>
            <if test="isDel != null">#{isDel},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTEntranceGuardPersonInfo" parameterType="TEntranceGuardPersonInfo">
        update t_entrance_guard_person_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="personName != null">person_name = #{personName},</if>
            <if test="personNum != null">person_num = #{personNum},</if>
            <if test="actionType != null">action_type = #{actionType},</if>
            <if test="actionTime != null">action_time = #{actionTime},</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>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where entrance_guard_person_id = #{entranceGuardPersonId}
    </update>

    <delete id="deleteTEntranceGuardPersonInfoById" parameterType="Long">
        delete from t_entrance_guard_person_info where entrance_guard_person_id = #{entranceGuardPersonId}
    </delete>

    <delete id="deleteTEntranceGuardPersonInfoByIds" parameterType="String">
        delete from t_entrance_guard_person_info where entrance_guard_person_id in 
        <foreach item="entranceGuardPersonId" collection="array" open="(" separator="," close=")">
            #{entranceGuardPersonId}
        </foreach>
    </delete>
    
    <select id="statisticsPersonByActionType" resultMap="statisticsPersonByActionTypeResult">
        SELECT
          action_type,
          COUNT(*)AS counts
        FROM
            t_entrance_guard_person_info
        GROUP BY
            action_type
    </select>
    
    <select id="statisticsStayInPersons" resultType="java.lang.String">
        SELECT
            COUNT(*)
        FROM
            (
                (
                    SELECT
                      *
                    FROM
                     (
                       SELECT
                                action_time AS importTime,
                                person_num
                        FROM
                                t_entrance_guard_person_info
                        WHERE
                                action_type = '0'
                        ORDER BY action_time DESC
                     )a
                     GROUP BY a.person_num
                )import,
                (
                   SELECT
                     *
                    FROM
                    (
                      SELECT
                            action_time AS exportTime,
                            person_num
                      FROM
                            t_entrance_guard_person_info
                      WHERE
                            action_type = '1'
                      ORDER BY action_time DESC
                     )b
                    GROUP BY b.person_num
                )export
          )
        WHERE import.person_num = export.person_num AND (export.exportTime - import.importTime) > 0
    </select>

    <select id="lastImportAndExportData"  resultMap="TEntranceGuardPersonInfoResult">
        SELECT
          present.*
        FROM(
            SELECT
                *
            FROM
                t_entrance_guard_person_info
            ORDER BY action_time DESC
        )present
        GROUP BY
            present.action_type
    </select>
</mapper>