<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">

    <query id="CrmSlmOrder.getOrderInfo" desc="查询合同信息">
        <![CDATA[
	SELECT   H.ORD_PK,
		L.ORD_LN_PK,
		D.ORD_LN_DLY_PK,
		H.ORDER_NO,
		L.ORDER_SEQ,
		D.DELIVERY_NO,
		H.CUSTM_ORDER_NO,
		H.ORDER_TYP,
		H.ORDER_TYP_DESC,
		C.REGION_NO,
		(SELECT T.REGION_NM FROM SEL_ADMIN_REGION T WHERE T.REGION_NO=C.REGION_NO) REGION_NAME,
		H.SALE_ORG,
		H.SALE_ORG_DESC,
		H.SALE_AREA_NO,
		H.SALE_AREA_DESC,
		H.CUSTOMER_NO,
		H.CUSTOMER_NM,
		D.RECEIV_NO,
		D.RECEIV_NM,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.PRICE_FL) PRICE_FL,
		D.DELVRY_QTY ORDER_QTY,
		L.BALNCE_PRICE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.CURRENCY) CURRENCY,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.MNY_ASK_TYP) MNY_ASK_TYP,
		H.CONTAIN_TAX,
		D.ORDER_UNIT,
		L.PRODUCCODE,
		L.PRODUCNAME,
		L.STD_CODE,
		L.STD_NAME,
		L.STEELCODE,
		L.STEELNAME,
		L.STD_STYLE,
		L.STD_STYLE_DESC,
		L.MODEL_CODE,
		L.MODEL_DESC,
		L.ORDER_SPEC_CODE,
		L.ORDER_SPEC_DESC,
		L.SPEC_CODE,
		L.SPEC_NAME,
		L.DIMATER,
		L.HEIGHT,
		L.LEN_NO,
		L.LEN_DESC,
		L.LEN_UNIT,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_BILLET_FL) OUTS_BILLET_FL,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
		H.MNY_ASK_DESC,
		L.ISLOCK,
		L.PRDCR_DESC,
		L.MPS_DESC,
		H.STLMT_UNIT_NO,
		H.STLMT_UNIT_NM,
		L.DELVRY_RANGE_TPE,
		L.DELVRY_RANGE_MIN,
		L.DELVRY_RANGE_MAX,
		L.ADD_ASK_NO,
		L.ORDER_ADD_DESC,
		L.ORDER_SPECIAL_DESC,
		D.DELIVERY_STATUS ORDER_STS,
        (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=D.DELIVERY_STATUS) ORDER_STS_DESC,
        L.ORDER_LN_STATUS ORDER_LN_STS,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.ORDER_LN_STATUS) ORDER_LN_STS_DESC,
		H.SUPPLY_UNIT SUPPLY_UNIT_CODE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.SUPPLY_UNIT) SUPPLY_UNIT,
		D.WGT_ESTMT,
		to_char(D.DELVRY_EDATE,'YYYY-MM-DD') DELVRY_EDATE,
		to_char(H.EFFECT_TIME,'YYYY-MM-DD') EFFECT_TIME,
		to_char((SELECT T.CREATE_TIME FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK=D.ORD_LN_DLY_PK),'YYYY-MM-DD') TIBAO_TIME
		FROM SLM_ORDER_HEAD H,SLM_ORDER_LINE L ,SLM_ORDER_LINE_DELIVERY D,
		SLM_BASE_CUSTOMER C
		WHERE H.ORD_PK=L.ORD_PK AND L.ORD_LN_PK=D.ORD_LN_PK
		AND H.CUSTOMER_NO=C.CUSTOMER_NO
		]]>
    </query>

    <query id="CrmSlmOrder.deleteCrmOrder" desc="作废">
        UPDATE CRM_SLM_ORDER T
        SET T.VALIDFLAG = '0',
        T.DATA_STATUS = '2',
        T.IS_FLAG ='1'
        WHERE
        T.ORD_PK = ?
        AND T.ORD_LN_PK = ?
    </query>

    <query id="CrmSlmOrder.insertDeliveryToCrmOrder" desc="新增交货行">
        <![CDATA[
	 	INSERT INTO CRM_SLM_ORDER
  (	ORD_PK,
	ORD_LN_PK,
	ORD_LN_DLY_PK,
	ORDER_NO,
	ORDER_SEQ,
	DELIVERY_NO,
	CUSTM_ORDER_NO,
	ORDER_TYP,
	ORDER_TYP_DESC,
	REGION_NO,
	REGION_NAME,
	SALE_ORG,
	SALE_ORG_DESC,
	SALE_AREA_NO,
	SALE_AREA_DESC,
	CUSTOMER_NO,
	CUSTOMER_NM,
	RECEIV_NO,
	RECEIV_NM,
	PRICE_FL,
	ORDER_QTY,
	BALNCE_PRICE,
	CURRENCY,
	MNY_ASK_TYP,
	CONTAIN_TAX,
	ORDER_UNIT,
	PRODUCCODE,
	PRODUCNAME,
	STD_CODE,
	STD_NAME,
	STEELCODE,
	STEELNAME,
	STD_STYLE,
	STD_STYLE_DESC,
	MODEL_CODE,
	MODEL_DESC,
	ORDER_SPEC_CODE,
	ORDER_SPEC_DESC,
	SPEC_CODE,
	SPEC_NAME,
	DIMATER,
	HEIGHT,
	LEN_NO,
	LEN_DESC,
	LEN_UNIT,
	OUTS_BILLET_FL,
	OUTS_STL_PIPE_FL,
	MNY_ASK_DESC,
	ISLOCK,
	PRDCR_DESC,
	MPS_DESC,
	STLMT_UNIT_NO,
	STLMT_UNIT_NM,
	DELVRY_RANGE_TPE,
	DELVRY_RANGE_MIN,
	DELVRY_RANGE_MAX,
	ADD_ASK_NO,
	ORDER_ADD_DESC,
	ORDER_SPECIAL_DESC,
	ORDER_STS,
	ORDER_STS_DESC,
	ORDER_LN_STS,
	ORDER_LN_STS_DESC,
	SUPPLY_UNIT_CODE,
	SUPPLY_UNIT,
	WGT_ESTMT,
	DELVRY_EDATE,
	EFFECT_TIME,
	TIBAO_TIME,
	CREATE_TIME,
	CREATE_NAME,
    FST_DRAWEE_UNIT,DATA_FLAG,BALNCE_PRICE_STS,KEEP_TYPE,
	ORDER_HEAD_STS,
    ORDER_HEAD_STS_DESC)

	SELECT   H.ORD_PK,
		L.ORD_LN_PK,
		D.ORD_LN_DLY_PK,
		H.ORDER_NO,
		L.ORDER_SEQ,
		D.DELIVERY_NO,
		H.CUSTM_ORDER_NO,
		H.ORDER_TYP,
		H.ORDER_TYP_DESC,
		C.REGION_NO,
		(SELECT T.REGION_NM FROM SEL_ADMIN_REGION T WHERE T.REGION_NO=C.REGION_NO) REGION_NAME,
		H.SALE_ORG,
		H.SALE_ORG_DESC,
		H.SALE_AREA_NO,
		H.SALE_AREA_DESC,
		H.CUSTOMER_NO,
		H.CUSTOMER_NM,
		D.RECEIV_NO,
		D.RECEIV_NM,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.PRICE_FL) PRICE_FL,
		D.DELVRY_QTY ORDER_QTY,
		L.BALNCE_PRICE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.CURRENCY) CURRENCY,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.MNY_ASK_TYP) MNY_ASK_TYP,
		H.CONTAIN_TAX,
		D.ORDER_UNIT,
		L.PRODUCCODE,
		L.PRODUCNAME,
		L.STD_CODE,
		L.STD_NAME,
		L.STEELCODE,
		L.STEELNAME,
		L.STD_STYLE,
		L.STD_STYLE_DESC,
		L.MODEL_CODE,
		L.MODEL_DESC,
		L.ORDER_SPEC_CODE,
		L.ORDER_SPEC_DESC,
		L.SPEC_CODE,
		L.SPEC_NAME,
		L.DIMATER,
		L.HEIGHT,
		L.LEN_NO,
		L.LEN_DESC,
		L.LEN_UNIT,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_BILLET_FL) OUTS_BILLET_FL,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
		H.MNY_ASK_DESC,
		L.ISLOCK,
		L.PRDCR_DESC,
		L.MPS_DESC,
		H.STLMT_UNIT_NO,
		H.STLMT_UNIT_NM,
		L.DELVRY_RANGE_TPE,
		L.DELVRY_RANGE_MIN,
		L.DELVRY_RANGE_MAX,
		L.ADD_ASK_NO,
		L.ORDER_ADD_DESC,
		L.ORDER_SPECIAL_DESC,
		D.DELIVERY_STATUS ORDER_STS,
        (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=D.DELIVERY_STATUS) ORDER_STS_DESC,
        L.ORDER_LN_STATUS ORDER_LN_STS,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.ORDER_LN_STATUS) ORDER_LN_STS_DESC,
		H.SUPPLY_UNIT SUPPLY_UNIT_CODE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.SUPPLY_UNIT) SUPPLY_UNIT,
		D.WGT_ESTMT,
		D.DELVRY_EDATE,
		H.EFFECT_TIME,
		(SELECT T.CREATE_TIME FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK=D.ORD_LN_DLY_PK) TIBAO_TIME,
		SYSDATE,
		H.CREATE_NAME,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
		'1',L.BALNCE_PRICE_STS,DECODE(l.KEEP_TYPE,'0','保单价','1','保总价') KEEP_TYPE,
		H.ORDER_STS ORDER_HEAD_STS,
        H.ORDER_STS_DESC ORDER_HEAD_STS_DESC
		FROM SLM_ORDER_HEAD H,SLM_ORDER_LINE L ,SLM_ORDER_LINE_DELIVERY D,
		SLM_BASE_CUSTOMER C
		WHERE H.ORD_PK=L.ORD_PK AND L.ORD_LN_PK=D.ORD_LN_PK
		AND H.CUSTOMER_NO=C.CUSTOMER_NO
		AND H.ORD_PK = ?
    	AND L.ORD_LN_PK = ?
		]]>
    </query>

    <query id="CrmSlmOrder.insertOrdLnToCrmOrder" desc="新增合同行">
        <![CDATA[
	 	INSERT INTO CRM_SLM_ORDER
  (	ORD_PK,
	ORD_LN_PK,
	ORD_LN_DLY_PK,
	ORDER_NO,
	ORDER_SEQ,
	DELIVERY_NO,
	CUSTM_ORDER_NO,
	ORDER_TYP,
	ORDER_TYP_DESC,
	REGION_NO,
	REGION_NAME,
	SALE_ORG,
	SALE_ORG_DESC,
	SALE_AREA_NO,
	SALE_AREA_DESC,
	CUSTOMER_NO,
	CUSTOMER_NM,
	RECEIV_NO,
	RECEIV_NM,
	PRICE_FL,
	ORDER_QTY,
	BALNCE_PRICE,
	CURRENCY,
	MNY_ASK_TYP,
	CONTAIN_TAX,
	ORDER_UNIT,
	PRODUCCODE,
	PRODUCNAME,
	STD_CODE,
	STD_NAME,
	STEELCODE,
	STEELNAME,
	STD_STYLE,
	STD_STYLE_DESC,
	MODEL_CODE,
	MODEL_DESC,
	ORDER_SPEC_CODE,
	ORDER_SPEC_DESC,
	SPEC_CODE,
	SPEC_NAME,
	DIMATER,
	HEIGHT,
	LEN_NO,
	LEN_DESC,
	LEN_UNIT,
	OUTS_BILLET_FL,
	OUTS_STL_PIPE_FL,
	MNY_ASK_DESC,
	ISLOCK,
	PRDCR_DESC,
	MPS_DESC,
	STLMT_UNIT_NO,
	STLMT_UNIT_NM,
	DELVRY_RANGE_TPE,
	DELVRY_RANGE_MIN,
	DELVRY_RANGE_MAX,
	ADD_ASK_NO,
	ORDER_ADD_DESC,
	ORDER_SPECIAL_DESC,
	ORDER_STS,
	ORDER_STS_DESC,
	ORDER_LN_STS,
	ORDER_LN_STS_DESC,
	SUPPLY_UNIT_CODE,
	SUPPLY_UNIT,
	WGT_ESTMT,
	DELVRY_EDATE,
	EFFECT_TIME,
	TIBAO_TIME,
	DATA_STATUS,
	CREATE_TIME,
	CREATE_NAME,FST_DRAWEE_UNIT,DATA_FLAG,BALNCE_PRICE_STS,KEEP_TYPE,
	ORDER_HEAD_STS,
    ORDER_HEAD_STS_DESC)

	SELECT   H.ORD_PK,
		L.ORD_LN_PK,
		D.ORD_LN_DLY_PK,
		H.ORDER_NO,
		L.ORDER_SEQ,
		D.DELIVERY_NO,
		H.CUSTM_ORDER_NO,
		H.ORDER_TYP,
		H.ORDER_TYP_DESC,
		C.REGION_NO,
		(SELECT T.REGION_NM FROM SEL_ADMIN_REGION T WHERE T.REGION_NO=C.REGION_NO) REGION_NAME,
		H.SALE_ORG,
		H.SALE_ORG_DESC,
		H.SALE_AREA_NO,
		H.SALE_AREA_DESC,
		H.CUSTOMER_NO,
		H.CUSTOMER_NM,
		D.RECEIV_NO,
		D.RECEIV_NM,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.PRICE_FL) PRICE_FL,
		D.DELVRY_QTY ORDER_QTY,
		L.BALNCE_PRICE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.CURRENCY) CURRENCY,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.MNY_ASK_TYP) MNY_ASK_TYP,
		H.CONTAIN_TAX,
		D.ORDER_UNIT,
		L.PRODUCCODE,
		L.PRODUCNAME,
		L.STD_CODE,
		L.STD_NAME,
		L.STEELCODE,
		L.STEELNAME,
		L.STD_STYLE,
		L.STD_STYLE_DESC,
		L.MODEL_CODE,
		L.MODEL_DESC,
		L.ORDER_SPEC_CODE,
		L.ORDER_SPEC_DESC,
		L.SPEC_CODE,
		L.SPEC_NAME,
		L.DIMATER,
		L.HEIGHT,
		L.LEN_NO,
		L.LEN_DESC,
		L.LEN_UNIT,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_BILLET_FL) OUTS_BILLET_FL,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
		H.MNY_ASK_DESC,
		L.ISLOCK,
		L.PRDCR_DESC,
		L.MPS_DESC,
		H.STLMT_UNIT_NO,
		H.STLMT_UNIT_NM,
		L.DELVRY_RANGE_TPE,
		L.DELVRY_RANGE_MIN,
		L.DELVRY_RANGE_MAX,
		L.ADD_ASK_NO,
		L.ORDER_ADD_DESC,
		L.ORDER_SPECIAL_DESC,
		D.DELIVERY_STATUS ORDER_STS,
        (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=D.DELIVERY_STATUS) ORDER_STS_DESC,
		L.ORDER_LN_STATUS ORDER_LN_STS,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.ORDER_LN_STATUS) ORDER_LN_STS_DESC,
		H.SUPPLY_UNIT SUPPLY_UNIT_CODE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.SUPPLY_UNIT) SUPPLY_UNIT,
		D.WGT_ESTMT,
		D.DELVRY_EDATE,
		H.EFFECT_TIME,
		(SELECT T.CREATE_TIME FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK=D.ORD_LN_DLY_PK) TIBAO_TIME,
		?,
		SYSDATE,
		H.CREATE_NAME,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
		'1',L.BALNCE_PRICE_STS,DECODE(l.KEEP_TYPE,'0','保单价','1','保总价') KEEP_TYPE,
		H.ORDER_STS ORDER_HEAD_STS,
        H.ORDER_STS_DESC ORDER_HEAD_STS_DESC
		FROM SLM_ORDER_HEAD H,SLM_ORDER_LINE L ,SLM_ORDER_LINE_DELIVERY D,
		SLM_BASE_CUSTOMER C
		WHERE H.ORD_PK=L.ORD_PK AND L.ORD_LN_PK=D.ORD_LN_PK
		AND H.CUSTOMER_NO=C.CUSTOMER_NO
		AND H.ORD_PK = ?
    	AND L.ORD_LN_PK = ?
		]]>
    </query>

    <query id="CrmSlmOrder.updateOrdLnToCrmOrder" desc="修改合同行">
        UPDATE CRM_SLM_ORDER T
        SET
        ORD_PK = '#ORD_PK#',
        ORD_LN_PK = '#ORD_LN_PK#',
        ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#',
        ORDER_NO = '#ORDER_NO#',
        ORDER_SEQ = '#ORDER_SEQ#',
        DELIVERY_NO = '#DELIVERY_NO#',
        CUSTM_ORDER_NO = '#CUSTM_ORDER_NO#',
        ORDER_TYP = '#ORDER_TYP#',
        ORDER_TYP_DESC = '#ORDER_TYP_DESC#',
        REGION_NO = '#REGION_NO#',
        REGION_NAME = '#REGION_NAME#',
        SALE_ORG = '#SALE_ORG#',
        SALE_ORG_DESC = '#SALE_ORG_DESC#',
        SALE_AREA_NO = '#SALE_AREA_NO#',
        SALE_AREA_DESC = '#SALE_AREA_DESC#',
        CUSTOMER_NO = '#CUSTOMER_NO#',
        CUSTOMER_NM = '#CUSTOMER_NM#',
        RECEIV_NO = '#RECEIV_NO#',
        RECEIV_NM = '#RECEIV_NM#',
        PRICE_FL = '#PRICE_FL#',
        ORDER_QTY = '#ORDER_QTY#',
        BALNCE_PRICE = '#BALNCE_PRICE#',
        CURRENCY = '#CURRENCY#',
        MNY_ASK_TYP = '#MNY_ASK_TYP#',
        CONTAIN_TAX = '#CONTAIN_TAX#',
        ORDER_UNIT = '#ORDER_UNIT#',
        PRODUCCODE = '#PRODUCCODE#',
        PRODUCNAME = '#PRODUCNAME#',
        STD_CODE = '#STD_CODE#',
        STD_NAME = '#STD_NAME#',
        STEELCODE = '#STEELCODE#',
        STEELNAME = '#STEELNAME#',
        STD_STYLE = '#STD_STYLE#',
        STD_STYLE_DESC = '#STD_STYLE_DESC#',
        MODEL_CODE = '#MODEL_CODE#',
        MODEL_DESC = '#MODEL_DESC#',
        ORDER_SPEC_CODE = '#ORDER_SPEC_CODE#',
        ORDER_SPEC_DESC = '#ORDER_SPEC_DESC#',
        SPEC_CODE = '#SPEC_CODE#',
        SPEC_NAME = '#SPEC_NAME#',
        DIMATER = '#DIMATER#',
        HEIGHT = '#HEIGHT#',
        LEN_NO = '#LEN_NO#',
        LEN_DESC = '#LEN_DESC#',
        LEN_UNIT = '#LEN_UNIT#',
        OUTS_BILLET_FL = '#OUTS_BILLET_FL#',
        OUTS_STL_PIPE_FL = '#OUTS_STL_PIPE_FL#',
        MNY_ASK_DESC = '#MNY_ASK_DESC#',
        ISLOCK = '#ISLOCK#',
        PRDCR_DESC = '#PRDCR_DESC#',
        MPS_DESC = '#MPS_DESC#',
        STLMT_UNIT_NO = '#STLMT_UNIT_NO#',
        STLMT_UNIT_NM = '#STLMT_UNIT_NM#',
        DELVRY_RANGE_TPE = '#DELVRY_RANGE_TPE#',
        DELVRY_RANGE_MIN = '#DELVRY_RANGE_MIN#',
        DELVRY_RANGE_MAX = '#DELVRY_RANGE_MAX#',
        ADD_ASK_NO = '#ADD_ASK_NO#',
        ORDER_ADD_DESC = '#ORDER_ADD_DESC#',
        ORDER_SPECIAL_DESC = '#ORDER_SPECIAL_DESC#',
        ORDER_STS = '#ORDER_STS#',
        ORDER_STS_DESC = '#ORDER_STS_DESC#',
        SUPPLY_UNIT_CODE = '#SUPPLY_UNIT_CODE#',
        SUPPLY_UNIT = '#SUPPLY_UNIT#',
        WGT_ESTMT = '#WGT_ESTMT#',
        DELVRY_EDATE = TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
        EFFECT_TIME = TO_DATE('#EFFECT_TIME#','YYYY-MM-DD'),
        TIBAO_TIME = TO_DATE('#TIBAO_TIME#','YYYY-MM-DD'),
        DATA_STATUS = '#DATA_STATUS#',
        IS_FLAG = '0'
        WHERE
        ORD_PK = '#ORD_PK#'
        AND ORD_LN_PK = '#ORD_LN_PK#'
        AND ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
    </query>

    <query id="CrmSlmOrder.updateOrdToCrmOrder" desc="修改合同头">
        UPDATE CRM_SLM_ORDER T
        SET
        ORD_PK = '#ORD_PK#',
        ORD_LN_PK = '#ORD_LN_PK#',
        ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#',
        ORDER_NO = '#ORDER_NO#',
        ORDER_SEQ = '#ORDER_SEQ#',
        DELIVERY_NO = '#DELIVERY_NO#',
        CUSTM_ORDER_NO = '#CUSTM_ORDER_NO#',
        ORDER_TYP = '#ORDER_TYP#',
        ORDER_TYP_DESC = '#ORDER_TYP_DESC#',
        REGION_NO = '#REGION_NO#',
        REGION_NAME = '#REGION_NAME#',
        SALE_ORG = '#SALE_ORG#',
        SALE_ORG_DESC = '#SALE_ORG_DESC#',
        SALE_AREA_NO = '#SALE_AREA_NO#',
        SALE_AREA_DESC = '#SALE_AREA_DESC#',
        CUSTOMER_NO = '#CUSTOMER_NO#',
        CUSTOMER_NM = '#CUSTOMER_NM#',
        RECEIV_NO = '#RECEIV_NO#',
        RECEIV_NM = '#RECEIV_NM#',
        PRICE_FL = '#PRICE_FL#',
        ORDER_QTY = '#ORDER_QTY#',
        BALNCE_PRICE = '#BALNCE_PRICE#',
        CURRENCY = '#CURRENCY#',
        MNY_ASK_TYP = '#MNY_ASK_TYP#',
        CONTAIN_TAX = '#CONTAIN_TAX#',
        ORDER_UNIT = '#ORDER_UNIT#',
        PRODUCCODE = '#PRODUCCODE#',
        PRODUCNAME = '#PRODUCNAME#',
        STD_CODE = '#STD_CODE#',
        STD_NAME = '#STD_NAME#',
        STEELCODE = '#STEELCODE#',
        STEELNAME = '#STEELNAME#',
        STD_STYLE = '#STD_STYLE#',
        STD_STYLE_DESC = '#STD_STYLE_DESC#',
        MODEL_CODE = '#MODEL_CODE#',
        MODEL_DESC = '#MODEL_DESC#',
        ORDER_SPEC_CODE = '#ORDER_SPEC_CODE#',
        ORDER_SPEC_DESC = '#ORDER_SPEC_DESC#',
        SPEC_CODE = '#SPEC_CODE#',
        SPEC_NAME = '#SPEC_NAME#',
        DIMATER = '#DIMATER#',
        HEIGHT = '#HEIGHT#',
        LEN_NO = '#LEN_NO#',
        LEN_DESC = '#LEN_DESC#',
        LEN_UNIT = '#LEN_UNIT#',
        OUTS_BILLET_FL = '#OUTS_BILLET_FL#',
        OUTS_STL_PIPE_FL = '#OUTS_STL_PIPE_FL#',
        MNY_ASK_DESC = '#MNY_ASK_DESC#',
        ISLOCK = '#ISLOCK#',
        PRDCR_DESC = '#PRDCR_DESC#',
        MPS_DESC = '#MPS_DESC#',
        STLMT_UNIT_NO = '#STLMT_UNIT_NO#',
        STLMT_UNIT_NM = '#STLMT_UNIT_NM#',
        DELVRY_RANGE_TPE = '#DELVRY_RANGE_TPE#',
        DELVRY_RANGE_MIN = '#DELVRY_RANGE_MIN#',
        DELVRY_RANGE_MAX = '#DELVRY_RANGE_MAX#',
        ADD_ASK_NO = '#ADD_ASK_NO#',
        ORDER_ADD_DESC = '#ORDER_ADD_DESC#',
        ORDER_SPECIAL_DESC = '#ORDER_SPECIAL_DESC#',
        ORDER_STS = '#ORDER_STS#',
        ORDER_STS_DESC = '#ORDER_STS_DESC#',
        SUPPLY_UNIT_CODE = '#SUPPLY_UNIT_CODE#',
        SUPPLY_UNIT = '#SUPPLY_UNIT#',
        WGT_ESTMT = '#WGT_ESTMT#',
        DELVRY_EDATE = TO_DATE('#DELVRY_EDATE#','YYYY-MM-DD'),
        EFFECT_TIME = TO_DATE('#EFFECT_TIME#','YYYY-MM-DD'),
        TIBAO_TIME = TO_DATE('#TIBAO_TIME#','YYYY-MM-DD'),
        DATA_STATUS = '#DATA_STATUS#',
        IS_FLAG='0'
        WHERE
        ORD_PK = '#ORD_PK#'
        AND ORD_LN_PK = '#ORD_LN_PK#'
        AND ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
    </query>

    <query id="CrmSlmOrder.insertOrdToCrmOrder" desc="修改合同头">
        <![CDATA[
	 	INSERT INTO CRM_SLM_ORDER
  (	ORD_PK,
	ORD_LN_PK,
	ORD_LN_DLY_PK,
	ORDER_NO,
	ORDER_SEQ,
	DELIVERY_NO,
	CUSTM_ORDER_NO,
	ORDER_TYP,
	ORDER_TYP_DESC,
	REGION_NO,
	REGION_NAME,
	SALE_ORG,
	SALE_ORG_DESC,
	SALE_AREA_NO,
	SALE_AREA_DESC,
	CUSTOMER_NO,
	CUSTOMER_NM,
	RECEIV_NO,
	RECEIV_NM,
	PRICE_FL,
	ORDER_QTY,
	BALNCE_PRICE,
	CURRENCY,
	MNY_ASK_TYP,
	CONTAIN_TAX,
	ORDER_UNIT,
	PRODUCCODE,
	PRODUCNAME,
	STD_CODE,
	STD_NAME,
	STEELCODE,
	STEELNAME,
	STD_STYLE,
	STD_STYLE_DESC,
	MODEL_CODE,
	MODEL_DESC,
	ORDER_SPEC_CODE,
	ORDER_SPEC_DESC,
	SPEC_CODE,
	SPEC_NAME,
	DIMATER,
	HEIGHT,
	LEN_NO,
	LEN_DESC,
	LEN_UNIT,
	OUTS_BILLET_FL,
	OUTS_STL_PIPE_FL,
	MNY_ASK_DESC,
	ISLOCK,
	PRDCR_DESC,
	MPS_DESC,
	STLMT_UNIT_NO,
	STLMT_UNIT_NM,
	DELVRY_RANGE_TPE,
	DELVRY_RANGE_MIN,
	DELVRY_RANGE_MAX,
	ADD_ASK_NO,
	ORDER_ADD_DESC,
	ORDER_SPECIAL_DESC,
	ORDER_STS,
	ORDER_STS_DESC,
	ORDER_LN_STS,
	ORDER_LN_STS_DESC,
	SUPPLY_UNIT_CODE,
	SUPPLY_UNIT,
	WGT_ESTMT,
	DELVRY_EDATE,
	EFFECT_TIME,
	TIBAO_TIME,
	DATA_STATUS,
	CREATE_TIME,
	FST_DRAWEE_UNIT,DATA_FLAG,BALNCE_PRICE_STS,KEEP_TYPE,
	ORDER_HEAD_STS,
    ORDER_HEAD_STS_DESC)

	SELECT   H.ORD_PK,
		L.ORD_LN_PK,
		D.ORD_LN_DLY_PK,
		H.ORDER_NO,
		L.ORDER_SEQ,
		D.DELIVERY_NO,
		H.CUSTM_ORDER_NO,
		H.ORDER_TYP,
		H.ORDER_TYP_DESC,
		C.REGION_NO,
		(SELECT T.REGION_NM FROM SEL_ADMIN_REGION T WHERE T.REGION_NO=C.REGION_NO) REGION_NAME,
		H.SALE_ORG,
		H.SALE_ORG_DESC,
		H.SALE_AREA_NO,
		H.SALE_AREA_DESC,
		H.CUSTOMER_NO,
		H.CUSTOMER_NM,
		D.RECEIV_NO,
		D.RECEIV_NM,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.PRICE_FL) PRICE_FL,
		D.DELVRY_QTY ORDER_QTY,
		L.BALNCE_PRICE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.CURRENCY) CURRENCY,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.MNY_ASK_TYP) MNY_ASK_TYP,
		H.CONTAIN_TAX,
		D.ORDER_UNIT,
		L.PRODUCCODE,
		L.PRODUCNAME,
		L.STD_CODE,
		L.STD_NAME,
		L.STEELCODE,
		L.STEELNAME,
		L.STD_STYLE,
		L.STD_STYLE_DESC,
		L.MODEL_CODE,
		L.MODEL_DESC,
		L.ORDER_SPEC_CODE,
		L.ORDER_SPEC_DESC,
		L.SPEC_CODE,
		L.SPEC_NAME,
		L.DIMATER,
		L.HEIGHT,
		L.LEN_NO,
		L.LEN_DESC,
		L.LEN_UNIT,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_BILLET_FL) OUTS_BILLET_FL,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.OUTS_STL_PIPE_FL) OUTS_STL_PIPE_FL,
		H.MNY_ASK_DESC,
		L.ISLOCK,
		L.PRDCR_DESC,
		L.MPS_DESC,
		H.STLMT_UNIT_NO,
		H.STLMT_UNIT_NM,
		L.DELVRY_RANGE_TPE,
		L.DELVRY_RANGE_MIN,
		L.DELVRY_RANGE_MAX,
		L.ADD_ASK_NO,
		L.ORDER_ADD_DESC,
		L.ORDER_SPECIAL_DESC,
		D.DELIVERY_STATUS ORDER_STS,
        (SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=D.DELIVERY_STATUS) ORDER_STS_DESC,
        L.ORDER_LN_STATUS ORDER_LN_STS,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=L.ORDER_LN_STATUS) ORDER_LN_STS_DESC,
		H.SUPPLY_UNIT SUPPLY_UNIT_CODE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.SUPPLY_UNIT) SUPPLY_UNIT,
		D.WGT_ESTMT,
		D.DELVRY_EDATE,
		H.EFFECT_TIME,
		(SELECT T.CREATE_TIME FROM PLN_SALEORD T WHERE T.ORD_LN_DLY_PK=D.ORD_LN_DLY_PK) TIBAO_TIME,
		1,
		SYSDATE,
		(SELECT T.BASENAME FROM COM_BASE_INFO T WHERE T.BASECODE=H.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
		'0',L.BALNCE_PRICE_STS,DECODE(l.KEEP_TYPE,'0','保单价','1','保总价') KEEP_TYPE,
		H.ORDER_STS ORDER_HEAD_STS,
        H.ORDER_STS_DESC ORDER_HEAD_STS_DESC
		FROM SLM_ORDER_HEAD H,SLM_ORDER_LINE L ,SLM_ORDER_LINE_DELIVERY D,
		SLM_BASE_CUSTOMER C
		WHERE H.ORD_PK=L.ORD_PK AND L.ORD_LN_PK=D.ORD_LN_PK
		AND H.CUSTOMER_NO=C.CUSTOMER_NO
    	AND ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
		]]>
    </query>
</queryMap>