<?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="cbdoro.mods.facilityInfo.ae010.mapper.Ae010Mapper">

    <resultMap id="Ae010FeaVoMap" type="Ae010FeaVO">
        <result column="UID"                property="uid"               />  <!-- 시점 -->
        <result column="MLV"                property="mlv"               />  <!-- 관리등급 -->
        <result column="ROAD_NO"            property="roadNo"            />  <!-- 노선번호 -->
        <result column="SECT"               property="sect"              />  <!-- 구간번호 -->
        <result column="DOCODE"             property="docode"            />  <!-- 구조물코드 -->
        <result column="FA_TYPE"            property="faType"            />  <!-- 시설물종별 -->
        <result column="STR_LEVEL"          property="strLevel"          />  <!-- 상태등급 -->
        <result column="RE_DIA"             property="reDia"             />  <!-- 진단결과 -->
        <result column="DOSTA1"             property="dosta1"            />  <!-- 시점_측점 -->
        <result column="DOSTA2"             property="dosta2"            />  <!-- 종점_측점 -->
        <result column="DOLENTH"            property="dolenth"           />  <!-- 연장 -->
        <result column="BR_NAME"            property="brName"            />  <!-- 교량명 -->
        <result column="AREA"               property="area"              />  <!-- 소재지 -->
        <result column="SDATE"              property="sdate"             />  <!-- 착공일 -->
        <result column="EDATE"              property="edate"             />  <!-- 준공일 -->
        <result column="STYLE"              property="style"             />  <!-- 교량형태 -->
        <result column="OFFCE"              property="offce"             />  <!-- 시공청 -->
        <result column="MANAGER"            property="manager"           />  <!-- 시공자 -->
        <result column="PLAN"               property="plan"              />  <!-- 설계자 -->
        <result column="SUPER"              property="SUPER"            />  <!-- 감리자 -->
        <result column="GLEN"               property="glen"              />  <!-- 최대경간장 -->
        <result column="GNUM"               property="gnum"              />  <!-- 경간수 -->
        <result column="COL_CONST"          property="colConst"          />  <!-- 경간구성 -->
        <result column="COL_TYPE"           property="colType"           />  <!-- 주경간형식 -->
        <result column="COL_MAT"            property="colMat"            />  <!-- 부경간형식 -->
        <result column="MDTH"               property="mdth"              />  <!-- 총폭원 -->
        <result column="P_LOAD"             property="pLoad"             />  <!-- 설계활하중 -->
        <result column="PER_WET"            property="perWet"            />  <!-- 허용통행하중 -->
        <result column="IN_DE"              property="inDe"              />  <!-- 내진설계적용_유무 -->
        <result column="SUE_TYPE"           property="sueType"           />  <!-- 교좌장치_형식 -->
        <result column="SUE_MAT"            property="sueMat"            />  <!-- 교좌장치_재질 -->
        <result column="GMSTYLE"            property="gmstyle"           />  <!-- 고명주형식 -->
        <result column="CWDT"               property="cwdt"              />  <!-- 차도폭 -->
        <result column="MWDT"               property="mwdt"              />  <!-- 보도폭 -->
        <result column="LANE_U"             property="laneU"             />  <!-- 차로수_상행 -->
        <result column="LANE_D"             property="laneD"             />  <!-- 차로수_하행 -->
        <result column="SPC"                property="spc"               />  <!-- 주형_간격 -->
        <result column="HEI"                property="hei"               />  <!-- 주형_높이 -->
        <result column="UMWDT"              property="umwdt"             />  <!-- 상판_두께 -->
        <result column="UGIFT"              property="ugift"             />  <!-- 상판_재료 -->
        <result column="HWDT"               property="hwdt"              />  <!-- 난간_재료 -->
        <result column="HLEN"               property="hlen"              />  <!-- 난간_연장 -->
        <result column="HHEI"               property="hhei"              />  <!-- 난간_높이 -->
        <result column="FIXSTYLE"           property="fixstyle"          />  <!-- 신축이음장치_고정형식 -->
        <result column="WKSTYLE"            property="wkstyle"           />  <!-- 신축이음장치_가동형식 -->
        <result column="LINK_LEN"           property="linkLen"           />  <!-- 신축이음장치_길이 -->
        <result column="LINK_EA"            property="linkEa"            />  <!-- 신축이음장치_수량 -->
        <result column="LINK_TYPE"          property="linkType"          />  <!-- 신축이음장치_종류 -->
        <result column="LINK_NEA"           property="linkNea"           />  <!-- 신축이음장치_신축량 -->
        <result column="GY_TYPE"            property="gyType"            />  <!-- 교면_포장재료 -->
        <result column="GY_THICK"           property="gyThick"           />  <!-- 교면_포장두께 -->
        <result column="GY_WATER"           property="gyWater"           />  <!-- 교면_방수형식 -->
        <result column="GKSTYLE"            property="gkstyle"           />  <!-- 교각형식 -->
        <result column="GKNUM"              property="gknum"             />  <!-- 교각수 -->
        <result column="GKFILL"             property="gkfill"            />  <!-- 교각매립깊이 -->
        <result column="GKHEI"              property="gkhei"             />  <!-- 교각총높이 -->
        <result column="EDG_BASE"           property="edgBase"           />  <!-- 교각기초 -->
        <result column="EDG_HRN"            property="edgHrn"            />  <!-- 교각평수위상고 -->
        <result column="UPSTYLE"            property="upstyle"           />  <!-- 상부구조형식 -->
        <result column="DNSTYLE"            property="dnstyle"           />  <!-- 하부구조형식 -->
        <result column="GDSTYLE"            property="gdstyle"           />  <!-- 교대형식 -->
        <result column="GDUP"               property="gdup"              />  <!-- 교대평수위상고 -->
        <result column="GDFILL"             property="gdfill"            />  <!-- 교대매립깊이 -->
        <result column="GDHEI"              property="gdhei"             />  <!-- 교대총높이 -->
        <result column="GDSTYLE1"           property="gdstyle1"          />  <!-- 교대기초형식 -->
        <result column="GDNSTYLE"           property="gdnstyle"          />  <!-- 교대날개벽종류 -->
        <result column="GDNAREA"            property="gdnarea"           />  <!-- 교대날개벽길이 -->
        <result column="PER_LANE"           property="perLane"           />  <!-- 점검통로_유무 -->
        <result column="CRS_TYPE"           property="crsType"           />  <!-- 교차종류 -->
        <result column="CEN_TYPE"           property="cenType"           />  <!-- 중앙분리대_종류 -->
        <result column="CEN_LEN"            property="cenLen"            />  <!-- 중앙분리대_연장 -->
        <result column="SEP_TYPE"           property="sepType"           />  <!-- 차도분리시설_종류 -->
        <result column="SEP_LEN"            property="sepLen"            />  <!-- 차도분리시설_연장 -->
        <result column="SGT_TYPE"           property="sgtType"           />  <!-- 조명시설_종류 -->
        <result column="SGT_EA"             property="sgtEa"             />  <!-- 조명시설_수량 -->
        <result column="SP_TYPE"            property="spType"            />  <!-- 방음시설_종류 -->
        <result column="SP_LEN"             property="spLen"             />  <!-- 방음시설_연장 -->
        <result column="PERIOD"             property="period"            />  <!-- 공사기간 -->
        <result column="TOTAL_CT"           property="totalCt"           />  <!-- 총사업비 -->
        <result column="DGN_CT"             property="dgnCt"             />  <!-- 설계비 -->
        <result column="WORK_CT"            property="workCt"            />  <!-- 공사비 -->
        <result column="SU_CT"              property="suCt"              />  <!-- 감리비 -->
        <result column="RI_CODE"            property="riCode"            />  <!-- 법정코드 -->
        <result column="REM"                property="rem"               />  <!-- 비고 -->
        <!--추가-->
        <result column="LOC_NAM"            property="locNam"            />  <!-- 로케이션 명 -->
    </resultMap>

    <resultMap id="Ae010GeoVoAddMap" type="Ae010GeoVo" extends="Ae010FeaVoMap">
        <result column="UID"                property="uid"               />  <!-- 시점 -->
        <result column="XMIN"               property="xmin"              />  <!-- X축 최소 -->
        <result column="XMAX"               property="xmax"              />  <!-- X축 최대 -->
        <result column="YMIN"               property="ymin"              />  <!-- Y축 최소 -->
        <result column="YMAX"               property="ymax"              />  <!-- Y축 최대 -->
        <result column="SHAPETYPE"          property="shapetype"         />  <!-- 도형타입 -->
        <result column="GEOMETRY"           property="geometry"          />  <!-- 기하학 -->
    </resultMap>

    <sql id="selectColumns">
        ${alias}UID
        , ${alias}MLV
        , ${alias}ROAD_NO
        , ${alias}SECT
        , ${alias}DOCODE
        , ${alias}FA_TYPE
        , ${alias}STR_LEVEL
        , ${alias}RE_DIA
        , ${alias}DOSTA1
        , ${alias}DOSTA2
        , ${alias}DOLENTH
        , ${alias}BR_NAME
        , ${alias}AREA
        , ${alias}SDATE
        , ${alias}EDATE
        , ${alias}STYLE
        , ${alias}OFFCE
        , ${alias}MANAGER
        , ${alias}PLAN
        , ${alias}SUPER
        , ${alias}GLEN
        , ${alias}GNUM
        , ${alias}COL_CONST
        , ${alias}COL_TYPE
        , ${alias}COL_MAT
        , ${alias}MDTH
        , ${alias}P_LOAD
        , ${alias}PER_WET
        , ${alias}IN_DE
        , ${alias}SUE_TYPE
        , ${alias}SUE_MAT
        , ${alias}GMSTYLE
        , ${alias}CWDT
        , ${alias}MWDT
        , ${alias}LANE_U
        , ${alias}LANE_D
        , ${alias}SPC
        , ${alias}HEI
        , ${alias}UMWDT
        , ${alias}UGIFT
        , ${alias}HWDT
        , ${alias}HLEN
        , ${alias}HHEI
        , ${alias}FIXSTYLE
        , ${alias}WKSTYLE
        , ${alias}LINK_LEN
        , ${alias}LINK_EA
        , ${alias}LINK_TYPE
        , ${alias}LINK_NEA
        , ${alias}GY_TYPE
        , ${alias}GY_THICK
        , ${alias}GY_WATER
        , ${alias}GKSTYLE
        , ${alias}GKNUM
        , ${alias}GKFILL
        , ${alias}GKHEI
        , ${alias}EDG_BASE
        , ${alias}EDG_HRN
        , ${alias}UPSTYLE
        , ${alias}DNSTYLE
        , ${alias}GDSTYLE
        , ${alias}GDUP
        , ${alias}GDFILL
        , ${alias}GDHEI
        , ${alias}GDSTYLE1
        , ${alias}GDNSTYLE
        , ${alias}GDNAREA
        , ${alias}PER_LANE
        , ${alias}CRS_TYPE
        , ${alias}CEN_TYPE
        , ${alias}CEN_LEN
        , ${alias}SEP_TYPE
        , ${alias}SEP_LEN
        , ${alias}SGT_TYPE
        , ${alias}SGT_EA
        , ${alias}SP_TYPE
        , ${alias}SP_LEN
        , ${alias}PERIOD
        , ${alias}TOTAL_CT
        , ${alias}DGN_CT
        , ${alias}WORK_CT
        , ${alias}SU_CT
        , ${alias}RI_CODE
        , ${alias}REM
    </sql>

    <!-- 컬럼 -->
    <sql id="columns">
        UID
        , MLV
        , ROAD_NO
        , SECT
        , DOCODE
        , FA_TYPE
        , STR_LEVEL
        , RE_DIA
        , DOSTA1
        , DOSTA2
        , DOLENTH
        , BR_NAME
        , AREA
        , SDATE
        , EDATE
        , STYLE
        , OFFCE
        , MANAGER
        , PLAN
        , SUPER
        , GLEN
        , GNUM
        , COL_CONST
        , COL_TYPE
        , COL_MAT
        , MDTH
        , P_LOAD
        , PER_WET
        , IN_DE
        , SUE_TYPE
        , SUE_MAT
        , GMSTYLE
        , CWDT
        , MWDT
        , LANE_U
        , LANE_D
        , SPC
        , HEI
        , UMWDT
        , UGIFT
        , HWDT
        , HLEN
        , HHEI
        , FIXSTYLE
        , WKSTYLE
        , LINK_LEN
        , LINK_EA
        , LINK_TYPE
        , LINK_NEA
        , GY_TYPE
        , GY_THICK
        , GY_WATER
        , GKSTYLE
        , GKNUM
        , GKFILL
        , GKHEI
        , EDG_BASE
        , EDG_HRN
        , UPSTYLE
        , DNSTYLE
        , GDSTYLE
        , GDUP
        , GDFILL
        , GDHEI
        , GDSTYLE1
        , GDNSTYLE
        , GDNAREA
        , PER_LANE
        , CRS_TYPE
        , CEN_TYPE
        , CEN_LEN
        , SEP_TYPE
        , SEP_LEN
        , SGT_TYPE
        , SGT_EA
        , SP_TYPE
        , SP_LEN
        , PERIOD
        , TOTAL_CT
        , DGN_CT
        , WORK_CT
        , SU_CT
        , RI_CODE
        , REM
    </sql>

    <!-- 값 -->
    <sql id="values">
        #{uid}
        , #{mlv}
        , #{roadNo}
        , #{sect}
        , #{docode}
        , #{faType}
        , #{strLevel}
        , #{reDia}
        , #{dosta1}
        , #{dosta2}
        , #{dolenth}
        , #{brName}
        , #{area}
        , #{sdate}
        , #{edate}
        , #{style}
        , #{offce}
        , #{manager}
        , #{plan}
        , #{SUPER}
        , #{glen}
        , #{gnum}
        , #{colConst}
        , #{colType}
        , #{colMat}
        , #{mdth}
        , #{pLoad}
        , #{perWet}
        , #{inDe}
        , #{sueType}
        , #{sueMat}
        , #{gmstyle}
        , #{cwdt}
        , #{mwdt}
        , #{laneU}
        , #{laneD}
        , #{spc}
        , #{hei}
        , #{umwdt}
        , #{ugift}
        , #{hwdt}
        , #{hlen}
        , #{hhei}
        , #{fixstyle}
        , #{wkstyle}
        , #{linkLen}
        , #{linkEa}
        , #{linkType}
        , #{linkNea}
        , #{gyType}
        , #{gyThick}
        , #{gyWater}
        , #{gkstyle}
        , #{gknum}
        , #{gkfill}
        , #{gkhei}
        , #{edgBase}
        , #{edgHrn}
        , #{upstyle}
        , #{dnstyle}
        , #{gdstyle}
        , #{gdup}
        , #{gdfill}
        , #{gdhei}
        , #{gdstyle1}
        , #{gdnstyle}
        , #{gdnarea}
        , #{perLane}
        , #{crsType}
        , #{cenType}
        , #{cenLen}
        , #{sepType}
        , #{sepLen}
        , #{sgtType}
        , #{sgtEa}
        , #{spType}
        , #{spLen}
        , #{period}
        , #{totalCt}
        , #{dgnCt}
        , #{workCt}
        , #{suCt}
        , #{riCode}
        , #{rem}
    </sql>

    <!-- 업데이트 값 -->
    <sql id="updateField">
        <trim prefixOverrides=",">
            <if test="uid != null">
                , UID               = #{uid}
            </if>
            <if test="mlv != null">
                , MLV               = #{mlv}
            </if>
            <if test="roadNo != null">
                , ROAD_NO           = #{roadNo}
            </if>
            <if test="sect != null">
                , SECT              = #{sect}
            </if>
            <if test="docode != null">
                , DOCODE            = #{docode}
            </if>
            <if test="faType != null">
                , FA_TYPE           = #{faType}
            </if>
            <if test="strLevel != null">
                , STR_LEVEL         = #{strLevel}
            </if>
            <if test="reDia != null">
                , RE_DIA            = #{reDia}
            </if>
            <if test="dosta1 != null">
                , DOSTA1            = #{dosta1}
            </if>
            <if test="dosta2 != null">
                , DOSTA2            = #{dosta2}
            </if>
            <if test="dolenth != null">
                , DOLENTH           = #{dolenth}
            </if>
            <if test="brName != null">
                , BR_NAME           = #{brName}
            </if>
            <if test="area != null">
                , AREA              = #{area}
            </if>
            <if test="sdate != null">
                , SDATE             = #{sdate}
            </if>
            <if test="edate != null">
                , EDATE             = #{edate}
            </if>
            <if test="style != null">
                , STYLE             = #{style}
            </if>
            <if test="offce != null">
                , OFFCE             = #{offce}
            </if>
            <if test="manager != null">
                , MANAGER           = #{manager}
            </if>
            <if test="plan != null">
                , PLAN              = #{plan}
            </if>
            <if test="SUPER != null">
                , SUPER             = #{SUPER}
            </if>
            <if test="glen != null">
                , GLEN              = #{glen}
            </if>
            <if test="gnum != null">
                , GNUM              = #{gnum}
            </if>
            <if test="colConst != null">
                , COL_CONST         = #{colConst}
            </if>
            <if test="colType != null">
                , COL_TYPE          = #{colType}
            </if>
            <if test="colMat != null">
                , COL_MAT           = #{colMat}
            </if>
            <if test="mdth != null">
                , MDTH              = #{mdth}
            </if>
            <if test="pLoad != null">
                , P_LOAD            = #{pLoad}
            </if>
            <if test="perWet != null">
                , PER_WET           = #{perWet}
            </if>
            <if test="inDe != null">
                , IN_DE             = #{inDe}
            </if>
            <if test="sueType != null">
                , SUE_TYPE          = #{sueType}
            </if>
            <if test="sueMat != null">
                , SUE_MAT           = #{sueMat}
            </if>
            <if test="gmstyle != null">
                , GMSTYLE           = #{gmstyle}
            </if>
            <if test="cwdt != null">
                , CWDT              = #{cwdt}
            </if>
            <if test="mwdt != null">
                , MWDT              = #{mwdt}
            </if>
            <if test="laneU != null">
                , LANE_U            = #{laneU}
            </if>
            <if test="laneD != null">
                , LANE_D            = #{laneD}
            </if>
            <if test="spc != null">
                , SPC               = #{spc}
            </if>
            <if test="hei != null">
                , HEI               = #{hei}
            </if>
            <if test="umwdt != null">
                , UMWDT             = #{umwdt}
            </if>
            <if test="ugift != null">
                , UGIFT             = #{ugift}
            </if>
            <if test="hwdt != null">
                , HWDT              = #{hwdt}
            </if>
            <if test="hlen != null">
                , HLEN              = #{hlen}
            </if>
            <if test="hhei != null">
                , HHEI              = #{hhei}
            </if>
            <if test="fixstyle != null">
                , FIXSTYLE          = #{fixstyle}
            </if>
            <if test="wkstyle != null">
                , WKSTYLE           = #{wkstyle}
            </if>
            <if test="linkLen != null">
                , LINK_LEN          = #{linkLen}
            </if>
            <if test="linkEa != null">
                , LINK_EA           = #{linkEa}
            </if>
            <if test="linkType != null">
                , LINK_TYPE         = #{linkType}
            </if>
            <if test="linkNea != null">
                , LINK_NEA          = #{linkNea}
            </if>
            <if test="gyType != null">
                , GY_TYPE           = #{gyType}
            </if>
            <if test="gyThick != null">
                , GY_THICK          = #{gyThick}
            </if>
            <if test="gyWater != null">
                , GY_WATER          = #{gyWater}
            </if>
            <if test="gkstyle != null">
                , GKSTYLE           = #{gkstyle}
            </if>
            <if test="gknum != null">
                , GKNUM             = #{gknum}
            </if>
            <if test="gkfill != null">
                , GKFILL            = #{gkfill}
            </if>
            <if test="gkhei != null">
                , GKHEI             = #{gkhei}
            </if>
            <if test="edgBase != null">
                , EDG_BASE          = #{edgBase}
            </if>
            <if test="edgHrn != null">
                , EDG_HRN           = #{edgHrn}
            </if>
            <if test="upstyle != null">
                , UPSTYLE           = #{upstyle}
            </if>
            <if test="dnstyle != null">
                , DNSTYLE           = #{dnstyle}
            </if>
            <if test="gdstyle != null">
                , GDSTYLE           = #{gdstyle}
            </if>
            <if test="gdup != null">
                , GDUP              = #{gdup}
            </if>
            <if test="gdfill != null">
                , GDFILL            = #{gdfill}
            </if>
            <if test="gdhei != null">
                , GDHEI             = #{gdhei}
            </if>
            <if test="gdstyle1 != null">
                , GDSTYLE1          = #{gdstyle1}
            </if>
            <if test="gdnstyle != null">
                , GDNSTYLE          = #{gdnstyle}
            </if>
            <if test="gdnarea != null">
                , GDNAREA           = #{gdnarea}
            </if>
            <if test="perLane != null">
                , PER_LANE          = #{perLane}
            </if>
            <if test="crsType != null">
                , CRS_TYPE          = #{crsType}
            </if>
            <if test="cenType != null">
                , CEN_TYPE          = #{cenType}
            </if>
            <if test="cenLen != null">
                , CEN_LEN           = #{cenLen}
            </if>
            <if test="sepType != null">
                , SEP_TYPE          = #{sepType}
            </if>
            <if test="sepLen != null">
                , SEP_LEN           = #{sepLen}
            </if>
            <if test="sgtType != null">
                , SGT_TYPE          = #{sgtType}
            </if>
            <if test="sgtEa != null">
                , SGT_EA            = #{sgtEa}
            </if>
            <if test="spType != null">
                , SP_TYPE           = #{spType}
            </if>
            <if test="spLen != null">
                , SP_LEN            = #{spLen}
            </if>
            <if test="period != null">
                , PERIOD            = #{period}
            </if>
            <if test="totalCt != null">
                , TOTAL_CT          = #{totalCt}
            </if>
            <if test="dgnCt != null">
                , DGN_CT            = #{dgnCt}
            </if>
            <if test="workCt != null">
                , WORK_CT           = #{workCt}
            </if>
            <if test="suCt != null">
                , SU_CT             = #{suCt}
            </if>
            <if test="riCode != null">
                , RI_CODE           = #{riCode}
            </if>
            <if test="rem != null">
                , REM               = #{rem}
            </if>
        </trim>
    </sql>

    <sql id="defaultWhere">
        <trim prefix="AND" prefixOverrides="AND">
            <if  test="'' != roadNo and null != roadNo">
                AND AF.ROAD_NO  LIKE CONCAT('%', #{roadNo}, '%')
            </if>
            <if test="'' != sect and null != sect">
                AND AF.SECT     LIKE CONCAT('%', #{sect}, '%')
            </if>
        </trim>
    </sql>

    <!-- 시설 : 교량 정보 조회 -->
    <select id="selectGetList" resultMap="Ae010GeoVoAddMap">
        SELECT  <include refid="selectColumns">
        <property name="alias" value="AF." />
    </include>
        ,       (SELECT LOC_NAM FROM BML_DNRI_AS_FEA WHERE RI_CD = AF.RI_CODE) AS LOC_NAM
        ,       AG.XMIN
        ,       AG.XMAX
        ,       AG.YMIN
        ,       AG.YMAX
        ,       AG.SHAPETYPE
        FROM    AE010_FEA AS AF
        ,       AE010_GEO AS AG
        WHERE   AF.UID = AG.UID
        <include refid="defaultWhere" />
        ORDER BY AF.DOSTA1 ASC
    </select>

    <!-- 교량 정보 조회 -->
    <select id="selectGetInfo" parameterType="ae010FeaVO" resultType="ae010FeaVO">
        SELECT  <include refid="columns"/>
        FROM    AE010_FEA
        WHERE   DOCODE   = #{docode}
    </select>

    <!-- 교량 수정 -->
    <update id="updateFacilityInfo">
        UPDATE AE010_FEA
        SET    <include refid="updateField" />
        WHERE   UID   = #{uid}
    </update>
</mapper>