<?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.roadm.mapper.SmsCompanySignReportInfoMapper">
    <resultMap id="SmsCompanySignReportInfoMap" type="cn.roadm.bo.SmsCompanySignReportInfo">
        <id column="id" property="id"/>
        <result column="signature" property="signature"/>
        <result column="sign_ext_suffix" property="signExtSuffix"/>
        <result column="sign_ext_prefix" property="signExtPrefix"/>
        <result column="sign_ext" property="signExt"/>
        <result column="damians" property="damians"/>
        <result column="phones" property="phones"/>
        <result column="business_category" property="businessCategory"/>
        <result column="business_subcategory" property="businessSubcategory"/>
        <result column="template_content" property="templateContent"/>
        <result column="parameter_type" property="parameterType"/>
        <result column="parameter_length" property="parameterLength"/>
        <result column="sms_type" property="smsType"/>
        <result column="sms_drainage" property="smsDrainage"/>
        <result column="task" property="task"/>
        <result column="file_name" property="fileName"/>
        <result column="create_time" property="createTime"/>
        <result column="status" property="status"/>
        <result column="reason" property="reason"/>
        <result column="submit_uid" property="submitUid"/>
        <result column="audit_uid" property="auditUid"/>
        <result column="report_otype" property="reportOtype"/>
        <result column="support_otype" property="supportOtype"/>
    </resultMap>

    <resultMap id="ExportSmsCompanySignInfoMap" type="cn.roadm.bo.ExportSmsCompanySignInfoDO">
        <result column="signature" property="signature"/>
        <result column="sign_ext_suffix" property="signExtSuffix"/>
        <result column="sign_ext_prefix" property="signExtPrefix"/>
        <result column="sign_ext" property="signExt"/>
        <result column="damians" property="damians"/>
        <result column="phones" property="phones"/>
        <result column="business_category" property="businessCategory"/>
        <result column="business_subcategory" property="businessSubcategory"/>
        <result column="template_content" property="templateContent"/>
        <result column="parameter_type" property="parameterType"/>
        <result column="parameter_length" property="parameterLength"/>
        <result column="sms_type" property="smsType"/>
        <result column="sms_drainage" property="smsDrainage"/>
        <result column="task" property="task"/>
        <result column="file_name" property="fileName"/>
        <result column="create_time" property="createTime"/>
        <result column="company_name" property="companyName"/>
        <result column="company_code" property="companyCode"/>
        <result column="business_pic_path" property="businessPicPath"/>
        <result column="legal_name" property="legalName"/>
        <result column="legal_cert_type" property="legalCertType"/>
        <result column="legal_cert_id" property="legalCertId"/>
        <result column="legal_identity_card_path" property="legalIdentityCardPath"/>
        <result column="agency_name" property="agencyName"/>
        <result column="agency_cert_type" property="agencyCertType"/>
        <result column="agency_cert_id" property="agencyCertId"/>
        <result column="agency_phone" property="agencyPhone"/>
        <result column="agency_identity_card_path" property="agencyIdentityCardPath"/>

        <result column="lt_agency_name" property="ltAgencyName"/>
        <result column="lt_agency_cert_type" property="ltAgencyCertType"/>
        <result column="lt_agency_cert_id" property="ltAgencyCertId"/>
        <result column="lt_agency_phone" property="ltAgencyPhone"/>
        <result column="lt_agency_identity_card_path" property="ltAgencyIdentityCardPath"/>
        <result column="yd_agency_name" property="ydAgencyName"/>
        <result column="yd_agency_cert_type" property="ydAgencyCertType"/>
        <result column="yd_agency_cert_id" property="ydAgencyCertId"/>
        <result column="yd_agency_phone" property="ydAgencyPhone"/>
        <result column="yd_agency_identity_card_path" property="ydAgencyIdentityCardPath"/>
        <result column="dx_agency_name" property="dxAgencyName"/>
        <result column="dx_agency_cert_type" property="dxAgencyCertType"/>
        <result column="dx_agency_cert_id" property="dxAgencyCertId"/>
        <result column="dx_agency_phone" property="dxAgencyPhone"/>
        <result column="dx_agency_identity_card_path" property="dxAgencyIdentityCardPath"/>
        <result column="sing_source" property="singSource"/>
        <result column="sign_pic" property="signPic"/>
        <result column="trademark_registration_num" property="trademarkRegistrationNum"/>
        <result column="channel_id" property="channelId"/>
        <result column="reportStatus" property="reportStatus"/>
        <result column="sign_id" property="signId"/>
        <result column="company_id" property="companyId"/>
        <result column="source_desc" property="sourceDesc"/>
        <result column="app_store_publish" property="appStorePublish"/>
        <result column="sign_ex_id" property="signExId"/>
    </resultMap>


    <select id="selectById" resultMap="SmsCompanySignReportInfoMap">
        SELECT id, signature, sign_ext_suffix,sign_ext_prefix, sign_ext, damians, phones, business_category, business_subcategory,
               template_content, parameter_type, parameter_length, sms_type, sms_drainage, task, file_name, create_time,report_otype,support_otype,status
        FROM sms_company_sign_report_info
        WHERE id = #{id}
    </select>

    <select id="listPageSelectAll" resultMap="SmsCompanySignReportInfoMap">
        SELECT a.id, a.signature, a.sign_ext_suffix,a.sign_ext_prefix, a.sign_ext, a.damians, a.phones,
        a.business_category, a.business_subcategory, a.status, a.reason, a.submit_uid, a.audit_uid,
        a.template_content, a.parameter_type, a.parameter_length, a.sms_type, a.sms_drainage, a.task, a.file_name,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as create_time,a.report_otype,a.support_otype,b.channelId
        FROM sms_company_sign_report_info a
        left join (select sign_ext,signature,GROUP_CONCAT(NULLIF(channel_id, '') SEPARATOR ',') as channelId from
        sms_company_sign_export_info group by sign_ext ,signature) b
        on a.sign_ext = b.sign_ext and a.signature = b.signature
        <where>
            <if test="signature != null and signature != ''">
                a.signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="task != null and task != ''">
                and a.task = #{task}
            </if>
            <if test="businessCategory != null and businessCategory != ''">
                and a.business_category = #{businessCategory}
            </if>
            <if test="phones != null and phones != ''">
                and a.phones like CONCAT('%',#{phones},'%')
            </if>
            <if test="damians != null and damians != ''">
                and a.damians like CONCAT('%',#{damians},'%')
            </if>
            <if test="signExt != null and signExt != ''">
                and a.sign_ext = #{signExt}
            </if>
            <if test="createTime!=null and createTime!=''">
                and a.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
            </if>
            <if test="status != null">
                and a.status = #{status}
            </if>
            <if test="submitUid != null">
                and a.submit_uid = #{submitUid}
            </if>
            <if test="channelFlag != null and channelFlag!=''">
                <choose>
                    <when test="channelFlag == 2">
                        and (b.channelId is null or b.channelId = '')
                    </when>
                    <when test="channelFlag == 1">
                        and b.channelId is not null
                        and b.channelId != ''
                    </when>
                </choose>
            </if>
            <if test="channelId !=null and channelId !=''">
                and FIND_IN_SET(#{channelId},b.channelId)>0
            </if>

        </where>
        ORDER BY a.id DESC
    </select>

    <select id="listPageSignReportSelectAll" resultMap="SmsCompanySignReportInfoMap">
        SELECT a.id, a.signature, a.sign_ext_suffix,a.sign_ext_prefix, a.sign_ext, a.damians, a.phones,
        a.business_category, a.business_subcategory, a.status, a.reason, a.submit_uid, a.audit_uid,
        a.template_content, a.parameter_type, a.parameter_length, a.sms_type, a.sms_drainage, a.task, a.file_name,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as create_time,a.report_otype,a.support_otype
        FROM sms_company_sign_report_info a
        <where>
            <if test="signature != null and signature != ''">
                a.signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="task != null and task != ''">
                and a.task = #{task}
            </if>
            <if test="businessCategory != null and businessCategory != ''">
                and a.business_category = #{businessCategory}
            </if>
            <if test="phones != null and phones != ''">
                and a.phones like CONCAT('%',#{phones},'%')
            </if>
            <if test="damians != null and damians != ''">
                and a.damians like CONCAT('%',#{damians},'%')
            </if>
            <if test="signExt != null and signExt != ''">
                and a.sign_ext = #{signExt}
            </if>
            <if test="createTime!=null and createTime!=''">
                and a.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
            </if>
            <if test="status != null">
                and a.status = #{status}
            </if>
            <if test="submitUid != null">
                and a.submit_uid = #{submitUid}
            </if>

        </where>
        ORDER BY a.id DESC
    </select>

    <select id="selectAll" resultMap="SmsCompanySignReportInfoMap">
        SELECT a.id, a.signature, a.sign_ext_suffix,a.sign_ext_prefix, a.sign_ext, a.damians, a.phones,
        a.business_category, a.business_subcategory, a.status, a.reason, a.submit_uid, a.audit_uid,
        a.template_content, a.parameter_type, a.parameter_length, a.sms_type, a.sms_drainage, a.task, a.file_name,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as create_time,a.report_otype,a.support_otype,b.channelId
        FROM sms_company_sign_report_info a
        left join (select sign_ext,signature,GROUP_CONCAT(NULLIF(channel_id, '') SEPARATOR ',') as channelId from
        sms_company_sign_export_info group by sign_ext ,signature) b
        on a.sign_ext = b.sign_ext and a.signature = b.signature
        <where>
            <if test="signature != null and signature != ''">
                a.signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="task != null and task != ''">
                and a.task = #{task}
            </if>
            <if test="businessCategory != null and businessCategory != ''">
                and a.business_category = #{businessCategory}
            </if>
            <if test="phones != null and phones != ''">
                and a.phones like CONCAT('%',#{phones},'%')
            </if>
            <if test="damians != null and damians != ''">
                and a.damians like CONCAT('%',#{damians},'%')
            </if>
            <if test="signExt != null and signExt != ''">
                and a.sign_ext = #{signExt}
            </if>
            <if test="createTime!=null and createTime!=''">
                and a.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
            </if>
            <if test="status != null">
                and a.status = #{status}
            </if>
            <if test="submitUid != null">
                and a.submit_uid = #{submitUid}
            </if>
            <if test="channelFlag != null and channelFlag!=''">
                <choose>
                    <when test="channelFlag == 2">
                        and (b.channelId is null or b.channelId = '')
                    </when>
                    <when test="channelFlag == 1">
                        and b.channelId is not null
                        and b.channelId != ''
                    </when>
                </choose>
            </if>
            <if test="channelId !=null and channelId !=''">
                and FIND_IN_SET(#{channelId},b.channelId)>0
            </if>
            <if test="ids!=null and ids!=''">
                and a.id in
                <foreach collection="idList" index="index"  item="id" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        ORDER BY a.id DESC
    </select>

    <select id="selectBySignature" resultMap="SmsCompanySignReportInfoMap">
        SELECT id, signature, sign_ext_suffix,sign_ext_prefix, sign_ext, damians, phones, business_category, business_subcategory,
               template_content, parameter_type, parameter_length, sms_type, sms_drainage, task, file_name, create_time,report_otype,support_otype
        FROM sms_company_sign_report_info
        WHERE signature = #{signature}
    </select>

    <insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="cn.roadm.bo.SmsCompanySignReportInfo">
        INSERT INTO sms_company_sign_report_info (
            signature, sign_ext_suffix,sign_ext_prefix, sign_ext, damians, phones, business_category, business_subcategory,
            template_content, parameter_type, parameter_length, sms_type, sms_drainage, task, file_name, create_time, submit_uid, audit_uid,report_otype
        )
        VALUES (
            #{signature}, #{signExtSuffix},#{signExtPrefix}, #{signExt}, #{damians}, #{phones}, #{businessCategory}, #{businessSubcategory},
            #{templateContent}, #{parameterType}, #{parameterLength}, #{smsType}, #{smsDrainage}, #{task}, #{fileName}, now(), #{submitUid}, #{auditUid},#{reportOtype}
        )
    </insert>

    <update id="update" parameterType="cn.roadm.bo.SmsCompanySignReportInfo">
        UPDATE sms_company_sign_report_info
        <set>
            <if test="signature != null and signature != ''">
                signature = #{signature},
            </if>
            <if test="signExtSuffix != null and signExtSuffix != ''">
                sign_ext_suffix = #{signExtSuffix},
            </if>
            <if test="signExtPrefix != null and signExtPrefix != ''">
                sign_ext_prefix = #{signExtPrefix},
            </if>
            <if test="signExt != null and signExt != ''">
                sign_ext = #{signExt},
            </if>
            <if test="damians != null">
                damians = #{damians},
            </if>
            <if test="phones != null">
                phones = #{phones},
            </if>
            <if test="businessCategory != null">
                business_category = #{businessCategory},
            </if>
            <if test="businessSubcategory != null">
                business_subcategory = #{businessSubcategory},
            </if>
            <if test="templateContent != null">
                template_content = #{templateContent},
            </if>
            <if test="parameterType != null">
                parameter_type = #{parameterType},
            </if>
            <if test="parameterLength != null">
                parameter_length = #{parameterLength},
            </if>
            <if test="smsType != null">
                sms_type = #{smsType},
            </if>
            <if test="smsDrainage != null">
                sms_drainage = #{smsDrainage},
            </if>
            <if test="task != null">
                task = #{task},
            </if>
            <if test="fileName != null">
                file_name = #{fileName},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="auditUid != null">
                audit_uid = #{auditUid},
            </if>
            <if test="reportOtype != null and reportOtype!=''">
                report_otype = #{reportOtype},
            </if>
            <if test="supportOtype != null and supportOtype!=''">
                support_otype = #{supportOtype},
            </if>
        </set>
        WHERE id = #{id}
    </update>

    <delete id="deleteById">
        DELETE FROM sms_company_sign_report_info
        WHERE id = #{id}
    </delete>

    <delete id="deleteByChannelIdAndExtend">
        DELETE FROM sms_company_sign_export_info WHERE channel_id = #{channelId} and sign_ext = #{extend}
    </delete>

    <insert id="insertFileInfo" parameterType="cn.roadm.bo.SmsCompanySignReportFileInfo">
        insert into sms_company_sign_report_file_info (task,file_name,real_name,file_url,status,create_time,submit_uid)
        value(#{task},#{fileName},#{realName},#{fileUrl},#{status},now(),#{submitUid})
    </insert>

    <select id="listPageSelectAllFile" resultType="cn.roadm.bo.SmsCompanySignReportFileInfo">
        select a.id,a.task,a.file_name as fileName,a.file_url as fileUrl,a.status,a.import_msg as importMsg,
        DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime,a.submit_uid as submitUid,b.name as userName
        from sms_company_sign_report_file_info a left join sms_user_info b on a.submit_uid = b.id
        <where>
            <if test="status!=null">
                a.status = #{status}
            </if>
            <if test="task!=null and task!=''">
                and a.task = #{task}
            </if>
            <if test="fileName!=null and fileName!=''">
                and a.file_name = #{fileName}
            </if>
        </where>
        order by a.create_time desc
    </select>

    <select id="selectAllExtendFromBypass" resultType="string">
        select distinct mobile_suffix from sms_sign_bypass
    </select>

    <select id="selectCountFromBypassBySignExt" resultType="int">
        select count(1) from sms_sign_bypass where mobile_suffix=#{signExt}
    </select>

    <select id="selectSignExtendDesc" resultMap="SmsCompanySignReportInfoMap">
        select distinct signature,sign_ext FROM sms_company_sign_report_info order by sign_ext desc
    </select>

    <select id="selectMaxSignExtendSuffix" resultMap="SmsCompanySignReportInfoMap">
        select signature,max(sign_ext_suffix) as sign_ext_suffix FROM sms_company_sign_report_info group by signature
    </select>

    <select id="selectExtendPrefix" resultType="SmsCompanySignInfo">
        select sign_ext_prefix as signExtPrefix,sign_customize as signCustomize,sign_ext_suffix_digit as signExtSuffixDigit
        FROM sms_company_sign_info where flag = 1
        <if test="signature!=null and signature!=''">
            and signature = #{signature}
        </if>
        <if test="signExtPrefix!=null and signExtPrefix!=''">
            and sign_ext_prefix = #{signExtPrefix}
        </if>
    </select>

    <select id="selectMaxSignExtend" resultType="string">
        select max(sign_ext+0) from sms_company_sign_report_info where sign_ext_prefix =#{prefix} and status = 1  and sign_ext_prefix != sign_ext
    </select>

    <update id="updateFileInfoStatus" parameterType="cn.roadm.bo.SmsCompanySignReportFileInfo">
        update sms_company_sign_report_file_info set status = #{status}
        <if test="importMsg!=null and importMsg!=''">
            , import_msg = #{importMsg}
        </if>
        where id = #{id}
    </update>

    <select id="selectAllChannelInfo" resultType="cn.roadm.bo.ChannelAttributeBO">
        select channel_id as channelId,channel_name as channelName,otype from channel_attribute where state = 0
    </select>

    <select id="selectChannelInfoByOtype" resultType="cn.roadm.bo.ChannelAttributeBO">
        select channel_id as channelId,channel_name as channelName,otype from channel_attribute where state = 0
        <if test="otype != null and otype != ''">
            and otype = #{otype}
        </if>
    </select>

    <select id="getChannelAttributeByChannelId" resultType="cn.roadm.bo.ChannelAttributeBO">
        select a.channel_id as channelId,a.channel_name as channelName,a.otype,a.call_mdn as callMdn,a.province,
        a.city,a.export_template as exportTemplate,a.operator_gateway as operatorGateway,
        a.equipment_room_location as equipmentRoomLocation,a.tBaseSpId,a.mdn_company_name as mdnCompanyName,
        a.channel_report_ip as channelReportIp,b.MOBILE_PREFIX as mobilePrefix
        from channel_attribute a left join sms_send_channel_info b on a.channel_id = b.ID
        where a.state = 0 and a.channel_id = #{channelId}
    </select>

    <select id="getChannelAttributeByChannelIds" resultType="cn.roadm.bo.ChannelAttributeBO">
        select channel_id as channelId,channel_name as channelName,otype,call_mdn as callMdn,province,
        city,export_template as exportTemplate,operator_gateway as operatorGateway,
        equipment_room_location as equipmentRoomLocation,tBaseSpId,mdn_company_name as mdnCompanyName,channel_report_ip as channelReportIp
        from channel_attribute where state = 0 and channel_id in (${channelIds})
    </select>

    <select id="selectExportData" resultMap="ExportSmsCompanySignInfoMap">
        SELECT scsri.signature,scsri.sign_ext_suffix,scsri.sign_ext_prefix, scsri.sign_ext, scsri.damians, scsri.phones,
        scsri.business_category, scsri.business_subcategory, scsri.template_content, scsri.parameter_type,
        scsri.parameter_length, scsri.sms_type, scsri.sms_drainage, scsri.task, DATE_FORMAT(scsri.create_time, '%Y-%m-%d %H:%i:%s') as createTime,
        sci.company_name,sci.company_code,sci.business_pic_path,sci.legal_name,sci.legal_cert_type,sci.legal_cert_id,sci.legal_identity_card_path,
        sci.agency_name,sci.agency_cert_type,sci.agency_cert_id,sci.agency_phone,sci.agency_identity_card_path,
        sci.lt_agency_name,sci.lt_agency_cert_type,sci.lt_agency_cert_id,sci.lt_agency_phone,sci.lt_agency_identity_card_path,
        sci.yd_agency_name,sci.yd_agency_cert_type,sci.yd_agency_cert_id,sci.yd_agency_phone,sci.yd_agency_identity_card_path,
        sci.dx_agency_name,sci.dx_agency_cert_type,sci.dx_agency_cert_id,sci.dx_agency_phone,sci.dx_agency_identity_card_path,
        scsi.sing_source,scsi.sign_pic,scsi.trademark_registration_num,scsi.id as sign_id,sci.id as company_id,
        scsi.source_desc,scsi.app_store_publish,scsri.sign_ext_prefix as sign_ex_id
        FROM sms_company_sign_report_info scsri
        left join sms_company_sign_info scsi on scsri.sign_ext_prefix = scsi.sign_ext_prefix
        left join sms_company_info sci on scsi.company_code = sci.company_code where scsri.status = 1 and scsi.flag = 1
        <if test="signature != null and signature != ''">
           and scsri.signature like CONCAT('%',#{signature},'%')
        </if>
        <if test="task != null and task != ''">
            and scsri.task = #{task}
        </if>
        <if test="signExt != null and signExt != ''">
            and scsri.sign_ext = #{signExt}
        </if>
        <if test="createTime!=null and createTime!=''">
            and scsri.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
        </if>
        <if test="endTime!=null and endTime!=''">
            and scsri.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
        </if>
        <if test="batchSign!=null and batchSign!=''">
            and scsri.signature in
            <foreach collection="signList" index="index"  item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="ids!=null and ids!=''">
            and scsri.id in
            <foreach collection="idList" index="index"  item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>

    <select id="selectExportData2" resultMap="ExportSmsCompanySignInfoMap">
        SELECT a.channel_id,a.status as reportStatus,COALESCE(a.signature, scsri.signature) as signature,
        scsri.sign_ext_suffix,COALESCE(a.sign_ext, scsri.sign_ext) as sign_ext,COALESCE(a.sign_ext_prefix, scsri.sign_ext_prefix) as sign_ext_prefix,
        COALESCE(a.damians, scsri.damians) as damians, COALESCE(a.phones, scsri.phones) as phones,
        COALESCE(a.business_category, scsri.business_category) as business_category, 
        COALESCE(a.business_subcategory, scsri.business_subcategory) as business_subcategory, 
        COALESCE(a.template_content, scsri.template_content) as template_content, 
        COALESCE(a.parameter_type, scsri.parameter_type) as parameter_type,
        COALESCE(a.parameter_length, scsri.parameter_length) as parameter_length, 
        COALESCE(a.sms_type, scsri.sms_type) as sms_type, scsri.sms_drainage,
        COALESCE(a.task, scsri.task) as task,
        DATE_FORMAT(COALESCE(a.create_time, scsri.create_time), '%Y-%m-%d %H:%i:%s') as createTime,
        COALESCE(a.company_name, sci.company_name) as company_name,
        COALESCE(a.company_code, sci.company_code) as company_code,
        COALESCE(a.business_pic_path, sci.business_pic_path) as business_pic_path,
        COALESCE(a.legal_name, sci.legal_name) as legal_name,
        COALESCE(a.legal_cert_type, sci.legal_cert_type) as legal_cert_type,
        COALESCE(a.legal_cert_id, sci.legal_cert_id) as legal_cert_id,
        COALESCE(a.legal_identity_card_path, sci.legal_identity_card_path) as legal_identity_card_path,
        COALESCE(a.agency_name, sci.agency_name) as agency_name,
        COALESCE(a.agency_cert_type, sci.agency_cert_type) as agency_cert_type,
        COALESCE(a.agency_cert_id, sci.agency_cert_id) as agency_cert_id,
        COALESCE(a.agency_phone, sci.agency_phone) as agency_phone,
        COALESCE(a.agency_identity_card_path, sci.agency_identity_card_path) as agency_identity_card_path,
        COALESCE(a.lt_agency_name, sci.lt_agency_name) as lt_agency_name,
        COALESCE(a.lt_agency_cert_type, sci.lt_agency_cert_type) as lt_agency_cert_type,
        COALESCE(a.lt_agency_cert_id, sci.lt_agency_cert_id) as lt_agency_cert_id,
        COALESCE(a.lt_agency_phone, sci.lt_agency_phone) as lt_agency_phone,
        COALESCE(a.lt_agency_identity_card_path, sci.lt_agency_identity_card_path) as lt_agency_identity_card_path,
        COALESCE(a.yd_agency_name, sci.yd_agency_name) as yd_agency_name,
        COALESCE(a.yd_agency_cert_type, sci.yd_agency_cert_type) as yd_agency_cert_type,
        COALESCE(a.yd_agency_cert_id, sci.yd_agency_cert_id) as yd_agency_cert_id,
        COALESCE(a.yd_agency_phone, sci.yd_agency_phone) as yd_agency_phone,
        COALESCE(a.yd_agency_identity_card_path, sci.yd_agency_identity_card_path) as yd_agency_identity_card_path,
        COALESCE(a.dx_agency_name, sci.dx_agency_name) as dx_agency_name,
        COALESCE(a.dx_agency_cert_type, sci.dx_agency_cert_type) as dx_agency_cert_type,
        COALESCE(a.dx_agency_cert_id, sci.dx_agency_cert_id) as dx_agency_cert_id,
        COALESCE(a.dx_agency_phone, sci.dx_agency_phone) as dx_agency_phone,
        COALESCE(a.dx_agency_identity_card_path, sci.dx_agency_identity_card_path) as dx_agency_identity_card_path,
        COALESCE(a.sing_source, scsi.sing_source) as sing_source,
        COALESCE(a.sign_pic, scsi.sign_pic) as sign_pic,
        COALESCE(a.trademark_registration_num, scsi.trademark_registration_num) as trademark_registration_num,
        COALESCE(a.sign_id, scsi.id) as sign_id,
        COALESCE(a.company_id, sci.id) as company_id,
        COALESCE(a.source_desc, scsi.source_desc) as source_desc,
        COALESCE(a.app_store_publish, scsi.app_store_publish) as app_store_publish,
        COALESCE(a.sign_ex_id, a.sign_ext_prefix, scsri.sign_ext_prefix) as sign_ex_id
        FROM (select channel_id, signature, sign_ext, status, create_time, 
              damians, phones, business_category, business_subcategory, task, template_content,
              parameter_type, parameter_length, sms_type,
              company_id, company_name, company_code, business_pic_path,
              legal_name, legal_cert_type, legal_cert_id, legal_identity_card_path,
              agency_name, agency_cert_type, agency_cert_id, agency_phone, agency_identity_card_path,
              lt_agency_name, lt_agency_cert_type, lt_agency_cert_id, lt_agency_phone, lt_agency_identity_card_path,
              yd_agency_name, yd_agency_cert_type, yd_agency_cert_id, yd_agency_phone, yd_agency_identity_card_path,
              dx_agency_name, dx_agency_cert_type, dx_agency_cert_id, dx_agency_phone, dx_agency_identity_card_path,
              sign_id, sing_source, sign_pic, trademark_registration_num, source_desc, sign_ext_prefix, app_store_publish, sign_ex_id
              from sms_company_sign_export_info where status != '8'
        <if test="ids!=null and ids!=''">
            and id in
            <foreach collection="idList" index="index"  item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>

        <if test="channelId!=null and channelId!=''">
            and channel_id in
            <foreach collection="channelList" index="index"  item="channel" open="(" separator="," close=")">
                #{channel}
            </foreach>
        </if>

        <if test="batchSign!=null and batchSign!=''">
            and signature in
            <foreach collection="signList" index="index"  item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="status!=null and status!=''">
            and status in
            <foreach collection="statusList" index="index"  item="item" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>

        <if test="task!=null and task!=''">
            and task = #{task}
        </if>

        <if test="businessCategory!=null and businessCategory!=''">
            and business_category = #{businessCategory}
        </if>

        <if test="phones!=null and phones!=''">
            and phones like CONCAT('%',#{phones},'%')
        </if>

        <if test="damians!=null and damians!=''">
            and damians like CONCAT('%',#{damians},'%')
        </if>

        <if test="createTime!=null and createTime!=''">
            and create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
        </if>
        <if test="endTime!=null and endTime!=''">
            and create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
        </if>
        ) a
        left join sms_company_sign_report_info scsri on a.sign_ext = scsri.sign_ext and a.signature = scsri.signature
        left join sms_company_sign_info scsi on scsri.sign_ext_prefix = scsi.sign_ext_prefix
        left join sms_company_info sci on scsi.company_code = sci.company_code
        left join sms_send_channel_info ssch on a.channel_id = ssch.id
        left join (select * from channel_attribute where state = 0) ca on ssch.id = ca.channel_id
        where scsri.status = 1 and scsi.flag = 1
        <if test="otype!=null and otype!=''">
            and ca.otype = #{otype}
        </if>
        <if test="task!=null and task!=''">
            and (a.task = #{task} or (a.task is null and scsri.task = #{task}))
        </if>
        <if test="businessCategory!=null and businessCategory!=''">
            and (a.business_category = #{businessCategory} or (a.business_category is null and scsri.business_category = #{businessCategory}))
        </if>
        <if test="phones!=null and phones!=''">
            and (a.phones like CONCAT('%',#{phones},'%') or (a.phones is null and scsri.phones like CONCAT('%',#{phones},'%')))
        </if>
        <if test="damians!=null and damians!=''">
            and (a.damians like CONCAT('%',#{damians},'%') or (a.damians is null and scsri.damians like CONCAT('%',#{damians},'%')))
        </if>
    </select>

    <insert id="insertSmsCompanySignExportInfo" parameterType="cn.roadm.bo.SmsCompanySignExportInfo">
        insert into sms_company_sign_export_info (channel_id,signature,sign_ext,status,create_time) value (#{channelId},#{signature},#{signExt},#{status},now());
    </insert>

    <update id="updateSmsCompanySignExportInfo" parameterType="cn.roadm.bo.SmsCompanySignExportInfo">
        update sms_company_sign_export_info
        <set>
            <if test="status != null and status != ''">
                status = #{status},
            </if>
            <if test="damians != null">
                damians = #{damians},
            </if>
            <if test="phones != null">
                phones = #{phones},
            </if>
            <if test="businessCategory != null">
                business_category = #{businessCategory},
            </if>
            <if test="businessSubcategory != null">
                business_subcategory = #{businessSubcategory},
            </if>
            <if test="task != null">
                task = #{task},
            </if>
            <if test="templateContent != null">
                template_content = #{templateContent},
            </if>
            <if test="parameterType != null">
                parameter_type = #{parameterType},
            </if>
            <if test="parameterLength != null">
                parameter_length = #{parameterLength},
            </if>
            <if test="smsType != null">
                sms_type = #{smsType},
            </if>
            <if test="companyId != null">
                company_id = #{companyId},
            </if>
            <if test="companyName != null">
                company_name = #{companyName},
            </if>
            <if test="companyCode != null">
                company_code = #{companyCode},
            </if>
            <if test="businessPicPath != null">
                business_pic_path = #{businessPicPath},
            </if>
            <if test="legalName != null">
                legal_name = #{legalName},
            </if>
            <if test="legalCertType != null">
                legal_cert_type = #{legalCertType},
            </if>
            <if test="legalCertId != null">
                legal_cert_id = #{legalCertId},
            </if>
            <if test="legalIdentityCardPath != null">
                legal_identity_card_path = #{legalIdentityCardPath},
            </if>
            <if test="agencyName != null">
                agency_name = #{agencyName},
            </if>
            <if test="agencyCertType != null">
                agency_cert_type = #{agencyCertType},
            </if>
            <if test="agencyCertId != null">
                agency_cert_id = #{agencyCertId},
            </if>
            <if test="agencyPhone != null">
                agency_phone = #{agencyPhone},
            </if>
            <if test="agencyIdentityCardPath != null">
                agency_identity_card_path = #{agencyIdentityCardPath},
            </if>
            <if test="ltAgencyName != null">
                lt_agency_name = #{ltAgencyName},
            </if>
            <if test="ltAgencyCertType != null">
                lt_agency_cert_type = #{ltAgencyCertType},
            </if>
            <if test="ltAgencyCertId != null">
                lt_agency_cert_id = #{ltAgencyCertId},
            </if>
            <if test="ltAgencyPhone != null">
                lt_agency_phone = #{ltAgencyPhone},
            </if>
            <if test="ltAgencyIdentityCardPath != null">
                lt_agency_identity_card_path = #{ltAgencyIdentityCardPath},
            </if>
            <if test="dxAgencyName != null">
                dx_agency_name = #{dxAgencyName},
            </if>
            <if test="dxAgencyCertType != null">
                dx_agency_cert_type = #{dxAgencyCertType},
            </if>
            <if test="dxAgencyCertId != null">
                dx_agency_cert_id = #{dxAgencyCertId},
            </if>
            <if test="dxAgencyPhone != null">
                dx_agency_phone = #{dxAgencyPhone},
            </if>
            <if test="dxAgencyIdentityCardPath != null">
                dx_agency_identity_card_path = #{dxAgencyIdentityCardPath},
            </if>
            <if test="ydAgencyName != null">
                yd_agency_name = #{ydAgencyName},
            </if>
            <if test="ydAgencyCertType != null">
                yd_agency_cert_type = #{ydAgencyCertType},
            </if>
            <if test="ydAgencyCertId != null">
                yd_agency_cert_id = #{ydAgencyCertId},
            </if>
            <if test="ydAgencyPhone != null">
                yd_agency_phone = #{ydAgencyPhone},
            </if>
            <if test="ydAgencyIdentityCardPath != null">
                yd_agency_identity_card_path = #{ydAgencyIdentityCardPath},
            </if>
            <if test="signId != null">
                sign_id = #{signId},
            </if>
            <if test="singSource != null">
                sing_source = #{singSource},
            </if>
            <if test="signPic != null">
                sign_pic = #{signPic},
            </if>
            <if test="trademarkRegistrationNum != null">
                trademark_registration_num = #{trademarkRegistrationNum},
            </if>
            <if test="sourceDesc != null">
                source_desc = #{sourceDesc},
            </if>
            <if test="signExtPrefix != null">
                sign_ext_prefix = #{signExtPrefix},
            </if>
            <if test="appStorePublish != null">
                app_store_publish = #{appStorePublish},
            </if>
            <if test="signExId != null">
                sign_ex_id = #{signExId},
            </if>
        </set>
        where channel_id = #{channelId} and signature = #{signature} and sign_ext = #{signExt}
    </update>

    <update id="updateSmsCompanySignExportInfoStatus" parameterType="cn.roadm.bo.SmsCompanySignExportInfo">
        update sms_company_sign_export_info set status = #{status} where channel_id = #{channelId} and signature = #{signature} and sign_ext=#{signExt}
    </update>

    <select id="listPageselectSmsCompanySignExportInfo" resultType="cn.roadm.bo.SmsCompanySignExportInfo">
        select a.id,a.channel_id as channelId,a.signature,a.sign_ext as signExt, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime ,a.status,
        a.test_task_id as testTaskId ,b.CHANNEL_NAME as channelName,c.otype,
        a.damians,a.phones,a.task,a.business_category as businessCategory
        from sms_company_sign_export_info a left join sms_send_channel_info b
        on a.channel_id = b.id left join (select *from channel_attribute where state = 0) c  on b.id = c.channel_id
        <where>
            <if test="signature!=null and signature!=''">
                a.signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="signExt!=null and signExt!=''">
                and a.sign_ext like CONCAT(#{signExt},'%')
            </if>
            <if test="channelId!=null and channelId!=''">
                and a.channel_id = #{channelId}
            </if>
            <if test="status!=null and status!=''">
                and a.status = #{status}
            </if>
            <if test="otype!=null and otype!=''">
                and c.otype = #{otype}
            </if>
            <if test="task!=null and task!=''">
                and a.task = #{task}
            </if>
            <if test="businessCategory!=null and businessCategory!=''">
                and a.business_category = #{businessCategory}
            </if>
            <if test="phones!=null and phones!=''">
                and a.phones like CONCAT('%',#{phones},'%')
            </if>
            <if test="damians!=null and damians!=''">
                and a.damians like CONCAT('%',#{damians},'%')
            </if>
            <if test="createTime!=null and createTime!=''">
                and a.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
            </if>
        </where>
        order by a.create_time desc
    </select>

    <select id="smsCompanySignExportInfo" resultType="cn.roadm.bo.SmsCompanySignExportInfo">
        select a.id,a.channel_id as channelId,a.signature,a.sign_ext as signExt, DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%s') as createTime ,a.status,
        a.test_task_id as testTaskId ,b.CHANNEL_NAME as channelName,c.otype
        from sms_company_sign_export_info a left join sms_send_channel_info b
        on a.channel_id = b.id left join (select *from channel_attribute where state = 0) c  on b.id = c.channel_id
        <where>
            <if test="signature!=null and signature!=''">
                a.signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="signExt!=null and signExt!=''">
                and a.sign_ext like CONCAT(#{signExt},'%')
            </if>
            <if test="channelList!=null and channelList.size()>0">
                and a.channel_id in
                <foreach collection="channelList" index="index" item="channel" open="(" separator="," close=")">
                    #{channel}
                </foreach>
            </if>
            <if test="channelId!=null and channelId!='' and (channelList==null or channelList.size()==0)">
                and a.channel_id = #{channelId}
            </if>
            <if test="status!=null and status!=''">
                and a.status = #{status}
            </if>
            <if test="createTime!=null and createTime!=''">
                and a.create_time&gt;=str_to_date(#{createTime},'%Y-%m-%d %H')
            </if>
            <if test="endTime!=null and endTime!=''">
                and a.create_time&lt;str_to_date(#{endTime},'%Y-%m-%d %H')
            </if>
        </where>
        order by a.create_time desc
    </select>

    <select id="selectSmsCompanySignExportInfoByIds" resultType="cn.roadm.bo.SmsCompanySignExportInfo">
        select a.*,c.template_content as templateContent,c.business_category as businessCategory,c.damians,c.phones
        from (select id,channel_id as channelId,signature,sign_ext as signExt, create_time as createTime ,status,
        test_task_id as testTaskId from sms_company_sign_export_info where id in (${ids}) AND status != 1 and status != 3 and status != 8) a
        left join sms_company_sign_report_info c on a.signExt = c.sign_ext and a.signature = c.signature
    </select>

    <select id="selectSmsCompanySignExportInfoByIds2" resultType="cn.roadm.bo.SmsCompanySignExportInfo">
        select a.*,c.template_content as templateContent,c.damians,c.phones,
        d.use_extend_type as useExtendType,c.business_category as businessCategory
        from (select id,channel_id as channelId,signature,sign_ext as signExt, create_time as createTime ,status,
        test_task_id as testTaskId from sms_company_sign_export_info where id in (${ids}) AND status = 5) a
        left join sms_company_sign_report_info c on a.signExt = c.sign_ext and a.signature = c.signature
        left join sms_send_channel_info d on a.channelId = d.id
    </select>

    <update id="updateExportInfoById" parameterType="cn.roadm.bo.SmsCompanySignExportInfo">
        update sms_company_sign_export_info
        <set>
            <if test="testTaskId!=null and testTaskId!=''">
                test_task_id = #{testTaskId},
            </if>
            <if test="status!=null and status !=''">
                status = #{status},
            </if>
            <if test="signature!=null and signature !=''">
                signature = #{signature},
            </if>
            <if test="channelId!=null and channelId !=''">
                channel_id = #{channelId},
            </if>
            <if test="signExt!=null and signExt !=''">
                sign_ext = #{signExt},
            </if>
        </set>
         where id = #{id}
    </update>

    <update id="updateExportInfoTaskIdById">
        update sms_company_sign_export_info set test_task_id = #{taskId} where id = #{id}
    </update>

    <update id="updateExportInfoStatusById">
        update sms_company_sign_export_info set status=#{status},create_time=now() where id = #{id}
    </update>

    <update id="updateExportInfoStatusByIds">
        update sms_company_sign_export_info set status=#{status} where id in (${ids})
    </update>

    <select id="selectArriveSuccessConutByTaskId" resultType="String">
        select result from sms_arrive where taskid = #{taskId} and channelid = #{channelId} and create_time >= NOW() - INTERVAL 4 DAY;
    </select>

    <update id="updateExportInfoStatus">
        update sms_company_sign_export_info set status = #{updateStatus}
        <where>
            <if test="signature!=null and signature!=''">
                signature like CONCAT('%',#{signature},'%')
            </if>
            <if test="signExt!=null and signExt!=''">
                and sign_ext like CONCAT(#{signExt},'%')
            </if>
            <if test="channelId!=null and channelId!=''">
                and channel_id = #{channelId}
            </if>
            <if test="status!=null and status!=''">
                and status = #{status}
            </if>
            <if test="task!=null and task!=''">
                and task = #{task}
            </if>
            <if test="businessCategory!=null and businessCategory!=''">
                and business_category = #{businessCategory}
            </if>
            <if test="phones!=null and phones!=''">
                and phones like CONCAT('%',#{phones},'%')
            </if>
            <if test="damians!=null and damians!=''">
                and damians like CONCAT('%',#{damians},'%')
            </if>
        </where>
    </update>

    <update id="syncUpdateExportInfoBySignatureAndSignExt" parameterType="cn.roadm.bo.SmsCompanySignReportInfo">
        UPDATE sms_company_sign_export_info a
        INNER JOIN sms_company_sign_report_info scsri ON a.signature = scsri.signature AND a.sign_ext = scsri.sign_ext
        LEFT JOIN sms_company_sign_info scsi ON scsri.sign_ext_prefix = scsi.sign_ext_prefix
        LEFT JOIN sms_company_info sci ON scsi.company_code = sci.company_code
        SET 
            a.damians = scsri.damians,
            a.phones = scsri.phones,
            a.business_category = scsri.business_category,
            a.business_subcategory = scsri.business_subcategory,
            a.task = scsri.task,
            a.template_content = scsri.template_content,
            a.parameter_type = scsri.parameter_type,
            a.parameter_length = scsri.parameter_length,
            a.sms_type = scsri.sms_type,
            a.company_id = sci.id,
            a.company_name = sci.company_name,
            a.company_code = sci.company_code,
            a.business_pic_path = sci.business_pic_path,
            a.legal_name = sci.legal_name,
            a.legal_cert_type = sci.legal_cert_type,
            a.legal_cert_id = sci.legal_cert_id,
            a.legal_identity_card_path = sci.legal_identity_card_path,
            a.agency_name = sci.agency_name,
            a.agency_cert_type = sci.agency_cert_type,
            a.agency_cert_id = sci.agency_cert_id,
            a.agency_phone = sci.agency_phone,
            a.agency_identity_card_path = sci.agency_identity_card_path,
            a.lt_agency_name = sci.lt_agency_name,
            a.lt_agency_cert_type = sci.lt_agency_cert_type,
            a.lt_agency_cert_id = sci.lt_agency_cert_id,
            a.lt_agency_phone = sci.lt_agency_phone,
            a.lt_agency_identity_card_path = sci.lt_agency_identity_card_path,
            a.dx_agency_name = sci.dx_agency_name,
            a.dx_agency_cert_type = sci.dx_agency_cert_type,
            a.dx_agency_cert_id = sci.dx_agency_cert_id,
            a.dx_agency_phone = sci.dx_agency_phone,
            a.dx_agency_identity_card_path = sci.dx_agency_identity_card_path,
            a.yd_agency_name = sci.yd_agency_name,
            a.yd_agency_cert_type = sci.yd_agency_cert_type,
            a.yd_agency_cert_id = sci.yd_agency_cert_id,
            a.yd_agency_phone = sci.yd_agency_phone,
            a.yd_agency_identity_card_path = sci.yd_agency_identity_card_path,
            a.sign_id = scsi.id,
            a.sing_source = scsi.sing_source,
            a.sign_pic = scsi.sign_pic,
            a.trademark_registration_num = scsi.trademark_registration_num,
            a.source_desc = scsi.source_desc,
            a.sign_ext_prefix = scsri.sign_ext_prefix,
            a.app_store_publish = scsi.app_store_publish,
            a.sign_ex_id = scsri.sign_ext_prefix
        WHERE a.signature = #{signature} AND a.sign_ext = #{signExt}
    </update>

    <select id="selectExportBypassCountBySignExt" resultType="cn.roadm.bo.SmsCompanySignExportInfo">
        select sign_ext  as signExt,count(1) as exCount from sms_company_sign_export_info where sign_ext in
        <foreach item="item" collection="signExts" index="index" separator="," close=")" open="(">
            #{item}
        </foreach>
         group by sign_ext
    </select>

    <select id="selectSignBypassCountBySignExtChannelId" resultType="int">
        select count(1) from sms_sign_bypass where mobilechannel = #{channelId} and mobile_suffix = #{signExt}
    </select>

    <insert id="insertSmsSignBypass"  useGeneratedKeys="true" keyProperty="id"  parameterType="SmsBypass">
        insert into sms_sign_bypass
        (sign,CREATETIME,mobilechannel,unicomchannel,telecomchannel,status,mobile_suffix,unicom_suffix,telecom_suffix
        ,fixed_mobile_suffix,fixed_unicom_suffix,fixed_telecom_suffix,reporting_status,extend_type,sign_flag, user_suffix, class_id,domain,phones,sms_template,auto_test) values
        (#{sign,jdbcType=VARCHAR},sysdate(),#{mobilechannel,jdbcType=VARCHAR}
        ,#{unicomchannel,jdbcType=VARCHAR},#{telecomchannel,jdbcType=VARCHAR},#{status},#{mobile_suffix},#{unicom_suffix},#{telecom_suffix}
        ,#{fixed_mobile_suffix},#{fixed_unicom_suffix},#{fixed_telecom_suffix},#{reportingStatus}, #{extendType},#{signFlag}, #{user_suffix}, #{classId},#{domain},#{phones},#{smsTemplate},#{autoTest})
    </insert>

    <update id="updateCompanySignReportInfoStatus">
        update sms_company_sign_report_info set status = #{status} where id = #{id}
    </update>

    <update id="updateSignReportInfoAuditStatus">
        update sms_company_sign_report_info set status = #{status}, reason = #{reason} where id = #{id}
    </update>

    <update id="batchUpdateSignReportInfoAuditStatus">
        update sms_company_sign_report_info set status = #{status}, reason = #{reason}
        where id in
        <foreach item="item" collection="idList" separator="," open="(" close=")" index="">
            ${item}
        </foreach>
    </update>

    <select id="selectChannelReportAccount" resultType="cn.roadm.bo.UploadAccount">
        select a.channel_id as channelId,a.username,a.password,a.sms_port as smsPort,a.province_code as provinceCode,
        b.otype,c.MOBILE_PREFIX as mobilePrefix from upload_account_info a left join channel_attribute b on a.channel_id = b.channel_id
        left join sms_send_channel_info c on a.channel_id = c.ID
    </select>

    <select id="selectNoOtypeStatus" resultMap="SmsCompanySignReportInfoMap">
        select id,report_otype,support_otype,sign_ext,signature from sms_company_sign_report_info where
        <![CDATA[NOT (report_otype <=> support_otype)]]> and report_otype is not null
    </select>

    <select id="selectSignBypassBySignExt" resultType="string">
        select mobilechannel from sms_sign_bypass where mobile_suffix = #{ext} and sign = #{sign} and reporting_status = '1'
    </select>

    <update id="updateSignatureByOldSignature">
        update sms_company_sign_report_info set signature = #{signatureEnd} where signature = #{signatureBegin}
    </update>

    <select id="selectCountBySignatureAndSignExt" resultType="int">
        select count(1) from sms_company_sign_export_info where signature = #{signature} and sign_ext = #{signExt}
    </select>

    <update id="updateExportInfoByCompanyId" parameterType="cn.roadm.bo.SmsCompanyInfo">
        update sms_company_sign_export_info
        <set>
            <if test="companyName != null">
                company_name = #{companyName},
            </if>
            <if test="companyCode != null">
                company_code = #{companyCode},
            </if>
            <if test="businessPicPath != null">
                business_pic_path = #{businessPicPath},
            </if>
            <if test="legalName != null">
                legal_name = #{legalName},
            </if>
            <if test="legalCertType != null">
                legal_cert_type = #{legalCertType},
            </if>
            <if test="legalCertId != null">
                legal_cert_id = #{legalCertId},
            </if>
            <if test="legalIdentityCardPath != null">
                legal_identity_card_path = #{legalIdentityCardPath},
            </if>
            <if test="agencyName != null">
                agency_name = #{agencyName},
            </if>
            <if test="agencyCertType != null">
                agency_cert_type = #{agencyCertType},
            </if>
            <if test="agencyCertId != null">
                agency_cert_id = #{agencyCertId},
            </if>
            <if test="agencyPhone != null">
                agency_phone = #{agencyPhone},
            </if>
            <if test="agencyIdentityCardPath != null">
                agency_identity_card_path = #{agencyIdentityCardPath},
            </if>
            <if test="ltAgencyName != null">
                lt_agency_name = #{ltAgencyName},
            </if>
            <if test="ltAgencyCertType != null">
                lt_agency_cert_type = #{ltAgencyCertType},
            </if>
            <if test="ltAgencyCertId != null">
                lt_agency_cert_id = #{ltAgencyCertId},
            </if>
            <if test="ltAgencyPhone != null">
                lt_agency_phone = #{ltAgencyPhone},
            </if>
            <if test="ltAgencyIdentityCardPath != null">
                lt_agency_identity_card_path = #{ltAgencyIdentityCardPath},
            </if>
            <if test="dxAgencyName != null">
                dx_agency_name = #{dxAgencyName},
            </if>
            <if test="dxAgencyCertType != null">
                dx_agency_cert_type = #{dxAgencyCertType},
            </if>
            <if test="dxAgencyCertId != null">
                dx_agency_cert_id = #{dxAgencyCertId},
            </if>
            <if test="dxAgencyPhone != null">
                dx_agency_phone = #{dxAgencyPhone},
            </if>
            <if test="dxAgencyIdentityCardPath != null">
                dx_agency_identity_card_path = #{dxAgencyIdentityCardPath},
            </if>
            <if test="ydAgencyName != null">
                yd_agency_name = #{ydAgencyName},
            </if>
            <if test="ydAgencyCertType != null">
                yd_agency_cert_type = #{ydAgencyCertType},
            </if>
            <if test="ydAgencyCertId != null">
                yd_agency_cert_id = #{ydAgencyCertId},
            </if>
            <if test="ydAgencyPhone != null">
                yd_agency_phone = #{ydAgencyPhone},
            </if>
            <if test="ydAgencyIdentityCardPath != null">
                yd_agency_identity_card_path = #{ydAgencyIdentityCardPath},
            </if>
        </set>
        where company_id = #{id}
    </update>

    <update id="updateExportInfoByCompanyInfo" parameterType="cn.roadm.bo.SmsCompanySignInfo">
        UPDATE sms_company_sign_export_info a
            INNER JOIN sms_company_sign_report_info scsri ON a.signature = scsri.signature AND a.sign_ext = scsri.sign_ext
            LEFT JOIN sms_company_sign_info scsi ON scsri.sign_ext_prefix = scsi.sign_ext_prefix
            LEFT JOIN sms_company_info sci ON scsi.company_code = sci.company_code
            SET
                a.damians = scsri.damians,
                a.phones = scsri.phones,
                a.business_category = scsri.business_category,
                a.business_subcategory = scsri.business_subcategory,
                a.task = scsri.task,
                a.template_content = scsri.template_content,
                a.parameter_type = scsri.parameter_type,
                a.parameter_length = scsri.parameter_length,
                a.sms_type = scsri.sms_type,
                a.company_id = sci.id,
                a.company_name = sci.company_name,
                a.company_code = sci.company_code,
                a.business_pic_path = sci.business_pic_path,
                a.legal_name = sci.legal_name,
                a.legal_cert_type = sci.legal_cert_type,
                a.legal_cert_id = sci.legal_cert_id,
                a.legal_identity_card_path = sci.legal_identity_card_path,
                a.agency_name = sci.agency_name,
                a.agency_cert_type = sci.agency_cert_type,
                a.agency_cert_id = sci.agency_cert_id,
                a.agency_phone = sci.agency_phone,
                a.agency_identity_card_path = sci.agency_identity_card_path,
                a.lt_agency_name = sci.lt_agency_name,
                a.lt_agency_cert_type = sci.lt_agency_cert_type,
                a.lt_agency_cert_id = sci.lt_agency_cert_id,
                a.lt_agency_phone = sci.lt_agency_phone,
                a.lt_agency_identity_card_path = sci.lt_agency_identity_card_path,
                a.dx_agency_name = sci.dx_agency_name,
                a.dx_agency_cert_type = sci.dx_agency_cert_type,
                a.dx_agency_cert_id = sci.dx_agency_cert_id,
                a.dx_agency_phone = sci.dx_agency_phone,
                a.dx_agency_identity_card_path = sci.dx_agency_identity_card_path,
                a.yd_agency_name = sci.yd_agency_name,
                a.yd_agency_cert_type = sci.yd_agency_cert_type,
                a.yd_agency_cert_id = sci.yd_agency_cert_id,
                a.yd_agency_phone = sci.yd_agency_phone,
                a.yd_agency_identity_card_path = sci.yd_agency_identity_card_path,
                a.sign_id = scsi.id,
                a.sing_source = scsi.sing_source,
                a.sign_pic = scsi.sign_pic,
                a.trademark_registration_num = scsi.trademark_registration_num,
                a.source_desc = scsi.source_desc,
                a.sign_ext_prefix = scsri.sign_ext_prefix,
                a.app_store_publish = scsi.app_store_publish,
                a.sign_ex_id = scsri.sign_ext_prefix
        WHERE a.signature = #{signature} AND a.sign_ext_prefix = #{signExtPrefix}
    </update>
</mapper>
