<?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.unis.policy.info.modular.sqrEnterpriseApply.mapper.SqrEnterpriseApplyMapper">


    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT
        bgqa.id,bui.id unitInfoId, bui.dwmc,bui.dwdm,bui.fddbr,bui.dwlx,bgqa.apply_status,bgqa.reissue_time,bgqa.apply_type,bgq.audit_status
        FROM
        province_all.biz_sqr_enterprise_apply bgqa
        LEFT JOIN province_all.biz_unit_info bui ON bgqa.unit_info_id = bui.id
        LEFT JOIN province_all.biz_audit_request bgq ON bgqa.id = bgq.request_id

        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>

    </select>
    <select id="findById" resultType="com.unis.policy.info.modular.sqrEnterpriseApply.entity.SqrEnterpriseApply">
        SELECT
        bgqa.id,A.id unitInfoId, A.dwmc,A.dwdm,A.fddbr,A.dwlx,A.zcdz,bgqa.apply_status,bgqa.apply_type,bgqa.reissue_time,bgqa.attachment,bgqa.sqr_enterprise_id,A.DICT_LABEL
        FROM
        province_all.biz_sqr_enterprise_apply bgqa
        left join(select bui.id,bui.dwmc,bui.dwdm,bui.fddbr,bui.dwlx,bui.zcdz,bui.cfs,bui.ygs,dict.DICT_LABEL  from province_all.biz_unit_info bui left join province_all.dev_dict dict on bui.dwlx = dict.id
        <if test="unitInfoId != null and unitInfoId != ''">
        where bui.id =#{unitInfoId,jdbcType=VARCHAR}
    </if>

        )A  on bgqa.unit_info_id = A.id
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where ${ew.sqlSegment}
        </if>

    </select>

</mapper>