<?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="cn.cecep.talroad.mapper.analysis.SRaActionReportsAuditRecordMapper">

    <resultMap type="cn.cecep.talroad.domain.analysis.SRaActionReportsAuditRecord" id="SRaActionReportsAuditRecordResult">
        <result property="id"    column="id"    />
        <result property="reportId"    column="report_id"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="totalEnterprises"    column="total_enterprises"    />
        <result property="submittedEnterprises"    column="submitted_enterprises"    />
        <result property="auditedEnterprises"    column="audited_enterprises"    />
        <result property="problemsEnterprises"    column="problems_enterprises"    />
        <result property="auditStatus"    column="audit_status"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>


    <sql id="selectSRaActionReportsAuditRecordVo">
        select id, report_id, audit_time, total_enterprises, submitted_enterprises, audited_enterprises, problems_enterprises, audit_status, update_time, create_time, create_by, update_by from s_ra_action_reports_audit_record
    </sql>

    <select id="selectSRaActionReportsAuditRecordList" parameterType="cn.cecep.talroad.domain.analysis.SRaActionReportsAuditRecord" resultMap="SRaActionReportsAuditRecordResult">
        <include refid="selectSRaActionReportsAuditRecordVo"/>
        <where>
            <if test="reportId != null  and reportId != ''"> and report_id = #{reportId}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="totalEnterprises != null "> and total_enterprises = #{totalEnterprises}</if>
            <if test="submittedEnterprises != null "> and submitted_enterprises = #{submittedEnterprises}</if>
            <if test="auditedEnterprises != null "> and audited_enterprises = #{auditedEnterprises}</if>
            <if test="problemsEnterprises != null "> and problems_enterprises = #{problemsEnterprises}</if>
            <if test="auditStatus != null "> and audit_status = #{auditStatus}</if>
        </where>
    </select>
    <select id="recordList" resultType="cn.cecep.talroad.domain.vo.AuditRecordLIstVO">
        select
        factoryInfo.id,
        factory.factory_name ,
        report.report_time ,
        factory.city_name ,
        factory.country_name,
        industry.indus_name as industryName,
        factory.license_man_type,
        factoryInfo.commit_time,
        factory.poll_dis_license_code
        from s_ra_action_reports_audit_factory_info factoryInfo
        left join pc_factory factory on factoryinfo.factory_id  = factory.id
        left join s_ra_action_reports_audit report on factoryInfo.report_id = report.id
        left join pc_industry industry on factory.industry_category = industry.indus_code
        where factoryInfo.audit_status  = 0
          <if test="recordListDTO.factoryName != null and recordListDTO.factoryName != ''">
              and factory.factory_name = #{recordListDTO.factoryName}
          </if>
        <if test="recordListDTO.industryCode != null and recordListDTO.industryCode != ''">
            and factory.industry_category  = #{recordListDTO.industryCode}
        </if>
        <if test="recordListDTO.countryName != null and recordListDTO.countryName != ''">
            and factory.country_name = #{recordListDTO.countryName}
        </if>
        <if test="recordListDTO.licenseManType != null and recordListDTO.licenseManType != ''">
            and factory.license_man_type = #{recordListDTO.licenseManType}
        </if>
        <if test="recordListDTO.commitTimeStart != null and recordListDTO.commitTimeStart != '' and recordListDTO.commitTimeEnd != null and recordListDTO.commitTimeEnd != ''">
            and factoryInfo.commit_time >= #{recordListDTO.commitTimeStart} and factoryinfo.commit_time &lt;= #{recordListDTO.commitTimeEnd}
        </if>

    </select>

</mapper>
