<?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.interplug.qcast.biz.estimate.EstimateMapper">

    <select id="selectEstimateDetail" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.EstimateResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateDetail */
        SELECT
              P.OBJECT_NO
            , P.PLAN_NO
            , P.CONSTRUCT_SPECIFICATION
            , P.SETUP_HEIGHT
            , P.WEATHER_POINT
            , P.ROOF_KIND_ID
            , P.SLOPE
            , P.ANGLE
            , P.ROOF_MATERIAL_CLASS_ID
            , P.ROOF_MATERIAL_ID
            , P.SUPPORT_METHOD_ID
            , P.MODULE_MODEL
            , P.DRAWING_ESTIMATE_CREATE_DATE
            , P.CHARGER
            , P.ESTIMATE_VALIDITY_TERM
            , P.DECISION_PLAN
            , P.NUMBER
            , P.CAPACITY
            , P.SNOWFALL
            , P.STANDARD_WIND_SPEED_CHECK
            , P.OPTION_COVER
            , P.HANWFA_FLG
            , P.STAND_KIND_ID
            , P.STANDARD_WIND_SPEED_ID
            , P.SUPPORT_MEAKER
            , P.CONSUMPTION_TAX_ID
            , P.STATUS
            , P.PC_TYPE_NO
            , P.NORTH_ARRANGEMENT
            , P.CONSTRUCT_SPECIFICATION_MULTI
            , P.ROOF_MATERIAL_ID_MULTI
            , P.SUPPORT_METHOD_ID_MULTI
            , P.SUPPORT_MEAKER_MULTI
            , P.DIFF_ROOF_ENABLED
            , P.ORDER_FLG
            , P.ESTIMATE_DATE
            , P.DOC_NO
            , P.ESTIMATE_TYPE
            , P.FILE_FLG
            , P.ESTIMATE_OPTION
            , P.PKG_ASP
            , P.PRICE_CD
            , P.REMARKS
            , P.LAST_EDIT_DATETIME
            , O.OBJECT_NAME
            , O.OBJECT_NAME_OMIT
            , O.REMARKS AS OBJECT_REMARKS
            , O.SALE_STORE_ID
            , SS.FIRST_AGENT_ID
            , SS.SALE_STORE_LEVEL
            , CASE WHEN ISNULL(SS.FIRST_AGENT_ID, '') = '' THEN SS.SALE_STORE_NAME ELSE (SELECT SALE_STORE_NAME FROM M_SALES_STORE WHERE SALE_STORE_ID = SS.FIRST_AGENT_ID) END AS FIRST_SALE_STORE_NAME
            , CASE WHEN ISNULL(SS.FIRST_AGENT_ID, '') = '' THEN NULL ELSE SS.SALE_STORE_NAME END AS AGENCY_SALE_STORE_NAME
        FROM T_PLAN P WITH (NOLOCK)
        INNER JOIN T_OBJECT O WITH (NOLOCK)
            ON P.OBJECT_NO = O.OBJECT_NO
        INNER JOIN M_SALES_STORE SS WITH(NOLOCK)
            ON O.SALE_STORE_ID = SS.SALE_STORE_ID
        WHERE P.OBJECT_NO = #{objectNo}
          AND P.PLAN_NO = #{planNo}
          AND P.DEL_FLG = '0'
    </select>

    <select id="selectEstimatePdfDetail" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.EstimateResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectPdfEstimateDetail */
        SELECT
              T.*
            , SS1.SALE_STORE_NAME AS CUST_SALE_STORE_NAME
            , SS2.SALE_STORE_NAME
            , SS2.ZIP_NO
            , SS2.ADDRESS
            , SS2.TEL
            , SS2.FAX
            , SS2.BIZ_NO
        FROM
        (
            SELECT
                  P.OBJECT_NO
                , P.PLAN_NO
                , P.ESTIMATE_VALIDITY_TERM
                , P.ESTIMATE_TYPE
                , P.ESTIMATE_OPTION
                , P.PKG_ASP
                , P.REMARKS
                , CONVERT(NVARCHAR(10), P.LAST_EDIT_DATETIME, 121) AS ESTIMATE_DATE
                , O.SALE_STORE_ID
                , O.OBJECT_NAME
                , O.OBJECT_NAME_OMIT
                , (SELECT SALE_STORE_ID FROM M_USER WHERE USER_ID = O.CREATE_USER) AS CREATE_SALE_STORE_ID
            FROM T_PLAN P WITH (NOLOCK)
	        INNER JOIN T_OBJECT O WITH (NOLOCK)
                ON P.OBJECT_NO = O.OBJECT_NO
            WHERE P.OBJECT_NO = #{objectNo}
                AND P.PLAN_NO = #{planNo}
        ) T
        LEFT OUTER JOIN M_SALES_STORE SS1 WITH (NOLOCK)
            ON T.SALE_STORE_ID = SS1.SALE_STORE_ID
        LEFT OUTER JOIN M_SALES_STORE SS2 WITH (NOLOCK)
            ON T.CREATE_SALE_STORE_ID = SS2.SALE_STORE_ID
    </select>

    <select id="selectEstimateApiDetail" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.EstimateSendResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateDetail */
        SELECT
              O.OBJECT_NO
            , O.SALE_STORE_ID
            , O.OBJECT_NAME
            , O.RECEIVE_COMPANY_NAME
            , O.RECEIVE_USER
            , O.DELIVERY_ZIP_NO
            , O.DELIVERY_TARGET
            , O.DELIVERY_TEL
            , O.DELIVERY_HOPE_DATE
            , O.SPECIFICATION_CONFIRM_DATE
            , O.PAYMENT_TERMS
            , O.CAR_KIND_CD
            , O.TRACK_KAIND AS TRACK_KIND
            , O.TRACK_10T_DELIVERY
            , O.TRACK_WEIGHT
            , O.TRACK_TIME_SPECIFY
            , O.TRACK_TIME
            , O.FORKLIFT
            , O.HOUSE_CLASS_CD
            , O.BUSINESS_CHARGER_CD
            , O.BUSINESS_GROUP_CD
            , P.PLAN_NO
            , P.CONSTRUCT_SPECIFICATION
            , P.NORTH_ARRANGEMENT
            , P.ESTIMATE_TYPE
            , P.PKG_ASP
            , P.DEL_FLG
            , CONVERT(NVARCHAR(10), P.CREATE_DATETIME, 121)  AS ESTIMATE_DETAIL_CREATE_DATE
            , P.LAST_EDIT_DATETIME
            , P.LAST_EDIT_USER
        FROM T_PLAN P WITH (NOLOCK)
        INNER JOIN T_OBJECT O WITH (NOLOCK)
            ON P.OBJECT_NO = O.OBJECT_NO
        INNER JOIN M_SALES_STORE SS WITH(NOLOCK)
            ON O.SALE_STORE_ID = SS.SALE_STORE_ID
        WHERE P.OBJECT_NO = #{objectNo}
          AND P.PLAN_NO = #{planNo}
    </select>

    <select id="selectEstimateItemList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.ItemResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateItemList */
        SELECT
              PE.OBJECT_NO
            , PE.PLAN_NO
            , PE.DISP_ORDER
            , PE.ITEM_ID
            , PE.ITEM_NO
            , PE.ITEM_NAME
            , PE.UNIT
            , PE.SPECIFICATION
            , PE.AMOUNT
            , PE.UNIT_PRICE
            , PE.SALE_PRICE
            , PE.FILE_UPLOAD_FLG
            , PE.PKG_MATERIAL_FLG
            , PE.SPECIAL_NOTE_CD
            , PE.ITEM_CHANGE_FLG
            , I.PNOW_W
            , CASE WHEN I.ITEM_GROUP = 'MODULE_' THEN '1' ELSE '0' END AS MODULE_FLG
        FROM T_PART_ESTIMATE PE WITH (NOLOCK)
        INNER JOIN M_ITEM I WITH (NOLOCK)
            ON PE.ITEM_ID = I.ITEM_ID
        WHERE PE.OBJECT_NO = #{objectNo}
            AND PE.PLAN_NO = #{planNo}
        ORDER BY
            PE.DISP_ORDER ASC
    </select>

    <select id="selectItemMasterList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest" resultType="com.interplug.qcast.biz.estimate.dto.ItemResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectItemMasterList */
        SELECT
              I.ITEM_ID
            , I.ITEM_NO
            , I.ITEM_NAME
            , I.UNIT
            , I.PNOW_W
            , I.ITEM_GROUP
            , I.PKG_MATERIAL_FLG
            , I.FILE_UPLOAD_FLG
            , ISNULL(PPM.SALE_PRICE, '0') AS SALE_PRICE
        FROM M_ITEM I WITH (NOLOCK)
        LEFT OUTER JOIN M_PRICE_PATTERN_MONEY PPM
            ON PPM.PRICE_PATTERN = '510'
            AND I.ITEM_ID = PPM.ITEM_ID
        WHERE I.ITEM_ID IN
            <foreach collection="arrItemId" item="itemId" index="index" separator="," open="(" close=")">
                #{itemId}
            </foreach>
    </select>

    <select id="selectEstimateNoteList" parameterType="com.interplug.qcast.biz.estimate.dto.NoteRequest" resultType="com.interplug.qcast.biz.estimate.dto.NoteResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateNoteList */
        SELECT
              CL.CODE
            , CL.CODE_NM
            , OSN.REMARKS
        FROM M_COMM_L CL WITH (NOLOCK)
        INNER JOIN T_OBJECT_SPECIAL_NOTE OSN WITH (NOLOCK)
            ON CL.CODE  = OSN.SPN_ATTR_CD
        WHERE CL.HEAD_CD = '202400'
            AND CL.DEL_FLG = '0'
            AND OSN.USE_FLG = '1'
            AND OSN.DEL_FLG = '0'
            <if test='schSpnTypeCd != null and schSpnTypeCd != ""'>
            AND OSN.SPN_TYPE_CD = #{schSpnTypeCd}
            </if>
            <if test='arrSpnAttrCd != null'>
            AND CL.CODE IN
                <foreach collection="arrSpnAttrCd" item="code" index="index" separator="," open="(" close=")">
                    #{code}
                </foreach>
            </if>
    </select>

    <select id="selectEstimateNoteItemList" parameterType="com.interplug.qcast.biz.estimate.dto.NoteRequest" resultType="com.interplug.qcast.biz.estimate.dto.NoteResponse">
        /* sqlid : com.interplug.qcast.biz.estimate.selectEstimateNoteItemList */
        SELECT
              CL.CODE
            , OSNI.ITEM_ID
        FROM M_COMM_L CL WITH (NOLOCK)
        INNER JOIN T_OBJECT_SPECIAL_NOTE OSN WITH (NOLOCK)
            ON CL.CODE  = OSN.SPN_ATTR_CD
        INNER JOIN T_OBJECT_SPECIAL_NOTE_ITEM OSNI WITH (NOLOCK)
            ON OSN.SPN_ATTR_CD = OSNI.SPN_ATTR_CD
            AND OSN.SPN_TYPE_CD = OSNI.SPN_TYPE_CD
        WHERE CL.HEAD_CD = '202400'
            AND CL.DEL_FLG = '0'
            AND OSN.USE_FLG = '1'
            AND OSN.DEL_FLG = '0'
            AND OSNI.DEL_FLG = '0'
            <if test='schSpnTypeCd != null and schSpnTypeCd != ""'>
            AND OSN.SPN_TYPE_CD = #{schSpnTypeCd}
            </if>
            AND OSNI.ITEM_ID IN
            <foreach collection="arrItemId" item="itemId" index="index" separator="," open="(" close=")">
                #{itemId}
            </foreach>
    </select>

    <update id="updateObject" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.updateObject */
        UPDATE T_OBJECT
        SET
              LAST_EDIT_DATETIME = GETDATE()
            , LAST_EDIT_USER = #{userId}
            <if test='objectName != null and objectName != ""'>
            , OBJECT_NAME = #{objectName}
            </if>
            <if test='standardWindSpeedId != null and standardWindSpeedId != ""'>
            , STANDARD_WIND_SPEED_ID = #{standardWindSpeedId}
            </if>
            <if test='snowfall != null and snowfall != ""'>
            , VERTICAL_SNOW_COVER = #{snowfall}
            </if>
            <if test='surfaceType != null and surfaceType != ""'>
            , SURFACE_TYPE = #{surfaceType}
            </if>
            <if test='setupHeight != null and setupHeight != ""'>
            , INSTALL_HEIGHT = #{setupHeight}
            </if>
        WHERE OBJECT_NO = #{objectNo}
    </update>

    <update id="updateEstimate" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.updateEstimate */
        UPDATE T_PLAN
        SET
              ESTIMATE_TYPE = #{estimateType}
            <choose>
            <when test='drawingFlg != null and drawingFlg == "1"'>
                , CONSTRUCT_SPECIFICATION = #{constructSpecification}
                , SETUP_HEIGHT = #{setupHeight}
                , WEATHER_POINT = #{weatherPoint}
                , SLOPE = #{slope}
                , ANGLE = #{angle}
                , ROOF_MATERIAL_ID = #{roofMaterialId}
                , SUPPORT_METHOD_ID = #{supportMethodId}
                , DRAWING_ESTIMATE_CREATE_DATE = GETDATE()
                , CHARGER = #{charger}
                , ESTIMATE_VALIDITY_TERM = '発行日より1ヶ月'
                , SNOWFALL = #{snowfall}
                , STANDARD_WIND_SPEED_ID = #{standardWindSpeedId}
                , SUPPORT_MEAKER = #{supportMeaker}
                , NORTH_ARRANGEMENT = #{northArrangement}
                , CONSTRUCT_SPECIFICATION_MULTI = #{constructSpecificationMulti}
                , ROOF_MATERIAL_ID_MULTI = #{roofMaterialIdMulti}
                , SUPPORT_METHOD_ID_MULTI = #{supportMethodIdMulti}
                , SUPPORT_MEAKER_MULTI = #{supportMeaker}
                , ESTIMATE_DATE = CONVERT(NVARCHAR(10), GETDATE(), 121)
                , FILE_FLG = '0'
                , ESTIMATE_OPTION = #{estimateOption}
                , PKG_ASP = NULL
                , PRICE_CD = #{priceCd}
                , SURFACE_TYPE = #{surfaceType}
            </when>
            <otherwise>
                , CHARGER = #{charger}
                , ESTIMATE_DATE = #{estimateDate}
                , FILE_FLG = #{fileFlg}
                , ESTIMATE_OPTION = #{estimateOption}
                , REMARKS = #{remarks}
                , PKG_ASP = #{pkgAsp}
                , PRICE_CD = #{priceCd}
            </otherwise>
            </choose>
            , CAPACITY = #{capacity}
            , MODULE_MODEL = #{moduleModel}
            , PC_TYPE_NO = #{pcTypeNo}
            , LAST_EDIT_DATETIME = GETDATE()
            , LAST_EDIT_USER = #{userId}
        WHERE OBJECT_NO = #{objectNo}
            AND PLAN_NO = #{planNo}
    </update>

    <update id="updateEstimateApi" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.updateEstimateApi */
        UPDATE T_PLAN
        SET
              DOC_NO = #{docNo}
            , SYNC_FLG = #{syncFlg}
        WHERE OBJECT_NO = #{objectNo}
            AND PLAN_NO = #{planNo}
    </update>

    <insert id="insertEstimateItem" parameterType="com.interplug.qcast.biz.estimate.dto.ItemRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateItem */
        INSERT INTO T_PART_ESTIMATE
        (
              OBJECT_NO
            , PLAN_NO
            , DISP_ORDER
            , ITEM_ID
            , ITEM_NO
            , ITEM_NAME
            , UNIT
            , SPECIFICATION
            , AMOUNT
            <if test='amountChange != null and amountChange != ""'>
            , AMOUNT_CHANGE
            </if>
            , PART_ADD
            , LAST_EDIT_DATETIME
            , LAST_EDIT_USER
            , UNIT_PRICE
            , SALE_PRICE
            , FILE_UPLOAD_FLG
            , PKG_MATERIAL_FLG
            <if test='specialNoteCd != null and specialNoteCd != ""'>
            , SPECIAL_NOTE_CD
            </if>
            , ITEM_CHANGE_FLG
        ) VALUES (
              #{objectNo}
            , #{planNo}
            , #{dispOrder}
            , #{itemId}
            , #{itemNo}
            , #{itemName}
            , #{unit}
            , #{specification}
            , #{amount}
            <if test='amountChange != null and amountChange != ""'>
            , #{amountChange}
            </if>
            , #{partAdd}
            , GETDATE()
            , #{userId}
            , #{unitPrice}
            , #{salePrice}
            , #{fileUploadFlg}
            , #{pkgMaterialFlg}
            <if test='specialNoteCd != null and specialNoteCd != ""'>
            , #{specialNoteCd}
            </if>
            , #{itemChangeFlg}
        )
    </insert>

    <insert id="insertEstimateRoof" parameterType="com.interplug.qcast.biz.estimate.dto.RoofRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateRoof */
        <selectKey keyProperty="roofNo" keyColumn="roofNo" resultType="String" order="AFTER">
            SELECT @@IDENTITY
        </selectKey>

        INSERT INTO T_ROOF_ESTIMATE
        (
              OBJECT_NO
            , PLAN_NO
            , ROOF_SURFACE
            , ROOF_MATERIAL_ID
            , SUPPORT_METHOD_ID
            , CONSTRUCT_SPECIFICATION
            <if test='slope != null and slope != ""'>
            , SLOPE
            </if>
            <if test='angle != null and angle != ""'>
            , ANGLE
            </if>
            <if test='azimuth != null and azimuth != ""'>
            , AZIMUTH
            </if>
            , CREATE_DATETIME
            , CREATE_USER
        ) VALUES (
              #{objectNo}
            , #{planNo}
            , #{roofSurface}
            , #{roofMaterialId}
            , #{supportMethodId}
            , #{constructSpecification}
            <if test='slope != null and slope != ""'>
            , #{slope}
            </if>
            <if test='angle != null and angle != ""'>
            , #{angle}
            </if>
            <if test='azimuth != null and azimuth != ""'>
            , #{azimuth}
            </if>
            , GETDATE()
            , #{userId}
        )
    </insert>

    <insert id="insertEstimateRoofItem" parameterType="com.interplug.qcast.biz.estimate.dto.ItemRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateRoofItem */
        INSERT INTO T_ROOF_ITEM_ESTIMATE
        (
              ROOF_NO
            , OBJECT_NO
            , PLAN_NO
            , ITEM_ID
            , ITEM_NO
            , ITEM_NAME
            , SPECIFICATION
            , AMOUNT
        )
        SELECT
              #{roofNo} AS ROOF_NO
            , #{objectNo} AS OBJECT_NO
            , #{planNo} AS PLAN_NO
            , I.ITEM_ID
            , I.ITEM_NO
            , I.ITEM_NAME
            , I.PNOW_W
            , #{amount}
        FROM M_ITEM I WITH (NOLOCK)
        WHERE I.ITEM_ID = #{itemId}
    </insert>

    <delete id="deleteEstimateRoofList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateRoofList */
        DELETE FROM T_ROOF_ESTIMATE
        WHERE OBJECT_NO = #{objectNo}
          AND PLAN_NO = #{planNo}
    </delete>

    <delete id="deleteEstimateRoofItemList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateRoofItemList */
        DELETE FROM T_ROOF_ITEM_ESTIMATE
        WHERE OBJECT_NO = #{objectNo}
          AND PLAN_NO = #{planNo}
    </delete>

    <delete id="deleteEstimateItemList" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.deleteEstimateItemList */
        DELETE FROM T_PART_ESTIMATE
        WHERE OBJECT_NO = #{objectNo}
          AND PLAN_NO = #{planNo}
    </delete>

    <insert id="insertEstimateCopy" parameterType="com.interplug.qcast.biz.estimate.dto.EstimateRequest">
        /* sqlid : com.interplug.qcast.biz.estimate.insertEstimateCopy */
        <selectKey resultType="String" keyProperty="copyPlanNo" order="BEFORE">
            SELECT CAST(ISNULL(MAX(PLAN_NO), 0) + 1 AS NVARCHAR) FROM T_PLAN WITH (NOLOCK) WHERE OBJECT_NO = #{objectNo}
        </selectKey>

        INSERT INTO T_PLAN
        (
              OBJECT_NO
            , PLAN_NO
            , CONSTRUCT_SPECIFICATION
            , SETUP_HEIGHT
            , WEATHER_POINT
            , ROOF_KIND_ID
            , SLOPE
            , ROOF_MATERIAL_CLASS_ID
            , ROOF_MATERIAL_ID
            , SUPPORT_METHOD_ID
            , MODULE_MODEL
            , DRAWING_ESTIMATE_CREATE_DATE
            , CHARGER
            , ESTIMATE_VALIDITY_TERM
            , DECISION_PLAN
            , NUMBER
            , CAPACITY
            , SNOWFALL
            , STANDARD_WIND_SPEED_CHECK
            , OPTION_COVER
            , HANWFA_FLG
            , STAND_KIND_ID
            , STANDARD_WIND_SPEED_ID
            , SUPPORT_MEAKER
            , CONSUMPTION_TAX_ID
            , STATUS
            , LAST_EDIT_DATETIME
            , LAST_EDIT_USER
            , DEL_FLG
            , PC_TYPE_NO
            , NORTH_ARRANGEMENT
            , ROOF_MATERIAL_ID_MULTI
            , SUPPORT_METHOD_ID_MULTI
            , SUPPORT_MEAKER_MULTI
            , DIFF_ROOF_ENABLED
            , ORDER_FLG
            , ESTIMATE_DATE
            , ESTIMATE_TYPE
            , FILE_FLG
            , ESTIMATE_OPTION
            , PKG_ASP
            , PRICE_CD
            , REMARKS
        )
        SELECT
              #{objectNo} AS OBJECT_NO
            , #{copyPlanNo} AS PLAN_NO
            , P.CONSTRUCT_SPECIFICATION
            , P.SETUP_HEIGHT
            , P.WEATHER_POINT
            , P.ROOF_KIND_ID
            , P.SLOPE
            , P.ROOF_MATERIAL_CLASS_ID
            , P.ROOF_MATERIAL_ID
            , P.SUPPORT_METHOD_ID
            , P.MODULE_MODEL
            , GETDATE() AS DRAWING_ESTIMATE_CREATE_DATE
            , P.CHARGER
            , P.ESTIMATE_VALIDITY_TERM
            , P.DECISION_PLAN
            , P.NUMBER
            , P.CAPACITY
            , P.SNOWFALL
            , P.STANDARD_WIND_SPEED_CHECK
            , P.OPTION_COVER
            , P.HANWFA_FLG
            , P.STAND_KIND_ID
            , P.STANDARD_WIND_SPEED_ID
            , P.SUPPORT_MEAKER
            , P.CONSUMPTION_TAX_ID
            , '1' AS STATUS
            , GETDATE() AS LAST_EDIT_DATETIME
            , #{userId} AS LAST_EDIT_USER
            , P.DEL_FLG
            , P.PC_TYPE_NO
            , P.NORTH_ARRANGEMENT
            , P.ROOF_MATERIAL_ID_MULTI
            , P.SUPPORT_METHOD_ID_MULTI
            , P.SUPPORT_MEAKER_MULTI
            , P.DIFF_ROOF_ENABLED
            , '0' AS ORDER_FLG
            , P.ESTIMATE_DATE
            , P.ESTIMATE_TYPE
            , P.FILE_FLG
            , P.ESTIMATE_OPTION
            , P.PKG_ASP
            , P.PRICE_CD
            , P.REMARKS
        FROM T_PLAN P WITH (NOLOCK)
        WHERE P.OBJECT_NO = #{objectNo}
            AND P.PLAN_NO = #{planNo}
            AND P.DEL_FLG = '0'
    </insert>

</mapper>