<?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="org.jeecg.modules.commonQueryConfig.mapper.CommonQueryConfigMapper">
    <select id="commonQuery" parameterType="hashmap" resultType="hashmap">
        select t.*, t.shape.GET_WKT() as wkt,SDO_GEOM.SDO_AREA(SDO_CS.TRANSFORM(t.shape,4490),0.05) as shapeArea
        from ${tablename} t
        where ${queryfield} like CONCAT(CONCAT('%', #{queryinfo}), '%')
    </select>
    <select id="commonQuery2" parameterType="hashmap" resultType="hashmap">
        select a.* from (select a.OBJECTID,b.*, st_astext(ST_GeometryN(geom, generate_series(1, ST_NumGeometries(geom))))  as wkt
        from ${tablename} a
                 left join ${reltablename} b on a.${fromfldname} = b.${tofldname}
        where b.${queryfield} like CONCAT(CONCAT('%', #{queryinfo}), '%')
       ) a
        <if test="pageno!=null and pagesize!=null">
            limit ${pagesize * pageno} offset ${pagesize * (pageno-1)}
        </if>

    </select>
    <select id="count" parameterType="hashmap" resultType="int">
        select count(1) from (select a.OBJECTID,b.*, st_astext(a.geom) as wkt
        from ${tablename} a
        left join ${reltablename} b on a.${fromfldname} = b.${tofldname}
        where b.${queryfield} like CONCAT(CONCAT('%', #{queryinfo}), '%')) a

    </select>

    <select id="commonQuery3" parameterType="hashmap" resultType="hashmap">
        select a.OBJECTID,a.${otherfield},b.${queryfield}, b.*, a.shape.GET_WKT() as wkt,SDO_GEOM.SDO_AREA(SDO_CS.TRANSFORM(a.shape,4490),0.05) as shapeArea
        from ${tablename} a
                 left join ${reltablename} b on a.${fromfldname} = b.${tofldname}
        where b.${queryfield} like CONCAT(CONCAT('%', #{queryinfo}), '%')
    </select>
    <select id="commonQuery4" parameterType="hashmap" resultType="hashmap">
        select distinct(${fromfldname}),t.${queryfield}
        from ${tablename} t
        where ${queryfield} like CONCAT(CONCAT('%', #{queryinfo}), '%')
    </select>
<!--    <select id="commonQuery5" parameterType="hashmap" resultType="hashmap">-->
<!--        select t.${otherfield},t.shape.GET_WKT(),SDO_GEOM.SDO_AREA(SDO_CS.TRANSFORM(t.shape,4527),0.05) as shapeArea-->
<!--        from ${tablename} t-->
<!--        where ${queryfield} = #{queryinfo}-->
<!--    </select>-->
    <select id="commonQuery5" parameterType="hashmap" resultType="hashmap">
        select a.OBJECTID,a.${otherfield}, b.*, a.shape.GET_WKT() as wkt,SDO_GEOM.SDO_AREA(SDO_CS.TRANSFORM(a.shape,4490),0.05) as shapeArea
        from ${tablename} a
                 left join ${reltablename} b on a.${fromfldname} = b.${tofldname}
        where a.${fromfldname} = #{fromfldvalue}
    </select>
    <select id="identifyQuery" parameterType="hashmap" resultType="hashmap">
        select a.*, a.shape.GET_WKT() as wkt
        from ${tablename} a
        where a.OBJECTID = ${objectid}
    </select>
    <select id="identifyQuery2" parameterType="hashmap" resultType="hashmap">
        select a.OBJECTID,b.*, a.shape.GET_WKT() as wkt
        from ${tablename} a
                 left join ${reltablename} b on a.${fromfldname} = b.${tofldname}
        where a.OBJECTID = ${objectid}
    </select>
</mapper>