<?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.crk.basic.mapper.OrgInfoMapper">

        <!-- 通用查询映射结果 -->
        <resultMap id="BaseResultMap" type="com.unis.crk.basic.entity.OrgInfo">
                    <id column="org_id" property="orgId" />
                    <result column="org_name" property="orgName" />
                    <result column="short_name" property="shortName" />
                    <result column="org_code" property="orgCode" />
                    <result column="org_class_id" property="orgClassId" />
                    <result column="company_nature" property="companyNature" />
                    <result column="busi_type" property="busiType" />
                    <result column="address" property="address" />
                    <result column="contact" property="contact" />
                    <result column="fax" property="fax" />
                    <result column="charge_person" property="chargePerson" />
                    <result column="longitude" property="longitude" />
                    <result column="latitude" property="latitude" />
                    <result column="regist_capital" property="registCapital" />
                    <result column="work_number" property="workNumber" />
                    <result column="area_code" property="areaCode" />
                    <result column="area_name" property="areaName" />
                    <result column="post" property="post" />
                    <result column="depot_class" property="depotClass" />
                    <result column="design_capacity" property="designCapacity" />
                    <result column="effective_capacity" property="effectiveCapacity" />
                    <result column="depot_area" property="depotArea" />
                    <result column="complete_date" property="completeDate" />
                    <result column="use_date" property="useDate" />
                    <result column="company_org_code" property="companyOrgCode" />
                    <result column="credit_code" property="creditCode" />
                    <result column="regist_type" property="registType" />
                    <result column="qualification" property="qualification" />
                    <result column="independent_corporation" property="independentCorporation" />
                    <result column="legal_person" property="legalPerson" />
                    <result column="whether_rent" property="whetherRent" />
                    <result column="info_regist" property="infoRegist" />
                    <result column="regist_date" property="registDate" />
                    <result column="remark" property="remark" />
                    <result column="parent_id" property="parentId" />
                    <result column="status" property="status" />
                    <result column="del_flag" property="delFlag" />
                    <result column="birds_eye" property="birdsEye" />
                    <result column="birds_Remote" property="birdsRemote" />
                    <result column="brief_introduction" property="briefIntroduction" />
                    <result column="invoice_title" property="invoiceTitle" />
                    <result column="regist_number" property="registNumber" />
                    <result column="bank_name" property="bankName" />
                    <result column="account_name" property="accountName" />
                    <result column="account_number" property="accountNumber" />
                    <result column="total_assets" property="totalAssets" />
                    <result column="corporate_capacity" property="corporateCapacity" />
                    <result column="office_phone" property="officePhone" />
                    <result column="registered_address" property="registeredAddress" />
                    <result column="mail_box" property="mailBox" />
                    <result column="official_website" property="officialWebsite" />
                    <result column="house_number" property="houseNumber" />
                    <result column="tank_number" property="tankNumber" />
                    <result column="depot_property" property="depotProperty" />
                    <result column="updatetime" property="updatetime" />
                    <result column="level_code" property="levelCode" />
                    <result column="cityCouncil_code" property="citycouncilCode" />
        </resultMap>
    <resultMap id="OrgInfoVo" type="com.unis.crk.basic.entity.OrgInfo">
        <id column="org_id" property="orgId" />
        <result column="org_name" property="orgName" />
        <result column="short_name" property="shortName" />
        <result column="org_code" property="orgCode" />
        <result column="org_class_id" property="orgClassId" />
        <result column="company_nature" property="companyNature" />
        <result column="busi_type" property="busiType" />
        <result column="address" property="address" />
        <result column="contact" property="contact" />
        <result column="fax" property="fax" />
        <result column="charge_person" property="chargePerson" />
        <result column="longitude" property="longitude" />
        <result column="latitude" property="latitude" />
        <result column="regist_capital" property="registCapital" />
        <result column="work_number" property="workNumber" />
        <result column="area_code" property="areaCode" />
        <result column="area_name" property="areaName" />
        <result column="post" property="post" />
        <result column="depot_class" property="depotClass" />
        <result column="design_capacity" property="designCapacity" />
        <result column="effective_capacity" property="effectiveCapacity" />
        <result column="depot_area" property="depotArea" />
        <result column="complete_date" property="completeDate" />
        <result column="use_date" property="useDate" />
        <result column="company_org_code" property="companyOrgCode" />
        <result column="credit_code" property="creditCode" />
        <result column="regist_type" property="registType" />
        <result column="qualification" property="qualification" />
        <result column="independent_corporation" property="independentCorporation" />
        <result column="legal_person" property="legalPerson" />
        <result column="whether_rent" property="whetherRent" />
        <result column="info_regist" property="infoRegist" />
        <result column="regist_date" property="registDate" />
        <result column="remark" property="remark" />
        <result column="parent_id" property="parentId" />
        <result column="status" property="status" />
        <result column="del_flag" property="delFlag" />
        <result column="birds_eye" property="birdsEye" />
        <result column="birds_Remote" property="birdsRemote" />
        <result column="brief_introduction" property="briefIntroduction" />
        <result column="invoice_title" property="invoiceTitle" />
        <result column="regist_number" property="registNumber" />
        <result column="bank_name" property="bankName" />
        <result column="account_name" property="accountName" />
        <result column="account_number" property="accountNumber" />
        <result column="total_assets" property="totalAssets" />
        <result column="corporate_capacity" property="corporateCapacity" />
        <result column="office_phone" property="officePhone" />
        <result column="registered_address" property="registeredAddress" />
        <result column="mail_box" property="mailBox" />
        <result column="official_website" property="officialWebsite" />
        <result column="house_number" property="houseNumber" />
        <result column="tank_number" property="tankNumber" />
        <result column="depot_property" property="depotProperty" />
        <result column="updatetime" property="updatetime" />
        <result column="level_code" property="levelCode" />
        <result column="cityCouncil_code" property="citycouncilCode" />
    </resultMap>
    <select id="getPerData" resultType="java.util.Map">
        SELECT *   FROM  org_info
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
    </select>
    <select id="selectMyMapsPage" resultType="java.util.Map">
        SELECT *   FROM  org_info
        <if test="ew.sqlSegment != null and ew.sqlSegment != ''">
            where  ${ew.sqlSegment}
        </if>
    </select>

    <select id="getTree" resultMap="BaseResultMap" parameterType="com.unis.crk.basic.entity.OrgInfo" >
        select *
        from org_info
        <if test="orgName!=null and orgName!=''">
            where  org_name = '%${orgName}%'
        </if>


    </select>
    <select id="getAllChildren" resultMap="BaseResultMap" parameterType="com.unis.crk.basic.entity.OrgInfo" >
        select *
        from org_info
        <if test="orgName!=null and orgName!=''">
            where  org_name LIKE '%${orgName}%'
        </if>
        <if test="orgClassId!=null and orgClassId!=''">
            and  org_class_id LIKE '%${orgClassId}%'
        </if>


    </select>

    <select id="selectOrgInfoVo"  resultMap="BaseResultMap" parameterType="com.unis.crk.basic.entity.OrgInfo">
        select * from org_info
        <if test="orgId!=null and orgId!=''">
            where  org_id = '${orgId}'
        </if>
    </select>
    <update id="upateOrgLevel" parameterType="map" statementType="CALLABLE" >
        {call set_org_level(#{parentId,mode=IN},#{parentLevel,mode=IN})}
    </update>


    <select id="getallOrgInfo" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select *  from org_info
    </select>

    <select id="getCountChildren" resultType="Integer" parameterType="java.lang.String">
        SELECT COUNT(*) FROM org_info WHERE parent_id=#{orgId}
    </select>
</mapper>
