<?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.xrtygis.callCenterMapper.ServiceList1000Mapper">

    <resultMap id="serviceList1000Map" type="com.tofly.xrtygis.entity.callCenter.ServiceList1000">
        <id property="id" column="ID"/>
        <result property="taskcalltype" column="TASKCALLTYPE"/>
        <result property="serviceconnectionid" column="SERVICECONNECTIONID"/>
        <result property="connectionid" column="CONNECTIONID"/>
        <result property="cusid" column="CUSID"/>
        <result property="telephone" column="TELEPHONE"/>
        <result property="sysphone" column="SYSPHONE"/>
        <result property="callType" column="CALL_TYPE"/>
        <result property="serviceType" column="SERVICE_TYPE"/>
        <result property="callTime" column="CALL_TIME"/>
        <result property="connectTime" column="CONNECT_TIME"/>
        <result property="hangupTime" column="HANGUP_TIME"/>
        <result property="agentCallTime" column="AGENT_CALL_TIME"/>
        <result property="agentAnswerTime" column="AGENT_ANSWER_TIME"/>
        <result property="agentEndProcessTime" column="AGENT_END_PROCESS_TIME"/>
        <result property="agentHangupTime" column="AGENT_HANGUP_TIME"/>
        <result property="times" column="TIMES"/>
        <result property="callResult" column="CALL_RESULT"/>
        <result property="transferResult" column="TRANSFER_RESULT"/>
        <result property="callFailresult" column="CALL_FAILRESULT"/>
        <result property="causeValue" column="Cause_Value"/>
        <result property="causeDesc" column="Cause_Desc"/>
        <result property="deptid" column="DEPTID"/>
        <result property="empcode" column="EMPCODE"/>
        <result property="transferNo" column="TRANSFER_NO"/>
        <result property="recordFile" column="RECORD_FILE"/>
        <result property="datacode" column="DATACODE"/>
        <result property="dataid" column="DATAID"/>
        <result property="taskid" column="TASKID"/>
        <result property="taskdataid" column="TASKDATAID"/>
        <result property="hangupflag" column="HANGUPFLAG"/>
        <result property="reason" column="REASON"/>
        <result property="callerFlag" column="CALLER_FLAG"/>
        <result property="callerCode" column="CALLER_CODE"/>
        <result property="satisfactionScore" column="SATISFACTION_SCORE"/>
        <result property="queryid" column="queryid"/>
        <association property="taskcalltypeName" column="TASKCALLTYPE"
                     select="getTaskcalltypeName"/>
        <association property="callTypeName" column="CALL_TYPE"
                     select="getCallTypeName"/>
        <association property="serviceTypeName" column="SERVICE_TYPE"
                     select="getServiceTypeName"/>
        <association property="callResultName" column="CALL_RESULT"
                     select="getCallResultName"/>
        <association property="transferResultName" column="TRANSFER_RESULT"
                     select="getTransferResultName"/>
        <association property="callFailresultName" column="CALL_FAILRESULT"
                     select="getCallFailresultName"/>
        <association property="hangupflagName" column="HANGUPFLAG"
                     select="getHangupflagName"/>
    </resultMap>

    <select id="getTaskcalltypeName" resultType="string">
        SELECT (
                   CASE #{taskcalltype}
                       WHEN '2' THEN
                           '任务营销预拨号'
                       WHEN '3' THEN
                           '客户营销预拨号'
                       END
                   )
        from dual


    </select>

    <select id="getCallTypeName" resultType="string">
        select ELT(#{callType}, '呼入', '呼出')
        from dual
    </select>

    <select id="getServiceTypeName" resultType="string">
        select ELT(#{serviceType}, '转坐席', '转外线', '转分机')
        from dual
    </select>

    <select id="getCallResultName" resultType="string">
        SELECT (
                   CASE #{callResult}
                       WHEN '0' THEN
                           '未呼叫'
                       WHEN '1' THEN
                           '接通'
                       WHEN '2' THEN
                           '无应答'
                       WHEN '3' THEN
                           '用户忙'
                       WHEN '4' THEN
                           '空关停'
                       WHEN '5' THEN
                           '其它错误'
                       WHEN '99' THEN
                           '外呼中'
                       END
                   )
        from dual


    </select>

    <select id="getTransferResultName" resultType="string">
        SELECT (
                   CASE #{transferResult}
                       WHEN '1' THEN
                           '接通'
                       WHEN '2' THEN
                           '坐席忙'
                       WHEN '3' THEN
                           '无应答'
                       WHEN '4' THEN
                           '坐席拒绝'
                       WHEN '5' THEN
                           '坐席未登录'
                       WHEN '6' THEN
                           '振铃中挂机'
                       WHEN '7' THEN
                           '转接中挂机'
                       WHEN '8' THEN
                           '未转坐席挂机'
                       WHEN '9' THEN
                           '其它错误'
                       END
                   )
        from dual


    </select>

    <select id="getCallFailresultName" resultType="string">
        SELECT (
                   CASE #{callFailresult}
                       WHEN '2' THEN
                           '无应答'
                       WHEN '3' THEN
                           '用户忙'
                       WHEN '4' THEN
                           '空关停'
                       WHEN '5' THEN
                           '其它错误'
                       WHEN '99' THEN
                           '外呼中'
                       END
                   )
        from dual


    </select>

    <select id="getHangupflagName" resultType="string">
        select ELT(#{hangupflag}, '坐席挂机', '客户挂机')
        from dual
    </select>


</mapper>
