<?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.tofly.callcenter.mapper.CalllosscountMapper">

    <resultMap id="calllosscountMap" type="com.tofly.callcenter.entity.Calllosscount">
        <id property="tel" column="tel"/>
        <result property="flag" column="flag"/>
        <result property="id" column="id"/>
        <result property="empcode" column="empcode"/>
    </resultMap>

    <select id="calllosscount" resultType="long">
        select count(*)
        from tf_ywpn_calllosscount_w
        where flag = 0
        and empcode = #{empcode}
    </select>

    <select id="getInsertInfo" resultType="com.tofly.callcenter.entity.Calllosscount">
        select *
        from (SELECT TELEPHONE tel, '0' flag, CONNECTIONID id,AGENT_FIRST_CODE empcode
        FROM plt_calllist1000
        WHERE CALL_TYPE = 1
        AND TRANSFER_RESULT in (3, 4, 5, 6)
        and AGENT_FIRST_CODE = #{empcode}
        order by CALL_TIME desc
        limit 100) cc
        where not exists(select * from tf_ywpn_calllosscount_w where id = cc.id)
    </select>

</mapper>
