<?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.dxhy.erp.dao.RequestRecordDao">

    <resultMap id="BaseResultMap" type="com.dxhy.erp.entity.BaseRequestRecordVO">
        <id column="id" property="id" />
        <result column="request_detail" property="requestDetail" />
        <result column="response_detail" property="responseDetail" />
        <result column="port_name" property="portName" />
        <result column="retry_times" property="retryTimes" />
        <result column="failed_times" property="failedTimes" />
        <result column="create_time" property="createTime" />
        <result column="status" property="status" />
        <result column="method_name" property="methodName" />
    </resultMap>

    <resultMap id="DetailResultMap" type="com.dxhy.erp.entity.RequestRecord">
        <id column="id" property="id" />
        <result column="bzdh" property="bzdh" />
        <result column="invoice_code" property="invoiceCode" />
        <result column="image_id" property="imageId" />
        <result column="invoice_no" property="invoiceNo" />
        <result column="request_detail" property="requestDetail" />
        <result column="response_detail" property="responseDetail" />
        <result column="port_name" property="portName" />
        <result column="retry_times" property="retryTimes" />
        <result column="failed_times" property="failedTimes" />
        <result column="create_time" property="createTime" />
        <result column="last_retry_time" property="lastRetryTime" />
        <result column="status" property="status" />
        <result column="method_name" property="methodName" />
        <result column="active_call" property="activeCall"/>
        <result column="failed_reason" property="failedReason"/>
        <result column="recall_response_detail" property="recallResponseDetail"/>
        <result column="active_call_response" property="activeCallResponse"/>
        <result column="is_recall" property="isRecall"/>
        <result column="active_call_recall_response" property="activeCallRecallResponse"/>
        <result column="active_call_request_detail" property="activeCallRequestDetail"/>
    </resultMap>

    <select id="selectRecordList" resultMap="BaseResultMap">
        select
        id,
        request_detail,
        response_detail,
        port_name,
        retry_times,
        failed_times,
        create_time,
        status,
        method_name from t_dx_erp_request_record
        <where>
            <if test="portName!=null and portName!=''">
                and port_name=#{portName}
            </if>
            <if test="startTime!=null">
                and create_time>=#{startTime}
            </if>
            <if test="endTime!=null">
                <![CDATA[
                and create_time<=#{endTime}
                ]]>
            </if>
            <if test="status!=null and status!=''">
                and status=#{status}
            </if>
            <if test="methodName!=null and methodName!=''">
                and method_name=#{methodName}
            </if>
        </where>
        <if test="orderBy==1">
            order by create_time desc
        </if>
        <if test="orderBy==0">
            order by create_time asc
        </if>

    </select>

    <select id="selectDetailRecord" resultMap="DetailResultMap">
        select
        id,
        bzdh,
        invoice_code,
        image_id,
        invoice_no,
        request_detail,
        response_detail,
        port_name,
        retry_times,
        failed_times,
        create_time,
        status,
        last_retry_time,
        method_name,
        active_call,
        failed_reason,
        recall_response_detail,
        active_call_response,
        is_recall,
        active_call_recall_response,
        active_call_request_detail
        from t_dx_erp_request_record where id = #{id}
    </select>

</mapper>